Changeset 968313
- Timestamp:
- 08/19/2014 01:48:08 PM (11 years ago)
- Location:
- clean-admin-ui/trunk
- Files:
-
- 2 edited
-
clean-admin-ui.php (modified) (10 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
clean-admin-ui/trunk/clean-admin-ui.php
r756063 r968313 1 1 <?php 2 2 /* 3 Plugin Name: Clean Admin UI4 Plugin URI: http://www.arenddeboer.com/clean-admin-ui-a-new-wordpress-plugin-to-remove-admin-menu-items/5 Version: 1.2 6 Description: Configure and remove admin menu items like posts, pages, comments7 Author: Arend de Boer8 Author URI: http://www.arenddeboer.com/clean-admin-ui-a-new-wordpress-plugin-to-remove-admin-menu-items/9 10 Copyright 2011 Arend de Boer (email : [email protected])11 12 This program is free software; you can redistribute it and/or modify13 it under the terms of the GNU General Public License as published by14 the Free Software Foundation; either version 2 of the License, or15 (at your option) any later version.16 17 This program is distributed in the hope that it will be useful,18 but WITHOUT ANY WARRANTY; without even the implied warranty of19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the20 GNU General Public License for more details.21 22 You should have received a copy of the GNU General Public License23 along with this program; if not, write to the Free Software24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA3 Plugin Name: Clean Admin UI 4 Plugin URI: http://www.arenddeboer.com/clean-admin-ui-a-new-wordpress-plugin-to-remove-admin-menu-items/ 5 Version: 1.3 6 Description: Configure and remove admin menu items like posts, pages, comments 7 Author: Arend de Boer 8 Author URI: http://www.arenddeboer.com/clean-admin-ui-a-new-wordpress-plugin-to-remove-admin-menu-items/ 9 10 Copyright 2011 Arend de Boer (email : [email protected]) 11 12 This program is free software; you can redistribute it and/or modify 13 it under the terms of the GNU General Public License as published by 14 the Free Software Foundation; either version 2 of the License, or 15 (at your option) any later version. 16 17 This program is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 along with this program; if not, write to the Free Software 24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25 25 */ 26 26 … … 29 29 =============================================================================== 30 30 31 set default options when plugin is activated, remove options when deactivated31 set default options when plugin is activated, remove options when deactivated 32 32 33 33 =============================================================================== … … 36 36 global $CAUdefaults; 37 37 $CAUdefaults = array( 38 'show_menu_posts'=>'1', 39 'show_menu_media'=>'1', 40 'show_menu_page_links'=>'1', 41 'show_menu_pages'=>'1', 42 'show_menu_comments'=>'1', 43 'show_menu_users'=>'1', 44 'show_menu_tools'=>'1'); 38 'show_menu_posts'=>'1', 39 'show_menu_media'=>'1', 40 'show_menu_page_links'=>'1', 41 'show_menu_pages'=>'1', 42 'show_menu_comments'=>'1', 43 'show_menu_users'=>'1', 44 'show_menu_plugins'=>'1', 45 'show_menu_themes'=>'1', 46 'show_menu_tools'=>'1', 47 'show_menu_dashboard'=>'1', 48 'db_version'=>'1.1'); 45 49 46 50 register_activation_hook( __FILE__, 'onCAUActivation' ); 47 51 register_deactivation_hook( __FILE__, 'onCAUDeactivation' ); 48 52 53 /*** 54 * Generate the menu options to hide from the database 55 * 56 */ 49 57 function onCAUActivation() { 50 58 global $CAUdefaults; … … 52 60 53 61 } 62 /*** 63 * Remove options from the database 64 * 65 */ 54 66 function onCAUDeactivation() { delete_option('CAUoptions'); } 55 67 … … 57 69 =============================================================================== 58 70 59 insert styles into <head> 60 61 =============================================================================== 62 */ 63 71 insert styles into <head> 72 73 =============================================================================== 74 */ 75 /*** 76 * Request stored options from db 77 * 78 * @var mixed 79 */ 64 80 $CAUoptions = get_option('CAUoptions'); 65 81 … … 67 83 =============================================================================== 68 84 69 Clean Admin UI settings 70 71 =============================================================================== 72 */ 73 85 Clean Admin UI settings 86 87 =============================================================================== 88 */ 89 /*** 90 * Register for add_action hook 91 */ 74 92 add_action('admin_menu', 'clean_admin_ui_init', 1); 75 93 76 94 /*** 95 * Add this plugin to the menu 96 * 97 */ 77 98 function clean_admin_ui_init() { 78 99 add_options_page('Clean Admin UI', 'Clean Admin UI', 'activate_plugins', 'clean-admin-ui', 'CAUoptions'); 79 100 80 101 clean_admin_ui_do_clean(); 81 102 } 82 103 104 /*** 105 * Actual cleanup function which removes the selected menu items 106 * 107 */ 83 108 function clean_admin_ui_do_clean() { 84 109 85 110 global $menu; 86 111 87 112 $wp_version = explode('.', get_bloginfo('version')); 88 113 if($wp_version[0] >= 3 && $wp_version[1] >= 1 ) { … … 91 116 $legacy = true; 92 117 } 93 //DebugBreak(); 118 94 119 $CAUoptions = get_option('CAUoptions'); 120 95 121 foreach ($CAUoptions as $key => $value) { 96 122 switch ($key) { 97 123 case "show_menu_posts": 98 124 if(!$value && !$legacy) { 125 99 126 remove_menu_page('edit.php'); 100 127 } elseif(!$value && $legacy) { … … 144 171 } 145 172 break; 146 } 147 } 148 } 149 173 case "show_menu_themes": 174 if(!$value && !$legacy) { 175 remove_menu_page('themes.php'); 176 } 177 break; 178 case "show_menu_plugins": 179 if(!$value && !$legacy) { 180 remove_menu_page('plugins.php'); 181 } 182 break; 183 case "show_menu_dashboard": 184 if(!$value && !$legacy) { 185 remove_the_dashboard(); 186 } 187 break; 188 } 189 } 190 } 191 192 /*** 193 * Generate a refresh link 194 * 195 */ 150 196 function curPageURL() { 151 $pageURL = 'http'; 152 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} 153 $pageURL .= "://"; 154 if ($_SERVER["SERVER_PORT"] != "80") { 155 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; 156 } else { 157 $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; 158 } 159 return $pageURL; 160 } 161 197 $pageURL = 'http'; 198 if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {$pageURL .= "s";} 199 $pageURL .= "://"; 200 if ($_SERVER["SERVER_PORT"] != "80") { 201 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; 202 } else { 203 $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; 204 } 205 return $pageURL; 206 } 207 208 // borrowed from http://bavotasan.com/2008/hiding-the-wordpress-dashboard-for-non-admin-users/ original code by Austin Matzko 209 // Modified by c.bavota of http://bavotasan.com for WordPress 2.7 and to allow the dashboard for Admins. 210 function remove_the_dashboard () { 211 if (current_user_can('level_10') && false) { 212 //return; apply to all 213 } else { 214 215 global $menu, $submenu, $user_ID; 216 $the_user = new WP_User($user_ID); 217 reset($menu); $page = key($menu); 218 while ((__('Dashboard') != $menu[$page][0]) && next($menu)) 219 $page = key($menu); 220 if (__('Dashboard') == $menu[$page][0]) unset($menu[$page]); 221 reset($menu); $page = key($menu); 222 while (!$the_user->has_cap($menu[$page][1]) && next($menu)) 223 $page = key($menu); 224 if (preg_match('#wp-admin/?(index.php)?$#',$_SERVER['REQUEST_URI']) && ('index.php' != $menu[$page][2])) 225 wp_redirect(get_option('siteurl') . '/wp-admin/post-new.php'); 226 } 227 } 228 /*** 229 * Create and update the CAUoptions object based on POST condition 230 * 231 */ 162 232 function CAUoptions() { ?> 163 233 164 234 <?php 235 $message = ""; 165 236 global $CAUdefaults; 166 if ($_POST['submit']) { 167 $_POST['content'] = stripslashes($_POST['content']); 237 if (isset($_POST['submit'])) { 238 if(isset($_POST['content'])) { 239 $_POST['content'] = stripslashes($_POST['content']); 240 } 241 168 242 $CAUoptions = array(); 169 243 foreach ($CAUdefaults as $name => $value) { 170 $CAUoptions[$name] = $_POST[$name]; 171 } 172 173 244 if(isset($_POST[$name])) { 245 $CAUoptions[$name] = $_POST[$name]; 246 } else { 247 $CAUoptions[$name] = ""; 248 } 249 } 250 251 174 252 update_option('CAUoptions', $CAUoptions); 175 253 $message = '<div id="message" class="updated"><p>Clean Admin UI settings updated.</p> … … 179 257 } else { 180 258 $CAUoptions = get_option('CAUoptions'); 259 if(!isset($CAUoptions['show_menu_plugins']) && !isset($CAUoptions['show_menu_themes']) && !isset($CAUoptions['db_version']) ) { 260 // new options since 1.3 261 update_option('CAUoptions', array_merge($CAUoptions, array('show_menu_plugins' => '1', 'show_menu_themes' => '1', 'db_version', '1.1', 'show_menu_dashboard' => '1'))); 262 $CAUoptions = get_option('CAUoptions'); 263 } 181 264 } 182 265 ?> 183 266 184 267 <style type="text/css"> 185 .formField {186 width: 60%;187 padding: 5px 0px 10px 0px;188 }189 .form-table input[type="text"], .form-table textarea {190 width: 50%;191 }192 .form-table th {193 width: 150px;194 }195 #CAUcss {196 display: block;197 margin-top: 8px;198 width: 93%;199 }268 .formField { 269 width: 60%; 270 padding: 5px 0px 10px 0px; 271 } 272 .form-table input[type="text"], .form-table textarea { 273 width: 50%; 274 } 275 .form-table th { 276 width: 150px; 277 } 278 #CAUcss { 279 display: block; 280 margin-top: 8px; 281 width: 93%; 282 } 200 283 </style> 201 284 202 285 <div class="wrap"> 203 286 204 287 <a href="http://www.arenddeboer.com/clean-admin-ui-a-new-wordpress-plugin-to-remove-admin-menu-items/" target="_blank"></a><h2>Clean Admin UI</h2> 205 288 <?php print $message; ?> … … 209 292 <form action="" method="post"> 210 293 211 <table class="form-table"> 212 213 <tr> 214 <th scope="row" colspan="2" class="th-full"> 215 <label for="show_menu_posts"><input type="checkbox" name="show_menu_posts" <?php if ($CAUoptions['show_menu_posts']) {print 'checked="checked" ';} ?>/> Show <strong>Posts</strong> menu entry.</label> 216 </th> 217 </tr> 218 219 <tr> 220 <th scope="row" colspan="2" class="th-full"> 221 <label for="show_menu_media"><input type="checkbox" name="show_menu_media" <?php if ($CAUoptions['show_menu_media']) {print 'checked="checked" ';} ?>/> Show <strong>Media</strong> menu entry.</label> 222 </th> 223 </tr> 224 225 <tr> 226 <th scope="row" colspan="2" class="th-full"> 227 <label for="show_menu_page_links"><input type="checkbox" name="show_menu_page_links" <?php if ($CAUoptions['show_menu_page_links']) {print 'checked="checked" ';} ?>/> Show <strong>Page Links</strong> menu entry.</label> 228 </th> 229 </tr> 230 231 <tr> 232 <th scope="row" colspan="2" class="th-full"> 233 <label for="show_menu_pages"><input type="checkbox" name="show_menu_pages" <?php if ($CAUoptions['show_menu_pages']) {print 'checked="checked" ';} ?>/> Show <strong>Pages</strong> menu entry.</label> 234 </th> 235 </tr> 236 237 <tr> 238 <th scope="row" colspan="2" class="th-full"> 239 <label for="show_menu_comments"><input type="checkbox" name="show_menu_comments" <?php if ($CAUoptions['show_menu_comments']) {print 'checked="checked" ';} ?>/> Show <strong>Comments</strong> menu entry.</label> 240 </th> 241 </tr> 242 243 <tr> 244 <th scope="row" colspan="2" class="th-full"> 245 <label for="show_menu_users"><input type="checkbox" name="show_menu_users" <?php if ($CAUoptions['show_menu_users']) {print 'checked="checked" ';} ?>/> Show <strong>Users</strong> menu entry.</label> 246 </th> 247 </tr> 248 249 <tr> 250 <th scope="row" colspan="2" class="th-full"> 251 <label for="show_menu_tools"><input type="checkbox" name="show_menu_tools" <?php if ($CAUoptions['show_menu_tools']) {print 'checked="checked" ';} ?>/> Show <strong>Tools</strong> menu entry.</label> 252 </th> 253 </tr> 254 255 </table><!-- form-table --> 256 257 <p class="submit"><input type="submit" class="button-primary" name="submit" value="Save Changes" /></p> 258 294 <table class="form-table"> 295 296 <tr> 297 <th scope="row" colspan="2" class="th-full"> 298 <label> 299 <input type="checkbox" name="show_menu_posts" <?php if ($CAUoptions['show_menu_posts']) {print 'checked="checked" ';} ?>/> Show <strong>Posts</strong> menu entry. 300 </label> 301 </th> 302 </tr> 303 304 <tr> 305 <th scope="row" colspan="2" class="th-full"> 306 <label> 307 <input type="checkbox" name="show_menu_media" <?php if ($CAUoptions['show_menu_media']) {print 'checked="checked" ';} ?>/> Show <strong>Media</strong> menu entry. 308 </label> 309 </th> 310 </tr> 311 312 <tr> 313 <th scope="row" colspan="2" class="th-full"> 314 <label> 315 <input type="checkbox" name="show_menu_page_links" <?php if ($CAUoptions['show_menu_page_links']) {print 'checked="checked" ';} ?>/> Show <strong>Page Links</strong> menu entry. 316 </label> 317 </th> 318 </tr> 319 320 <tr> 321 <th scope="row" colspan="2" class="th-full"> 322 <label> 323 <input type="checkbox" name="show_menu_pages" <?php if ($CAUoptions['show_menu_pages']) {print 'checked="checked" ';} ?>/> Show <strong>Pages</strong> menu entry. 324 </label> 325 </th> 326 </tr> 327 328 <tr> 329 <th scope="row" colspan="2" class="th-full"> 330 <label> 331 <input type="checkbox" name="show_menu_comments" <?php if ($CAUoptions['show_menu_comments']) {print 'checked="checked" ';} ?>/> Show <strong>Comments</strong> menu entry. 332 </label> 333 </th> 334 </tr> 335 336 <tr> 337 <th scope="row" colspan="2" class="th-full"> 338 <label> 339 <input type="checkbox" name="show_menu_users" <?php if ($CAUoptions['show_menu_users']) {print 'checked="checked" ';} ?>/> Show <strong>Users</strong> menu entry. 340 </label> 341 </th> 342 </tr> 343 344 <tr> 345 <th scope="row" colspan="2" class="th-full"> 346 <label> 347 <input type="checkbox" name="show_menu_tools" <?php if ($CAUoptions['show_menu_tools']) {print 'checked="checked" ';} ?>/> Show <strong>Tools</strong> menu entry. 348 </label> 349 </th> 350 </tr> 351 352 <tr> 353 <th scope="row" colspan="2" class="th-full"> 354 <label> 355 <input type="checkbox" name="show_menu_plugins" <?php if ($CAUoptions['show_menu_plugins']) {print 'checked="checked" ';} ?>/> Show <strong>Plugins</strong> menu entry. 356 </label> 357 </th> 358 </tr> 359 360 <tr> 361 <th scope="row" colspan="2" class="th-full"> 362 <label> 363 <input type="checkbox" name="show_menu_themes" <?php if ($CAUoptions['show_menu_themes']) {print 'checked="checked" ';} ?>/> Show <strong>Appearance</strong> menu entry. 364 </label> 365 </th> 366 </tr> 367 <tr> 368 <th scope="row" colspan="2" class="th-full"> 369 <label> 370 <input type="checkbox" name="show_menu_dashboard" <?php if ($CAUoptions['show_menu_dashboard']) {print 'checked="checked" ';} ?>/> Show <strong>Dashboard</strong> menu entry. 371 </label> 372 </th> 373 </tr> 374 375 </table><!-- form-table --> 376 377 <p class="submit"><input type="submit" class="button-primary" name="submit" value="Save Changes" /></p> 378 259 379 </form> 260 380 261 381 </div><!-- wrap --> 262 382 263 <?php }383 <?php } 264 384 265 385 ?> -
clean-admin-ui/trunk/readme.txt
r412052 r968313 2 2 Tags: admin, menu, cms, ui 3 3 Requires at least: 2.8 4 Tested up to: 3. 2.14 Tested up to: 3.9.2 5 5 Stable tag: trunk 6 6 7 Remove menu elements from the admin menu7 Easy Wordpress Menu, Remove menu items from the admin menu 8 8 9 9 == Description == 10 10 Use this plugin to hide admin menu items like Posts, Comments, Users, etc 11 This makes it easier for your clients to navigate Wordpress, no distractions, leave only those options that are required. 11 12 12 13 == Installation == 13 14 1. Upload the `clean-admin-ui` directory to the `/wp-content/plugins/` directory. 14 2. Activate `Clean Admin UI` through the 'Plugins' menu in WordPress .15 2. Activate `Clean Admin UI` through the 'Plugins' menu in WordPress end select which items to hide. 15 16 16 17 == Changelog == 18 = 1.3 = 19 * Added option to hide plugins, appearance end dashboard (for Wordpress 2.7 and higher) 20 * Database versioning 21 * Better update handling 22 * Updated to comply with Wordpress WP_DEBUG code guidance 17 23 = 1.2 = 18 24 * Removed bug where menu item Pages remained visible
Note: See TracChangeset
for help on using the changeset viewer.