Automattic\WooCommerce\Internal\EmailEditor
PageRenderer::render
Render the email editor page.
Method of the class: PageRenderer{}
No Hooks.
Returns
null. Nothing (null).
Usage
$PageRenderer = new PageRenderer(); $PageRenderer->render();
PageRenderer::render() PageRenderer::render code WC 10.4.3
public function render() {
$post_id = isset( $_GET['post'] ) ? intval( $_GET['post'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- We are not verifying the nonce here because we are not using the nonce in the function and the data is okay in this context (WP-admin errors out gracefully).
$template_id = isset( $_GET['template'] ) ? sanitize_text_field( wp_unslash( $_GET['template'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- We are not verifying the nonce here because we are not using the nonce in the function and the data is okay in this context (WP-admin errors out gracefully).
$post_type = $template_id ? 'wp_template' : Integration::EMAIL_POST_TYPE;
$post_id = $template_id ? $template_id : $post_id;
$edited_item = $this->get_edited_item( $post_id, $post_type );
if ( ! $edited_item ) {
return;
}
add_filter( 'woocommerce_email_editor_script_localization_data', array( $this, 'update_localized_data' ) );
// Load the email editor integration script.
// The JS file is located in plugins/woocommerce/client/admin/client/wp-admin-scripts/email-editor-integration/index.ts.
WCAdminAssets::register_script( 'wp-admin-scripts', 'email-editor-integration', true );
WCAdminAssets::register_style( 'email-editor-integration', 'style', true );
$this->assets_manager->load_editor_assets( $edited_item, 'wc-admin-email-editor-integration' );
$this->assets_manager->render_email_editor_html();
remove_filter(
'woocommerce_email_editor_script_localization_data',
array( $this, 'update_localized_data' ),
10
);
}