PluginProbe
Adminimize / 1.8.4
Adminimize v1.8.4
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.8.4, at adminimize.php

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