Yoast\WP\SEO\Abilities\Infrastructure\Global_Setting_Targets

Global_Setting_Target_Repository::get │ public │ Yoast 1.0

Returns a target by its name and, for the archive of a content type, its post type.

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

Хуков нет.

Возвращает

Global_Setting_Target_Interface. The target.

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

$Global_Setting_Target_Repository = new Global_Setting_Target_Repository();
$Global_Setting_Target_Repository->get( $name, $post_type ): Global_Setting_Target_Interface;
$name(строка) (обязательный)
The name of the target.
$post_type(строка) (обязательный)
The post type, for the archive of a content type.

Код Global_Setting_Target_Repository::get() Yoast 28.9

public function get( string $name, string $post_type ): Global_Setting_Target_Interface {
	if ( $name === Post_Type_Archive_Target::NAME ) {
		return $this->post_type_archive_factory->create( $post_type );
	}

	if ( isset( $this->single_targets[ $name ] ) ) {
		return $this->single_targets[ $name ];
	}

	$message = \__( 'The given target is not valid.', 'wordpress-seo' );

	// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- This is an exception message, not output.
	throw new Unavailable_Global_Setting_Target_Exception( 'yoast_seo_invalid_target', $message );
}