| @@ -11,9 +11,9 @@ | ||
| 11 | 11 | Domain Path: /languages |
| 12 | 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 | 13 | Author: Frank Bültge |
| 14 | 14 | Author URI: http://bueltge.de/ |
| 15 | -Version: 1.7.13 | |
| 15 | +Version: 1.7.17 | |
| 16 | 16 | License: GPL |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | /** |
| @@ -28,8 +28,9 @@ | ||
| 28 | 28 | if ( function_exists ('add_action') ) |
| 29 | 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 | 30 | else |
| 31 | 31 | $exit_msg = ''; |
| 32 | + | |
| 32 | 33 | header('Status: 403 Forbidden'); |
| 33 | 34 | header('HTTP/1.1 403 Forbidden'); |
| 34 | 35 | exit($exit_msg); |
| 35 | 36 | } |
| @@ -34,8 +35,9 @@ | ||
| 34 | 35 | exit($exit_msg); |
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | if ( function_exists('add_action') ) { |
| 39 | + | |
| 38 | 40 | // Pre-2.6 compatibility |
| 39 | 41 | if ( !defined( 'WP_CONTENT_URL' ) ) |
| 40 | 42 | define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); |
| 41 | 43 | if ( !defined( 'WP_CONTENT_DIR' ) ) |
| @@ -52,26 +54,27 @@ | ||
| 52 | 54 | } |
| 53 | 55 | |
| 54 | 56 | function _mw_adminimize_textdomain() { |
| 55 | 57 | |
| 56 | - if ( function_exists('load_plugin_textdomain') ) | |
| 57 | - load_plugin_textdomain( FB_ADMINIMIZE_TEXTDOMAIN, false, dirname( FB_ADMINIMIZE_BASENAME ) . '/languages'); | |
| 58 | + load_plugin_textdomain( FB_ADMINIMIZE_TEXTDOMAIN, FALSE, dirname( FB_ADMINIMIZE_BASENAME ) . '/languages'); | |
| 58 | 59 | } |
| 59 | 60 | |
| 60 | 61 | |
| 61 | 62 | function _mw_adminimize_register_styles() { |
| 63 | + | |
| 62 | 64 | wp_register_style( 'adminimize-style', plugins_url( 'css/style.css', __FILE__ ) ); |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | 67 | |
| 66 | 68 | function recursive_in_array($needle, $haystack) { |
| 67 | - if ($haystack != '') { | |
| 69 | + | |
| 70 | + if ( '' != $haystack ) { | |
| 68 | 71 | foreach ($haystack as $stalk) { |
| 69 | 72 | if ( $needle == $stalk || ( is_array($stalk) && recursive_in_array($needle, $stalk) ) ) { |
| 70 | - return true; | |
| 73 | + return TRUE; | |
| 71 | 74 | } |
| 72 | 75 | } |
| 73 | - return false; | |
| 76 | + return FALSE; | |
| 74 | 77 | } |
| 75 | 78 | } |
| 76 | 79 | |
| 77 | 80 | |
| @@ -78,8 +81,12 @@ | ||
| 78 | 81 | /** |
| 79 | 82 | * some basics for message |
| 80 | 83 | */ |
| 81 | 84 | class _mw_adminimize_message_class { |
| 85 | + | |
| 86 | + /** | |
| 87 | + * constructor | |
| 88 | + */ | |
| 82 | 89 | function _mw_adminimize_message_class() { |
| 83 | 90 | $this->localizionName = FB_ADMINIMIZE_TEXTDOMAIN; |
| 84 | 91 | $this->errors = new WP_Error(); |
| 85 | 92 | $this->initialize_errors(); |
| @@ -85,21 +92,23 @@ | ||
| 85 | 92 | $this->initialize_errors(); |
| 86 | 93 | } |
| 87 | 94 | |
| 88 | 95 | /** |
| 89 | - get_error - Returns an error message based on the passed code | |
| 90 | - Parameters - $code (the error code as a string) | |
| 91 | - Returns an error message | |
| 92 | - */ | |
| 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 | + */ | |
| 93 | 100 | function get_error($code = '') { |
| 94 | 101 | $errorMessage = $this->errors->get_error_message($code); |
| 95 | - if ($errorMessage == null) { | |
| 102 | + if ($errorMessage == NULL) { | |
| 96 | 103 | return __("Unknown error.", $this->localizionName); |
| 97 | 104 | } |
| 98 | 105 | return $errorMessage; |
| 99 | 106 | } |
| 100 | 107 | |
| 101 | - // Initializes all the error messages | |
| 108 | + /** | |
| 109 | + * Initializes all the error messages | |
| 110 | + */ | |
| 102 | 111 | function initialize_errors() { |
| 103 | 112 | $this->errors->add('_mw_adminimize_update', __('The updates were saved.', $this->localizionName)); |
| 104 | 113 | $this->errors->add('_mw_adminimize_access_denied', __('You have not enough rights to edit entries in the database.', $this->localizionName)); |
| 105 | 114 | $this->errors->add('_mw_adminimize_import', __('All entries in the database were imported.', $this->localizionName)); |
| @@ -111,13 +120,26 @@ | ||
| 111 | 120 | } |
| 112 | 121 | } |
| 113 | 122 | |
| 114 | 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 | + | |
| 115 | 136 | /** |
| 116 | 137 | * get_all_user_roles() - Returns an array with all user roles(names) in it. |
| 117 | 138 | * Inclusive self defined roles (for example with the 'Role Manager' plugin). |
| 118 | 139 | * code by Vincent Weber, www.webRtistik.nl |
| 119 | 140 | * @uses $wp_roles |
| 141 | + * @return $user_roles | |
| 120 | 142 | */ |
| 121 | 143 | function get_all_user_roles() { |
| 122 | 144 | global $wp_roles; |
| 123 | 145 | |
| @@ -137,8 +159,9 @@ | ||
| 137 | 159 | /** |
| 138 | 160 | * get_all_user_roles_names() - Returns an array with all user roles_names in it. |
| 139 | 161 | * Inclusive self defined roles (for example with the 'Role Manager' plugin). |
| 140 | 162 | * @uses $wp_roles |
| 163 | + * @return $user_roles_names | |
| 141 | 164 | */ |
| 142 | 165 | function get_all_user_roles_names() { |
| 143 | 166 | global $wp_roles; |
| 144 | 167 | |
| @@ -148,8 +171,9 @@ | ||
| 148 | 171 | if ( function_exists('translate_user_role') ) |
| 149 | 172 | $data = translate_user_role( $data ); |
| 150 | 173 | else |
| 151 | 174 | $data = translate_with_context( $data ); |
| 175 | + | |
| 152 | 176 | array_push($user_roles_names, $data ); |
| 153 | 177 | } |
| 154 | 178 | |
| 155 | 179 | return $user_roles_names; |
| @@ -154,16 +178,21 @@ | ||
| 154 | 178 | |
| 155 | 179 | return $user_roles_names; |
| 156 | 180 | } |
| 157 | 181 | |
| 158 | - | |
| 182 | +/** | |
| 183 | + * Control Flash Uploader | |
| 184 | + * | |
| 185 | + * @return boolean | |
| 186 | + */ | |
| 159 | 187 | function _mw_adminimize_control_flashloader() { |
| 188 | + | |
| 160 | 189 | $_mw_adminimize_control_flashloader = _mw_adminimize_getOptionValue('_mw_adminimize_control_flashloader'); |
| 161 | 190 | |
| 162 | 191 | if ($_mw_adminimize_control_flashloader == '1') { |
| 163 | - return false; | |
| 192 | + return FALSE; | |
| 164 | 193 | } else { |
| 165 | - return true; | |
| 194 | + return TRUE; | |
| 166 | 195 | } |
| 167 | 196 | } |
| 168 | 197 | |
| 169 | 198 | |
| @@ -170,17 +199,11 @@ | ||
| 170 | 199 | /** |
| 171 | 200 | * check user-option and add new style |
| 172 | 201 | * @uses $pagenow |
| 173 | 202 | */ |
| 174 | -function _mw_adminimize_init() { | |
| 203 | +function _mw_adminimize_admin_init() { | |
| 175 | 204 | global $pagenow, $menu, $submenu, $adminimizeoptions, $wp_version; |
| 176 | 205 | |
| 177 | - // exclude super admin | |
| 178 | - if ( defined('WP_DEBUG') && !WP_DEBUG ) { | |
| 179 | - if ( is_super_admin() ) | |
| 180 | - return NULL; | |
| 181 | - } | |
| 182 | - | |
| 183 | 206 | if ( function_exists('get_post_type_object') ) { |
| 184 | 207 | if ( isset($_GET['post']) ) |
| 185 | 208 | $post_id = (int) $_GET['post']; |
| 186 | 209 | elseif ( isset($_POST['post_ID']) ) |
| @@ -187,11 +210,11 @@ | ||
| 187 | 210 | $post_id = (int) $_POST['post_ID']; |
| 188 | 211 | else |
| 189 | 212 | $post_id = 0; |
| 190 | 213 | $post_ID = $post_id; |
| 191 | - $post = null; | |
| 192 | - $post_type_object = null; | |
| 193 | - $post_type = null; | |
| 214 | + $post = NULL; | |
| 215 | + $post_type_object = NULL; | |
| 216 | + $post_type = NULL; | |
| 194 | 217 | if ( $post_id ) { |
| 195 | 218 | $post = get_post($post_id); |
| 196 | 219 | if ( $post ) { |
| 197 | 220 | $post_type_object = get_post_type_object($post->post_type); |
| @@ -213,17 +236,17 @@ | ||
| 213 | 236 | $post_type = ''; |
| 214 | 237 | } |
| 215 | 238 | |
| 216 | 239 | $user_roles = get_all_user_roles(); |
| 217 | - | |
| 240 | + | |
| 218 | 241 | $adminimizeoptions = get_option('mw_adminimize'); |
| 219 | 242 | |
| 220 | 243 | foreach ($user_roles as $role) { |
| 221 | - $disabled_global_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_global_option_'. $role .'_items'); | |
| 222 | - $disabled_metaboxes_post_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_metaboxes_post_'. $role .'_items'); | |
| 223 | - $disabled_metaboxes_page_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_metaboxes_page_'. $role .'_items'); | |
| 224 | - $disabled_link_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_link_option_'. $role .'_items'); | |
| 225 | - $disabled_nav_menu_option_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_nav_menu_option_'. $role .'_items'); | |
| 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'); | |
| 226 | 249 | } |
| 227 | 250 | |
| 228 | 251 | $disabled_metaboxes_post_all = array(); |
| 229 | 252 | $disabled_metaboxes_page_all = array(); |
| @@ -235,74 +258,77 @@ | ||
| 235 | 258 | |
| 236 | 259 | $_mw_admin_color = get_user_option('admin_color'); |
| 237 | 260 | |
| 238 | 261 | //global options |
| 239 | - $_mw_adminimize_footer = _mw_adminimize_getOptionValue('_mw_adminimize_footer'); | |
| 240 | - switch ($_mw_adminimize_footer) { | |
| 241 | - case 1: | |
| 242 | - wp_enqueue_script( '_mw_adminimize_remove_footer', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/remove_footer.js', array('jquery') ); | |
| 243 | - break; | |
| 244 | - } | |
| 245 | - | |
| 246 | - $_mw_adminimize_header = _mw_adminimize_getOptionValue('_mw_adminimize_header'); | |
| 247 | - switch ($_mw_adminimize_header) { | |
| 248 | - case 1: | |
| 249 | - wp_enqueue_script( '_mw_adminimize_remove_header', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/remove_header.js', array('jquery') ); | |
| 250 | - break; | |
| 251 | - } | |
| 252 | - | |
| 253 | - //post-page options | |
| 254 | - $post_page_pages = array('post-new.php', 'post.php', 'page-new.php', 'page.php'); | |
| 255 | - if ( in_array( $pagenow, $post_page_pages ) ) { | |
| 256 | - | |
| 257 | - $_mw_adminimize_writescroll = _mw_adminimize_getOptionValue('_mw_adminimize_writescroll'); | |
| 258 | - switch ($_mw_adminimize_writescroll) { | |
| 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) { | |
| 259 | 266 | case 1: |
| 260 | - wp_enqueue_script( '_mw_adminimize_writescroll', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/writescroll.js', array('jquery') ); | |
| 267 | + wp_enqueue_script( '_mw_adminimize_remove_footer', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/remove_footer.js', array('jquery') ); | |
| 261 | 268 | break; |
| 262 | 269 | } |
| 263 | - $_mw_adminimize_tb_window = _mw_adminimize_getOptionValue('_mw_adminimize_tb_window'); | |
| 264 | - switch ($_mw_adminimize_tb_window) { | |
| 270 | + | |
| 271 | + $_mw_adminimize_header = _mw_adminimize_getOptionValue('_mw_adminimize_header'); | |
| 272 | + switch ($_mw_adminimize_header) { | |
| 265 | 273 | case 1: |
| 266 | - wp_deregister_script('media-upload'); | |
| 267 | - wp_enqueue_script('media-upload', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/tb_window.js', array('thickbox')); | |
| 274 | + wp_enqueue_script( '_mw_adminimize_remove_header', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/remove_header.js', array('jquery') ); | |
| 268 | 275 | break; |
| 269 | 276 | } |
| 270 | - $_mw_adminimize_timestamp = _mw_adminimize_getOptionValue('_mw_adminimize_timestamp'); | |
| 271 | - switch ($_mw_adminimize_timestamp) { | |
| 272 | - case 1: | |
| 273 | - wp_enqueue_script( '_mw_adminimize_timestamp', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/timestamp.js', array('jquery') ); | |
| 274 | - break; | |
| 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); | |
| 275 | 321 | } |
| 276 | - | |
| 277 | - //category options | |
| 278 | - $_mw_adminimize_cat_full = _mw_adminimize_getOptionValue('_mw_adminimize_cat_full'); | |
| 279 | - switch ($_mw_adminimize_cat_full) { | |
| 322 | + | |
| 323 | + $_mw_adminimize_control_flashloader = _mw_adminimize_getOptionValue('_mw_adminimize_control_flashloader'); | |
| 324 | + switch ($_mw_adminimize_control_flashloader) { | |
| 280 | 325 | case 1: |
| 281 | - wp_enqueue_style( 'adminimize-ful-category', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/css/mw_cat_full.css' ); | |
| 326 | + add_filter( 'flash_uploader', '_mw_adminimize_control_flashloader', 1 ); | |
| 282 | 327 | break; |
| 283 | 328 | } |
| 284 | - | |
| 285 | - // set default editor tinymce | |
| 286 | - if ( recursive_in_array('#editor-toolbar #edButtonHTML, #quicktags', $disabled_metaboxes_page_all) | |
| 287 | - || recursive_in_array('#editor-toolbar #edButtonHTML, #quicktags', $disabled_metaboxes_post_all) ) | |
| 288 | - add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') ); | |
| 289 | - | |
| 290 | - // remove media bottons | |
| 291 | - if ( recursive_in_array('media_buttons', $disabled_metaboxes_page_all) | |
| 292 | - || recursive_in_array('media_buttons', $disabled_metaboxes_post_all) ) | |
| 293 | - remove_action('media_buttons', 'media_buttons'); | |
| 294 | - | |
| 295 | - //add_filter('image_downsize', '_mw_adminimize_image_downsize', 1, 3); | |
| 296 | 329 | } |
| 297 | 330 | |
| 298 | - $_mw_adminimize_control_flashloader = _mw_adminimize_getOptionValue('_mw_adminimize_control_flashloader'); | |
| 299 | - switch ($_mw_adminimize_control_flashloader) { | |
| 300 | - case 1: | |
| 301 | - add_filter( 'flash_uploader', '_mw_adminimize_control_flashloader', 1 ); | |
| 302 | - break; | |
| 303 | - } | |
| 304 | - | |
| 305 | 331 | if ( ($_mw_admin_color == 'mw_fresh') || |
| 306 | 332 | ($_mw_admin_color == 'mw_classic') || |
| 307 | 333 | ($_mw_admin_color == 'mw_colorblind') || |
| 308 | 334 | ($_mw_admin_color == 'mw_grey') || |
| @@ -336,12 +362,12 @@ | ||
| 336 | 362 | } |
| 337 | 363 | |
| 338 | 364 | // only pages |
| 339 | 365 | if ( |
| 340 | - ( 'page-new.php' == $pagenow ) || | |
| 341 | - ( 'page.php' == $pagenow ) || | |
| 342 | - ( 'post_type=page' == esc_attr($_SERVER['QUERY_STRING']) ) || | |
| 343 | - ( 'page' == $post_type ) | |
| 366 | + ( 'page-new.php' == $pagenow ) || | |
| 367 | + ( 'page.php' == $pagenow ) || | |
| 368 | + ( 'post_type=page' == esc_attr($_SERVER['QUERY_STRING']) ) || | |
| 369 | + ( 'page' == $post_type ) | |
| 344 | 370 | ) { |
| 345 | 371 | |
| 346 | 372 | // check for array empty |
| 347 | 373 | if ( !isset($disabled_metaboxes_page_['editor']['0']) ) |
| @@ -346,9 +372,9 @@ | ||
| 346 | 372 | // check for array empty |
| 347 | 373 | if ( !isset($disabled_metaboxes_page_['editor']['0']) ) |
| 348 | 374 | $disabled_metaboxes_page_['editor']['0'] = ''; |
| 349 | 375 | if ( isset($disabled_metaboxes_page_['administrator']['0']) ) |
| 350 | - $disabled_metaboxes_page_['administrator']['0'] = ''; | |
| 376 | + $disabled_metaboxes_page_['administrator']['0'] = ''; | |
| 351 | 377 | } |
| 352 | 378 | |
| 353 | 379 | } |
| 354 | 380 | |
| @@ -388,20 +414,18 @@ | ||
| 388 | 414 | |
| 389 | 415 | // on init of WordPress |
| 390 | 416 | add_action( 'init', '_mw_adminimize_textdomain' ); |
| 391 | 417 | add_action( 'init', '_mw_adminimize_register_styles' ); |
| 418 | +add_action( 'init', '_mw_adminimize_remove_admin_bar' ); | |
| 392 | 419 | |
| 393 | -if ( is_admin() ) { // exclude super admin of multisite | |
| 394 | - add_action('admin_menu', '_mw_adminimize_add_settings_page'); | |
| 395 | - add_action('admin_menu', '_mw_adminimize_remove_dashboard'); | |
| 396 | - add_action('admin_init', '_mw_adminimize_init', 1); | |
| 397 | - add_action('admin_init', '_mw_adminimize_admin_styles', 1); | |
| 398 | -} | |
| 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 ); | |
| 399 | 425 | |
| 400 | -if ( function_exists('register_activation_hook') ) | |
| 401 | - register_activation_hook(__FILE__, '_mw_adminimize_install'); | |
| 402 | -if ( function_exists('register_uninstall_hook') ) | |
| 403 | - register_uninstall_hook(__FILE__, '_mw_adminimize_deinstall'); | |
| 426 | +register_activation_hook( __FILE__, '_mw_adminimize_install' ); | |
| 427 | +register_uninstall_hook( __FILE__, '_mw_adminimize_deinstall' ); | |
| 404 | 428 | //register_deactivation_hook(__FILE__, '_mw_adminimize_deinstall'); |
| 405 | 429 | |
| 406 | 430 | |
| 407 | 431 | /** |
| @@ -409,28 +433,29 @@ | ||
| 409 | 433 | * code by Andrew Rickmann |
| 410 | 434 | * http://www.wp-fun.co.uk/ |
| 411 | 435 | * @param $value, $id, $size |
| 412 | 436 | */ |
| 413 | -function _mw_adminimize_image_downsize($value = false, $id = 0, $size = "medium") { | |
| 437 | +function _mw_adminimize_image_downsize($value = FALSE, $id = 0, $size = "medium") { | |
| 414 | 438 | |
| 415 | 439 | if ( !wp_attachment_is_image($id) ) |
| 416 | - return false; | |
| 440 | + return FALSE; | |
| 417 | 441 | |
| 418 | 442 | $img_url = wp_get_attachment_url($id); |
| 443 | + | |
| 419 | 444 | // Mimic functionality in image_downsize function in wp-includes/media.php |
| 420 | 445 | if ( $intermediate = image_get_intermediate_size($id, $size) ) { |
| 421 | - $img_url = str_replace(basename($img_url), $intermediate['file'], $img_url); | |
| 422 | - } | |
| 423 | - elseif ( $size == 'thumbnail' ) { | |
| 446 | + $img_url = str_replace( basename($img_url), $intermediate['file'], $img_url ); | |
| 447 | + } elseif ( $size == 'thumbnail' ) { | |
| 424 | 448 | // fall back to the old thumbnail |
| 425 | 449 | if ( $thumb_file = wp_get_attachment_thumb_file() && $info = getimagesize($thumb_file) ) { |
| 426 | - $img_url = str_replace(basename($img_url), basename($thumb_file), $img_url); | |
| 450 | + $img_url = str_replace( basename($img_url), basename($thumb_file), $img_url ); | |
| 427 | 451 | } |
| 428 | 452 | } |
| 453 | + | |
| 429 | 454 | if ( $img_url) |
| 430 | 455 | return array($img_url, 0, 0); |
| 431 | 456 | |
| 432 | - return false; | |
| 457 | + return FALSE; | |
| 433 | 458 | } |
| 434 | 459 | |
| 435 | 460 | |
| 436 | 461 | /** |
| @@ -452,9 +477,9 @@ | ||
| 452 | 477 | <p id="category-add" class="wp-hidden-child"> |
| 453 | 478 | <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" /> |
| 454 | 479 | <?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?> |
| 455 | 480 | <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" /> |
| 456 | - <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?> | |
| 481 | + <?php wp_nonce_field( 'add-category', '_ajax_nonce', FALSE ); ?> | |
| 457 | 482 | <span id="category-ajax-response"></span> |
| 458 | 483 | </p> |
| 459 | 484 | </div> |
| 460 | 485 | <?php } else { ?> |
| @@ -460,13 +485,13 @@ | ||
| 460 | 485 | <?php } else { ?> |
| 461 | 486 | <div id="category-adder" class="wp-hidden-children"> |
| 462 | 487 | <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4> |
| 463 | 488 | <p id="category-add" class="wp-hidden-child"> |
| 464 | - <label class="hidden" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" aria-required="true"/> | |
| 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"/> | |
| 465 | 490 | <br /> |
| 466 | 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 ) ); ?> |
| 467 | 492 | <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" /> |
| 468 | - <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?> | |
| 493 | + <?php wp_nonce_field( 'add-category', '_ajax_nonce', FALSE ); ?> | |
| 469 | 494 | <span id="category-ajax-response"></span> |
| 470 | 495 | </p> |
| 471 | 496 | </div> |
| 472 | 497 | <?php } ?> |
| @@ -502,8 +527,9 @@ | ||
| 502 | 527 | |
| 503 | 528 | if ( function_exists('remove_meta_box') ) { |
| 504 | 529 | if ( !class_exists('SimpleTagsAdmin') ) |
| 505 | 530 | remove_meta_box('tagsdiv', 'post', 'normal'); |
| 531 | + | |
| 506 | 532 | remove_meta_box('categorydiv', 'post', 'normal'); |
| 507 | 533 | } else { |
| 508 | 534 | $_mw_adminimize_sidecat_admin_head = "\n" . '<script type="text/javascript">' . "\n"; |
| 509 | 535 | $_mw_adminimize_sidecat_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#categorydiv\').remove(); });' . "\n"; |
| @@ -523,9 +549,27 @@ | ||
| 523 | 549 | global $wp_version; |
| 524 | 550 | |
| 525 | 551 | $_mw_adminimize_path = WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/'; |
| 526 | 552 | |
| 527 | - if ( version_compare( $wp_version, '2.7alpha', '>=' ) ) { | |
| 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', '<' ) ) { | |
| 528 | 572 | // MW Adminimize Classic |
| 529 | 573 | $styleName = 'Adminimize:' . ' ' . __('Blue'); |
| 530 | 574 | wp_admin_css_color ( |
| 531 | 575 | 'mw_classic', $styleName, $_mw_adminimize_path . 'mw_classic27.css', |
| @@ -566,9 +610,9 @@ | ||
| 566 | 610 | 'mw_fresh_tweak', $styleName, $_mw_adminimize_path . 'mw_fresh28_tweak.css', |
| 567 | 611 | array('#464646', '#6d6d6d', '#f1f1f1', '#dfdfdf') |
| 568 | 612 | ); |
| 569 | 613 | |
| 570 | - } else { | |
| 614 | + } elseif ( version_compare( $wp_version, '2.7alpha', '<' ) ) { | |
| 571 | 615 | // MW Adminimize Classic |
| 572 | 616 | $styleName = 'MW Adminimize:' . ' ' . __('Classic'); |
| 573 | 617 | wp_admin_css_color ( |
| 574 | 618 | 'mw_classic', $styleName, $_mw_adminimize_path . 'mw_classic.css', |
| @@ -658,14 +702,8 @@ | ||
| 658 | 702 | */ |
| 659 | 703 | function _mw_adminimize_remove_dashboard() { |
| 660 | 704 | global $menu, $submenu, $user_ID, $wp_version; |
| 661 | 705 | |
| 662 | - // exclude super admin | |
| 663 | - if ( defined('WP_DEBUG') && !WP_DEBUG ) { | |
| 664 | - if ( is_super_admin() ) | |
| 665 | - return NULL; | |
| 666 | - } | |
| 667 | - | |
| 668 | 706 | $user_roles = get_all_user_roles(); |
| 669 | 707 | |
| 670 | 708 | foreach ($user_roles as $role) { |
| 671 | 709 | $disabled_menu_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_menu_'. $role .'_items'); |
| @@ -694,26 +732,27 @@ | ||
| 694 | 732 | } |
| 695 | 733 | |
| 696 | 734 | if ( $redirect ) { |
| 697 | 735 | $_mw_adminimize_db_redirect = _mw_adminimize_getOptionValue('_mw_adminimize_db_redirect'); |
| 736 | + $_mw_adminimize_db_redirect_admin_url = get_option('siteurl') . '/wp-admin/'; | |
| 698 | 737 | switch ($_mw_adminimize_db_redirect) { |
| 699 | 738 | case 0: |
| 700 | - $_mw_adminimize_db_redirect = 'profile.php'; | |
| 739 | + $_mw_adminimize_db_redirect = $_mw_adminimize_db_redirect_admin_url . 'profile.php'; | |
| 701 | 740 | break; |
| 702 | 741 | case 1: |
| 703 | - $_mw_adminimize_db_redirect = 'edit.php'; | |
| 742 | + $_mw_adminimize_db_redirect = $_mw_adminimize_db_redirect_admin_url . 'edit.php'; | |
| 704 | 743 | break; |
| 705 | 744 | case 2: |
| 706 | - $_mw_adminimize_db_redirect = 'edit.php?post_type=page'; | |
| 745 | + $_mw_adminimize_db_redirect = $_mw_adminimize_db_redirect_admin_url . 'edit.php?post_type=page'; | |
| 707 | 746 | break; |
| 708 | 747 | case 3: |
| 709 | - $_mw_adminimize_db_redirect = 'post-new.php'; | |
| 748 | + $_mw_adminimize_db_redirect = $_mw_adminimize_db_redirect_admin_url . 'post-new.php'; | |
| 710 | 749 | break; |
| 711 | 750 | case 4: |
| 712 | - $_mw_adminimize_db_redirect = 'page-new.php'; | |
| 751 | + $_mw_adminimize_db_redirect = $_mw_adminimize_db_redirect_admin_url . 'page-new.php'; | |
| 713 | 752 | break; |
| 714 | 753 | case 5: |
| 715 | - $_mw_adminimize_db_redirect = 'edit-comments.php'; | |
| 754 | + $_mw_adminimize_db_redirect = $_mw_adminimize_db_redirect_admin_url . 'edit-comments.php'; | |
| 716 | 755 | break; |
| 717 | 756 | case 6: |
| 718 | 757 | $_mw_adminimize_db_redirect = _mw_adminimize_getOptionValue('_mw_adminimize_db_redirect_txt'); |
| 719 | 758 | break; |
| @@ -723,9 +762,10 @@ | ||
| 723 | 762 | if ( version_compare($wp_version, "3.0alpha", "<") && 'edit.php?post_type=page' == $_mw_adminimize_db_redirect ) |
| 724 | 763 | $_mw_adminimize_db_redirect = 'edit-pages.php'; |
| 725 | 764 | |
| 726 | 765 | $the_user = new WP_User($user_ID); |
| 727 | - reset($menu); $page = key($menu); | |
| 766 | + reset($menu); | |
| 767 | + $page = key($menu); | |
| 728 | 768 | |
| 729 | 769 | while ( (__('Dashboard') != $menu[$page][0]) && next($menu) || (__('Dashboard') != $menu[$page][1]) && next($menu) ) |
| 730 | 770 | $page = key($menu); |
| 731 | 771 | |
| @@ -736,9 +776,9 @@ | ||
| 736 | 776 | while ( !$the_user->has_cap($menu[$page][1]) && next($menu) ) |
| 737 | 777 | $page = key($menu); |
| 738 | 778 | |
| 739 | 779 | if ( preg_match('#wp-admin/?(index.php)?$#', $_SERVER['REQUEST_URI']) ) { |
| 740 | - wp_redirect( get_option('siteurl') . '/wp-admin/' . $_mw_adminimize_db_redirect ); | |
| 780 | + wp_redirect( $_mw_adminimize_db_redirect ); | |
| 741 | 781 | } |
| 742 | 782 | } |
| 743 | 783 | } |
| 744 | 784 | } |
| @@ -747,9 +787,10 @@ | ||
| 747 | 787 | /** |
| 748 | 788 | * remove the flash_uploader |
| 749 | 789 | */ |
| 750 | 790 | function _mw_adminimize_disable_flash_uploader() { |
| 751 | - return false; | |
| 791 | + | |
| 792 | + return FALSE; | |
| 752 | 793 | } |
| 753 | 794 | |
| 754 | 795 | |
| 755 | 796 | /** |
| @@ -757,8 +798,12 @@ | ||
| 757 | 798 | */ |
| 758 | 799 | function _mw_adminimize_set_menu_option() { |
| 759 | 800 | global $pagenow, $menu, $submenu, $user_identity, $wp_version; |
| 760 | 801 | |
| 802 | + // exclude super admin | |
| 803 | + if ( _mw_adminimize_exclude_super_admin() ) | |
| 804 | + return NULL; | |
| 805 | + | |
| 761 | 806 | $user_roles = get_all_user_roles(); |
| 762 | 807 | |
| 763 | 808 | foreach ($user_roles as $role) { |
| 764 | 809 | $disabled_menu_[$role] = _mw_adminimize_getOptionValue('mw_adminimize_disabled_menu_'. $role .'_items'); |
| @@ -769,51 +814,51 @@ | ||
| 769 | 814 | $_mw_adminimize_user_info = _mw_adminimize_getOptionValue('_mw_adminimize_user_info'); |
| 770 | 815 | $_mw_adminimize_ui_redirect = _mw_adminimize_getOptionValue('_mw_adminimize_ui_redirect'); |
| 771 | 816 | |
| 772 | 817 | switch ($_mw_adminimize_user_info) { |
| 773 | - case 1: | |
| 774 | - $_mw_adminimize_admin_head .= '<script type="text/javascript">' . "\n"; | |
| 775 | - $_mw_adminimize_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#user_info\').remove(); });' . "\n"; | |
| 776 | - $_mw_adminimize_admin_head .= '</script>' . "\n"; | |
| 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"; | |
| 777 | 822 | break; |
| 778 | - case 2: | |
| 779 | - if ( version_compare($wp_version, "3.0alpha", ">=") ) { | |
| 780 | - $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info30.css" type="text/css" />' . "\n"; | |
| 781 | - } elseif ( version_compare(substr($wp_version, 0, 3), '2.7', '>=') ) { | |
| 782 | - $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info27.css" type="text/css" />' . "\n"; | |
| 783 | - } else { | |
| 784 | - $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info.css" type="text/css" />' . "\n"; | |
| 785 | - } | |
| 786 | - $_mw_adminimize_admin_head .= '<script type="text/javascript">' . "\n"; | |
| 787 | - $_mw_adminimize_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#user_info\').remove();'; | |
| 788 | - if ($_mw_adminimize_ui_redirect == '1') { | |
| 789 | - $_mw_adminimize_admin_head .= 'jQuery(\'div#wpcontent\').after(\'<div id="small_user_info"><p><a href="' . get_option('siteurl') . wp_nonce_url( ('/wp-login.php?action=logout&redirect_to=') . get_option('siteurl') , 'log-out' ) . '" title="' . __('Log Out') . '">' . __('Log Out') . '</a></p></div>\') });' . "\n"; | |
| 790 | - } else { | |
| 791 | - $_mw_adminimize_admin_head .= 'jQuery(\'div#wpcontent\').after(\'<div id="small_user_info"><p><a href="' . get_option('siteurl') . wp_nonce_url( ('/wp-login.php?action=logout') , 'log-out' ) . '" title="' . __('Log Out') . '">' . __('Log Out') . '</a></p></div>\') });' . "\n"; | |
| 792 | - } | |
| 793 | - $_mw_adminimize_admin_head .= '</script>' . "\n"; | |
| 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&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"; | |
| 794 | 839 | break; |
| 795 | - case 3: | |
| 796 | - if ( version_compare($wp_version, "3.0alpha", ">=") ) { | |
| 797 | - $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info30.css" type="text/css" />' . "\n"; | |
| 798 | - } elseif ( version_compare(substr($wp_version, 0, 3), '2.7', '>=') ) { | |
| 799 | - $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info27.css" type="text/css" />' . "\n"; | |
| 800 | - } else { | |
| 801 | - $_mw_adminimize_admin_head .= '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/css/mw_small_user_info.css" type="text/css" />' . "\n"; | |
| 802 | - } | |
| 803 | - $_mw_adminimize_admin_head .= '<script type="text/javascript">' . "\n"; | |
| 804 | - $_mw_adminimize_admin_head .= "\t" . 'jQuery(document).ready(function() { jQuery(\'#user_info\').remove();'; | |
| 805 | - if ($_mw_adminimize_ui_redirect == '1') { | |
| 806 | - $_mw_adminimize_admin_head .= 'jQuery(\'div#wpcontent\').after(\'<div id="small_user_info"><p><a href="' . get_option('siteurl') . ('/wp-admin/profile.php') . '">' . $user_identity . '</a> | <a href="' . get_option('siteurl') . wp_nonce_url( ('/wp-login.php?action=logout&redirect_to=') . get_option('siteurl'), 'log-out' ) . '" title="' . __('Log Out') . '">' . __('Log Out') . '</a></p></div>\') });' . "\n"; | |
| 807 | - } else { | |
| 808 | - $_mw_adminimize_admin_head .= 'jQuery(\'div#wpcontent\').after(\'<div id="small_user_info"><p><a href="' . get_option('siteurl') . ('/wp-admin/profile.php') . '">' . $user_identity . '</a> | <a href="' . get_option('siteurl') . wp_nonce_url( ('/wp-login.php?action=logout'), 'log-out' ) . '" title="' . __('Log Out') . '">' . __('Log Out') . '</a></p></div>\') });' . "\n"; | |
| 809 | - } | |
| 810 | - $_mw_adminimize_admin_head .= '</script>' . "\n"; | |
| 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&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"; | |
| 811 | 856 | break; |
| 812 | 857 | } |
| 813 | 858 | |
| 814 | 859 | // set menu |
| 815 | - if ($disabled_menu_['editor'] != '') { | |
| 860 | + if ( '' != $disabled_menu_['editor'] ) { | |
| 816 | 861 | |
| 817 | 862 | // set admin-menu |
| 818 | 863 | foreach ($user_roles as $role) { |
| 819 | 864 | $user = wp_get_current_user(); |
| @@ -860,8 +905,12 @@ | ||
| 860 | 905 | */ |
| 861 | 906 | function _mw_adminimize_set_global_option() { |
| 862 | 907 | global $_wp_admin_css_colors; |
| 863 | 908 | |
| 909 | + // exclude super admin | |
| 910 | + if ( _mw_adminimize_exclude_super_admin() ) | |
| 911 | + return NULL; | |
| 912 | + | |
| 864 | 913 | $user_roles = get_all_user_roles(); |
| 865 | 914 | |
| 866 | 915 | $_mw_adminimize_admin_head = ''; |
| 867 | 916 | |
| @@ -892,22 +941,63 @@ | ||
| 892 | 941 | $_wp_admin_css_colors = 0; |
| 893 | 942 | $_mw_adminimize_admin_head .= '<!-- global options -->' . "\n"; |
| 894 | 943 | $_mw_adminimize_admin_head .= '<style type="text/css">' . $global_options . ' {display: none !important;}</style>' . "\n"; |
| 895 | 944 | |
| 896 | - // for deactivate admin bar | |
| 897 | - if ( $remove_adminbar ) | |
| 898 | - add_filter( 'show_admin_bar','__return_false' ); | |
| 899 | - | |
| 900 | 945 | if ($global_options) |
| 901 | 946 | echo $_mw_adminimize_admin_head; |
| 902 | 947 | } |
| 903 | 948 | |
| 904 | 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 | + | |
| 905 | 991 | /** |
| 906 | 992 | * set metabox options from database an area post |
| 907 | 993 | */ |
| 908 | 994 | function _mw_adminimize_set_metabox_post_option() { |
| 909 | 995 | |
| 996 | + // exclude super admin | |
| 997 | + if ( _mw_adminimize_exclude_super_admin() ) | |
| 998 | + return NULL; | |
| 999 | + | |
| 910 | 1000 | $user_roles = get_all_user_roles(); |
| 911 | 1001 | |
| 912 | 1002 | $_mw_adminimize_admin_head = ''; |
| 913 | 1003 | |
| @@ -922,9 +1012,9 @@ | ||
| 922 | 1012 | // new 1.7.8 |
| 923 | 1013 | foreach ($user_roles as $role) { |
| 924 | 1014 | $user = wp_get_current_user(); |
| 925 | 1015 | if ( in_array($role, $user->roles) ) { |
| 926 | - if ( current_user_can($role) && is_array($disabled_metaboxes_post_[$role]) ) { | |
| 1016 | + if ( current_user_can($role) && isset($disabled_metaboxes_post_[$role]) && is_array($disabled_metaboxes_post_[$role]) ) { | |
| 927 | 1017 | $metaboxes = implode(',', $disabled_metaboxes_post_[$role]); |
| 928 | 1018 | } |
| 929 | 1019 | } |
| 930 | 1020 | } |
| @@ -941,8 +1031,12 @@ | ||
| 941 | 1031 | * set metabox options from database an area page |
| 942 | 1032 | */ |
| 943 | 1033 | function _mw_adminimize_set_metabox_page_option() { |
| 944 | 1034 | |
| 1035 | + // exclude super admin | |
| 1036 | + if ( _mw_adminimize_exclude_super_admin() ) | |
| 1037 | + return NULL; | |
| 1038 | + | |
| 945 | 1039 | $user_roles = get_all_user_roles(); |
| 946 | 1040 | |
| 947 | 1041 | $_mw_adminimize_admin_head = ''; |
| 948 | 1042 | |
| @@ -976,8 +1070,12 @@ | ||
| 976 | 1070 | * set link options in area Links of Backend |
| 977 | 1071 | */ |
| 978 | 1072 | function _mw_adminimize_set_link_option() { |
| 979 | 1073 | |
| 1074 | + // exclude super admin | |
| 1075 | + if ( _mw_adminimize_exclude_super_admin() ) | |
| 1076 | + return NULL; | |
| 1077 | + | |
| 980 | 1078 | $user_roles = get_all_user_roles(); |
| 981 | 1079 | |
| 982 | 1080 | $_mw_adminimize_admin_head = ''; |
| 983 | 1081 | |
| @@ -1011,8 +1109,12 @@ | ||
| 1011 | 1109 | * remove objects on wp nav menu |
| 1012 | 1110 | */ |
| 1013 | 1111 | function _mw_adminimize_set_nav_menu_option() { |
| 1014 | 1112 | |
| 1113 | + // exclude super admin | |
| 1114 | + if ( _mw_adminimize_exclude_super_admin() ) | |
| 1115 | + return NULL; | |
| 1116 | + | |
| 1015 | 1117 | $user_roles = get_all_user_roles(); |
| 1016 | 1118 | |
| 1017 | 1119 | $_mw_adminimize_admin_head = ''; |
| 1018 | 1120 | |
| @@ -1035,8 +1137,9 @@ | ||
| 1035 | 1137 | $nav_menu_options = implode(',', $disabled_nav_menu_option_[$role]); |
| 1036 | 1138 | } |
| 1037 | 1139 | } |
| 1038 | 1140 | } |
| 1141 | + //remove_meta_box($id, 'nav-menus', 'side'); | |
| 1039 | 1142 | $_mw_adminimize_admin_head .= '<style type="text/css">' . $nav_menu_options . ' {display: none !important;}</style>' . "\n"; |
| 1040 | 1143 | |
| 1041 | 1144 | if ($nav_menu_options) |
| 1042 | 1145 | echo $_mw_adminimize_admin_head; |
| @@ -1065,10 +1168,12 @@ | ||
| 1065 | 1168 | /** |
| 1066 | 1169 | * credit in wp-footer |
| 1067 | 1170 | */ |
| 1068 | 1171 | function _mw_adminimize_admin_footer() { |
| 1172 | + | |
| 1069 | 1173 | $plugin_data = get_plugin_data( __FILE__ ); |
| 1070 | 1174 | $plugin_data['Title'] = $plugin_data['Name']; |
| 1175 | + | |
| 1071 | 1176 | if ( !empty($plugin_data['PluginURI']) && !empty($plugin_data['Name']) ) |
| 1072 | 1177 | $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="'.__( 'Visit plugin homepage' ).'">' . $plugin_data['Name'] . '</a>'; |
| 1073 | 1178 | |
| 1074 | 1179 | if ( basename($_SERVER['REQUEST_URI']) == 'adminimize.php') { |
| @@ -1073,11 +1178,13 @@ | ||
| 1073 | 1178 | |
| 1074 | 1179 | if ( basename($_SERVER['REQUEST_URI']) == 'adminimize.php') { |
| 1075 | 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']); |
| 1076 | 1181 | } |
| 1182 | + | |
| 1077 | 1183 | if ( _mw_adminimize_getOptionValue('_mw_adminimize_advice') == 1 && basename($_SERVER['REQUEST_URI']) != 'adminimize.php' ) { |
| 1078 | 1184 | printf('%1$s ' . __('plugin activate', FB_ADMINIMIZE_TEXTDOMAIN ) . ' | ' . stripslashes( _mw_adminimize_getOptionValue('_mw_adminimize_advice_txt') ) . '<br />', $plugin_data['Title']); |
| 1079 | 1185 | } |
| 1186 | + | |
| 1080 | 1187 | } |
| 1081 | 1188 | |
| 1082 | 1189 | |
| 1083 | 1190 | /** |
| @@ -1091,9 +1198,9 @@ | ||
| 1091 | 1198 | */ |
| 1092 | 1199 | function _mw_adminimize_filter_plugin_meta($links, $file) { |
| 1093 | 1200 | |
| 1094 | 1201 | /* create link */ |
| 1095 | - if ( $file == FB_ADMINIMIZE_BASENAME ) { | |
| 1202 | + if ( FB_ADMINIMIZE_BASENAME == $file ) { | |
| 1096 | 1203 | array_unshift( |
| 1097 | 1204 | $links, |
| 1098 | 1205 | sprintf( '<a href="options-general.php?page=%s">%s</a>', FB_ADMINIMIZE_BASENAME, __('Settings') ) |
| 1099 | 1206 | ); |
| @@ -1107,8 +1214,9 @@ | ||
| 1107 | 1214 | * Images/ Icons in base64-encoding |
| 1108 | 1215 | * @use function _mw_adminimize_get_resource_url() for display |
| 1109 | 1216 | */ |
| 1110 | 1217 | if ( isset($_GET['resource']) && !empty($_GET['resource']) ) { |
| 1218 | + | |
| 1111 | 1219 | # base64 encoding performed by base64img.php from http://php.holtsmark.no |
| 1112 | 1220 | $resources = array( |
| 1113 | 1221 | 'adminimize.gif' => |
| 1114 | 1222 | 'R0lGODlhCwALAKIEAPb29tTU1Kurq5SUlP///wAAAAAAAAAAAC'. |
| @@ -1120,17 +1228,17 @@ | ||
| 1120 | 1228 | |
| 1121 | 1229 | $content = base64_decode($resources[ $_GET['resource'] ]); |
| 1122 | 1230 | |
| 1123 | 1231 | $lastMod = filemtime(__FILE__); |
| 1124 | - $client = ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false ); | |
| 1232 | + $client = ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : FALSE ); | |
| 1125 | 1233 | // Checking if the client is validating his cache and if it is current. |
| 1126 | 1234 | if (isset($client) && (strtotime($client) == $lastMod)) { |
| 1127 | 1235 | // Client's cache IS current, so we just respond '304 Not Modified'. |
| 1128 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', true, 304); | |
| 1236 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', TRUE, 304); | |
| 1129 | 1237 | exit; |
| 1130 | 1238 | } else { |
| 1131 | 1239 | // Image not cached or cache outdated, we respond '200 OK' and output the image. |
| 1132 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', true, 200); | |
| 1240 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', TRUE, 200); | |
| 1133 | 1241 | header('Content-Length: '.strlen($content)); |
| 1134 | 1242 | header('Content-Type: image/' . substr(strrchr($_GET['resource'], '.'), 1) ); |
| 1135 | 1243 | echo $content; |
| 1136 | 1244 | exit; |
| @@ -1135,8 +1243,9 @@ | ||
| 1135 | 1243 | echo $content; |
| 1136 | 1244 | exit; |
| 1137 | 1245 | } |
| 1138 | 1246 | } |
| 1247 | + | |
| 1139 | 1248 | } |
| 1140 | 1249 | |
| 1141 | 1250 | |
| 1142 | 1251 | /** |
| @@ -1156,8 +1265,9 @@ | ||
| 1156 | 1265 | */ |
| 1157 | 1266 | function _mw_adminimize_contextual_help() { |
| 1158 | 1267 | |
| 1159 | 1268 | $content = __('<a href="http://wordpress.org/extend/plugins/adminimize/">Documentation</a>', FB_ADMINIMIZE_TEXTDOMAIN ); |
| 1269 | + | |
| 1160 | 1270 | return $content; |
| 1161 | 1271 | } |
| 1162 | 1272 | |
| 1163 | 1273 | |
| @@ -1178,12 +1288,14 @@ | ||
| 1178 | 1288 | $pagehook = add_submenu_page('options-general.php', __('Adminimize Options', FB_ADMINIMIZE_TEXTDOMAIN ), $menutitle, 'unfiltered_html', __FILE__, '_mw_adminimize_options'); |
| 1179 | 1289 | add_action( 'load-' . $pagehook, '_mw_adminimize_on_load_page' ); |
| 1180 | 1290 | add_filter( 'plugin_action_links', '_mw_adminimize_filter_plugin_meta', 10, 2 ); |
| 1181 | 1291 | } |
| 1292 | + | |
| 1182 | 1293 | } |
| 1183 | 1294 | |
| 1184 | 1295 | |
| 1185 | 1296 | function _mw_adminimize_on_load_page() { |
| 1297 | + | |
| 1186 | 1298 | add_filter( 'contextual_help', '_mw_adminimize_contextual_help' ); |
| 1187 | 1299 | |
| 1188 | 1300 | wp_enqueue_style( 'adminimize-style' ); |
| 1189 | 1301 | } |
| @@ -1200,13 +1312,14 @@ | ||
| 1200 | 1312 | $user_ids = $_POST[mw_adminimize_theme_items]; |
| 1201 | 1313 | $admin_color = htmlspecialchars( stripslashes( $_POST[_mw_adminimize_set_theme] ) ); |
| 1202 | 1314 | |
| 1203 | 1315 | if ( !$user_ids ) |
| 1204 | - return false; | |
| 1316 | + return FALSE; | |
| 1205 | 1317 | |
| 1206 | 1318 | foreach( $user_ids as $user_id) { |
| 1207 | 1319 | update_usermeta($user_id, 'admin_color', $admin_color); |
| 1208 | 1320 | } |
| 1321 | + | |
| 1209 | 1322 | } |
| 1210 | 1323 | |
| 1211 | 1324 | |
| 1212 | 1325 | /** |
| @@ -1214,8 +1327,9 @@ | ||
| 1214 | 1327 | */ |
| 1215 | 1328 | function _mw_adminimize_getOptionValue($key) { |
| 1216 | 1329 | |
| 1217 | 1330 | $adminimizeoptions = get_option('mw_adminimize'); |
| 1331 | + | |
| 1218 | 1332 | if ( isset($adminimizeoptions[$key]) ) |
| 1219 | 1333 | return ($adminimizeoptions[$key]); |
| 1220 | 1334 | } |
| 1221 | 1335 | |
| @@ -1250,9 +1364,15 @@ | ||
| 1250 | 1364 | $adminimizeoptions['_mw_adminimize_header'] = strip_tags(stripslashes($_POST['_mw_adminimize_header'])); |
| 1251 | 1365 | } else { |
| 1252 | 1366 | $adminimizeoptions['_mw_adminimize_header'] = 0; |
| 1253 | 1367 | } |
| 1254 | - | |
| 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 | + | |
| 1255 | 1375 | if (isset($_POST['_mw_adminimize_writescroll'])) { |
| 1256 | 1376 | $adminimizeoptions['_mw_adminimize_writescroll'] = strip_tags(stripslashes($_POST['_mw_adminimize_writescroll'])); |
| 1257 | 1377 | } else { |
| 1258 | 1378 | $adminimizeoptions['_mw_adminimize_writescroll'] = 0; |
| @@ -1412,8 +1532,21 @@ | ||
| 1412 | 1532 | } else { |
| 1413 | 1533 | $adminimizeoptions['_mw_adminimize_own_link_options'] = 0; |
| 1414 | 1534 | } |
| 1415 | 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 | + | |
| 1416 | 1549 | // update |
| 1417 | 1550 | update_option('mw_adminimize', $adminimizeoptions); |
| 1418 | 1551 | $adminimizeoptions = get_option('mw_adminimize'); |
| 1419 | 1552 | |
| @@ -1467,11 +1600,11 @@ | ||
| 1467 | 1600 | header("Content-Disposition: attachment; filename=" . urlencode($filename)); |
| 1468 | 1601 | header("Content-Type: application/force-download"); |
| 1469 | 1602 | header("Content-Type: application/octet-stream"); |
| 1470 | 1603 | header("Content-Type: application/download"); |
| 1471 | - header('Content-Type: text/seq; charset=' . get_option('blog_charset'), true); | |
| 1604 | + header('Content-Type: text/seq; charset=' . get_option('blog_charset'), TRUE); | |
| 1472 | 1605 | flush(); |
| 1473 | - | |
| 1606 | + | |
| 1474 | 1607 | $export_data = mysql_query("SELECT option_value FROM $wpdb->options WHERE option_name = 'mw_adminimize'"); |
| 1475 | 1608 | $export_data = mysql_result($export_data, 0); |
| 1476 | 1609 | echo $export_data; |
| 1477 | 1610 | flush(); |
| @@ -1499,12 +1632,18 @@ | ||
| 1499 | 1632 | chmod($str_ziel, 0644); |
| 1500 | 1633 | // SQL import |
| 1501 | 1634 | ini_set('default_socket_timeout', 120); |
| 1502 | 1635 | $import_file = file_get_contents($str_ziel); |
| 1636 | + | |
| 1503 | 1637 | _mw_adminimize_deinstall(); |
| 1504 | 1638 | $import_file = unserialize($import_file); |
| 1639 | + | |
| 1640 | + if ( file_exists($str_ziel) ) | |
| 1641 | + unlink($str_ziel); | |
| 1505 | 1642 | update_option('mw_adminimize', $import_file); |
| 1506 | - unlink($str_ziel); | |
| 1643 | + if ( file_exists($str_ziel) ) | |
| 1644 | + unlink($str_ziel); | |
| 1645 | + | |
| 1507 | 1646 | $addreferer = 'true'; |
| 1508 | 1647 | } |
| 1509 | 1648 | |
| 1510 | 1649 | $myErrors = new _mw_adminimize_message_class(); |