/** * set global options in backend in all areas */ function __wp_supercustom_cms_set_global_option() { global $_wp_admin_css_colors; // exclude super admin if (__wp_supercustom_cms_exclude_super_admin()) { return NULL; } $user_roles = __wp_supercustom_cms_get_all_user_roles(); $__wp_supercustom_cms_admin_head = ''; // remove_action( 'admin_head', 'index_js' ); foreach ($user_roles as $role) { $disabled_global_option_[$role] = __wp_supercustom_cms_get_option_value('wp_supercustom_cms_disabled_global_option_' . $role . '_items'); } foreach ($user_roles as $role) { if (!isset($disabled_global_option_[$role]['0'])) { $disabled_global_option_[$role]['0'] = ''; } } $remove_adminbar = FALSE; // new 1.7.8 foreach ($user_roles as $role) { $user = wp_get_current_user(); if (is_array($user->roles) && in_array($role, $user->roles)) { if (current_user_can($role) && isset($disabled_global_option_[$role]) && is_array($disabled_global_option_[$role])) { $global_options = implode(', ', $disabled_global_option_[$role]); if (__wp_supercustom_cms_recursive_in_array('.show-admin-bar', $disabled_global_option_[$role])) { $remove_adminbar = TRUE; } } } } if (0 != strpos($global_options, '#your-profile .form-table fieldset')) { $_wp_admin_css_colors = 0; } $__wp_supercustom_cms_admin_head .= '<!-- global options -->' . "\n"; $__wp_supercustom_cms_admin_head .= '<style type="text/css">' . $global_options . ' {display: none !important;}</style>' . "\n"; if ($global_options) { echo $__wp_supercustom_cms_admin_head; } }
?> </td> </tr> <?php // when remove dashboard foreach ($user_roles as $role) { $disabled_menu_[$role] = __wp_supercustom_cms_get_option_value('wp_supercustom_cms_disabled_menu_' . $role . '_items'); $disabled_submenu_[$role] = __wp_supercustom_cms_get_option_value('wp_supercustom_cms_disabled_submenu_' . $role . '_items'); } $disabled_menu_all = array(); foreach ($user_roles as $role) { array_push($disabled_menu_all, $disabled_menu_[$role]); array_push($disabled_menu_all, $disabled_submenu_[$role]); } if ('' != $disabled_menu_all) { if (!__wp_supercustom_cms_recursive_in_array('index.php', $disabled_menu_all)) { $disabled_item2 = ' disabled="disabled"'; } ?> <tr valign="top" class="form-invalid"> <td><?php _e('Dashboard deactivate, redirect to', FB_SUPERCUSTOM_CMS_TEXTDOMAIN); ?> </td> <td> <?php $__wp_supercustom_cms_db_redirect = __wp_supercustom_cms_get_option_value('__wp_supercustom_cms_db_redirect'); ?> <select name="__wp_supercustom_cms_db_redirect"<?php if (isset($disabled_item2)) { echo $disabled_item2;
/** * check user-option and add new style * @uses $pagenow */ function __wp_supercustom_cms_admin_init() { global $pagenow, $post_type, $menu, $submenu, $wp_version; if (isset($_GET['post'])) { $post_id = (int) esc_attr($_GET['post']); } elseif (isset($_POST['post_ID'])) { $post_id = (int) esc_attr($_POST['post_ID']); } else { $post_id = 0; } $current_post_type = $post_type; if (!isset($current_post_type)) { $current_post_type = get_post_type($post_id); } if (!$current_post_type) { $current_post_type = str_replace('post_type=', '', esc_attr($_SERVER['QUERY_STRING'])); } if (!$current_post_type) { // set hard to post $current_post_type = 'post'; } $user_roles = __wp_supercustom_cms_get_all_user_roles(); $SuperCustomCMSoptions = get_option('supercustom_cms'); // pages for post type Post $def_post_pages = array('edit.php', 'post.php', 'post-new.php'); $def_post_types = array('post'); $disabled_metaboxes_post_all = array(); // pages for post type Page $def_page_pages = array_merge($def_post_pages, array('page-new.php', 'page.php')); $def_page_types = array('page'); $disabled_metaboxes_page_all = array(); // pages for custom post types $def_custom_pages = $def_post_pages; $args = array('public' => TRUE, '_builtin' => FALSE); $def_custom_types = get_post_types($args); // pages for link pages $link_pages = array('link.php', 'link-manager.php', 'link-add.php', 'edit-link-categories.php'); // pages for nav menu $nav_menu_pages = array('nav-menus.php'); // get admin color for current user $_mw_admin_color = get_user_option('admin_color'); foreach ($user_roles as $role) { $disabled_global_option_[$role] = __wp_supercustom_cms_get_option_value('wp_supercustom_cms_disabled_global_option_' . $role . '_items'); $disabled_metaboxes_post_[$role] = __wp_supercustom_cms_get_option_value('wp_supercustom_cms_disabled_metaboxes_post_' . $role . '_items'); $disabled_metaboxes_page_[$role] = __wp_supercustom_cms_get_option_value('wp_supercustom_cms_disabled_metaboxes_page_' . $role . '_items'); foreach ($def_custom_types as $post_type) { $disabled_metaboxes_[$post_type . '_' . $role] = __wp_supercustom_cms_get_option_value('wp_supercustom_cms_disabled_metaboxes_' . $post_type . '_' . $role . '_items'); } $disabled_link_option_[$role] = __wp_supercustom_cms_get_option_value('wp_supercustom_cms_disabled_link_option_' . $role . '_items'); $disabled_nav_menu_option_[$role] = __wp_supercustom_cms_get_option_value('wp_supercustom_cms_disabled_nav_menu_option_' . $role . '_items'); array_push($disabled_metaboxes_post_all, $disabled_metaboxes_post_[$role]); array_push($disabled_metaboxes_page_all, $disabled_metaboxes_page_[$role]); } // global options // exclude super admin if (!__wp_supercustom_cms_exclude_super_admin()) { $__wp_supercustom_cms_footer = __wp_supercustom_cms_get_option_value('__wp_supercustom_cms_footer'); switch ($__wp_supercustom_cms_footer) { case 1: wp_enqueue_script('__wp_supercustom_cms_remove_footer', WP_PLUGIN_URL . '/' . FB_SUPERCUSTOM_CMS_BASEFOLDER . '/js/remove_footer.js', array('jquery')); break; } $__wp_supercustom_cms_header = __wp_supercustom_cms_get_option_value('__wp_supercustom_cms_header'); switch ($__wp_supercustom_cms_header) { case 1: wp_enqueue_script('__wp_supercustom_cms_remove_header', WP_PLUGIN_URL . '/' . FB_SUPERCUSTOM_CMS_BASEFOLDER . '/js/remove_header.js', array('jquery')); break; } //post-page options if (in_array($pagenow, $def_post_pages)) { $__wp_supercustom_cms_writescroll = __wp_supercustom_cms_get_option_value('__wp_supercustom_cms_writescroll'); switch ($__wp_supercustom_cms_writescroll) { case 1: wp_enqueue_script('__wp_supercustom_cms_writescroll', WP_PLUGIN_URL . '/' . FB_SUPERCUSTOM_CMS_BASEFOLDER . '/js/writescroll.js', array('jquery')); break; } $__wp_supercustom_cms_tb_window = __wp_supercustom_cms_get_option_value('__wp_supercustom_cms_tb_window'); switch ($__wp_supercustom_cms_tb_window) { case 1: wp_deregister_script('media-upload'); wp_enqueue_script('media-upload', WP_PLUGIN_URL . '/' . FB_SUPERCUSTOM_CMS_BASEFOLDER . '/js/tb_window.js', array('thickbox')); break; } $__wp_supercustom_cms_timestamp = __wp_supercustom_cms_get_option_value('__wp_supercustom_cms_timestamp'); switch ($__wp_supercustom_cms_timestamp) { case 1: wp_enqueue_script('__wp_supercustom_cms_timestamp', WP_PLUGIN_URL . '/' . FB_SUPERCUSTOM_CMS_BASEFOLDER . '/js/timestamp.js', array('jquery')); break; } //category options $__wp_supercustom_cms_cat_full = __wp_supercustom_cms_get_option_value('__wp_supercustom_cms_cat_full'); switch ($__wp_supercustom_cms_cat_full) { case 1: wp_enqueue_style('SuperCustomCMS-ful-category', WP_PLUGIN_URL . '/' . FB_SUPERCUSTOM_CMS_BASEFOLDER . '/css/mw_cat_full.css'); break; } // set default editor tinymce if (__wp_supercustom_cms_recursive_in_array('#editor-toolbar #edButtonHTML, #quicktags, #content-html', $disabled_metaboxes_page_all) || __wp_supercustom_cms_recursive_in_array('#editor-toolbar #edButtonHTML, #quicktags, #content-html', $disabled_metaboxes_post_all)) { add_filter('wp_default_editor', create_function('', 'return "tinymce";')); } // remove media bottons if (__wp_supercustom_cms_recursive_in_array('media_buttons', $disabled_metaboxes_page_all) || __wp_supercustom_cms_recursive_in_array('media_buttons', $disabled_metaboxes_post_all)) { remove_action('media_buttons', 'media_buttons'); } //add_filter( 'image_downsize', '__wp_supercustom_cms_image_downsize', 1, 3); } $__wp_supercustom_cms_control_flashloader = __wp_supercustom_cms_get_option_value('__wp_supercustom_cms_control_flashloader'); switch ($__wp_supercustom_cms_control_flashloader) { case 1: add_filter('flash_uploader', '__wp_supercustom_cms_control_flashloader', 1); break; } } // change Admin Bar and user Info if (version_compare($wp_version, '3.3alpha', '>=')) { __wp_supercustom_cms_set_menu_option_33(); } else { add_action('admin_head', '__wp_supercustom_cms_set_user_info'); add_action('wp_head', '__wp_supercustom_cms_set_user_info'); } // set menu option add_action('admin_head', '__wp_supercustom_cms_set_menu_option', 1); // global_options add_action('admin_head', '__wp_supercustom_cms_set_global_option', 1); // set metabox post option if (in_array($pagenow, $def_post_pages) && in_array($current_post_type, $def_post_types)) { add_action('admin_head', '__wp_supercustom_cms_set_metabox_post_option', 1); } // set metabox page option if (in_array($pagenow, $def_page_pages) && in_array($current_post_type, $def_page_types)) { add_action('admin_head', '__wp_supercustom_cms_set_metabox_page_option', 1); } // set custom post type options if (function_exists('get_post_types') && in_array($pagenow, $def_custom_pages) && in_array($current_post_type, $def_custom_types)) { add_action('admin_head', '__wp_supercustom_cms_set_metabox_cp_option', 1); } // set link option if (in_array($pagenow, $link_pages)) { add_action('admin_head', '__wp_supercustom_cms_set_link_option', 1); } // set wp nav menu options if (in_array($pagenow, $nav_menu_pages)) { add_action('admin_head', '__wp_supercustom_cms_set_nav_menu_option', 1); } add_action('in_admin_footer', '__wp_supercustom_cms_admin_footer'); $SuperCustomCMSoptions['wp_supercustom_cms_default_menu'] = $menu; $SuperCustomCMSoptions['wp_supercustom_cms_default_submenu'] = $submenu; // if custom design of SuperCustomCMS; kill with version 1.7.18 if ($_mw_admin_color == 'mw_fresh' || $_mw_admin_color == 'mw_classic' || $_mw_admin_color == 'mw_colorblind' || $_mw_admin_color == 'mw_grey' || $_mw_admin_color == 'mw_fresh_ozh_am' || $_mw_admin_color == 'mw_classic_ozh_am' || $_mw_admin_color == 'mw_fresh_lm' || $_mw_admin_color == 'mw_classic_lm' || $_mw_admin_color == 'mw_wp23') { // only posts if ('post-new.php' == $pagenow || 'post.php' == $pagenow || 'post' == $post_type) { if (version_compare(substr($wp_version, 0, 3), '2.7', '<')) { add_action('admin_head', '__wp_supercustom_cms_remove_box', 99); } // check for array empty if (!isset($disabled_metaboxes_post_['editor']['0'])) { $disabled_metaboxes_post_['editor']['0'] = ''; } if (isset($disabled_metaboxes_post_['administrator']['0'])) { $disabled_metaboxes_post_['administrator']['0'] = ''; } if (version_compare(substr($wp_version, 0, 3), '2.7', '<')) { if (!__wp_supercustom_cms_recursive_in_array('#categorydivsb', $disabled_metaboxes_post_all)) { add_action('submitpost_box', '__wp_supercustom_cms_sidecat_list_category_box'); } if (!__wp_supercustom_cms_recursive_in_array('#tagsdivsb', $disabled_metaboxes_post_all)) { add_action('submitpost_box', '__wp_supercustom_cms_sidecat_list_tag_box'); } } } // only pages if ('page-new.php' == $pagenow || 'page.php' == $pagenow || 'post_type=page' == esc_attr($_SERVER['QUERY_STRING']) || 'page' == $post_type) { // check for array empty if (!isset($disabled_metaboxes_page_['editor']['0'])) { $disabled_metaboxes_page_['editor']['0'] = ''; } if (isset($disabled_metaboxes_page_['administrator']['0'])) { $disabled_metaboxes_page_['administrator']['0'] = ''; } } } }
/** * remove the dashbord * @author of basic Austin Matzko * http://www.ilfilosofo.com/blog/2006/05/24/plugin-remove-the-wordpress-dashboard/ */ function __wp_supercustom_cms_remove_dashboard() { global $menu, $submenu, $user_ID, $wp_version; $user_roles = __wp_supercustom_cms_get_all_user_roles(); foreach ($user_roles as $role) { $disabled_menu_[$role] = __wp_supercustom_cms_get_option_value('wp_supercustom_cms_disabled_menu_' . $role . '_items'); $disabled_submenu_[$role] = __wp_supercustom_cms_get_option_value('wp_supercustom_cms_disabled_submenu_' . $role . '_items'); } $disabled_menu_all = array(); $disabled_submenu_all = array(); foreach ($user_roles as $role) { array_push($disabled_menu_all, $disabled_menu_[$role]); array_push($disabled_submenu_all, $disabled_submenu_[$role]); } // remove dashboard if ($disabled_menu_all != '' || $disabled_submenu_all != '') { foreach ($user_roles as $role) { if (current_user_can($role)) { if (__wp_supercustom_cms_recursive_in_array('index.php', $disabled_menu_[$role]) || __wp_supercustom_cms_recursive_in_array('index.php', $disabled_submenu_[$role])) { $redirect = TRUE; } else { $redirect = FALSE; } } } if ($redirect) { $__wp_supercustom_cms_db_redirect = __wp_supercustom_cms_get_option_value('__wp_supercustom_cms_db_redirect'); $__wp_supercustom_cms_db_redirect_admin_url = get_option('siteurl') . '/wp-admin/'; switch ($__wp_supercustom_cms_db_redirect) { case 0: $__wp_supercustom_cms_db_redirect = $__wp_supercustom_cms_db_redirect_admin_url . 'profile.php'; break; case 1: $__wp_supercustom_cms_db_redirect = $__wp_supercustom_cms_db_redirect_admin_url . 'edit.php'; break; case 2: $__wp_supercustom_cms_db_redirect = $__wp_supercustom_cms_db_redirect_admin_url . 'edit.php?post_type=page'; break; case 3: $__wp_supercustom_cms_db_redirect = $__wp_supercustom_cms_db_redirect_admin_url . 'post-new.php'; break; case 4: $__wp_supercustom_cms_db_redirect = $__wp_supercustom_cms_db_redirect_admin_url . 'page-new.php'; break; case 5: $__wp_supercustom_cms_db_redirect = $__wp_supercustom_cms_db_redirect_admin_url . 'edit-comments.php'; break; case 6: $__wp_supercustom_cms_db_redirect = __wp_supercustom_cms_get_option_value('__wp_supercustom_cms_db_redirect_txt'); break; } // fallback for WP smaller 3.0 if (version_compare($wp_version, "3.0alpha", "<") && 'edit.php?post_type=page' == $__wp_supercustom_cms_db_redirect) { $__wp_supercustom_cms_db_redirect = 'edit-pages.php'; } $the_user = new WP_User($user_ID); reset($menu); $page = key($menu); while (__('Dashboard') != $menu[$page][0] && next($menu) || __('Dashboard') != $menu[$page][1] && next($menu)) { $page = key($menu); } if (__('Dashboard') == $menu[$page][0] || __('Dashboard') == $menu[$page][1]) { unset($menu[$page]); } reset($menu); $page = key($menu); while (!$the_user->has_cap($menu[$page][1]) && next($menu)) { $page = key($menu); } if (preg_match('#wp-admin/?(index.php)?$#', $_SERVER['REQUEST_URI'])) { wp_redirect($__wp_supercustom_cms_db_redirect); } } } }
/** * Remove Admin Bar */ function __wp_supercustom_cms_remove_admin_bar() { // exclude super admin if (__wp_supercustom_cms_exclude_super_admin()) { return NULL; } global $wp_version; $user_roles = __wp_supercustom_cms_get_all_user_roles(); foreach ($user_roles as $role) { $disabled_global_option_[$role] = __wp_supercustom_cms_get_option_value('wp_supercustom_cms_disabled_global_option_' . $role . '_items'); } foreach ($user_roles as $role) { if (!isset($disabled_global_option_[$role]['0'])) { $disabled_global_option_[$role]['0'] = ''; } } $remove_adminbar = FALSE; // new 1.7.8 foreach ($user_roles as $role) { $user = wp_get_current_user(); if (is_array($user->roles) && in_array($role, $user->roles)) { if (current_user_can($role) && isset($disabled_global_option_[$role]) && is_array($disabled_global_option_[$role])) { $global_options = implode(', ', $disabled_global_option_[$role]); if (__wp_supercustom_cms_recursive_in_array('.show-admin-bar', $disabled_global_option_[$role])) { $remove_adminbar = TRUE; } } } } if ($remove_adminbar) { // for deactivate admin bar in WP smaller WP 3.3 if (version_compare($wp_version, '3.3alpha', '<=')) { add_filter('show_admin_bar', '__return_false'); wp_deregister_script('admin-bar'); wp_deregister_style('admin-bar'); remove_action('wp_footer', 'wp_admin_bar_render', 1000); remove_action('wp_head', '_admin_bar_bump_cb'); } else { if (!is_admin_bar_showing()) { return false; } wp_deregister_script('admin-bar'); wp_deregister_style('admin-bar'); remove_action('init', '_wp_admin_bar_init'); remove_action('wp_footer', 'wp_admin_bar_render', 1000); remove_action('admin_footer', 'wp_admin_bar_render', 1000); // maybe also: 'wp_head' foreach (array('admin_head') as $hook) { add_action($hook, create_function('', "echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';")); } add_action('in_admin_header', '__wp_supercustom_cms_restore_links'); } // end else version 3.3 } // end if $remove_adminbar TRUE }