/**
  * @author Vova Feldman (@svovaf)
  * @since  1.0.9
  */
 function _prepare_admin_menu()
 {
     if (!$this->is_on()) {
         return;
     }
     if (!$this->has_api_connectivity() && !$this->enable_anonymous()) {
         $this->_menu->remove_menu_item();
     } else {
         $this->add_submenu_items();
         $this->add_menu_action();
     }
 }
Ejemplo n.º 2
0
 /**
  * @author Vova Feldman (@svovaf)
  * @since  1.0.9
  */
 function _prepare_admin_menu()
 {
     //			if ( ! $this->is_on() ) {
     //				return;
     //			}
     if (!$this->has_api_connectivity() && !$this->is_enable_anonymous()) {
         $this->_menu->remove_menu_item();
     } else {
         $this->do_action('before_admin_menu_init');
         $this->add_menu_action();
         $this->add_submenu_items();
     }
 }
Ejemplo n.º 3
0
 /**
  * Remove plugin's all admin menu items & pages, and replace with activation page.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.1
  */
 private function override_plugin_menu_with_activation()
 {
     $this->_logger->entrance();
     $hook = false;
     if ($this->_menu->is_top_level()) {
         $menu = $this->_menu->remove_menu_item();
         if (false !== $menu) {
             // Override menu action.
             $hook = add_menu_page($menu['menu'][3], $menu['menu'][0], 'manage_options', $this->_menu->get_slug(), array(&$this, '_connect_page_render'), $menu['menu'][6], $menu['position']);
         }
     } else {
         if ($this->_menu->has_custom_parent()) {
             $menus = array($this->_menu->get_parent_slug());
             if ($this->_menu->is_override_exact()) {
                 // Make sure the current page is matching the activation page.
                 $activation_url = strtolower($this->get_activation_url());
                 $request_url = strtolower($_SERVER['REQUEST_URI']);
                 if (parse_url($activation_url, PHP_URL_PATH) !== parse_url($request_url, PHP_URL_PATH)) {
                     // Different path - DO NOT OVERRIDE PAGE.
                     return;
                 }
                 $activation_url_params = array();
                 parse_str(parse_url($activation_url, PHP_URL_QUERY), $activation_url_params);
                 $request_url_params = array();
                 parse_str(parse_url($request_url, PHP_URL_QUERY), $request_url_params);
                 foreach ($activation_url_params as $key => $val) {
                     if (!isset($request_url_params[$key]) || $val != $request_url_params[$key]) {
                         // Not matching query string - DO NOT OVERRIDE PAGE.
                         return;
                     }
                 }
             }
         } else {
             $menus = array('tools.php', 'options-general.php');
         }
         foreach ($menus as $parent_slug) {
             $hook = $this->_menu->override_submenu_action($parent_slug, $this->_menu->get_raw_slug(), array(&$this, '_connect_page_render'));
             if (false !== $hook) {
                 // Found plugin's submenu item.
                 break;
             }
         }
     }
     if ($this->_menu->is_activation_page()) {
         // Clean admin page from distracting content.
         $this->_clean_admin_content_section();
     }
     if (false !== $hook) {
         if (fs_request_is_action($this->_slug . '_activate_existing')) {
             add_action("load-{$hook}", array(&$this, '_install_with_current_user'));
         } else {
             if (fs_request_is_action($this->_slug . '_activate_new')) {
                 add_action("load-{$hook}", array(&$this, '_install_with_new_user'));
             }
         }
     }
 }