cript( 'ws-ame-add-on-management', plugins_url('extras/add-on-management.js', __FILE__), array('jquery') ); wp_localize_script( 'ws-ame-add-on-management', 'wsAmeAddOnData', array( 'ajaxUrl' => self_admin_url('admin-ajax.php'), ) ); } public function ajax_activate_addon() { if ( !isset($_POST['slug']) || !is_string($_POST['slug']) ) { exit('Error: No add-on slug specified'); } $slug = $_POST['slug']; check_ajax_referer('ws_ame_activate_add_on-' . $slug); $addOns = $this->get_addons(); if ( !isset($addOns[$slug]) ) { exit('Error: Add-on not found'); } if ( !current_user_can('activate_plugins') ) { exit('You cannot activate plugins'); } $result = activate_plugin($addOns[$slug]['fileName']); if ( is_wp_error($result) ) { exit($result->get_error_code() . ': ' . $result->get_error_message()); } exit('OK'); } public function ajax_install_addon() { } /** * Prevent non-privileged users from accessing the special "All Settings" page even if * they've been granted access to other pages that require the "manage_options" capability. */ public function disable_virtual_caps_on_all_options() { //options.php also handles the saving of settings created with the Settings API, so we //need to check if this is a direct request for options.php and not just a form submission. $action = ameUtils::get($_POST, 'action', ameUtils::get($_GET, 'action', '')); $option_page = ameUtils::get($_POST, 'option_page', ameUtils::get($_GET, 'option_page', 'options')); if ( ($action !== 'update') && (($option_page === 'options') || empty($option_page)) ) { $this->wp_menu_editor->disable_virtual_caps = true; add_action('admin_enqueue_scripts', array($this, 'enable_virtual_caps')); } } public function enable_virtual_caps() { $this->wp_menu_editor->disable_virtual_caps = false; } public function filter_available_modules($modules) { $modules['plugin-visibility'] = array_merge( $modules['plugin-visibility'], array( 'path' => AME_ROOT_DIR . '/extras/modules/plugin-visibility/plugin-visibility.php', 'className' => 'amePluginVisibilityPro', 'title' => 'Plugins', ) ); $modules['role-editor'] = array( 'path' => AME_ROOT_DIR . '/extras/modules/role-editor/load.php', 'className' => 'ameRoleEditor', 'requiredPhpVersion' => '5.3.6', 'title' => 'Role Editor', ); $modules['tweaks'] = array( 'path' => AME_ROOT_DIR . '/extras/modules/tweaks/tweaks.php', 'className' => 'ameTweakManager', 'title' => 'Tweaks', 'requiredPhpVersion' => '5.4', ); $modules['separator-styles'] = array( 'path' => AME_ROOT_DIR . '/extras/modules/separator-styles/ameMenuSeparatorStyler.php', 'className' => 'ameMenuSeparatorStyler', 'title' => 'Custom menu separator styles', 'requiredPhpVersion' => '5.6', ); return $modules; } } if ( isset($wp_menu_editor) && !defined('WP_UNINSTALL_PLUGIN') ) { //Initialize extras global $wsMenuEditorExtras; $wsMenuEditorExtras = new wsMenuEditorExtras($wp_menu_editor); } if ( !defined('IS_DEMO_MODE') && !defined('IS_MASTER_MODE') ) { //Load the custom update checker (requires PHP 5) if ( (version_compare(PHP_VERSION, '5.0.0', '>=')) && isset($wp_menu_editor) ){ require dirname(__FILE__) . '/plugin-updates/plugin-update-checker.php'; $ameProUpdateChecker = Puc_v4_Factory::buildUpdateChecker( 'https://adminmenueditor.com/?get_metadata_for=admin-menu-editor-pro', $wp_menu_editor->plugin_file, //Note: This variable is set in the framework constructor 'admin-menu-editor-pro', 12, //check every 12 hours 'ame_pro_external_updates', //store book-keeping info in this WP option 'admin-menu-editor-mu.php' ); //Hack. See PluginUpdateChecker::installHooks(). function wsDisableAmeCron(){ wp_clear_scheduled_hook('check_plugin_updates-admin-menu-editor-pro'); } register_deactivation_hook($wp_menu_editor->plugin_file, 'wsDisableAmeCron'); } //Load the license manager. require dirname(__FILE__) . '/license-manager/LicenseManager.php'; global $ameProLicenseManager; $ameProLicenseManager = new Wslm_LicenseManagerClient(array( 'api_url' => 'https://adminmenueditor.com/licensing_api/', 'product_slug' => 'admin-menu-editor-pro', 'license_scope' => Wslm_LicenseManagerClient::LICENSE_SCOPE_NETWORK, 'update_checker' => isset($ameProUpdateChecker) ? $ameProUpdateChecker : null, 'token_history_size' => 5, )); if ( isset($wp_menu_editor) ) { $ameLicensingUi = new Wslm_BasicPluginLicensingUI( $ameProLicenseManager, $wp_menu_editor->plugin_file, isset($ameProUpdateChecker) ? $ameProUpdateChecker : null, 'AME_LICENSE_KEY' ); } //Load WP-CLI commands. if ( defined('WP_CLI') && WP_CLI && isset($wp_menu_editor) ) { include dirname(__FILE__) . '/extras/wp-cli-integration.php'; } }