Yoast\WP\SEO\Actions

Indexables_Page_Action::query()protectedYoast 1.0

Creates a query that can find public indexables.

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

Хуков нет.

Возвращает

ORM. Returns an ORM instance that can be used to execute the query.

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

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

Код Indexables_Page_Action::query() Yoast 19.11

protected function query() {
	$sub_types = $this->get_sub_types();
	if ( empty( $sub_types ) ) {
		// If there are no subtypes to display, any query should return an empty result.
		return $this->indexable_repository->query()->where_raw( '1 = 0' );
	}

	// Make sure that we consider the noindex of both each post but also for the global values.
	$build_where = '(';
	foreach ( $sub_types as $sub_type ) {
		$is_default_noindex = $this->post_type_helper->is_indexable( $sub_type ) ? ' OR is_robots_noindex IS NULL' : '';
		$build_where       .= '( object_sub_type = \'' . $sub_type . '\' AND ( is_robots_noindex = FALSE' . $is_default_noindex . ' ) ) OR';
	}
	$build_where  = rtrim( $build_where, ' OR' );
	$build_where .= ')';

	return $this->indexable_repository->query()
		->where_raw( '( post_status = \'publish\' OR post_status IS NULL )' )
		->where_in( 'object_type', [ 'post' ] )
		->where_raw( $build_where );
}