PluginProbe
Adminimize / 1.7.17
Adminimize v1.7.17
1.11.14 1.11.13 1.11.1 1.11.10 1.11.11 1.11.12 1.11.2 1.11.3 1.11.4 1.11.5 1.11.6 1.11.7 1.11.8 1.11.9 1.3 1.4.7 1.6 1.7.12 1.7.13 1.7.14 1.7.15 1.7.16 1.7.17 1.7.18 1.7.19 All 53 releases
adminimize / adminimize.php

adminimize.php in Adminimize 1.7.17, at adminimize.php

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