Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review feedback
  • Loading branch information
mukeshpanchal27 committed Dec 18, 2023
commit 84e4d933eec75cb5b93c89d203e9ba66726cc1be
25 changes: 11 additions & 14 deletions admin/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ function perflab_enqueue_modules_page_scripts() {
wp_enqueue_script(
'perflab-module-migration-notice',
plugin_dir_url( __FILE__ ) . 'perflab-module-migration-notice.js',
array(),
array( 'wp-i18n' ),
'1.0.0',
array(
'strategy' => 'defer',
Expand All @@ -558,9 +558,8 @@ function perflab_enqueue_modules_page_scripts() {
'perflab-module-migration-notice',
'perflab_module_migration_notice',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'perflab-install-activate-plugins' ),
'network_error' => esc_html__( 'Network response was not ok.', 'performance-lab' ),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'perflab-install-activate-plugins' ),
)
);
}
Expand Down Expand Up @@ -651,18 +650,16 @@ function perflab_deactivate_plugin() {
*/
function perflab_install_activate_standalone_plugins_callback() {
if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'perflab-install-activate-plugins' ) ) {
$status['errorMessage'] = esc_html__( 'Invalid nonce: Please refresh and try again.', 'performance-lab' );
$status['errorMessage'] = __( 'Invalid nonce: Please refresh and try again.', 'performance-lab' );
wp_send_json_error( $status );
}

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

if ( ! function_exists( 'plugins_api' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
}
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php';

Expand All @@ -689,7 +686,7 @@ function perflab_install_activate_standalone_plugins_callback() {
}

if ( ! $plugin_slug ) {
$status['errorMessage'] = esc_html__( 'Invalid plugin.', 'performance-lab' );
$status['errorMessage'] = __( 'Invalid plugin.', 'performance-lab' );
wp_send_json_error( $status );
}

Expand Down Expand Up @@ -769,19 +766,19 @@ function perflab_plugin_admin_notices() {
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' ),
esc_attr( $available_module_names[0] )
);
$message .= '<br>';
$message .= ' ';
$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' );
$message .= '</p>';
} else {
$message = '<p>';
$message .= esc_html__( 'Your site is using modules which will be removed in the future in favor of their equivalent standalone plugins.', 'performance-lab' );
$message .= '<br>';
$message .= ' ';
$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' );
$message .= '</p>';
$message .= '<strong>' . esc_html__( 'Available standalone plugins:', 'performance-lab' ) . '</strong>';
$message .= '<ol>';
foreach ( $available_module_names as $names ) {
$message .= sprintf( '<li>%s</li>', esc_html( $names ) );
foreach ( $available_module_names as $module_name ) {
$message .= sprintf( '<li>%s</li>', esc_html( $module_name ) );
}
$message .= '</ol>';
}
Expand Down
2 changes: 1 addition & 1 deletion admin/perflab-module-migration-notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
.then( function ( response ) {
if ( ! response.ok ) {
throw new Error(
perflab_module_migration_notice.network_error
wp.i18n.__( 'Network response was not ok.', 'performance-lab' )
);
}
return response.json();
Expand Down
4 changes: 2 additions & 2 deletions admin/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ function perflab_get_active_modules_with_standalone_plugins() {
$modules = perflab_get_module_settings();
return array_filter(
array_keys( perflab_get_standalone_plugins_constants() ),
static function ( $v ) use ( $modules ) {
return ! empty( $modules[ $v ] ) && $modules[ $v ]['enabled'];
static function ( $module ) use ( $modules ) {
return ! empty( $modules[ $module ] ) && $modules[ $module ]['enabled'];
}
);
}
Expand Down