public function available_content_panel_data() { $relative = array(); $absolute = array(); $membership = $this->data['membership']; $rule_types = MS_Model_Rule::get_dripped_rule_types(); foreach ($rule_types as $rule_type) { $rule = $membership->get_rule($rule_type); $contents = (array) $rule->get_contents(); foreach ($contents as $content) { if ($rule->has_dripped_rules($content->id)) { $infos = $rule->dripped[$content->id]; $key = false; $content->date = $rule->get_dripped_description($content->id); $content->icon = 'visibility'; switch ($infos['type']) { case MS_Model_Rule::DRIPPED_TYPE_FROM_REGISTRATION: $content->icon = 'clock'; $key = MS_Helper_Period::get_period_in_days($infos['delay_unit'], $infos['delay_type']); $key = 100000 + $key * 1000; while (isset($relative[$key])) { $key += 1; } $relative[$key] = $content; break; case MS_Model_Rule::DRIPPED_TYPE_SPEC_DATE: $key = preg_replace('/[^0-9]/', '', $infos['date']); if (!$rule->has_access($content->id)) { $content->icon = 'lock'; } // Fall through // Fall through case MS_Model_Rule::DRIPPED_TYPE_INSTANTLY: default: if (empty($key)) { $key = 0; } $key = $key * 1000; while (isset($relative[$key])) { $key += 1; } $absolute[$key] = $content; break; } } } } ?> <div class="clear"></div> <div class="cf"> <div class="ms-half ms-available-soon space"> <div class="ms-bold"> <i class="dashicons dashicons-calendar ms-low"></i> <?php _e('Available on a specific date:', MS_TEXT_DOMAIN); ?> </div> <div class="inside"> <?php $this->content_box($absolute); ?> </div> </div> <div class="ms-half ms-available"> <div class="ms-bold"> <i class="dashicons dashicons-clock ms-low"></i> <?php _e('Relative to registration:', MS_TEXT_DOMAIN); ?> </div> <div class="inside"> <?php $this->content_box($relative); ?> </div> </div> </div> <div class="cf"> <div class="ms-half"> <div class="inside"> <div class="ms-protection-edit-wrapper"> <?php $edit_url = MS_Controller_Plugin::get_admin_url('protection', array('tab' => $rule->rule_type, 'membership_id' => $membership->id)); MS_Helper_Html::html_element(array('id' => 'edit_dripped', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'value' => __('Edit Dripped Content', MS_TEXT_DOMAIN), 'url' => $edit_url, 'class' => 'wpmui-field-button button')); if (!$membership->is_free) { $payment_url = esc_url_raw(add_query_arg(array('step' => MS_Controller_Membership::STEP_PAYMENT, 'edit' => 1))); MS_Helper_Html::html_element(array('id' => 'setup_payment', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'value' => __('Payment Options', MS_TEXT_DOMAIN), 'url' => $payment_url, 'class' => 'wpmui-field-button button')); } ?> </div> </div> </div> </div> <?php }
/** * Prepare the list and choose which items to display. * * This is the core logic of the listtable parent class! * * @since 1.0.0 */ public function prepare_items() { $args = null; $this->_column_headers = array($this->get_columns(), $this->get_hidden_columns(), $this->get_sortable_columns()); // Some columns have a pre-defined title that cannot be changed. if (isset($this->_column_headers[0]['cb'])) { $this->_column_headers[0]['cb'] = '<input type="checkbox" />'; } $is_dripped = in_array($this->model->rule_type, MS_Model_Rule::get_dripped_rule_types()); if ($is_dripped) { $this->_column_headers[0]['dripped'] = __('Reveal Content', 'membership2'); } else { unset($this->_column_headers[0]['dripped']); } if (isset($this->_column_headers[0]['access'])) { $this->_column_headers[0]['access'] = __('Who Has Access', 'membership2'); } // Initialize current pagination Page $per_page = $this->get_items_per_page("{$this->id}_per_page", self::DEFAULT_PAGE_SIZE); /** * Custom filter to modify the items on all Protection Rule list tables. * * @since 1.0.1.0 * @var int */ $per_page = apply_filters('rule_items_per_page', $per_page, $this->id); $current_page = $this->get_pagenum(); $args = array('posts_per_page' => $per_page, 'number' => $per_page, 'offset' => ($current_page - 1) * $per_page); // Add a status filter if (!empty($_GET['status'])) { $args['rule_status'] = $_GET['status']; } // Search string. if (!empty($_REQUEST['s'])) { $this->search_string = $_REQUEST['s']; $args['s'] = $_REQUEST['s']; $args['posts_per_page'] = -1; $args['number'] = false; $args['offset'] = 0; } // Month filter. if (!empty($_REQUEST['m']) && 6 == strlen($_REQUEST['m'])) { $args['year'] = substr($_REQUEST['m'], 0, 4); $args['monthnum'] = substr($_REQUEST['m'], 5, 2); } // If a membership is filtered then only show protected items if (!empty($_REQUEST['membership_id'])) { $args['membership_id'] = $_REQUEST['membership_id']; } // Allow other helper list tables to customize the args array. $args = $this->prepare_items_args($args); // Count items $total_items = $this->model->get_content_count($args); // List available items $this->items = apply_filters("ms_rule_{$this->id}_items", $this->model->get_contents($args)); // Save the args for use in later functions $this->prepared_args = $args; // Prepare the table pagination $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page)); }