public function registerScripts()
 {
     $isProVersion = apply_filters('admin_menu_editor_is_pro', false);
     $dependencies = array('ame-actor-manager', 'ame-lodash', 'jquery');
     if ($isProVersion || wp_script_is('ame-visible-users', 'registered')) {
         $dependencies[] = 'ame-visible-users';
     }
     wp_register_auto_versioned_script('ame-actor-selector', plugins_url('modules/actor-selector/actor-selector.js', $this->menuEditor->plugin_file), $dependencies);
     $currentUser = wp_get_current_user();
     wp_localize_script('ame-actor-selector', 'wsAmeActorSelectorData', array('visibleUsers' => $this->menuEditor->get_plugin_option('visible_users'), 'currentUserLogin' => $currentUser->get('user_login'), 'isProVersion' => apply_filters('admin_menu_editor_is_pro', false), 'ajaxUpdateAction' => self::ajaxUpdateAction, 'ajaxUpdateNonce' => wp_create_nonce(self::ajaxUpdateAction), 'adminAjaxUrl' => admin_url('admin-ajax.php')));
 }
 /**
  * Add the JS required by the editor to the page header
  *
  * @return void
  */
 function enqueue_scripts()
 {
     //jQuery JSON plugin
     wp_register_auto_versioned_script('jquery-json', plugins_url('js/jquery.json.js', $this->plugin_file), array('jquery'));
     //jQuery sort plugin
     wp_register_auto_versioned_script('jquery-sort', plugins_url('js/jquery.sort.js', $this->plugin_file), array('jquery'));
     //qTip2 - jQuery tooltip plugin
     wp_register_auto_versioned_script('jquery-qtip', plugins_url('js/jquery.qtip.min.js', $this->plugin_file), array('jquery'));
     //jQuery Form plugin. This is a more recent version than the one included with WP.
     wp_register_auto_versioned_script('ame-jquery-form', plugins_url('js/jquery.form.js', $this->plugin_file), array('jquery'));
     //jQuery cookie plugin
     wp_register_auto_versioned_script('jquery-cookie', plugins_url('js/jquery.cookie.js', $this->plugin_file), array('jquery'));
     //Editor's scripts
     wp_register_auto_versioned_script('menu-editor', plugins_url('js/menu-editor.js', $this->plugin_file), array('jquery', 'jquery-ui-sortable', 'jquery-ui-dialog', 'ame-jquery-form', 'jquery-ui-droppable', 'jquery-qtip', 'jquery-sort', 'jquery-json', 'jquery-cookie', 'wp-color-picker'));
     //Add scripts to our editor page, but not the settings sub-section
     //that shares the same page slug. Some of the scripts would crash otherwise.
     if (!$this->is_editor_page()) {
         return;
     }
     wp_enqueue_script('menu-editor');
     //We use WordPress media uploader to let the user upload custom menu icons (WP 3.5+).
     if (function_exists('wp_enqueue_media')) {
         wp_enqueue_media();
     }
     //Remove the default jQuery Form plugin to prevent conflicts with our custom version.
     wp_dequeue_script('jquery-form');
     //Actors (roles and users) are used in the permissions UI, so we need to pass them along.
     $actors = array();
     $roles = array();
     $wp_roles = ameRoleUtils::get_roles();
     foreach ($wp_roles->roles as $role_id => $role) {
         $actors['role:' . $role_id] = $role['name'];
         $role['capabilities'] = $this->castValuesToBool($role['capabilities']);
         $roles[$role_id] = $role;
     }
     if (is_multisite() && is_super_admin()) {
         $actors['special:super_admin'] = 'Super Admin';
     }
     //Known users. Right now, this is limited to the current user only.
     $users = array();
     $current_user = wp_get_current_user();
     $users[$current_user->get('user_login')] = array('user_login' => $current_user->get('user_login'), 'id' => $current_user->ID, 'roles' => array_values($current_user->roles), 'capabilities' => $this->castValuesToBool($current_user->caps), 'is_super_admin' => is_multisite() && is_super_admin());
     $actors['user:'******'user_login')] = sprintf('Current user (%s)', $current_user->get('user_login'));
     //Note: Users do NOT get added to the actor list because that feature
     //is not fully implemented.
     $showExtraIcons = (bool) $this->options['show_extra_icons'];
     if (isset($_COOKIE['ame-show-extra-icons']) && is_numeric($_COOKIE['ame-show-extra-icons'])) {
         $showExtraIcons = intval($_COOKIE['ame-show-extra-icons']) > 0;
     }
     //The editor will need access to some of the plugin data and WP data.
     wp_localize_script('menu-editor', 'wsEditorData', array('imagesUrl' => plugins_url('images', $this->plugin_file), 'adminAjaxUrl' => admin_url('admin-ajax.php'), 'hideAdvancedSettings' => (bool) $this->options['hide_advanced_settings'], 'showExtraIcons' => $showExtraIcons, 'submenuIconsEnabled' => $this->options['submenu_icons_enabled'], 'hideAdvancedSettingsNonce' => wp_create_nonce('ws_ame_save_screen_options'), 'dashiconsAvailable' => wp_style_is('dashicons', 'registered'), 'captionShowAdvanced' => 'Show advanced options', 'captionHideAdvanced' => 'Hide advanced options', 'wsMenuEditorPro' => false, 'menuFormatName' => ameMenu::format_name, 'menuFormatVersion' => ameMenu::format_version, 'blankMenuItem' => ameMenuItem::blank_menu(), 'itemTemplates' => $this->item_templates, 'customItemTemplate' => array('name' => '< Custom >', 'defaults' => ameMenuItem::custom_item_defaults()), 'unclickableTemplateId' => ameMenuItem::unclickableTemplateId, 'unclickableTemplateClass' => ameMenuItem::unclickableTemplateClass, 'actors' => $actors, 'roles' => $roles, 'users' => $users, 'currentUserLogin' => $current_user->get('user_login'), 'selectedActor' => isset($this->get['selected_actor']) ? strval($this->get['selected_actor']) : null, 'showHints' => $this->get_hint_visibility(), 'dashboardHidingConfirmationEnabled' => $this->options['dashboard_hiding_confirmation_enabled'], 'disableDashboardConfirmationNonce' => wp_create_nonce('ws_ame_disable_dashboard_hiding_confirmation'), 'isDemoMode' => defined('IS_DEMO_MODE'), 'isMasterMode' => defined('IS_MASTER_MODE')));
 }
 /**
  * Add the JS required by the editor to the page header
  *
  * @return void
  */
 function enqueue_scripts()
 {
     //Optimization: Remove wp-emoji.js from the plugin page. wpEmoji makes DOM manipulation slow because
     //it tracks *all* DOM changes using MutationObserver.
     remove_action('admin_print_scripts', 'print_emoji_detection_script');
     //jQuery JSON plugin
     wp_register_auto_versioned_script('jquery-json', plugins_url('js/jquery.json.js', $this->plugin_file), array('jquery'));
     //jQuery sort plugin
     wp_register_auto_versioned_script('jquery-sort', plugins_url('js/jquery.sort.js', $this->plugin_file), array('jquery'));
     //qTip2 - jQuery tooltip plugin
     wp_register_auto_versioned_script('jquery-qtip', plugins_url('js/jquery.qtip.min.js', $this->plugin_file), array('jquery'));
     //jQuery Form plugin. This is a more recent version than the one included with WP.
     wp_register_auto_versioned_script('ame-jquery-form', plugins_url('js/jquery.form.js', $this->plugin_file), array('jquery'));
     //jQuery cookie plugin
     wp_register_auto_versioned_script('jquery-cookie', plugins_url('js/jquery.biscuit.js', $this->plugin_file), array('jquery'));
     //Lodash library
     wp_register_auto_versioned_script('ame-lodash', plugins_url('js/lodash.min.js', $this->plugin_file));
     //Knockout
     wp_register_auto_versioned_script('knockout', plugins_url('js/knockout.js', $this->plugin_file));
     //Move admin notices (e.g. "Settings saved") below editor tabs.
     //This is a separate script because it has to run after common.js which is loaded in the page footer.
     wp_enqueue_auto_versioned_script('ame-editor-tab-fix', plugins_url('js/editor-tab-fix.js', $this->plugin_file), array('jquery', 'common'), true);
     //Actor manager.
     wp_register_auto_versioned_script('ame-actor-manager', plugins_url('js/actor-manager.js', $this->plugin_file), array('ame-lodash'));
     //Modules
     wp_register_auto_versioned_script('ame-access-editor', plugins_url('modules/access-editor/access-editor.js', $this->plugin_file), array('jquery', 'ame-lodash'));
     //Let extras register their scripts.
     do_action('admin_menu_editor-register_scripts');
     //Editor's scripts
     $editor_dependencies = array('jquery', 'jquery-ui-sortable', 'jquery-ui-dialog', 'jquery-ui-tabs', 'ame-jquery-form', 'jquery-ui-droppable', 'jquery-qtip', 'jquery-sort', 'jquery-json', 'jquery-cookie', 'wp-color-picker', 'ame-lodash', 'ame-access-editor', 'ame-actor-manager', 'ame-actor-selector');
     wp_register_auto_versioned_script('menu-editor', plugins_url('js/menu-editor.js', $this->plugin_file), apply_filters('admin_menu_editor-editor_script_dependencies', $editor_dependencies));
     do_action('admin_menu_editor-enqueue_scripts-' . $this->current_tab);
     //Actors (roles and users) are used in the permissions UI, so we need to pass them along.
     $actors = array();
     $roles = array();
     $wp_roles = ameRoleUtils::get_roles();
     foreach ($wp_roles->roles as $role_id => $role) {
         $actors['role:' . $role_id] = $role['name'];
         $role['capabilities'] = $this->castValuesToBool($role['capabilities']);
         $roles[$role_id] = $role;
     }
     if (is_multisite() && is_super_admin()) {
         $actors['special:super_admin'] = 'Super Admin';
     }
     //Known users.
     $users = array();
     $current_user = wp_get_current_user();
     $visible_users = isset($this->options['visible_users']) ? $this->options['visible_users'] : array();
     $logins_to_include = $visible_users;
     //Always include the current user.
     $logins_to_include[] = $current_user->get('user_login');
     $logins_to_include = array_unique($logins_to_include);
     //Load user details.
     foreach ($logins_to_include as $login) {
         $user = get_user_by('login', $login);
         if (!empty($user)) {
             $users[$login] = $this->user_to_property_map($user);
         }
     }
     //Compatibility workaround: Get the real roles of the current user even if other plugins corrupt the list.
     $users[$current_user->get('user_login')]['roles'] = array_values($this->get_user_roles($current_user));
     $actors['user:'******'user_login')] = sprintf('Current user (%s)', $current_user->get('user_login'));
     $actor_data = array('roles' => $roles, 'users' => $users, 'isMultisite' => is_multisite());
     wp_localize_script('ame-actor-manager', 'wsAmeActorData', $actor_data);
     //Add only certain scripts to the settings sub-section.
     if ($this->is_settings_page()) {
         wp_enqueue_script('jquery-qtip');
         return;
     }
     //Add all scripts to our editor page, but not the settings sub-section
     //that shares the same page slug. Some of the scripts would crash otherwise.
     if (!$this->is_editor_page()) {
         return;
     }
     wp_enqueue_script('menu-editor');
     //We use WordPress media uploader to let the user upload custom menu icons (WP 3.5+).
     if (function_exists('wp_enqueue_media')) {
         wp_enqueue_media();
     }
     //Remove the default jQuery Form plugin to prevent conflicts with our custom version.
     wp_dequeue_script('jquery-form');
     //The editor will need access to some of the plugin data and WP data.
     $script_data = array('imagesUrl' => plugins_url('images', $this->plugin_file), 'adminAjaxUrl' => admin_url('admin-ajax.php'), 'hideAdvancedSettings' => (bool) $this->options['hide_advanced_settings'], 'showExtraIcons' => true, 'submenuIconsEnabled' => $this->options['submenu_icons_enabled'], 'hideAdvancedSettingsNonce' => wp_create_nonce('ws_ame_save_screen_options'), 'dashiconsAvailable' => wp_style_is('dashicons', 'registered'), 'captionShowAdvanced' => 'Show advanced options', 'captionHideAdvanced' => 'Hide advanced options', 'wsMenuEditorPro' => $this->is_pro_version(), 'menuFormatName' => ameMenu::format_name, 'menuFormatVersion' => ameMenu::format_version, 'blankMenuItem' => ameMenuItem::blank_menu(), 'itemTemplates' => $this->item_templates, 'customItemTemplate' => array('name' => '< Custom >', 'defaults' => ameMenuItem::custom_item_defaults()), 'unclickableTemplateId' => ameMenuItem::unclickableTemplateId, 'unclickableTemplateClass' => ameMenuItem::unclickableTemplateClass, 'embeddedPageTemplateId' => ameMenuItem::embeddedPageTemplateId, 'actors' => $actors, 'currentUserLogin' => $current_user->get('user_login'), 'selectedActor' => isset($this->get['selected_actor']) ? strval($this->get['selected_actor']) : null, 'postTypes' => $this->get_post_type_details(), 'taxonomies' => $this->get_taxonomy_details(), 'showHints' => $this->get_hint_visibility(), 'dashboardHidingConfirmationEnabled' => $this->options['dashboard_hiding_confirmation_enabled'], 'disableDashboardConfirmationNonce' => wp_create_nonce('ws_ame_disable_dashboard_hiding_confirmation'), 'getPagesNonce' => wp_create_nonce('ws_ame_get_pages'), 'getPageDetailsNonce' => wp_create_nonce('ws_ame_get_page_details'), 'isDemoMode' => defined('IS_DEMO_MODE'), 'isMasterMode' => defined('IS_MASTER_MODE'));
     $script_data = apply_filters('admin_menu_editor-script_data', $script_data);
     wp_localize_script('menu-editor', 'wsEditorData', $script_data);
 }
 public function enqueueScripts()
 {
     wp_register_auto_versioned_script('ame-plugin-visibility', plugins_url('plugin-visibility.js', __FILE__), array('ame-lodash', 'knockout', 'ame-actor-selector', 'jquery-json'));
     wp_enqueue_script('ame-plugin-visibility');
     //Reselect the same actor.
     $query = $this->menuEditor->get_query_params();
     $selectedActor = null;
     if (isset($query['selected_actor'])) {
         $selectedActor = strval($query['selected_actor']);
     }
     $scriptData = $this->getScriptData();
     $scriptData['selectedActor'] = $selectedActor;
     wp_localize_script('ame-plugin-visibility', 'wsPluginVisibilityData', $scriptData);
 }
 /**
  * Add the JS required by the editor to the page header
  *
  * @return void
  */
 function enqueue_scripts()
 {
     //jQuery JSON plugin
     wp_register_auto_versioned_script('jquery-json', plugins_url('js/jquery.json-1.3.js', $this->plugin_file), array('jquery'));
     //jQuery sort plugin
     wp_register_auto_versioned_script('jquery-sort', plugins_url('js/jquery.sort.js', $this->plugin_file), array('jquery'));
     //qTip2 - jQuery tooltip plugin
     wp_register_auto_versioned_script('jquery-qtip', plugins_url('js/jquery.qtip.min.js', $this->plugin_file), array('jquery'));
     //Editor's scripts
     wp_register_auto_versioned_script('menu-editor', plugins_url('js/menu-editor.js', $this->plugin_file), array('jquery', 'jquery-ui-sortable', 'jquery-ui-dialog', 'jquery-form', 'jquery-ui-droppable', 'jquery-qtip', 'jquery-sort', 'jquery-json'));
     wp_enqueue_script('menu-editor');
     //Actors (roles and users) are used in the permissions UI, so we need to pass them along.
     $actors = array();
     $roles = array();
     $wp_roles = ameRoleUtils::get_roles();
     foreach ($wp_roles->roles as $role_id => $role) {
         $actors['role:' . $role_id] = $role['name'];
         $role['capabilities'] = $this->castValuesToBool($role['capabilities']);
         $roles[$role_id] = $role;
     }
     if (is_multisite() && is_super_admin()) {
         $actors['special:super_admin'] = 'Super Admin';
     }
     //Known users. Right now, this is limited to the current user only.
     $users = array();
     $current_user = wp_get_current_user();
     $users[$current_user->user_login] = array('user_login' => $current_user->user_login, 'id' => $current_user->ID, 'roles' => array_values($current_user->roles), 'capabilities' => $this->castValuesToBool($current_user->caps), 'is_super_admin' => is_multisite() && is_super_admin());
     $actors['user:'******'Current user (%s)', $current_user->user_login);
     //Note: Users do NOT get added to the actor list because that feature
     //is not fully implemented.
     //The editor will need access to some of the plugin data and WP data.
     wp_localize_script('menu-editor', 'wsEditorData', array('imagesUrl' => plugins_url('images', $this->plugin_file), 'adminAjaxUrl' => admin_url('admin-ajax.php'), 'hideAdvancedSettings' => (bool) $this->options['hide_advanced_settings'], 'hideAdvancedSettingsNonce' => wp_create_nonce('ws_ame_save_screen_options'), 'captionShowAdvanced' => 'Show advanced options', 'captionHideAdvanced' => 'Hide advanced options', 'wsMenuEditorPro' => false, 'menuFormatName' => ameMenu::format_name, 'menuFormatVersion' => ameMenu::format_version, 'blankMenuItem' => ameMenuItem::blank_menu(), 'itemTemplates' => $this->item_templates, 'customItemTemplate' => array('name' => '< Custom >', 'defaults' => ameMenuItem::custom_item_defaults()), 'actors' => $actors, 'roles' => $roles, 'users' => $users, 'currentUserLogin' => $current_user->user_login, 'showHints' => $this->get_hint_visibility()));
 }
 public function register_scripts()
 {
     wp_register_auto_versioned_script('ame-visible-users', plugins_url('extras/modules/visible-users/visible-users.js', $this->wp_menu_editor->plugin_file), array('jquery', 'ame-lodash'));
 }
