PluginProbe
Adminimize / 1.7.14
Adminimize v1.7.14
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
adminimize / adminimize.php

adminimize.php in Adminimize 1.7.14, at adminimize.php

1,544 lines 54.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Adminimize
4 * @author Frank B&uuml;ltge
5 */
6
7 /*
8 Plugin Name: Adminimize
9 Plugin URI: http://bueltge.de/wordpress-admin-theme-adminimize/674/
10 Text Domain: adminimize
11 Domain Path: /languages
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.
13 Author: Frank B&uuml;ltge
14 Author URI: http://bueltge.de/
15 Version: 1.7.14
16 License: GPL
17 */
18
19 /**
20 * The stylesheet and the initial idea is from Eric A. Meyer, http://meyerweb.com/
21 * and i have written a plugin with many options on the basis
22 * of differently user-right and a user-friendly range in admin-area.
23 */
24
25
26 global $wp_version;
27 if ( !function_exists ('add_action') || version_compare($wp_version, "2.5alpha", "<") ) {
28 if ( function_exists ('add_action') )
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.';
30 else
31 $exit_msg = '';
32
33 header('Status: 403 Forbidden');
34 header('HTTP/1.1 403 Forbidden');
35 exit($exit_msg);
36 }
37
38 if ( function_exists('add_action') ) {
39
40 // Pre-2.6 compatibility
41 if ( !defined( 'WP_CONTENT_URL' ) )
42 define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
43 if ( !defined( 'WP_CONTENT_DIR' ) )
44 define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
45 if ( !defined( 'WP_PLUGIN_URL' ) )
46 define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
47 if ( !defined( 'WP_PLUGIN_DIR' ) )
48 define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
49
50 // plugin definitions
51 define( 'FB_ADMINIMIZE_BASENAME', plugin_basename( __FILE__ ) );
52 define( 'FB_ADMINIMIZE_BASEFOLDER', plugin_basename( dirname( __FILE__ ) ) );
53 define( 'FB_ADMINIMIZE_TEXTDOMAIN', 'adminimize' );
54 }
55
56 function _mw_adminimize_textdomain() {
57
58 load_plugin_textdomain( FB_ADMINIMIZE_TEXTDOMAIN, FALSE, dirname( FB_ADMINIMIZE_BASENAME ) . '/languages');
59 }
60
61
62 function _mw_adminimize_register_styles() {
63
64 wp_register_style( 'adminimize-style', plugins_url( 'css/style.css', __FILE__ ) );
65 }
66
67
68 function recursive_in_array($needle, $haystack) {
69
70 if ( '' != $haystack ) {
71 foreach ($haystack as $stalk) {
72 if ( $needle == $stalk || ( is_array($stalk) && recursive_in_array($needle, $stalk) ) ) {
73 return TRUE;
74 }
75 }
76 return FALSE;
77 }
78 }
79
80
81 /**
82 * some basics for message
83 */
84 class _mw_adminimize_message_class {
85
86 /**
87 * constructor
88 */
89 function _mw_adminimize_message_class() {
90 $this->localizionName = FB_ADMINIMIZE_TEXTDOMAIN;
91 $this->errors = new WP_Error();
92 $this->initialize_errors();
93 }
94
95 /**
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 */
100 function get_error($code = '') {
101 $errorMessage = $this->errors->get_error_message($code);
102 if ($errorMessage == NULL) {
103 return __("Unknown error.", $this->localizionName);
104 }
105 return $errorMessage;
106 }
107
108 /**
109 * Initializes all the error messages
110 */
111 function initialize_errors() {
112 $this->errors->add('_mw_adminimize_update', __('The updates were saved.', $this->localizionName));
113 $this->errors->add('_mw_adminimize_access_denied', __('You have not enough rights to edit entries in the database.', $this->localizionName));
114 $this->errors->add('_mw_adminimize_import', __('All entries in the database were imported.', $this->localizionName));
115 $this->errors->add('_mw_adminimize_deinstall', __('All entries in the database were deleted.', $this->localizionName));
116 $this->errors->add('_mw_adminimize_deinstall_yes', __('Set the checkbox on deinstall-button.', $this->localizionName));
117 $this->errors->add('_mw_adminimize_get_option', __('Can\'t load menu and submenu.', $this->localizionName));
118 $this->errors->add('_mw_adminimize_set_theme', __('Backend-Theme was activated!', $this->localizionName));
119 $this->errors->add('_mw_adminimize_load_theme', __('Load user data to themes was successful.', $this->localizionName));
120 }
121 }
122
123
124 /**
125 * get_all_user_roles() - Returns an array with all user roles(names) in it.
126 * Inclusive self defined roles (for example with the 'Role Manager' plugin).
127 * code by Vincent Weber, www.webRtistik.nl
128 * @uses $wp_roles
129 * @return $user_roles
130 */
131 function get_all_user_roles() {
132 global $wp_roles;
133
134 $user_roles = array();
135
136 if ( isset($wp_roles->roles) && is_array($wp_roles->roles) ) {
137 foreach ($wp_roles->roles as $role => $data) {
138 array_push($user_roles, $role);
139 //$data contains caps, maybe for later use..
140 }
141 }
142
143 return $user_roles;
144 }
145
146
147 /**
148 * get_all_user_roles_names() - Returns an array with all user roles_names in it.
149 * Inclusive self defined roles (for example with the 'Role Manager' plugin).
150 * @uses $wp_roles
151 * @return $user_roles_names
152 */
153 function get_all_user_roles_names() {
154 global $wp_roles;
155
156 $user_roles_names = array();
157
158 foreach ($wp_roles->role_names as $role_name => $data) {
159 if ( function_exists('translate_user_role') )
160 $data = translate_user_role( $data );
161 else
162 $data = translate_with_context( $data );
163
164 array_push($user_roles_names, $data );
165 }
166
167 return $user_roles_names;
168 }
169
170 /**
171 * Control Flash Uploader
172 *
173 * @return boolean
174 */
175 function _mw_adminimize_control_flashloader() {
176
177 $_mw_adminimize_control_flashloader = _mw_adminimize_getOptionValue('_mw_adminimize_control_flashloader');
178
179 if ($_mw_adminimize_control_flashloader == '1') {
180 return FALSE;
181 } else {
182 return TRUE;
183 }
184 }
185
186
187 /**
188 * check user-option and add new style
189 * @uses $pagenow
190 */
191 function _mw_adminimize_init() {
192 global $pagenow, $menu, $submenu, $adminimizeoptions, $wp_version;
193
194 // exclude super admin
195 if ( defined('WP_DEBUG') && !WP_DEBUG ) {
196 if ( is_super_admin() )
197 return NULL;
198 }
199
200 if ( function_exists('get_post_type_object') ) {
201 if ( isset($_GET['post']) )
202 $post_id = (int) $_GET['post'];
203 elseif ( isset($_POST['post_ID']) )
204 $post_id = (int) $_POST['post_ID'];
205 else
206 $post_id = 0;
207 $post_ID = $post_id;
208 $post = NULL;
209 $post_type_object = NULL;
210 $post_type = NULL;
211 if ( $post_id ) {
212 $post = get_post($post_id);
213 if ( $post ) {
214 $post_type_object = get_post_type_object($post->post_type);
215 if ( $post_type_object ) {
216 $post_type = $post->post_type;
217 $current_screen->post_type = $post->post_type;
218 $current_screen->id = $current_screen->post_type;
219 }
220 }
221 } elseif ( isset($_POST['post_type']) ) {
222 $post_type_object = get_post_type_object($_POST['post_type']);
223 if ( $post_type_object ) {
224 $post_type = $post_type_object->name;
225 $current_screen->post_type = $post_type;
226 $current_screen->id = $current_screen->post_type;
227 }
228 }
229 } else {
230 $post_type = '';
231 }
232
233 $user_roles = get_all_user_roles();
234
235 $adminimizeoptions = get_option('mw_adminimize');
236
237 foreach ($user_roles as $role) {
238 $disabled_global_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_global_option_'. $role .'_items');
239 $disabled_metaboxes_post_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_metaboxes_post_'. $role .'_items');
240 $disabled_metaboxes_page_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_metaboxes_page_'. $role .'_items');
241 $disabled_link_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_link_option_'. $role .'_items');
242 $disabled_nav_menu_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_nav_menu_option_'. $role .'_items');
243 }
244
245 $disabled_metaboxes_post_all = array();
246 $disabled_metaboxes_page_all = array();
247
248 foreach ($user_roles as $role) {
249 array_push($disabled_metaboxes_post_all, $disabled_metaboxes_post_[$role]);
250 array_push($disabled_metaboxes_page_all, $disabled_metaboxes_page_[$role]);
251 }
252
253 $_mw_admin_color = get_user_option('admin_color');
254
255 //global options
256 $_mw_adminimize_footer = _mw_adminimize_getOptionValue('_mw_adminimize_footer');
257 switch ($_mw_adminimize_footer) {
258 case 1:
259 wp_enqueue_script( '_mw_adminimize_remove_footer', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/remove_footer.js', array('jquery') );
260 break;
261 }
262
263 $_mw_adminimize_header = _mw_adminimize_getOptionValue('_mw_adminimize_header');
264 switch ($_mw_adminimize_header) {
265 case 1:
266 wp_enqueue_script( '_mw_adminimize_remove_header', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/remove_header.js', array('jquery') );
267 break;
268 }
269
270 //post-page options
271 $post_page_pages = array('post-new.php', 'post.php', 'page-new.php', 'page.php');
272 if ( in_array( $pagenow, $post_page_pages ) ) {
273
274 $_mw_adminimize_writescroll = _mw_adminimize_getOptionValue('_mw_adminimize_writescroll');
275 switch ($_mw_adminimize_writescroll) {
276 case 1:
277 wp_enqueue_script( '_mw_adminimize_writescroll', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/writescroll.js', array('jquery') );
278 break;
279 }
280 $_mw_adminimize_tb_window = _mw_adminimize_getOptionValue('_mw_adminimize_tb_window');
281 switch ($_mw_adminimize_tb_window) {
282 case 1:
283 wp_deregister_script('media-upload');
284 wp_enqueue_script('media-upload', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/tb_window.js', array('thickbox'));
285 break;
286 }
287 $_mw_adminimize_timestamp = _mw_adminimize_getOptionValue('_mw_adminimize_timestamp');
288 switch ($_mw_adminimize_timestamp) {
289 case 1:
290 wp_enqueue_script( '_mw_adminimize_timestamp', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/timestamp.js', array('jquery') );
291 break;
292 }
293
294 //category options
295 $_mw_adminimize_cat_full = _mw_adminimize_getOptionValue('_mw_adminimize_cat_full');
296 switch ($_mw_adminimize_cat_full) {
297 case 1:
298 wp_enqueue_style( 'adminimize-ful-category', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/css/mw_cat_full.css' );
299 break;
300 }
301
302 // set default editor tinymce
303 if ( recursive_in_array('#editor-toolbar #edButtonHTML, #quicktags', $disabled_metaboxes_page_all)
304 || recursive_in_array('#editor-toolbar #edButtonHTML, #quicktags', $disabled_metaboxes_post_all) )
305 add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );
306
307 // remove media bottons
308 if ( recursive_in_array('media_buttons', $disabled_metaboxes_page_all)
309 || recursive_in_array('media_buttons', $disabled_metaboxes_post_all) )
310 remove_action('media_buttons', 'media_buttons');
311
312 //add_filter('image_downsize', '_mw_adminimize_image_downsize', 1, 3);
313 }
314
315 $_mw_adminimize_control_flashloader = _mw_adminimize_getOptionValue('_mw_adminimize_control_flashloader');
316 switch ($_mw_adminimize_control_flashloader) {
317 case 1:
318 add_filter( 'flash_uploader', '_mw_adminimize_control_flashloader', 1 );
319 break;
320 }
321
322 if ( ($_mw_admin_color == 'mw_fresh') ||
323 ($_mw_admin_color == 'mw_classic') ||
324 ($_mw_admin_color == 'mw_colorblind') ||
325 ($_mw_admin_color == 'mw_grey') ||
326 ($_mw_admin_color == 'mw_fresh_ozh_am') ||
327 ($_mw_admin_color == 'mw_classic_ozh_am') ||
328 ($_mw_admin_color == 'mw_fresh_lm') ||
329 ($_mw_admin_color == 'mw_classic_lm') ||
330 ($_mw_admin_color == 'mw_wp23')
331 ) {
332
333 // only posts
334 if (
335 ( 'post-new.php' == $pagenow ) ||
336 ( 'post.php' == $pagenow ) ||
337 ( 'post' == $post_type )
338 ) {
339 if ( version_compare( substr($wp_version, 0, 3), '2.7', '<' ) )
340 add_action('admin_head', '_mw_adminimize_remove_box', 99);
341
342 // check for array empty
343 if ( !isset($disabled_metaboxes_post_['editor']['0']) )
344 $disabled_metaboxes_post_['editor']['0'] = '';
345 if ( isset($disabled_metaboxes_post_['administrator']['0']) )
346 $disabled_metaboxes_post_['administrator']['0'] = '';
347 if ( version_compare(substr($wp_version, 0, 3), '2.7', '<') ) {
348 if ( !recursive_in_array('#categorydivsb', $disabled_metaboxes_post_all) )
349 add_action('submitpost_box', '_mw_adminimize_sidecat_list_category_box');
350 if ( !recursive_in_array('#tagsdivsb', $disabled_metaboxes_post_all) )
351 add_action('submitpost_box', '_mw_adminimize_sidecat_list_tag_box');
352 }
353 }
354
355 // only pages
356 if (
357 ( 'page-new.php' == $pagenow ) ||
358 ( 'page.php' == $pagenow ) ||
359 ( 'post_type=page' == esc_attr($_SERVER['QUERY_STRING']) ) ||
360 ( 'page' == $post_type )
361 ) {
362
363 // check for array empty
364 if ( !isset($disabled_metaboxes_page_['editor']['0']) )
365 $disabled_metaboxes_page_['editor']['0'] = '';
366 if ( isset($disabled_metaboxes_page_['administrator']['0']) )
367 $disabled_metaboxes_page_['administrator']['0'] = '';
368 }
369
370 }
371
372 // set menu option
373 add_action('admin_head', '_mw_adminimize_set_menu_option', 1);
374
375 // global_options
376 add_action('admin_head', '_mw_adminimize_set_global_option', 1);
377
378 // set metabox post option
379 $post_pages = array('post-new.php', 'post.php', 'post');
380 if ( in_array( $pagenow, $post_pages ) || in_array($post_type, $post_pages) ) {
381 if ( ( esc_attr($_SERVER['QUERY_STRING']) != 'post_type=page' ) && ($post_type != 'page') )
382 add_action('admin_head', '_mw_adminimize_set_metabox_post_option', 1);
383 }
384
385 // set metabox page option
386 $page_pages = array( 'page-new.php', 'page.php', 'post_type=page', 'page' );
387 if ( in_array( $pagenow, $page_pages ) || in_array($post_type, $page_pages) || in_array( esc_attr($_SERVER['QUERY_STRING']), $page_pages) )
388 add_action('admin_head', '_mw_adminimize_set_metabox_page_option', 1);
389
390 // set link option
391 $link_pages = array('link-manager.php', 'link-add.php', 'edit-link-categories.php');
392 if ( in_array( $pagenow, $link_pages ) )
393 add_action('admin_head', '_mw_adminimize_set_link_option', 1);
394
395 // set wp nav menu options
396 $nav_menu_pages = array('nav-menus.php');
397 if ( in_array( $pagenow, $nav_menu_pages ) )
398 add_action('admin_head', '_mw_adminimize_set_nav_menu_option', 1);
399
400 add_action('in_admin_footer', '_mw_adminimize_admin_footer');
401
402 $adminimizeoptions['mw_adminimize_default_menu'] = $menu;
403 $adminimizeoptions['mw_adminimize_default_submenu'] = $submenu;
404 }
405
406 // on init of WordPress
407 add_action( 'init', '_mw_adminimize_textdomain' );
408 add_action( 'init', '_mw_adminimize_register_styles' );
409
410 // on admin init
411 add_action( 'admin_menu', '_mw_adminimize_add_settings_page' );
412 add_action( 'admin_menu', '_mw_adminimize_remove_dashboard' );
413 add_action( 'admin_init', '_mw_adminimize_init', 1 );
414 add_action( 'admin_init', '_mw_adminimize_admin_styles', 1 );
415
416 register_activation_hook( __FILE__, '_mw_adminimize_install' );
417 register_uninstall_hook( __FILE__, '_mw_adminimize_deinstall' );
418 //register_deactivation_hook(__FILE__, '_mw_adminimize_deinstall');
419
420
421 /**
422 * Uses WordPress filter for image_downsize, kill wp-image-dimension
423 * code by Andrew Rickmann
424 * http://www.wp-fun.co.uk/
425 * @param $value, $id, $size
426 */
427 function _mw_adminimize_image_downsize($value = FALSE, $id = 0, $size = "medium") {
428
429 if ( !wp_attachment_is_image($id) )
430 return FALSE;
431
432 $img_url = wp_get_attachment_url($id);
433
434 // Mimic functionality in image_downsize function in wp-includes/media.php
435 if ( $intermediate = image_get_intermediate_size($id, $size) ) {
436 $img_url = str_replace( basename($img_url), $intermediate['file'], $img_url );
437 } elseif ( $size == 'thumbnail' ) {
438 // fall back to the old thumbnail
439 if ( $thumb_file = wp_get_attachment_thumb_file() && $info = getimagesize($thumb_file) ) {
440 $img_url = str_replace( basename($img_url), basename($thumb_file), $img_url );
441 }
442 }
443
444 if ( $img_url)
445 return array($img_url, 0, 0);
446
447 return FALSE;
448 }
449
450
451 /**
452 * list category-box in sidebar
453 * @uses $post_ID
454 */
455 function _mw_adminimize_sidecat_list_category_box() {
456 global $post_ID;
457 ?>
458
459 <div class="inside" id="categorydivsb">
460 <p><strong><?php _e("Categories"); ?></strong></p>
461 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
462 <?php wp_category_checklist($post_ID); ?>
463 </ul>
464 <?php if ( !defined('WP_PLUGIN_DIR') ) { // for wp <2.6 ?>
465 <div id="category-adder" class="wp-hidden-children">
466 <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
467 <p id="category-add" class="wp-hidden-child">
468 <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" />
469 <?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
470 <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
471 <?php wp_nonce_field( 'add-category', '_ajax_nonce', FALSE ); ?>
472 <span id="category-ajax-response"></span>
473 </p>
474 </div>
475 <?php } else { ?>
476 <div id="category-adder" class="wp-hidden-children">
477 <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
478 <p id="category-add" class="wp-hidden-child">
479 <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"/>
480 <br />
481 <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 ) ); ?>
482 <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
483 <?php wp_nonce_field( 'add-category', '_ajax_nonce', FALSE ); ?>
484 <span id="category-ajax-response"></span>
485 </p>
486 </div>
487 <?php } ?>
488 </div>
489 <?php
490 }
491
492
493 /**
494 * list tag-box in sidebar
495 * @uses $post_ID
496 */
497 function _mw_adminimize_sidecat_list_tag_box() {
498 global $post_ID;
499
500 if ( !class_exists('SimpleTagsAdmin') ) {
501 ?>
502 <div class="inside" id="tagsdivsb">
503 <p><strong><?php _e('Tags'); ?></strong></p>
504 <p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit($post_ID); ?>" /></p>
505 <div id="tagchecklist"></div>
506 </div>
507 <?php
508 }
509 }
510
511
512 /**
513 * remove default categorydiv
514 * @echo script
515 */
516 function _mw_adminimize_remove_box() {
517
518 if ( function_exists('remove_meta_box') ) {
519 if ( !class_exists('SimpleTagsAdmin') )
520 remove_meta_box('tagsdiv', 'post', 'normal');
521
522 remove_meta_box('categorydiv', 'post', 'normal');
523 } else {
524 $_mw_adminimize_sidecat_admin_head = "\n" . '<script type="text/javascript">' . "\n";
525 $_mw_adminimize_sidecat_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#categorydiv\').remove(); });' . "\n";
526 $_mw_adminimize_sidecat_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#tagsdiv\').remove(); });' . "\n";
527 $_mw_adminimize_sidecat_admin_head .= '</script>' . "\n";
528
529 echo $_mw_adminimize_sidecat_admin_head;
530 }
531 }
532
533
534 /**
535 * add new adminstyle to usersettings
536 * @param $file
537 */
538 function _mw_adminimize_admin_styles($file) {
539 global $wp_version;
540
541 $_mw_adminimize_path = WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/';
542
543 if ( version_compare( $wp_version, '2.7alpha', '>=' ) ) {
544 // MW Adminimize Classic
545 $styleName = 'Adminimize:' . ' ' . __('Blue');
546 wp_admin_css_color (
547 'mw_classic', $styleName, $_mw_adminimize_path . 'mw_classic27.css',
548 array('#073447', '#21759b', '#eaf3fa', '#bbd8e7')
549 );
550
551 // MW Adminimize Fresh
552 $styleName = 'Adminimize:' . ' ' . __('Gray');
553 wp_admin_css_color (
554 'mw_fresh', $styleName, $_mw_adminimize_path . 'mw_fresh27.css',
555 array('#464646', '#6d6d6d', '#f1f1f1', '#dfdfdf')
556 );
557
558 // MW Adminimize Classic Fixed
559 $styleName = 'Adminimize:' . ' Fixed ' . __('Blue');
560 wp_admin_css_color (
561 'mw_classic_fixed', $styleName, $_mw_adminimize_path . 'mw_classic28_fixed.css',
562 array('#073447', '#21759b', '#eaf3fa', '#bbd8e7')
563 );
564
565 // MW Adminimize Fresh Fixed
566 $styleName = 'Adminimize:' . ' Fixed ' . __('Gray');
567 wp_admin_css_color (
568 'mw_fresh_fixed', $styleName, $_mw_adminimize_path . 'mw_fresh28_fixed.css',
569 array('#464646', '#6d6d6d', '#f1f1f1', '#dfdfdf')
570 );
571
572 // MW Adminimize Classic Tweak
573 $styleName = 'Adminimize:' . ' Tweak ' . __('Blue');
574 wp_admin_css_color (
575 'mw_classic_tweak', $styleName, $_mw_adminimize_path . 'mw_classic28_tweak.css',
576 array('#073447', '#21759b', '#eaf3fa', '#bbd8e7')
577 );
578
579 // MW Adminimize Fresh Tweak
580 $styleName = 'Adminimize:' . ' Tweak ' . __('Gray');
581 wp_admin_css_color (
582 'mw_fresh_tweak', $styleName, $_mw_adminimize_path . 'mw_fresh28_tweak.css',
583 array('#464646', '#6d6d6d', '#f1f1f1', '#dfdfdf')
584 );
585
586 } else {
587 // MW Adminimize Classic
588 $styleName = 'MW Adminimize:' . ' ' . __('Classic');
589 wp_admin_css_color (
590 'mw_classic', $styleName, $_mw_adminimize_path . 'mw_classic.css',
591 array('#07273E', '#14568A', '#D54E21', '#2683AE')
592 );
593
594 // MW Adminimize Fresh
595 $styleName = 'MW Adminimize:' . ' ' . __('Fresh');
596 wp_admin_css_color (
597 'mw_fresh', $styleName, $_mw_adminimize_path . 'mw_fresh.css',
598 array('#464646', '#CEE1EF', '#D54E21', '#2683AE')
599 );
600
601 // MW Adminimize WordPress 2.3
602 $styleName = 'MW Adminimize:' . ' ' . __('WordPress 2.3');
603 wp_admin_css_color (
604 'mw_wp23', $styleName, $_mw_adminimize_path . 'mw_wp23.css',
605 array('#000000', '#14568A', '#448ABD', '#83B4D8')
606 );
607
608 // MW Adminimize Colorblind
609 $styleName = 'MW Adminimize:' . ' ' . __('Maybe i\'m colorblind');
610 wp_admin_css_color (
611 'mw_colorblind', $styleName, $_mw_adminimize_path . 'mw_colorblind.css',
612 array('#FF9419', '#F0720C', '#710001', '#550007', '#CF4529')
613 );
614
615 // MW Adminimize Grey
616 $styleName = 'MW Adminimize:' . ' ' . __('Grey');
617 wp_admin_css_color (
618 'mw_grey', $styleName, $_mw_adminimize_path . 'mw_grey.css',
619 array('#000000', '#787878', '#F0F0F0', '#D8D8D8', '#909090')
620 );
621 }
622 /**
623 * style and changes for plugin Admin Drop Down Menu
624 * by Ozh
625 * http://planetozh.com/blog/my-projects/wordpress-admin-menu-drop-down-css/
626 */
627 if ( function_exists('wp_ozh_adminmenu') ) {
628
629 // MW Adminimize Classic include ozh adminmenu
630 $styleName = 'MW Adminimize inc. Admin Drop Down Menu' . ' ' . __('Classic');
631 wp_admin_css_color (
632 'mw_classic_ozh_am', $styleName, $_mw_adminimize_path . 'mw_classic_ozh_am.css',
633 array('#07273E', '#14568A', '#D54E21', '#2683AE')
634 );
635
636 // MW Adminimize Fresh include ozh adminmenu
637 $styleName = 'MW Adminimize inc. Admin Drop Down Menu' . ' ' . __('Fresh');
638 wp_admin_css_color (
639 'mw_fresh_ozh_am', $styleName, $_mw_adminimize_path . 'mw_fresh_ozh_am.css',
640 array('#464646', '#CEE1EF', '#D54E21', '#2683AE')
641 );
642
643 }
644
645 /**
646 * style and changes for plugin Lighter Menus
647 * by corpodibacco
648 * http://www.italyisfalling.com/lighter-menus
649 */
650 if ( function_exists('lm_build') ) {
651
652 // MW Adminimize Classic include Lighter Menus
653 $styleName = 'MW Adminimize inc. Lighter Menus' . ' ' . __('Classic');
654 wp_admin_css_color (
655 'mw_classic_lm', $styleName, $_mw_adminimize_path . 'mw_classic_lm.css',
656 array('#07273E', '#14568A', '#D54E21', '#2683AE')
657 );
658
659 // MW Adminimize Fresh include Lighter Menus
660 $styleName = 'MW Adminimize inc. Lighter Menus' . ' ' . __('Fresh');
661 wp_admin_css_color (
662 'mw_fresh_lm', $styleName, $_mw_adminimize_path . 'mw_fresh_lm.css',
663 array('#464646', '#CEE1EF', '#D54E21', '#2683AE')
664 );
665
666 }
667 }
668
669
670 /**
671 * remove the dashbord
672 * @author of basic Austin Matzko
673 * http://www.ilfilosofo.com/blog/2006/05/24/plugin-remove-the-wordpress-dashboard/
674 */
675 function _mw_adminimize_remove_dashboard() {
676 global $menu, $submenu, $user_ID, $wp_version;
677
678 // exclude super admin
679 if ( defined('WP_DEBUG') && !WP_DEBUG ) {
680 if ( is_super_admin() )
681 return NULL;
682 }
683
684 $user_roles = get_all_user_roles();
685
686 foreach ($user_roles as $role) {
687 $disabled_menu_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_menu_'. $role .'_items');
688 $disabled_submenu_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_submenu_'. $role .'_items');
689 }
690
691 $disabled_menu_all = array();
692 $disabled_submenu_all = array();
693
694 foreach ($user_roles as $role) {
695 array_push($disabled_menu_all, $disabled_menu_[$role]);
696 array_push($disabled_submenu_all, $disabled_submenu_[$role]);
697 }
698
699 // remove dashboard
700 if ( $disabled_menu_all != '' || $disabled_submenu_all != '' ) {
701
702 foreach ($user_roles as $role) {
703
704 if ( current_user_can($role) ) {
705 if ( recursive_in_array('index.php', $disabled_menu_[$role]) || recursive_in_array('index.php', $disabled_submenu_[$role]) )
706 $redirect = TRUE;
707 else
708 $redirect = FALSE;
709 }
710 }
711
712 if ( $redirect ) {
713 $_mw_adminimize_db_redirect = _mw_adminimize_getOptionValue('_mw_adminimize_db_redirect');
714 switch ($_mw_adminimize_db_redirect) {
715 case 0:
716 $_mw_adminimize_db_redirect = 'profile.php';
717 break;
718 case 1:
719 $_mw_adminimize_db_redirect = 'edit.php';
720 break;
721 case 2:
722 $_mw_adminimize_db_redirect = 'edit.php?post_type=page';
723 break;
724 case 3:
725 $_mw_adminimize_db_redirect = 'post-new.php';
726 break;
727 case 4:
728 $_mw_adminimize_db_redirect = 'page-new.php';
729 break;
730 case 5:
731 $_mw_adminimize_db_redirect = 'edit-comments.php';
732 break;
733 case 6:
734 $_mw_adminimize_db_redirect = _mw_adminimize_getOptionValue('_mw_adminimize_db_redirect_txt');
735 break;
736 }
737
738 // fallback for WP smaller 3.0
739 if ( version_compare($wp_version, "3.0alpha", "<") && 'edit.php?post_type=page' == $_mw_adminimize_db_redirect )
740 $_mw_adminimize_db_redirect = 'edit-pages.php';
741
742 $the_user = new WP_User($user_ID);
743 reset($menu); $page = key($menu);
744
745 while ( (__('Dashboard') != $menu[$page][0]) && next($menu) || (__('Dashboard') != $menu[$page][1]) && next($menu) )
746 $page = key($menu);
747
748 if (__('Dashboard') == $menu[$page][0] || __('Dashboard') == $menu[$page][1])
749 unset($menu[$page]);
750 reset($menu); $page = key($menu);
751
752 while ( !$the_user->has_cap($menu[$page][1]) && next($menu) )
753 $page = key($menu);
754
755 if ( preg_match('#wp-admin/?(index.php)?$#', $_SERVER['REQUEST_URI']) ) {
756 wp_redirect( get_option('siteurl') . '/wp-admin/' . $_mw_adminimize_db_redirect );
757 }
758 }
759 }
760 }
761
762
763 /**
764 * remove the flash_uploader
765 */
766 function _mw_adminimize_disable_flash_uploader() {
767
768 return FALSE;
769 }
770
771
772 /**
773 * set menu options from database
774 */
775 function _mw_adminimize_set_menu_option() {
776 global $pagenow, $menu, $submenu, $user_identity, $wp_version;
777
778 $user_roles = get_all_user_roles();
779
780 foreach ($user_roles as $role) {
781 $disabled_menu_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_menu_'. $role .'_items');
782 $disabled_submenu_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_submenu_'. $role .'_items');
783 }
784
785 $_mw_adminimize_admin_head = "\n";
786 $_mw_adminimize_user_info = _mw_adminimize_getOptionValue('_mw_adminimize_user_info');
787 $_mw_adminimize_ui_redirect = _mw_adminimize_getOptionValue('_mw_adminimize_ui_redirect');
788
789 switch ($_mw_adminimize_user_info) {
790 case 1:
791 $_mw_adminimize_admin_head .= '<script type="text/javascript">' . "\n";
792 $_mw_adminimize_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#user_info\').remove(); });' . "\n";
793 $_mw_adminimize_admin_head .= '</script>' . "\n";
794 break;
795 case 2:
796 if ( version_compare($wp_version, "3.0alpha", ">=") ) {
797 $_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";
798 } elseif ( version_compare(substr($wp_version, 0, 3), '2.7', '>=') ) {
799 $_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";
800 } else {
801 $_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";
802 }
803 $_mw_adminimize_admin_head .= '<script type="text/javascript">' . "\n";
804 $_mw_adminimize_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#user_info\').remove();';
805 if ($_mw_adminimize_ui_redirect == '1') {
806 $_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";
807 } else {
808 $_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";
809 }
810 $_mw_adminimize_admin_head .= '</script>' . "\n";
811 break;
812 case 3:
813 if ( version_compare($wp_version, "3.0alpha", ">=") ) {
814 $_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";
815 } elseif ( version_compare(substr($wp_version, 0, 3), '2.7', '>=') ) {
816 $_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";
817 } else {
818 $_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";
819 }
820 $_mw_adminimize_admin_head .= '<script type="text/javascript">' . "\n";
821 $_mw_adminimize_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#user_info\').remove();';
822 if ($_mw_adminimize_ui_redirect == '1') {
823 $_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";
824 } else {
825 $_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";
826 }
827 $_mw_adminimize_admin_head .= '</script>' . "\n";
828 break;
829 }
830
831 // set menu
832 if ( '' != $disabled_menu_['editor'] ) {
833
834 // set admin-menu
835 foreach ($user_roles as $role) {
836 $user = wp_get_current_user();
837 if ( in_array($role, $user->roles) ) {
838 if ( current_user_can($role) ) {
839 $mw_adminimize_menu = $disabled_menu_[$role];
840 $mw_adminimize_submenu = $disabled_submenu_[$role];
841 }
842 }
843 }
844
845 // fallback on users.php on all userroles smaller admin
846 if ( is_array($mw_adminimize_menu) && in_array('users.php', $mw_adminimize_menu) )
847 $mw_adminimize_menu[] = 'profile.php';
848
849 if ( isset($menu) && !empty($menu) ) {
850 foreach ($menu as $index => $item) {
851 if ( 'index.php' === $item )
852 continue;
853
854 if ( isset($mw_adminimize_menu) && in_array($item[2], $mw_adminimize_menu) ) {
855 unset($menu[$index]);
856 }
857
858 if ( isset($submenu) && !empty($submenu[$item[2]]) ) {
859 foreach ($submenu[$item[2]] as $subindex => $subitem) {
860 if ( isset($mw_adminimize_submenu) && in_array($subitem[2], $mw_adminimize_submenu))
861 //if ('profile.php' === $subitem[2])
862 // unset($menu[70]);
863 unset($submenu[$item[2]][$subindex]);
864 }
865 }
866 }
867 }
868
869 }
870
871 echo $_mw_adminimize_admin_head;
872 }
873
874
875 /**
876 * set global options in backend in all areas
877 */
878 function _mw_adminimize_set_global_option() {
879 global $_wp_admin_css_colors;
880
881 $user_roles = get_all_user_roles();
882
883 $_mw_adminimize_admin_head = '';
884
885 remove_action('admin_head', 'index_js');
886
887 foreach ($user_roles as $role) {
888 $disabled_global_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_global_option_'. $role .'_items');
889 }
890
891 foreach ($user_roles as $role) {
892 if ( !isset($disabled_global_option_[$role]['0']) )
893 $disabled_global_option_[$role]['0'] = '';
894 }
895
896 $remove_adminbar = FALSE;
897 // new 1.7.8
898 foreach ($user_roles as $role) {
899 $user = wp_get_current_user();
900 if ( in_array($role, $user->roles) ) {
901 if ( current_user_can($role) && is_array($disabled_global_option_[$role]) ) {
902 $global_options = implode(', ', $disabled_global_option_[$role]);
903 if ( recursive_in_array('.show-admin-bar', $disabled_global_option_[$role]) )
904 $remove_adminbar = TRUE;
905 }
906 }
907 }
908 if ( 0 != strpos($global_options, '#your-profile .form-table fieldset') )
909 $_wp_admin_css_colors = 0;
910 $_mw_adminimize_admin_head .= '<!-- global options -->' . "\n";
911 $_mw_adminimize_admin_head .= '<style type="text/css">' . $global_options . ' {display: none !important;}</style>' . "\n";
912
913 // for deactivate admin bar
914 if ( $remove_adminbar )
915 add_filter( 'show_admin_bar','__return_false' );
916
917 if ($global_options)
918 echo $_mw_adminimize_admin_head;
919 }
920
921
922 /**
923 * set metabox options from database an area post
924 */
925 function _mw_adminimize_set_metabox_post_option() {
926
927 $user_roles = get_all_user_roles();
928
929 $_mw_adminimize_admin_head = '';
930
931 remove_action('admin_head', 'index_js');
932
933 foreach ($user_roles as $role) {
934 $disabled_metaboxes_post_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_metaboxes_post_'. $role .'_items');
935
936 if ( !isset($disabled_metaboxes_post_[$role]['0']) )
937 $disabled_metaboxes_post_[$role]['0'] = '';
938
939 // new 1.7.8
940 foreach ($user_roles as $role) {
941 $user = wp_get_current_user();
942 if ( in_array($role, $user->roles) ) {
943 if ( current_user_can($role) && isset($disabled_metaboxes_post_[$role]) && is_array($disabled_metaboxes_post_[$role]) ) {
944 $metaboxes = implode(',', $disabled_metaboxes_post_[$role]);
945 }
946 }
947 }
948 }
949
950 $_mw_adminimize_admin_head .= '<style type="text/css">' . $metaboxes . ' {display: none !important;}</style>' . "\n";
951
952 if ($metaboxes)
953 echo $_mw_adminimize_admin_head;
954 }
955
956
957 /**
958 * set metabox options from database an area page
959 */
960 function _mw_adminimize_set_metabox_page_option() {
961
962 $user_roles = get_all_user_roles();
963
964 $_mw_adminimize_admin_head = '';
965
966 remove_action('admin_head', 'index_js');
967
968 foreach ($user_roles as $role) {
969 $disabled_metaboxes_page_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_metaboxes_page_'. $role .'_items');
970
971 if ( !isset($disabled_metaboxes_page_[$role]['0']) )
972 $disabled_metaboxes_page_[$role]['0'] = '';
973
974 // new 1.7.8
975 foreach ($user_roles as $role) {
976 $user = wp_get_current_user();
977 if ( in_array($role, $user->roles) ) {
978 if ( current_user_can($role) && is_array($disabled_metaboxes_page_[$role]) ) {
979 $metaboxes = implode(',', $disabled_metaboxes_page_[$role]);
980 }
981 }
982 }
983 }
984
985 $_mw_adminimize_admin_head .= '<style type="text/css">' . $metaboxes . ' {display: none !important;}</style>' . "\n";
986
987 if ($metaboxes)
988 echo $_mw_adminimize_admin_head;
989 }
990
991
992 /**
993 * set link options in area Links of Backend
994 */
995 function _mw_adminimize_set_link_option() {
996
997 $user_roles = get_all_user_roles();
998
999 $_mw_adminimize_admin_head = '';
1000
1001 remove_action('admin_head', 'index_js');
1002
1003 foreach ($user_roles as $role) {
1004 $disabled_link_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_link_option_'. $role .'_items');
1005 }
1006
1007 foreach ($user_roles as $role) {
1008 if ( !isset($disabled_link_option_[$role]['0']) )
1009 $disabled_link_option_[$role]['0'] = '';
1010 }
1011
1012 // new 1.7.8
1013 foreach ($user_roles as $role) {
1014 $user = wp_get_current_user();
1015 if ( in_array($role, $user->roles) ) {
1016 if ( current_user_can($role) && is_array($disabled_link_option_[$role]) ) {
1017 $link_options = implode(',', $disabled_link_option_[$role]);
1018 }
1019 }
1020 }
1021 $_mw_adminimize_admin_head .= '<style type="text/css">' . $link_options . ' {display: none !important;}</style>' . "\n";
1022
1023 if ($link_options)
1024 echo $_mw_adminimize_admin_head;
1025 }
1026
1027 /**
1028 * remove objects on wp nav menu
1029 */
1030 function _mw_adminimize_set_nav_menu_option() {
1031
1032 $user_roles = get_all_user_roles();
1033
1034 $_mw_adminimize_admin_head = '';
1035
1036 remove_action('admin_head', 'index_js');
1037
1038 foreach ($user_roles as $role) {
1039 $disabled_nav_menu_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_nav_menu_option_'. $role .'_items');
1040 }
1041
1042 foreach ($user_roles as $role) {
1043 if ( !isset($disabled_nav_menu_option_[$role]['0']) )
1044 $disabled_nav_menu_option_[$role]['0'] = '';
1045 }
1046
1047 // new 1.7.8
1048 foreach ($user_roles as $role) {
1049 $user = wp_get_current_user();
1050 if ( in_array($role, $user->roles) ) {
1051 if ( current_user_can($role) && is_array($disabled_nav_menu_option_[$role]) ) {
1052 $nav_menu_options = implode(',', $disabled_nav_menu_option_[$role]);
1053 }
1054 }
1055 }
1056 $_mw_adminimize_admin_head .= '<style type="text/css">' . $nav_menu_options . ' {display: none !important;}</style>' . "\n";
1057
1058 if ($nav_menu_options)
1059 echo $_mw_adminimize_admin_head;
1060 }
1061
1062
1063 /**
1064 * small user-info
1065 * @uses $post_ID
1066 */
1067 function _mw_adminimize_small_user_info() {
1068 ?>
1069 <div id="small_user_info">
1070 <p><a href="<?php echo wp_nonce_url( site_url('wp-login.php?action=logout'), 'log-out' ) ?>" title="<?php _e('Log Out') ?>"><?php _e('Log Out'); ?></a></p>
1071 </div>
1072 <?php
1073 }
1074
1075
1076 /**
1077 * include options-page in wp-admin
1078 */
1079 require_once('adminimize_page.php');
1080
1081
1082 /**
1083 * credit in wp-footer
1084 */
1085 function _mw_adminimize_admin_footer() {
1086
1087 $plugin_data = get_plugin_data( __FILE__ );
1088 $plugin_data['Title'] = $plugin_data['Name'];
1089
1090 if ( !empty($plugin_data['PluginURI']) && !empty($plugin_data['Name']) )
1091 $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="'.__( 'Visit plugin homepage' ).'">' . $plugin_data['Name'] . '</a>';
1092
1093 if ( basename($_SERVER['REQUEST_URI']) == 'adminimize.php') {
1094 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']);
1095 }
1096
1097 if ( _mw_adminimize_getOptionValue('_mw_adminimize_advice') == 1 && basename($_SERVER['REQUEST_URI']) != 'adminimize.php' ) {
1098 printf('%1$s ' . __('plugin activate', FB_ADMINIMIZE_TEXTDOMAIN ) . ' | ' . stripslashes( _mw_adminimize_getOptionValue('_mw_adminimize_advice_txt') ) . '<br />', $plugin_data['Title']);
1099 }
1100
1101 }
1102
1103
1104 /**
1105 * @version WP 2.8
1106 * Add action link(s) to plugins page
1107 *
1108 * @package Secure WordPress
1109 *
1110 * @param $links, $file
1111 * @return $links
1112 */
1113 function _mw_adminimize_filter_plugin_meta($links, $file) {
1114
1115 /* create link */
1116 if ( FB_ADMINIMIZE_BASENAME == $file ) {
1117 array_unshift(
1118 $links,
1119 sprintf( '<a href="options-general.php?page=%s">%s</a>', FB_ADMINIMIZE_BASENAME, __('Settings') )
1120 );
1121 }
1122
1123 return $links;
1124 }
1125
1126
1127 /**
1128 * Images/ Icons in base64-encoding
1129 * @use function _mw_adminimize_get_resource_url() for display
1130 */
1131 if ( isset($_GET['resource']) && !empty($_GET['resource']) ) {
1132
1133 # base64 encoding performed by base64img.php from http://php.holtsmark.no
1134 $resources = array(
1135 'adminimize.gif' =>
1136 'R0lGODlhCwALAKIEAPb29tTU1Kurq5SUlP///wAAAAAAAAAAAC'.
1137 'H5BAEAAAQALAAAAAALAAsAAAMlSErTuw1Ix4a8s4mYgxZbE4wf'.
1138 'OIzkAJqop64nWm7tULHu0+xLAgA7'.
1139 '');
1140
1141 if (array_key_exists($_GET['resource'], $resources)) {
1142
1143 $content = base64_decode($resources[ $_GET['resource'] ]);
1144
1145 $lastMod = filemtime(__FILE__);
1146 $client = ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : FALSE );
1147 // Checking if the client is validating his cache and if it is current.
1148 if (isset($client) && (strtotime($client) == $lastMod)) {
1149 // Client's cache IS current, so we just respond '304 Not Modified'.
1150 header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', TRUE, 304);
1151 exit;
1152 } else {
1153 // Image not cached or cache outdated, we respond '200 OK' and output the image.
1154 header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', TRUE, 200);
1155 header('Content-Length: '.strlen($content));
1156 header('Content-Type: image/' . substr(strrchr($_GET['resource'], '.'), 1) );
1157 echo $content;
1158 exit;
1159 }
1160 }
1161
1162 }
1163
1164
1165 /**
1166 * Display Images/ Icons in base64-encoding
1167 * @return $resourceID
1168 */
1169 function _mw_adminimize_get_resource_url($resourceID) {
1170
1171 return trailingslashit( get_bloginfo('url') ) . '?resource=' . $resourceID;
1172 }
1173
1174
1175 /**
1176 * content of help
1177 *
1178 * @package Secure WordPress
1179 */
1180 function _mw_adminimize_contextual_help() {
1181
1182 $content = __('<a href="http://wordpress.org/extend/plugins/adminimize/">Documentation</a>', FB_ADMINIMIZE_TEXTDOMAIN );
1183
1184 return $content;
1185 }
1186
1187
1188 /**
1189 * settings in plugin-admin-page
1190 */
1191 function _mw_adminimize_add_settings_page() {
1192 global $wp_version;
1193
1194 if ( current_user_can('switch_themes') && function_exists('add_submenu_page') ) {
1195
1196 $menutitle = '';
1197 if ( version_compare( $wp_version, '2.7alpha', '>' ) ) {
1198 $menutitle = '<img src="' . _mw_adminimize_get_resource_url('adminimize.gif') . '" alt="" />';
1199 }
1200 $menutitle .= ' ' . __('Adminimize', FB_ADMINIMIZE_TEXTDOMAIN );
1201
1202 $pagehook = add_submenu_page('options-general.php', __('Adminimize Options', FB_ADMINIMIZE_TEXTDOMAIN ), $menutitle, 'unfiltered_html', __FILE__, '_mw_adminimize_options');
1203 add_action( 'load-' . $pagehook, '_mw_adminimize_on_load_page' );
1204 add_filter( 'plugin_action_links', '_mw_adminimize_filter_plugin_meta', 10, 2 );
1205 }
1206
1207 }
1208
1209
1210 function _mw_adminimize_on_load_page() {
1211
1212 add_filter( 'contextual_help', '_mw_adminimize_contextual_help' );
1213
1214 wp_enqueue_style( 'adminimize-style' );
1215 }
1216
1217
1218 /**
1219 * Set theme for users
1220 */
1221 function _mw_adminimize_set_theme() {
1222
1223 if ( !current_user_can('edit_users') )
1224 wp_die(__('Cheatin&#8217; uh?'));
1225
1226 $user_ids = $_POST[mw_adminimize_theme_items];
1227 $admin_color = htmlspecialchars( stripslashes( $_POST[_mw_adminimize_set_theme] ) );
1228
1229 if ( !$user_ids )
1230 return FALSE;
1231
1232 foreach( $user_ids as $user_id) {
1233 update_usermeta($user_id, 'admin_color', $admin_color);
1234 }
1235
1236 }
1237
1238
1239 /**
1240 * read otpions
1241 */
1242 function _mw_adminimize_getOptionValue($key) {
1243
1244 $adminimizeoptions = get_option('mw_adminimize');
1245
1246 if ( isset($adminimizeoptions[$key]) )
1247 return ($adminimizeoptions[$key]);
1248 }
1249
1250
1251 /**
1252 * Update options in database
1253 */
1254 function _mw_adminimize_update() {
1255 global $menu, $submenu, $adminimizeoptions;
1256
1257 $user_roles = get_all_user_roles();
1258
1259 if (isset($_POST['_mw_adminimize_user_info'])) {
1260 $adminimizeoptions['_mw_adminimize_user_info'] = strip_tags(stripslashes($_POST['_mw_adminimize_user_info']));
1261 } else {
1262 $adminimizeoptions['_mw_adminimize_user_info'] = 0;
1263 }
1264
1265 if (isset($_POST['_mw_adminimize_dashmenu'])) {
1266 $adminimizeoptions['_mw_adminimize_dashmenu'] = strip_tags(stripslashes($_POST['_mw_adminimize_dashmenu']));
1267 } else {
1268 $adminimizeoptions['_mw_adminimize_dashmenu'] = 0;
1269 }
1270
1271 if (isset($_POST['_mw_adminimize_footer'])) {
1272 $adminimizeoptions['_mw_adminimize_footer'] = strip_tags(stripslashes($_POST['_mw_adminimize_footer']));
1273 } else {
1274 $adminimizeoptions['_mw_adminimize_footer'] = 0;
1275 }
1276
1277 if (isset($_POST['_mw_adminimize_header'])) {
1278 $adminimizeoptions['_mw_adminimize_header'] = strip_tags(stripslashes($_POST['_mw_adminimize_header']));
1279 } else {
1280 $adminimizeoptions['_mw_adminimize_header'] = 0;
1281 }
1282
1283 if (isset($_POST['_mw_adminimize_writescroll'])) {
1284 $adminimizeoptions['_mw_adminimize_writescroll'] = strip_tags(stripslashes($_POST['_mw_adminimize_writescroll']));
1285 } else {
1286 $adminimizeoptions['_mw_adminimize_writescroll'] = 0;
1287 }
1288
1289 if (isset($_POST['_mw_adminimize_tb_window'])) {
1290 $adminimizeoptions['_mw_adminimize_tb_window'] = strip_tags(stripslashes($_POST['_mw_adminimize_tb_window']));
1291 } else {
1292 $adminimizeoptions['_mw_adminimize_tb_window'] = 0;
1293 }
1294
1295 if (isset($_POST['_mw_adminimize_cat_full'])) {
1296 $adminimizeoptions['_mw_adminimize_cat_full'] = strip_tags(stripslashes($_POST['_mw_adminimize_cat_full']));
1297 } else {
1298 $adminimizeoptions['_mw_adminimize_cat_full'] = 0;
1299 }
1300
1301 if (isset($_POST['_mw_adminimize_db_redirect'])) {
1302 $adminimizeoptions['_mw_adminimize_db_redirect'] = strip_tags(stripslashes($_POST['_mw_adminimize_db_redirect']));
1303 } else {
1304 $adminimizeoptions['_mw_adminimize_db_redirect'] = 0;
1305 }
1306
1307 if (isset($_POST['_mw_adminimize_ui_redirect'])) {
1308 $adminimizeoptions['_mw_adminimize_ui_redirect'] = strip_tags(stripslashes($_POST['_mw_adminimize_ui_redirect']));
1309 } else {
1310 $adminimizeoptions['_mw_adminimize_ui_redirect'] = 0;
1311 }
1312
1313 if (isset($_POST['_mw_adminimize_advice'])) {
1314 $adminimizeoptions['_mw_adminimize_advice'] = strip_tags(stripslashes($_POST['_mw_adminimize_advice']));
1315 } else {
1316 $adminimizeoptions['_mw_adminimize_advice'] = 0;
1317 }
1318
1319 if (isset($_POST['_mw_adminimize_advice_txt'])) {
1320 $adminimizeoptions['_mw_adminimize_advice_txt'] = stripslashes($_POST['_mw_adminimize_advice_txt']);
1321 } else {
1322 $adminimizeoptions['_mw_adminimize_advice_txt'] = 0;
1323 }
1324
1325 if (isset($_POST['_mw_adminimize_timestamp'])) {
1326 $adminimizeoptions['_mw_adminimize_timestamp'] = strip_tags(stripslashes($_POST['_mw_adminimize_timestamp']));
1327 } else {
1328 $adminimizeoptions['_mw_adminimize_timestamp'] = 0;
1329 }
1330
1331 if (isset($_POST['_mw_adminimize_control_flashloader'])) {
1332 $adminimizeoptions['_mw_adminimize_control_flashloader'] = strip_tags(stripslashes($_POST['_mw_adminimize_control_flashloader']));
1333 } else {
1334 $adminimizeoptions['_mw_adminimize_control_flashloader'] = 0;
1335 }
1336
1337 if (isset($_POST['_mw_adminimize_db_redirect_txt'])) {
1338 $adminimizeoptions['_mw_adminimize_db_redirect_txt'] = stripslashes($_POST['_mw_adminimize_db_redirect_txt']);
1339 } else {
1340 $adminimizeoptions['_mw_adminimize_db_redirect_txt'] = 0;
1341 }
1342
1343 // menu update
1344 foreach ($user_roles as $role) {
1345 if (isset($_POST['mw_adminimize_disabled_menu_'. $role .'_items'])) {
1346 $adminimizeoptions['mw_adminimize_disabled_menu_'. $role .'_items'] = $_POST['mw_adminimize_disabled_menu_'. $role .'_items'];
1347 } else {
1348 $adminimizeoptions['mw_adminimize_disabled_menu_'. $role .'_items'] = array();
1349 }
1350
1351 if (isset($_POST['mw_adminimize_disabled_submenu_'. $role .'_items'])) {
1352 $adminimizeoptions['mw_adminimize_disabled_submenu_'. $role .'_items'] = $_POST['mw_adminimize_disabled_submenu_'. $role .'_items'];
1353 } else {
1354 $adminimizeoptions['mw_adminimize_disabled_submenu_'. $role .'_items'] = array();
1355 }
1356 }
1357
1358 // global_options, metaboxes update
1359 foreach ($user_roles as $role) {
1360 if (isset($_POST['mw_adminimize_disabled_global_option_'. $role . '_items'])) {
1361 $adminimizeoptions['mw_adminimize_disabled_global_option_'. $role . '_items'] = $_POST['mw_adminimize_disabled_global_option_'. $role . '_items'];
1362 } else {
1363 $adminimizeoptions['mw_adminimize_disabled_global_option_'. $role . '_items'] = array();
1364 }
1365
1366 if (isset($_POST['mw_adminimize_disabled_metaboxes_post_'. $role . '_items'])) {
1367 $adminimizeoptions['mw_adminimize_disabled_metaboxes_post_'. $role . '_items'] = $_POST['mw_adminimize_disabled_metaboxes_post_'. $role . '_items'];
1368 } else {
1369 $adminimizeoptions['mw_adminimize_disabled_metaboxes_post_'. $role . '_items'] = array();
1370 }
1371
1372 if (isset($_POST['mw_adminimize_disabled_metaboxes_page_'. $role . '_items'])) {
1373 $adminimizeoptions['mw_adminimize_disabled_metaboxes_page_'. $role . '_items'] = $_POST['mw_adminimize_disabled_metaboxes_page_'. $role . '_items'];
1374 } else {
1375 $adminimizeoptions['mw_adminimize_disabled_metaboxes_page_'. $role . '_items'] = array();
1376 }
1377
1378 if (isset($_POST['mw_adminimize_disabled_link_option_'. $role . '_items'])) {
1379 $adminimizeoptions['mw_adminimize_disabled_link_option_'. $role . '_items'] = $_POST['mw_adminimize_disabled_link_option_'. $role . '_items'];
1380 } else {
1381 $adminimizeoptions['mw_adminimize_disabled_link_option_'. $role . '_items'] = array();
1382 }
1383
1384 // wp nav menu options
1385 if (isset($_POST['mw_adminimize_disabled_nav_menu_option_'. $role . '_items'])) {
1386 $adminimizeoptions['mw_adminimize_disabled_nav_menu_option_'. $role . '_items'] = $_POST['mw_adminimize_disabled_nav_menu_option_'. $role . '_items'];
1387 } else {
1388 $adminimizeoptions['mw_adminimize_disabled_nav_menu_option_'. $role . '_items'] = array();
1389 }
1390 }
1391
1392 // own options
1393 if (isset($_POST['_mw_adminimize_own_values'])) {
1394 $adminimizeoptions['_mw_adminimize_own_values'] = stripslashes($_POST['_mw_adminimize_own_values']);
1395 } else {
1396 $adminimizeoptions['_mw_adminimize_own_values'] = 0;
1397 }
1398
1399 if (isset($_POST['_mw_adminimize_own_options'])) {
1400 $adminimizeoptions['_mw_adminimize_own_options'] = stripslashes($_POST['_mw_adminimize_own_options']);
1401 } else {
1402 $adminimizeoptions['_mw_adminimize_own_options'] = 0;
1403 }
1404
1405 // own post options
1406 if (isset($_POST['_mw_adminimize_own_post_values'])) {
1407 $adminimizeoptions['_mw_adminimize_own_post_values'] = stripslashes($_POST['_mw_adminimize_own_post_values']);
1408 } else {
1409 $adminimizeoptions['_mw_adminimize_own_post_values'] = 0;
1410 }
1411
1412 if (isset($_POST['_mw_adminimize_own_post_options'])) {
1413 $adminimizeoptions['_mw_adminimize_own_post_options'] = stripslashes($_POST['_mw_adminimize_own_post_options']);
1414 } else {
1415 $adminimizeoptions['_mw_adminimize_own_post_options'] = 0;
1416 }
1417
1418 // own page options
1419 if (isset($_POST['_mw_adminimize_own_page_values'])) {
1420 $adminimizeoptions['_mw_adminimize_own_page_values'] = stripslashes($_POST['_mw_adminimize_own_page_values']);
1421 } else {
1422 $adminimizeoptions['_mw_adminimize_own_page_values'] = 0;
1423 }
1424
1425 if (isset($_POST['_mw_adminimize_own_page_options'])) {
1426 $adminimizeoptions['_mw_adminimize_own_page_options'] = stripslashes($_POST['_mw_adminimize_own_page_options']);
1427 } else {
1428 $adminimizeoptions['_mw_adminimize_own_page_options'] = 0;
1429 }
1430
1431 // own link options
1432 if (isset($_POST['_mw_adminimize_own_link_values'])) {
1433 $adminimizeoptions['_mw_adminimize_own_link_values'] = stripslashes($_POST['_mw_adminimize_own_link_values']);
1434 } else {
1435 $adminimizeoptions['_mw_adminimize_own_link_values'] = 0;
1436 }
1437
1438 if (isset($_POST['_mw_adminimize_own_link_options'])) {
1439 $adminimizeoptions['_mw_adminimize_own_link_options'] = stripslashes($_POST['_mw_adminimize_own_link_options']);
1440 } else {
1441 $adminimizeoptions['_mw_adminimize_own_link_options'] = 0;
1442 }
1443
1444 // update
1445 update_option('mw_adminimize', $adminimizeoptions);
1446 $adminimizeoptions = get_option('mw_adminimize');
1447
1448 $myErrors = new _mw_adminimize_message_class();
1449 $myErrors = '<div id="message" class="updated fade"><p>' . $myErrors->get_error('_mw_adminimize_update') . '</p></div>';
1450 echo $myErrors;
1451 }
1452
1453
1454 /**
1455 * Delete options in database
1456 */
1457 function _mw_adminimize_deinstall() {
1458
1459 delete_option('mw_adminimize');
1460 }
1461
1462
1463 /**
1464 * Install options in database
1465 */
1466 function _mw_adminimize_install() {
1467 global $menu, $submenu;
1468
1469 $user_roles = get_all_user_roles();
1470 $adminimizeoptions = array();
1471
1472 foreach ($user_roles as $role) {
1473 $adminimizeoptions['mw_adminimize_disabled_menu_'. $role .'_items'] = array();
1474 $adminimizeoptions['mw_adminimize_disabled_submenu_'. $role .'_items'] = array();
1475 $adminimizeoptions['mw_adminimize_disabled_global_option_'. $role .'_items'] = array();
1476 $adminimizeoptions['mw_adminimize_disabled_metaboxes_post_'. $role .'_items'] = array();
1477 $adminimizeoptions['mw_adminimize_disabled_metaboxes_page_'. $role .'_items'] = array();
1478 }
1479
1480 $adminimizeoptions['mw_adminimize_default_menu'] = $menu;
1481 $adminimizeoptions['mw_adminimize_default_submenu'] = $submenu;
1482
1483 add_option('mw_adminimize', $adminimizeoptions);
1484 }
1485
1486 /**
1487 * export options in file
1488 */
1489 function _mw_adminimize_export() {
1490 global $wpdb;
1491
1492 $filename = 'adminimize_export-' . date('Y-m-d_G-i-s') . '.seq';
1493
1494 header("Content-Description: File Transfer");
1495 header("Content-Disposition: attachment; filename=" . urlencode($filename));
1496 header("Content-Type: application/force-download");
1497 header("Content-Type: application/octet-stream");
1498 header("Content-Type: application/download");
1499 header('Content-Type: text/seq; charset=' . get_option('blog_charset'), TRUE);
1500 flush();
1501
1502 $export_data = mysql_query("SELECT option_value FROM $wpdb->options WHERE option_name = 'mw_adminimize'");
1503 $export_data = mysql_result($export_data, 0);
1504 echo $export_data;
1505 flush();
1506 }
1507
1508 /**
1509 * import options in table _options
1510 */
1511 function _mw_adminimize_import() {
1512
1513 // check file extension
1514 $str_file_name = $_FILES['datei']['name'];
1515 $str_file_ext = explode(".", $str_file_name);
1516
1517 if ($str_file_ext[1] != 'seq') {
1518 $addreferer = 'notexist';
1519 } elseif (file_exists($_FILES['datei']['name'])) {
1520 $addreferer = 'exist';
1521 } else {
1522 // path for file
1523 $str_ziel = WP_CONTENT_DIR . '/' . $_FILES['datei']['name'];
1524 // transfer
1525 move_uploaded_file($_FILES['datei']['tmp_name'], $str_ziel);
1526 // access authorisation
1527 chmod($str_ziel, 0644);
1528 // SQL import
1529 ini_set('default_socket_timeout', 120);
1530 $import_file = file_get_contents($str_ziel);
1531 _mw_adminimize_deinstall();
1532 $import_file = unserialize($import_file);
1533 update_option('mw_adminimize', $import_file);
1534 unlink($str_ziel);
1535 $addreferer = 'true';
1536 }
1537
1538 $myErrors = new _mw_adminimize_message_class();
1539 $myErrors = '<div id="message" class="updated fade"><p>' . $myErrors->get_error('_mw_adminimize_import') . '</p></div>';
1540 echo $myErrors;
1541 }
1542
1543 ?>
1544