init filter

This commit is contained in:
Matthias Pfefferle 2023-05-19 15:21:49 +02:00
parent e46991e83c
commit 48ab6e53cc
3 changed files with 31 additions and 5 deletions

View file

@ -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' );
}

View file

@ -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' => '<input type="checkbox" />',
'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();
}

View file

@ -1,16 +1,15 @@
<?php $followes_table = new \Activitypub\Table\Followers(); ?>
<div class="wrap">
<h1><?php \esc_html_e( 'Followers', 'activitypub' ); ?></h1>
<?php // translators: ?>
<p><?php \printf( \esc_html__( 'You currently have %s followers.', 'activitypub' ), \esc_attr( \Activitypub\Collection\Followers::count_followers( \get_current_user_id() ) ) ); ?></p>
<?php $token_table = new \Activitypub\Table\Followers(); ?>
<form method="get">
<input type="hidden" name="page" value="activitypub-followers-list" />
<?php
$token_table->prepare_items();
$token_table->display();
$followes_table->prepare_items();
$followes_table->display();
?>
<?php wp_nonce_field( 'activitypub-followers-list', '_apnonce' ); ?>
</form>