From 6dcb192c06ee551ca635069896236c6e3d1462ea Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 21 Mar 2024 09:14:46 -0700 Subject: [PATCH 1/9] Use wp_json_encode() instead of esc_js() --- admin/load.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/load.php b/admin/load.php index 3b89a6db8d..bf2d1d826f 100644 --- a/admin/load.php +++ b/admin/load.php @@ -132,7 +132,7 @@ function perflab_render_pointer( $pointer_id = 'perflab-admin-pointer', $args = jQuery( function() { // Pointer Options. var options = { - content: '

', + content: ' . esc_html( $args['heading'] ) . '

' . wp_kses( $args['content'], $wp_kses_options ) . '

' ); ?>, position: { edge: 'left', align: 'right', @@ -143,7 +143,7 @@ function perflab_render_pointer( $pointer_id = 'perflab-admin-pointer', $args = jQuery.post( window.ajaxurl, { - pointer: '', + pointer: , action: 'dismiss-wp-pointer', _wpnonce: , } From 5e6284b99bbc6473a036e5f27b844323fd3bb5f9 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 21 Mar 2024 09:29:57 -0700 Subject: [PATCH 2/9] Use const instead of var in PerfLab JS --- admin/js/perflab-plugin-management.js | 14 +++++++------- admin/load.php | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/admin/js/perflab-plugin-management.js b/admin/js/perflab-plugin-management.js index 45200150e8..677d5584fb 100644 --- a/admin/js/perflab-plugin-management.js +++ b/admin/js/perflab-plugin-management.js @@ -9,15 +9,15 @@ typeof settings.data === 'string' && settings.data.includes( 'action=install-plugin' ) ) { - var params = new URLSearchParams( settings.data ); - var slug = params.get( 'slug' ); + const params = new URLSearchParams( settings.data ); + const slug = params.get( 'slug' ); // Check if 'slug' was found and output the value. if ( ! slug ) { return; } - var target_element = $( + const target_element = $( '.wpp-standalone-plugins a[data-slug="' + slug + '"]' ); if ( ! target_element ) { @@ -30,15 +30,15 @@ * the core changes have taken place. */ setTimeout( function () { - var plugin_url = target_element.attr( 'href' ); + const plugin_url = target_element.attr( 'href' ); if ( ! plugin_url ) { return; } - var nonce = target_element.attr( + const nonce = target_element.attr( 'data-plugin-activation-nonce' ); - var plugin_slug = target_element.attr( 'data-slug' ); - var url = new URL( plugin_url ); + const plugin_slug = target_element.attr( 'data-slug' ); + const url = new URL( plugin_url ); url.searchParams.set( 'action', 'perflab_activate_plugin' ); url.searchParams.set( '_wpnonce', nonce ); url.searchParams.set( 'plugin', plugin_slug ); diff --git a/admin/load.php b/admin/load.php index bf2d1d826f..8d739d3a72 100644 --- a/admin/load.php +++ b/admin/load.php @@ -131,7 +131,7 @@ function perflab_render_pointer( $pointer_id = 'perflab-admin-pointer', $args =