Skip to content

Commit 5a4cf83

Browse files
authored
Merge pull request #915 from WordPress/fix/un-dismiss-pointer
Implement "un-dismiss" migration pointer functionality when the user activates a module
2 parents 28b8905 + 17f773a commit 5a4cf83

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

‎load.php‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,37 @@ function perflab_run_module_activation_deactivation( $old_value, $value ) {
458458

459459
// Get the list of modules that were activated, and load the activate.php files if they exist.
460460
if ( ! empty( $value ) ) {
461+
$reset_migration_pointer_dismissals = false;
461462
foreach ( $value as $module => $module_settings ) {
462463
if ( ! empty( $module_settings['enabled'] ) && ( empty( $old_value[ $module ] ) || empty( $old_value[ $module ]['enabled'] ) ) ) {
463464
perflab_activate_module( PERFLAB_PLUGIN_DIR_PATH . 'modules/' . $module );
465+
$reset_migration_pointer_dismissals = true;
464466
}
465467
}
468+
if ( $reset_migration_pointer_dismissals ) {
469+
// Retrieve a list of active modules with associated standalone plugins.
470+
$active_modules_with_plugins = perflab_get_active_modules_with_standalone_plugins();
471+
472+
/*
473+
* Check if there are any active modules with compatible standalone plugins.
474+
* If no such modules are found bail early.
475+
*/
476+
if ( empty( $active_modules_with_plugins ) ) {
477+
return;
478+
}
479+
480+
$current_user = get_current_user_id();
481+
$dismissed = array_filter( explode( ',', (string) get_user_meta( $current_user, 'dismissed_wp_pointers', true ) ) );
482+
483+
if ( ! in_array( 'perflab-module-migration-pointer', $dismissed, true ) ) {
484+
return;
485+
}
486+
487+
unset( $dismissed[ array_search( 'perflab-module-migration-pointer', $dismissed, true ) ] );
488+
$dismissed = implode( ',', $dismissed );
489+
490+
update_user_meta( $current_user, 'dismissed_wp_pointers', $dismissed );
491+
}
466492
}
467493

468494
// Get the list of modules that were deactivated, and load the deactivate.php files if they exist.

0 commit comments

Comments
 (0)