Skip to content

Commit

Permalink
Merge pull request #915 from WordPress/fix/un-dismiss-pointer
Browse files Browse the repository at this point in the history
Implement "un-dismiss" migration pointer functionality when the user activates a module
  • Loading branch information
felixarntz authored Dec 21, 2023
2 parents 28b8905 + 17f773a commit 5a4cf83
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions load.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,37 @@ function perflab_run_module_activation_deactivation( $old_value, $value ) {

// Get the list of modules that were activated, and load the activate.php files if they exist.
if ( ! empty( $value ) ) {
$reset_migration_pointer_dismissals = false;
foreach ( $value as $module => $module_settings ) {
if ( ! empty( $module_settings['enabled'] ) && ( empty( $old_value[ $module ] ) || empty( $old_value[ $module ]['enabled'] ) ) ) {
perflab_activate_module( PERFLAB_PLUGIN_DIR_PATH . 'modules/' . $module );
$reset_migration_pointer_dismissals = true;
}
}
if ( $reset_migration_pointer_dismissals ) {
// Retrieve a list of active modules with associated standalone plugins.
$active_modules_with_plugins = perflab_get_active_modules_with_standalone_plugins();

/*
* Check if there are any active modules with compatible standalone plugins.
* If no such modules are found bail early.
*/
if ( empty( $active_modules_with_plugins ) ) {
return;
}

$current_user = get_current_user_id();
$dismissed = array_filter( explode( ',', (string) get_user_meta( $current_user, 'dismissed_wp_pointers', true ) ) );

if ( ! in_array( 'perflab-module-migration-pointer', $dismissed, true ) ) {
return;
}

unset( $dismissed[ array_search( 'perflab-module-migration-pointer', $dismissed, true ) ] );
$dismissed = implode( ',', $dismissed );

update_user_meta( $current_user, 'dismissed_wp_pointers', $dismissed );
}
}

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

0 comments on commit 5a4cf83

Please sign in to comment.