/** * Get the current active settings page/tab. * * @since 1.0.0 */ public function get_active_tab() { if (null === $this->active_tab) { if (!MS_Controller_Plugin::is_page('settings')) { $this->active_tab = ''; } else { $tabs = $this->get_tabs(); reset($tabs); $first_key = key($tabs); // Setup navigation tabs. lib3()->array->equip_get('tab'); $active_tab = sanitize_html_class($_GET['tab'], $first_key); if (!array_key_exists($active_tab, $tabs)) { $new_url = esc_url_raw(add_query_arg(array('tab' => $first_key))); wp_safe_redirect($new_url); exit; } else { $this->active_tab = apply_filters('ms_controller_settings_get_active_tab', $active_tab); } } } return apply_filters('ms_controller_settings_get_active_tab', $this->active_tab, $this); }
/** * Handles all sub-menu clicks. We check if the menu item of our add-on was * clicked and if it was we display the correct page. * * The $handler value is ONLY changed when the current menu is displayed. * If another menu item was clicked then don't do anythign here! * * @since 1.0.0 * @param array $handler { * Menu-item handling information. * * 0 .. any|network|site The admin-area that can handle our menu item. * 1 .. callable A callback to handle the menu item. * @return array Menu-item handling information. */ public function route_submenu_request($handler) { if (MS_Controller_Plugin::is_page(self::SLUG)) { $handler = array('network', array($this, 'admin_coupon')); } return $handler; }