如何获得菜单隐藏代码在wordpress


how to get menu is hiding code in wordpress

我使用的主题(wordpress)自带的用户角色。如果我登录与管理员角色的所有菜单在wp-admin出现,这是正确的。但是,当我登录从管理员与角色订阅者所有管理菜单都隐藏。我有搜索函数。php,但没有代码隐藏菜单。在花费大量时间搜索隐藏代码后,没有结果。

有人能告诉我哪些文件可能包含隐藏代码吗?查找代码要花很多时间。

function my_function_admin_bar(){
    echo "Access";exit;
    return true;
}
add_filter( 'show_admin_bar' , 'my_function_admin_bar');

updted显然也

 <?php
    @ob_start();

    define('velocity_FUNCTIONS', get_template_directory() . '/functions/');
    define('velocity_THEME', get_template_directory_uri());
    define('velocity_JAVASCRIPT', get_template_directory_uri() . '/js');
    define('velocity_CSS', get_template_directory_uri() . '/css');
    define('velocity_TYPE', get_template_directory_uri() . '/type');
    $result = add_role( 'CustomP', __(
    'Customp' ),
    array(
    'read' => true, // true allows this capability
    'edit_posts' => true, // Allows user to edit their own posts
    'edit_pages' => true, // Allows user to edit pages
    'edit_others_posts' => true, // Allows user to edit others posts not just their own
    'create_posts' => true, // Allows user to create new posts
    'manage_categories' => true, // Allows user to manage post categories
    'publish_posts' => true, // Allows the user to publish, otherwise posts stays in draft mode
    'edit_themes' => false, // false denies this capability. User can’t edit your theme
    'install_plugins' => false, // User cant add new plugins
    'update_plugin' => false, // User can’t update any plugins
    'update_core' => false // user cant perform core updates
    )
    );

    /* Admin Functionality */
    if (is_admin()){
   function my_function_admin_bar(){
        echo "Access";exit;
        return true;
    }
    add_filter( 'show_admin_bar' , 'my_function_admin_bar');
        require_once(velocity_FUNCTIONS . '/page_options/theme_page_options.php');
        require_once(velocity_FUNCTIONS . '/theme_options/theme_settings.php');
        if(function_exists("wpb_map")){
            require_once(velocity_FUNCTIONS . '/theme_builder.php');
        }
        require_once(velocity_FUNCTIONS . '/thundercodes/thundericons.php');
        if(get_option('velocity_first_import')!="on"){
            require_once(velocity_FUNCTIONS . '/theme_activate.php');
        }
        require_once(velocity_FUNCTIONS . '/theme_plugins.php');
        require_once(velocity_FUNCTIONS . '/theme_startmessage.php');
        require_once(velocity_FUNCTIONS . '/theme_featured_image_preview.php');
        require_once(velocity_FUNCTIONS . '/theme_docu.php');
    }
    require_once(velocity_FUNCTIONS . '/navigation/sweet-custom-menu.php');
    /* Theme Functionality */
    require_once(velocity_FUNCTIONS . '/theme_support.php');
    require_once(velocity_FUNCTIONS . '/aq_resize.php');
    require_once(velocity_FUNCTIONS . '/theme_functions.php');
    require_once(velocity_FUNCTIONS . '/theme_pagination.php');
    require_once(velocity_FUNCTIONS . '/theme_javascriptcss.php');
    require_once(velocity_FUNCTIONS . '/theme_widgets.php');
    require_once(velocity_FUNCTIONS . '/theme_sidebars.php');
    require_once(velocity_FUNCTIONS . '/theme_post_comments.php');
    require_once(velocity_FUNCTIONS . '/theme_breadcrumbs.php');
    if(!is_admin()){
    require_once(velocity_FUNCTIONS . '/theme_options/theme_style_generate.php');
    }
    /* Theme Language */
    require_once(velocity_FUNCTIONS . '/theme_language.php');
    /* Media Box */
    function load_media_box(){
     if(function_exists(wp_enqueue_media())) wp_enqueue_media();
    }
    add_action('admin_enqueue_scripts', 'load_media_box'); 
    ?>
    <?php

    function my_login_redirect($redirect_to, $request) {
    $redirect_url = get_bloginfo( 'url' ) . '/wp-admin/';
    return $redirect_url;
    }
    add_filter("login_redirect", "my_login_redirect", 10, 3);

    /* new code */
        /*
        global $wp_roles;
        foreach ( $wp_roles->role_names as $role => $name ) :
        if ( current_user_can( $role ) )
                echo 'This user has a role of ' . $role;
         endforeach;*/
    ?>

这是一个选项,从特定的用户/用户组隐藏Admin菜单。您可以通过编辑用户启用/禁用该功能,并勾选/取消勾选:

查看站点时显示工具栏


UPDATE或者,您可以使用show_admin_bar(true)在您的主题中显示functions.php中的管理栏。

if(is_admin()) {
  show_admin_bar(true);
}

参考:https://codex.wordpress.org/Function_Reference/show_admin_bar