PluginProbe
Adminimize / 1.7.13
Adminimize v1.7.13
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.13, at adminimize.php

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