Yoast\WP\SEO\Actions\Wincher

Wincher_Keyphrases_Action::collect_keyphrases_from_post()publicYoast 1.0

Collects the keyphrases associated with the post.

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

Хуки из метода

Возвращает

Массив. The keyphrases.

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

$Wincher_Keyphrases_Action = new Wincher_Keyphrases_Action();
$Wincher_Keyphrases_Action->collect_keyphrases_from_post( $post );
$post(WP_Post) (обязательный)
The post object.

Код Wincher_Keyphrases_Action::collect_keyphrases_from_post() Yoast 19.11

public function collect_keyphrases_from_post( $post ) {
	$keyphrases        = [];
	$primary_keyphrase = $this->indexable_repository
		->query()
		->select( 'primary_focus_keyword' )
		->where( 'object_id', $post->ID )
		->find_one();

	if ( $primary_keyphrase ) {
		$keyphrases[] = $primary_keyphrase->primary_focus_keyword;
	}

	/**
	 * Filters the keyphrases collected by the Wincher integration from the post.
	 *
	 * @param array $keyphrases The keyphrases array.
	 * @param int   $post_id    The ID of the post.
	 */
	return \apply_filters( 'wpseo_wincher_keyphrases_from_post', $keyphrases, $post->ID );
}