Yoast\WP\SEO\Bulk_Editor\User_Interface

Posts_Route::register_routes │ public │ Yoast 1.0

Registers routes with WordPress.

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

Хуки из метода

Возвращает

void. Ничего (null).

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

$Posts_Route = new Posts_Route();
$Posts_Route->register_routes();

Код Posts_Route::register_routes() Yoast 28.9

public function register_routes() {
	\register_rest_route(
		self::ROUTE_NAMESPACE,
		self::ROUTE_PREFIX,
		[
			'methods'             => 'GET',
			'args'                => [
				'content_type'      => [
					'required'          => true,
					'type'              => 'string',
					'description'       => 'The content type to fetch posts for.',
					'sanitize_callback' => 'sanitize_text_field',
				],
				'per_page'          => [
					'required'          => false,
					'type'              => 'integer',
					'default'           => self::DEFAULT_PER_PAGE,
					'minimum'           => 1,
					'maximum'           => self::MAX_PER_PAGE,
					'description'       => 'The number of posts to fetch.',
					'sanitize_callback' => 'absint',
				],
				'page'              => [
					'required'          => false,
					'type'              => 'integer',
					'default'           => 1,
					'minimum'           => 1,
					'description'       => 'The page of posts to fetch.',
					'sanitize_callback' => 'absint',
				],
				'search'            => [
					'required'          => false,
					'type'              => 'string',
					'default'           => '',
					'description'       => 'The term to search posts by.',
					'sanitize_callback' => 'sanitize_text_field',
				],
				'status'            => [
					'required'    => false,
					'type'        => 'array',
					'default'     => Posts_Collector_Interface::STATUSES,
					'items'       => [
						'type' => 'string',
						'enum' => Posts_Collector_Interface::STATUSES,
					],
					'description' => 'The post statuses to include.',
				],
				'needs_improvement' => [
					'required'    => false,
					'type'        => 'array',
					'default'     => [],
					'items'       => [
						'type' => 'string',
						'enum' => \apply_filters( 'wpseo_bulk_editor_needs_improvement_fields', Posts_Collector_Interface::NEEDS_IMPROVEMENT_FIELDS ),
					],
					'description' => 'The fields to filter posts by; a field matches when it is empty, or (for search fields, while SEO analysis is enabled and the content type shows Yoast\'s controls and assessments) when its score needs improvement.',
				],
				'include'           => [
					'required'    => false,
					'type'        => 'array',
					'default'     => [],
					'maxItems'    => self::MAX_PER_PAGE,
					'items'       => [
						'type'    => 'integer',
						'minimum' => 1,
					],
					'description' => 'Limits the posts to these post IDs, e.g. a selection carried over from the posts overview.',
				],
			],
			'callback'            => [ $this, 'get_posts' ],
			'permission_callback' => [ $this, 'check_permissions' ],
		],
	);
}