Yoast\WP\SEO\Repositories

Indexable_Repository::find_by_id_and_type()publicYoast 1.0

Retrieves an indexable by its ID and type.

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

Хуков нет.

Возвращает

true|false|Indexable. Instance of indexable.

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

$Indexable_Repository = new Indexable_Repository();
$Indexable_Repository->find_by_id_and_type( $object_id, $object_type, $auto_create );
$object_id(int) (обязательный)
The indexable object ID.
$object_type(строка) (обязательный)
The indexable object type.
$auto_create(true|false)
Create the indexable if it does not exist.
По умолчанию: true

Код Indexable_Repository::find_by_id_and_type() Yoast 24.0

public function find_by_id_and_type( $object_id, $object_type, $auto_create = true ) {
	$indexable = $this->query()
		->where( 'object_id', $object_id )
		->where( 'object_type', $object_type )
		->find_one();

	if ( $auto_create && ! $indexable ) {
		$indexable = $this->builder->build_for_id_and_type( $object_id, $object_type );
	}
	else {
		$indexable = $this->upgrade_indexable( $indexable );
	}

	return $indexable;
}