Yoast\WP\SEO\Actions

Indexables_Page_Action::get_setup_info()publicYoast 1.0

Устарела с версии 20.4. Больше не поддерживается и может быть удалена. Рекомендуется заменить эту функцию на аналог.

Gets the neccessary information to set up the indexables page.

Метод класса: Indexables_Page_Action{}

Хуков нет.

Возвращает

Массив. The neccessary information to set up the indexables page.

Использование

$Indexables_Page_Action = new Indexables_Page_Action();
$Indexables_Page_Action->get_setup_info( $content_threshold, $analysis_threshold );
$content_threshold(int) (обязательный)
The threshold to check against for enough content.
$analysis_threshold(int) (обязательный)
The threshold to check against for enough analyzed content.

Список изменений

Устарела с 20.4

Код Indexables_Page_Action::get_setup_info() Yoast 22.4

public function get_setup_info( $content_threshold, $analysis_threshold ) {
	\_deprecated_function( __METHOD__, 'Yoast SEO 20.4' );

	$features = [
		'isSeoScoreEnabled'    => $this->options_helper->get( 'keyword_analysis_active', true ),
		'isReadabilityEnabled' => $this->options_helper->get( 'content_analysis_active', true ),
		'isLinkCountEnabled'   => $this->options_helper->get( 'enable_text_link_counter', true ),
	];

	$posts_with_seo_score    = 0;
	$posts_with_readability  = 0;
	$posts_without_keyphrase = [];

	$all_posts = $this->query()->count();

	if ( $all_posts < 1 ) {
		$this->set_indexables_state( 'no-content' );
		return [
			'enabledFeatures'       => $features,
			'enoughContent'         => false,
			'enoughAnalysedContent' => false,
		];
	}

	$posts_with_seo_score = $this->query()
		->where_not_equal( 'primary_focus_keyword', 0 )
		->count();

	$posts_without_keyphrase = $this->query()
		->where_null( 'primary_focus_keyword' )
		->order_by_desc( 'incoming_link_count' )
		->find_many();

	$posts_with_readability = $this->query()
		->where_not_equal( 'readability_score', 0 )
		->count();

	$analysed_content = ( \max( $posts_with_seo_score, $posts_with_readability ) / $all_posts );

	$enough_content          = $all_posts > $content_threshold;
	$enough_analysed_content = $analysed_content > $analysis_threshold;

	if ( ! $enough_content ) {
		$this->set_indexables_state( 'not-enough-content' );
	}
	elseif ( ! $enough_analysed_content ) {
		$this->set_indexables_state( 'not-enough-analysed-content' );
	}
	else {
		$this->set_indexables_state( 'lists-shown' );
	}

	return [
		'enabledFeatures'       => $features,
		'enoughContent'         => $enough_content,
		'enoughAnalysedContent' => $enough_analysed_content,
		'postsWithoutKeyphrase' => \array_map(
			static function ( $indexable ) {
				$output = $indexable;
				if ( $indexable->incoming_link_count === null ) {
					$output->incoming_link_count = 0;
				}
				return $output;
			},
			$posts_without_keyphrase
		),
	];
}