/**
  * Add 'Unprotected' node.
  *
  * @since  1.0.0
  *
  */
 private function add_unprotected_node()
 {
     global $wp_admin_bar;
     if (MS_Plugin::is_enabled()) {
         return;
     }
     if (MS_Plugin::is_wizard()) {
         return;
     }
     $link_url = MS_Controller_Plugin::get_admin_url('settings');
     $wp_admin_bar->add_node(apply_filters('ms_controller_adminbar_add_unprotected_node', array('id' => 'ms-unprotected', 'title' => __('Content Protection is disabled', 'membership2'), 'href' => $link_url, 'meta' => array('class' => 'ms-unprotected', 'title' => __('Content of this site is unprotected', 'membership2'), 'tabindex' => '1'))));
 }
 /**
  * Track wizard step.
  *
  * Save current step.
  *
  * since 1.0.0
  *
  * @param string $step Optional. The step to save. Default to current step.
  * @param boolean $end_wizard Optional. Whether end the wizard mode.
  * @return string The current step.
  */
 public function wizard_tracker($step = null, $end_wizard = false)
 {
     $settings = MS_Plugin::instance()->settings;
     if (empty($step)) {
         $step = $this->get_step();
     }
     if (MS_Plugin::is_wizard()) {
         $settings->wizard_step = $step;
         if ($end_wizard) {
             $settings->initial_setup = false;
         }
         $settings->save();
     }
     do_action('ms_controller_membership_wizard_tracker', $step, $end_wizard, $settings, $this);
 }
 /**
  * Handles all menu-items and calls the correct callback function.
  *
  * We introduce this routing function to monitor all menu-item calls so we
  * can make sure that network-wide protection loads the correct blog or
  * admin-area before displaing the page.
  *
  * This function will only handle submenu items of the Membership2 menu!
  *
  * @since  1.0.0
  */
 public function route_submenu_request()
 {
     global $submenu;
     $handler = null;
     $handle_it = false;
     if (!isset($_GET['page'])) {
         return;
     }
     if ($_GET['page'] === self::$base_slug) {
         $handle_it = true;
     } elseif (isset($submenu[self::$base_slug])) {
         foreach ($submenu[self::$base_slug] as $item) {
             if ($_GET['page'] === $item[2]) {
                 $handle_it = true;
                 break;
             }
         }
     }
     if (!$handle_it) {
         return;
     }
     if (MS_Plugin::is_wizard()) {
         $step_add = MS_Controller_Membership::STEP_ADD_NEW == MS_Plugin::instance()->settings->wizard_step;
         if (!$step_add || self::is_page('setup')) {
             $handler = array('any', array($this->controllers['membership'], 'admin_page_router'));
         } else {
             $handler = array('site', array($this->controllers['protection'], 'admin_page'));
         }
     } else {
         if (self::is_page('')) {
             $handler = array('network', array($this->controllers['membership'], 'admin_page_router'));
         } elseif (self::is_page('protection')) {
             $handler = array('site', array($this->controllers['protection'], 'admin_page'));
         } elseif (self::is_page('members')) {
             $handler = array('network', array($this->controllers['member'], 'admin_page'));
         } elseif (self::is_page('add-member')) {
             $handler = array('network', array($this->controllers['member'], 'admin_page_editor'));
         } elseif (self::is_page('addon')) {
             $handler = array('network', array($this->controllers['addon'], 'admin_page'));
         } elseif (self::is_page('settings')) {
             $handler = array('network', array($this->controllers['settings'], 'admin_page'));
         } elseif (self::is_page('help')) {
             $handler = array('any', array($this->controllers['help'], 'admin_page'));
         } elseif (self::is_page('billing')) {
             $handler = array('network', array($this->controllers['billing'], 'admin_page'));
         }
     }
     /**
      * Filter that allows Add-ons to add their own sub-menu handlers.
      *
      * @since  1.0.0
      */
     $handler = apply_filters('ms_route_submenu_request', $handler, $this);
     // Provide a fallback handler in case we could not identify the handler.
     if (!$handler) {
         $handler = array('network', array($this->controllers['membership'], 'membership_admin_page_router'));
     }
     // Handle the target attribute specified in $handler[0]
     if (MS_Plugin::is_network_wide() && 'any' != $handler[0]) {
         $redirect = false;
         $admin_script = 'admin.php?' . $_SERVER['QUERY_STRING'];
         if ('network' == $handler[0] && !is_network_admin()) {
             $redirect = network_admin_url($admin_script);
         } elseif ('site' == $handler[0] && is_network_admin()) {
             $redirect = admin_url($admin_script);
         }
         if ($redirect) {
             if (headers_sent()) {
                 echo '<script>location.href=' . json_encode($redirect) . ';</script>';
             } else {
                 wp_safe_redirect($redirect);
             }
             exit;
         }
     }
     $this->menu_handler = $handler;
 }