PluginProbe
Adminimize / 1.7.17
Adminimize v1.7.17
1.11.14 1.11.13 1.11.1 1.11.10 1.11.11 1.11.12 1.11.2 1.11.3 1.11.4 1.11.5 1.11.6 1.11.7 1.11.8 1.11.9 1.3 1.4.7 1.6 1.7.12 1.7.13 1.7.14 1.7.15 1.7.16 1.7.17 1.7.18 1.7.19 All 53 releases
← All changes | adminimize.php +413 -189 1.7.121.7.17 View file →
@@ -1,9 +1,8 @@
1 1 <?php
2 2 /**
3 3 * @package Adminimize
4 4 * @author Frank B&uuml;ltge
5 -
6 5 */
7 6
8 7 /*
9 8 Plugin Name: Adminimize
@@ -12,11 +11,10 @@
12 11 Domain Path: /languages
13 12 Description: Visually compresses the administratrive meta-boxes so that more admin page content can be initially seen. The plugin that lets you hide 'unnecessary' items from the WordPress administration menu, for alle roles of your install. You can also hide post meta controls on the edit-area to simplify the interface. It is possible to simplify the admin in different for all roles.
14 13 Author: Frank B&uuml;ltge
15 14 Author URI: http://bueltge.de/
16 -Version: 1.7.12
17 -License: GNU
18 -Last Update: 02.10.2010 17:15:23
15 +Version: 1.7.17
16 +License: GPL
19 17 */
20 18
21 19 /**
22 20 * The stylesheet and the initial idea is from Eric A. Meyer, http://meyerweb.com/
@@ -30,8 +28,9 @@
30 28 if ( function_exists ('add_action') )
31 29 $exit_msg = 'The plugin <em><a href="http://bueltge.de/wordpress-admin-theme-adminimize/674/">Adminimize</a></em> requires WordPress 2.5 or newer. <a href="http://codex.wordpress.org/Upgrading_WordPress">Please update WordPress</a> or delete the plugin.';
32 30 else
33 31 $exit_msg = '';
32 +
34 33 header('Status: 403 Forbidden');
35 34 header('HTTP/1.1 403 Forbidden');
36 35 exit($exit_msg);
37 36 }
@@ -36,8 +35,9 @@
36 35 exit($exit_msg);
37 36 }
38 37
39 38 if ( function_exists('add_action') ) {
39 +
40 40 // Pre-2.6 compatibility
41 41 if ( !defined( 'WP_CONTENT_URL' ) )
42 42 define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
43 43 if ( !defined( 'WP_CONTENT_DIR' ) )
@@ -54,21 +54,27 @@
54 54 }
55 55
56 56 function _mw_adminimize_textdomain() {
57 57
58 - if ( function_exists('load_plugin_textdomain') )
59 - load_plugin_textdomain( FB_ADMINIMIZE_TEXTDOMAIN, false, dirname( FB_ADMINIMIZE_BASENAME ) . '/languages');
58 + load_plugin_textdomain( FB_ADMINIMIZE_TEXTDOMAIN, FALSE, dirname( FB_ADMINIMIZE_BASENAME ) . '/languages');
60 59 }
61 60
62 61
62 +function _mw_adminimize_register_styles() {
63 +
64 + wp_register_style( 'adminimize-style', plugins_url( 'css/style.css', __FILE__ ) );
65 +}
66 +
67 +
63 68 function recursive_in_array($needle, $haystack) {
64 - if ($haystack != '') {
69 +
70 + if ( '' != $haystack ) {
65 71 foreach ($haystack as $stalk) {
66 72 if ( $needle == $stalk || ( is_array($stalk) && recursive_in_array($needle, $stalk) ) ) {
67 - return true;
73 + return TRUE;
68 74 }
69 75 }
70 - return false;
76 + return FALSE;
71 77 }
72 78 }
73 79
74 80
@@ -75,8 +81,12 @@
75 81 /**
76 82 * some basics for message
77 83 */
78 84 class _mw_adminimize_message_class {
85 +
86 + /**
87 + * constructor
88 + */
79 89 function _mw_adminimize_message_class() {
80 90 $this->localizionName = FB_ADMINIMIZE_TEXTDOMAIN;
81 91 $this->errors = new WP_Error();
82 92 $this->initialize_errors();
@@ -82,21 +92,23 @@
82 92 $this->initialize_errors();
83 93 }
84 94
85 95 /**
86 - get_error - Returns an error message based on the passed code
87 - Parameters - $code (the error code as a string)
88 - Returns an error message
89 - */
96 + * get_error - Returns an error message based on the passed code
97 + * Parameters - $code (the error code as a string)
98 + * @return Returns an error message
99 + */
90 100 function get_error($code = '') {
91 101 $errorMessage = $this->errors->get_error_message($code);
92 - if ($errorMessage == null) {
102 + if ($errorMessage == NULL) {
93 103 return __("Unknown error.", $this->localizionName);
94 104 }
95 105 return $errorMessage;
96 106 }
97 107
98 - // Initializes all the error messages
108 + /**
109 + * Initializes all the error messages
110 + */
99 111 function initialize_errors() {
100 112 $this->errors->add('_mw_adminimize_update', __('The updates were saved.', $this->localizionName));
101 113 $this->errors->add('_mw_adminimize_access_denied', __('You have not enough rights to edit entries in the database.', $this->localizionName));
102 114 $this->errors->add('_mw_adminimize_import', __('All entries in the database were imported.', $this->localizionName));
@@ -108,13 +120,26 @@
108 120 }
109 121 }
110 122
111 123
124 +function _mw_adminimize_exclude_super_admin() {
125 + // exclude super admin
126 + if ( function_exists('is_super_admin')
127 + && is_super_admin()
128 + && 1 == _mw_adminimize_getOptionValue('_mw_adminimize_exclude_super_admin')
129 + )
130 + return TRUE;
131 +
132 + return FALSE;
133 +}
134 +
135 +
112 136 /**
113 137 * get_all_user_roles() - Returns an array with all user roles(names) in it.
114 138 * Inclusive self defined roles (for example with the 'Role Manager' plugin).
115 139 * code by Vincent Weber, www.webRtistik.nl
116 140 * @uses $wp_roles
141 + * @return $user_roles
117 142 */
118 143 function get_all_user_roles() {
119 144 global $wp_roles;
120 145
@@ -134,8 +159,9 @@
134 159 /**
135 160 * get_all_user_roles_names() - Returns an array with all user roles_names in it.
136 161 * Inclusive self defined roles (for example with the 'Role Manager' plugin).
137 162 * @uses $wp_roles
163 + * @return $user_roles_names
138 164 */
139 165 function get_all_user_roles_names() {
140 166 global $wp_roles;
141 167
@@ -145,8 +171,9 @@
145 171 if ( function_exists('translate_user_role') )
146 172 $data = translate_user_role( $data );
147 173 else
148 174 $data = translate_with_context( $data );
175 +
149 176 array_push($user_roles_names, $data );
150 177 }
151 178
152 179 return $user_roles_names;
@@ -151,16 +178,21 @@
151 178
152 179 return $user_roles_names;
153 180 }
154 181
155 -
182 +/**
183 + * Control Flash Uploader
184 + *
185 + * @return boolean
186 + */
156 187 function _mw_adminimize_control_flashloader() {
188 +
157 189 $_mw_adminimize_control_flashloader = _mw_adminimize_getOptionValue('_mw_adminimize_control_flashloader');
158 190
159 191 if ($_mw_adminimize_control_flashloader == '1') {
160 - return false;
192 + return FALSE;
161 193 } else {
162 - return true;
194 + return TRUE;
163 195 }
164 196 }
165 197
166 198
@@ -167,9 +199,9 @@
167 199 /**
168 200 * check user-option and add new style
169 201 * @uses $pagenow
170 202 */
171 -function _mw_adminimize_init() {
203 +function _mw_adminimize_admin_init() {
172 204 global $pagenow, $menu, $submenu, $adminimizeoptions, $wp_version;
173 205
174 206 if ( function_exists('get_post_type_object') ) {
175 207 if ( isset($_GET['post']) )
@@ -178,11 +210,11 @@
178 210 $post_id = (int) $_POST['post_ID'];
179 211 else
180 212 $post_id = 0;
181 213 $post_ID = $post_id;
182 - $post = null;
183 - $post_type_object = null;
184 - $post_type = null;
214 + $post = NULL;
215 + $post_type_object = NULL;
216 + $post_type = NULL;
185 217 if ( $post_id ) {
186 218 $post = get_post($post_id);
187 219 if ( $post ) {
188 220 $post_type_object = get_post_type_object($post->post_type);
@@ -204,16 +236,17 @@
204 236 $post_type = '';
205 237 }
206 238
207 239 $user_roles = get_all_user_roles();
208 -
240 +
209 241 $adminimizeoptions = get_option('mw_adminimize');
210 242
211 243 foreach ($user_roles as $role) {
212 - $disabled_global_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_global_option_'. $role .'_items');
213 - $disabled_metaboxes_post_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_metaboxes_post_'. $role .'_items');
214 - $disabled_metaboxes_page_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_metaboxes_page_'. $role .'_items');
215 - $disabled_link_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_link_option_'. $role .'_items');
244 + $disabled_global_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_global_option_'. $role .'_items');
245 + $disabled_metaboxes_post_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_metaboxes_post_'. $role .'_items');
246 + $disabled_metaboxes_page_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_metaboxes_page_'. $role .'_items');
247 + $disabled_link_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_link_option_'. $role .'_items');
248 + $disabled_nav_menu_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_nav_menu_option_'. $role .'_items');
216 249 }
217 250
218 251 $disabled_metaboxes_post_all = array();
219 252 $disabled_metaboxes_page_all = array();
@@ -225,74 +258,77 @@
225 258
226 259 $_mw_admin_color = get_user_option('admin_color');
227 260
228 261 //global options
229 - $_mw_adminimize_footer = _mw_adminimize_getOptionValue('_mw_adminimize_footer');
230 - switch ($_mw_adminimize_footer) {
231 - case 1:
232 - wp_enqueue_script( '_mw_adminimize_remove_footer', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/remove_footer.js', array('jquery') );
233 - break;
234 - }
235 -
236 - $_mw_adminimize_header = _mw_adminimize_getOptionValue('_mw_adminimize_header');
237 - switch ($_mw_adminimize_header) {
238 - case 1:
239 - wp_enqueue_script( '_mw_adminimize_remove_header', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/remove_header.js', array('jquery') );
240 - break;
241 - }
242 -
243 - //post-page options
244 - $post_page_pages = array('post-new.php', 'post.php', 'page-new.php', 'page.php');
245 - if ( in_array( $pagenow, $post_page_pages ) ) {
246 -
247 - $_mw_adminimize_writescroll = _mw_adminimize_getOptionValue('_mw_adminimize_writescroll');
248 - switch ($_mw_adminimize_writescroll) {
262 + // exclude super admin
263 + if ( ! _mw_adminimize_exclude_super_admin() ) {
264 + $_mw_adminimize_footer = _mw_adminimize_getOptionValue('_mw_adminimize_footer');
265 + switch ($_mw_adminimize_footer) {
249 266 case 1:
250 - wp_enqueue_script( '_mw_adminimize_writescroll', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/writescroll.js', array('jquery') );
267 + wp_enqueue_script( '_mw_adminimize_remove_footer', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/remove_footer.js', array('jquery') );
251 268 break;
252 269 }
253 - $_mw_adminimize_tb_window = _mw_adminimize_getOptionValue('_mw_adminimize_tb_window');
254 - switch ($_mw_adminimize_tb_window) {
270 +
271 + $_mw_adminimize_header = _mw_adminimize_getOptionValue('_mw_adminimize_header');
272 + switch ($_mw_adminimize_header) {
255 273 case 1:
256 - wp_deregister_script('media-upload');
257 - wp_enqueue_script('media-upload', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/tb_window.js', array('thickbox'));
274 + wp_enqueue_script( '_mw_adminimize_remove_header', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/remove_header.js', array('jquery') );
258 275 break;
259 276 }
260 - $_mw_adminimize_timestamp = _mw_adminimize_getOptionValue('_mw_adminimize_timestamp');
261 - switch ($_mw_adminimize_timestamp) {
262 - case 1:
263 - wp_enqueue_script( '_mw_adminimize_timestamp', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/timestamp.js', array('jquery') );
264 - break;
277 +
278 + //post-page options
279 + $post_page_pages = array('post-new.php', 'post.php', 'page-new.php', 'page.php');
280 + if ( in_array( $pagenow, $post_page_pages ) ) {
281 +
282 + $_mw_adminimize_writescroll = _mw_adminimize_getOptionValue('_mw_adminimize_writescroll');
283 + switch ($_mw_adminimize_writescroll) {
284 + case 1:
285 + wp_enqueue_script( '_mw_adminimize_writescroll', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/writescroll.js', array('jquery') );
286 + break;
287 + }
288 + $_mw_adminimize_tb_window = _mw_adminimize_getOptionValue('_mw_adminimize_tb_window');
289 + switch ($_mw_adminimize_tb_window) {
290 + case 1:
291 + wp_deregister_script('media-upload');
292 + wp_enqueue_script('media-upload', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/tb_window.js', array('thickbox'));
293 + break;
294 + }
295 + $_mw_adminimize_timestamp = _mw_adminimize_getOptionValue('_mw_adminimize_timestamp');
296 + switch ($_mw_adminimize_timestamp) {
297 + case 1:
298 + wp_enqueue_script( '_mw_adminimize_timestamp', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/timestamp.js', array('jquery') );
299 + break;
300 + }
301 +
302 + //category options
303 + $_mw_adminimize_cat_full = _mw_adminimize_getOptionValue('_mw_adminimize_cat_full');
304 + switch ($_mw_adminimize_cat_full) {
305 + case 1:
306 + wp_enqueue_style( 'adminimize-ful-category', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/css/mw_cat_full.css' );
307 + break;
308 + }
309 +
310 + // set default editor tinymce
311 + if ( recursive_in_array('#editor-toolbar #edButtonHTML, #quicktags', $disabled_metaboxes_page_all)
312 + || recursive_in_array('#editor-toolbar #edButtonHTML, #quicktags', $disabled_metaboxes_post_all) )
313 + add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );
314 +
315 + // remove media bottons
316 + if ( recursive_in_array('media_buttons', $disabled_metaboxes_page_all)
317 + || recursive_in_array('media_buttons', $disabled_metaboxes_post_all) )
318 + remove_action('media_buttons', 'media_buttons');
319 +
320 + //add_filter('image_downsize', '_mw_adminimize_image_downsize', 1, 3);
265 321 }
266 -
267 - //category options
268 - $_mw_adminimize_cat_full = _mw_adminimize_getOptionValue('_mw_adminimize_cat_full');
269 - switch ($_mw_adminimize_cat_full) {
322 +
323 + $_mw_adminimize_control_flashloader = _mw_adminimize_getOptionValue('_mw_adminimize_control_flashloader');
324 + switch ($_mw_adminimize_control_flashloader) {
270 325 case 1:
271 - wp_enqueue_style( 'adminimize-ful-category', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/css/mw_cat_full.css' );
326 + add_filter( 'flash_uploader', '_mw_adminimize_control_flashloader', 1 );
272 327 break;
273 328 }
274 -
275 - // set default editor tinymce
276 - if ( recursive_in_array('#editor-toolbar #edButtonHTML, #quicktags', $disabled_metaboxes_page_all)
277 - || recursive_in_array('#editor-toolbar #edButtonHTML, #quicktags', $disabled_metaboxes_post_all) )
278 - add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );
279 -
280 - // remove media bottons
281 - if ( recursive_in_array('media_buttons', $disabled_metaboxes_page_all)
282 - || recursive_in_array('media_buttons', $disabled_metaboxes_post_all) )
283 - remove_action('media_buttons', 'media_buttons');
284 -
285 - //add_filter('image_downsize', '_mw_adminimize_image_downsize', 1, 3);
286 329 }
287 330
288 - $_mw_adminimize_control_flashloader = _mw_adminimize_getOptionValue('_mw_adminimize_control_flashloader');
289 - switch ($_mw_adminimize_control_flashloader) {
290 - case 1:
291 - add_filter( 'flash_uploader', '_mw_adminimize_control_flashloader', 1 );
292 - break;
293 - }
294 -
295 331 if ( ($_mw_admin_color == 'mw_fresh') ||
296 332 ($_mw_admin_color == 'mw_classic') ||
297 333 ($_mw_admin_color == 'mw_colorblind') ||
298 334 ($_mw_admin_color == 'mw_grey') ||
@@ -326,19 +362,19 @@
326 362 }
327 363
328 364 // only pages
329 365 if (
330 - ( 'page-new.php' == $pagenow ) ||
331 - ( 'page.php' == $pagenow ) ||
332 - ( 'post_type=page' == esc_attr($_SERVER['QUERY_STRING']) ) ||
333 - ( 'page' == $post_type )
334 - ) {
366 + ( 'page-new.php' == $pagenow ) ||
367 + ( 'page.php' == $pagenow ) ||
368 + ( 'post_type=page' == esc_attr($_SERVER['QUERY_STRING']) ) ||
369 + ( 'page' == $post_type )
370 + ) {
335 371
336 372 // check for array empty
337 373 if ( !isset($disabled_metaboxes_page_['editor']['0']) )
338 374 $disabled_metaboxes_page_['editor']['0'] = '';
339 375 if ( isset($disabled_metaboxes_page_['administrator']['0']) )
340 - $disabled_metaboxes_page_['administrator']['0'] = '';
376 + $disabled_metaboxes_page_['administrator']['0'] = '';
341 377 }
342 378
343 379 }
344 380
@@ -364,8 +400,13 @@
364 400 $link_pages = array('link-manager.php', 'link-add.php', 'edit-link-categories.php');
365 401 if ( in_array( $pagenow, $link_pages ) )
366 402 add_action('admin_head', '_mw_adminimize_set_link_option', 1);
367 403
404 + // set wp nav menu options
405 + $nav_menu_pages = array('nav-menus.php');
406 + if ( in_array( $pagenow, $nav_menu_pages ) )
407 + add_action('admin_head', '_mw_adminimize_set_nav_menu_option', 1);
408 +
368 409 add_action('in_admin_footer', '_mw_adminimize_admin_footer');
369 410
370 411 $adminimizeoptions['mw_adminimize_default_menu'] = $menu;
371 412 $adminimizeoptions['mw_adminimize_default_submenu'] = $submenu;
@@ -370,20 +411,21 @@
370 411 $adminimizeoptions['mw_adminimize_default_menu'] = $menu;
371 412 $adminimizeoptions['mw_adminimize_default_submenu'] = $submenu;
372 413 }
373 414
374 -add_action('init', '_mw_adminimize_textdomain');
375 -if ( is_admin() ) {
376 - add_action('admin_menu', '_mw_adminimize_add_settings_page');
377 - add_action('admin_menu', '_mw_adminimize_remove_dashboard');
378 - add_action('admin_init', '_mw_adminimize_init', 1);
379 - add_action('admin_init', '_mw_adminimize_admin_styles', 1);
380 -}
415 +// on init of WordPress
416 +add_action( 'init', '_mw_adminimize_textdomain' );
417 +add_action( 'init', '_mw_adminimize_register_styles' );
418 +add_action( 'init', '_mw_adminimize_remove_admin_bar' );
381 419
382 -if ( function_exists('register_activation_hook') )
383 - register_activation_hook(__FILE__, '_mw_adminimize_install');
384 -if ( function_exists('register_uninstall_hook') )
385 - register_uninstall_hook(__FILE__, '_mw_adminimize_deinstall');
420 +// on admin init
421 +add_action( 'admin_init', '_mw_adminimize_admin_init', 1 );
422 +add_action( 'admin_menu', '_mw_adminimize_add_settings_page' );
423 +add_action( 'admin_menu', '_mw_adminimize_remove_dashboard' );
424 +add_action( 'admin_init', '_mw_adminimize_admin_styles', 1 );
425 +
426 +register_activation_hook( __FILE__, '_mw_adminimize_install' );
427 +register_uninstall_hook( __FILE__, '_mw_adminimize_deinstall' );
386 428 //register_deactivation_hook(__FILE__, '_mw_adminimize_deinstall');
387 429
388 430
389 431 /**
@@ -391,28 +433,29 @@
391 433 * code by Andrew Rickmann
392 434 * http://www.wp-fun.co.uk/
393 435 * @param $value, $id, $size
394 436 */
395 -function _mw_adminimize_image_downsize($value = false, $id = 0, $size = "medium") {
437 +function _mw_adminimize_image_downsize($value = FALSE, $id = 0, $size = "medium") {
396 438
397 439 if ( !wp_attachment_is_image($id) )
398 - return false;
440 + return FALSE;
399 441
400 442 $img_url = wp_get_attachment_url($id);
443 +
401 444 // Mimic functionality in image_downsize function in wp-includes/media.php
402 445 if ( $intermediate = image_get_intermediate_size($id, $size) ) {
403 - $img_url = str_replace(basename($img_url), $intermediate['file'], $img_url);
404 - }
405 - elseif ( $size == 'thumbnail' ) {
446 + $img_url = str_replace( basename($img_url), $intermediate['file'], $img_url );
447 + } elseif ( $size == 'thumbnail' ) {
406 448 // fall back to the old thumbnail
407 449 if ( $thumb_file = wp_get_attachment_thumb_file() && $info = getimagesize($thumb_file) ) {
408 - $img_url = str_replace(basename($img_url), basename($thumb_file), $img_url);
450 + $img_url = str_replace( basename($img_url), basename($thumb_file), $img_url );
409 451 }
410 452 }
453 +
411 454 if ( $img_url)
412 455 return array($img_url, 0, 0);
413 456
414 - return false;
457 + return FALSE;
415 458 }
416 459
417 460
418 461 /**
@@ -434,9 +477,9 @@
434 477 <p id="category-add" class="wp-hidden-child">
435 478 <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" />
436 479 <?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
437 480 <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
438 - <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
481 + <?php wp_nonce_field( 'add-category', '_ajax_nonce', FALSE ); ?>
439 482 <span id="category-ajax-response"></span>
440 483 </p>
441 484 </div>
442 485 <?php } else { ?>
@@ -442,13 +485,13 @@
442 485 <?php } else { ?>
443 486 <div id="category-adder" class="wp-hidden-children">
444 487 <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
445 488 <p id="category-add" class="wp-hidden-child">
446 - <label class="hidden" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" aria-required="true"/>
489 + <label class="hidden" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" aria-required="TRUE"/>
447 490 <br />
448 491 <label class="hidden" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
449 492 <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
450 - <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
493 + <?php wp_nonce_field( 'add-category', '_ajax_nonce', FALSE ); ?>
451 494 <span id="category-ajax-response"></span>
452 495 </p>
453 496 </div>
454 497 <?php } ?>
@@ -484,8 +527,9 @@
484 527
485 528 if ( function_exists('remove_meta_box') ) {
486 529 if ( !class_exists('SimpleTagsAdmin') )
487 530 remove_meta_box('tagsdiv', 'post', 'normal');
531 +
488 532 remove_meta_box('categorydiv', 'post', 'normal');
489 533 } else {
490 534 $_mw_adminimize_sidecat_admin_head = "\n" . '<script type="text/javascript">' . "\n";
491 535 $_mw_adminimize_sidecat_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#categorydiv\').remove(); });' . "\n";
@@ -505,9 +549,27 @@
505 549 global $wp_version;
506 550
507 551 $_mw_adminimize_path = WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/';
508 552
509 - if ( version_compare( $wp_version, '2.7alpha', '>=' ) ) {
553 + if ( version_compare( $wp_version, '3.0alpha', '>=' ) ) {
554 +
555 + // MW Adminimize Classic Tweak
556 + $styleName = 'Adminimize:' . ' Tweak ' . __('Blue');
557 + wp_admin_css_color (
558 + 'mw_classic_tweak', $styleName, $_mw_adminimize_path . 'mw_classic28_tweak.css',
559 + array('#073447', '#21759b', '#eaf3fa', '#bbd8e7')
560 + );
561 +
562 + // MW Adminimize Fresh Tweak
563 + $styleName = 'Adminimize:' . ' Tweak ' . __('Gray');
564 + wp_admin_css_color (
565 + 'mw_fresh_tweak', $styleName, $_mw_adminimize_path . 'mw_fresh28_tweak.css',
566 + array('#464646', '#6d6d6d', '#f1f1f1', '#dfdfdf')
567 + );
568 +
569 + }
570 +
571 + if ( version_compare( $wp_version, '2.7alpha', '>=' ) && version_compare( $wp_version, '3.0alpha', '<' ) ) {
510 572 // MW Adminimize Classic
511 573 $styleName = 'Adminimize:' . ' ' . __('Blue');
512 574 wp_admin_css_color (
513 575 'mw_classic', $styleName, $_mw_adminimize_path . 'mw_classic27.css',
@@ -548,9 +610,9 @@
548 610 'mw_fresh_tweak', $styleName, $_mw_adminimize_path . 'mw_fresh28_tweak.css',
549 611 array('#464646', '#6d6d6d', '#f1f1f1', '#dfdfdf')
550 612 );
551 613
552 - } else {
614 + } elseif ( version_compare( $wp_version, '2.7alpha', '<' ) ) {
553 615 // MW Adminimize Classic
554 616 $styleName = 'MW Adminimize:' . ' ' . __('Classic');
555 617 wp_admin_css_color (
556 618 'mw_classic', $styleName, $_mw_adminimize_path . 'mw_classic.css',
@@ -638,9 +700,9 @@
638 700 * @author of basic Austin Matzko
639 701 * http://www.ilfilosofo.com/blog/2006/05/24/plugin-remove-the-wordpress-dashboard/
640 702 */
641 703 function _mw_adminimize_remove_dashboard() {
642 - global $menu, $submenu, $user_ID;
704 + global $menu, $submenu, $user_ID, $wp_version;
643 705
644 706 $user_roles = get_all_user_roles();
645 707
646 708 foreach ($user_roles as $role) {
@@ -670,34 +732,40 @@
670 732 }
671 733
672 734 if ( $redirect ) {
673 735 $_mw_adminimize_db_redirect = _mw_adminimize_getOptionValue('_mw_adminimize_db_redirect');
736 + $_mw_adminimize_db_redirect_admin_url = get_option('siteurl') . '/wp-admin/';
674 737 switch ($_mw_adminimize_db_redirect) {
675 738 case 0:
676 - $_mw_adminimize_db_redirect = 'profile.php';
739 + $_mw_adminimize_db_redirect = $_mw_adminimize_db_redirect_admin_url . 'profile.php';
677 740 break;
678 741 case 1:
679 - $_mw_adminimize_db_redirect = 'edit.php';
742 + $_mw_adminimize_db_redirect = $_mw_adminimize_db_redirect_admin_url . 'edit.php';
680 743 break;
681 744 case 2:
682 - $_mw_adminimize_db_redirect = 'edit-pages.php';
745 + $_mw_adminimize_db_redirect = $_mw_adminimize_db_redirect_admin_url . 'edit.php?post_type=page';
683 746 break;
684 747 case 3:
685 - $_mw_adminimize_db_redirect = 'post-new.php';
748 + $_mw_adminimize_db_redirect = $_mw_adminimize_db_redirect_admin_url . 'post-new.php';
686 749 break;
687 750 case 4:
688 - $_mw_adminimize_db_redirect = 'page-new.php';
751 + $_mw_adminimize_db_redirect = $_mw_adminimize_db_redirect_admin_url . 'page-new.php';
689 752 break;
690 753 case 5:
691 - $_mw_adminimize_db_redirect = 'edit-comments.php';
754 + $_mw_adminimize_db_redirect = $_mw_adminimize_db_redirect_admin_url . 'edit-comments.php';
692 755 break;
693 756 case 6:
694 757 $_mw_adminimize_db_redirect = _mw_adminimize_getOptionValue('_mw_adminimize_db_redirect_txt');
695 758 break;
696 759 }
697 -
760 +
761 + // fallback for WP smaller 3.0
762 + if ( version_compare($wp_version, "3.0alpha", "<") && 'edit.php?post_type=page' == $_mw_adminimize_db_redirect )
763 + $_mw_adminimize_db_redirect = 'edit-pages.php';
764 +
698 765 $the_user = new WP_User($user_ID);
699 - reset($menu); $page = key($menu);
766 + reset($menu);
767 + $page = key($menu);
700 768
701 769 while ( (__('Dashboard') != $menu[$page][0]) && next($menu) || (__('Dashboard') != $menu[$page][1]) && next($menu) )
702 770 $page = key($menu);
703 771
@@ -708,9 +776,9 @@
708 776 while ( !$the_user->has_cap($menu[$page][1]) && next($menu) )
709 777 $page = key($menu);
710 778
711 779 if ( preg_match('#wp-admin/?(index.php)?$#', $_SERVER['REQUEST_URI']) ) {
712 - wp_redirect( get_option('siteurl') . '/wp-admin/' . $_mw_adminimize_db_redirect );
780 + wp_redirect( $_mw_adminimize_db_redirect );
713 781 }
714 782 }
715 783 }
716 784 }
@@ -719,9 +787,10 @@
719 787 /**
720 788 * remove the flash_uploader
721 789 */
722 790 function _mw_adminimize_disable_flash_uploader() {
723 - return false;
791 +
792 + return FALSE;
724 793 }
725 794
726 795
727 796 /**
@@ -729,8 +798,12 @@
729 798 */
730 799 function _mw_adminimize_set_menu_option() {
731 800 global $pagenow, $menu, $submenu, $user_identity, $wp_version;
732 801
802 + // exclude super admin
803 + if ( _mw_adminimize_exclude_super_admin() )
804 + return NULL;
805 +
733 806 $user_roles = get_all_user_roles();
734 807
735 808 foreach ($user_roles as $role) {
736 809 $disabled_menu_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_menu_'. $role .'_items');
@@ -741,51 +814,51 @@
741 814 $_mw_adminimize_user_info = _mw_adminimize_getOptionValue('_mw_adminimize_user_info');
742 815 $_mw_adminimize_ui_redirect = _mw_adminimize_getOptionValue('_mw_adminimize_ui_redirect');
743 816
744 817 switch ($_mw_adminimize_user_info) {
745 - case 1:
746 - $_mw_adminimize_admin_head .= '<script type="text/javascript">' . "\n";
747 - $_mw_adminimize_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#user_info\').remove(); });' . "\n";
748 - $_mw_adminimize_admin_head .= '</script>' . "\n";
818 + case 1:
819 + $_mw_adminimize_admin_head .= '<script type="text/javascript">' . "\n";
820 + $_mw_adminimize_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#user_info\').remove(); });' . "\n";
821 + $_mw_adminimize_admin_head .= '</script>' . "\n";
749 822 break;
750 - case 2:
751 - if ( version_compare($wp_version, "3.0alpha", ">=") ) {
752 - $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info30.css" type="text/css" />' . "\n";
753 - } elseif ( version_compare(substr($wp_version, 0, 3), '2.7', '>=') ) {
754 - $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info27.css" type="text/css" />' . "\n";
755 - } else {
756 - $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info.css" type="text/css" />' . "\n";
757 - }
758 - $_mw_adminimize_admin_head .= '<script type="text/javascript">' . "\n";
759 - $_mw_adminimize_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#user_info\').remove();';
760 - if ($_mw_adminimize_ui_redirect == '1') {
761 - $_mw_adminimize_admin_head .= 'jQuery(\'div#wpcontent\').after(\'<div id="small_user_info"><p><a href="' . get_option('siteurl') . wp_nonce_url( ('/wp-login.php?action=logout&amp;redirect_to=') . get_option('siteurl') , 'log-out' ) . '" title="' . __('Log Out') . '">' . __('Log Out') . '</a></p></div>\') });' . "\n";
762 - } else {
763 - $_mw_adminimize_admin_head .= 'jQuery(\'div#wpcontent\').after(\'<div id="small_user_info"><p><a href="' . get_option('siteurl') . wp_nonce_url( ('/wp-login.php?action=logout') , 'log-out' ) . '" title="' . __('Log Out') . '">' . __('Log Out') . '</a></p></div>\') });' . "\n";
764 - }
765 - $_mw_adminimize_admin_head .= '</script>' . "\n";
823 + case 2:
824 + if ( version_compare($wp_version, "3.0alpha", ">=") ) {
825 + $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info30.css" type="text/css" />' . "\n";
826 + } elseif ( version_compare(substr($wp_version, 0, 3), '2.7', '>=') ) {
827 + $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info27.css" type="text/css" />' . "\n";
828 + } else {
829 + $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info.css" type="text/css" />' . "\n";
830 + }
831 + $_mw_adminimize_admin_head .= '<script type="text/javascript">' . "\n";
832 + $_mw_adminimize_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#user_info\').remove();';
833 + if ($_mw_adminimize_ui_redirect == '1') {
834 + $_mw_adminimize_admin_head .= 'jQuery(\'div#wpcontent\').after(\'<div id="small_user_info"><p><a href="' . get_option('siteurl') . wp_nonce_url( ('/wp-login.php?action=logout&amp;redirect_to=') . get_option('siteurl') , 'log-out' ) . '" title="' . __('Log Out') . '">' . __('Log Out') . '</a></p></div>\') });' . "\n";
835 + } else {
836 + $_mw_adminimize_admin_head .= 'jQuery(\'div#wpcontent\').after(\'<div id="small_user_info"><p><a href="' . get_option('siteurl') . wp_nonce_url( ('/wp-login.php?action=logout') , 'log-out' ) . '" title="' . __('Log Out') . '">' . __('Log Out') . '</a></p></div>\') });' . "\n";
837 + }
838 + $_mw_adminimize_admin_head .= '</script>' . "\n";
766 839 break;
767 - case 3:
768 - if ( version_compare($wp_version, "3.0alpha", ">=") ) {
769 - $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info30.css" type="text/css" />' . "\n";
770 - } elseif ( version_compare(substr($wp_version, 0, 3), '2.7', '>=') ) {
771 - $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info27.css" type="text/css" />' . "\n";
772 - } else {
773 - $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info.css" type="text/css" />' . "\n";
774 - }
775 - $_mw_adminimize_admin_head .= '<script type="text/javascript">' . "\n";
776 - $_mw_adminimize_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#user_info\').remove();';
777 - if ($_mw_adminimize_ui_redirect == '1') {
778 - $_mw_adminimize_admin_head .= 'jQuery(\'div#wpcontent\').after(\'<div id="small_user_info"><p><a href="' . get_option('siteurl') . ('/wp-admin/profile.php') . '">' . $user_identity . '</a> | <a href="' . get_option('siteurl') . wp_nonce_url( ('/wp-login.php?action=logout&amp;redirect_to=') . get_option('siteurl'), 'log-out' ) . '" title="' . __('Log Out') . '">' . __('Log Out') . '</a></p></div>\') });' . "\n";
779 - } else {
780 - $_mw_adminimize_admin_head .= 'jQuery(\'div#wpcontent\').after(\'<div id="small_user_info"><p><a href="' . get_option('siteurl') . ('/wp-admin/profile.php') . '">' . $user_identity . '</a> | <a href="' . get_option('siteurl') . wp_nonce_url( ('/wp-login.php?action=logout'), 'log-out' ) . '" title="' . __('Log Out') . '">' . __('Log Out') . '</a></p></div>\') });' . "\n";
781 - }
782 - $_mw_adminimize_admin_head .= '</script>' . "\n";
840 + case 3:
841 + if ( version_compare($wp_version, "3.0alpha", ">=") ) {
842 + $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info30.css" type="text/css" />' . "\n";
843 + } elseif ( version_compare(substr($wp_version, 0, 3), '2.7', '>=') ) {
844 + $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info27.css" type="text/css" />' . "\n";
845 + } else {
846 + $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info.css" type="text/css" />' . "\n";
847 + }
848 + $_mw_adminimize_admin_head .= '<script type="text/javascript">' . "\n";
849 + $_mw_adminimize_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#user_info\').remove();';
850 + if ($_mw_adminimize_ui_redirect == '1') {
851 + $_mw_adminimize_admin_head .= 'jQuery(\'div#wpcontent\').after(\'<div id="small_user_info"><p><a href="' . get_option('siteurl') . ('/wp-admin/profile.php') . '">' . $user_identity . '</a> | <a href="' . get_option('siteurl') . wp_nonce_url( ('/wp-login.php?action=logout&amp;redirect_to=') . get_option('siteurl'), 'log-out' ) . '" title="' . __('Log Out') . '">' . __('Log Out') . '</a></p></div>\') });' . "\n";
852 + } else {
853 + $_mw_adminimize_admin_head .= 'jQuery(\'div#wpcontent\').after(\'<div id="small_user_info"><p><a href="' . get_option('siteurl') . ('/wp-admin/profile.php') . '">' . $user_identity . '</a> | <a href="' . get_option('siteurl') . wp_nonce_url( ('/wp-login.php?action=logout'), 'log-out' ) . '" title="' . __('Log Out') . '">' . __('Log Out') . '</a></p></div>\') });' . "\n";
854 + }
855 + $_mw_adminimize_admin_head .= '</script>' . "\n";
783 856 break;
784 857 }
785 -
858 +
786 859 // set menu
787 - if ($disabled_menu_['editor'] != '') {
860 + if ( '' != $disabled_menu_['editor'] ) {
788 861
789 862 // set admin-menu
790 863 foreach ($user_roles as $role) {
791 864 $user = wp_get_current_user();
@@ -797,26 +870,28 @@
797 870 }
798 871 }
799 872
800 873 // fallback on users.php on all userroles smaller admin
801 - if ( in_array('users.php', $mw_adminimize_menu) )
874 + if ( is_array($mw_adminimize_menu) && in_array('users.php', $mw_adminimize_menu) )
802 875 $mw_adminimize_menu[] = 'profile.php';
803 876
804 - foreach ($menu as $index => $item) {
805 - if ( 'index.php' === $item )
806 - continue;
807 -
808 - if ( isset($mw_adminimize_menu) && in_array($item[2], $mw_adminimize_menu) ) {
809 - unset($menu[$index]);
810 - }
811 -
812 - if ( isset($submenu) && !empty($submenu[$item[2]]) ) {
813 - foreach ($submenu[$item[2]] as $subindex => $subitem) {
814 - if ( isset($mw_adminimize_submenu) && in_array($subitem[2], $mw_adminimize_submenu))
815 - //if ('profile.php' === $subitem[2])
816 - // unset($menu[70]);
817 - unset($submenu[$item[2]][$subindex]);
877 + if ( isset($menu) && !empty($menu) ) {
878 + foreach ($menu as $index => $item) {
879 + if ( 'index.php' === $item )
880 + continue;
881 +
882 + if ( isset($mw_adminimize_menu) && in_array($item[2], $mw_adminimize_menu) ) {
883 + unset($menu[$index]);
818 884 }
885 +
886 + if ( isset($submenu) && !empty($submenu[$item[2]]) ) {
887 + foreach ($submenu[$item[2]] as $subindex => $subitem) {
888 + if ( isset($mw_adminimize_submenu) && in_array($subitem[2], $mw_adminimize_submenu))
889 + //if ('profile.php' === $subitem[2])
890 + // unset($menu[70]);
891 + unset($submenu[$item[2]][$subindex]);
892 + }
893 + }
819 894 }
820 895 }
821 896
822 897 }
@@ -828,9 +903,14 @@
828 903 /**
829 904 * set global options in backend in all areas
830 905 */
831 906 function _mw_adminimize_set_global_option() {
907 + global $_wp_admin_css_colors;
832 908
909 + // exclude super admin
910 + if ( _mw_adminimize_exclude_super_admin() )
911 + return NULL;
912 +
833 913 $user_roles = get_all_user_roles();
834 914
835 915 $_mw_adminimize_admin_head = '';
836 916
@@ -844,8 +924,9 @@
844 924 if ( !isset($disabled_global_option_[$role]['0']) )
845 925 $disabled_global_option_[$role]['0'] = '';
846 926 }
847 927
928 + $remove_adminbar = FALSE;
848 929 // new 1.7.8
849 930 foreach ($user_roles as $role) {
850 931 $user = wp_get_current_user();
851 932 if ( in_array($role, $user->roles) ) {
@@ -850,11 +931,15 @@
850 931 $user = wp_get_current_user();
851 932 if ( in_array($role, $user->roles) ) {
852 933 if ( current_user_can($role) && is_array($disabled_global_option_[$role]) ) {
853 934 $global_options = implode(', ', $disabled_global_option_[$role]);
935 + if ( recursive_in_array('.show-admin-bar', $disabled_global_option_[$role]) )
936 + $remove_adminbar = TRUE;
854 937 }
855 938 }
856 939 }
940 + if ( 0 != strpos($global_options, '#your-profile .form-table fieldset') )
941 + $_wp_admin_css_colors = 0;
857 942 $_mw_adminimize_admin_head .= '<!-- global options -->' . "\n";
858 943 $_mw_adminimize_admin_head .= '<style type="text/css">' . $global_options . ' {display: none !important;}</style>' . "\n";
859 944
860 945 if ($global_options)
@@ -861,13 +946,58 @@
861 946 echo $_mw_adminimize_admin_head;
862 947 }
863 948
864 949
950 +function _mw_adminimize_remove_admin_bar() {
951 +
952 + // exclude super admin
953 + if ( _mw_adminimize_exclude_super_admin() )
954 + return NULL;
955 +
956 + $user_roles = get_all_user_roles();
957 +
958 + foreach ($user_roles as $role) {
959 + $disabled_global_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_global_option_'. $role .'_items');
960 + }
961 +
962 + foreach ($user_roles as $role) {
963 + if ( !isset($disabled_global_option_[$role]['0']) )
964 + $disabled_global_option_[$role]['0'] = '';
965 + }
966 +
967 + $remove_adminbar = FALSE;
968 + // new 1.7.8
969 + foreach ($user_roles as $role) {
970 + $user = wp_get_current_user();
971 + if ( in_array($role, $user->roles) ) {
972 + if ( current_user_can($role) && is_array($disabled_global_option_[$role]) ) {
973 + $global_options = implode(', ', $disabled_global_option_[$role]);
974 + if ( recursive_in_array('.show-admin-bar', $disabled_global_option_[$role]) )
975 + $remove_adminbar = TRUE;
976 + }
977 + }
978 + }
979 +
980 + // for deactivate admin bar
981 + if ( $remove_adminbar ) {
982 + add_filter( 'show_admin_bar', '__return_false' );
983 + wp_deregister_script( 'admin-bar' );
984 + wp_deregister_style( 'admin-bar' );
985 + remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
986 + remove_action( 'wp_head', '_admin_bar_bump_cb' );
987 + }
988 +}
989 +
990 +
865 991 /**
866 992 * set metabox options from database an area post
867 993 */
868 994 function _mw_adminimize_set_metabox_post_option() {
869 995
996 + // exclude super admin
997 + if ( _mw_adminimize_exclude_super_admin() )
998 + return NULL;
999 +
870 1000 $user_roles = get_all_user_roles();
871 1001
872 1002 $_mw_adminimize_admin_head = '';
873 1003
@@ -882,9 +1012,9 @@
882 1012 // new 1.7.8
883 1013 foreach ($user_roles as $role) {
884 1014 $user = wp_get_current_user();
885 1015 if ( in_array($role, $user->roles) ) {
886 - if ( current_user_can($role) && is_array($disabled_metaboxes_post_[$role]) ) {
1016 + if ( current_user_can($role) && isset($disabled_metaboxes_post_[$role]) && is_array($disabled_metaboxes_post_[$role]) ) {
887 1017 $metaboxes = implode(',', $disabled_metaboxes_post_[$role]);
888 1018 }
889 1019 }
890 1020 }
@@ -901,8 +1031,12 @@
901 1031 * set metabox options from database an area page
902 1032 */
903 1033 function _mw_adminimize_set_metabox_page_option() {
904 1034
1035 + // exclude super admin
1036 + if ( _mw_adminimize_exclude_super_admin() )
1037 + return NULL;
1038 +
905 1039 $user_roles = get_all_user_roles();
906 1040
907 1041 $_mw_adminimize_admin_head = '';
908 1042
@@ -936,8 +1070,12 @@
936 1070 * set link options in area Links of Backend
937 1071 */
938 1072 function _mw_adminimize_set_link_option() {
939 1073
1074 + // exclude super admin
1075 + if ( _mw_adminimize_exclude_super_admin() )
1076 + return NULL;
1077 +
940 1078 $user_roles = get_all_user_roles();
941 1079
942 1080 $_mw_adminimize_admin_head = '';
943 1081
@@ -966,9 +1104,49 @@
966 1104 if ($link_options)
967 1105 echo $_mw_adminimize_admin_head;
968 1106 }
969 1107
1108 +/**
1109 + * remove objects on wp nav menu
1110 + */
1111 +function _mw_adminimize_set_nav_menu_option() {
1112 +
1113 + // exclude super admin
1114 + if ( _mw_adminimize_exclude_super_admin() )
1115 + return NULL;
1116 +
1117 + $user_roles = get_all_user_roles();
970 1118
1119 + $_mw_adminimize_admin_head = '';
1120 +
1121 + remove_action('admin_head', 'index_js');
1122 +
1123 + foreach ($user_roles as $role) {
1124 + $disabled_nav_menu_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_nav_menu_option_'. $role .'_items');
1125 + }
1126 +
1127 + foreach ($user_roles as $role) {
1128 + if ( !isset($disabled_nav_menu_option_[$role]['0']) )
1129 + $disabled_nav_menu_option_[$role]['0'] = '';
1130 + }
1131 +
1132 + // new 1.7.8
1133 + foreach ($user_roles as $role) {
1134 + $user = wp_get_current_user();
1135 + if ( in_array($role, $user->roles) ) {
1136 + if ( current_user_can($role) && is_array($disabled_nav_menu_option_[$role]) ) {
1137 + $nav_menu_options = implode(',', $disabled_nav_menu_option_[$role]);
1138 + }
1139 + }
1140 + }
1141 + //remove_meta_box($id, 'nav-menus', 'side');
1142 + $_mw_adminimize_admin_head .= '<style type="text/css">' . $nav_menu_options . ' {display: none !important;}</style>' . "\n";
1143 +
1144 + if ($nav_menu_options)
1145 + echo $_mw_adminimize_admin_head;
1146 +}
1147 +
1148 +
971 1149 /**
972 1150 * small user-info
973 1151 * @uses $post_ID
974 1152 */
@@ -990,10 +1168,12 @@
990 1168 /**
991 1169 * credit in wp-footer
992 1170 */
993 1171 function _mw_adminimize_admin_footer() {
1172 +
994 1173 $plugin_data = get_plugin_data( __FILE__ );
995 1174 $plugin_data['Title'] = $plugin_data['Name'];
1175 +
996 1176 if ( !empty($plugin_data['PluginURI']) && !empty($plugin_data['Name']) )
997 1177 $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="'.__( 'Visit plugin homepage' ).'">' . $plugin_data['Name'] . '</a>';
998 1178
999 1179 if ( basename($_SERVER['REQUEST_URI']) == 'adminimize.php') {
@@ -998,11 +1178,13 @@
998 1178
999 1179 if ( basename($_SERVER['REQUEST_URI']) == 'adminimize.php') {
1000 1180 printf('%1$s ' . __('plugin') . ' | ' . __('Version') . ' <a href="http://wordpress.org/extend/plugins/adminimize/changelog/" title="' . __('History', FB_ADMINIMIZE_TEXTDOMAIN ) . '">%2$s</a> | ' . __('Author') . ' %3$s<br />', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']);
1001 1181 }
1182 +
1002 1183 if ( _mw_adminimize_getOptionValue('_mw_adminimize_advice') == 1 && basename($_SERVER['REQUEST_URI']) != 'adminimize.php' ) {
1003 1184 printf('%1$s ' . __('plugin activate', FB_ADMINIMIZE_TEXTDOMAIN ) . ' | ' . stripslashes( _mw_adminimize_getOptionValue('_mw_adminimize_advice_txt') ) . '<br />', $plugin_data['Title']);
1004 1185 }
1186 +
1005 1187 }
1006 1188
1007 1189
1008 1190 /**
@@ -1016,9 +1198,9 @@
1016 1198 */
1017 1199 function _mw_adminimize_filter_plugin_meta($links, $file) {
1018 1200
1019 1201 /* create link */
1020 - if ( $file == FB_ADMINIMIZE_BASENAME ) {
1202 + if ( FB_ADMINIMIZE_BASENAME == $file ) {
1021 1203 array_unshift(
1022 1204 $links,
1023 1205 sprintf( '<a href="options-general.php?page=%s">%s</a>', FB_ADMINIMIZE_BASENAME, __('Settings') )
1024 1206 );
@@ -1032,8 +1214,9 @@
1032 1214 * Images/ Icons in base64-encoding
1033 1215 * @use function _mw_adminimize_get_resource_url() for display
1034 1216 */
1035 1217 if ( isset($_GET['resource']) && !empty($_GET['resource']) ) {
1218 +
1036 1219 # base64 encoding performed by base64img.php from http://php.holtsmark.no
1037 1220 $resources = array(
1038 1221 'adminimize.gif' =>
1039 1222 'R0lGODlhCwALAKIEAPb29tTU1Kurq5SUlP///wAAAAAAAAAAAC'.
@@ -1045,17 +1228,17 @@
1045 1228
1046 1229 $content = base64_decode($resources[ $_GET['resource'] ]);
1047 1230
1048 1231 $lastMod = filemtime(__FILE__);
1049 - $client = ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false );
1232 + $client = ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : FALSE );
1050 1233 // Checking if the client is validating his cache and if it is current.
1051 1234 if (isset($client) && (strtotime($client) == $lastMod)) {
1052 1235 // Client's cache IS current, so we just respond '304 Not Modified'.
1053 - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', true, 304);
1236 + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', TRUE, 304);
1054 1237 exit;
1055 1238 } else {
1056 1239 // Image not cached or cache outdated, we respond '200 OK' and output the image.
1057 - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', true, 200);
1240 + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', TRUE, 200);
1058 1241 header('Content-Length: '.strlen($content));
1059 1242 header('Content-Type: image/' . substr(strrchr($_GET['resource'], '.'), 1) );
1060 1243 echo $content;
1061 1244 exit;
@@ -1060,8 +1243,9 @@
1060 1243 echo $content;
1061 1244 exit;
1062 1245 }
1063 1246 }
1247 +
1064 1248 }
1065 1249
1066 1250
1067 1251 /**
@@ -1081,8 +1265,9 @@
1081 1265 */
1082 1266 function _mw_adminimize_contextual_help() {
1083 1267
1084 1268 $content = __('<a href="http://wordpress.org/extend/plugins/adminimize/">Documentation</a>', FB_ADMINIMIZE_TEXTDOMAIN );
1269 +
1085 1270 return $content;
1086 1271 }
1087 1272
1088 1273
@@ -1100,18 +1285,23 @@
1100 1285 }
1101 1286 $menutitle .= ' ' . __('Adminimize', FB_ADMINIMIZE_TEXTDOMAIN );
1102 1287
1103 1288 $pagehook = add_submenu_page('options-general.php', __('Adminimize Options', FB_ADMINIMIZE_TEXTDOMAIN ), $menutitle, 'unfiltered_html', __FILE__, '_mw_adminimize_options');
1104 - if ( version_compare( $wp_version, '2.7alpha', '>' ) )
1105 - add_contextual_help( $pagehook, __( '<a href="http://wordpress.org/extend/plugins/adminimize/">Documentation</a>', FB_ADMINIMIZE_TEXTDOMAIN ) );
1106 - else
1107 - add_filter( 'contextual_help', '_mw_adminimize_contextual_help' );
1108 -
1289 + add_action( 'load-' . $pagehook, '_mw_adminimize_on_load_page' );
1109 1290 add_filter( 'plugin_action_links', '_mw_adminimize_filter_plugin_meta', 10, 2 );
1110 1291 }
1292 +
1111 1293 }
1112 1294
1113 1295
1296 +function _mw_adminimize_on_load_page() {
1297 +
1298 + add_filter( 'contextual_help', '_mw_adminimize_contextual_help' );
1299 +
1300 + wp_enqueue_style( 'adminimize-style' );
1301 +}
1302 +
1303 +
1114 1304 /**
1115 1305 * Set theme for users
1116 1306 */
1117 1307 function _mw_adminimize_set_theme() {
@@ -1122,13 +1312,14 @@
1122 1312 $user_ids = $_POST[mw_adminimize_theme_items];
1123 1313 $admin_color = htmlspecialchars( stripslashes( $_POST[_mw_adminimize_set_theme] ) );
1124 1314
1125 1315 if ( !$user_ids )
1126 - return false;
1316 + return FALSE;
1127 1317
1128 1318 foreach( $user_ids as $user_id) {
1129 1319 update_usermeta($user_id, 'admin_color', $admin_color);
1130 1320 }
1321 +
1131 1322 }
1132 1323
1133 1324
1134 1325 /**
@@ -1136,8 +1327,9 @@
1136 1327 */
1137 1328 function _mw_adminimize_getOptionValue($key) {
1138 1329
1139 1330 $adminimizeoptions = get_option('mw_adminimize');
1331 +
1140 1332 if ( isset($adminimizeoptions[$key]) )
1141 1333 return ($adminimizeoptions[$key]);
1142 1334 }
1143 1335
@@ -1172,9 +1364,15 @@
1172 1364 $adminimizeoptions['_mw_adminimize_header'] = strip_tags(stripslashes($_POST['_mw_adminimize_header']));
1173 1365 } else {
1174 1366 $adminimizeoptions['_mw_adminimize_header'] = 0;
1175 1367 }
1176 -
1368 +
1369 + if (isset($_POST['_mw_adminimize_exclude_super_admin'])) {
1370 + $adminimizeoptions['_mw_adminimize_exclude_super_admin'] = strip_tags(stripslashes($_POST['_mw_adminimize_exclude_super_admin']));
1371 + } else {
1372 + $adminimizeoptions['_mw_adminimize_exclude_super_admin'] = 0;
1373 + }
1374 +
1177 1375 if (isset($_POST['_mw_adminimize_writescroll'])) {
1178 1376 $adminimizeoptions['_mw_adminimize_writescroll'] = strip_tags(stripslashes($_POST['_mw_adminimize_writescroll']));
1179 1377 } else {
1180 1378 $adminimizeoptions['_mw_adminimize_writescroll'] = 0;
@@ -1273,8 +1471,15 @@
1273 1471 $adminimizeoptions['mw_adminimize_disabled_link_option_'. $role . '_items'] = $_POST['mw_adminimize_disabled_link_option_'. $role . '_items'];
1274 1472 } else {
1275 1473 $adminimizeoptions['mw_adminimize_disabled_link_option_'. $role . '_items'] = array();
1276 1474 }
1475 +
1476 + // wp nav menu options
1477 + if (isset($_POST['mw_adminimize_disabled_nav_menu_option_'. $role . '_items'])) {
1478 + $adminimizeoptions['mw_adminimize_disabled_nav_menu_option_'. $role . '_items'] = $_POST['mw_adminimize_disabled_nav_menu_option_'. $role . '_items'];
1479 + } else {
1480 + $adminimizeoptions['mw_adminimize_disabled_nav_menu_option_'. $role . '_items'] = array();
1481 + }
1277 1482 }
1278 1483
1279 1484 // own options
1280 1485 if (isset($_POST['_mw_adminimize_own_values'])) {
@@ -1327,8 +1532,21 @@
1327 1532 } else {
1328 1533 $adminimizeoptions['_mw_adminimize_own_link_options'] = 0;
1329 1534 }
1330 1535
1536 + // wp nav menu options
1537 + if (isset($_POST['_mw_adminimize_own_nav_menu_values'])) {
1538 + $adminimizeoptions['_mw_adminimize_own_nav_menu_values'] = stripslashes($_POST['_mw_adminimize_own_nav_menu_values']);
1539 + } else {
1540 + $adminimizeoptions['_mw_adminimize_own_nav_menu_values'] = 0;
1541 + }
1542 +
1543 + if (isset($_POST['_mw_adminimize_own_nav_menu_options'])) {
1544 + $adminimizeoptions['_mw_adminimize_own_nav_menu_options'] = stripslashes($_POST['_mw_adminimize_own_nav_menu_options']);
1545 + } else {
1546 + $adminimizeoptions['_mw_adminimize_own_nav_menu_options'] = 0;
1547 + }
1548 +
1331 1549 // update
1332 1550 update_option('mw_adminimize', $adminimizeoptions);
1333 1551 $adminimizeoptions = get_option('mw_adminimize');
1334 1552
@@ -1382,11 +1600,11 @@
1382 1600 header("Content-Disposition: attachment; filename=" . urlencode($filename));
1383 1601 header("Content-Type: application/force-download");
1384 1602 header("Content-Type: application/octet-stream");
1385 1603 header("Content-Type: application/download");
1386 - header('Content-Type: text/seq; charset=' . get_option('blog_charset'), true);
1604 + header('Content-Type: text/seq; charset=' . get_option('blog_charset'), TRUE);
1387 1605 flush();
1388 -
1606 +
1389 1607 $export_data = mysql_query("SELECT option_value FROM $wpdb->options WHERE option_name = 'mw_adminimize'");
1390 1608 $export_data = mysql_result($export_data, 0);
1391 1609 echo $export_data;
1392 1610 flush();
@@ -1414,12 +1632,18 @@
1414 1632 chmod($str_ziel, 0644);
1415 1633 // SQL import
1416 1634 ini_set('default_socket_timeout', 120);
1417 1635 $import_file = file_get_contents($str_ziel);
1636 +
1418 1637 _mw_adminimize_deinstall();
1419 1638 $import_file = unserialize($import_file);
1639 +
1640 + if ( file_exists($str_ziel) )
1641 + unlink($str_ziel);
1420 1642 update_option('mw_adminimize', $import_file);
1421 - unlink($str_ziel);
1643 + if ( file_exists($str_ziel) )
1644 + unlink($str_ziel);
1645 +
1422 1646 $addreferer = 'true';
1423 1647 }
1424 1648
1425 1649 $myErrors = new _mw_adminimize_message_class();