From 48ab6e53cc0d35d77b38c83c9305694b5910b9f1 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Fri, 19 May 2023 15:21:49 +0200 Subject: [PATCH] init filter --- includes/class-admin.php | 23 +++++++++++++++++++++++ includes/table/class-followers.php | 6 +++++- templates/followers-list.php | 7 +++---- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/includes/class-admin.php b/includes/class-admin.php index fe44ed4..b8ba3f5 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -37,6 +37,19 @@ class Admin { $followers_list_page = \add_users_page( \__( 'Followers', 'activitypub' ), \__( 'Followers', 'activitypub' ), 'read', 'activitypub-followers-list', array( self::class, 'followers_list_page' ) ); + add_filter( "manage_{$followers_list_page}_columns", array( '\Activitypub\Table\Followers', 'get_default_columns' ) ); + add_filter( + 'screen_options_show_screen', + function( $show_screen, $screen ) use ( $followers_list_page ) { + if ( $followers_list_page === $screen->base ) { + return true; + } + return $show_screen; + }, + 2, + 10 + ); + \add_action( 'load-' . $followers_list_page, array( self::class, 'add_followers_list_help_tab' ) ); } @@ -71,6 +84,16 @@ class Admin { * Load user settings page */ public static function followers_list_page() { + add_screen_option( + 'per_page', + array( + 'default' => 100, + 'option' => 'edit_1_per_page', + ) + ); + + add_screen_option( 'layout_columns', array( 'max' => 2, 'default' => 2 ) ); + \load_template( ACTIVITYPUB_PLUGIN_DIR . 'templates/followers-list.php' ); } diff --git a/includes/table/class-followers.php b/includes/table/class-followers.php index 03fb70f..037a0aa 100644 --- a/includes/table/class-followers.php +++ b/includes/table/class-followers.php @@ -9,7 +9,7 @@ if ( ! \class_exists( '\WP_List_Table' ) ) { } class Followers extends WP_List_Table { - public function get_columns() { + public static function get_default_columns() { return array( 'cb' => '', 'avatar' => \__( 'Avatar', 'activitypub' ), @@ -21,6 +21,10 @@ class Followers extends WP_List_Table { ); } + public function get_columns() { + return self::get_default_columns(); + } + public function get_sortable_columns() { return array(); } diff --git a/templates/followers-list.php b/templates/followers-list.php index c79c961..00da02c 100644 --- a/templates/followers-list.php +++ b/templates/followers-list.php @@ -1,16 +1,15 @@ +

- -
prepare_items(); - $token_table->display(); + $followes_table->prepare_items(); + $followes_table->display(); ?>