本文整理汇总了PHP中_mw_adminimize_exclude_super_admin函数的典型用法代码示例。如果您正苦于以下问题:PHP _mw_adminimize_exclude_super_admin函数的具体用法?PHP _mw_adminimize_exclude_super_admin怎么用?PHP _mw_adminimize_exclude_super_admin使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_mw_adminimize_exclude_super_admin函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _mw_adminimize_change_admin_bar
/**
* Remove items in Admin Bar for current role of current active user in front end area
* Exclude Super Admin, if active
* Exclude Settings page of Adminimize
*
* @since 1.8.1 01/10/2013
*/
function _mw_adminimize_change_admin_bar()
{
// Only for users, there logged in.
if (!is_user_logged_in()) {
return;
}
// Exclude super admin.
if (_mw_adminimize_exclude_super_admin()) {
return;
}
/** @var $wp_admin_bar WP_Admin_Bar */
global $wp_admin_bar;
// Get current user data.
$user = wp_get_current_user();
if (!$user->roles[0]) {
return;
}
$user_role = $user->roles[0];
// Get Backend Admin Bar settings for the current user role.
if (is_admin()) {
$disabled_admin_bar_option_[$user_role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_admin_bar_' . $user_role . '_items');
} else {
// Get Frontend Admin Bar settings for the current user role.
$disabled_admin_bar_option_[$user_role] = (array) _mw_adminimize_get_option_value('mw_adminimize_disabled_admin_bar_frontend_' . $user_role . '_items');
}
// No settings for this role, exit.
if (!$disabled_admin_bar_option_[$user_role]) {
return;
}
foreach ($disabled_admin_bar_option_[$user_role] as $admin_bar_item) {
$wp_admin_bar->remove_node($admin_bar_item);
}
}
示例2: _mw_adminimize_dashboard_setup
/**
* Set dashboard widget options.
*/
function _mw_adminimize_dashboard_setup()
{
// exclude super admin
if (_mw_adminimize_exclude_super_admin()) {
return;
}
$user_roles = _mw_adminimize_get_all_user_roles();
$disabled_dashboard_option_ = array();
foreach ($user_roles as $role) {
$disabled_dashboard_option_[$role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_dashboard_option_' . $role . '_items');
}
foreach ($user_roles as $role) {
if (!isset($disabled_dashboard_option_[$role]['0'])) {
$disabled_dashboard_option_[$role]['0'] = '';
}
}
// Get all widgets.
$widgets = _mw_adminimize_get_dashboard_widgets();
// Get current user data.
$user = wp_get_current_user();
foreach ($user_roles as $role) {
if (is_array($user->roles) && is_array($disabled_dashboard_option_[$role]) && in_array($role, $user->roles) && _mw_adminimize_current_user_has_role($role)) {
foreach ($disabled_dashboard_option_[$role] as $widget) {
if (isset($widgets[$widget]['context'])) {
remove_meta_box($widget, 'dashboard', $widgets[$widget]['context']);
}
}
}
}
}
示例3: _mw_adminimize_check_to_remove_admin_notices
/**
* @return bool|null
*/
function _mw_adminimize_check_to_remove_admin_notices()
{
// Exclude super admin.
if (_mw_adminimize_exclude_super_admin()) {
return;
}
$user_roles = _mw_adminimize_get_all_user_roles();
foreach ($user_roles as $role) {
$disabled_global_option_[$role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_global_option_' . $role . '_items');
}
foreach ($user_roles as $role) {
if (!isset($disabled_global_option_[$role]['0'])) {
$disabled_global_option_[$role]['0'] = '';
}
}
$remove_admin_notices = FALSE;
foreach ($user_roles as $role) {
$user = wp_get_current_user();
if (is_array($user->roles) && in_array($role, $user->roles)) {
if (_mw_adminimize_current_user_has_role($role) && isset($disabled_global_option_[$role]) && is_array($disabled_global_option_[$role])) {
$remove_admin_notices = _mw_adminimize_recursive_in_array('.admin-notices', $disabled_global_option_[$role]);
}
}
}
return $remove_admin_notices;
}
示例4: _mw_adminimize_dashboard_setup
function _mw_adminimize_dashboard_setup()
{
global $wp_meta_boxes;
$adminimizeoptions = get_option('mw_adminimize');
$widgets = _mw_adminimize_get_dashboard_widgets();
$adminimizeoptions['mw_adminimize_dashboard_widgets'] = $widgets;
if (current_user_can('manage_options')) {
update_option('mw_adminimize', $adminimizeoptions);
}
// exclude super admin
if (_mw_adminimize_exclude_super_admin()) {
return NULL;
}
$user_roles = _mw_adminimize_get_all_user_roles();
foreach ($user_roles as $role) {
$disabled_dashboard_option_[$role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_dashboard_option_' . $role . '_items');
}
foreach ($user_roles as $role) {
if (!isset($disabled_dashboard_option_[$role]['0'])) {
$disabled_dashboard_option_[$role]['0'] = '';
}
}
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) && is_array($disabled_dashboard_option_[$role])) {
foreach ($disabled_dashboard_option_[$role] as $widget) {
if (isset($widgets[$widget]['context'])) {
remove_meta_box($widget, 'dashboard', $widgets[$widget]['context']);
}
}
}
}
}
}
示例5: _mw_adminimize_change_admin_bar
/**
* Remove items in Admin Bar for current role of current active user
* Exclude Super Admin, if active
* Exclude Settings page of Adminimize
*
* @since 1.8.1 01/10/2013
* @return void
*/
function _mw_adminimize_change_admin_bar($wp_admin_bar)
{
// Don't filter on settings page
if (isset($GLOBALS['current_screen']->base) && 'settings_page_adminimize/adminimize' == $GLOBALS['current_screen']->base) {
return NULL;
}
// Exclude super admin
if (_mw_adminimize_exclude_super_admin()) {
return NULL;
}
$user_roles = _mw_adminimize_get_all_user_roles();
foreach ($user_roles as $role) {
$disabled_admin_bar_option_[$role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_admin_bar_' . $role . '_items');
}
foreach ($user_roles as $role) {
if (!isset($disabled_admin_bar_option_[$role]['0'])) {
$disabled_admin_bar_option_[$role]['0'] = '';
}
}
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) && is_array($disabled_admin_bar_option_[$role])) {
foreach ($disabled_admin_bar_option_[$role] as $admin_bar_item) {
$wp_admin_bar->remove_node($admin_bar_item);
}
}
// end if
}
// end if user roles
}
}
示例6: _mw_adminimize_change_admin_bar
/**
* Remove items in Admin Bar for current role of current active user in front end area
* Exclude Super Admin, if active
* Exclude Settings page of Adminimize
*
* @since 1.8.1 01/10/2013
*/
function _mw_adminimize_change_admin_bar()
{
// Only for users, there logged in.
if (!is_user_logged_in()) {
return;
}
// Exclude super admin.
if (_mw_adminimize_exclude_super_admin()) {
return;
}
// Exclude the new settings of the Admin Bar on settings page of Adminimize.
if (_mw_adminimize_exclude_settings_page()) {
return;
}
// If the admin bar is not active, filtering is not necessary.
if (!is_admin_bar_showing()) {
return;
}
/** @var $wp_admin_bar WP_Admin_Bar */
global $wp_admin_bar;
// Get current user data.
$user = wp_get_current_user();
if (!$user->roles) {
return;
}
// Get all roles of logged in user.
$user_roles = $user->roles;
//$user_roles = _mw_adminimize_get_all_user_roles();
$disabled_admin_bar_option_ = array();
// Get Backend Admin Bar settings for the current user role.
if (is_admin()) {
foreach ($user_roles as $role) {
$disabled_admin_bar_option_[$role] = (array) _mw_adminimize_get_option_value('mw_adminimize_disabled_admin_bar_' . $role . '_items');
}
} else {
// Get Frontend Admin Bar settings for the current user role.
foreach ($user_roles as $role) {
$disabled_admin_bar_option_[$role] = (array) _mw_adminimize_get_option_value('mw_adminimize_disabled_admin_bar_frontend_' . $role . '_items');
}
}
// Merge multidimensional array in to one, flat.
$disabled_admin_bar_option_ = array_reduce($disabled_admin_bar_option_, 'array_merge', array());
// Support Multiple Roles for users.
if (_mw_adminimize_get_option_value('mw_adminimize_multiple_roles') && 1 < count($user->roles)) {
$disabled_admin_bar_option_ = _mw_adminimize_get_duplicate($disabled_admin_bar_option_);
}
// No settings for this role, exit.
if (!$disabled_admin_bar_option_) {
return;
}
foreach ($disabled_admin_bar_option_ as $admin_bar_item) {
$wp_admin_bar->remove_node($admin_bar_item);
}
}
示例7: _mw_adminimize_set_widget_option
/**
* Remove areas in Widget Settings
*/
function _mw_adminimize_set_widget_option()
{
// exclude super admin
if (_mw_adminimize_exclude_super_admin()) {
return NULL;
}
$user_roles = _mw_adminimize_get_all_user_roles();
$_mw_adminimize_admin_head = '';
foreach ($user_roles as $role) {
$disabled_widget_option_[$role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_widget_option_' . $role . '_items');
}
foreach ($user_roles as $role) {
if (!isset($disabled_widget_option_[$role]['0'])) {
$disabled_widget_option_[$role]['0'] = '';
}
}
$widget_options = '';
// 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_widget_option_[$role]) && is_array($disabled_widget_option_[$role])) {
$widget_options = implode(',', $disabled_widget_option_[$role]);
}
}
}
//remove_meta_box( $id, 'nav-menus', 'side' );
$_mw_adminimize_admin_head .= '<style type="text/css">' . $widget_options . ' {display: none !important;}</style>' . "\n";
if ($widget_options) {
echo $_mw_adminimize_admin_head;
}
}
示例8: _mw_adminimize_unregister_sidebars
/**
* Remove sidebars for different roles
*
* @return void
*/
function _mw_adminimize_unregister_sidebars()
{
// Get settings.
$adminimizeoptions = _mw_adminimize_get_option_value();
// Get settings.
_mw_adminimize_update_option($adminimizeoptions);
// exclude super admin
if (_mw_adminimize_exclude_super_admin()) {
return NULL;
}
$user_roles = _mw_adminimize_get_all_user_roles();
foreach ($user_roles as $role) {
$disabled_widget_option_[$role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_widget_option_' . $role . '_items');
}
foreach ($user_roles as $role) {
if (!isset($disabled_widget_option_[$role]['0'])) {
$disabled_widget_option_[$role]['0'] = '';
}
}
foreach ($user_roles as $role) {
$user = wp_get_current_user();
if (is_array($user->roles) && in_array($role, $user->roles)) {
if (_mw_adminimize_current_user_has_role($role) && is_array($disabled_widget_option_[$role])) {
foreach ($disabled_widget_option_[$role] as $sidebar) {
unregister_sidebar($sidebar);
}
}
}
// end if user roles
}
}
示例9: _mw_adminimize_remove_admin_bar
/**
* Remove Admin Bar
*/
function _mw_adminimize_remove_admin_bar()
{
// exclude super admin
if (_mw_adminimize_exclude_super_admin()) {
return NULL;
}
global $wp_version;
$user_roles = _mw_adminimize_get_all_user_roles();
foreach ($user_roles as $role) {
$disabled_global_option_[$role] = _mw_adminimize_get_option_value('mw_adminimize_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 (_mw_adminimize_current_user_has_role($role) && isset($disabled_global_option_[$role]) && is_array($disabled_global_option_[$role])) {
if (_mw_adminimize_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;
}
add_filter('show_admin_bar', '__return_false');
add_filter('wp_admin_bar_class', '__return_false');
add_filter('show_wp_pointer_admin_bar', '__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('wp_head', 'admin_head') as $hook) {
add_action($hook, create_function('', "echo '<style>body.admin-bar, body.admin-bar #wpcontent, body.admin-bar #adminmenu {\n\t\t\t\t\t\t\t padding-top: 0 !important;\n\t\t\t\t\t\t}\n\t\t\t\t\t\thtml.wp-toolbar {\n\t\t\t\t\t\t\tpadding-top: 0 !important;\n\t\t\t\t\t\t}</style>';"));
}
add_action('in_admin_header', '_mw_adminimize_restore_links');
}
// end else version 3.3
}
// end if $remove_adminbar TRUE
return NULL;
}
示例10: _mw_adminimize_change_admin_bar_frontend
/**
* Remove items in Admin Bar for current role of current active user in front end area
* Exclude Super Admin, if active
* Exclude Settings page of Adminimize
*
* @since 1.8.1 01/10/2013
*
* @param $wp_admin_bar
*
* @return null
*/
function _mw_adminimize_change_admin_bar_frontend($wp_admin_bar)
{
// works only for back end admin bar
if (is_admin()) {
return NULL;
}
// Exclude super admin
if (_mw_adminimize_exclude_super_admin()) {
return NULL;
}
$user_roles = _mw_adminimize_get_all_user_roles();
$disabled_admin_bar_frontend_option_ = '';
foreach ($user_roles as $role) {
$disabled_admin_bar_frontend_option_[$role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_admin_bar_frontend_' . $role . '_items');
}
foreach ($user_roles as $role) {
if (!isset($disabled_admin_bar_frontend_option_[$role]['0'])) {
$disabled_admin_bar_frontend_option_[$role]['0'] = '';
}
}
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) && is_array($disabled_admin_bar_frontend_option_[$role])) {
foreach ($disabled_admin_bar_frontend_option_[$role] as $admin_bar_item) {
$wp_admin_bar->remove_node($admin_bar_item);
}
}
// end if
}
// end if user roles
}
}
示例11: _mw_adminimize_unregister_sidebars
/**
* Remove sidebars for different roles
*
* @return void
*/
function _mw_adminimize_unregister_sidebars()
{
if (is_multisite() && is_plugin_active_for_network(MW_ADMIN_FILE)) {
$adminimizeoptions = get_site_option('mw_adminimize');
} else {
$adminimizeoptions = get_option('mw_adminimize');
}
if (current_user_can('manage_options')) {
if (is_multisite() && is_plugin_active_for_network(MW_ADMIN_FILE)) {
update_site_option('mw_adminimize', $adminimizeoptions);
} else {
update_option('mw_adminimize', $adminimizeoptions);
}
}
// exclude super admin
if (_mw_adminimize_exclude_super_admin()) {
return NULL;
}
$user_roles = _mw_adminimize_get_all_user_roles();
foreach ($user_roles as $role) {
$disabled_widget_option_[$role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_widget_option_' . $role . '_items');
}
foreach ($user_roles as $role) {
if (!isset($disabled_widget_option_[$role]['0'])) {
$disabled_widget_option_[$role]['0'] = '';
}
}
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) && is_array($disabled_widget_option_[$role])) {
foreach ($disabled_widget_option_[$role] as $sidebar) {
unregister_sidebar($sidebar);
}
}
}
// end if user roles
}
}
示例12: _mw_adminimize_remove_admin_bar
/**
* Remove Admin Bar
*
* @return null|void
*/
function _mw_adminimize_remove_admin_bar()
{
// exclude super admin
if (_mw_adminimize_exclude_super_admin()) {
return;
}
// Leave the settings screen from Adminimize to see all areas on settings.
if (_mw_adminimize_exclude_settings_page()) {
return;
}
$user_roles = _mw_adminimize_get_all_user_roles();
foreach ($user_roles as $role) {
$disabled_global_option_[$role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_global_option_' . $role . '_items');
}
foreach ($user_roles as $role) {
if (!isset($disabled_global_option_[$role]['0'])) {
$disabled_global_option_[$role]['0'] = '';
}
}
$user = wp_get_current_user();
$remove_adminbar = FALSE;
// new 1.7.8
foreach ($user_roles as $role) {
if (is_array($user->roles) && in_array($role, $user->roles, FALSE)) {
if (_mw_adminimize_current_user_has_role($role) && isset($disabled_global_option_[$role]) && is_array($disabled_global_option_[$role]) && _mw_adminimize_recursive_in_array('.show-admin-bar', $disabled_global_option_[$role])) {
$remove_adminbar = TRUE;
}
}
}
if ($remove_adminbar) {
if (!is_admin_bar_showing()) {
return FALSE;
}
add_filter('show_admin_bar', '__return_false');
add_filter('wp_admin_bar_class', '__return_false');
add_filter('show_wp_pointer_admin_bar', '__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('wp_head', 'admin_head') as $hook) {
add_action($hook, create_function('', "echo '<style>body.admin-bar, body.admin-bar #wpcontent, body.admin-bar #adminmenu {\n\t\t\t\t\t\t\t padding-top: 0 !important;\n\t\t\t\t\t\t}\n\t\t\t\t\t\thtml.wp-toolbar {\n\t\t\t\t\t\t\tpadding-top: 0 !important;\n\t\t\t\t\t\t}</style>';"));
}
add_action('in_admin_header', '_mw_adminimize_restore_links');
}
// end if $remove_adminbar TRUE
}
示例13: _mw_adminimize_remove_admin_bar
/**
* Remove Admin Bar
*
* @return null|void
*/
function _mw_adminimize_remove_admin_bar()
{
// exclude super admin
if (_mw_adminimize_exclude_super_admin()) {
return;
}
// Leave the settings screen from Adminimize to see all areas on settings.
if (_mw_adminimize_exclude_settings_page()) {
return;
}
$user_roles = _mw_adminimize_get_all_user_roles();
$disabled_global_option_ = array();
foreach ($user_roles as $role) {
$disabled_global_option_[$role] = (array) _mw_adminimize_get_option_value('mw_adminimize_disabled_global_option_' . $role . '_items');
}
$mw_global_options = array();
$user = wp_get_current_user();
foreach ($user_roles as $role) {
if (in_array($role, $user->roles, FALSE) && _mw_adminimize_current_user_has_role($role)) {
// Create array about all items with all affected roles, important for multiple roles.
foreach ($disabled_global_option_[$role] as $global_item) {
$mw_global_options[] = $global_item;
}
}
}
// Support Multiple Roles for users.
if (_mw_adminimize_get_option_value('mw_adminimize_multiple_roles') && 1 < count($user->roles)) {
$mw_global_options = _mw_adminimize_get_duplicate($mw_global_options);
}
$remove_adminbar = FALSE;
// Check for admin bar selector to set to remove the Admin Bar.
if (_mw_adminimize_recursive_in_array('.show-admin-bar', $mw_global_options)) {
$remove_adminbar = TRUE;
}
if ($remove_adminbar) {
if (!is_admin_bar_showing()) {
return FALSE;
}
add_filter('show_admin_bar', '__return_false');
add_filter('wp_admin_bar_class', '__return_false');
add_filter('show_wp_pointer_admin_bar', '__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('wp_head', 'admin_head') as $hook) {
add_action($hook, create_function('', "echo '<style>body.admin-bar, body.admin-bar #wpcontent, body.admin-bar #adminmenu {\n\t\t\t\t\t\t\t padding-top: 0 !important;\n\t\t\t\t\t\t}\n\t\t\t\t\t\thtml.wp-toolbar {\n\t\t\t\t\t\t\tpadding-top: 0 !important;\n\t\t\t\t\t\t}</style>';"));
}
add_action('in_admin_header', '_mw_adminimize_restore_links');
}
// end if $remove_adminbar TRUE
}