MS_Rule_MenuItem_ListTable

Membership List Table.

Defined (1)

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

/app/rule/menuitem/class-ms-rule-menuitem-listtable.php  
  1. class MS_Rule_MenuItem_ListTable extends MS_Helper_ListTable_Rule { 
  2.  
  3. protected $id = MS_Rule_MenuItem::RULE_ID; 
  4.  
  5. /** 
  6. * A list of all available menus. 
  7. * @var array 
  8. */ 
  9. protected $menus; 
  10.  
  11. /** 
  12. * The currently selected menu-ID. 
  13. * @var int 
  14. */ 
  15. protected $menu_id; 
  16.  
  17. public function __construct( $model, $all_menus, $menu_id ) { 
  18. parent::__construct( $model ); 
  19. $this->menus = $all_menus; 
  20. $this->menu_id = $menu_id; 
  21. $this->name['singular'] = __( 'Menu Item', 'membership2' ); 
  22. $this->name['plural'] = __( 'Menu Items', 'membership2' ); 
  23.  
  24. public function get_columns() { 
  25. $columns = array( 
  26. 'cb' => true,  
  27. 'title' => __( 'Menu Title', 'membership2' ),  
  28. 'type' => __( 'Menu Type', 'membership2' ),  
  29. 'access' => true,  
  30. ); 
  31.  
  32. return apply_filters( 
  33. 'membership_helper_listtable_' . $this->id . '_columns',  
  34. $columns 
  35. ); 
  36.  
  37. public function prepare_items_args( $defaults ) { 
  38. $args = apply_filters( 
  39. 'ms_rule_menuitem_listtable_prepare_items_args',  
  40. array( 'menu_id' => $this->menu_id ) 
  41. ); 
  42.  
  43. return wp_parse_args( $args, $defaults ); 
  44.  
  45. public function column_title( $item, $column_name ) { 
  46. return $item->title; 
  47.  
  48. public function column_type( $item, $column_name ) { 
  49. return $item->type_label; 
  50.  
  51. /** 
  52. * No pagination for this rule 
  53. * @since 1.0.0 
  54. * @return int 
  55. */ 
  56. protected function get_items_per_page( $option, $default_value = null ) { 
  57. return 0; 
  58.  
  59. /** 
  60. * Return true if the current list is a view except "all" 
  61. * @since 1.0.0 
  62. * @return bool 
  63. */ 
  64. public function is_view() { 
  65. return true; 
  66.  
  67. /** 
  68. * The rule uses the view-filter to select the menu to protect 
  69. * @since 1.0.0 
  70. */ 
  71. public function get_views() { 
  72. $views = $this->menus; 
  73. $views[$this->menu_id]['current'] = true; 
  74.  
  75. return $views; 
  76.