\__( 'Followers per page', 'activitypub' ), 'default' => 20, 'option' => 'activitypub_followers_per_page', ) ); } /** * Add screen options for following list. * * @see Menu::admin_menu() */ public static function add_following_list_options() { \add_screen_option( 'per_page', array( 'label' => \__( 'Following per page', 'activitypub' ), 'default' => 20, 'option' => 'activitypub_following_per_page', ) ); } /** * Add screen options for blocked actors list. * * @see Menu::admin_menu() */ public static function add_blocked_actors_list_options() { \add_screen_option( 'per_page', array( 'label' => \__( 'Blocked Actors per page', 'activitypub' ), 'default' => 20, 'option' => 'activitypub_blocked_actors_per_page', ) ); } /** * Set per_page screen options. * * @param mixed $status Screen option value. Default false to skip. * @param string $option The option name. * @param mixed $value The option value. * @return int */ public static function set_per_page_option( $status, $option, $value ) { if ( 'activitypub_followers_per_page' === $option || 'activitypub_following_per_page' === $option || 'activitypub_blocked_actors_per_page' === $option ) { $value = (int) $value; if ( $value > 0 && $value <= 100 ) { return $value; } } return $status; } /** * Add screen options. * * @param string $screen_settings The screen settings. * @param object $screen The screen object. * * @return string The screen settings. */ public static function add_screen_option( $screen_settings, $screen ) { if ( 'settings_page_activitypub' !== $screen->id ) { return $screen_settings; } // No screen options on followers, following, and blocked-actors tabs. The per_page screen options interfere with them. if ( \in_array( \sanitize_text_field( \wp_unslash( $_GET['tab'] ?? 'welcome' ) ), array( 'followers', 'following', 'blocked-actors' ), true ) ) { // phpcs:ignore WordPress.Security.NonceVerification return $screen_settings; } // Verify screen options nonce. if ( isset( $_POST['screenoptionnonce'] ) ) { $nonce = \sanitize_text_field( \wp_unslash( $_POST['screenoptionnonce'] ) ); if ( ! \wp_verify_nonce( $nonce, 'screen-options-nonce' ) ) { return $screen_settings; } } $screen_options = array( 'activitypub_show_welcome_tab' => \__( 'Welcome Page', 'activitypub' ), 'activitypub_show_advanced_tab' => \__( 'Advanced Settings', 'activitypub' ), ); /** * Filters Activitypub settings screen options. * * @param string[] $screen_options Screen options. An array of user meta keys and screen option labels. */ $screen_options = \apply_filters( 'activitypub_screen_options', $screen_options ); if ( empty( $screen_options ) ) { return $screen_settings; } foreach ( $screen_options as $option => $label ) { if ( isset( $_POST[ $option ] ) ) { $value = \sanitize_text_field( \wp_unslash( $_POST[ $option ] ) ); \update_user_meta( \get_current_user_id(), $option, empty( $value ) ? 0 : 1 ); } } \ob_start(); ?>
$label ) : ?>
id ) { return $show_submit; } return true; } }