PluginProbe
Adminimize / 1.7.12
Adminimize v1.7.12
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.12, at adminimize.php

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