• Resolved wilbert schaapman

    (@wilbertschaapmancom)


    Button to have a menu item to customize your template
    Bottom Admin Toolbar
    Replace the toolbar dropdown menu with wp-admin menu
    Enable/Disable button to toggle the toolbar

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Bowo

    (@qriouslad)

    This is not clear enough. Please elaborate on each point.

    Thread Starter wilbert schaapman

    (@wilbertschaapmancom)

    Button to have a menu item to customize your template
    I like to go directly to costomize theme with a button in the admin bar


    Bottom Admin Toolbar
    Show the bar at the bottom of the dashboar’`n sted oof the top (there is a plugin fot that)


    Replace the toolbar dropdown menu with wp-admin menu
    All admin menu items anbd sub items directly avialable

    Enable/Disable button to toggle the toolbar
    Show or hide the toolbar

    Plugin Author Bowo

    (@qriouslad)

    Thanks for explaining further. My response below after your comments.

    Button to have a menu item to customize your template
    I like to go directly to costomize theme with a button in the admin bar

    Probably best left to a code snippet. It’s not something many users will likely need.

    Bottom Admin Toolbar

    Not a fan of that approach. I prefer to keep admin UI as close to core WP as possible. Moving it to the bottom may cause incompatibilities with plugins admin screens.

    Replace the toolbar dropdown menu with wp-admin menu
    All admin menu items anbd sub items directly avialable

    Not sure what is gained by lumping together the top admin toolbar menu items into a single dropdown.

    Enable/Disable button to toggle the toolbar

    See my second response above.

    Thanks again.

    Bri

    (@tinnyfusion)

    Hi, see below snippets to add the functionality you need.

    NOTE: These haven’t been tested as I’m on mobile.

    Add a Customiser link to the admin toolbar:

    function customizer_admin_bar_link() {
        if (is_admin_bar_showing()) {
            global $wp_admin_bar;
            $wp_admin_bar->add_menu(array(
                'id' => 'customizer-link',
                'title' => __('Customizer'),
                'href' => admin_url('customize.php'),
                'meta' => array(
                    'class' => 'customizer-link',
                    'target' => '_blank', // Open link in a new tab
                    'title' => __('Customize your site'), // Tooltip
                ),
            ));
        }
    }
    add_action('admin_bar_menu', 'customizer_admin_bar_link', 100);

    Move admin toolbar to bottom of screen but only in front end:

    // Move admin toolbar to the bottom on the front end
    function move_admin_toolbar() {
        if (is_admin_bar_showing()) {
            remove_action('wp_footer', 'wp_admin_bar_render', 1000);
            add_action('wp_footer', 'wp_admin_bar_render', 1000);
        }
    }
    add_action('wp_footer', 'move_admin_toolbar', 999);

    Let me know if these work for you.

    Bri

    (@tinnyfusion)

    Ok, just got back home and tested my snippets. The first one is totally fine, although I did make a slight adjustment to have it open in the same tab. I have included instructions on how to change it so that it opens the customizer in a new tab if that is what you prefer.

    Here is the new version:

    // Add link to the customizer on the admin bar
    function customizer_admin_bar_link() {
        if (is_admin_bar_showing()) {
            global $wp_admin_bar;
            $wp_admin_bar->add_menu(array(
                'id' => 'customizer-link',
                'title' => __('Customizer'),
                'href' => admin_url('customize.php'),
                'meta' => array(
                    'class' => 'customizer-link',
                    'target' => '_self', // To open link in a new tab use _blank
                    'title' => __('Customize your site'), // Tooltip
                ),
            ));
        }
    }
    add_action('admin_bar_menu', 'customizer_admin_bar_link', 100);

    As for the second snippet, I realise now that this isn’t what you asked for so rather that re-invent the wheel I got the following from isitwp.com which does as you requested and moves the admin bar to the bottom of the screen while viewing the frontend:

    // Move admin toolbar to the bottom
    function move_admin_bar() {
    echo '
        <style type="text/css">
            body {margin-top: -28px;padding-bottom: 28px;}
            body.admin-bar #wphead {padding-top: 0;}
            body.admin-bar #footer {padding-bottom: 28px;}
            #wpadminbar { top: auto !important;bottom: 0;}
            #wpadminbar .quicklinks .menupop .ab-sub-wrapper { bottom: 28px;}
            #wpadminbar .quicklinks .menupop ul { bottom: 0;}
        </style>';
    }
    
    add_action( 'wp_head', 'move_admin_bar' );

    Finally, my apologies for adding a whole new post as opposed to simply editing my pervious reply but the ‘Edit’ option was no longer available.

    Bri

    (@tinnyfusion)

    While doing something else I noticed that there is already a link to the customizer on the admin bar… It is displayed when viewing the front-end by default, or at least it is in WordPress v6.4.3.

    This renders the need for the above redundant.

    Thread Starter wilbert schaapman

    (@wilbertschaapmancom)

    Thanks for the shortcodes!

    The customizer is showing only when you are on a page of the website. Not when you are in the Dashboard of wp.

    Bri

    (@tinnyfusion)

    You are very welcome. Glad they were of use to up.

    During my testing I did notice the bottom menu snippet doesn’t play well with some plugins that add their own stuff there so something to think about. For example, Google Site Kit adds analytics for the page you are viewing but the menu refuses to open up so you can’t see it properly.

    Personally I don’t use the snippet and instead prefer a simple bit of CSS to add a bit of transparency to the WordPress admin bar when viewing on the front end.

    Just add the following to your child themes style.css:

    /* Set colour and transparency of admin toolbar on front-end */
    div#wpadminbar { background-color: #222222 !important; opacity: 0.5; }

    Feel free of course to change the opacity value to suit your needs.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Feature : Admin bar’ is closed to new replies.