MS_Helper_ListTable_Rule

Membership List Table.

Defined (1)

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

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