BP_Members_MS_List_Table

List table class for signups network admin page.

Defined (1)

The class is defined in the following location(s).

/bp-members/classes/class-bp-members-ms-list-table.php  
  1. class BP_Members_MS_List_Table extends WP_MS_Users_List_Table { 
  2.  
  3. /** 
  4. * Signup counts. 
  5. * @since 2.0.0 
  6. * @var int 
  7. */ 
  8. public $signup_counts = 0; 
  9.  
  10. /** 
  11. * Constructor. 
  12. * @since 2.0.0 
  13. */ 
  14. public function __construct() { 
  15. // Define singular and plural labels, as well as whether we support AJAX. 
  16. parent::__construct( array( 
  17. 'ajax' => false,  
  18. 'plural' => 'signups',  
  19. 'singular' => 'signup',  
  20. 'screen' => get_current_screen()->id,  
  21. ) ); 
  22.  
  23. /** 
  24. * Set up items for display in the list table. 
  25. * Handles filtering of data, sorting, pagination, and any other data 
  26. * manipulation required prior to rendering. 
  27. * @since 2.0.0 
  28. */ 
  29. public function prepare_items() { 
  30. global $usersearch, $mode; 
  31.  
  32. $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; 
  33. $signups_per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) ); 
  34. $paged = $this->get_pagenum(); 
  35.  
  36. $args = array( 
  37. 'offset' => ( $paged - 1 ) * $signups_per_page,  
  38. 'number' => $signups_per_page,  
  39. 'usersearch' => $usersearch,  
  40. 'orderby' => 'signup_id',  
  41. 'order' => 'DESC' 
  42. ); 
  43.  
  44. if ( isset( $_REQUEST['orderby'] ) ) { 
  45. $args['orderby'] = $_REQUEST['orderby']; 
  46.  
  47. if ( isset( $_REQUEST['order'] ) ) { 
  48. $args['order'] = $_REQUEST['order']; 
  49.  
  50. $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; 
  51. $signups = BP_Signup::get( $args ); 
  52.  
  53. $this->items = $signups['signups']; 
  54. $this->signup_counts = $signups['total']; 
  55.  
  56. $this->set_pagination_args( array( 
  57. 'total_items' => $this->signup_counts,  
  58. 'per_page' => $signups_per_page,  
  59. ) ); 
  60.  
  61. /** 
  62. * Display the users screen views 
  63. * @since 2.5.0 
  64. * @global string $role The name of role the users screens is filtered by 
  65. */ 
  66. public function views() { 
  67. global $role; 
  68.  
  69. // Used to reset the role. 
  70. $reset_role = $role; 
  71.  
  72. // Temporarly set the role to registered. 
  73. $role = 'registered'; 
  74.  
  75. // Used to reset the screen id once views are displayed. 
  76. $reset_screen_id = $this->screen->id; 
  77.  
  78. // Temporarly set the screen id to the users one. 
  79. $this->screen->id = 'users-network'; 
  80.  
  81. // Use the parent function so that other plugins can safely add views. 
  82. parent::views(); 
  83.  
  84. // Reset the role. 
  85. $role = $reset_role; 
  86.  
  87. // Reset the screen id. 
  88. $this->screen->id = $reset_screen_id; 
  89.  
  90. /** 
  91. * Specific signups columns. 
  92. * @since 2.0.0 
  93. * @return array 
  94. */ 
  95. public function get_columns() { 
  96.  
  97. /** 
  98. * Filters the multisite Members signup columns. 
  99. * @since 2.0.0 
  100. * @param array $value Array of columns to display. 
  101. */ 
  102. return apply_filters( 'bp_members_ms_signup_columns', array( 
  103. 'cb' => '<input type="checkbox" />',  
  104. 'username' => __( 'Username', 'buddypress' ),  
  105. 'name' => __( 'Name', 'buddypress' ),  
  106. 'email' => __( 'Email', 'buddypress' ),  
  107. 'registered' => __( 'Registered', 'buddypress' ),  
  108. 'date_sent' => __( 'Last Sent', 'buddypress' ),  
  109. 'count_sent' => __( 'Emails Sent', 'buddypress' ) 
  110. ) ); 
  111.  
  112. /** 
  113. * Specific bulk actions for signups. 
  114. * @since 2.0.0 
  115. */ 
  116. public function get_bulk_actions() { 
  117. $actions = array( 
  118. 'activate' => _x( 'Activate', 'Pending signup action', 'buddypress' ),  
  119. 'resend' => _x( 'Email', 'Pending signup action', 'buddypress' ),  
  120. ); 
  121.  
  122. if ( current_user_can( 'delete_users' ) ) { 
  123. $actions['delete'] = __( 'Delete', 'buddypress' ); 
  124.  
  125. return $actions; 
  126.  
  127. /** 
  128. * The text shown when no items are found. 
  129. * Nice job, clean sheet! 
  130. * @since 2.0.0 
  131. */ 
  132. public function no_items() { 
  133. if ( bp_get_signup_allowed() ) { 
  134. esc_html_e( 'No pending accounts found.', 'buddypress' ); 
  135. } else { 
  136. $link = false; 
  137.  
  138. if ( current_user_can( 'manage_network_users' ) ) { 
  139. $link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( network_admin_url( 'settings.php' ) ), esc_html__( 'Edit settings', 'buddypress' ) ); 
  140.  
  141. printf( __( 'Registration is disabled. %s', 'buddypress' ), $link ); 
  142.  
  143. /** 
  144. * The columns signups can be reordered with. 
  145. * @since 2.0.0 
  146. */ 
  147. public function get_sortable_columns() { 
  148. return array( 
  149. 'username' => 'login',  
  150. 'email' => 'email',  
  151. 'registered' => 'signup_id',  
  152. ); 
  153.  
  154. /** 
  155. * Display signups rows. 
  156. * @since 2.0.0 
  157. */ 
  158. public function display_rows() { 
  159. $style = ''; 
  160. foreach ( $this->items as $userid => $signup_object ) { 
  161.  
  162. // Avoid a notice error appearing since 4.3.0. 
  163. if ( isset( $signup_object->id ) ) { 
  164. $signup_object->ID = $signup_object->id; 
  165.  
  166. $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"'; 
  167. echo "\n\t" . $this->single_row( $signup_object, $style ); 
  168.  
  169. /** 
  170. * Display a signup row. 
  171. * @since 2.0.0 
  172. * @see WP_List_Table::single_row() for explanation of params. 
  173. * @param object|null $signup_object Signup user object. 
  174. * @param string $style Styles for the row. 
  175. */ 
  176. public function single_row( $signup_object = null, $style = '' ) { 
  177. echo '<tr' . $style . ' id="signup-' . esc_attr( $signup_object->id ) . '">'; 
  178. echo $this->single_row_columns( $signup_object ); 
  179. echo '</tr>'; 
  180.  
  181. /** 
  182. * Prevents regular users row actions to be output. 
  183. * @since 2.4.0 
  184. * @param object|null $signup_object Signup being acted upon. 
  185. * @param string $column_name Current column name. 
  186. * @param string $primary Primary column name. 
  187. * @return string 
  188. */ 
  189. protected function handle_row_actions( $signup_object = null, $column_name = '', $primary = '' ) { 
  190. return ''; 
  191.  
  192. /** 
  193. * Markup for the checkbox used to select items for bulk actions. 
  194. * @since 2.0.0 
  195. * @param object|null $signup_object The signup data object. 
  196. */ 
  197. public function column_cb( $signup_object = null ) { 
  198. ?> 
  199. <label class="screen-reader-text" for="signup_<?php echo intval( $signup_object->id ); ?>"><?php printf( 
  200. /** translators: accessibility text */ 
  201. esc_html__( 'Select user: %s', 'buddypress' ), $signup_object->user_login ); 
  202. ?></label> 
  203. <input type="checkbox" id="signup_<?php echo intval( $signup_object->id ) ?>" name="allsignups[]" value="<?php echo esc_attr( $signup_object->id ) ?>" /> 
  204. <?php 
  205.  
  206. /** 
  207. * The row actions (delete/activate/email). 
  208. * @since 2.0.0 
  209. * @param object|null $signup_object The signup data object. 
  210. */ 
  211. public function column_username( $signup_object = null ) { 
  212. $avatar = get_avatar( $signup_object->user_email, 32 ); 
  213.  
  214. // Activation email link. 
  215. $email_link = add_query_arg( 
  216. array( 
  217. 'page' => 'bp-signups',  
  218. 'signup_id' => $signup_object->id,  
  219. 'action' => 'resend',  
  220. ),  
  221. network_admin_url( 'users.php' ) 
  222. ); 
  223.  
  224. // Activate link. 
  225. $activate_link = add_query_arg( 
  226. array( 
  227. 'page' => 'bp-signups',  
  228. 'signup_id' => $signup_object->id,  
  229. 'action' => 'activate',  
  230. ),  
  231. network_admin_url( 'users.php' ) 
  232. ); 
  233.  
  234. // Delete link. 
  235. $delete_link = add_query_arg( 
  236. array( 
  237. 'page' => 'bp-signups',  
  238. 'signup_id' => $signup_object->id,  
  239. 'action' => 'delete',  
  240. ),  
  241. network_admin_url( 'users.php' ) 
  242. ); 
  243.  
  244. echo $avatar . sprintf( '<strong><a href="%1$s" class="edit" title="%2$s">%3$s</a></strong><br/>', esc_url( $activate_link ), esc_attr__( 'Activate', 'buddypress' ), $signup_object->user_login ); 
  245.  
  246. $actions = array(); 
  247.  
  248. $actions['activate'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $activate_link ), __( 'Activate', 'buddypress' ) ); 
  249. $actions['resend'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $email_link ), __( 'Email', 'buddypress' ) ); 
  250.  
  251. if ( current_user_can( 'delete_users' ) ) { 
  252. $actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), __( 'Delete', 'buddypress' ) ); 
  253.  
  254. /** This filter is documented in bp-members/admin/bp-members-classes.php */ 
  255. $actions = apply_filters( 'bp_members_ms_signup_row_actions', $actions, $signup_object ); 
  256.  
  257. echo $this->row_actions( $actions ); 
  258.  
  259. /** 
  260. * Display user name, if any. 
  261. * @since 2.0.0 
  262. * @param object|null $signup_object The signup data object. 
  263. */ 
  264. public function column_name( $signup_object = null ) { 
  265. echo esc_html( $signup_object->user_name ); 
  266.  
  267. /** 
  268. * Display user email. 
  269. * @since 2.0.0 
  270. * @param object|null $signup_object The signup data object. 
  271. */ 
  272. public function column_email( $signup_object = null ) { 
  273. printf( '<a href="mailto:%1$s">%2$s</a>', esc_attr( $signup_object->user_email ), esc_html( $signup_object->user_email ) ); 
  274.  
  275. /** 
  276. * Display registration date. 
  277. * @since 2.0.0 
  278. * @param object|null $signup_object The signup data object. 
  279. */ 
  280. public function column_registered( $signup_object = null ) { 
  281. global $mode; 
  282.  
  283. if ( 'list' === $mode ) { 
  284. $date = 'Y/m/d'; 
  285. } else { 
  286. $date = 'Y/m/d \<\b\r \/\> g:i:s a'; 
  287.  
  288. echo mysql2date( $date, $signup_object->registered ) . "</td>"; 
  289.  
  290. /** 
  291. * Display the last time an activation email has been sent. 
  292. * @since 2.0.0 
  293. * @param object|null $signup_object Signup object instance. 
  294. */ 
  295. public function column_date_sent( $signup_object = null ) { 
  296. global $mode; 
  297.  
  298. if ( 'list' === $mode ) { 
  299. $date = 'Y/m/d'; 
  300. } else { 
  301. $date = 'Y/m/d \<\b\r \/\> g:i:s a'; 
  302.  
  303. echo mysql2date( $date, $signup_object->date_sent ); 
  304.  
  305. /** 
  306. * Display number of time an activation email has been sent. 
  307. * @since 2.0.0 
  308. * @param object|null $signup_object Signup object instance. 
  309. */ 
  310. public function column_count_sent( $signup_object = null ) { 
  311. echo absint( $signup_object->count_sent ); 
  312.  
  313. /** 
  314. * Allow plugins to add their custom column. 
  315. * @since 2.1.0 
  316. * @param object|null $signup_object The signup data object. 
  317. * @param string $column_name The column name. 
  318. * @return string 
  319. */ 
  320. function column_default( $signup_object = null, $column_name = '' ) { 
  321.  
  322. /** 
  323. * Filters the multisite custom columns for plugins. 
  324. * @since 2.1.0 
  325. * @param string $column_name The column name. 
  326. * @param object $signup_object The signup data object. 
  327. */ 
  328. return apply_filters( 'bp_members_ms_signup_custom_column', '', $column_name, $signup_object );