MS_View_Member_List

The Membership 2 MS View Member List class.

Defined (1)

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

/app/view/member/class-ms-view-member-list.php  
  1. class MS_View_Member_List extends MS_View { 
  2.  
  3. public function to_html() { 
  4. $this->check_simulation(); 
  5.  
  6. // Search for orphaned relationships and delete them. 
  7. MS_Model_Member::clean_db(); 
  8.  
  9. $listview = MS_Factory::create( 'MS_Helper_ListTable_Member' ); 
  10. $listview->prepare_items(); 
  11.  
  12. ob_start(); 
  13. ?> 
  14.  
  15. <div class="wrap ms-wrap ms-member-list"> 
  16. <?php 
  17. MS_Helper_Html::settings_header( 
  18. array( 
  19. 'title' => __( 'Members', 'membership2' ),  
  20. 'title_icon_class' => 'wpmui-fa wpmui-fa-users',  
  21. 'desc' => __( 'Here you can manage the Memberships of existing Users.', 'membership2' ),  
  22. ); 
  23.  
  24. // Display a filter to switch between individual memberships. 
  25. $this->membership_filter(); 
  26.  
  27. $listview->views(); 
  28. $listview->search_box(); 
  29. ?> 
  30. <form method="post"> 
  31. <?php $listview->display(); ?> 
  32. </form> 
  33. </div> 
  34.  
  35. <?php 
  36. $html = ob_get_clean(); 
  37.  
  38. return $html; 
  39.  
  40. /** 
  41. * Display a filter to select the current membership 
  42. * @since 1.0.0 
  43. */ 
  44. public function membership_filter() { 
  45. $memberships = MS_Model_Membership::get_membership_names( 
  46. array( 'active' => true, 'include_guest' => false ) 
  47. ); 
  48. $url = esc_url_raw( 
  49. remove_query_arg( array( 'membership_id', 'paged' ) ) 
  50. ); 
  51. $links = array(); 
  52.  
  53. $links['all'] = array( 
  54. 'label' => __( 'All', 'membership2' ),  
  55. 'url' => $url,  
  56. ); 
  57.  
  58. foreach ( $memberships as $id => $name ) { 
  59. if ( empty( $name ) ) { 
  60. $name = __( '(No Name)', 'membership2' ); 
  61.  
  62. $filter_url = esc_url_raw( 
  63. add_query_arg( array( 'membership_id' => $id ), $url ) 
  64. ); 
  65. $links['ms-' . $id] = array( 
  66. 'label' => esc_html( $name ),  
  67. 'url' => $filter_url,  
  68. ); 
  69.  
  70. ?> 
  71. <div class="wp-filter"> 
  72. <ul class="filter-links"> 
  73. <?php foreach ( $links as $key => $item ) : 
  74. $is_current = MS_Helper_Utility::is_current_url( $item['url'] ); 
  75. $class = ( $is_current ? 'current' : '' ); 
  76. ?> 
  77. <li> 
  78. <a href="<?php echo esc_url( $item['url'] ); ?>" class="<?php echo esc_attr( $class ); ?>"> 
  79. <?php echo esc_html( $item['label'] ); ?> 
  80. </a> 
  81. </li> 
  82. <?php endforeach; ?> 
  83. </ul> 
  84. </div> 
  85. <?php 
  86.