/**
  * Generate special menu templates and add them to the input template list.
  *
  * @param array $templates Template list.
  * @return array Modified template list.
  */
 private function add_special_templates($templates)
 {
     //Add a special template for unclickable menu items. These can be used as headers and such.
     $itemDefaults = ameMenuItem::custom_item_defaults();
     $unclickableDefaults = array_merge($itemDefaults, array('file' => '#' . ameMenuItem::unclickableTemplateClass, 'url' => '#' . ameMenuItem::unclickableTemplateClass, 'css_class' => $itemDefaults['css_class'] . ' ' . ameMenuItem::unclickableTemplateClass, 'menu_title' => 'Unclickable Menu'));
     $templates[ameMenuItem::unclickableTemplateId] = array('name' => '< None >', 'used' => true, 'defaults' => $unclickableDefaults);
     if ($this->is_pro_version()) {
         //The Pro version has a [wp-logout-url] shortcode. Lets make it easier o use
         //by adding it to the "Target page" dropdown.
         $logoutDefaults = array_merge(ameMenuItem::basic_defaults(), array('menu_title' => 'Logout', 'file' => '[wp-logout-url]', 'url' => '[wp-logout-url]', 'icon_url' => 'dashicons-migrate'));
         $templates['>logout'] = array('name' => 'Logout', 'used' => true, 'defaults' => $logoutDefaults);
     }
     return $templates;
 }
예제 #2
0
 /**
  * Compress menu configuration (lossless).
  *
  * Reduces data size by storing commonly used properties and defaults in one place
  * instead of in every menu item.
  *
  * @param array $menu
  * @return array
  */
 public static function compress($menu)
 {
     $property_dict = ameMenuItem::blank_menu();
     unset($property_dict['defaults']);
     $common = array('properties' => $property_dict, 'basic_defaults' => ameMenuItem::basic_defaults(), 'custom_item_defaults' => ameMenuItem::custom_item_defaults());
     $menu['tree'] = self::map_items($menu['tree'], array(__CLASS__, 'compress_item'), array($common));
     $menu = self::add_format_header($menu);
     $menu['format']['compressed'] = true;
     $menu['format']['common'] = $common;
     return $menu;
 }
예제 #3
0
 /**
  * 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, '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()), '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')));
 }
예제 #4
0
 /**
  * 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()));
 }
예제 #5
0
 /**
  * Add the JS required by the editor to the page header
  *
  * @return void
  */
 function enqueue_scripts()
 {
     //jQuery JSON plugin
     wp_register_script('jquery-json', $this->plugin_dir_url . '/js/jquery.json-1.3.js', array('jquery'), '1.3');
     //jQuery sort plugin
     wp_register_script('jquery-sort', $this->plugin_dir_url . '/js/jquery.sort.js', array('jquery'));
     //qTip2 - jQuery tooltip plugin
     wp_register_script('jquery-qtip', $this->plugin_dir_url . '/js/jquery.qtip.min.js', array('jquery'), '20120513', true);
     //Editor's scripts
     wp_enqueue_script('menu-editor', $this->plugin_dir_url . '/js/menu-editor.js', array('jquery', 'jquery-ui-sortable', 'jquery-ui-dialog', 'jquery-form', 'jquery-ui-droppable', 'jquery-qtip', 'jquery-sort', 'jquery-json'), '20120609');
     //The editor will need access to some of the plugin data and WP data.
     $wp_roles = ameRoleUtils::get_roles();
     wp_localize_script('menu-editor', 'wsEditorData', array('imagesUrl' => $this->plugin_dir_url . '/images', '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()), 'roles' => $wp_roles->roles, 'showHints' => $this->get_hint_visibility()));
 }