Changeset 8119 for trunk/bp-members/bp-members-admin.php
- Timestamp:
- 03/13/2014 12:58:28 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-members/bp-members-admin.php
r8030 r8119 117 117 // BuddyPress edit user's profile url 118 118 $this->edit_profile_url = add_query_arg( 'page', 'bp-profile-edit', bp_get_admin_url( 'users.php' ) ); 119 120 // Data specific to signups 121 $this->users_page = ''; 122 $this->signups_page = ''; 123 $this->users_url = bp_get_admin_url( 'users.php' ); 124 $this->users_screen = bp_core_do_network_admin() ? 'users-network' : 'users'; 119 125 } 120 126 … … 127 133 private function setup_actions() { 128 134 129 /** Actions***************************************************/135 /** Community Profile ***************************************************/ 130 136 131 137 // Add some page specific output to the <head> … … 141 147 add_action( 'edit_user_profile', array( $this, 'profile_nav' ), 99, 1 ); 142 148 143 144 /** Filters ***************************************************/145 146 149 // Add a row action to users listing 147 150 add_filter( bp_core_do_network_admin() ? 'ms_user_row_actions' : 'user_row_actions', array( $this, 'row_actions' ), 10, 2 ); 148 151 149 } 150 151 /** 152 * Create the All Users > Edit Profile submenu. 152 /** Signups **************************************************************/ 153 154 if ( bp_get_signup_allowed() ) { 155 if ( ! is_multisite() && is_admin() ) { 156 add_action( 'pre_user_query', array( $this, 'remove_signups_from_user_query'), 10, 1 ); 157 } 158 159 // Reorganise the views navigation in users.php and signups page 160 add_filter( "views_{$this->users_screen}", array( $this, 'signup_filter_view' ), 10, 1 ); 161 add_filter( 'set-screen-option', array( $this, 'signup_screen_options' ), 10, 3 ); 162 } 163 } 164 165 /** 166 * Create the All Users > Edit Profile and Signups submenus. 153 167 * 154 168 * @access public … … 160 174 161 175 // Manage user's profile 162 $hook = $this->user_page = add_users_page(176 $hooks['user'] = $this->user_page = add_users_page( 163 177 __( 'Edit Profile', 'buddypress' ), 164 178 __( 'Edit Profile', 'buddypress' ), … … 168 182 ); 169 183 184 $hooks['signups'] = $this->users_page = add_users_page( 185 __( 'Manage Signups', 'buddypress' ), 186 __( 'Manage Signups', 'buddypress' ), 187 'bp_moderate', 188 'bp-signups', 189 array( &$this, 'signups_admin' ) 190 ); 191 170 192 $edit_page = 'user-edit'; 193 $this->users_page = 'users'; 171 194 172 195 if ( bp_core_do_network_admin() ) { 173 $edit_page .= '-network'; 174 $this->user_page .= '-network'; 196 $edit_page .= '-network'; 197 $this->users_page .= '-network'; 198 $this->user_page .= '-network'; 199 $this->signups_page .= '-network'; 175 200 } 176 201 177 202 $this->screen_id = array( $edit_page, $this->user_page ); 178 203 179 add_action( "admin_head-$hook", array( $this, 'modify_admin_menu_highlight' ) ); 180 add_action( "load-$hook", array( $this, 'user_admin_load' ) ); 181 182 } 204 foreach ( $hooks as $key => $hook ) { 205 add_action( "admin_head-$hook", array( $this, 'modify_admin_menu_highlight' ) ); 206 add_action( "load-$hook", array( $this, $key . '_admin_load' ) ); 207 } 208 209 } 210 211 /** 212 * Highlight the Users menu if on Edit Profile or Signups pages. 213 * 214 * @access public 215 * @since BuddyPress (2.0.0) 216 */ 217 public function modify_admin_menu_highlight() { 218 global $plugin_page, $submenu_file; 219 220 // Only Show the All users menu 221 if ( in_array( $plugin_page, array( 'bp-profile-edit', 'bp-signups' ) ) ) { 222 $submenu_file = 'users.php'; 223 } 224 } 225 226 /** 227 * Remove the Edit Profile & Signups submenu page. 228 * 229 * We add these pages in order to integrate with WP's Users panel, but 230 * we want them to show up as Views of the WP panel, not as separate 231 * subnav items under the Users menu. 232 * 233 * @access public 234 * @since BuddyPress (2.0.0) 235 */ 236 public function admin_head() { 237 // Remove submenu to force using Profile Navigation 238 remove_submenu_page( 'users.php', 'bp-profile-edit' ); 239 240 // Remove submenu to force using users views 241 remove_submenu_page( 'users.php', 'bp-signups' ); 242 } 243 244 /** Community Profile ************************************************/ 183 245 184 246 /** … … 246 308 247 309 <?php 248 }249 250 /**251 * Highlight the Users menu if on Edit Profile pages.252 *253 * @access public254 * @since BuddyPress (2.0.0)255 */256 public function modify_admin_menu_highlight() {257 global $plugin_page, $submenu_file;258 259 // Only Show the All users menu260 if ( 'bp-profile-edit' == $plugin_page ) {261 $submenu_file = 'users.php';262 }263 }264 265 /**266 * Remove the Edit Profile submenu page.267 *268 * @access public269 * @since BuddyPress (2.0.0)270 */271 public function admin_head() {272 // Remove submenu to force using Profile Navigation273 remove_submenu_page( 'users.php', 'bp-profile-edit' );274 310 } 275 311 … … 691 727 return array_merge( $new_edit_actions, $actions ); 692 728 } 729 730 /** Signups Management ***********************************************/ 731 732 /** 733 * Display the admin preferences about signups pagination. 734 * 735 * @access public 736 * @since BuddyPress (2.0.0) 737 * 738 * @param int $value 739 * @param string $option 740 * @param int $new_value 741 * @return int the pagination preferences 742 */ 743 public function signup_screen_options( $value = 0, $option = '', $new_value = 0 ) { 744 if ( 'users_page_bp_signups_network_per_page' != $option && 'users_page_bp_signups_per_page' != $option ) { 745 return $value; 746 } 747 748 // Per page 749 $new_value = (int) $new_value; 750 if ( $new_value < 1 || $new_value > 999 ) { 751 return $value; 752 } 753 754 return $new_value; 755 } 756 757 /** 758 * Make sure no signups will show in users list. 759 * 760 * This is needed to handle signups that may have not been activated 761 * before the 2.0.0 upgrade. 762 * 763 * @since BuddyPress (2.0.0) 764 * 765 * @param WP_User_Query $query The users query. 766 * @return WP_User_Query The users query without the signups. 767 */ 768 public function remove_signups_from_user_query( $query = null ) { 769 global $wpdb; 770 771 // Bail if this is an ajax request 772 if ( defined( 'DOING_AJAX' ) ) 773 return; 774 775 if ( bp_is_update() ) { 776 return; 777 } 778 779 if ( $this->users_page != get_current_screen()->id ) { 780 return; 781 } 782 783 if ( ! empty( $query->query_vars['role'] ) ) { 784 return; 785 } 786 787 $query->query_where .= " AND {$wpdb->users}.user_status != 2"; 788 } 789 790 /** 791 * Filter the WP Users List Table views to include 'bp-signups'. 792 * 793 * @since BuddyPress (2.0.0) 794 * 795 * @param array $views WP List Table views. 796 * @return array The views with the signup view added. 797 */ 798 public function signup_filter_view( $views = array() ) { 799 $class = ''; 800 801 $signups = BP_Signup::count_signups(); 802 803 // Remove the 'current' class from All if we're on the signups 804 // view 805 if ( $this->signups_page == get_current_screen()->id ) { 806 $views['all'] = str_replace( 'class="current"', '', $views['all'] ); 807 $class = ' class="current"'; 808 } 809 810 $views['registered'] = '<a href="' . add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ) . '"' . $class . '>' . sprintf( _nx( 'Pending account <span class="count">(%s)</span>', 'Pending accounts <span class="count">(%s)</span>', $signups, 'signup users', 'buddypress' ), number_format_i18n( $signups ) ) . '</a>'; 811 812 return $views; 813 } 814 815 /** 816 * Load the Signup WP Users List table. 817 * 818 * @since BuddyPress (2.0.0) 819 * 820 * @param string $class The name of the class to use. 821 * @param string $required The parent class. 822 * @return WP_List_Table The List table. 823 */ 824 public static function get_list_table_class( $class = '', $required = '' ) { 825 if ( empty( $class ) ) { 826 return; 827 } 828 829 if ( ! empty( $required ) ) { 830 require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' ); 831 require_once( buddypress()->members->admin->admin_dir . 'bp-members-classes.php' ); 832 } 833 834 return new $class(); 835 } 836 837 /** 838 * Set up the signups admin page. 839 * 840 * Loaded before the page is rendered, this function does all initial 841 * setup, including: processing form requests, registering contextual 842 * help, and setting up screen options. 843 * 844 * @since BuddyPress (2.0.0) 845 * 846 * @global $bp_members_signup_list_table 847 */ 848 public function signups_admin_load() { 849 global $bp_members_signup_list_table; 850 851 // Build redirection URL 852 $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'] ); 853 $doaction = bp_admin_list_table_current_bulk_action(); 854 855 // Call an action for plugins to hook in early 856 do_action( 'bp_signups_admin_load', $doaction, $_REQUEST ); 857 858 // Allowed actions 859 $allowed_actions = apply_filters( 'bp_signups_admin_allowed_actions', array( 'do_delete', 'do_activate', 'do_resend' ) ); 860 861 // Prepare the display of the Community Profile screen 862 if ( ! in_array( $doaction, $allowed_actions ) || -1 == $doaction ) { 863 864 if ( bp_core_do_network_admin() ) { 865 $bp_members_signup_list_table = self::get_list_table_class( 'BP_Members_MS_List_Table', 'ms-users' ); 866 } else { 867 $bp_members_signup_list_table = self::get_list_table_class( 'BP_Members_List_Table', 'users' ); 868 } 869 870 // per_page screen option 871 add_screen_option( 'per_page', array( 'label' => _x( 'Pending Accounts', 'Pending Accounts per page (screen options)', 'buddypress' ) ) ); 872 873 get_current_screen()->add_help_tab( array( 874 'id' => 'bp-signups-overview', 875 'title' => __( 'Overview', 'buddypress' ), 876 'content' => 877 '<p>' . __( 'This is the admininistration screen for pending accounts on your site.', 'buddypress' ) . '</p>' . 878 '<p>' . __( 'From the screen options, you can customize the displayed columns and the pagination of this screen.', 'buddypress' ) . '</p>' . 879 '<p>' . __( 'You can reorder the list of your pending accounts by clicking on the Username, E-mail or Registered column headers.', 'buddypress' ) . '</p>' . 880 '<p>' . __( 'Using the search form, you can find pending accounts more easily. The Username and E-mail fields will be included in the search.', 'buddypress' ) . '</p>' 881 ) ); 882 883 get_current_screen()->add_help_tab( array( 884 'id' => 'bp-signups-actions', 885 'title' => __( 'Actions', 'buddypress' ), 886 'content' => 887 '<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>' . 888 '<ul><li>' . __( '"Email" takes you to the confirmation screen before being able to send the activation link to the desired pending account. You can only send the activation email once per day.', 'buddypress' ) . '</li>' . 889 '<li>' . __( '"Delete" allows you to delete a pending account from your site. You will be asked to confirm this deletion.', 'buddypress' ) . '</li></ul>' . 890 '<p>' . __( 'By clicking on a Username you will be able to activate a pending account from the confirmation screen.', 'buddypress' ) . '</p>' . 891 '<p>' . __( 'Bulk actions allow you to perform these 3 actions for the selected rows.', 'buddypress' ) . '</p>' 892 ) ); 893 894 // Help panel - sidebar links 895 get_current_screen()->set_help_sidebar( 896 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . 897 '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>' 898 ); 899 } else { 900 if ( ! empty( $_REQUEST['signup_ids' ] ) ) { 901 $signups = wp_parse_id_list( $_REQUEST['signup_ids' ] ); 902 } 903 904 // Handle resent activation links 905 if ( 'do_resend' == $doaction ) { 906 // nonce check 907 check_admin_referer( 'signups_resend' ); 908 909 $resent = BP_Signup::resend( $signups ); 910 911 if ( empty( $resent ) ) { 912 $redirect_to = add_query_arg( 'error', $doaction, $redirect_to ); 913 } else { 914 $query_arg = array( 'updated' => 'resent' ); 915 916 if ( ! empty( $resent['resent'] ) ) { 917 $query_arg['resent'] = count( $resent['resent'] ); 918 } 919 920 if ( ! empty( $resent['errors'] ) ) { 921 $query_arg['notsent'] = count( $resent['errors'] ); 922 set_transient( '_bp_admin_signups_errors', $resent['errors'], 30 ); 923 } 924 925 $redirect_to = add_query_arg( $query_arg, $redirect_to ); 926 } 927 928 bp_core_redirect( $redirect_to ); 929 930 // Handle activated accounts 931 } else if ( 'do_activate' == $doaction ) { 932 // nonce check 933 check_admin_referer( 'signups_activate' ); 934 935 $activated = BP_Signup::activate( $signups ); 936 937 if ( empty( $activated ) ) { 938 $redirect_to = add_query_arg( 'error', $doaction, $redirect_to ); 939 } else { 940 $query_arg = array( 'updated' => 'activated' ); 941 942 if ( ! empty( $activated['activated'] ) ) { 943 $query_arg['activated'] = count( $activated['activated'] ); 944 } 945 946 if ( ! empty( $activated['errors'] ) ) { 947 $query_arg['notactivated'] = count( $activated['errors'] ); 948 set_transient( '_bp_admin_signups_errors', $activated['errors'], 30 ); 949 } 950 951 $redirect_to = add_query_arg( $query_arg, $redirect_to ); 952 } 953 954 bp_core_redirect( $redirect_to ); 955 956 // Handle sign-ups delete 957 } else if ( 'do_delete' == $doaction ) { 958 // nonce check 959 check_admin_referer( 'signups_delete' ); 960 961 $deleted = BP_Signup::delete( $signups ); 962 963 if ( empty( $deleted ) ) { 964 $redirect_to = add_query_arg( 'error', $doaction, $redirect_to ); 965 } else { 966 $query_arg = array( 'updated' => 'deleted' ); 967 968 if ( ! empty( $deleted['deleted'] ) ) { 969 $query_arg['deleted'] = count( $deleted['deleted'] ); 970 } 971 972 if ( ! empty( $deleted['errors'] ) ) { 973 $query_arg['notdeleted'] = count( $deleted['errors'] ); 974 set_transient( '_bp_admin_signups_errors', $deleted['errors'], 30 ); 975 } 976 977 $redirect_to = add_query_arg( $query_arg, $redirect_to ); 978 } 979 980 bp_core_redirect( $redirect_to ); 981 982 // Plugins can update other stuff from here 983 } else { 984 $this->redirect = $redirect_to; 985 986 do_action( 'bp_members_admin_update_signups', $doaction, $_REQUEST, $this->redirect ); 987 988 bp_core_redirect( $this->redirect ); 989 } 990 } 991 } 992 993 /** 994 * Display any activation errors. 995 * 996 * @since BuddyPress (2.0.0) 997 */ 998 public function signups_display_errors() { 999 // Bail if no activation errors 1000 if ( ! $errors = get_transient( '_bp_admin_signups_errors' ) ) { 1001 return; 1002 } 1003 1004 foreach ( $errors as $error ) { 1005 ?> 1006 <li><?php echo esc_html( $error[0] );?>: <?php echo esc_html( $error[1] );?></li> 1007 <?php 1008 } 1009 1010 // Delete the redirect transient 1011 delete_transient( '_bp_admin_signups_errors' ); 1012 } 1013 1014 /** 1015 * Signups admin page router. 1016 * 1017 * Depending on the context, display 1018 * - the list of signups 1019 * - or the delete confirmation screen 1020 * - or the activate confirmation screen 1021 * - or the "resend" email confirmation screen 1022 * 1023 * Also prepare the admin notices. 1024 * 1025 * @since BuddyPress (2.0.0) 1026 */ 1027 public function signups_admin() { 1028 $doaction = bp_admin_list_table_current_bulk_action(); 1029 1030 // Prepare notices for admin 1031 $notice = array(); 1032 1033 if ( ! empty( $_REQUEST['updated'] ) ) { 1034 switch ( $_REQUEST['updated'] ) { 1035 case 'resent': 1036 $notice = array( 1037 'class' => 'updated', 1038 'message' => '' 1039 ); 1040 1041 if ( ! empty( $_REQUEST['resent'] ) ) { 1042 $notice['message'] .= sprintf( 1043 _nx( '%s activation email successfully sent! ', '%s activation emails successfully sent! ', 1044 absint( $_REQUEST['resent'] ), 1045 'signup resent', 1046 'buddypress' 1047 ), 1048 number_format_i18n( absint( $_REQUEST['resent'] ) ) 1049 ); 1050 } 1051 1052 if ( ! empty( $_REQUEST['notsent'] ) ) { 1053 $notice['message'] .= sprintf( 1054 _nx( '%s activation email was not sent.', '%s activation emails were not sent.', 1055 absint( $_REQUEST['notsent'] ), 1056 'signup notsent', 1057 'buddypress' 1058 ), 1059 number_format_i18n( absint( $_REQUEST['notsent'] ) ) 1060 ); 1061 1062 if ( empty( $_REQUEST['resent'] ) ) { 1063 $notice['class'] = 'error'; 1064 } 1065 } 1066 1067 break; 1068 1069 case 'activated': 1070 $notice = array( 1071 'class' => 'updated', 1072 'message' => '' 1073 ); 1074 1075 if ( ! empty( $_REQUEST['activated'] ) ) { 1076 $notice['message'] .= sprintf( 1077 _nx( '%s account successfully activated! ', '%s accounts successfully activated! ', 1078 absint( $_REQUEST['activated'] ), 1079 'signup resent', 1080 'buddypress' 1081 ), 1082 number_format_i18n( absint( $_REQUEST['activated'] ) ) 1083 ); 1084 } 1085 1086 if ( ! empty( $_REQUEST['notactivated'] ) ) { 1087 $notice['message'] .= sprintf( 1088 _nx( '%s account was not activated.', '%s accounts were not activated.', 1089 absint( $_REQUEST['notactivated'] ), 1090 'signup notsent', 1091 'buddypress' 1092 ), 1093 number_format_i18n( absint( $_REQUEST['notactivated'] ) ) 1094 ); 1095 1096 if ( empty( $_REQUEST['activated'] ) ) { 1097 $notice['class'] = 'error'; 1098 } 1099 } 1100 1101 break; 1102 1103 case 'deleted': 1104 $notice = array( 1105 'class' => 'updated', 1106 'message' => '' 1107 ); 1108 1109 if ( ! empty( $_REQUEST['deleted'] ) ) { 1110 $notice['message'] .= sprintf( 1111 _nx( '%s sign-up successfully deleted!', '%s sign-ups successfully deleted!', 1112 absint( $_REQUEST['deleted'] ), 1113 'signup deleted', 1114 'buddypress' 1115 ), 1116 number_format_i18n( absint( $_REQUEST['deleted'] ) ) 1117 ); 1118 } 1119 1120 if ( ! empty( $_REQUEST['notdeleted'] ) ) { 1121 $notice['message'] .= sprintf( 1122 _nx( '%s sign-up was not deleted.', '%s sign-ups were not deleted.', 1123 absint( $_REQUEST['notdeleted'] ), 1124 'signup notdeleted', 1125 'buddypress' 1126 ), 1127 number_format_i18n( absint( $_REQUEST['notdeleted'] ) ) 1128 ); 1129 1130 if ( empty( $_REQUEST['deleted'] ) ) { 1131 $notice['class'] = 'error'; 1132 } 1133 } 1134 1135 break; 1136 } 1137 } 1138 1139 // Process error messages 1140 if ( ! empty( $_REQUEST['error'] ) ) { 1141 switch ( $_REQUEST['error'] ) { 1142 case 'do_resend': 1143 $notice = array( 1144 'class' => 'error', 1145 'message' => esc_html__( 'There was a problem sending the activation emails, please try again.', 'buddypress' ), 1146 ); 1147 break; 1148 1149 case 'do_activate': 1150 $notice = array( 1151 'class' => 'error', 1152 'message' => esc_html__( 'There was a problem activating accounts, please try again.', 'buddypress' ), 1153 ); 1154 break; 1155 1156 case 'do_delete': 1157 $notice = array( 1158 'class' => 'error', 1159 'message' => esc_html__( 'There was a problem deleting sign-ups, please try again.', 'buddypress' ), 1160 ); 1161 break; 1162 } 1163 } 1164 1165 // Display notices 1166 if ( ! empty( $notice ) ) : 1167 if ( 'updated' === $notice['class'] ) : ?> 1168 <div id="message" class="<?php echo esc_attr( $notice['class'] ); ?>"> 1169 <?php else: ?> 1170 <div class="<?php echo esc_attr( $notice['class'] ); ?>"> 1171 <?php endif; ?> 1172 <p><?php echo $notice['message']; ?></p> 1173 <?php if ( ! empty( $_REQUEST['notactivated'] ) || ! empty( $_REQUEST['notdeleted'] ) || ! empty( $_REQUEST['notsent'] ) ) :?> 1174 <ul><?php $this->signups_display_errors();?></ul> 1175 <?php endif ;?> 1176 </div> 1177 <?php endif; 1178 1179 // Show the proper screen 1180 switch ( $doaction ) { 1181 case 'activate' : 1182 case 'delete' : 1183 case 'resend' : 1184 $this->signups_admin_manage( $doaction ); 1185 break; 1186 1187 default: 1188 $this->signups_admin_index(); 1189 break; 1190 1191 } 1192 } 1193 1194 /** 1195 * This is the list of the Pending accounts (signups). 1196 * 1197 * @since BuddyPress (2.0.0) 1198 * 1199 * @global $plugin_page 1200 * @global $bp_members_signup_list_table 1201 */ 1202 public function signups_admin_index() { 1203 global $plugin_page, $bp_members_signup_list_table; 1204 1205 $usersearch = ! empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; 1206 1207 // Prepare the group items for display 1208 $bp_members_signup_list_table->prepare_items(); 1209 1210 $form_url = add_query_arg( 1211 array( 1212 'page' => 'bp-signups', 1213 ), 1214 bp_get_admin_url( 'users.php' ) 1215 ); 1216 1217 $search_form_url = remove_query_arg( 1218 array( 1219 'action', 1220 'deleted', 1221 'notdeleted', 1222 'error', 1223 'updated', 1224 'delete', 1225 'activate', 1226 'activated', 1227 'notactivated', 1228 'resend', 1229 'resent', 1230 'notresent', 1231 'do_delete', 1232 'do_activate', 1233 'do_resend', 1234 'action2', 1235 '_wpnonce', 1236 'signup_ids' 1237 ), $_SERVER['REQUEST_URI'] 1238 ); 1239 1240 ?> 1241 1242 <div class="wrap"> 1243 <?php screen_icon( 'users' ); ?> 1244 <h2> 1245 <?php 1246 _e( 'Users', 'buddypress' ); 1247 if ( current_user_can( 'create_users' ) ) { ?> 1248 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user' ); ?></a> 1249 <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> 1250 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a> 1251 <?php } 1252 1253 if ( $usersearch ) { 1254 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $usersearch ) ); 1255 } 1256 1257 ?> 1258 </h2> 1259 1260 <?php // Display each signups on its own row ?> 1261 <?php $bp_members_signup_list_table->views(); ?> 1262 1263 <form id="bp-signups-search-form" action="<?php echo esc_url( $search_form_url ) ;?>"> 1264 <input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" /> 1265 <?php $bp_members_signup_list_table->search_box( __( 'Search Pending accounts', 'buddypress' ), 'bp-signups' ); ?> 1266 </form> 1267 1268 <form id="bp-signups-form" action="<?php echo esc_url( $form_url );?>" method="post"> 1269 <?php $bp_members_signup_list_table->display(); ?> 1270 </form> 1271 </div> 1272 <?php 1273 } 1274 1275 /** 1276 * This is the confirmation screen for actions. 1277 * 1278 * @since BuddyPress (2.0.0) 1279 * 1280 * @param string $action Delete, activate, or resend activation link. 1281 */ 1282 public function signups_admin_manage( $action = '' ) { 1283 if ( ! is_super_admin() || empty( $action ) ) { 1284 die( '-1' ); 1285 } 1286 1287 // Get the user IDs from the URL 1288 $ids = false; 1289 if ( ! empty( $_POST['allsignups'] ) ) { 1290 $ids = wp_parse_id_list( $_POST['allsignups'] ); 1291 } else if ( ! empty( $_GET['signup_id'] ) ) { 1292 $ids = absint( $_GET['signup_id'] ); 1293 } 1294 1295 if ( empty( $ids ) ) { 1296 return false; 1297 } 1298 1299 // Query for signups, and filter out those IDs that don't 1300 // correspond to an actual signup 1301 $signups_query = BP_Signup::get( array( 1302 'include' => $ids, 1303 ) ); 1304 1305 $signups = $signups_query['signups']; 1306 $signup_ids = wp_list_pluck( $signups, 'signup_id' ); 1307 1308 // Set up strings 1309 switch ( $action ) { 1310 case 'delete' : 1311 $header_text = __( 'Delete Pending Accounts', 'buddypress' ); 1312 $helper_text = _n( 'You are about to delete the following account:', 'You are about to delete the following accounts:', count( $signup_ids ), 'buddypress' ); 1313 break; 1314 1315 case 'activate' : 1316 $header_text = __( 'Activate Pending Accounts', 'buddypress' ); 1317 $helper_text = _n( 'You are about to activate the following account:', 'You are about to activate the following accounts:', count( $signup_ids ), 'buddypress' ); 1318 break; 1319 1320 case 'resend' : 1321 $header_text = __( 'Resend Activation Emails', 'buddypress' ); 1322 $helper_text = _n( 'You are about to resend an activation email to the following account:', 'You are about to resend activation emails to the following accounts:', count( $signup_ids ), 'buddypress' ); 1323 break; 1324 } 1325 1326 // These arguments are added to all URLs 1327 $url_args = array( 'page' => 'bp-signups' ); 1328 1329 // These arguments are only added when performing an action 1330 $action_args = array( 1331 'action' => 'do_' . $action, 1332 'signup_ids' => implode( ',', $signup_ids ) 1333 ); 1334 1335 $cancel_url = add_query_arg( $url_args, bp_get_admin_url( 'users.php' ) ); 1336 $action_url = wp_nonce_url( 1337 add_query_arg( 1338 array_merge( $url_args, $action_args ), 1339 bp_get_admin_url( 'users.php' ) 1340 ), 1341 'signups_' . $action 1342 ); 1343 1344 ?> 1345 1346 <div class="wrap"> 1347 <?php screen_icon( 'users' ); ?> 1348 <h2><?php echo esc_html( $header_text ); ?></h2> 1349 <p><?php echo esc_html( $helper_text ); ?></p> 1350 1351 <ol class="bp-signups-list"> 1352 <?php foreach ( $signups as $signup ) : 1353 $last_notified = mysql2date( 'Y/m/d g:i:s a', $signup->date_sent ) 1354 ?> 1355 1356 <li> 1357 <?php echo esc_html( $signup->user_name ) ?> - <?php echo sanitize_email( $signup->user_email );?> 1358 1359 <?php if ( 'resend' == $action ) : ?> 1360 <p class="description"> 1361 <?php printf( esc_html__( 'Last notified: %s', 'buddypress'), $last_notified ) ;?> 1362 1363 <?php if ( ! empty( $signup->recently_sent ) ) : ?> 1364 <span class="attention wp-ui-text-notification"> <?php esc_html_e( '(less than 24 hours ago)', 'buddypress' ); ?></span> 1365 <?php endif; ?> 1366 </p> 1367 1368 <?php endif; ?> 1369 </li> 1370 1371 <?php endforeach; ?> 1372 </ol> 1373 1374 <?php if ( 'resend' != $action ) : ?> 1375 <p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p> 1376 <?php endif ; ?> 1377 1378 <a class="button-primary" href="<?php echo esc_url( $action_url ); ?>"><?php esc_html_e( 'Confirm', 'buddypress' ); ?></a> 1379 <a class="button" href="<?php echo esc_url( $cancel_url ); ?>"><?php esc_html_e( 'Cancel', 'buddypress' ) ?></a> 1380 </div> 1381 1382 <?php 1383 } 693 1384 } 694 1385 endif; // class_exists check 695 1386 696 1387 // Load the BP Members admin 697 add_action( 'bp_init', array( 'BP_Members_Admin', 'register_members_admin' ) );1388 add_action( 'bp_init', array( 'BP_Members_Admin', 'register_members_admin' ) );
Note: See TracChangeset
for help on using the changeset viewer.