WP_REST_Attachments_Controller::register_routes()publicWP 5.3.0

Registers the routes for attachments.

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

Хуков нет.

Возвращает

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

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

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

Заметки

Список изменений

С версии 5.3.0 Введена.

Код WP_REST_Attachments_Controller::register_routes() WP 6.5.2

public function register_routes() {
	parent::register_routes();
	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/(?P<id>[\d]+)/post-process',
		array(
			'methods'             => WP_REST_Server::CREATABLE,
			'callback'            => array( $this, 'post_process_item' ),
			'permission_callback' => array( $this, 'post_process_item_permissions_check' ),
			'args'                => array(
				'id'     => array(
					'description' => __( 'Unique identifier for the attachment.' ),
					'type'        => 'integer',
				),
				'action' => array(
					'type'     => 'string',
					'enum'     => array( 'create-image-subsizes' ),
					'required' => true,
				),
			),
		)
	);
	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/(?P<id>[\d]+)/edit',
		array(
			'methods'             => WP_REST_Server::CREATABLE,
			'callback'            => array( $this, 'edit_media_item' ),
			'permission_callback' => array( $this, 'edit_media_item_permissions_check' ),
			'args'                => $this->get_edit_media_item_args(),
		)
	);
}