Automattic\WooCommerce\EmailEditor\Engine
Email_Editor::register_email_editor_api_routes
Registers the API route endpoint for the email editor
Method of the class: Email_Editor{}
No Hooks.
Returns
null. Nothing (null).
Usage
$Email_Editor = new Email_Editor(); $Email_Editor->register_email_editor_api_routes();
Email_Editor::register_email_editor_api_routes() Email Editor::register email editor api routes code WC 10.7.0
public function register_email_editor_api_routes() {
register_rest_route(
'woocommerce-email-editor/v1',
'/send_preview_email',
array(
'methods' => 'POST',
'callback' => array( $this->email_api_controller, 'send_preview_email_data' ),
'permission_callback' => function ( WP_REST_Request $request ) {
if ( ! current_user_can( 'edit_posts' ) ) {
return false;
}
$post_id = $request->get_param( 'postId' );
if ( ! is_numeric( $post_id ) || (int) $post_id <= 0 ) {
return false;
}
return current_user_can( 'edit_post', (int) $post_id );
},
)
);
register_rest_route(
'woocommerce-email-editor/v1',
'/get_personalization_tags',
array(
'methods' => 'GET',
'callback' => array( $this->email_api_controller, 'get_personalization_tags' ),
'permission_callback' => function () {
return current_user_can( 'edit_posts' );
},
)
);
register_rest_route(
'woocommerce-email-editor/v1',
'/personalization_tags',
array(
'methods' => 'GET',
'callback' => array( $this->email_api_controller, 'get_personalization_tags_collection' ),
'permission_callback' => function () {
return current_user_can( 'edit_posts' );
},
'args' => array(
'post_id' => array(
'description' => __( 'The post ID for context-aware tag filtering.', 'woocommerce' ),
'type' => 'integer',
'required' => false,
'sanitize_callback' => 'absint',
),
),
)
);
}