Yoast\WP\SEO\Helpers
Score_Icon_Helper::for_seo
Creates a Score_Icon_Presenter for the SEO analysis from an indexable.
Метод класса: Score_Icon_Helper{}
Хуков нет.
Возвращает
Score_Icon_Presenter. The Score_Icon_Presenter.
Использование
$Score_Icon_Helper = new Score_Icon_Helper(); $Score_Icon_Helper->for_seo( $indexable, $extra_class, $no_index_title );
- $indexable(Indexable|false) (обязательный)
- The Indexable.
- $extra_class(строка)
- Any extra class.
По умолчанию:'' - $no_index_title(строка)
- Override the title when not indexable.
По умолчанию:''
Код Score_Icon_Helper::for_seo() Score Icon Helper::for seo Yoast 27.4
public function for_seo( $indexable, $extra_class = '', $no_index_title = '' ) {
$is_indexable = $indexable && $this->robots_helper->is_indexable( $indexable );
if ( ! $is_indexable ) {
$rank = new WPSEO_Rank( WPSEO_Rank::NO_INDEX );
$title = empty( $no_index_title ) ? $rank->get_label() : $no_index_title;
}
elseif ( empty( $indexable && $indexable->primary_focus_keyword ) ) {
$rank = new WPSEO_Rank( WPSEO_Rank::BAD );
$title = \__( 'Focus keyphrase not set', 'wordpress-seo' );
}
else {
$rank = WPSEO_Rank::from_numeric_score( ( $indexable ) ? $indexable->primary_focus_keyword_score : 0 );
$title = $rank->get_label();
}
$class = $rank->get_css_class();
if ( $extra_class ) {
$class .= " $extra_class";
}
return new Score_Icon_Presenter( $title, $class );
}