MailPoet\EmailEditor\Engine\Templates
Templates::register_post_types_to_api()
Register post_types property to the templates rest api response.
There is a PR that adds the property into the core https://github.com/WordPress/wordpress-develop/pull/7530 Until it is merged, we need to add it manually.
Method of the class: Templates{}
No Hooks.
Return
null
. Nothing (null).
Usage
$Templates = new Templates(); $Templates->register_post_types_to_api(): void;
Templates::register_post_types_to_api() Templates::register post types to api code WC 9.8.1
public function register_post_types_to_api(): void { $controller = new \WP_REST_Templates_Controller( 'wp_template' ); $schema = $controller->get_item_schema(); // Future compatibility check if the post_types property is already registered. if ( isset( $schema['properties']['post_types'] ) ) { return; } register_rest_field( 'wp_template', 'post_types', array( 'get_callback' => array( $this, 'get_post_types' ), 'update_callback' => null, 'schema' => Builder::string()->to_array(), ) ); }