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

  1. <?php 
  2. /** 
  3. * Membership List Table 
  4. * 
  5. * @since 1.0.0 
  6. */ 
  7. class MS_Helper_ListTable_Rule extends MS_Helper_ListTable { 
  8.  
  9. /** 
  10. * ID of the rule. This is overwritten by each rule! 
  11. * 
  12. * @var string 
  13. */ 
  14. protected $id = 'rule'; 
  15.  
  16. /** 
  17. * Holds the human readable name of the rule tyle 
  18. * 
  19. * @since 1.0.0 
  20. * @var array 
  21. */ 
  22. protected $name = array( 
  23. 'singular' => 'Item',  
  24. 'plural' => 'Items',  
  25. 'default_access' => 'Everyone',  
  26. ); 
  27.  
  28. /** 
  29. * The rule model 
  30. * 
  31. * @var MS_Rule 
  32. */ 
  33. protected $model; 
  34.  
  35. /** 
  36. * The membership object linked to the rule 
  37. * 
  38. * @var MS_Model_Membership 
  39. */ 
  40. protected $membership; 
  41.  
  42. /** 
  43. * The `prepare_items()` function stores the prepared filter args in this 
  44. * member variable for later usage. 
  45. * 
  46. * @var array 
  47. * @since 1.0.0 
  48. */ 
  49. protected $prepared_args = array(); 
  50.  
  51. /** 
  52. * A list of all active memberships 
  53. * 
  54. * @var array 
  55. * @since 1.0.0 
  56. */ 
  57. static protected $memberships = array(); 
  58.  
  59. /** 
  60. * Initialize the list table 
  61. * 
  62. * @since 1.0.0 
  63. * @param MS_Rule $model Rule-Model 
  64. */ 
  65. public function __construct( $model ) { 
  66. parent::__construct( 
  67. array( 
  68. 'singular' => 'rule_' . $this->id,  
  69. 'plural' => 'rules_' . $this->id,  
  70. 'ajax' => false,  
  71. ); 
  72.  
  73. $this->name['singular'] = __( 'Item', 'membership2' ); 
  74. $this->name['plural'] = __( 'Items', 'membership2' ); 
  75. $this->name['default_access'] = __( 'Everyone', 'membership2' ); 
  76.  
  77. $this->model = $model; 
  78. $this->membership = MS_Model_Membership::get_base(); 
  79.  
  80. $memberships = MS_Model_Membership::get_memberships(); 
  81. self::$memberships = array(); 
  82.  
  83. foreach ( $memberships as $item ) { 
  84. self::$memberships[$item->id] = (object) array( 
  85. 'label' => $item->name,  
  86. 'attr' => sprintf( 'data-color="%1$s"', $item->get_color() ),  
  87. ); 
  88.  
  89. // Add code right before the bulk actions are displayed. 
  90. add_action( 
  91. 'ms_listtable_before_bulk_actions',  
  92. array( $this, 'add_rule_type' ) 
  93. ); 
  94.  
  95. /** 
  96. * Returns the rule model. 
  97. * 
  98. * @since 1.0.0 
  99. * @return MS_Rule 
  100. */ 
  101. public function get_model() { 
  102. return $this->model; 
  103.  
  104. public function get_columns() { 
  105. return apply_filters( 
  106. 'ms_helper_listtable_' . $this->id . '_columns',  
  107. array( 
  108. 'cb' => '<input type="checkbox" />',  
  109. 'content' => __( 'Content', 'membership2' ),  
  110. 'rule_type' => __( 'Rule type', 'membership2' ),  
  111. 'dripped' => __( 'Dripped Content', 'membership2' ),  
  112. ); 
  113.  
  114. public function get_hidden_columns() { 
  115. return apply_filters( 
  116. 'ms_helper_listtable_' . $this->id . '_hidden_columns',  
  117. array() 
  118. ); 
  119.  
  120. public function get_sortable_columns() { 
  121. return apply_filters( 
  122. 'ms_helper_listtable_' . $this->id . '_sortable_columns',  
  123. array() 
  124. ); 
  125.  
  126. /** 
  127. * Defines bulk-actions that are available for this list. 
  128. * 
  129. * @since 1.0.0 
  130. * @return array 
  131. */ 
  132. public function get_bulk_actions() { 
  133. $protect_key = __( 'Add Membership', 'membership2' ); 
  134. $unprotect_key = __( 'Drop Membership', 'membership2' ); 
  135. $bulk_actions = array( 
  136. 'rem-all' => __( 'Drop all Memberships', 'membership2' ),  
  137. $protect_key => array(),  
  138. $unprotect_key => array(),  
  139. ); 
  140.  
  141. $memberships = MS_Model_Membership::get_membership_names(); 
  142. $txt_add = __( 'Add: %s', 'membership2' ); 
  143. $txt_rem = __( 'Drop: %s', 'membership2' ); 
  144. foreach ( $memberships as $id => $name ) { 
  145. $bulk_actions[$protect_key]['add-' . $id] = sprintf( $txt_add, $name ); 
  146. $bulk_actions[$unprotect_key]['rem-' . $id] = sprintf( $txt_rem, $name ); 
  147.  
  148. return apply_filters( 
  149. 'ms_helper_listtable_' . $this->id . '_bulk_actions',  
  150. $bulk_actions 
  151. ); 
  152.  
  153. /** 
  154. * Adds a hidden field to the form that passes the current rule_type to the 
  155. * bulk-edit action handler. 
  156. * 
  157. * @since 1.0.0 
  158. */ 
  159. public function add_rule_type() { 
  160. MS_Helper_Html::html_element( 
  161. array( 
  162. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  163. 'name' => 'rule_type',  
  164. 'value' => $this->id, // $this->id is always identical to RULE_ID 
  165. ); 
  166.  
  167. /** 
  168. * Prepare the list and choose which items to display. 
  169. * 
  170. * This is the core logic of the listtable parent class! 
  171. * 
  172. * @since 1.0.0 
  173. */ 
  174. public function prepare_items() { 
  175. $args = null; 
  176.  
  177. $this->_column_headers = array( 
  178. $this->get_columns(),  
  179. $this->get_hidden_columns(),  
  180. $this->get_sortable_columns(),  
  181. ); 
  182.  
  183. // Some columns have a pre-defined title that cannot be changed. 
  184. if ( isset( $this->_column_headers[0]['cb'] ) ) { 
  185. $this->_column_headers[0]['cb'] = '<input type="checkbox" />'; 
  186.  
  187. $is_dripped = in_array( $this->model->rule_type, MS_Model_Rule::get_dripped_rule_types() ); 
  188. if ( $is_dripped ) { 
  189. $this->_column_headers[0]['dripped'] = __( 'Reveal Content', 'membership2' ); 
  190. } else { 
  191. unset( $this->_column_headers[0]['dripped'] ); 
  192.  
  193. if ( isset( $this->_column_headers[0]['access'] ) ) { 
  194. $this->_column_headers[0]['access'] = __( 'Who Has Access', 'membership2' ); 
  195.  
  196. // Initialize current pagination Page 
  197. $per_page = $this->get_items_per_page( 
  198. "{$this->id}_per_page",  
  199. self::DEFAULT_PAGE_SIZE 
  200. ); 
  201.  
  202. /** 
  203. * Custom filter to modify the items on all Protection Rule list tables. 
  204. * 
  205. * @since 1.0.1.0 
  206. * @var int 
  207. */ 
  208. $per_page = apply_filters( 
  209. 'rule_items_per_page',  
  210. $per_page,  
  211. $this->id 
  212. ); 
  213.  
  214. $current_page = $this->get_pagenum(); 
  215.  
  216. $args = array( 
  217. 'posts_per_page' => $per_page,  
  218. 'number' => $per_page,  
  219. 'offset' => ( $current_page - 1 ) * $per_page,  
  220. ); 
  221.  
  222. // Add a status filter 
  223. if ( ! empty( $_GET['status'] ) ) { 
  224. $args['rule_status'] = $_GET['status']; 
  225.  
  226. // Search string. 
  227. if ( ! empty( $_REQUEST['s'] ) ) { 
  228. $this->search_string = $_REQUEST['s']; 
  229. $args['s'] = $_REQUEST['s']; 
  230. $args['posts_per_page'] = -1; 
  231. $args['number'] = false; 
  232. $args['offset'] = 0; 
  233.  
  234. // Month filter. 
  235. if ( ! empty( $_REQUEST['m'] ) && 6 == strlen( $_REQUEST['m'] ) ) { 
  236. $args['year'] = substr( $_REQUEST['m'], 0 , 4 ); 
  237. $args['monthnum'] = substr( $_REQUEST['m'], 5 , 2 ); 
  238.  
  239. // If a membership is filtered then only show protected items 
  240. if ( ! empty( $_REQUEST['membership_id'] ) ) { 
  241. $args['membership_id'] = $_REQUEST['membership_id']; 
  242.  
  243. // Allow other helper list tables to customize the args array. 
  244. $args = $this->prepare_items_args( $args ); 
  245.  
  246. // Count items 
  247. $total_items = $this->model->get_content_count( $args ); 
  248.  
  249. // List available items 
  250. $this->items = apply_filters( 
  251. "ms_rule_{$this->id}_items",  
  252. $this->model->get_contents( $args ) 
  253. ); 
  254.  
  255. // Save the args for use in later functions 
  256. $this->prepared_args = $args; 
  257.  
  258. // Prepare the table pagination 
  259. $this->set_pagination_args( 
  260. array( 
  261. 'total_items' => $total_items,  
  262. 'per_page' => $per_page,  
  263. ); 
  264.  
  265. /** 
  266. * Returns true, if the list displays items of the base membership. 
  267. * i.e. true means that the Membership filter is set to "All" 
  268. * 
  269. * @since 1.0.0 
  270. * @return bool 
  271. */ 
  272. public function list_shows_base_items() { 
  273. static $Is_Base = null; 
  274.  
  275. if ( null === $Is_Base ) { 
  276. $Is_Base = $this->get_membership()->is_base(); 
  277.  
  278. return $Is_Base; 
  279.  
  280. /** 
  281. * Returnst the membership of the current view. 
  282. * 
  283. * @since 1.0.0 
  284. * @return bool 
  285. */ 
  286. public function get_membership() { 
  287. static $Membership = null; 
  288.  
  289. if ( null === $Membership ) { 
  290. if ( ! empty( $_REQUEST['membership_id'] ) ) { 
  291. $Membership = MS_Factory::load( 'MS_Model_Membership', $_REQUEST['membership_id'] ); 
  292.  
  293. if ( empty( $Membership ) || ! $Membership->is_valid() ) { 
  294. $Membership = MS_Model_Membership::get_base(); 
  295.  
  296. return $Membership; 
  297.  
  298. /** 
  299. * Can be overwritten to customize the args array for prepare_items() 
  300. * 
  301. * @since 1.0.0 
  302. * @param array $defaults 
  303. * @return array 
  304. */ 
  305. public function prepare_items_args( $defaults ) { 
  306. return $defaults; 
  307.  
  308. /** 
  309. * Return content of Checkbox column. 
  310. * This column also contains the inline-editor-data for `item_id` - this 
  311. * value can be overwritten in any of the other columns. 
  312. * 
  313. * @since 1.0.0 
  314. */ 
  315. public function column_cb( $item, $column_name ) { 
  316. return sprintf( 
  317. '<input type="checkbox" name="item[]" value="%1$s" />' . 
  318. '<div class="inline_data hidden"><span class="item_id">%1$s</span></div>',  
  319. $item->id 
  320. ); 
  321.  
  322. public function column_access( $item, $column_name ) { 
  323. $rule = $this->model; 
  324. $memberships = $rule->get_memberships( $item->id ); 
  325.  
  326. $public = array( 
  327. 'id' => 'ms-empty-' . $item->id,  
  328. 'type' => MS_Helper_Html::TYPE_HTML_TEXT,  
  329. 'value' => $this->name['default_access'],  
  330. 'after' => 'Modify Access',  
  331. 'class' => 'ms-empty-note',  
  332. ); 
  333.  
  334. $list = array( 
  335. 'id' => 'ms-memberships-' . $item->id,  
  336. 'type' => MS_Helper_Html::INPUT_TYPE_SELECT,  
  337. 'value' => array_keys( $memberships ),  
  338. 'field_options' => self::$memberships,  
  339. 'multiple' => true,  
  340. 'class' => 'ms-memberships',  
  341. 'ajax_data' => array( 
  342. 'action' => MS_Controller_Rule::AJAX_ACTION_CHANGE_MEMBERSHIPS,  
  343. 'rule' => $item->type,  
  344. 'item' => $item->id,  
  345. ),  
  346. ); 
  347.  
  348. $html = sprintf( 
  349. '<div class="no-auto-init">%1$s%2$s</div>',  
  350. MS_Helper_Html::html_element( $public, true ),  
  351. MS_Helper_Html::html_element( $list, true ) 
  352. ); 
  353.  
  354. return $html; 
  355.  
  356. public function column_dripped( $item, $column_name ) { 
  357. static $Dripped_memberships = null; 
  358. $membership = $this->get_membership(); 
  359. $label = ''; 
  360.  
  361. if ( null === $Dripped_memberships ) { 
  362. $Dripped_memberships = MS_Model_membership::get_dripped_memberships(); 
  363.  
  364. if ( $membership->is_base() ) { 
  365. // Base: If only one dripped membership then show the date. 
  366. foreach ( $Dripped_memberships as $membership ) { 
  367. $rule = $membership->get_rule( $this->model->rule_type ); 
  368. if ( ! empty( $rule->dripped[$item->id] ) ) { 
  369. if ( empty( $label ) ) { 
  370. $label = $rule->get_dripped_description( $item->id ); 
  371. } else { 
  372. // Multiple dripped memberships. Display placeholer text. 
  373. $label = ''; 
  374. break; 
  375. } elseif ( $membership->is_dripped() ) { 
  376. $rule = $membership->get_rule( $this->model->rule_type ); 
  377. if ( ! empty( $rule->dripped[$item->id] ) ) { 
  378. $label = $rule->get_dripped_description( $item->id ); 
  379.  
  380. if ( empty( $label ) ) { 
  381. $label = __( 'Set date...', 'membership2' ); 
  382.  
  383. $offset = 0; 
  384. $number = 20; 
  385. if ( isset( $this->prepared_args['offset'] ) ) { 
  386. $offset = $this->prepared_args['offset']; 
  387. } elseif ( isset( $_POST['offset'] ) ) { 
  388. $offset = $_POST['offset']; 
  389. if ( isset( $this->prepared_args['number'] ) ) { 
  390. $number = $this->prepared_args['number']; 
  391. } elseif ( isset( $_POST['number'] ) ) { 
  392. $number = $_POST['number']; 
  393.  
  394. ob_start(); 
  395. ?> 
  396. <a href="#" class="editinline"><?php echo '' . $label; ?></a> 
  397. <div class="inline_data hidden"> 
  398. <span class="name"><?php echo esc_html( $item->name ); ?></span> 
  399. <?php 
  400. foreach ( $Dripped_memberships as $membership ) { 
  401. $rule = $membership->get_rule( $this->model->rule_type ); 
  402. if ( ! empty( $rule->dripped[$item->id] ) ) { 
  403. $data = $rule->dripped[$item->id]; 
  404. printf( 
  405. '<span class="ms_%1$s[dripped_type]">%2$s</span>' . 
  406. '<span class="ms_%1$s[date]">%3$s</span>' . 
  407. '<span class="ms_%1$s[delay_unit]">%4$s</span>' . 
  408. '<span class="ms_%1$s[delay_type]">%5$s</span>' . 
  409. '<span class="offset">%6$s</span>' . 
  410. '<span class="number">%7$s</span>',  
  411. $membership->id,  
  412. $data['type'],  
  413. $data['date'],  
  414. $data['delay_unit'],  
  415. $data['delay_type'],  
  416. $offset,  
  417. $number 
  418. ); 
  419. ?> 
  420. </div> 
  421. <?php 
  422. $html = ob_get_clean(); 
  423.  
  424. return apply_filters( 
  425. 'ms_helper_listtable_rule_column_dripped',  
  426. $html 
  427. ); 
  428.  
  429. public function column_content( $item, $column_name ) { 
  430. $html = $item->content; 
  431.  
  432. return $html; 
  433.  
  434. /** 
  435. * Adds a class to the <tr> element 
  436. * 
  437. * @since 1.0.0 
  438. * @param object $item 
  439. */ 
  440. protected function single_row_class( $item ) { 
  441. $rule = $this->model; 
  442. $memberships = $rule->get_memberships( $item->id ); 
  443.  
  444. $class = empty( $memberships ) ? 'ms-empty' : 'ms-assigned'; 
  445. return $class; 
  446.  
  447. /** 
  448. * Displays the inline-edit form used to edit the dripped content details. 
  449. * 
  450. * @since 1.0.0 
  451. */ 
  452. protected function inline_edit() { 
  453. $rule = $this->model; 
  454. $membership = $this->membership; 
  455.  
  456. $field_action = array( 
  457. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  458. 'name' => 'action',  
  459. 'value' => MS_Controller_Rule::AJAX_ACTION_UPDATE_DRIPPED,  
  460. ); 
  461.  
  462. $field_rule = array( 
  463. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  464. 'name' => 'rule_type',  
  465. 'value' => $this->model->rule_type,  
  466. ); 
  467.  
  468. $field_item = array( 
  469. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  470. 'name' => 'item_id',  
  471. ); 
  472.  
  473. $field_offset = array( 
  474. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  475. 'name' => 'offset',  
  476. ); 
  477.  
  478. $field_number = array( 
  479. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  480. 'name' => 'number',  
  481. ); 
  482.  
  483. $field_filter = array( 
  484. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  485. 'name' => 'membership_id',  
  486. 'value' => isset( $_REQUEST['membership_id'] ) ? $_REQUEST['membership_id'] : '',  
  487. ); 
  488.  
  489. $field_id = array( 
  490. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  491. 'name' => 'membership_ids',  
  492. ); 
  493.  
  494. $field_type = array( 
  495. 'type' => MS_Helper_Html::INPUT_TYPE_SELECT,  
  496. 'name' => 'dripped_type',  
  497. 'class' => 'dripped_type',  
  498. 'field_options' => MS_Model_Rule::get_dripped_types(),  
  499. ); 
  500.  
  501. $field_date = array( 
  502. 'type' => MS_Helper_Html::INPUT_TYPE_DATEPICKER,  
  503. 'name' => 'date',  
  504. 'placeholder' => __( 'Date', 'membership2' ) . '...',  
  505. ); 
  506.  
  507. $field_delay_unit = array( 
  508. 'type' => MS_Helper_Html::INPUT_TYPE_TEXT,  
  509. 'name' => 'delay_unit',  
  510. 'class' => 'ms-text-small',  
  511. 'placeholder' => '0',  
  512. ); 
  513.  
  514. $field_delay_type = array( 
  515. 'type' => MS_Helper_Html::INPUT_TYPE_SELECT,  
  516. 'name' => 'delay_type',  
  517. 'field_options' => MS_Helper_Period::get_period_types( 'plural' ),  
  518. 'after' => __( 'after subscription', 'membership2' ),  
  519. ); 
  520.  
  521. ?> 
  522. <div> 
  523. <h4> 
  524. <span class="lbl-name"></span> - 
  525. <?php _e( 'Dripped Content Settings', 'membership2' ); ?> 
  526. </h4> 
  527. </div> 
  528. <fieldset> 
  529. <div class="inline-edit-col"> 
  530. <?php 
  531. MS_Helper_Html::html_element( $field_action ); 
  532. MS_Helper_Html::html_element( $field_rule ); 
  533. MS_Helper_Html::html_element( $field_item ); 
  534. MS_Helper_Html::html_element( $field_offset ); 
  535. MS_Helper_Html::html_element( $field_number ); 
  536. MS_Helper_Html::html_element( $field_filter ); 
  537. ?> 
  538. <div class="dynamic-form"></div> 
  539. </div> 
  540. </fieldset> 
  541. <div class="dripped-form cf no-auto-init hidden"> 
  542. <div class="drip-col col-1"> 
  543. <span class="the-name ms-membership"></span> 
  544. <?php MS_Helper_Html::html_element( $field_id ); ?> 
  545. </div> 
  546. <div class="drip-col col-2"> 
  547. <?php MS_Helper_Html::html_element( $field_type ); ?> 
  548. </div> 
  549. <div class="drip-col col-3"> 
  550. <div class="drip-option <?php echo esc_attr( MS_Model_Rule::DRIPPED_TYPE_INSTANTLY ); ?>"> 
  551. <?php _e( 'Instantly', 'membership2' ); ?> 
  552. </div> 
  553. <div class="drip-option <?php echo esc_attr( MS_Model_Rule::DRIPPED_TYPE_SPEC_DATE ); ?>"> 
  554. <?php MS_Helper_Html::html_element( $field_date ); ?> 
  555. </div> 
  556. <div class="drip-option <?php echo esc_attr( MS_Model_Rule::DRIPPED_TYPE_FROM_REGISTRATION ); ?>"> 
  557. <?php 
  558. MS_Helper_Html::html_element( $field_delay_unit ); 
  559. MS_Helper_Html::html_element( $field_delay_type ); 
  560. ?> 
  561. </div> 
  562. </div> 
  563. </div> 
  564. </div> 
  565. <?php 
  566.  
  567. /** 
  568. * Displayed above the views. 
  569. * 
  570. * In the rule list-tables the list-head is used to display a filter for 
  571. * membership-ID. Combined with the views (below) users can filter all rules 
  572. * by membership + protection status independantly 
  573. * 
  574. * @since 1.0.0 
  575. */ 
  576. public function list_head() { 
  577. $type_name = $this->name['plural']; 
  578. $membership_name = ''; 
  579. $membership_color = ''; 
  580.  
  581. /** 
  582. * We don't build the title dynamically to make sure translations are 
  583. * possible and meaningful in the context. 
  584. * 
  585. * E.g. "Showing All Pages" in german would typically translate as 
  586. * "All pages are shown"; also "All" has several translations, depending 
  587. * on context. 
  588. */ 
  589. if ( empty( $_GET['membership_id'] ) ) { 
  590. if ( empty( $_GET['status'] ) ) { 
  591. $title = __( 'Showing <b>All</b> %1$s', 'membership2' ); 
  592. } elseif ( MS_Model_Rule::FILTER_NOT_PROTECTED == $_GET['status'] ) { 
  593. $title = __( 'Showing All <b>Unprotected</b> %1$s', 'membership2' ); 
  594. } elseif ( MS_Model_Rule::FILTER_PROTECTED == $_GET['status'] ) { 
  595. $title = __( 'Showing All <b>Protected</b> %1$s', 'membership2' ); 
  596. } else { 
  597. $membership = MS_Factory::load( 'MS_Model_Membership', $_GET['membership_id'] ); 
  598.  
  599. if ( empty( $_GET['status'] ) ) { 
  600. $title = __( 'Showing <b>All</b> %1$s for %2$s', 'membership2' ); 
  601. } elseif ( MS_Model_Rule::FILTER_NOT_PROTECTED == $_GET['status'] ) { 
  602. $title = __( 'Showing All %1$s that are <b>not protected</b> by %2$s', 'membership2' ); 
  603. } elseif ( MS_Model_Rule::FILTER_PROTECTED == $_GET['status'] ) { 
  604. $title = __( 'Showing All %1$s that are <b>protected</b> by %2$s', 'membership2' ); 
  605.  
  606. $membership_name = $membership->name; 
  607. $membership_color = $membership->get_color(); 
  608.  
  609. $title = sprintf( 
  610. $title,  
  611. '<b>' . esc_html( $type_name ) . '</b>',  
  612. sprintf( 
  613. '<span class="ms-membership" style="background-color:%2$s">%1$s</span>',  
  614. esc_html( $membership_name ),  
  615. $membership_color 
  616. ); 
  617.  
  618. printf( '<h3 class="ms-list-title">%1$s</h3>', $title ); 
  619.  
  620. /** 
  621. * Returns an array that defines possible views. 
  622. * 
  623. * In the rule list-tables the views are used to filter by protection status 
  624. * and not by membership-ID or other factors. 
  625. * 
  626. * @since 1.0.0 
  627. * @return array 
  628. */ 
  629. public function get_views() { 
  630. $count_args = $this->prepared_args; 
  631. unset( $count_args['rule_status'] ); 
  632.  
  633. // Count is not working, so we remove it for now 
  634. //$count = $this->model->count_item_access( $count_args ); 
  635.  
  636. $url = apply_filters( 
  637. 'ms_helper_listtable_' . $this->id . '_url',  
  638. esc_url_raw( remove_query_arg( array( 'status', 'paged' ) ) ) 
  639. ); 
  640.  
  641. $views = array(); 
  642.  
  643. $views['all'] = array( 
  644. 'url' => $url,  
  645. 'label' => __( 'All', 'membership2' ),  
  646. //'count' => $count['total'],  
  647. ); 
  648.  
  649. $public_url = esc_url_raw( 
  650. add_query_arg( 
  651. array( 'status' => MS_Model_Rule::FILTER_NOT_PROTECTED ),  
  652. $url 
  653. ); 
  654. $views['public'] = array( 
  655. 'url' => $public_url,  
  656. 'label' => __( 'Unprotected', 'membership2' ),  
  657. //'count' => $count['restricted'],  
  658. ); 
  659.  
  660. $protected_url = esc_url_raw( 
  661. add_query_arg( 
  662. array( 'status' => MS_Model_Rule::FILTER_PROTECTED ),  
  663. $url 
  664. ); 
  665. $views['protected'] = array( 
  666. 'url' => $protected_url,  
  667. 'label' => __( 'Protected', 'membership2' ),  
  668. //'count' => $count['accessible'],  
  669. ); 
  670.  
  671. return apply_filters( 
  672. "ms_helper_listtable_{$this->id}_views",  
  673. $views 
  674. ); 
  675.  
  676. /** 
  677. * Return true if the current list is a view except "all" 
  678. * 
  679. * @since 1.0.0 
  680. * @return bool 
  681. */ 
  682. public function is_view() { 
  683. return ! empty( $_GET['status'] ); 
.