/includes/admin/referrals/referrals.php

https://github.com/seb86/AffiliateWP · PHP · 653 lines · 321 code · 124 blank · 208 comment · 46 complexity · fb98d6d4f4de0bd29e9ac8bc21920ad6 MD5 · raw file

  1. <?php
  2. /**
  3. * Referrals Admin
  4. *
  5. * @package AffiliateWP
  6. * @subpackage Admin/Referrals
  7. * @copyright Copyright (c) 2014, Pippin Williamson
  8. * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
  9. * @since 1.0
  10. */
  11. // Exit if accessed directly
  12. if ( ! defined( 'ABSPATH' ) ) exit;
  13. include AFFILIATEWP_PLUGIN_DIR . 'includes/admin/referrals/contextual-help.php';
  14. function affwp_referrals_admin() {
  15. if( isset( $_GET['action'] ) && 'add_referral' == $_GET['action'] ) {
  16. include AFFILIATEWP_PLUGIN_DIR . 'includes/admin/referrals/new.php';
  17. } else if( isset( $_GET['action'] ) && 'edit_referral' == $_GET['action'] ) {
  18. include AFFILIATEWP_PLUGIN_DIR . 'includes/admin/referrals/edit.php';
  19. } else {
  20. $referrals_table = new AffWP_Referrals_Table();
  21. $referrals_table->prepare_items();
  22. ?>
  23. <div class="wrap">
  24. <h2><?php _e( 'Referrals', 'affiliate-wp' ); ?></h2>
  25. <?php do_action( 'affwp_referrals_page_top' ); ?>
  26. <div id="affwp-referrals-export-wrap">
  27. <a href="<?php echo add_query_arg( 'action', 'add_referral' ); ?>" class="button-secondary"><?php _e( 'Add New Referral', 'affiliate-wp' ); ?></a>
  28. <button class="button-primary affwp-referrals-export-toggle"><?php _e( 'Generate Payout File', 'affiliate-wp' ); ?></button>
  29. <button class="button-primary affwp-referrals-export-toggle" style="display:none"><?php _e( 'Close', 'affiliate-wp' ); ?></button>
  30. <?php do_action( 'affwp_referrals_page_buttons' ); ?>
  31. <form id="affwp-referrals-export-form" style="display:none;" action="<?php echo admin_url( 'admin.php?page=affiliate-wp-referrals' ); ?>" method="post">
  32. <p>
  33. <input type="text" class="affwp-datepicker" autocomplete="off" name="from" placeholder="<?php _e( 'From - mm/dd/yyyy', 'affiliate-wp' ); ?>"/>
  34. <input type="text" class="affwp-datepicker" autocomplete="off" name="to" placeholder="<?php _e( 'To - mm/dd/yyyy', 'affiliate-wp' ); ?>"/>
  35. <input type="text" class="affwp-text" name="minimum" placeholder="<?php esc_attr_e( 'Minimum amount', 'affiliate-wp' ); ?>"/>
  36. <input type="hidden" name="affwp_action" value="generate_referral_payout"/>
  37. <?php do_action( 'affwp_referrals_page_csv_export_form' ); ?>
  38. <input type="submit" value="<?php _e( 'Generate CSV File', 'affiliate-wp' ); ?>" class="button-secondary"/>
  39. <p><?php printf( __( 'This will mark all unpaid referrals in this timeframe as paid. To export referrals with a status other than <em>unpaid</em>, go to the <a href="%s">Tools &rarr; Export</a> page.', 'affiliate-wp' ), admin_url( 'admin.php?page=affiliate-wp-tools&tab=export_import' ) ); ?></p>
  40. </p>
  41. </form>
  42. </div>
  43. <form id="affwp-referrals-filter-form" method="get" action="<?php echo admin_url( 'admin.php?page=affiliate-wp-referrals' ); ?>">
  44. <?php $referrals_table->search_box( __( 'Search', 'affiliate-wp' ), 'affwp-referrals' ); ?>
  45. <input type="hidden" name="page" value="affiliate-wp-referrals" />
  46. <?php $referrals_table->views() ?>
  47. <?php $referrals_table->display() ?>
  48. </form>
  49. <?php do_action( 'affwp_referrals_page_bottom' ); ?>
  50. </div>
  51. <?php
  52. }
  53. }
  54. // Load WP_List_Table if not loaded
  55. if ( ! class_exists( 'WP_List_Table' ) ) {
  56. require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
  57. }
  58. /**
  59. * AffWP_Referrals_Table Class
  60. *
  61. * Renders the Affiliates table on the Affiliates page
  62. *
  63. * @since 1.0
  64. */
  65. class AffWP_Referrals_Table extends WP_List_Table {
  66. /**
  67. * Number of results to show per page
  68. *
  69. * @var int
  70. * @since 1.0
  71. */
  72. public $per_page = 30;
  73. /**
  74. *
  75. * Total number of referrals
  76. * @var int
  77. * @since 1.0
  78. */
  79. public $total_count;
  80. /**
  81. * Number of paid referrals
  82. *
  83. * @var int
  84. * @since 1.0
  85. */
  86. public $paid_count;
  87. /**
  88. * Number of unpaid referrals
  89. *
  90. * @var int
  91. * @since 1.0
  92. */
  93. public $unpaid_count;
  94. /**
  95. * Number of pending referrals
  96. *
  97. * @var int
  98. * @since 1.0
  99. */
  100. public $pending_count;
  101. /**
  102. * Number of rejected referrals
  103. *
  104. * @var int
  105. * @since 1.0
  106. */
  107. public $rejected_count;
  108. /**
  109. * Get things started
  110. *
  111. * @since 1.0
  112. * @uses AffWP_Referrals_Table::get_affiliate_counts()
  113. * @see WP_List_Table::__construct()
  114. */
  115. public function __construct() {
  116. global $status, $page;
  117. parent::__construct( array(
  118. 'ajax' => false
  119. ) );
  120. $this->get_referral_counts();
  121. }
  122. /**
  123. * Show the search field
  124. *
  125. * @access public
  126. * @since 1.0
  127. *
  128. * @param string $text Label for the search box
  129. * @param string $input_id ID of the search box
  130. *
  131. * @return svoid
  132. */
  133. public function search_box( $text, $input_id ) {
  134. if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
  135. return;
  136. $input_id = $input_id . '-search-input';
  137. if ( ! empty( $_REQUEST['orderby'] ) )
  138. echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
  139. if ( ! empty( $_REQUEST['order'] ) )
  140. echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
  141. ?>
  142. <p class="search-box">
  143. <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
  144. <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
  145. <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?>
  146. </p>
  147. <?php
  148. }
  149. /**
  150. * Retrieve the view types
  151. *
  152. * @access public
  153. * @since 1.0
  154. * @return array $views All the views available
  155. */
  156. public function get_views() {
  157. $base = admin_url( 'admin.php?page=affiliate-wp-referrals' );
  158. $current = isset( $_GET['status'] ) ? $_GET['status'] : '';
  159. $total_count = '&nbsp;<span class="count">(' . $this->total_count . ')</span>';
  160. $paid_count = '&nbsp;<span class="count">(' . $this->paid_count . ')</span>';
  161. $unpaid_count = '&nbsp;<span class="count">(' . $this->unpaid_count . ')</span>';
  162. $pending_count = '&nbsp;<span class="count">(' . $this->pending_count . ')</span>';
  163. $rejected_count = '&nbsp;<span class="count">(' . $this->rejected_count . ')</span>';
  164. $views = array(
  165. 'all' => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( 'status', $base ), $current === 'all' || $current == '' ? ' class="current"' : '', __( 'All', 'affiliate-wp' ) . $total_count ),
  166. 'paid' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( 'status', 'paid', $base ), $current === 'paid' ? ' class="current"' : '', __( 'Paid', 'affiliate-wp' ) . $paid_count ),
  167. 'unpaid' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( 'status', 'unpaid', $base ), $current === 'unpaid' ? ' class="current"' : '', __( 'Unpaid', 'affiliate-wp' ) . $unpaid_count ),
  168. 'pending' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( 'status', 'pending', $base ), $current === 'pending' ? ' class="current"' : '', __( 'Pending', 'affiliate-wp' ) . $pending_count ),
  169. 'rejected' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( 'status', 'rejected', $base ), $current === 'rejected' ? ' class="current"' : '', __( 'Rejected', 'affiliate-wp' ) . $rejected_count ),
  170. );
  171. return $views;
  172. }
  173. /**
  174. * Retrieve the table columns
  175. *
  176. * @access public
  177. * @since 1.0
  178. * @return array $columns Array of all the list table columns
  179. */
  180. public function get_columns() {
  181. $columns = array(
  182. 'cb' => '<input type="checkbox" />',
  183. 'amount' => __( 'Amount', 'affiliate-wp' ),
  184. 'affiliate' => __( 'Affiliate', 'affiliate-wp' ),
  185. 'reference' => __( 'Reference', 'affiliate-wp' ),
  186. 'description' => __( 'Description', 'affiliate-wp' ),
  187. 'date' => __( 'Date', 'affiliate-wp' ),
  188. 'actions' => __( 'Actions', 'affiliate-wp' ),
  189. 'status' => __( 'Status', 'affiliate-wp' ),
  190. );
  191. return $columns;
  192. }
  193. /**
  194. * Retrieve the table's sortable columns
  195. *
  196. * @access public
  197. * @since 1.0
  198. * @return array Array of all the sortable columns
  199. */
  200. public function get_sortable_columns() {
  201. return array(
  202. 'name' => array( 'name', false )
  203. );
  204. }
  205. /**
  206. * This function renders most of the columns in the list table.
  207. *
  208. * @access public
  209. * @since 1.0
  210. *
  211. * @param array $item Contains all the data of the affiliate
  212. * @param string $column_name The name of the column
  213. *
  214. * @return string Column Name
  215. */
  216. public function column_default( $referral, $column_name ) {
  217. switch( $column_name ){
  218. case 'date' :
  219. $value = date_i18n( get_option( 'date_format' ), strtotime( $referral->date ) );
  220. break;
  221. default:
  222. $value = isset( $referral->$column_name ) ? $referral->$column_name : '';
  223. break;
  224. }
  225. return $value;
  226. }
  227. /**
  228. * Render the checkbox column
  229. *
  230. * @access public
  231. * @since 1.0
  232. * @param array $referral Contains all the data for the checkbox column
  233. * @return string Displays a checkbox
  234. */
  235. public function column_cb( $referral ) {
  236. return '<input type="checkbox" name="referral_id[]" value="' . absint( $referral->referral_id ) . '" />';
  237. }
  238. /**
  239. * Render the amount column
  240. *
  241. * @access public
  242. * @since 1.0
  243. * @param array $referral Contains all the data for the checkbox column
  244. * @return string Displays the referral amount
  245. */
  246. public function column_amount( $referral ) {
  247. return affwp_currency_filter( affwp_format_amount( $referral->amount ) );
  248. }
  249. /**
  250. * Render the status column
  251. *
  252. * @access public
  253. * @since 1.0
  254. * @param array $referral Contains all the data for the checkbox column
  255. * @return string Displays the referral status
  256. */
  257. public function column_status( $referral ) {
  258. return '<span class="affwp-status ' . $referral->status . '"><i></i>' . $referral->status . '</span>';
  259. }
  260. /**
  261. * Render the affiliate column
  262. *
  263. * @access public
  264. * @since 1.0
  265. * @param array $referral Contains all the data for the checkbox column
  266. * @return string The affiliate
  267. */
  268. public function column_affiliate( $referral ) {
  269. return '<a href="' . admin_url( 'admin.php?page=affiliate-wp-referrals&affiliate_id=' . $referral->affiliate_id ) . '">' . affiliate_wp()->affiliates->get_affiliate_name( $referral->affiliate_id ) . '</a>';
  270. }
  271. /**
  272. * Render the reference column
  273. *
  274. * @access public
  275. * @since 1.0
  276. * @param array $referral Contains all the data for the checkbox column
  277. * @return string The reference
  278. */
  279. public function column_reference( $referral ) {
  280. return apply_filters( 'affwp_referral_reference_column', $referral->reference, $referral );
  281. }
  282. /**
  283. * Render the actions column
  284. *
  285. * @access public
  286. * @since 1.0
  287. * @param array $referral Contains all the data for the actions column
  288. * @return string The actions HTML
  289. */
  290. public function column_actions( $referral ) {
  291. $action_links = array();
  292. if( 'paid' == $referral->status ) {
  293. $action_links[] = '<a href="' . esc_url( add_query_arg( array( 'action' => 'mark_as_unpaid', 'referral_id' => $referral->referral_id ) ) ) . '" class="mark-as-paid">' . __( 'Mark as Unpaid', 'affiliate-wp' ) . '</a>';
  294. } else {
  295. if( 'unpaid' == $referral->status ) {
  296. $action_links[] = '<a href="' . esc_url( add_query_arg( array( 'action' => 'mark_as_paid', 'referral_id' => $referral->referral_id ) ) ) . '" class="mark-as-paid">' . __( 'Mark as Paid', 'affiliate-wp' ) . '</a>';
  297. }
  298. if( 'rejected' == $referral->status || 'pending' == $referral->status ) {
  299. $action_links[] = '<a href="' . esc_url( add_query_arg( array( 'action' => 'accept', 'referral_id' => $referral->referral_id ) ) ) . '" class="reject">' . __( 'Accept', 'affiliate-wp' ) . '</a>';
  300. }
  301. if( 'rejected' != $referral->status ) {
  302. $action_links[] = '<a href="' . esc_url( add_query_arg( array( 'action' => 'reject', 'referral_id' => $referral->referral_id ) ) ) . '" class="reject">' . __( 'Reject', 'affiliate-wp' ) . '</a>';
  303. }
  304. }
  305. $action_links[] = '<span class="trash"><a href="' . esc_url( add_query_arg( array( 'action' => 'edit_referral', 'referral_id' => $referral->referral_id ) ) ) . '" class="edit">' . __( 'Edit', 'affiliate-wp' ) . '</a></span>';
  306. $action_links[] = '<span class="trash"><a href="' . esc_url( add_query_arg( array( 'action' => 'delete', 'referral_id' => $referral->referral_id ) ) ) . '" class="delete">' . __( 'Delete', 'affiliate-wp' ) . '</a></span>';
  307. $action_links = array_unique( apply_filters( 'affwp_referral_action_links', $action_links, $referral ) );
  308. return '<div class="action-links">' . implode( ' | ', $action_links ) . '</div>';
  309. }
  310. /**
  311. * Message to be displayed when there are no items
  312. *
  313. * @since 1.7.2
  314. * @access public
  315. */
  316. public function no_items() {
  317. _e( 'No referrals found.', 'affiliate-wp' );
  318. }
  319. /**
  320. * Outputs the reporting views
  321. *
  322. * @access public
  323. * @since 1.0
  324. * @return void
  325. */
  326. public function bulk_actions( $which = '' ) {
  327. if ( is_null( $this->_actions ) ) {
  328. $no_new_actions = $this->_actions = $this->get_bulk_actions();
  329. $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
  330. $two = '';
  331. } else {
  332. $two = '2';
  333. }
  334. if ( empty( $this->_actions ) )
  335. return;
  336. echo "<select name='action$two'>\n";
  337. echo "<option value='-1' selected='selected'>" . __( 'Bulk Actions', 'affiliate-wp' ) . "</option>\n";
  338. foreach ( $this->_actions as $name => $title ) {
  339. $class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
  340. echo "\t<option value='$name'$class>$title</option>\n";
  341. }
  342. echo "</select>\n";
  343. do_action( 'affwp_referral_bulk_actions' );
  344. submit_button( __( 'Apply', 'affiliate-wp' ), 'action', false, false, array( 'id' => "doaction$two" ) );
  345. echo "\n";
  346. // Makes the filters only get output at the top of the page
  347. if( ! did_action( 'affwp_referral_filters' ) ) {
  348. $from = ! empty( $_REQUEST['filter_from'] ) ? $_REQUEST['filter_from'] : '';
  349. $to = ! empty( $_REQUEST['filter_to'] ) ? $_REQUEST['filter_to'] : '';
  350. echo "<input type='text' class='affwp-datepicker' autocomplete='off' name='filter_from' placeholder='" . __( 'From - mm/dd/yyyy', 'affiliate-wp' ) . "' value='" . $from . "'/>";
  351. echo "<input type='text' class='affwp-datepicker' autocomplete='off' name='filter_to' placeholder='" . __( 'To - mm/dd/yyyy', 'affiliate-wp' ) . "' value='" . $to . "'/>&nbsp;";
  352. do_action( 'affwp_referral_filters' );
  353. submit_button( __( 'Filter', 'affiliate-wp' ), 'action', false, false );
  354. echo "\n";
  355. }
  356. }
  357. /**
  358. * Retrieve the bulk actions
  359. *
  360. * @access public
  361. * @since 1.0
  362. * @return array $actions Array of the bulk actions
  363. */
  364. public function get_bulk_actions() {
  365. $actions = array(
  366. 'accept' => __( 'Accept', 'affiliate-wp' ),
  367. 'reject' => __( 'Reject', 'affiliate-wp' ),
  368. 'mark_as_paid' => __( 'Mark as Paid', 'affiliate-wp' ),
  369. 'mark_as_unpaid' => __( 'Mark as Unpaid', 'affiliate-wp' ),
  370. 'delete' => __( 'Delete', 'affiliate-wp' ),
  371. );
  372. return apply_filters( 'affwp_referrals_bulk_actions', $actions );
  373. }
  374. /**
  375. * Process the bulk actions
  376. *
  377. * @access public
  378. * @since 1.0
  379. * @return void
  380. */
  381. public function process_bulk_action() {
  382. $ids = isset( $_GET['referral_id'] ) ? $_GET['referral_id'] : array();
  383. if ( ! is_array( $ids ) ) {
  384. $ids = array( $ids );
  385. }
  386. $ids = array_map( 'absint', $ids );
  387. $action = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : false;
  388. if( empty( $ids ) || empty( $action ) ) {
  389. return;
  390. }
  391. foreach ( $ids as $id ) {
  392. if ( 'delete' === $this->current_action() ) {
  393. affwp_delete_referral( $id );
  394. }
  395. if ( 'reject' === $this->current_action() ) {
  396. affwp_set_referral_status( $id, 'rejected' );
  397. }
  398. if ( 'accept' === $this->current_action() ) {
  399. affwp_set_referral_status( $id, 'unpaid' );
  400. }
  401. if ( 'mark_as_paid' === $this->current_action() ) {
  402. affwp_set_referral_status( $id, 'paid' );
  403. }
  404. if ( 'mark_as_unpaid' === $this->current_action() ) {
  405. affwp_set_referral_status( $id, 'unpaid' );
  406. }
  407. do_action( 'affwp_referrals_do_bulk_action_' . $this->current_action(), $id );
  408. }
  409. }
  410. /**
  411. * Retrieve the discount code counts
  412. *
  413. * @access public
  414. * @since 1.0
  415. * @return void
  416. */
  417. public function get_referral_counts() {
  418. $affiliate_id = isset( $_GET['affiliate_id'] ) ? $_GET['affiliate_id'] : '';
  419. if( is_array( $affiliate_id ) ) {
  420. $affiliate_id = array_map( 'absint', $affiliate_id );
  421. } else {
  422. $affiliate_id = absint( $affiliate_id );
  423. }
  424. $this->paid_count = affiliate_wp()->referrals->count( array( 'affiliate_id' => $affiliate_id, 'status' => 'paid' ) );
  425. $this->unpaid_count = affiliate_wp()->referrals->count( array( 'affiliate_id' => $affiliate_id, 'status' => 'unpaid' ) );
  426. $this->pending_count = affiliate_wp()->referrals->count( array( 'affiliate_id' => $affiliate_id, 'status' => 'pending' ) );
  427. $this->rejected_count = affiliate_wp()->referrals->count( array( 'affiliate_id' => $affiliate_id, 'status' => 'rejected' ) );
  428. $this->total_count = $this->paid_count + $this->unpaid_count + $this->pending_count + $this->rejected_count;
  429. }
  430. /**
  431. * Retrieve all the data for all the Affiliates
  432. *
  433. * @access public
  434. * @since 1.0
  435. * @return array $referrals_data Array of all the data for the Affiliates
  436. */
  437. public function referrals_data() {
  438. $page = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
  439. $status = isset( $_GET['status'] ) ? $_GET['status'] : '';
  440. $affiliate = isset( $_GET['affiliate_id'] ) ? $_GET['affiliate_id'] : '';
  441. $reference = isset( $_GET['reference'] ) ? $_GET['reference'] : '';
  442. $context = isset( $_GET['context'] ) ? $_GET['context'] : '';
  443. $from = isset( $_GET['filter_from'] ) ? $_GET['filter_from'] : '';
  444. $to = isset( $_GET['filter_to'] ) ? $_GET['filter_to'] : '';
  445. $referral = '';
  446. $is_search = false;
  447. $date = array();
  448. if( ! empty( $from ) ) {
  449. $date['start'] = $from;
  450. }
  451. if( ! empty( $to ) ) {
  452. $date['end'] = $to . ' 23:59:59';;
  453. }
  454. if( ! empty( $_GET['s'] ) ) {
  455. $is_search = true;
  456. $search = sanitize_text_field( $_GET['s'] );
  457. if( is_numeric( $search ) ) {
  458. // This is an referral ID search
  459. $referral = absint( $search );
  460. } elseif ( strpos( $search, 'ref:' ) !== false ) {
  461. $reference = trim( str_replace( 'ref:', '', $search ) );
  462. } elseif ( strpos( $search, 'context:' ) !== false ) {
  463. $context = trim( str_replace( 'context:', '', $search ) );
  464. } elseif ( strpos( $search, 'affiliate:' ) !== false ) {
  465. $affiliate = absint( trim( str_replace( 'affiliate:', '', $search ) ) );
  466. }
  467. }
  468. $referrals = affiliate_wp()->referrals->get_referrals( array(
  469. 'number' => $this->per_page,
  470. 'offset' => $this->per_page * ( $page - 1 ),
  471. 'status' => $status,
  472. 'referral_id' => $referral,
  473. 'affiliate_id' => $affiliate,
  474. 'reference' => $reference,
  475. 'context' => $context,
  476. 'date' => $date,
  477. 'search' => $is_search
  478. ) );
  479. return $referrals;
  480. }
  481. /**
  482. * Setup the final data for the table
  483. *
  484. * @access public
  485. * @since 1.0
  486. * @uses AffWP_Referrals_Table::get_columns()
  487. * @uses AffWP_Referrals_Table::get_sortable_columns()
  488. * @uses AffWP_Referrals_Table::process_bulk_action()
  489. * @uses AffWP_Referrals_Table::referrals_data()
  490. * @uses WP_List_Table::get_pagenum()
  491. * @uses WP_List_Table::set_pagination_args()
  492. * @return void
  493. */
  494. public function prepare_items() {
  495. $per_page = $this->per_page;
  496. $columns = $this->get_columns();
  497. $hidden = array();
  498. $sortable = $this->get_sortable_columns();
  499. $this->_column_headers = array( $columns, $hidden, $sortable );
  500. $this->process_bulk_action();
  501. $data = $this->referrals_data();
  502. $current_page = $this->get_pagenum();
  503. $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any';
  504. switch( $status ) {
  505. case 'paid':
  506. $total_items = $this->paid_count;
  507. break;
  508. case 'pending':
  509. $total_items = $this->pending_count;
  510. break;
  511. case 'unpaid':
  512. $total_items = $this->unpaid_count;
  513. break;
  514. case 'rejected':
  515. $total_items = $this->rejected_count;
  516. break;
  517. case 'any':
  518. $total_items = $this->total_count;
  519. break;
  520. }
  521. $this->items = $data;
  522. $this->set_pagination_args( array(
  523. 'total_items' => $total_items,
  524. 'per_page' => $per_page,
  525. 'total_pages' => ceil( $total_items / $per_page )
  526. )
  527. );
  528. }
  529. }