WP_REST_Attachments_Controller::post_process_item()publicWP 5.3.0

Performs post processing on an attachment.

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

Хуков нет.

Возвращает

WP_REST_Response|WP_Error. Response object on success, WP_Error object on failure.

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

$WP_REST_Attachments_Controller = new WP_REST_Attachments_Controller();
$WP_REST_Attachments_Controller->post_process_item( $request );
$request(WP_REST_Request) (обязательный)
Full details about the request.

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

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

Код WP_REST_Attachments_Controller::post_process_item() WP 6.5.2

public function post_process_item( $request ) {
	switch ( $request['action'] ) {
		case 'create-image-subsizes':
			require_once ABSPATH . 'wp-admin/includes/image.php';
			wp_update_image_subsizes( $request['id'] );
			break;
	}

	$request['context'] = 'edit';

	return $this->prepare_item_for_response( get_post( $request['id'] ), $request );
}