Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong Friend Requests link #184

Merged
merged 1 commit into from
Jan 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions includes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function register_admin_menu() {
add_action( 'load-' . $page_type . '_page_friends-settings', array( $this, 'process_admin_settings' ) );

if ( $this->friends_unread_friend_request_count( 0 ) > 0 ) {
add_submenu_page( 'friends', __( 'Friend Requests', 'friends' ), __( 'Friend Requests', 'friends' ) . $unread_badge, $required_role, 'friend-list?requests' );
add_submenu_page( 'friends', __( 'Friend Requests', 'friends' ), __( 'Friend Requests', 'friends' ) . $unread_badge, $required_role, 'friends-list-requests', array( $this, 'render_friends_list' ) );
}

add_submenu_page( 'friends', __( 'Friends & Requests', 'friends' ), __( 'Friends & Requests', 'friends' ), $required_role, 'friends-list', array( $this, 'render_friends_list' ) );
Expand Down Expand Up @@ -872,7 +872,13 @@ public function ajax_refresh_link_token() {
wp_die();
}
public function render_friends_list() {
echo '<div class="wrap"><h3>' . esc_html__( 'Your Friends & Subscriptions', 'friends' ) . '</h3>';
if ( isset( $_GET['page'] ) && 'friends-list-requests' === $_GET['page'] ) {
echo '<div class="wrap"><h3>' . esc_html__( 'Your Friend Requests', 'friends' ) . '</h3>';
$query = User_Query::all_friend_requests();
} else {
echo '<div class="wrap"><h3>' . esc_html__( 'Your Friends & Subscriptions', 'friends' ) . '</h3>';
$query = User_Query::all_associated_users();
}

if ( isset( $_GET['deleted'] ) ) {
?>
Expand All @@ -899,11 +905,12 @@ public function render_friends_list() {
</p></div>
<?php
}

Friends::template_loader()->get_template_part(
'admin/friends-list',
null,
array(
'friends' => User_Query::all_associated_users()->get_results(),
'friends' => $query->get_results(),
)
);
echo '</div>';
Expand Down Expand Up @@ -2128,7 +2135,7 @@ public static function get_associated_roles() {
}

public static function get_users_url() {
return 'users.php?role=' . implode( ',', array_keys( self::get_associated_roles() ) );
return 'admin.php?page=friends-list';
}

/**
Expand Down Expand Up @@ -2483,7 +2490,7 @@ public function admin_bar_friends_menu( \WP_Admin_Bar $wp_menu ) {
'id' => 'friends-requests',
'parent' => 'friends-menu',
'title' => esc_html__( 'My Friends & Requests', 'friends' ),
'href' => $my_url . '/wp-admin/' . self::get_users_url(),
'href' => $my_url . '/wp-admin/admin.php?page=friends-list-requests',
)
);
$wp_menu->add_menu(
Expand Down
Loading