@@ -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