Automattic\WooCommerce\Internal\EmailEditor
EmailApiController::get_default_content_response
Return the default (plugin-distributed) block content for a woo_email post.
Method of the class: EmailApiController{}
No Hooks.
Returns
WP_REST_Response|WP_Error.
Usage
$EmailApiController = new EmailApiController(); $EmailApiController->get_default_content_response( $request );
- $request(WP_REST_Request) (required)
- The REST request.
EmailApiController::get_default_content_response() EmailApiController::get default content response code WC 10.7.0
public function get_default_content_response( WP_REST_Request $request ) {
if ( ! ( $this->post_manager && $this->posts_generator ) ) {
return new WP_Error(
'woocommerce_email_editor_not_initialized',
__( 'Email editor is not initialized.', 'woocommerce' ),
array( 'status' => 500 )
);
}
$post_id = (int) $request->get_param( 'id' );
$email_type = $this->post_manager->get_email_type_from_post_id( $post_id );
$email = $this->get_email_by_type( $email_type ?? '' );
if ( ! $email ) {
return new WP_Error(
'woocommerce_email_not_found',
__( 'No email found for the given post ID.', 'woocommerce' ),
array( 'status' => 404 )
);
}
return new WP_REST_Response(
array( 'content' => $this->posts_generator->get_email_template( $email ) ),
200
);
}