Changeset 12927
- Timestamp:
- 04/28/2021 11:52:15 PM (3 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/admin/bp-core-admin-functions.php
r12899 r12927 86 86 } 87 87 88 // Keep the BuddyPress tools menu highlighted .89 if ( 'bp-optouts' === $plugin_page ) {88 // Keep the BuddyPress tools menu highlighted when using a tools tab. 89 if ( 'bp-optouts' === $plugin_page || 'bp-members-invitations' === $plugin_page ) { 90 90 $submenu_file = 'bp-tools'; 91 91 } … … 285 285 // Activate and Register are special cases. They are not components but they need WP pages. 286 286 // If user registration is disabled, we can skip this step. 287 if ( bp_get_signup_allowed() ) {287 if ( bp_get_signup_allowed() || bp_get_members_invitations_allowed() ) { 288 288 $wp_page_components[] = array( 289 289 'id' => 'activate', … … 480 480 ), 481 481 '1' => array( 482 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-members-invitations' ), $tools_page ) ), 483 'name' => __( 'Manage Invitations', 'buddypress' ), 484 ), 485 '2' => array( 482 486 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-optouts' ), $tools_page ) ), 483 487 'name' => __( 'Manage Opt-outs', 'buddypress' ), -
trunk/src/bp-core/admin/bp-core-admin-slugs.php
r12725 r12927 188 188 <h3><?php _e( 'Registration', 'buddypress' ); ?></h3> 189 189 190 <?php if ( bp_get_signup_allowed() ) : ?>190 <?php if ( bp_get_signup_allowed() || bp_get_members_invitations_allowed() ) : ?> 191 191 <p><?php _e( 'Associate WordPress Pages with the following BuddyPress Registration pages.', 'buddypress' ); ?></p> 192 192 <?php else : ?> … … 211 211 <tbody> 212 212 213 <?php if ( bp_get_signup_allowed() ) : foreach ( $static_pages as $name => $label ) : ?>213 <?php if ( bp_get_signup_allowed() || bp_get_members_invitations_allowed() ) : foreach ( $static_pages as $name => $label ) : ?> 214 214 215 215 <tr valign="top"> -
trunk/src/bp-core/admin/bp-core-admin-tools.php
r12911 r12927 558 558 ?> 559 559 </dd> 560 561 <dt><?php esc_html_e( 'Manage Invitations', 'buddypress' ) ?></dt> 562 <dd> 563 <?php esc_html_e( 'When enabled, BuddyPress allows your users to invite nonmembers to join your site.', 'buddypress' ); ?> 564 <?php 565 $url = add_query_arg( 'page', 'bp-members-invitations', bp_get_admin_url( $page ) ); 566 printf( 567 /* translators: %s: the link to the BuddyPress Invitations management tool screen */ 568 esc_html_x( 'Visit %s to manage your site’s invitations.', 'buddypress invitations tool intro', 'buddypress' ), 569 '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Invitations', 'buddypress' ) . '</a>' 570 ); 571 ?> 572 </dd> 573 560 574 <dt><?php esc_html_e( 'Manage Opt-outs', 'buddypress' ) ?></dt> 561 575 <dd> -
trunk/src/bp-core/admin/css/common-rtl.css
r12900 r12927 316 316 body.tools-php .bp-tools dd { 317 317 margin: 0; 318 } 319 320 body.tools_page_bp-members-invitations .nav-tab-wrapper, 321 body.tools_page_bp-optouts .nav-tab-wrapper { 322 margin-bottom: 1em; 318 323 } 319 324 -
trunk/src/bp-core/admin/css/common.css
r12900 r12927 316 316 body.tools-php .bp-tools dd { 317 317 margin: 0; 318 } 319 320 body.tools_page_bp-members-invitations .nav-tab-wrapper, 321 body.tools_page_bp-optouts .nav-tab-wrapper { 322 margin-bottom: 1em; 318 323 } 319 324 -
trunk/src/bp-members/admin/bp-members-admin-classes.php
r10521 r12927 13 13 if ( class_exists( 'WP_Users_List_Table' ) ) { 14 14 require dirname( dirname( __FILE__ ) ) . '/classes/class-bp-members-list-table.php'; 15 require dirname( dirname( __FILE__ ) ) . '/classes/class-bp-members-invitations-list-table.php'; 15 16 } 16 17 -
trunk/src/bp-members/classes/class-bp-members-admin.php
r12899 r12927 141 141 $this->users_screen = bp_core_do_network_admin() ? 'users-network' : 'users'; 142 142 143 $this->members_invites_page = ''; 144 143 145 // Specific config: BuddyPress is not network activated. 144 146 $this->subsite_activated = (bool) is_multisite() && ! bp_is_network_activated(); … … 220 222 add_action( 'update_site_option_registration', array( $this, 'multisite_registration_on' ), 10, 2 ); 221 223 add_action( 'update_option_users_can_register', array( $this, 'single_site_registration_on' ), 10, 2 ); 224 225 // Member invitations are enabled. 226 if ( bp_is_network_activated() ) { 227 add_action( 'update_site_option_bp-enable-members-invitations', array( $this, 'multisite_registration_on' ), 10, 2 ); 228 } else { 229 add_action( 'update_option_bp-enable-members-invitations', array( $this, 'single_site_registration_on' ), 10, 2 ); 230 } 222 231 } 223 232 … … 249 258 */ 250 259 public function multisite_registration_on( $option_name, $value ) { 251 if ( 'user' === $value || 'all' === $value ) { 260 // Is registration enabled or are network invitations enabled? 261 if ( ( 'user' === $value || 'all' === $value ) 262 || bp_get_members_invitations_allowed() ) { 252 263 bp_core_add_page_mappings( array( 253 264 'register' => 1, … … 267 278 public function single_site_registration_on( $old_value, $value ) { 268 279 // Single site. 269 if ( ! is_multisite() && ! empty( $value) ) {280 if ( ! is_multisite() && ( ! empty( $value ) || bp_get_members_invitations_allowed() ) ) { 270 281 bp_core_add_page_mappings( array( 271 282 'register' => 1, … … 491 502 } 492 503 504 // For consistency with non-Multisite, we add a Tools menu in 505 // the Network Admin as a home for our Tools panel. 506 if ( is_multisite() && bp_core_do_network_admin() ) { 507 $tools_parent = 'network-tools'; 508 } else { 509 $tools_parent = 'tools.php'; 510 } 511 512 $hooks['members_invitations'] = $this->members_invites_page = add_submenu_page( 513 $tools_parent, 514 __( 'Manage Invitations', 'buddypress' ), 515 __( 'Manage Invitations', 'buddypress' ), 516 $this->capability, 517 'bp-members-invitations', 518 array( $this, 'invitations_admin' ) 519 ); 520 493 521 $edit_page = 'user-edit'; 494 522 $profile_page = 'profile'; … … 511 539 $this->signups_page .= '-network'; 512 540 513 $this->members_ optouts_page .= '-network';541 $this->members_invites_page .= '-network'; 514 542 } 515 543 … … 530 558 add_action( "admin_head-{$head}", array( $this, 'profile_admin_head' ) ); 531 559 } 560 561 // Highlight the BuddyPress tools submenu when managing invitations. 562 add_action( "admin_head-{$this->members_invites_page}", 'bp_core_modify_admin_menu_highlight' ); 532 563 } 533 564 … … 599 630 remove_submenu_page( 'users.php', 'bp-profile-edit' ); 600 631 remove_submenu_page( 'profile.php', 'bp-profile-edit' ); 632 633 // Manage Invitations Tool screen is a tab of BP Tools. 634 if ( is_network_admin() ) { 635 remove_submenu_page( 'network-tools', 'bp-members-invitations' ); 636 } else { 637 remove_submenu_page( 'tools.php', 'bp-members-invitations' ); 638 } 601 639 } 602 640 … … 1906 1944 1907 1945 if ( ! empty( $_REQUEST['notdeleted'] ) ) { 1946 $notdeleted = absint( $_REQUEST['notdeleted'] ); 1908 1947 $notice['message'] .= sprintf( 1909 /* translators: %s: number of deleted signups not deleted */ 1910 _nx( '%s sign-up was not deleted.', '%s sign-ups were not deleted.', 1911 absint( $_REQUEST['notdeleted'] ), 1912 'signup notdeleted', 1913 'buddypress' 1948 _nx( 1949 /* translators: %s: number of deleted signups not deleted */ 1950 '%s sign-up was not deleted.', '%s sign-ups were not deleted.', 1951 $notdeleted, 1952 'signup notdeleted', 1953 'buddypress' 1914 1954 ), 1915 number_format_i18n( absint( $_REQUEST['notdeleted'] ))1955 number_format_i18n( $notdeleted ) 1916 1956 ); 1917 1957 … … 2567 2607 return $value; 2568 2608 } 2609 2610 /** 2611 * Set up the signups admin page. 2612 * 2613 * Loaded before the page is rendered, this function does all initial 2614 * setup, including: processing form requests, registering contextual 2615 * help, and setting up screen options. 2616 * 2617 * @since 8.0.0 2618 * 2619 * @global $bp_members_invitations_list_table 2620 */ 2621 public function members_invitations_admin_load() { 2622 global $bp_members_invitations_list_table; 2623 2624 // Build redirection URL. 2625 $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'activated', 'notactivated', 'deleted', 'notdeleted', 'resent', 'notresent', 'do_delete', 'do_resend', 'do_activate', '_wpnonce', 'signup_ids' ), $_SERVER['REQUEST_URI'] ); 2626 $doaction = bp_admin_list_table_current_bulk_action(); 2627 2628 /** 2629 * Fires at the start of the member invitations admin load. 2630 * 2631 * @since 8.0.0 2632 * 2633 * @param string $doaction Current bulk action being processed. 2634 * @param array $_REQUEST Current $_REQUEST global. 2635 */ 2636 do_action( 'bp_members_invitations_admin_load', $doaction, $_REQUEST ); 2637 2638 /** 2639 * Filters the allowed actions for use in the user signups admin page. 2640 * 2641 * @since 8.0.0 2642 * 2643 * @param array $value Array of allowed actions to use. 2644 */ 2645 $allowed_actions = apply_filters( 'bp_members_invitations_admin_allowed_actions', array( 'do_delete', 'do_resend' ) ); 2646 2647 // Prepare the display of the bulk invitation action screen. 2648 if ( ! in_array( $doaction, $allowed_actions ) ) { 2649 2650 $bp_members_invitations_list_table = self::get_list_table_class( 'BP_Members_Invitations_List_Table', 'users' ); 2651 2652 // The per_page screen option. 2653 add_screen_option( 'per_page', array( 'label' => _x( 'Members Invitations', 'Members Invitations per page (screen options)', 'buddypress' ) ) ); 2654 2655 get_current_screen()->add_help_tab( array( 2656 'id' => 'bp-members-invitations-overview', 2657 'title' => __( 'Overview', 'buddypress' ), 2658 'content' => 2659 '<p>' . __( 'This is the administration screen for member invitations on your site.', 'buddypress' ) . '</p>' . 2660 '<p>' . __( 'From the screen options, you can customize the displayed columns and the pagination of this screen.', 'buddypress' ) . '</p>' . 2661 '<p>' . __( 'You can reorder the list of invitations by clicking on the Invitee, Inviter, Date Modified, Email Sent, or Accepted column headers.', 'buddypress' ) . '</p>' . 2662 '<p>' . __( 'Using the search form, you can find specific invitations more easily. The Invitee Email field will be included in the search.', 'buddypress' ) . '</p>' 2663 ) ); 2664 2665 get_current_screen()->add_help_tab( array( 2666 'id' => 'bp-members-invitations-actions', 2667 'title' => __( 'Actions', 'buddypress' ), 2668 'content' => 2669 '<p>' . __( 'Hovering over a row in the pending accounts list will display action links that allow you to manage pending accounts. You can perform the following actions:', 'buddypress' ) . '</p>' . 2670 '<ul><li>' . __( '"Send" or "Resend" takes you to the confirmation screen before being able to send or resend the invitation email to the desired pending invitee.', 'buddypress' ) . '</li>' . 2671 '<li>' . __( '"Delete" allows you to delete an unsent or accepted invitation from your site; "Cancel" allows you to cancel a sent, but not yet accepted, invitation. You will be asked to confirm this deletion.', 'buddypress' ) . '</li></ul>' . 2672 '<p>' . __( 'Bulk actions allow you to perform these actions for the selected rows.', 'buddypress' ) . '</p>' 2673 ) ); 2674 2675 // Help panel - sidebar links. 2676 get_current_screen()->set_help_sidebar( 2677 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . 2678 '<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>' 2679 ); 2680 2681 // Add accessible hidden headings and text for the Pending Users screen. 2682 get_current_screen()->set_screen_reader_content( array( 2683 /* translators: accessibility text */ 2684 'heading_views' => __( 'Filter invitations list', 'buddypress' ), 2685 /* translators: accessibility text */ 2686 'heading_pagination' => __( 'Invitation list navigation', 'buddypress' ), 2687 /* translators: accessibility text */ 2688 'heading_list' => __( 'Invitations list', 'buddypress' ), 2689 ) ); 2690 2691 } else { 2692 if ( empty( $_REQUEST['invite_ids' ] ) ) { 2693 return; 2694 } 2695 $invite_ids = wp_parse_id_list( $_REQUEST['invite_ids' ] ); 2696 2697 // Handle resent invitations. 2698 if ( 'do_resend' == $doaction ) { 2699 2700 // Nonce check. 2701 check_admin_referer( 'invitations_resend' ); 2702 2703 $success = 0; 2704 foreach ( $invite_ids as $invite_id ) { 2705 if ( bp_members_invitation_resend_by_id( $invite_id ) ) { 2706 $success++; 2707 } 2708 } 2709 2710 $query_arg = array( 'updated' => 'resent' ); 2711 2712 if ( ! empty( $success ) ) { 2713 $query_arg['resent'] = $success; 2714 } 2715 2716 $not_sent = count( $invite_ids ) - $success; 2717 if ( $not_sent > 0 ) { 2718 $query_arg['notsent'] = $not_sent; 2719 } 2720 2721 $redirect_to = add_query_arg( $query_arg, $redirect_to ); 2722 2723 bp_core_redirect( $redirect_to ); 2724 2725 // Handle invitation deletion. 2726 } elseif ( 'do_delete' == $doaction ) { 2727 2728 // Nonce check. 2729 check_admin_referer( 'invitations_delete' ); 2730 2731 $success = 0; 2732 foreach ( $invite_ids as $invite_id ) { 2733 if ( bp_members_invitations_delete_by_id( $invite_id ) ) { 2734 $success++; 2735 } 2736 } 2737 2738 $query_arg = array( 'updated' => 'deleted' ); 2739 2740 if ( ! empty( $success ) ) { 2741 $query_arg['deleted'] = $success; 2742 } 2743 2744 $notdeleted = count( $invite_ids ) - $success; 2745 if ( $notdeleted > 0 ) { 2746 $query_arg['notdeleted'] = $notdeleted; 2747 } 2748 2749 $redirect_to = add_query_arg( $query_arg, $redirect_to ); 2750 2751 bp_core_redirect( $redirect_to ); 2752 2753 // Plugins can update other stuff from here. 2754 } else { 2755 $this->redirect = $redirect_to; 2756 2757 /** 2758 * Fires at end of member invitations admin load 2759 * if doaction does not match any actions. 2760 * 2761 * @since 8.0.0 2762 * 2763 * @param string $doaction Current bulk action being processed. 2764 * @param array $_REQUEST Current $_REQUEST global. 2765 * @param string $redirect Determined redirect url to send user to. 2766 */ 2767 do_action( 'bp_members_admin_update_invitations', $doaction, $_REQUEST, $this->redirect ); 2768 2769 bp_core_redirect( $this->redirect ); 2770 } 2771 } 2772 } 2773 2774 /** 2775 * Get admin notice when viewing the invitations management page. 2776 * 2777 * @since 8.0.0 2778 * 2779 * @return array 2780 */ 2781 private function get_members_invitations_notice() { 2782 2783 // Setup empty notice for return value. 2784 $notice = array(); 2785 2786 // Updates. 2787 if ( ! empty( $_REQUEST['updated'] ) ) { 2788 switch ( $_REQUEST['updated'] ) { 2789 case 'resent': 2790 $notice = array( 2791 'class' => 'updated', 2792 'message' => '' 2793 ); 2794 2795 if ( ! empty( $_REQUEST['resent'] ) ) { 2796 $resent = absint( $_REQUEST['resent'] ); 2797 $notice['message'] .= sprintf( 2798 _nx( 2799 /* translators: %s: number of invitation emails sent */ 2800 '%s invtitation email successfully sent! ', '%s invitation emails successfully sent! ', 2801 $resent, 2802 'members invitation resent', 2803 'buddypress' 2804 ), 2805 number_format_i18n( $resent ) 2806 ); 2807 } 2808 2809 if ( ! empty( $_REQUEST['notsent'] ) ) { 2810 $notsent = absint( $_REQUEST['notsent'] ); 2811 $notice['message'] .= sprintf( 2812 _nx( 2813 /* translators: %s: number of unsent invitation emails */ 2814 '%s invitation email was not sent.', '%s invitation emails were not sent.', 2815 $notsent, 2816 'members invitation notsent', 2817 'buddypress' 2818 ), 2819 number_format_i18n( $notsent ) 2820 ); 2821 2822 if ( empty( $_REQUEST['resent'] ) ) { 2823 $notice['class'] = 'error'; 2824 } 2825 } 2826 2827 break; 2828 2829 case 'deleted': 2830 $notice = array( 2831 'class' => 'updated', 2832 'message' => '' 2833 ); 2834 2835 if ( ! empty( $_REQUEST['deleted'] ) ) { 2836 $deleted = absint( $_REQUEST['deleted'] ); 2837 $notice['message'] .= sprintf( 2838 _nx( 2839 /* translators: %s: number of deleted invitations */ 2840 '%s invitation successfully deleted!', '%s invitations successfully deleted!', 2841 $deleted, 2842 'members invitation deleted', 2843 'buddypress' 2844 ), 2845 number_format_i18n( $deleted ) 2846 ); 2847 } 2848 2849 if ( ! empty( $_REQUEST['notdeleted'] ) ) { 2850 $notdeleted = absint( $_REQUEST['notdeleted'] ); 2851 $notice['message'] .= sprintf( 2852 _nx( 2853 /* translators: %s: number of invitations that failed to be deleted */ 2854 '%s invitation was not deleted.', '%s invitations were not deleted.', 2855 $notdeleted, 2856 'members invitation notdeleted', 2857 'buddypress' 2858 ), 2859 number_format_i18n( $notdeleted ) 2860 ); 2861 2862 if ( empty( $_REQUEST['deleted'] ) ) { 2863 $notice['class'] = 'error'; 2864 } 2865 } 2866 2867 break; 2868 } 2869 } 2870 2871 // Errors. 2872 if ( ! empty( $_REQUEST['error'] ) ) { 2873 switch ( $_REQUEST['error'] ) { 2874 case 'do_resend': 2875 $notice = array( 2876 'class' => 'error', 2877 'message' => esc_html__( 'There was a problem sending the invitation emails. Please try again.', 'buddypress' ), 2878 ); 2879 break; 2880 2881 case 'do_delete': 2882 $notice = array( 2883 'class' => 'error', 2884 'message' => esc_html__( 'There was a problem deleting invitations. Please try again.', 'buddypress' ), 2885 ); 2886 break; 2887 } 2888 } 2889 2890 return $notice; 2891 } 2892 2893 /** 2894 * Member invitations admin page router. 2895 * 2896 * Depending on the context, display 2897 * - the list of invitations, 2898 * - or the delete confirmation screen, 2899 * - or the "resend" email confirmation screen. 2900 * 2901 * Also prepare the admin notices. 2902 * 2903 * @since 8.0.0 2904 */ 2905 public function invitations_admin() { 2906 $doaction = bp_admin_list_table_current_bulk_action(); 2907 2908 // Prepare notices for admin. 2909 $notice = $this->get_members_invitations_notice(); 2910 2911 // Display notices. 2912 if ( ! empty( $notice ) ) : 2913 if ( 'updated' === $notice['class'] ) : ?> 2914 2915 <div id="message" class="<?php echo esc_attr( $notice['class'] ); ?> notice is-dismissible"> 2916 2917 <?php else: ?> 2918 2919 <div class="<?php echo esc_attr( $notice['class'] ); ?> notice is-dismissible"> 2920 2921 <?php endif; ?> 2922 2923 <p><?php echo $notice['message']; ?></p> 2924 </div> 2925 2926 <?php endif; 2927 2928 // Show the proper screen. 2929 switch ( $doaction ) { 2930 case 'delete' : 2931 case 'resend' : 2932 $this->invitations_admin_manage( $doaction ); 2933 break; 2934 2935 default: 2936 $this->invitations_admin_index(); 2937 break; 2938 } 2939 } 2940 2941 /** 2942 * This is the list of invitations. 2943 * 2944 * @since 8.0.0 2945 * 2946 * @global $plugin_page 2947 * @global $bp_members_invitations_list_table 2948 */ 2949 public function invitations_admin_index() { 2950 global $plugin_page, $bp_members_invitations_list_table; 2951 2952 $usersearch = ! empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; 2953 2954 // Prepare the group items for display. 2955 $bp_members_invitations_list_table->prepare_items(); 2956 2957 if ( is_network_admin() ) { 2958 $form_url = network_admin_url( 'admin.php' ); 2959 } else { 2960 $form_url = bp_get_admin_url( 'tools.php' ); 2961 } 2962 2963 $form_url = add_query_arg( 2964 array( 2965 'page' => 'bp-members-invitations', 2966 ), 2967 $form_url 2968 ); 2969 2970 $search_form_url = remove_query_arg( 2971 array( 2972 'action', 2973 'deleted', 2974 'notdeleted', 2975 'error', 2976 'updated', 2977 'delete', 2978 'activate', 2979 'activated', 2980 'notactivated', 2981 'resend', 2982 'resent', 2983 'notresent', 2984 'do_delete', 2985 'do_activate', 2986 'do_resend', 2987 'action2', 2988 '_wpnonce', 2989 'invite_ids' 2990 ), $_SERVER['REQUEST_URI'] 2991 ); 2992 2993 ?> 2994 2995 <div class="wrap"> 2996 <h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress tools', 'buddypress' ); ?></h1> 2997 <hr class="wp-header-end"> 2998 2999 <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Manage Invitations', 'buddypress' ), 'tools' ); ?></h2> 3000 3001 <?php 3002 if ( $usersearch ) { 3003 printf( '<span class="subtitle">' . __( 'Search results for “%s”', 'buddypress' ) . '</span>', esc_html( $usersearch ) ); 3004 } 3005 ?> 3006 3007 <hr class="wp-header-end"> 3008 3009 <?php // Display each invitation on its own row. ?> 3010 <?php $bp_members_invitations_list_table->views(); ?> 3011 3012 <form id="bp-members-invitations-search-form" action="<?php echo esc_url( $search_form_url ) ;?>"> 3013 <input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" /> 3014 <?php $bp_members_invitations_list_table->search_box( __( 'Search Invitations', 'buddypress' ), 'bp-members-invitations' ); ?> 3015 </form> 3016 3017 <form id="bp-members-invitations-form" action="<?php echo esc_url( $form_url );?>" method="post"> 3018 <?php $bp_members_invitations_list_table->display(); ?> 3019 </form> 3020 </div> 3021 <?php 3022 } 3023 3024 /** 3025 * This is the confirmation screen for actions. 3026 * 3027 * @since 8.0.0 3028 * 3029 * @param string $action Delete or resend invitation. 3030 * @return null|false 3031 */ 3032 public function invitations_admin_manage( $action = '' ) { 3033 if ( ! current_user_can( $this->capability ) || empty( $action ) ) { 3034 die( '-1' ); 3035 } 3036 3037 // Get the IDs from the URL. 3038 $ids = false; 3039 if ( ! empty( $_POST['invite_ids'] ) ) { 3040 $ids = wp_parse_id_list( $_POST['invite_ids'] ); 3041 } elseif ( ! empty( $_GET['invite_id'] ) ) { 3042 $ids = absint( $_GET['invite_id'] ); 3043 } 3044 3045 3046 if ( empty( $ids ) ) { 3047 return false; 3048 } 3049 3050 // Check invite IDs and set up strings. 3051 switch ( $action ) { 3052 case 'delete' : 3053 // Query for matching invites, and filter out bad IDs. 3054 $args = array( 3055 'id' => $ids, 3056 'invite_sent' => 'all', 3057 'accepted' => 'all', 3058 ); 3059 $invites = bp_members_invitations_get_invites( $args ); 3060 $invite_ids = wp_list_pluck( $invites, 'id' ); 3061 3062 $header_text = __( 'Delete Invitations', 'buddypress' ); 3063 if ( 0 === count( $invite_ids ) ) { 3064 $helper_text = __( 'No invites were found, nothing to delete!', 'buddypress' ); 3065 } else { 3066 $helper_text = _n( 'You are about to delete the following invitation:', 'You are about to delete the following invitations:', count( $invite_ids ), 'buddypress' ); 3067 } 3068 break; 3069 3070 case 'resend' : 3071 /** 3072 * Query for matching invites, and filter out bad IDs 3073 * or those that have already been accepted. 3074 */ 3075 $args = array( 3076 'id' => $ids, 3077 'invite_sent' => 'all', 3078 'accepted' => 'pending', 3079 ); 3080 $invites = bp_members_invitations_get_invites( $args ); 3081 $invite_ids = wp_list_pluck( $invites, 'id' ); 3082 3083 $header_text = __( 'Resend Invitation Emails', 'buddypress' ); 3084 if ( 0 === count( $invite_ids ) ) { 3085 $helper_text = __( 'No pending invites were found, nothing to resend!', 'buddypress' ); 3086 } else { 3087 $helper_text = _n( 'You are about to resend an invitation email to the following address:', 'You are about to resend invitation emails to the following addresses:', count( $invite_ids ), 'buddypress' ); 3088 } 3089 break; 3090 } 3091 3092 // These arguments are added to all URLs. 3093 $url_args = array( 'page' => 'bp-members-invitations' ); 3094 3095 // These arguments are only added when performing an action. 3096 $action_args = array( 3097 'action' => 'do_' . $action, 3098 'invite_ids' => implode( ',', $invite_ids ) 3099 ); 3100 3101 if ( is_network_admin() ) { 3102 $base_url = network_admin_url( 'admin.php' ); 3103 } else { 3104 $base_url = bp_get_admin_url( 'tools.php' ); 3105 } 3106 3107 $cancel_url = add_query_arg( $url_args, $base_url ); 3108 $action_url = wp_nonce_url( 3109 add_query_arg( 3110 array_merge( $url_args, $action_args ), 3111 $base_url 3112 ), 3113 'invitations_' . $action 3114 ); 3115 3116 ?> 3117 3118 <div class="wrap"> 3119 <h1 class="wp-heading-inline"><?php echo esc_html( $header_text ); ?></h1> 3120 <hr class="wp-header-end"> 3121 3122 <p><?php echo esc_html( $helper_text ); ?></p> 3123 3124 <?php if ( $invites ) : ?> 3125 3126 <ol class="bp-invitations-list"> 3127 <?php foreach ( $invites as $invite ) : 3128 if ( $invite->invite_sent ) { 3129 $last_notified = mysql2date( 'Y/m/d g:i:s a', $invite->date_modified ); 3130 } else { 3131 $last_notified = __( 'Not yet notified', 'buddypress'); 3132 } 3133 ?> 3134 3135 <li> 3136 <strong><?php echo esc_html( $invite->invitee_email ) ?></strong> 3137 3138 <?php if ( 'resend' === $action ) : ?> 3139 3140 <p class="description"> 3141 <?php 3142 /* translators: %s: notification date */ 3143 printf( esc_html__( 'Last notified: %s', 'buddypress'), $last_notified ); 3144 ?> 3145 </p> 3146 3147 <?php endif; ?> 3148 3149 </li> 3150 3151 <?php endforeach; ?> 3152 </ol> 3153 3154 <?php endif ; ?> 3155 3156 <?php if ( 'delete' === $action ) : ?> 3157 3158 <p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p> 3159 3160 <?php endif; ?> 3161 3162 <?php if ( $invites ) : ?> 3163 3164 <a class="button-primary" href="<?php echo esc_url( $action_url ); ?>" <?php disabled( ! $invites ); ?>><?php esc_html_e( 'Confirm', 'buddypress' ); ?></a> 3165 3166 <?php endif; ?> 3167 3168 <a class="button" href="<?php echo esc_url( $cancel_url ); ?>"><?php esc_html_e( 'Cancel', 'buddypress' ) ?></a> 3169 </div> 3170 3171 <?php 3172 } 3173 2569 3174 } 2570 3175 endif; // End class_exists check.
Note: See TracChangeset
for help on using the changeset viewer.