false, 'plural' => 'invitations', 'singular' => 'invitation', 'screen' => get_current_screen()->id, ) ); } /** * Set up items for display in the list table. * * Handles filtering of data, sorting, pagination, and any other data * manipulation required prior to rendering. * * @since 8.0.0 */ public function prepare_items() { global $usersearch; $search = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) ); $paged = $this->get_pagenum(); $args = array( 'invite_sent' => 'all', 'accepted' => 'all', 'search_terms' => $search, 'order_by' => 'date_modified', 'sort_order' => 'DESC', 'page' => $paged, 'per_page' => $per_page, ); if ( isset( $_REQUEST['accepted'] ) && in_array( $_REQUEST['accepted'], array( 'pending', 'accepted' ), true ) ) { $args['accepted'] = $_REQUEST['accepted']; $this->active_filters[] = $_REQUEST['accepted']; } if ( isset( $_REQUEST['sent'] ) && in_array( $_REQUEST['sent'], array( 'draft', 'sent' ), true ) ) { $args['invite_sent'] = $_REQUEST['sent']; $this->active_filters[] = $_REQUEST['sent']; } if ( isset( $_REQUEST['orderby'] ) ) { $args['order_by'] = $_REQUEST['orderby']; } if ( isset( $_REQUEST['order'] ) ) { $args['sort_order'] = $_REQUEST['order']; } $invites_class = new BP_Members_Invitation_Manager(); $this->items = $invites_class->get_invitations( $args ); $this->total_items = $invites_class->get_invitations_total_count( $args ); $this->set_pagination_args( array( 'total_items' => $this->total_items, 'per_page' => $per_page, ) ); } /** * Gets the name of the default primary column. * * @since 10.1.0 * * @return string Name of the default primary column, in this case, 'invitee_email'. */ protected function get_default_primary_column_name() { return 'invitee_email'; } /** * Get the list of views available on this table (e.g. "all", "public"). * * @since 8.0.0 */ public function views() { $tools_url = bp_get_admin_url( 'tools.php' ); if ( is_network_admin() ) { $tools_url = network_admin_url( 'admin.php' ); } $url_base = add_query_arg( array( 'page' => 'bp-members-invitations', ), $tools_url ); ?>

'', 'invitee_email' => __( 'Invitee', 'buddypress' ), 'username' => __( 'Inviter', 'buddypress' ), 'inviter_registered_date' => __( 'Inviter Registered', 'buddypress' ), 'invitation_date_modified' => __( 'Date Modified', 'buddypress' ), 'invitation_sent' => __( 'Email Sent', 'buddypress' ), 'invitation_accepted' => __( 'Accepted', 'buddypress' ) ) ); } /** * Specific bulk actions for signups. * * @since 8.0.0 */ public function get_bulk_actions() { $actions = array( 'resend' => _x( 'Resend Email', 'Pending invitation action', 'buddypress' ), ); if ( current_user_can( 'delete_users' ) ) { $actions['delete'] = _x( 'Delete', 'Pending invitation action', 'buddypress' ); } return $actions; } /** * The text shown when no items are found. * * Nice job, clean sheet! * * @since 8.0.0 */ public function no_items() { if ( bp_get_members_invitations_allowed() ) { esc_html_e( 'No invitations found.', 'buddypress' ); } else { $link = sprintf( '%2$s', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ) ), esc_html__( 'Edit settings', 'buddypress' ) ); /* translators: %s: url to site settings */ printf( __( 'Invitations are not allowed. %s', 'buddypress' ), $link ); } } /** * The columns invitations can be reordered by. * * @since 8.0.0 */ public function get_sortable_columns() { return array( 'invitee_email' => 'invitee_email', 'username' => 'inviter_id', 'invitation_date_modified' => 'date_modified', 'invitation_sent' => 'invite_sent', 'invitation_accepted' => 'accepted', ); } /** * Display invitation rows. * * @since 8.0.0 */ public function display_rows() { $style = ''; foreach ( $this->items as $invite ) { $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"'; echo "\n\t" . $this->single_row( $invite, $style ); } } /** * Display an invitation row. * * @since 8.0.0 * * @see WP_List_Table::single_row() for explanation of params. * * @param BP_Invitation $invite BP_Invitation object. * @param string $style Styles for the row. * @param string $role Role to be assigned to user. * @param int $numposts Number of posts. * @return void */ public function single_row( $invite = null, $style = '', $role = '', $numposts = 0 ) { echo ''; echo $this->single_row_columns( $invite ); echo ''; } /** * Markup for the checkbox used to select items for bulk actions. * * @since 8.0.0 * * @param BP_Invitation $invite BP_Invitation object. */ public function column_cb( $invite = null ) { ?> invitee_email ); $actions = array(); $tools_url = bp_get_admin_url( 'tools.php' ); if ( is_network_admin() ) { $tools_url = network_admin_url( 'admin.php' ); } // Resend action only if pending if ( ! $invite->accepted ) { // Resend invitation email link. $email_link = add_query_arg( array( 'page' => 'bp-members-invitations', 'invite_id' => $invite->id, 'action' => 'resend', ), $tools_url ); if ( ! $invite->invite_sent ) { $resend_label = __( 'Send', 'buddypress' ); } else { $resend_label = __( 'Resend', 'buddypress' ); } $actions['resend'] = sprintf( '%2$s', esc_url( $email_link ), esc_html( $resend_label ) ); } // Delete link. Could be cleanup or revoking the invitation. $delete_link = add_query_arg( array( 'page' => 'bp-members-invitations', 'invite_id' => $invite->id, 'action' => 'delete', ), $tools_url ); // Two cases: unsent and accepted (cleanup), and pending (cancels invite). if ( ! $invite->invite_sent || $invite->accepted ) { $actions['delete'] = sprintf( '%2$s', esc_url( $delete_link ), esc_html__( 'Delete', 'buddypress' ) ); } else { $actions['delete'] = sprintf( '%2$s', esc_url( $delete_link ), esc_html__( 'Cancel', 'buddypress' ) ); } /** * Filters the row actions for each invitation in list. * * @since 8.0.0 * * @param array $actions Array of actions and corresponding links. * @param object $invite The BP_Invitation. */ $actions = apply_filters( 'bp_members_invitations_management_row_actions', $actions, $invite ); echo $this->row_actions( $actions ); } /** * Display invited user's email address. * * @since 8.0.0 * * @param BP_Invitation $invite BP_Invitation object. */ public function column_email( $invite = null ) { printf( '%2$s', esc_attr( $invite->user_email ), esc_html( $invite->user_email ) ); } /** * The inviter. * * @since 8.0.0 * * @param BP_Invitation $invite BP_Invitation object. */ public function column_username( $invite = null ) { $avatar = get_avatar( $invite->inviter_id, 32 ); $inviter = get_user_by( 'id', $invite->inviter_id ); if ( ! $inviter ) { return; } $user_link = bp_core_get_user_domain( $invite->inviter_id ); printf( '%1$s %3$s
', $avatar, esc_url( $user_link ), esc_html( $inviter->user_login ) ); } /** * Display invitation date. * * @since 8.0.0 * * @param BP_Invitation $invite BP_Invitation object. */ public function column_inviter_registered_date( $invite = null ) { $inviter = get_user_by( 'id', $invite->inviter_id ); if ( ! $inviter ) { return; } echo esc_html( $inviter->user_registered ); } /** * Display invitation date. * * @since 8.0.0 * * @param BP_Invitation $invite BP_Invitation object. */ public function column_invitation_date_modified( $invite = null ) { echo esc_html( $invite->date_modified ); } /** * Display invitation date. * * @since 8.0.0 * * @param BP_Invitation $invite BP_Invitation object. */ public function column_invitation_sent( $invite = null ) { if ( $invite->invite_sent) { esc_html_e( 'Yes', 'buddypress' ); } else { esc_html_e( 'No', 'buddypress' ); } } /** * Display invitation acceptance status. * * @since 8.0.0 * * @param BP_Invitation $invite BP_Invitation object. */ public function column_invitation_accepted( $invite = null ) { if ( $invite->accepted ) { esc_html_e( 'Yes', 'buddypress' ); } else { esc_html_e( 'No', 'buddypress' ); } } /** * Allow plugins to add their custom column. * * @since 8.0.0 * * @param BP_Invitation $invite BP_Invitation object. * @param string $column_name The column name. * @return string */ function column_default( $invite = null, $column_name = '' ) { /** * Filters the single site custom columns for plugins. * * @since 8.0.0 * * @param string $column_name The column name. * @param object $invite The BP_Invitation object.. */ return apply_filters( 'bp_members_invitations_management_custom_column', '', $column_name, $invite ); } }