Skip to content

Commit 84e4d93

Browse files
Address review feedback
1 parent b1c7633 commit 84e4d93

3 files changed

Lines changed: 14 additions & 17 deletions

File tree

‎admin/load.php‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ function perflab_enqueue_modules_page_scripts() {
547547
wp_enqueue_script(
548548
'perflab-module-migration-notice',
549549
plugin_dir_url( __FILE__ ) . 'perflab-module-migration-notice.js',
550-
array(),
550+
array( 'wp-i18n' ),
551551
'1.0.0',
552552
array(
553553
'strategy' => 'defer',
@@ -558,9 +558,8 @@ function perflab_enqueue_modules_page_scripts() {
558558
'perflab-module-migration-notice',
559559
'perflab_module_migration_notice',
560560
array(
561-
'ajaxurl' => admin_url( 'admin-ajax.php' ),
562-
'nonce' => wp_create_nonce( 'perflab-install-activate-plugins' ),
563-
'network_error' => esc_html__( 'Network response was not ok.', 'performance-lab' ),
561+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
562+
'nonce' => wp_create_nonce( 'perflab-install-activate-plugins' ),
564563
)
565564
);
566565
}
@@ -651,18 +650,16 @@ function perflab_deactivate_plugin() {
651650
*/
652651
function perflab_install_activate_standalone_plugins_callback() {
653652
if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'perflab-install-activate-plugins' ) ) {
654-
$status['errorMessage'] = esc_html__( 'Invalid nonce: Please refresh and try again.', 'performance-lab' );
653+
$status['errorMessage'] = __( 'Invalid nonce: Please refresh and try again.', 'performance-lab' );
655654
wp_send_json_error( $status );
656655
}
657656

658657
if ( ! current_user_can( 'install_plugins' ) || ! current_user_can( 'activate_plugins' ) ) {
659-
$status['errorMessage'] = esc_html__( 'Sorry, you are not allowed to manage plugins for this site. Please contact the administrator.', 'performance-lab' );
658+
$status['errorMessage'] = __( 'Sorry, you are not allowed to manage plugins for this site. Please contact the administrator.', 'performance-lab' );
660659
wp_send_json_error( $status );
661660
}
662661

663-
if ( ! function_exists( 'plugins_api' ) ) {
664-
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
665-
}
662+
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
666663
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
667664
require_once ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php';
668665

@@ -689,7 +686,7 @@ function perflab_install_activate_standalone_plugins_callback() {
689686
}
690687

691688
if ( ! $plugin_slug ) {
692-
$status['errorMessage'] = esc_html__( 'Invalid plugin.', 'performance-lab' );
689+
$status['errorMessage'] = __( 'Invalid plugin.', 'performance-lab' );
693690
wp_send_json_error( $status );
694691
}
695692

@@ -769,19 +766,19 @@ function perflab_plugin_admin_notices() {
769766
esc_html__( 'Your site is using the "%s" module which will be removed in the future in favor of its equivalent standalone plugin.', 'performance-lab' ),
770767
esc_attr( $available_module_names[0] )
771768
);
772-
$message .= '<br>';
769+
$message .= ' ';
773770
$message .= esc_html__( 'Please click the following button to install and activate the relevant plugin in favor of the module. This will not impact any of the underlying functionality.', 'performance-lab' );
774771
$message .= '</p>';
775772
} else {
776773
$message = '<p>';
777774
$message .= esc_html__( 'Your site is using modules which will be removed in the future in favor of their equivalent standalone plugins.', 'performance-lab' );
778-
$message .= '<br>';
775+
$message .= ' ';
779776
$message .= esc_html__( 'Please click the following button to install and activate the relevant plugins in favor of the modules. This will not impact any of the underlying functionality.', 'performance-lab' );
780777
$message .= '</p>';
781778
$message .= '<strong>' . esc_html__( 'Available standalone plugins:', 'performance-lab' ) . '</strong>';
782779
$message .= '<ol>';
783-
foreach ( $available_module_names as $names ) {
784-
$message .= sprintf( '<li>%s</li>', esc_html( $names ) );
780+
foreach ( $available_module_names as $module_name ) {
781+
$message .= sprintf( '<li>%s</li>', esc_html( $module_name ) );
785782
}
786783
$message .= '</ol>';
787784
}

‎admin/perflab-module-migration-notice.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
.then( function ( response ) {
2727
if ( ! response.ok ) {
2828
throw new Error(
29-
perflab_module_migration_notice.network_error
29+
wp.i18n.__( 'Network response was not ok.', 'performance-lab' )
3030
);
3131
}
3232
return response.json();

‎admin/plugins.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ function perflab_get_active_modules_with_standalone_plugins() {
6666
$modules = perflab_get_module_settings();
6767
return array_filter(
6868
array_keys( perflab_get_standalone_plugins_constants() ),
69-
static function ( $v ) use ( $modules ) {
70-
return ! empty( $modules[ $v ] ) && $modules[ $v ]['enabled'];
69+
static function ( $module ) use ( $modules ) {
70+
return ! empty( $modules[ $module ] ) && $modules[ $module ]['enabled'];
7171
}
7272
);
7373
}

0 commit comments

Comments
 (0)