@@ -30,19 +30,24 @@ public function __construct() {
3030
3131 public function get_columns () {
3232 return array (
33- 'cb ' => '<input type="checkbox" /> ' ,
34- 'avatar ' => \__ ( 'Avatar ' , 'activitypub ' ),
35- 'name ' => \__ ( 'Name ' , 'activitypub ' ),
36- 'username ' => \__ ( 'Username ' , 'activitypub ' ),
37- 'url ' => \__ ( 'URL ' , 'activitypub ' ),
38- 'updated ' => \__ ( 'Last updated ' , 'activitypub ' ),
39- //'errors' => \__( 'Errors', 'activitypub' ),
40- //'latest-error' => \__( 'Latest Error Message', 'activitypub' ),
33+ 'cb ' => '<input type="checkbox" /> ' ,
34+ 'avatar ' => \__ ( 'Avatar ' , 'activitypub ' ),
35+ 'post_title ' => \__ ( 'Name ' , 'activitypub ' ),
36+ 'username ' => \__ ( 'Username ' , 'activitypub ' ),
37+ 'url ' => \__ ( 'URL ' , 'activitypub ' ),
38+ 'published ' => \__ ( 'Followed ' , 'activitypub ' ),
39+ 'modified ' => \__ ( 'Last updated ' , 'activitypub ' ),
4140 );
4241 }
4342
4443 public function get_sortable_columns () {
45- return array ();
44+ $ sortable_columns = array (
45+ 'post_title ' => array ( 'post_title ' , true ),
46+ 'modified ' => array ( 'modified ' , false ),
47+ 'published ' => array ( 'published ' , false ),
48+ );
49+
50+ return $ sortable_columns ;
4651 }
4752
4853 public function prepare_items () {
@@ -55,8 +60,32 @@ public function prepare_items() {
5560 $ page_num = $ this ->get_pagenum ();
5661 $ per_page = 20 ;
5762
58- $ followers = FollowerCollection::get_followers ( $ this ->user_id , $ per_page , $ page_num );
59- $ counter = FollowerCollection::count_followers ( $ this ->user_id );
63+ $ args = array ();
64+
65+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
66+ if ( isset ( $ _GET ['orderby ' ] ) ) {
67+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
68+ $ args ['orderby ' ] = sanitize_text_field ( wp_unslash ( $ _GET ['orderby ' ] ) );
69+ }
70+
71+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
72+ if ( isset ( $ _GET ['order ' ] ) ) {
73+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
74+ $ args ['order ' ] = sanitize_text_field ( wp_unslash ( $ _GET ['order ' ] ) );
75+ }
76+
77+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
78+ if ( isset ( $ _GET ['s ' ] ) && isset ( $ _REQUEST ['_wpnonce ' ] ) ) {
79+ $ nonce = sanitize_text_field ( wp_unslash ( $ _REQUEST ['_wpnonce ' ] ) );
80+ if ( wp_verify_nonce ( $ nonce , 'bulk- ' . $ this ->_args ['plural ' ] ) ) {
81+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
82+ $ args ['s ' ] = sanitize_text_field ( wp_unslash ( $ _GET ['s ' ] ) );
83+ }
84+ }
85+
86+ $ followers_with_count = FollowerCollection::get_followers_with_count ( $ this ->user_id , $ per_page , $ page_num , $ args );
87+ $ followers = $ followers_with_count ['followers ' ];
88+ $ counter = $ followers_with_count ['total ' ];
6089
6190 $ this ->items = array ();
6291 $ this ->set_pagination_args (
@@ -69,14 +98,13 @@ public function prepare_items() {
6998
7099 foreach ( $ followers as $ follower ) {
71100 $ item = array (
72- 'icon ' => esc_attr ( $ follower ->get_icon_url () ),
73- 'name ' => esc_attr ( $ follower ->get_name () ),
74- 'username ' => esc_attr ( $ follower ->get_preferred_username () ),
75- 'url ' => esc_attr ( $ follower ->get_url () ),
76- 'identifier ' => esc_attr ( $ follower ->get_id () ),
77- 'updated ' => esc_attr ( $ follower ->get_updated () ),
78- 'errors ' => $ follower ->count_errors (),
79- 'latest-error ' => $ follower ->get_latest_error_message (),
101+ 'icon ' => esc_attr ( $ follower ->get_icon_url () ),
102+ 'post_title ' => esc_attr ( $ follower ->get_name () ),
103+ 'username ' => esc_attr ( $ follower ->get_preferred_username () ),
104+ 'url ' => esc_attr ( $ follower ->get_url () ),
105+ 'identifier ' => esc_attr ( $ follower ->get_id () ),
106+ 'published ' => esc_attr ( $ follower ->get_published () ),
107+ 'modified ' => esc_attr ( $ follower ->get_updated () ),
80108 );
81109
82110 $ this ->items [] = $ item ;
@@ -116,11 +144,11 @@ public function column_cb( $item ) {
116144 }
117145
118146 public function process_action () {
119- if ( ! isset ( $ _REQUEST ['followers ' ] ) || ! isset ( $ _REQUEST ['_apnonce ' ] ) ) {
147+ if ( ! isset ( $ _REQUEST ['followers ' ] ) || ! isset ( $ _REQUEST ['_wpnonce ' ] ) ) {
120148 return false ;
121149 }
122- $ nonce = sanitize_text_field ( wp_unslash ( $ _REQUEST ['_apnonce ' ] ) );
123- if ( ! wp_verify_nonce ( $ nonce , 'activitypub-followers-list ' ) ) {
150+ $ nonce = sanitize_text_field ( wp_unslash ( $ _REQUEST ['_wpnonce ' ] ) );
151+ if ( ! wp_verify_nonce ( $ nonce , 'bulk- ' . $ this -> _args [ ' plural ' ] ) ) {
124152 return false ;
125153 }
126154
0 commit comments