Skip to content

Commit 9363001

Browse files
authored
Fix: Set proper default, to show Welcome screen by default (#1512)
1 parent 01ca034 commit 9363001

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

includes/class-activitypub.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,5 +815,17 @@ public static function register_user_meta() {
815815
'sanitize_callback' => 'absint',
816816
)
817817
);
818+
819+
\register_meta(
820+
'user',
821+
'activitypub_show_welcome_tab',
822+
array(
823+
'type' => 'integer',
824+
'description' => 'Whether to show the welcome tab.',
825+
'single' => true,
826+
'default' => 1,
827+
'sanitize_callback' => 'absint',
828+
)
829+
);
818830
}
819831
}

includes/wp-admin/class-settings.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public static function init() {
2323
\add_action( 'admin_init', array( self::class, 'register_settings' ), 11 );
2424
\add_action( 'admin_menu', array( self::class, 'add_settings_page' ) );
2525

26+
\add_action( 'load-settings_page_activitypub', array( self::class, 'handle_welcome_query_arg' ) );
2627
\add_filter( 'screen_settings', array( self::class, 'add_screen_option' ), 10, 2 );
2728
\add_filter( 'screen_options_show_submit', array( self::class, 'screen_options_show_submit' ), 10, 2 );
2829
}
@@ -442,6 +443,20 @@ public static function add_settings_help_tab() {
442443
);
443444
}
444445

446+
/**
447+
* Handle 'welcome' query arg.
448+
*/
449+
public static function handle_welcome_query_arg() {
450+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
451+
if ( isset( $_GET['welcome'] ) ) {
452+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
453+
$welcome_checked = empty( \sanitize_text_field( \wp_unslash( $_GET['welcome'] ) ) ) ? 0 : 1;
454+
\update_user_meta( \get_current_user_id(), 'activitypub_show_welcome_tab', $welcome_checked );
455+
\wp_safe_redirect( \admin_url( 'options-general.php?page=activitypub&tab=settings' ) );
456+
exit;
457+
}
458+
}
459+
445460
/**
446461
* Add screen option.
447462
*
@@ -455,11 +470,6 @@ public static function add_screen_option( $screen_settings, $screen ) {
455470
return $screen_settings;
456471
}
457472

458-
if ( isset( $_GET['welcome'] ) ) {
459-
$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
460-
\update_user_meta( \get_current_user_id(), 'activitypub_show_welcome_tab', $welcome_checked );
461-
}
462-
463473
if ( isset( $_POST['activitypub_show_welcome_tab'] ) && isset( $_POST['screenoptionnonce'] ) ) {
464474
$nonce = \sanitize_text_field( \wp_unslash( $_POST['screenoptionnonce'] ) );
465475
$welcome = \sanitize_text_field( \wp_unslash( $_POST['activitypub_show_welcome_tab'] ) );

0 commit comments

Comments
 (0)