/app/rule/post/class-ms-rule-post-listtable.php

  1. <?php 
  2. /** 
  3. * Membership List Table 
  4. * 
  5. * @since 1.0.0 
  6. */ 
  7. class MS_Rule_Post_ListTable extends MS_Helper_ListTable_Rule { 
  8.  
  9. protected $id = MS_Rule_Post::RULE_ID; 
  10.  
  11. public function __construct( $model ) { 
  12. parent::__construct( $model ); 
  13. $this->name['singular'] = __( 'Post', 'membership2' ); 
  14. $this->name['plural'] = __( 'Posts', 'membership2' ); 
  15.  
  16. public function get_columns() { 
  17. $columns = array( 
  18. 'cb' => true,  
  19. 'name' => __( 'Post title', 'membership2' ),  
  20. 'access' => true,  
  21. 'post_date' => __( 'Post date', 'membership2' ),  
  22. 'dripped' => true,  
  23. ); 
  24.  
  25. return apply_filters( 
  26. 'ms_helper_listtable_' . $this->id . '_columns',  
  27. $columns 
  28. ); 
  29.  
  30. public function get_sortable_columns() { 
  31. return apply_filters( 
  32. 'membership_helper_listtable_' . $this->id . '_sortable_columns',  
  33. array( 
  34. 'name' => array( 'name', false ),  
  35. 'dripped' => array( 'dripped', false ),  
  36. ); 
  37.  
  38. public function column_name( $item ) { 
  39. $actions = array( 
  40. sprintf( 
  41. '<a href="%s" target="_blank">%s</a>',  
  42. get_edit_post_link( $item->id, true ),  
  43. __( 'Edit', 'membership2' ) 
  44. ),  
  45. sprintf( 
  46. '<a href="%s" target="_blank">%s</a>',  
  47. get_permalink( $item->id ),  
  48. __( 'View', 'membership2' ) 
  49. ),  
  50. ); 
  51. $actions = apply_filters( 
  52. 'ms_rule_' . $this->id . '_column_actions',  
  53. $actions,  
  54. $item 
  55. ); 
  56.  
  57. return sprintf( 
  58. '%1$s %2$s',  
  59. $item->post_title,  
  60. $this->row_actions( $actions ) 
  61. ); 
  62.  
  63. public function column_post_date( $item, $column_name ) { 
  64. return MS_Helper_Period::format_date( $item->post_date ); 
  65.  
  66. /** 
  67. * Extra controls to be displayed between bulk actions and pagination 
  68. * 
  69. * @param string $which Either 'top' or 'bottom' 
  70. * @param bool $echo Output or return the HTML code? Default is output. 
  71. */ 
  72. public function extra_tablenav( $which, $echo = true ) { 
  73. if ( 'top' != $which ) { 
  74. return; 
  75.  
  76. $filter_button = array( 
  77. 'id' => 'filter_button',  
  78. 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT,  
  79. 'value' => __( 'Filter', 'membership2' ),  
  80. 'class' => 'button',  
  81. ); 
  82.  
  83. if ( ! $echo ) { ob_start(); } 
  84. ?> 
  85. <div class="alignleft actions"> 
  86. <?php 
  87. $this->months_dropdown( 'page' ); 
  88. MS_Helper_Html::html_element( $filter_button ); 
  89. ?> 
  90. </div> 
  91. <?php 
  92. if ( ! $echo ) { return ob_get_clean(); } 
.