private function _handle_account_edits() { $properties = array('site_secret_key', 'site_id', 'site_public_key'); foreach ($properties as $p) { if (fs_request_is_action('update_' . $p)) { check_admin_referer('update_' . $p); $this->_logger->log('update_' . $p); $site_property = substr($p, strlen('site_')); $site_property_value = fs_request_get('fs_' . $p . '_' . $this->_slug, ''); $this->get_site()->{$site_property} = $site_property_value; // Store account after modification. $this->_store_site(); do_action('fs_account_property_edit_' . $this->_slug, 'site', $site_property, $site_property_value); // Anonymous functions are only available since PHP 5.3 add_action('all_admin_notices', array('Freemius', '_account_details_updated_message')); break; } } }
/** * 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()) { $hook = $this->_menu->override_menu_item(array(&$this, '_connect_page_render')); if (false === $hook) { // Create new menu item just for the opt-in. $hook = add_menu_page($this->get_plugin_name(), $this->get_plugin_name(), 'manage_options', $this->_menu->get_slug(), array(&$this, '_connect_page_render')); } } else { $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; } } } 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. self::_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')); } } } }
/** * 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(); $menu = $this->remove_menu_item(); if (false !== $menu) { // Override menu action. $hook = add_menu_page($menu['menu'][3], $menu['menu'][0], 'manage_options', $this->_menu_slug, array(&$this, '_connect_page_render'), $menu['menu'][6], $menu['position']); } else { // Try to override tools submenu item if exist. $hook = $this->override_plugin_submenu_action('tools.php', $this->_menu_slug, array(&$this, '_connect_page_render')); } if ($this->is_activation_page()) { // Clean admin page from distracting content. $this->_clean_admin_content_section(); } 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')); } } }