search for followers and order the output list
This commit is contained in:
parent
fd6cb84ba3
commit
c52983f908
4 changed files with 47 additions and 20 deletions
|
@ -315,7 +315,7 @@ class Follower extends Actor {
|
||||||
$object->set_id( $post->guid );
|
$object->set_id( $post->guid );
|
||||||
$object->set_name( $post->post_title );
|
$object->set_name( $post->post_title );
|
||||||
$object->set_summary( $post->post_excerpt );
|
$object->set_summary( $post->post_excerpt );
|
||||||
$object->set_published( gmdate( 'Y-m-d H:i:s', strtotime( $post->post_published ) ) );
|
$object->set_published( gmdate( 'Y-m-d H:i:s', strtotime( $post->post_date ) ) );
|
||||||
$object->set_updated( gmdate( 'Y-m-d H:i:s', strtotime( $post->post_modified ) ) );
|
$object->set_updated( gmdate( 'Y-m-d H:i:s', strtotime( $post->post_modified ) ) );
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
|
|
|
@ -32,17 +32,22 @@ class Followers extends WP_List_Table {
|
||||||
return array(
|
return array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'avatar' => \__( 'Avatar', 'activitypub' ),
|
'avatar' => \__( 'Avatar', 'activitypub' ),
|
||||||
'name' => \__( 'Name', 'activitypub' ),
|
'post_title' => \__( 'Name', 'activitypub' ),
|
||||||
'username' => \__( 'Username', 'activitypub' ),
|
'username' => \__( 'Username', 'activitypub' ),
|
||||||
'url' => \__( 'URL', 'activitypub' ),
|
'url' => \__( 'URL', 'activitypub' ),
|
||||||
'updated' => \__( 'Last updated', 'activitypub' ),
|
'published' => \__( 'Followed', 'activitypub' ),
|
||||||
//'errors' => \__( 'Errors', 'activitypub' ),
|
'modified' => \__( 'Last updated', 'activitypub' ),
|
||||||
//'latest-error' => \__( 'Latest Error Message', 'activitypub' ),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_sortable_columns() {
|
public function get_sortable_columns() {
|
||||||
return array();
|
$sortable_columns = array(
|
||||||
|
'post_title' => array( 'post_title', true ),
|
||||||
|
'modified' => array( 'modified', false ),
|
||||||
|
'published' => array( 'published', false ),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $sortable_columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prepare_items() {
|
public function prepare_items() {
|
||||||
|
@ -55,8 +60,29 @@ class Followers extends WP_List_Table {
|
||||||
$page_num = $this->get_pagenum();
|
$page_num = $this->get_pagenum();
|
||||||
$per_page = 20;
|
$per_page = 20;
|
||||||
|
|
||||||
$followers = FollowerCollection::get_followers( $this->user_id, $per_page, $page_num );
|
$args = array();
|
||||||
$counter = FollowerCollection::count_followers( $this->user_id );
|
|
||||||
|
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||||
|
if ( isset( $_GET['orderby'] ) ) {
|
||||||
|
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||||
|
$args['orderby'] = sanitize_text_field( wp_unslash( $_GET['orderby'] ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||||
|
if ( isset( $_GET['order'] ) ) {
|
||||||
|
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||||
|
$args['order'] = sanitize_text_field( wp_unslash( $_GET['order'] ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||||
|
if ( isset( $_GET['s'] ) ) {
|
||||||
|
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||||
|
$args['s'] = sanitize_text_field( wp_unslash( $_GET['s'] ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$followers_with_count = FollowerCollection::get_followers_with_count( $this->user_id, $per_page, $page_num, $args );
|
||||||
|
$followers = $followers_with_count['followers'];
|
||||||
|
$counter = $followers_with_count['total'];
|
||||||
|
|
||||||
$this->items = array();
|
$this->items = array();
|
||||||
$this->set_pagination_args(
|
$this->set_pagination_args(
|
||||||
|
@ -70,13 +96,12 @@ class Followers extends WP_List_Table {
|
||||||
foreach ( $followers as $follower ) {
|
foreach ( $followers as $follower ) {
|
||||||
$item = array(
|
$item = array(
|
||||||
'icon' => esc_attr( $follower->get_icon_url() ),
|
'icon' => esc_attr( $follower->get_icon_url() ),
|
||||||
'name' => esc_attr( $follower->get_name() ),
|
'post_title' => esc_attr( $follower->get_name() ),
|
||||||
'username' => esc_attr( $follower->get_preferred_username() ),
|
'username' => esc_attr( $follower->get_preferred_username() ),
|
||||||
'url' => esc_attr( $follower->get_url() ),
|
'url' => esc_attr( $follower->get_url() ),
|
||||||
'identifier' => esc_attr( $follower->get_id() ),
|
'identifier' => esc_attr( $follower->get_id() ),
|
||||||
'updated' => esc_attr( $follower->get_updated() ),
|
'published' => esc_attr( $follower->get_published() ),
|
||||||
'errors' => $follower->count_errors(),
|
'modified' => esc_attr( $follower->get_updated() ),
|
||||||
'latest-error' => $follower->get_latest_error_message(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
|
|
|
@ -21,6 +21,7 @@ $followers_template = _n( 'Your blog profile currently has %s follower.', 'Your
|
||||||
<input type="hidden" name="tab" value="followers" />
|
<input type="hidden" name="tab" value="followers" />
|
||||||
<?php
|
<?php
|
||||||
$table->prepare_items();
|
$table->prepare_items();
|
||||||
|
$table->search_box( 'Search', 'search' );
|
||||||
$table->display();
|
$table->display();
|
||||||
?>
|
?>
|
||||||
<?php wp_nonce_field( 'activitypub-followers-list', '_apnonce' ); ?>
|
<?php wp_nonce_field( 'activitypub-followers-list', '_apnonce' ); ?>
|
||||||
|
|
|
@ -14,6 +14,7 @@ $followers_template = _n( 'Your author profile currently has %s follower.', 'You
|
||||||
<input type="hidden" name="page" value="activitypub-followers-list" />
|
<input type="hidden" name="page" value="activitypub-followers-list" />
|
||||||
<?php
|
<?php
|
||||||
$table->prepare_items();
|
$table->prepare_items();
|
||||||
|
$table->search_box( 'Search', 'search' );
|
||||||
$table->display();
|
$table->display();
|
||||||
?>
|
?>
|
||||||
<?php wp_nonce_field( 'activitypub-followers-list', '_apnonce' ); ?>
|
<?php wp_nonce_field( 'activitypub-followers-list', '_apnonce' ); ?>
|
||||||
|
|
Loading…
Reference in a new issue