init filter
This commit is contained in:
parent
e46991e83c
commit
48ab6e53cc
3 changed files with 31 additions and 5 deletions
|
@ -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' ) );
|
$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' ) );
|
\add_action( 'load-' . $followers_list_page, array( self::class, 'add_followers_list_help_tab' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +84,16 @@ class Admin {
|
||||||
* Load user settings page
|
* Load user settings page
|
||||||
*/
|
*/
|
||||||
public static function followers_list_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' );
|
\load_template( ACTIVITYPUB_PLUGIN_DIR . 'templates/followers-list.php' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ if ( ! \class_exists( '\WP_List_Table' ) ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Followers extends WP_List_Table {
|
class Followers extends WP_List_Table {
|
||||||
public function get_columns() {
|
public static function get_default_columns() {
|
||||||
return array(
|
return array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'avatar' => \__( 'Avatar', 'activitypub' ),
|
'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() {
|
public function get_sortable_columns() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
|
<?php $followes_table = new \Activitypub\Table\Followers(); ?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h1><?php \esc_html_e( 'Followers', 'activitypub' ); ?></h1>
|
<h1><?php \esc_html_e( 'Followers', 'activitypub' ); ?></h1>
|
||||||
|
|
||||||
<?php // translators: ?>
|
<?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>
|
<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">
|
<form method="get">
|
||||||
<input type="hidden" name="page" value="activitypub-followers-list" />
|
<input type="hidden" name="page" value="activitypub-followers-list" />
|
||||||
<?php
|
<?php
|
||||||
$token_table->prepare_items();
|
$followes_table->prepare_items();
|
||||||
$token_table->display();
|
$followes_table->display();
|
||||||
?>
|
?>
|
||||||
<?php wp_nonce_field( 'activitypub-followers-list', '_apnonce' ); ?>
|
<?php wp_nonce_field( 'activitypub-followers-list', '_apnonce' ); ?>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue