Skip to content

Commit 24574e2

Browse files
davefxDavid Marín
authored andcommitted
Inverting logic to show notice.
To avoid adding an option that will be kept forever in the database, now the notice is only shown if there exists the corresponding option.
1 parent 2964663 commit 24574e2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

dfx-random-user-id.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ function dfx_random_user_randomize_first_user() {
5454

5555
global $wpdb;
5656

57+
update_option( 'dfx_randomuserid_activation_show_activation_notice', true, true );
58+
5759
// Check that user with ID=1 exists
5860
$user = get_userdata( 1 );
5961
if ( ! $user ) {
@@ -83,8 +85,6 @@ function dfx_random_user_randomize_first_user() {
8385

8486
update_option('dfx_randomuserid_first_user_moved_to', $new_id, false );
8587

86-
delete_option( 'dfx_randomuserid_activation_notice_dismissed' );
87-
8888
}
8989

9090
}
@@ -94,7 +94,7 @@ function dfx_random_user_randomize_first_user() {
9494
if ( ! function_exists( 'dfx_random_user_show_activation_msg') ) {
9595
function dfx_random_user_show_activation_msg() {
9696

97-
if ( ! get_option( 'dfx_randomuserid_activation_notice_dismissed' ) ) {
97+
if ( get_option( 'dfx_randomuserid_activation_show_activation_notice' ) ) {
9898

9999
$first_user_new_id = get_option( 'dfx_randomuserid_first_user_moved_to' );
100100

@@ -131,7 +131,11 @@ function dfx_random_user_dismissed_activation_msg() {
131131

132132
if (isset($_GET['dfx_randomuserid_dismiss_notice'])) {
133133

134-
update_option( 'dfx_randomuserid_activation_notice_dismissed', 'true', true );
134+
// Delete both the option to show the notice and the option keeping the new user id
135+
// to avoid database clutter. The less information in the database, the better.
136+
137+
delete_option( 'dfx_randomuserid_activation_notice_dismissed' );
138+
delete_option( 'dfx_randomuserid_first_user_moved_to' );
135139

136140
}
137141
}

0 commit comments

Comments
 (0)