コード例 #1
0
 private function display_editor_ui()
 {
     //Prepare a bunch of parameters for the editor.
     $editor_data = array('message' => isset($this->get['message']) ? intval($this->get['message']) : null, 'images_url' => plugins_url('images', $this->plugin_file), 'hide_advanced_settings' => $this->options['hide_advanced_settings'], 'show_extra_icons' => $this->options['show_extra_icons'], 'settings_page_url' => $this->get_settings_page_url(), 'show_deprecated_hide_button' => $this->options['show_deprecated_hide_button'], 'dashicons_available' => wp_style_is('dashicons', 'done'));
     //Build a tree struct. for the default menu
     $default_tree = ameMenu::wp2tree($this->default_wp_menu, $this->default_wp_submenu);
     $default_menu = ameMenu::load_array($default_tree);
     //Is there a custom menu?
     if (!empty($this->merged_custom_menu)) {
         $custom_menu = $this->merged_custom_menu;
     } else {
         //Start out with the default menu if there is no user-created one
         $custom_menu = $default_menu;
     }
     //The editor doesn't use the color CSS. Including it would just make the page bigger and waste bandwidth.
     unset($custom_menu['color_css']);
     unset($custom_menu['color_css_modified']);
     //Encode both menus as JSON
     $editor_data['default_menu_js'] = ameMenu::to_json($default_menu);
     $editor_data['custom_menu_js'] = ameMenu::to_json($custom_menu);
     //Create a list of all known capabilities and roles. Used for the drop-down list on the access field.
     $all_capabilities = ameRoleUtils::get_all_capabilities();
     //"level_X" capabilities are deprecated so we don't want people using them.
     //This would look better with array_filter() and an anonymous function as a callback.
     for ($level = 0; $level <= 10; $level++) {
         $cap = 'level_' . $level;
         if (isset($all_capabilities[$cap])) {
             unset($all_capabilities[$cap]);
         }
     }
     $all_capabilities = array_keys($all_capabilities);
     natcasesort($all_capabilities);
     //Multi-site installs also get the virtual "Super Admin" cap, but only the Super Admin sees it.
     if (is_multisite() && !isset($all_capabilities['super_admin']) && is_super_admin()) {
         array_unshift($all_capabilities, 'super_admin');
     }
     $editor_data['all_capabilities'] = $all_capabilities;
     //Create a list of all roles, too.
     $all_roles = ameRoleUtils::get_role_names();
     asort($all_roles);
     $editor_data['all_roles'] = $all_roles;
     //Include hint visibility settings
     $editor_data['show_hints'] = $this->get_hint_visibility();
     require dirname(__FILE__) . '/editor-page.php';
 }
コード例 #2
0
 private function display_editor_ui()
 {
     //Prepare a bunch of parameters for the editor.
     $editor_data = array('message' => isset($this->get['message']) ? intval($this->get['message']) : null, 'images_url' => $this->plugin_dir_url . '/images', 'hide_advanced_settings' => $this->options['hide_advanced_settings']);
     //Build a tree struct. for the default menu
     $default_tree = ameMenu::wp2tree($this->default_wp_menu, $this->default_wp_submenu);
     $default_menu = ameMenu::load_array($default_tree);
     //Is there a custom menu?
     if (!empty($this->merged_custom_menu)) {
         $custom_menu = $this->merged_custom_menu;
     } else {
         //Start out with the default menu if there is no user-created one
         $custom_menu = $default_menu;
     }
     //Encode both menus as JSON
     $editor_data['default_menu_js'] = ameMenu::to_json($default_menu);
     $editor_data['custom_menu_js'] = ameMenu::to_json($custom_menu);
     //Create a list of all known capabilities and roles. Used for the drop-down list on the access field.
     $all_capabilities = ameRoleUtils::get_all_capabilities();
     //"level_X" capabilities are deprecated so we don't want people using them.
     //This would look better with array_filter() and an anonymous function as a callback.
     for ($level = 0; $level <= 10; $level++) {
         $cap = 'level_' . $level;
         if (isset($all_capabilities[$cap])) {
             unset($all_capabilities[$cap]);
         }
     }
     $all_capabilities = array_keys($all_capabilities);
     natcasesort($all_capabilities);
     $editor_data['all_capabilities'] = $all_capabilities;
     //Create a list of all roles, too.
     $all_roles = ameRoleUtils::get_role_names();
     //Multi-site installs also get the virtual "Super Admin" role
     if (is_multisite() && !isset($all_roles['super_admin'])) {
         $all_roles['super_admin'] = 'Super Admin';
     }
     asort($all_roles);
     $editor_data['all_roles'] = $all_roles;
     //Include hint visibility settings
     $editor_data['show_hints'] = $this->get_hint_visibility();
     require dirname(__FILE__) . '/editor-page.php';
 }