From 05cc0882e519104661c4b17ca5903620a0b9c95e Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 22 Oct 2020 09:28:06 -0300 Subject: [PATCH] Replace deprecated jQuery code in includes/emails/class-wc-email.php This commit replaces a call to the now deprecated jQuery.fn.toggle(handler, handler...) (https://api.jquery.com/toggle-event/) with a jQuery.click(). The deprecated call was used in the page where admins can edit e-mail templates (example: wp-admin/admin.php?page=wc-settings&tab=email§ion=wc_email_customer_on_hold_order) to show or hide the contents of the template and at the same time change the label of the button. We are now using jQuery.click() with a if statement inside to decide which label to use. --- includes/emails/class-wc-email.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/includes/emails/class-wc-email.php b/includes/emails/class-wc-email.php index a47736ff75f..7149b938090 100644 --- a/includes/emails/class-wc-email.php +++ b/includes/emails/class-wc-email.php @@ -1048,11 +1048,14 @@ class WC_Email extends WC_Settings_API { var view = '" . esc_js( __( 'View template', 'woocommerce' ) ) . "'; var hide = '" . esc_js( __( 'Hide template', 'woocommerce' ) ) . "'; - jQuery( 'a.toggle_editor' ).text( view ).toggle( function() { - jQuery( this ).text( hide ).closest(' .template' ).find( '.editor' ).slideToggle(); - return false; - }, function() { - jQuery( this ).text( view ).closest( '.template' ).find( '.editor' ).slideToggle(); + jQuery( 'a.toggle_editor' ).text( view ).click( function() { + if ( jQuery( this ).closest(' .template' ).find( '.editor' ).is(':visible') ) { + var label = view; + } else { + var label = hide; + } + + jQuery( this ).text( label ).closest(' .template' ).find( '.editor' ).slideToggle(); return false; } );