Yoast\WP\SEO\Abilities\Infrastructure

Post_Identifier_Resolver::resolve_many │ public │ Yoast 1.0

Resolves the input to all matching post indexables.

Used by the read path. A title search may match several posts; with no identifier at all, an error is returned.

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

Хуков нет.

Возвращает

Indexable[]|WP_Error. The matching indexables, or an error for a missing or unknown id/permalink.

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

$Post_Identifier_Resolver = new Post_Identifier_Resolver();
$Post_Identifier_Resolver->resolve_many( $input );
$input(array<string, int|строка|true|false|null>) (обязательный)
The input containing a 'post_id', 'permalink', or 'title', plus an optional 'page' for a title search.

Код Post_Identifier_Resolver::resolve_many() Yoast 28.9

public function resolve_many( array $input ) {
	if ( $this->has( $input, 'post_id' ) ) {
		$indexable = $this->by_id( (int) $input['post_id'] );

		return ( $indexable instanceof WP_Error ) ? $indexable : [ $indexable ];
	}

	if ( $this->has( $input, 'permalink' ) ) {
		$indexable = $this->by_permalink( (string) $input['permalink'] );

		return ( $indexable instanceof WP_Error ) ? $indexable : [ $indexable ];
	}

	if ( $this->has( $input, 'title' ) ) {
		$page = ( isset( $input['page'] ) ) ? (int) $input['page'] : 1;

		return $this->by_title( (string) $input['title'], $page );
	}

	return new WP_Error(
		'yoast_seo_missing_identifier',
		\__( 'Provide a post_id, a permalink, or title keywords to identify the post.', 'wordpress-seo' ),
		[ 'status' => 400 ],
	);
}