Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Internal/EmailEdi...
File: Integration.php
<?php
[0] Fix | Delete
[1] Fix | Delete
declare( strict_types=1 );
[2] Fix | Delete
[3] Fix | Delete
namespace Automattic\WooCommerce\Internal\EmailEditor;
[4] Fix | Delete
[5] Fix | Delete
use Automattic\WooCommerce\EmailEditor\Email_Editor_Container;
[6] Fix | Delete
use Automattic\WooCommerce\EmailEditor\Engine\Dependency_Check;
[7] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\EmailPreview\EmailPreview;
[8] Fix | Delete
use Automattic\WooCommerce\Internal\EmailEditor\EmailPatterns\PatternsController;
[9] Fix | Delete
use Automattic\WooCommerce\Internal\EmailEditor\EmailTemplates\TemplatesController;
[10] Fix | Delete
use Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails\WCTransactionalEmails;
[11] Fix | Delete
use Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails\WCTransactionalEmailPostsManager;
[12] Fix | Delete
use Automattic\WooCommerce\Internal\EmailEditor\EmailTemplates\TemplateApiController;
[13] Fix | Delete
use Automattic\WooCommerce\EmailEditor\Engine\Logger\Email_Editor_Logger;
[14] Fix | Delete
use WP_Post;
[15] Fix | Delete
[16] Fix | Delete
defined( 'ABSPATH' ) || exit;
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Integration class for the Email Editor functionality.
[20] Fix | Delete
*/
[21] Fix | Delete
class Integration {
[22] Fix | Delete
const EMAIL_POST_TYPE = 'woo_email';
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* The email editor page renderer instance.
[26] Fix | Delete
*
[27] Fix | Delete
* @var PageRenderer
[28] Fix | Delete
*/
[29] Fix | Delete
private PageRenderer $editor_page_renderer;
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* The dependency check instance.
[33] Fix | Delete
*
[34] Fix | Delete
* @var Dependency_Check
[35] Fix | Delete
*/
[36] Fix | Delete
private Dependency_Check $dependency_check;
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* The template API controller instance.
[40] Fix | Delete
*
[41] Fix | Delete
* @var TemplateApiController
[42] Fix | Delete
*/
[43] Fix | Delete
private TemplateApiController $template_api_controller;
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* The email data API controller instance.
[47] Fix | Delete
*
[48] Fix | Delete
* @var EmailApiController
[49] Fix | Delete
*/
[50] Fix | Delete
private EmailApiController $email_api_controller;
[51] Fix | Delete
[52] Fix | Delete
/**
[53] Fix | Delete
* The WC_Email instance.
[54] Fix | Delete
*
[55] Fix | Delete
* @var \WC_Email
[56] Fix | Delete
*/
[57] Fix | Delete
private \WC_Email $wc_email_instance;
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Constructor.
[61] Fix | Delete
*/
[62] Fix | Delete
public function __construct() {
[63] Fix | Delete
$editor_container = Email_Editor_Container::container();
[64] Fix | Delete
$this->dependency_check = $editor_container->get( Dependency_Check::class );
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
/**
[68] Fix | Delete
* Initialize the integration.
[69] Fix | Delete
*
[70] Fix | Delete
* @internal
[71] Fix | Delete
*/
[72] Fix | Delete
final public function init(): void {
[73] Fix | Delete
if ( ! $this->dependency_check->are_dependencies_met() ) {
[74] Fix | Delete
// If dependencies are not met, do not initialize the email editor integration.
[75] Fix | Delete
return;
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
add_action( 'woocommerce_init', array( $this, 'initialize' ) );
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* Initialize the integration.
[83] Fix | Delete
*/
[84] Fix | Delete
public function initialize() {
[85] Fix | Delete
$this->init_logger();
[86] Fix | Delete
$this->init_hooks();
[87] Fix | Delete
$this->extend_post_api();
[88] Fix | Delete
$this->extend_template_post_api();
[89] Fix | Delete
$this->register_hooks();
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Initialize the logger.
[94] Fix | Delete
*/
[95] Fix | Delete
public function init_logger() {
[96] Fix | Delete
$editor_container = Email_Editor_Container::container();
[97] Fix | Delete
$logger = $editor_container->get( Email_Editor_Logger::class );
[98] Fix | Delete
[99] Fix | Delete
// Register the WooCommerce logger with the email editor package.
[100] Fix | Delete
$logger->set_logger( new Logger( wc_get_logger() ) );
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
/**
[104] Fix | Delete
* Initialize hooks for required classes.
[105] Fix | Delete
*/
[106] Fix | Delete
public function init_hooks() {
[107] Fix | Delete
$container = wc_get_container();
[108] Fix | Delete
$container->get( PatternsController::class );
[109] Fix | Delete
$container->get( TemplatesController::class );
[110] Fix | Delete
$container->get( PersonalizationTagManager::class );
[111] Fix | Delete
$container->get( BlockEmailRenderer::class );
[112] Fix | Delete
$container->get( WCTransactionalEmails::class );
[113] Fix | Delete
$this->editor_page_renderer = $container->get( PageRenderer::class );
[114] Fix | Delete
$this->template_api_controller = $container->get( TemplateApiController::class );
[115] Fix | Delete
$this->email_api_controller = $container->get( EmailApiController::class );
[116] Fix | Delete
[117] Fix | Delete
// Using any email class to get the instance.
[118] Fix | Delete
$registered_emails = \WC_Emails::instance()->get_emails();
[119] Fix | Delete
if ( isset( $registered_emails['WC_Email_New_Order'] ) ) {
[120] Fix | Delete
$this->wc_email_instance = $registered_emails['WC_Email_New_Order'];
[121] Fix | Delete
} else {
[122] Fix | Delete
$first_email_key = array_key_first( $registered_emails );
[123] Fix | Delete
$this->wc_email_instance = $registered_emails[ $first_email_key ];
[124] Fix | Delete
}
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
/**
[128] Fix | Delete
* Register hooks for the integration.
[129] Fix | Delete
*/
[130] Fix | Delete
public function register_hooks() {
[131] Fix | Delete
add_filter( 'woocommerce_email_editor_post_types', array( $this, 'add_email_post_type' ) );
[132] Fix | Delete
add_filter( 'woocommerce_is_email_editor_page', array( $this, 'is_editor_page' ), 10, 1 );
[133] Fix | Delete
add_filter( 'replace_editor', array( $this, 'replace_editor' ), 10, 2 );
[134] Fix | Delete
add_action( 'before_delete_post', array( $this, 'delete_email_template_associated_with_email_editor_post' ), 10, 2 );
[135] Fix | Delete
add_filter( 'woocommerce_email_editor_send_preview_email_rendered_data', array( $this, 'update_send_preview_email_rendered_data' ), 10, 2 );
[136] Fix | Delete
add_filter( 'woocommerce_email_editor_send_preview_email_personalizer_context', array( $this, 'update_send_preview_email_personalizer_context' ) );
[137] Fix | Delete
add_filter( 'woocommerce_email_editor_preview_post_template_html', array( $this, 'update_preview_post_template_html_data' ), 100, 1 );
[138] Fix | Delete
add_action( 'woocommerce_email_editor_send_preview_email_before_wp_mail', array( $this, 'send_preview_email_before_wp_mail' ), 10 );
[139] Fix | Delete
add_action( 'woocommerce_email_editor_send_preview_email_after_wp_mail', array( $this, 'send_preview_email_after_wp_mail' ), 10 );
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
/**
[143] Fix | Delete
* Add WooCommerce email post type to the list of supported post types.
[144] Fix | Delete
*
[145] Fix | Delete
* @param array $post_types List of post types.
[146] Fix | Delete
* @return array Modified list of post types.
[147] Fix | Delete
*/
[148] Fix | Delete
public function add_email_post_type( array $post_types ): array {
[149] Fix | Delete
$post_types[] = array(
[150] Fix | Delete
'name' => self::EMAIL_POST_TYPE,
[151] Fix | Delete
'args' => array(
[152] Fix | Delete
'labels' => array(
[153] Fix | Delete
'name' => __( 'Emails', 'woocommerce' ),
[154] Fix | Delete
'singular_name' => __( 'Email', 'woocommerce' ),
[155] Fix | Delete
'add_new_item' => __( 'Add Email', 'woocommerce' ),
[156] Fix | Delete
'edit_item' => __( 'Edit Email', 'woocommerce' ),
[157] Fix | Delete
'new_item' => __( 'New Email', 'woocommerce' ),
[158] Fix | Delete
'view_item' => __( 'View Email', 'woocommerce' ),
[159] Fix | Delete
'search_items' => __( 'Search Emails', 'woocommerce' ),
[160] Fix | Delete
),
[161] Fix | Delete
'rewrite' => array( 'slug' => self::EMAIL_POST_TYPE ),
[162] Fix | Delete
'supports' => array(
[163] Fix | Delete
'title',
[164] Fix | Delete
'editor' => array(
[165] Fix | Delete
'default-mode' => 'template-locked',
[166] Fix | Delete
),
[167] Fix | Delete
'excerpt',
[168] Fix | Delete
),
[169] Fix | Delete
'capability_type' => self::EMAIL_POST_TYPE,
[170] Fix | Delete
'capabilities' => array(
[171] Fix | Delete
'edit_post' => 'manage_woocommerce',
[172] Fix | Delete
'read_post' => 'manage_woocommerce',
[173] Fix | Delete
'delete_post' => 'manage_woocommerce',
[174] Fix | Delete
'edit_posts' => 'manage_woocommerce',
[175] Fix | Delete
'edit_others_posts' => 'manage_woocommerce',
[176] Fix | Delete
'delete_posts' => 'manage_woocommerce',
[177] Fix | Delete
'publish_posts' => 'manage_woocommerce',
[178] Fix | Delete
'read_private_posts' => 'manage_woocommerce',
[179] Fix | Delete
'create_posts' => 'manage_woocommerce',
[180] Fix | Delete
),
[181] Fix | Delete
'map_meta_cap' => false,
[182] Fix | Delete
),
[183] Fix | Delete
);
[184] Fix | Delete
return $post_types;
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
/**
[188] Fix | Delete
* Check if current page is email editor page.
[189] Fix | Delete
*
[190] Fix | Delete
* @param bool $is_editor_page Current editor page status.
[191] Fix | Delete
* @return bool Whether current page is email editor page.
[192] Fix | Delete
*/
[193] Fix | Delete
public function is_editor_page( bool $is_editor_page ): bool {
[194] Fix | Delete
if ( $is_editor_page ) {
[195] Fix | Delete
return $is_editor_page;
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
// We need to check early if we are on the email editor page. The check runs early so we can't use current_screen() here.
[199] Fix | Delete
if ( is_admin() && isset( $_GET['post'] ) && isset( $_GET['action'] ) && 'edit' === $_GET['action'] ) { // 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).
[200] Fix | Delete
$post = get_post( (int) $_GET['post'] ); // 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).
[201] Fix | Delete
return $post && self::EMAIL_POST_TYPE === $post->post_type;
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
return false;
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
/**
[208] Fix | Delete
* Replace the default editor with our custom email editor.
[209] Fix | Delete
*
[210] Fix | Delete
* @param bool $replace Whether to replace the editor.
[211] Fix | Delete
* @param WP_Post $post Post object.
[212] Fix | Delete
* @return bool Whether the editor was replaced.
[213] Fix | Delete
*/
[214] Fix | Delete
public function replace_editor( $replace, $post ) {
[215] Fix | Delete
$current_screen = get_current_screen();
[216] Fix | Delete
if ( self::EMAIL_POST_TYPE === $post->post_type && $current_screen ) {
[217] Fix | Delete
$this->editor_page_renderer->render();
[218] Fix | Delete
return true;
[219] Fix | Delete
}
[220] Fix | Delete
return $replace;
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
/**
[224] Fix | Delete
* Delete the email template associated with the email editor post when the post is permanently deleted.
[225] Fix | Delete
*
[226] Fix | Delete
* @param int $post_id The post ID.
[227] Fix | Delete
* @param WP_Post $post The post object.
[228] Fix | Delete
*/
[229] Fix | Delete
public function delete_email_template_associated_with_email_editor_post( $post_id, $post ) {
[230] Fix | Delete
if ( self::EMAIL_POST_TYPE !== $post->post_type ) {
[231] Fix | Delete
return;
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
$post_manager = WCTransactionalEmailPostsManager::get_instance();
[235] Fix | Delete
[236] Fix | Delete
$email_type = $post_manager->get_email_type_from_post_id( $post_id, true );
[237] Fix | Delete
[238] Fix | Delete
if ( empty( $email_type ) ) {
[239] Fix | Delete
return;
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
$post_manager->delete_email_template( $email_type );
[243] Fix | Delete
}
[244] Fix | Delete
[245] Fix | Delete
/**
[246] Fix | Delete
* Extend the post API for the wp_template post type to add and save the woocommerce_data field.
[247] Fix | Delete
*/
[248] Fix | Delete
public function extend_template_post_api(): void {
[249] Fix | Delete
register_rest_field(
[250] Fix | Delete
'wp_template',
[251] Fix | Delete
'woocommerce_data',
[252] Fix | Delete
array(
[253] Fix | Delete
'get_callback' => array( $this->template_api_controller, 'get_template_data' ),
[254] Fix | Delete
'update_callback' => array( $this->template_api_controller, 'save_template_data' ),
[255] Fix | Delete
'schema' => $this->template_api_controller->get_template_data_schema(),
[256] Fix | Delete
)
[257] Fix | Delete
);
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
/**
[261] Fix | Delete
* Filter email preview data to replace placeholders with actual content.
[262] Fix | Delete
*
[263] Fix | Delete
* This method retrieves the appropriate email type based on the request,
[264] Fix | Delete
* generates the email content using the WooContentProcessor, and replaces
[265] Fix | Delete
* the placeholder in the preview HTML.
[266] Fix | Delete
*
[267] Fix | Delete
* @param string $data The preview data.
[268] Fix | Delete
* @param string $email_type The email type identifier (e.g., 'customer_processing_order').
[269] Fix | Delete
* @param int $post_id The post ID.
[270] Fix | Delete
* @return string The updated preview data with placeholders replaced.
[271] Fix | Delete
*/
[272] Fix | Delete
private function update_email_preview_data( $data, string $email_type, $post_id = 0 ) {
[273] Fix | Delete
$type_param = EmailPreview::DEFAULT_EMAIL_TYPE;
[274] Fix | Delete
[275] Fix | Delete
if ( ! empty( $post_id ) ) {
[276] Fix | Delete
$type_param = WCTransactionalEmailPostsManager::get_instance()->get_email_type_class_name_from_post_id( $post_id );
[277] Fix | Delete
} elseif ( ! empty( $email_type ) ) {
[278] Fix | Delete
$type_param = WCTransactionalEmailPostsManager::get_instance()->get_email_type_class_name_from_email_id( $email_type );
[279] Fix | Delete
}
[280] Fix | Delete
[281] Fix | Delete
$email_preview = wc_get_container()->get( EmailPreview::class );
[282] Fix | Delete
[283] Fix | Delete
try {
[284] Fix | Delete
$message = $email_preview->generate_placeholder_content( $type_param );
[285] Fix | Delete
} catch ( \InvalidArgumentException $e ) {
[286] Fix | Delete
// If the provided type was invalid, fall back to the default.
[287] Fix | Delete
try {
[288] Fix | Delete
$message = $email_preview->generate_placeholder_content( EmailPreview::DEFAULT_EMAIL_TYPE );
[289] Fix | Delete
} catch ( \Throwable $e ) {
[290] Fix | Delete
return $data;
[291] Fix | Delete
}
[292] Fix | Delete
} catch ( \Throwable $e ) {
[293] Fix | Delete
return $data;
[294] Fix | Delete
}
[295] Fix | Delete
[296] Fix | Delete
return str_replace( BlockEmailRenderer::WOO_EMAIL_CONTENT_PLACEHOLDER, $message, $data );
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
/**
[300] Fix | Delete
* Filter email preview data used when sending a preview email.
[301] Fix | Delete
*
[302] Fix | Delete
* @param string $data The preview data.
[303] Fix | Delete
* @param WP_Post $post The post object.
[304] Fix | Delete
* @return string The updated preview data with placeholders replaced.
[305] Fix | Delete
*/
[306] Fix | Delete
public function update_send_preview_email_rendered_data( $data, $post ) {
[307] Fix | Delete
$email_type = '';
[308] Fix | Delete
$post_body = file_get_contents( 'php://input' );
[309] Fix | Delete
[310] Fix | Delete
if ( $post_body ) {
[311] Fix | Delete
$decoded_body = json_decode( $post_body );
[312] Fix | Delete
[313] Fix | Delete
if ( json_last_error() === JSON_ERROR_NONE && isset( $decoded_body->postId ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
[314] Fix | Delete
$post_id = absint( $decoded_body->postId ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
[315] Fix | Delete
[316] Fix | Delete
$email_type = WCTransactionalEmailPostsManager::get_instance()->get_email_type_from_post_id( $post_id );
[317] Fix | Delete
if ( ! empty( $email_type ) ) {
[318] Fix | Delete
return $this->update_email_preview_data( $data, $email_type );
[319] Fix | Delete
}
[320] Fix | Delete
}
[321] Fix | Delete
} elseif ( ! empty( $post ) && $post instanceof \WP_Post ) {
[322] Fix | Delete
$email_type = WCTransactionalEmailPostsManager::get_instance()->get_email_type_from_post_id( $post->ID );
[323] Fix | Delete
if ( ! empty( $email_type ) ) {
[324] Fix | Delete
return $this->update_email_preview_data( $data, $email_type, $post->ID );
[325] Fix | Delete
}
[326] Fix | Delete
}
[327] Fix | Delete
return $data;
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
/**
[331] Fix | Delete
* Update the personalizer context for the send preview email.
[332] Fix | Delete
*
[333] Fix | Delete
* @param array $context The personalizer context.
[334] Fix | Delete
* @return array The updated personalizer context.
[335] Fix | Delete
*/
[336] Fix | Delete
public function update_send_preview_email_personalizer_context( $context ) {
[337] Fix | Delete
$post_manager = WCTransactionalEmailPostsManager::get_instance();
[338] Fix | Delete
$email_id = $post_manager->get_email_type_from_post_id( get_the_ID() );
[339] Fix | Delete
$email_type = $email_id ? $post_manager->get_email_type_class_name_from_email_id( $email_id ) : EmailPreview::DEFAULT_EMAIL_TYPE;
[340] Fix | Delete
$email_preview = wc_get_container()->get( EmailPreview::class );
[341] Fix | Delete
[342] Fix | Delete
try {
[343] Fix | Delete
$email_preview->set_email_type( $email_type );
[344] Fix | Delete
} catch ( \InvalidArgumentException $e ) {
[345] Fix | Delete
// If the email type is invalid, return the context data as is.
[346] Fix | Delete
return $context;
[347] Fix | Delete
}
[348] Fix | Delete
[349] Fix | Delete
$email = $email_preview->get_email();
[350] Fix | Delete
$email->recipient = $context['recipient_email'] ?? '';
[351] Fix | Delete
$personalizer = wc_get_container()->get( TransactionalEmailPersonalizer::class );
[352] Fix | Delete
[353] Fix | Delete
return $personalizer->prepare_context_data( $context, $email );
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
/**
[357] Fix | Delete
* Filter email preview data used when previewing the email in new tab.
[358] Fix | Delete
*
[359] Fix | Delete
* @param string $data The preview HTML string.
[360] Fix | Delete
* @return string The updated preview HTML with placeholders replaced.
[361] Fix | Delete
*/
[362] Fix | Delete
public function update_preview_post_template_html_data( $data ) {
[363] Fix | Delete
// return early if the data does not contain the placeholder meaning it's already been processed.
[364] Fix | Delete
if ( ! str_contains( (string) $data, BlockEmailRenderer::WOO_EMAIL_CONTENT_PLACEHOLDER ) ) {
[365] Fix | Delete
return $data;
[366] Fix | Delete
}
[367] Fix | Delete
[368] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification.Recommended
[369] Fix | Delete
// Nonce verification is disabled here because the preview action doesn't modify data,
[370] Fix | Delete
// and the check caused issues with the 'Preview in new tab' feature due to context changes.
[371] Fix | Delete
$type_param = isset( $_GET['woo_email'] ) ? sanitize_text_field( wp_unslash( $_GET['woo_email'] ) ) : '';
[372] Fix | Delete
[373] Fix | Delete
// check for post id (preview id) in the request.
[374] Fix | Delete
$post_id = isset( $_REQUEST['preview_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['preview_id'] ) ) : '';
[375] Fix | Delete
[376] Fix | Delete
// phpcs:enable
[377] Fix | Delete
return $this->update_email_preview_data( $data, $type_param, $post_id );
[378] Fix | Delete
}
[379] Fix | Delete
[380] Fix | Delete
/**
[381] Fix | Delete
* Extend the post API for the woo_email post type to add and save the woocommerce_data field.
[382] Fix | Delete
*/
[383] Fix | Delete
public function extend_post_api(): void {
[384] Fix | Delete
register_rest_field(
[385] Fix | Delete
self::EMAIL_POST_TYPE,
[386] Fix | Delete
'woocommerce_data',
[387] Fix | Delete
array(
[388] Fix | Delete
'get_callback' => array( $this->email_api_controller, 'get_email_data' ),
[389] Fix | Delete
'update_callback' => array( $this->email_api_controller, 'save_email_data' ),
[390] Fix | Delete
'schema' => $this->email_api_controller->get_email_data_schema(),
[391] Fix | Delete
)
[392] Fix | Delete
);
[393] Fix | Delete
}
[394] Fix | Delete
[395] Fix | Delete
/**
[396] Fix | Delete
* Action hook callback before sending the preview email via wp_mail
[397] Fix | Delete
*
[398] Fix | Delete
* @since 10.6.0
[399] Fix | Delete
* @return void
[400] Fix | Delete
*/
[401] Fix | Delete
public function send_preview_email_before_wp_mail() {
[402] Fix | Delete
add_filter( 'wp_mail_from', array( $this->wc_email_instance, 'get_from_address' ) );
[403] Fix | Delete
add_filter( 'wp_mail_from_name', array( $this->wc_email_instance, 'get_from_name' ) );
[404] Fix | Delete
}
[405] Fix | Delete
[406] Fix | Delete
/**
[407] Fix | Delete
* Action hook callback after sending the preview email via wp_mail.
[408] Fix | Delete
*
[409] Fix | Delete
* @since 10.6.0
[410] Fix | Delete
* @return void
[411] Fix | Delete
*/
[412] Fix | Delete
public function send_preview_email_after_wp_mail() {
[413] Fix | Delete
remove_filter( 'wp_mail_from', array( $this->wc_email_instance, 'get_from_address' ) );
[414] Fix | Delete
remove_filter( 'wp_mail_from_name', array( $this->wc_email_instance, 'get_from_name' ) );
[415] Fix | Delete
}
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function