├── wordpress-custom-menu-separator.php ├── class-custom-menu-separator.php └── README.md /wordpress-custom-menu-separator.php: -------------------------------------------------------------------------------- 1 | 9 | * @license GPL-2.0+ 10 | * @link https://github.com/tommcfarlin/WordPress-Custom-Menu-Separator 11 | * @copyright 2013 - 2014 Tom McFarlin 12 | * 13 | * @wordpress-plugin 14 | * Plugin Name: Custom Menu Separator 15 | * Plugin URI: http://tommcfarlin.com/wordpress-menu-separator 16 | * Description: A simple plugin for adding a custom menu separator in the WordPress administration menu. 17 | * Version: 1.2.0 18 | * Author: Tom McFarlin 19 | * Author URI: http://tommcfarlin.com 20 | * Author Email: tom@tommcfarlin.com 21 | */ 22 | 23 | // If this file is called directly, abort. 24 | if ( ! defined( 'WPINC' ) ) { 25 | die; 26 | } 27 | 28 | require_once plugin_dir_path( __FILE__ ) . '/class-custom-menu-separator.php' ; 29 | 30 | add_action( 'plugins_loaded', 'custom_menu_separator_start' ); 31 | function custom_menu_separator_start() { 32 | new Custom_Menu_Separator(); 33 | } -------------------------------------------------------------------------------- /class-custom-menu-separator.php: -------------------------------------------------------------------------------- 1 | '', // The text of the menu item 60 | 1 => 'read', // Permission level required to view the item 61 | 2 => 'separator' . $position, // The ID of the menu item 62 | 3 => '', // Empty by default. 63 | 4 => 'wp-menu-separator' // Custom class names for the menu item 64 | ); 65 | ksort( $menu ); 66 | 67 | } // end add_admin_menu_separator 68 | 69 | } // end class -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WordPress Custom Menu Separator 2 | 3 | A simple plugin for adding a custom menu separator in the WordPress administration menu. The blog post associated with this plugin can be found [on my blog](http://tommcfarlin.com/wordpress-menu-separator). 4 | 5 | ## Default Menu Structure 6 | 7 | By default, WordPress populates its administration menu with the following array. Note that the indexes of the array are reserved for default menu items and should not be used to insert custom menu items. 8 | 9 | ```php 10 | Array 11 | ( 12 | [2] => Array 13 | ( 14 | [0] => Dashboard 15 | [1] => read 16 | [2] => index.php 17 | [3] => 18 | [4] => menu-top menu-top-first menu-icon-dashboard menu-top-last 19 | [5] => menu-dashboard 20 | [6] => div 21 | ) 22 | 23 | [4] => Array 24 | ( 25 | [0] => 26 | [1] => read 27 | [2] => separator1 28 | [3] => 29 | [4] => wp-menu-separator 30 | ) 31 | 32 | [5] => Array 33 | ( 34 | [0] => Posts 35 | [1] => edit_posts 36 | [2] => edit.php 37 | [3] => 38 | [4] => open-if-no-js menu-top menu-icon-post menu-top-first 39 | [5] => menu-posts 40 | [6] => div 41 | ) 42 | 43 | [10] => Array 44 | ( 45 | [0] => Media 46 | [1] => upload_files 47 | [2] => upload.php 48 | [3] => 49 | [4] => menu-top menu-icon-media 50 | [5] => menu-media 51 | [6] => div 52 | ) 53 | 54 | [15] => Array 55 | ( 56 | [0] => Links 57 | [1] => manage_links 58 | [2] => link-manager.php 59 | [3] => 60 | [4] => menu-top menu-icon-links 61 | [5] => menu-links 62 | [6] => div 63 | ) 64 | 65 | [20] => Array 66 | ( 67 | [0] => Pages 68 | [1] => edit_pages 69 | [2] => edit.php?post_type=page 70 | [3] => 71 | [4] => menu-top menu-icon-page 72 | [5] => menu-pages 73 | [6] => div 74 | ) 75 | 76 | [25] => Array 77 | ( 78 | [0] => Comments 0 79 | [1] => edit_posts 80 | [2] => edit-comments.php 81 | [3] => 82 | [4] => menu-top menu-icon-comments menu-top-last menu-top-last 83 | [5] => menu-comments 84 | [6] => div 85 | ) 86 | 87 | [57] => Array 88 | ( 89 | [0] => 90 | [1] => read 91 | [2] => separator57 92 | [3] => 93 | [4] => wp-menu-separator 94 | ) 95 | 96 | [59] => Array 97 | ( 98 | [0] => 99 | [1] => read 100 | [2] => separator2 101 | [3] => 102 | [4] => wp-menu-separator 103 | ) 104 | 105 | [60] => Array 106 | ( 107 | [0] => Appearance 108 | [1] => switch_themes 109 | [2] => themes.php 110 | [3] => 111 | [4] => menu-top menu-icon-appearance menu-top-first 112 | [5] => menu-appearance 113 | [6] => div 114 | ) 115 | 116 | [65] => Array 117 | ( 118 | [0] => Plugins 0 119 | [1] => activate_plugins 120 | [2] => plugins.php 121 | [3] => 122 | [4] => menu-top menu-icon-plugins 123 | [5] => menu-plugins 124 | [6] => div 125 | ) 126 | 127 | [70] => Array 128 | ( 129 | [0] => Users 130 | [1] => list_users 131 | [2] => users.php 132 | [3] => 133 | [4] => menu-top menu-icon-users 134 | [5] => menu-users 135 | [6] => div 136 | ) 137 | 138 | [75] => Array 139 | ( 140 | [0] => Tools 141 | [1] => edit_posts 142 | [2] => tools.php 143 | [3] => 144 | [4] => menu-top menu-icon-tools 145 | [5] => menu-tools 146 | [6] => div 147 | ) 148 | 149 | [80] => Array 150 | ( 151 | [0] => Settings 152 | [1] => manage_options 153 | [2] => options-general.php 154 | [3] => 155 | [4] => menu-top menu-icon-settings menu-top-last 156 | [5] => menu-settings 157 | [6] => div 158 | ) 159 | 160 | ) 161 | ``` 162 | 163 | ## Installation 164 | 165 | 1. Download (or pull) the plugin 166 | 2. Install it using the WordPress Plugin's administration page or my dropping it into your `/plugins/` directory 167 | 3. Activate it on the Plugin's listing page 168 | 169 | You should notice a new separator appear above the 'Settings' menu. This can be changed by editing Line 81 of `plugin.php` 170 | 171 | ## Changelog 172 | 173 | _1.2.0 23 April 2014_ 174 | * Minor code refactoring 175 | * Changing the wall the callback is implemented for `admin_init` 176 | * WordPress 3.9.0 compatibility fixes 177 | 178 | _1.1 22 March 2013_ 179 | * Updating the hooks to play nicely with WordPress 3.5 180 | --------------------------------------------------------------------------------