Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions includes/class-activitypub.php
Original file line number Diff line number Diff line change
Expand Up @@ -815,5 +815,17 @@ public static function register_user_meta() {
'sanitize_callback' => 'absint',
)
);

\register_meta(
'user',
'activitypub_show_welcome_tab',
array(
'type' => 'integer',
'description' => 'Whether to show the welcome tab.',
'single' => true,
'default' => 1,
'sanitize_callback' => 'absint',
)
);
}
}
20 changes: 15 additions & 5 deletions includes/wp-admin/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static function init() {
\add_action( 'admin_init', array( self::class, 'register_settings' ), 11 );
\add_action( 'admin_menu', array( self::class, 'add_settings_page' ) );

\add_action( 'load-settings_page_activitypub', array( self::class, 'handle_welcome_query_arg' ) );
\add_filter( 'screen_settings', array( self::class, 'add_screen_option' ), 10, 2 );
\add_filter( 'screen_options_show_submit', array( self::class, 'screen_options_show_submit' ), 10, 2 );
}
Expand Down Expand Up @@ -442,6 +443,20 @@ public static function add_settings_help_tab() {
);
}

/**
* Handle 'welcome' query arg.
*/
public static function handle_welcome_query_arg() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['welcome'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$welcome_checked = empty( \sanitize_text_field( \wp_unslash( $_GET['welcome'] ) ) ) ? 0 : 1;
\update_user_meta( \get_current_user_id(), 'activitypub_show_welcome_tab', $welcome_checked );
\wp_safe_redirect( \admin_url( 'options-general.php?page=activitypub&tab=settings' ) );
exit;
}
}

/**
* Add screen option.
*
Expand All @@ -455,11 +470,6 @@ public static function add_screen_option( $screen_settings, $screen ) {
return $screen_settings;
}

if ( isset( $_GET['welcome'] ) ) {
$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
\update_user_meta( \get_current_user_id(), 'activitypub_show_welcome_tab', $welcome_checked );
}

if ( isset( $_POST['activitypub_show_welcome_tab'] ) && isset( $_POST['screenoptionnonce'] ) ) {
$nonce = \sanitize_text_field( \wp_unslash( $_POST['screenoptionnonce'] ) );
$welcome = \sanitize_text_field( \wp_unslash( $_POST['activitypub_show_welcome_tab'] ) );
Expand Down
Loading