WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта
функция не описана

Yoast\WP\SEO\Integrations\Watchers

Indexable_Ancestor_Watcher::get_object_ids_for_term() protected Yoast 1.0

Retrieves the object id's for a term based on the term-post relationship.

{} Это метод класса: Indexable_Ancestor_Watcher{}

Хуков нет.

Возвращает

Массив. List with object ids for the term.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_object_ids_for_term( $term_id, $child_indexables );
$term_id(int) (обязательный)
The term to get the object id's for.
$child_indexables(Indexable[]) (обязательный)
The child indexables.

Код Indexable_Ancestor_Watcher::get_object_ids_for_term() Yoast 16.8

<?php
protected function get_object_ids_for_term( $term_id, $child_indexables ) {
	$filter_terms = static function( $child ) {
		return $child->object_type === 'term';
	};

	$child_terms      = \array_filter( $child_indexables, $filter_terms );
	$child_object_ids = \wp_list_pluck( $child_terms, 'object_id' );

	// Get the term-taxonomy id's for the term and its children.
	$term_taxonomy_ids = $this->wpdb->get_col(
		$this->wpdb->prepare(
			'SELECT term_taxonomy_id
			FROM ' . $this->wpdb->term_taxonomy . '
			WHERE term_id IN( ' . \implode( ', ', \array_fill( 0, ( \count( $child_object_ids ) + 1 ), '%s' ) ) . ' )',
			$term_id,
			...$child_object_ids
		)
	);

	// In the case of faulty data having been saved the above query can return 0 results.
	if ( empty( $term_taxonomy_ids ) ) {
		return [];
	}

	// Get the (post) object id's that are attached to the term.
	return $this->wpdb->get_col(
		$this->wpdb->prepare(
			'SELECT DISTINCT object_id
			FROM ' . $this->wpdb->term_relationships . '
			WHERE term_taxonomy_id IN( ' . \implode( ', ', \array_fill( 0, \count( $term_taxonomy_ids ), '%s' ) ) . ' )',
			...$term_taxonomy_ids
		)
	);
}