Skip to content

Commit 9894a39

Browse files
committed
Remove automatic status
1 parent d95fc8d commit 9894a39

35 files changed

+26
-2340
lines changed

blocks/friends-list/src/index.js

-12
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,6 @@ registerBlockType( 'friends/friends-list', {
2222
onChange={ user_types => setAttributes( { user_types } ) }
2323
value={ attributes.user_types }
2424
options={ [
25-
{
26-
label: __( 'Friends', 'friends' ),
27-
value: 'friends',
28-
},
29-
{
30-
label: __( 'Friend requests', 'friends' ),
31-
value: 'friend_requests',
32-
},
33-
{
34-
label: __( 'Subscriptions', 'friends' ),
35-
value: 'subscriptions',
36-
},
3725
{
3826
label: __( 'Friends + Subscriptions', 'friends' ),
3927
value: 'friends_subscriptions',

friends.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
require_once __DIR__ . '/feed-parsers/class-feed-item.php';
4141

4242
require_once __DIR__ . '/includes/class-admin.php';
43-
require_once __DIR__ . '/includes/class-automatic-status.php';
4443
require_once __DIR__ . '/includes/class-blocks.php';
4544
require_once __DIR__ . '/includes/class-feed.php';
4645
require_once __DIR__ . '/includes/class-frontend.php';
@@ -75,6 +74,9 @@
7574
add_filter( 'customize_loaded_components', array( __NAMESPACE__ . '\Frontend', 'ensure_widget_editing' ) );
7675

7776
require_once __DIR__ . '/widgets/class-widget-base-friends-list.php';
77+
require_once __DIR__ . '/widgets/class-widget-add-subscription.php';
78+
add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Add_Subscription', 'register' ) );
79+
7880
require_once __DIR__ . '/widgets/class-widget-refresh.php';
7981
add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Refresh', 'register' ) );
8082

@@ -87,9 +89,6 @@
8789
require_once __DIR__ . '/widgets/class-widget-recent-friends-list.php';
8890
add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Recent_Friends_List', 'register' ) );
8991

90-
require_once __DIR__ . '/widgets/class-widget-friend-request.php';
91-
add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Friend_Request', 'register' ) );
92-
9392
require_once __DIR__ . '/widgets/class-widget-friend-stats.php';
9493
add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Friend_Stats', 'register' ) );
9594

includes/class-admin.php

+12-212
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public function __construct( Friends $friends ) {
4141
private function register_hooks() {
4242
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
4343
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 );
4544
add_filter( 'the_title', array( $this, 'override_post_format_title' ), 10, 2 );
4645
add_filter( 'get_edit_user_link', array( $this, 'admin_edit_user_link' ), 10, 2 );
4746
add_action( 'admin_bar_menu', array( $this, 'admin_bar_friends_menu' ), 39 );
@@ -135,8 +134,6 @@ public function admin_menu() {
135134
add_action( 'load-' . $page_type . '_page_friends-import-export', array( $this, 'process_admin_import_export' ) );
136135
add_action( 'load-' . $page_type . '_page_friends-settings', array( $this, 'process_admin_settings' ) );
137136

138-
add_submenu_page( 'friends', __( 'Friends & Requests', 'friends' ), __( 'Friends & Requests', 'friends' ), $required_role, 'friends-list', array( $this, 'render_friends_list' ) );
139-
140137
if (
141138
isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'friends-refresh' ) && 'friends-refresh' === $current_page
142139
) {
@@ -467,21 +464,6 @@ public function process_admin_settings() {
467464
}
468465

469466
$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-
}
485467

486468
if ( current_user_can( 'manage_options' ) ) {
487469
foreach ( array( 'force_enable_post_formats', 'expose_post_format_feeds' ) as $checkbox ) {
@@ -491,12 +473,6 @@ public function process_admin_settings() {
491473
delete_option( 'friends_' . $checkbox );
492474
}
493475
}
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-
}
500476
}
501477

502478
if ( isset( $_POST['available_emojis'] ) && is_array( $_POST['available_emojis'] ) ) {
@@ -646,7 +622,6 @@ public function render_admin_settings() {
646622
'retention_delete_reacted' => get_option( 'friends_retention_delete_reacted' ),
647623
'frontend_default_view' => get_user_option( 'friends_frontend_default_view', get_current_user_id() ),
648624
'frontend_theme' => get_user_option( 'friends_frontend_theme' ),
649-
'blocks_everywhere' => get_user_option( 'friends_blocks_everywhere' ),
650625
)
651626
)
652627
);
@@ -676,8 +651,6 @@ private function check_admin_edit_friend_rules() {
676651
}
677652

678653
if (
679-
! $friend->has_cap( 'friend_request' ) &&
680-
! $friend->has_cap( 'pending_friend_request' ) &&
681654
! $friend->has_cap( 'friend' ) &&
682655
! $friend->has_cap( 'subscription' )
683656
) {
@@ -826,81 +799,6 @@ public function ajax_fetch_feeds() {
826799
wp_send_json_success();
827800
}
828801

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-
904802
/**
905803
* Render the Friend rules preview
906804
*
@@ -968,7 +866,7 @@ public function process_admin_edit_friend() {
968866
}
969867
} elseif ( isset( $_GET['convert-from-user'] ) && wp_verify_nonce( sanitize_key( $_GET['convert-from-user'] ), 'convert-from-user-' . $friend->user_login ) ) {
970868
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' ) ) {
972870
Subscription::convert_from_user( $friend );
973871
} else {
974872
$arg = 'error';
@@ -1566,12 +1464,6 @@ public function process_admin_notification_manager() {
15661464
update_user_option( get_current_user_id(), 'friends_no_new_post_notification', 1 );
15671465
}
15681466

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-
15751467
if ( isset( $_POST['friend_follower_notification'] ) && boolval( $_POST['friend_follower_notification'] ) ) {
15761468
delete_user_option( get_current_user_id(), 'friends_no_friend_follower_notification' );
15771469
} else {
@@ -1651,7 +1543,7 @@ public function render_admin_notification_manager() {
16511543

16521544
$friend_users = new User_Query(
16531545
array(
1654-
'role__in' => array( 'friend', 'acquaintance', 'pending_friend_request', 'friend_request', 'subscription' ),
1546+
'role__in' => array( 'friend', 'acquaintance', 'subscription' ),
16551547
'orderby' => 'display_name',
16561548
'order' => 'ASC',
16571549
)
@@ -1663,16 +1555,15 @@ public function render_admin_notification_manager() {
16631555
}
16641556

16651557
$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(),
16761567
);
16771568

16781569
if ( class_exists( '\Activitypub\Notification' ) ) {
@@ -2011,76 +1902,6 @@ public static function get_users_url() {
20111902
return 'admin.php?page=friends-list';
20121903
}
20131904

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&#8217;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-
20841905
/**
20851906
* Override the post title for specific post formats.
20861907
*
@@ -2322,31 +2143,10 @@ public function toolbox_bookmarklets() {
23222143
* @return array Items + our items.
23232144
*/
23242145
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();
23382147
$friend_post_count = wp_count_posts( Friends::CPT );
23392148
$friend_post_count = $friend_post_count->publish + $friend_post_count->private;
23402149

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-
}
23502150
if ( $subscription_count ) {
23512151
// translators: %s is the number of subscriptions.
23522152
$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

Comments
 (0)