/** * Displays a note while simulation mode is enabled. * * @since 1.0.0 */ protected function check_simulation() { if (self::$is_simulating) { ?> <div class="error below-h2"> <p> <strong><?php _e('You are in Simulation mode!', 'membership2'); ?> </strong> </p> <p> <?php _e('Content displayed here might be altered because of simulated restrictions.', 'membership2'); ?> <br /> <?php printf(__('We recommend to %sExit Simulation%s before making any changes!', 'membership2'), '<a href="' . MS_Controller_Adminbar::get_simulation_exit_url() . '">', '</a>'); ?> </p> <p> <em><?php _e('This page is only available to Administrators - you can always see it, even during Simulation.', 'membership2'); ?> </em> </p> </div> <?php } }
/** * Prepare html fields. * * @since 1.0.0 * * @return array */ public function prepare_fields() { // The ID of the main system membership. $base_id = MS_Model_Membership::get_base()->id; $sorted_memberships = array(); $memberships = MS_Model_Membership::get_memberships(array('include_base' => 1)); foreach ($memberships as $membership) { if ($base_id == $membership->id) { $label = __('- No membership / Visitor -', MS_TEXT_DOMAIN); } else { $label = $membership->name; if (!$membership->active) { $label .= ' ' . __('(Inactive)', MS_TEXT_DOMAIN); } } $sorted_memberships[$membership->id] = $label; } asort($sorted_memberships); $fields = array('exit_button' => array('type' => MS_Helper_Html::TYPE_HTML_LINK, 'value' => __('Exit Test Mode', MS_TEXT_DOMAIN), 'url' => MS_Controller_Adminbar::get_simulation_exit_url(), 'class' => 'button'), 'action_field' => array('name' => 'action', 'value' => 'ms_simulate', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN), 'membership_id' => array('id' => 'ab-membership-id', 'name' => 'membership_id', 'value' => $this->data['membership_id'], 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'field_options' => $sorted_memberships), 'nonce_field' => array('id' => '_wpnonce', 'value' => wp_create_nonce('ms_simulate'), 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN), 'simulate_date' => array('id' => 'simulate_date', 'type' => MS_Helper_Html::INPUT_TYPE_DATEPICKER, 'value' => $this->data['simulate_date'], 'class' => 'ms-admin-bar-date ms-date'), 'simulate_submit' => array('id' => 'simulate_submit', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Go', MS_TEXT_DOMAIN), 'class' => 'ms-admin-bar-submit')); return apply_filters('ms_view_admin_bar_prepare_fields', $fields, $this); }