MS_Helper_ListTable_Event

Membership List Table.

Defined (1)

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

/app/helper/listtable/class-ms-helper-listtable-event.php  
  1. class MS_Helper_ListTable_Event extends MS_Helper_ListTable { 
  2.  
  3. protected $id = 'event'; 
  4.  
  5. public function __construct() { 
  6. parent::__construct( 
  7. array( 
  8. 'singular' => 'event',  
  9. 'plural' => 'events',  
  10. 'ajax' => false,  
  11. ); 
  12.  
  13. public function get_columns() { 
  14. $columns = array( 
  15. 'post_modified' => __( 'Date', 'membership2' ),  
  16. 'user_id' => __( 'Member', 'membership2' ),  
  17. 'membership_id' => __( 'Membership', 'membership2' ),  
  18. 'description' => __( 'Event', 'membership2' ),  
  19. ); 
  20.  
  21. if ( isset( $_REQUEST['membership_id'] ) ) { 
  22. unset( $columns['membership_id'] ); 
  23.  
  24. return apply_filters( 
  25. 'membership_helper_listtable_event_columns',  
  26. $columns 
  27. ); 
  28.  
  29. public function get_sortable_columns() { 
  30. return apply_filters( 
  31. 'membership_helper_listtable_event_sortable_columns',  
  32. array( 
  33. 'post_modified' => array( 'post_modified', false ),  
  34. 'user_id' => array( 'user_id', false ),  
  35. 'membership_id' => array( 'membership_id', false ),  
  36. ); 
  37.  
  38. /** 
  39. * Prepare list items. 
  40. * @since 1.0.0 
  41. */ 
  42. public function prepare_items() { 
  43. $this->_column_headers = array( 
  44. $this->get_columns(),  
  45. array(),  
  46. $this->get_sortable_columns(),  
  47. ); 
  48.  
  49. $per_page = apply_filters( 
  50. 'ms_helper_listtable_member_items_per_page',  
  51. self::DEFAULT_PAGE_SIZE 
  52. ); 
  53. $current_page = $this->get_pagenum(); 
  54.  
  55. $args = array( 
  56. 'posts_per_page' => $per_page,  
  57. 'offset' => ( $current_page - 1 ) * $per_page,  
  58. ); 
  59.  
  60. if ( isset( $_REQUEST['membership_id'] ) ) { 
  61. $args['membership_id'] = $_REQUEST['membership_id']; 
  62.  
  63. if ( ! empty( $_REQUEST['s'] ) ) { 
  64. $args['s'] = $_REQUEST['s']; 
  65. $this->search_string = $args['s']; 
  66. $args['posts_per_page'] = -1; 
  67. $args['number'] = false; 
  68. $args['offset'] = 0; 
  69.  
  70. // Prepare order by statement. 
  71. if ( ! empty( $_REQUEST['orderby'] ) && ! empty( $_REQUEST['order'] ) ) { 
  72. $args['orderby'] = $_REQUEST['orderby']; 
  73. $args['order'] = $_REQUEST['order']; 
  74.  
  75. $total_items = MS_Model_Event::get_event_count( $args ); 
  76. $this->items = MS_Model_Event::get_events( $args ); 
  77.  
  78. $this->set_pagination_args( 
  79. array( 
  80. 'total_items' => $total_items,  
  81. 'per_page' => $per_page,  
  82. ); 
  83.  
  84. do_action( 
  85. 'ms_helper_listtable_event_prepare_items',  
  86. $args,  
  87. $this 
  88. ); 
  89.  
  90. public function column_user_id( $item, $column_name ) { 
  91. $member = MS_Factory::load( 
  92. 'MS_Model_Member',  
  93. $item->user_id 
  94. ); 
  95. $html = $member->username; 
  96.  
  97. return $html; 
  98.  
  99. public function column_membership_id( $item, $column_name ) { 
  100. $membership = MS_Factory::load( 
  101. 'MS_Model_Membership',  
  102. $item->membership_id 
  103. ); 
  104. $html = $membership->name; 
  105.  
  106. return $html; 
  107.  
  108. public function column_post_modified( $item, $column_name ) { 
  109. $html = MS_Helper_Period::format_date( $item->post_modified ); 
  110.  
  111. return $html; 
  112.  
  113. public function column_description( $item, $column_name ) { 
  114. $html = $item->description; 
  115.  
  116. return $html; 
  117.