Beispiel #7
0
 public function enqueueScripts()
 {
     wp_register_auto_versioned_script('knockout', plugins_url('js/knockout-2.2.1.js', WS_ADMIN_BAR_EDITOR_FILE));
     wp_register_auto_versioned_script('jquery-json', plugins_url('js/jquery.json-2.4.js', WS_ADMIN_BAR_EDITOR_FILE), array('jquery'));
     wp_register_auto_versioned_script('jquery-ajax-form', plugins_url('js/jquery.form.js', WS_ADMIN_BAR_EDITOR_FILE), array('jquery'));
     wp_register_auto_versioned_script('jquery-qtip2', plugins_url('js/qtip/jquery.qtip.min.js', WS_ADMIN_BAR_EDITOR_FILE), array('jquery'));
     wp_register_auto_versioned_script('mjs-jquery-nested-sortable', plugins_url('js/jquery.mjs.nestedSortable.js', WS_ADMIN_BAR_EDITOR_FILE), array('jquery-ui-sortable'));
     wp_register_auto_versioned_script('ws-abe-nested-sortable', plugins_url('js/knockout-nested-sortable.js', WS_ADMIN_BAR_EDITOR_FILE), array('knockout', 'mjs-jquery-nested-sortable'));
     wp_register_auto_versioned_script('ws-abe-node-view-model', plugins_url('js/node-view-model.js', WS_ADMIN_BAR_EDITOR_FILE), array('knockout', 'jquery'));
     wp_register_auto_versioned_script('ws-abe-settings-script', plugins_url('js/settings-page.js', WS_ADMIN_BAR_EDITOR_FILE), array('jquery'));
     if ($this->isEditorPage()) {
         wp_enqueue_auto_versioned_script('ws-admin-bar-editor', plugins_url('js/admin-bar-editor.js', WS_ADMIN_BAR_EDITOR_FILE), array('jquery', 'knockout', 'jquery-json', 'jquery-ajax-form', 'jquery-ui-dialog', 'mjs-jquery-nested-sortable', 'ws-abe-nested-sortable', 'ws-abe-node-view-model', 'jquery-qtip2'));
     } else {
         if ($this->isSettingsPage()) {
             wp_enqueue_script('ws-abe-settings-script');
         }
     }
     if ($this->isDemoMode()) {
         wp_register_auto_versioned_script('ws-abe-jquery-cookie', plugins_url('js/jquery-cookie/jquery.cookie.js', WS_ADMIN_BAR_EDITOR_FILE));
         wp_enqueue_auto_versioned_script('ws-abe-demo-helper', plugins_url('js/demo.js', WS_ADMIN_BAR_EDITOR_FILE), array('ws-abe-jquery-cookie'));
     }
 }