@@ -41,7 +41,6 @@ public function __construct( Friends $friends ) {
41
41
private function register_hooks () {
42
42
add_action ( 'admin_menu ' , array ( $ this , 'admin_menu ' ) );
43
43
add_filter ( 'users_list_table_query_args ' , array ( $ this , 'allow_role_multi_select ' ) );
44
- add_filter ( 'user_row_actions ' , array ( get_called_class (), 'user_row_actions ' ), 10 , 2 );
45
44
add_filter ( 'the_title ' , array ( $ this , 'override_post_format_title ' ), 10 , 2 );
46
45
add_filter ( 'get_edit_user_link ' , array ( $ this , 'admin_edit_user_link ' ), 10 , 2 );
47
46
add_action ( 'admin_bar_menu ' , array ( $ this , 'admin_bar_friends_menu ' ), 39 );
@@ -135,8 +134,6 @@ public function admin_menu() {
135
134
add_action ( 'load- ' . $ page_type . '_page_friends-import-export ' , array ( $ this , 'process_admin_import_export ' ) );
136
135
add_action ( 'load- ' . $ page_type . '_page_friends-settings ' , array ( $ this , 'process_admin_settings ' ) );
137
136
138
- add_submenu_page ( 'friends ' , __ ( 'Friends & Requests ' , 'friends ' ), __ ( 'Friends & Requests ' , 'friends ' ), $ required_role , 'friends-list ' , array ( $ this , 'render_friends_list ' ) );
139
-
140
137
if (
141
138
isset ( $ _GET ['_wpnonce ' ] ) && wp_verify_nonce ( sanitize_key ( $ _GET ['_wpnonce ' ] ), 'friends-refresh ' ) && 'friends-refresh ' === $ current_page
142
139
) {
@@ -467,21 +464,6 @@ public function process_admin_settings() {
467
464
}
468
465
469
466
$ this ->check_admin_settings ();
470
- foreach ( array ( 'ignore_incoming_friend_requests ' ) as $ checkbox ) {
471
- if ( isset ( $ _POST [ $ checkbox ] ) && boolval ( $ _POST [ $ checkbox ] ) ) {
472
- update_option ( 'friends_ ' . $ checkbox , true );
473
- } else {
474
- delete_option ( 'friends_ ' . $ checkbox );
475
- }
476
- }
477
-
478
- foreach ( array ( 'friend_request_notification ' ) as $ negative_user_checkbox ) {
479
- if ( isset ( $ _POST [ $ negative_user_checkbox ] ) && boolval ( $ _POST [ $ negative_user_checkbox ] ) ) {
480
- delete_user_option ( get_current_user_id (), 'friends_no_ ' . $ negative_user_checkbox );
481
- } else {
482
- update_user_option ( get_current_user_id (), 'friends_no_ ' . $ negative_user_checkbox , 1 );
483
- }
484
- }
485
467
486
468
if ( current_user_can ( 'manage_options ' ) ) {
487
469
foreach ( array ( 'force_enable_post_formats ' , 'expose_post_format_feeds ' ) as $ checkbox ) {
@@ -491,12 +473,6 @@ public function process_admin_settings() {
491
473
delete_option ( 'friends_ ' . $ checkbox );
492
474
}
493
475
}
494
-
495
- if ( isset ( $ _POST ['blocks_everywhere ' ] ) && boolval ( $ _POST ['blocks_everywhere ' ] ) ) {
496
- update_user_option ( get_current_user_id (), 'friends_blocks_everywhere ' , 1 );
497
- } else {
498
- delete_user_option ( get_current_user_id (), 'friends_blocks_everywhere ' );
499
- }
500
476
}
501
477
502
478
if ( isset ( $ _POST ['available_emojis ' ] ) && is_array ( $ _POST ['available_emojis ' ] ) ) {
@@ -646,7 +622,6 @@ public function render_admin_settings() {
646
622
'retention_delete_reacted ' => get_option ( 'friends_retention_delete_reacted ' ),
647
623
'frontend_default_view ' => get_user_option ( 'friends_frontend_default_view ' , get_current_user_id () ),
648
624
'frontend_theme ' => get_user_option ( 'friends_frontend_theme ' ),
649
- 'blocks_everywhere ' => get_user_option ( 'friends_blocks_everywhere ' ),
650
625
)
651
626
)
652
627
);
@@ -676,8 +651,6 @@ private function check_admin_edit_friend_rules() {
676
651
}
677
652
678
653
if (
679
- ! $ friend ->has_cap ( 'friend_request ' ) &&
680
- ! $ friend ->has_cap ( 'pending_friend_request ' ) &&
681
654
! $ friend ->has_cap ( 'friend ' ) &&
682
655
! $ friend ->has_cap ( 'subscription ' )
683
656
) {
@@ -826,81 +799,6 @@ public function ajax_fetch_feeds() {
826
799
wp_send_json_success ();
827
800
}
828
801
829
-
830
- public function render_friends_list () {
831
- // phpcs:disable WordPress.Security.NonceVerification
832
- $ page = isset ( $ _GET ['page ' ] ) ? sanitize_key ( $ _GET ['page ' ] ) : 'friends ' ;
833
- Friends::template_loader ()->get_template_part (
834
- 'admin/settings-header ' ,
835
- null ,
836
- array (
837
- 'menu ' => array (
838
- __ ( 'Your Friends & Subscriptions ' , 'friends ' ) => 'friends-list ' ,
839
- __ ( 'Your Friend Requests ' , 'friends ' ) => 'friends-list-requests ' ,
840
- ),
841
- 'active ' => $ page ,
842
- )
843
- );
844
-
845
- if ( 'friends-list-requests ' === $ page ) {
846
- echo '<p> ' ;
847
- echo wp_kses (
848
- sprintf (
849
- // translators: %1$s is a URL, %2$s is the translated text "Your Friends & Subscriptions".
850
- __ ( 'These are your current friend requests. To see all your friends and subscriptions, go to <a href="%1$s">%2$s</a>. ' , 'friends ' ),
851
- self_admin_url ( 'admin.php?page=friends-list ' ),
852
- __ ( 'Your Friends & Subscriptions ' , 'friends ' )
853
- ),
854
- array (
855
- 'a ' => array (
856
- 'href ' => array (),
857
- ),
858
- )
859
- );
860
- echo '</p> ' ;
861
- $ query = User_Query::all_friend_requests ();
862
- } else {
863
- $ query = User_Query::all_associated_users ();
864
- }
865
-
866
- if ( isset ( $ _GET ['deleted ' ] ) ) {
867
- ?>
868
- <div id="message" class="updated notice is-dismissible"><p>
869
- <?php
870
- echo esc_html (
871
- sprintf (
872
- // translators: % s is a username.
873
- __ ( '%s was deleted. ' , 'friends ' ),
874
- sanitize_user ( wp_unslash ( $ _GET ['deleted ' ] ) )
875
- )
876
- );
877
- ?>
878
- </p></div>
879
- <?php
880
- } elseif ( isset ( $ _GET ['error ' ] ) ) {
881
- ?>
882
- <div id="message" class="updated error is-dismissible"><p>
883
- <?php
884
- esc_html_e ( 'An error occurred. ' , 'friends ' );
885
- echo ' ' ;
886
- echo esc_html ( sanitize_text_field ( wp_unslash ( $ _GET ['error ' ] ) ) );
887
- ?>
888
- </p></div>
889
- <?php
890
- }
891
- // phpcs:enable WordPress.Security.NonceVerification
892
-
893
- Friends::template_loader ()->get_template_part (
894
- 'admin/friends-list ' ,
895
- null ,
896
- array (
897
- 'friends ' => $ query ->get_results (),
898
- )
899
- );
900
-
901
- Friends::template_loader ()->get_template_part ( 'admin/settings-footer ' );
902
- }
903
-
904
802
/**
905
803
* Render the Friend rules preview
906
804
*
@@ -968,7 +866,7 @@ public function process_admin_edit_friend() {
968
866
}
969
867
} elseif ( isset ( $ _GET ['convert-from-user ' ] ) && wp_verify_nonce ( sanitize_key ( $ _GET ['convert-from-user ' ] ), 'convert-from-user- ' . $ friend ->user_login ) ) {
970
868
if ( $ friend instanceof User && ! $ friend instanceof Subscription ) {
971
- if ( $ friend ->has_cap ( 'friends_plugin ' ) && ! $ friend -> has_cap ( ' friend ' ) && ! $ friend -> has_cap ( ' pending_friend_request ' ) && ! $ friend -> has_cap ( ' friend_request ' ) ) {
869
+ if ( $ friend ->has_cap ( 'friends_plugin ' ) ) {
972
870
Subscription::convert_from_user ( $ friend );
973
871
} else {
974
872
$ arg = 'error ' ;
@@ -1566,12 +1464,6 @@ public function process_admin_notification_manager() {
1566
1464
update_user_option ( get_current_user_id (), 'friends_no_new_post_notification ' , 1 );
1567
1465
}
1568
1466
1569
- if ( isset ( $ _POST ['friend_request_notification ' ] ) && boolval ( $ _POST ['friend_request_notification ' ] ) ) {
1570
- delete_user_option ( get_current_user_id (), 'friends_no_friend_request_notification ' );
1571
- } else {
1572
- update_user_option ( get_current_user_id (), 'friends_no_friend_request_notification ' , 1 );
1573
- }
1574
-
1575
1467
if ( isset ( $ _POST ['friend_follower_notification ' ] ) && boolval ( $ _POST ['friend_follower_notification ' ] ) ) {
1576
1468
delete_user_option ( get_current_user_id (), 'friends_no_friend_follower_notification ' );
1577
1469
} else {
@@ -1651,7 +1543,7 @@ public function render_admin_notification_manager() {
1651
1543
1652
1544
$ friend_users = new User_Query (
1653
1545
array (
1654
- 'role__in ' => array ( 'friend ' , 'acquaintance ' , 'pending_friend_request ' , ' friend_request ' , ' subscription ' ),
1546
+ 'role__in ' => array ( 'friend ' , 'acquaintance ' , 'subscription ' ),
1655
1547
'orderby ' => 'display_name ' ,
1656
1548
'order ' => 'ASC ' ,
1657
1549
)
@@ -1663,16 +1555,15 @@ public function render_admin_notification_manager() {
1663
1555
}
1664
1556
1665
1557
$ args = array (
1666
- 'friend_users ' => $ friend_users ->get_results (),
1667
- 'friends_settings_url ' => add_query_arg ( '_wp_http_referer ' , remove_query_arg ( '_wp_http_referer ' ), self_admin_url ( 'admin.php?page=friends-settings ' ) ),
1668
- 'hide_from_friends_page ' => $ hide_from_friends_page ,
1669
- 'no_friend_request_notification ' => get_user_option ( 'friends_no_friend_request_notification ' ),
1670
- 'keyword_override_disabled ' => get_user_option ( 'friends_keyword_notification_override_disabled ' ),
1671
- 'no_new_post_notification ' => get_user_option ( 'friends_no_new_post_notification ' ),
1672
- 'no_keyword_notification ' => get_user_option ( 'friends_no_keyword_notification ' ),
1673
- 'notification_keywords ' => Feed::get_all_notification_keywords (),
1674
- 'active_keywords ' => Feed::get_active_notification_keywords (),
1675
- 'feed_parsers ' => $ this ->friends ->feed ->get_registered_parsers (),
1558
+ 'friend_users ' => $ friend_users ->get_results (),
1559
+ 'friends_settings_url ' => add_query_arg ( '_wp_http_referer ' , remove_query_arg ( '_wp_http_referer ' ), self_admin_url ( 'admin.php?page=friends-settings ' ) ),
1560
+ 'hide_from_friends_page ' => $ hide_from_friends_page ,
1561
+ 'keyword_override_disabled ' => get_user_option ( 'friends_keyword_notification_override_disabled ' ),
1562
+ 'no_new_post_notification ' => get_user_option ( 'friends_no_new_post_notification ' ),
1563
+ 'no_keyword_notification ' => get_user_option ( 'friends_no_keyword_notification ' ),
1564
+ 'notification_keywords ' => Feed::get_all_notification_keywords (),
1565
+ 'active_keywords ' => Feed::get_active_notification_keywords (),
1566
+ 'feed_parsers ' => $ this ->friends ->feed ->get_registered_parsers (),
1676
1567
);
1677
1568
1678
1569
if ( class_exists ( '\Activitypub\Notification ' ) ) {
@@ -2011,76 +1902,6 @@ public static function get_users_url() {
2011
1902
return 'admin.php?page=friends-list ' ;
2012
1903
}
2013
1904
2014
- /**
2015
- * Add actions to the user rows
2016
- *
2017
- * @param array $actions The existing actions.
2018
- * @param \WP_User $user The user in question.
2019
- * @return array The extended actions.
2020
- */
2021
- public static function user_row_actions ( array $ actions , \WP_User $ user ) {
2022
- if (
2023
- ! Friends::has_required_privileges () ||
2024
- (
2025
- ! $ user ->has_cap ( 'friend_request ' ) &&
2026
- ! $ user ->has_cap ( 'pending_friend_request ' ) &&
2027
- ! $ user ->has_cap ( 'friend ' ) &&
2028
- ! $ user ->has_cap ( 'subscription ' )
2029
- )
2030
- ) {
2031
- return $ actions ;
2032
- }
2033
-
2034
- if ( is_multisite () ) {
2035
- // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
2036
- $ actions = array_merge ( array ( 'edit ' => '<a href=" ' . esc_url ( self_admin_url ( 'admin.php?page=edit-friend&user= ' . $ user ->user_login ) ) . '"> ' . __ ( 'Edit ' ) . '</a> ' ), $ actions );
2037
- }
2038
-
2039
- // Ensuire we have a friends user here.
2040
- $ user = new User ( $ user );
2041
-
2042
- $ actions ['view ' ] = Frontend::get_link (
2043
- $ user ->user_url ,
2044
- sprintf (
2045
- // translators: %s: Author’s display name.
2046
- __ ( 'Visit %s’s website ' ), // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
2047
- $ user ->display_name
2048
- ),
2049
- array (),
2050
- $ user
2051
- );
2052
- unset( $ actions ['resetpassword ' ] );
2053
-
2054
- if ( $ user ->has_cap ( 'friend_request ' ) ) {
2055
- $ link = self_admin_url ( wp_nonce_url ( 'users.php?action=accept_friend_request&users[]= ' . $ user ->ID ) );
2056
-
2057
- $ actions ['user_accept_friend_request ' ] = '<a href=" ' . esc_url ( $ link ) . '"> ' . __ ( 'Accept Friend Request ' , 'friends ' ) . '</a> ' ;
2058
- $ message = get_user_option ( 'friends_request_message ' , $ user ->ID );
2059
- $ actions ['friends friends_request_date ' ] = '<br/><span class="nonessential"> ' . esc_html (
2060
- sprintf (
2061
- // translators: %s is a date.
2062
- __ ( 'Requested on %s ' , 'friends ' ),
2063
- date_i18n ( __ ( 'F j, Y g:i a ' ), strtotime ( $ user ->user_registered ) ) // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
2064
- )
2065
- ) . '</span> ' ;
2066
- if ( $ message ) {
2067
- // translators: %s is a message text.
2068
- $ actions ['friends friend_request_message ' ] = '<br/><span class="nonessential"> ' . esc_html ( sprintf ( __ ( 'Message: %s ' , 'friends ' ), $ message ) ) . '</span> ' ;
2069
- }
2070
- }
2071
-
2072
- if ( $ user ->has_cap ( 'pending_friend_request ' ) || $ user ->has_cap ( 'subscription ' ) ) {
2073
- $ link = wp_nonce_url ( add_query_arg ( '_wp_http_referer ' , remove_query_arg ( '_wp_http_referer ' ), self_admin_url ( 'admin.php?page=edit-friend&user= ' . $ user ->user_login ) ), 'add-friend- ' . $ user ->user_login , 'add-friend ' );
2074
- if ( $ user ->has_cap ( 'pending_friend_request ' ) ) {
2075
- $ actions ['user_friend_request ' ] = '<a href=" ' . esc_url ( $ link ) . '"> ' . __ ( 'Resend Friend Request ' , 'friends ' ) . '</a> ' ;
2076
- } elseif ( $ user ->has_cap ( 'subscription ' ) ) {
2077
- $ actions ['user_friend_request ' ] = '<a href=" ' . esc_url ( $ link ) . '"> ' . __ ( 'Send Friend Request ' , 'friends ' ) . '</a> ' ;
2078
- }
2079
- }
2080
-
2081
- return $ actions ;
2082
- }
2083
-
2084
1905
/**
2085
1906
* Override the post title for specific post formats.
2086
1907
*
@@ -2322,31 +2143,10 @@ public function toolbox_bookmarklets() {
2322
2143
* @return array Items + our items.
2323
2144
*/
2324
2145
public function dashboard_glance_items ( $ items ) {
2325
- $ count_users = count_users ();
2326
- $ count = array_merge (
2327
- array (
2328
- 'friend ' => 0 ,
2329
- 'acquaintance ' => 0 ,
2330
- 'friend_request ' => 0 ,
2331
- 'subscription ' => 0 ,
2332
- ),
2333
- $ count_users ['avail_roles ' ]
2334
- );
2335
- $ friend_count = $ count ['friend ' ] + $ count ['acquaintance ' ];
2336
- $ friend_request_count = $ count ['friend_request ' ];
2337
- $ subscription_count = $ count ['subscription ' ];
2146
+ $ subscription_count = User_Query::all_subscriptions ()->get_total ();
2338
2147
$ friend_post_count = wp_count_posts ( Friends::CPT );
2339
2148
$ friend_post_count = $ friend_post_count ->publish + $ friend_post_count ->private ;
2340
2149
2341
- $ items [] = '<a class="friends" href=" ' . self_admin_url ( 'users.php?role=friend ' ) . '"> ' . sprintf (
2342
- // translators: %s is the number of your friends.
2343
- _n ( '%s Friend ' , '%s Friends ' , $ friend_count , 'friends ' ),
2344
- $ friend_count
2345
- ) . '</a> ' ;
2346
- if ( $ friend_request_count ) {
2347
- // translators: %s is the number of friend requests.
2348
- $ items [] = '<a class="friend-requests" href=" ' . self_admin_url ( 'users.php?role=friend_request ' ) . '"> ' . sprintf ( _n ( '%s Friend Request ' , '%s Friend Requests ' , $ friend_request_count , 'friends ' ), $ friend_request_count ) . '</a> ' ;
2349
- }
2350
2150
if ( $ subscription_count ) {
2351
2151
// translators: %s is the number of subscriptions.
2352
2152
$ items [] = '<a class="subscriptions" href=" ' . self_admin_url ( 'users.php?role=subscription ' ) . '"> ' . sprintf ( _n ( '%s Subscription ' , '%s Subscriptions ' , $ subscription_count , 'friends ' ), $ subscription_count ) . '</a> ' ;
0 commit comments