WPSEO_Replace_Vars::retrieve_focuskw()privateYoast 1.0

Retrieve the post/page/cpt's focus keyword for use as replacement string.

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

Хуков нет.

Возвращает

Строку|null.

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

// private - только в коде основоного (родительского) класса
$result = $this->retrieve_focuskw();

Код WPSEO_Replace_Vars::retrieve_focuskw() Yoast 22.4

private function retrieve_focuskw() {
	// Retrieve focuskw from a Post.
	if ( ! empty( $this->args->ID ) ) {
		$focus_kw = WPSEO_Meta::get_value( 'focuskw', $this->args->ID );
		if ( $focus_kw !== '' ) {
			return $focus_kw;
		}

		return null;
	}

	// Retrieve focuskw from a Term.
	if ( ! empty( $this->args->term_id ) ) {
		$focus_kw = WPSEO_Taxonomy_Meta::get_term_meta( $this->args->term_id, $this->args->taxonomy, 'focuskw' );
		if ( $focus_kw !== '' ) {
			return $focus_kw;
		}
	}

	return null;
}