WordPress.org

Ready to get started?Download WordPress

Forums

Toolbar Theme Switcher
[resolved] PATCH show current theme name, current template (2 posts)

  1. lkraav
    Member
    Posted 2 years ago #

    commit 39ee9c234abb38aaf67cd0abe3344b1ec6cc53c2
    Author: Leho Kraav <leho@kraav.com>
    Date:   Fri May 4 09:33:15 2012 -0400
    
        show current theme name in admin bar node
    
        we need to know $current before adding node, therefore we're moving it up
    
    diff --git a/toolbar-theme-switcher.php b/toolbar-theme-switcher.php
    index aa4ddfe..05c7e6c 100644
    --- a/toolbar-theme-switcher.php
    +++ b/toolbar-theme-switcher.php
    @@ -191,13 +191,14 @@ class Toolbar_Theme_Switcher {
         */
        static function admin_bar_menu( $wp_admin_bar ) {
    
    +       $themes  = self::get_allowed_themes();
    +       $current = ! empty( self::$theme_name ) ? self::$theme_name : get_option( 'current_theme' );
    +
            $wp_admin_bar->add_node( array(
                'id'        => 'toolbar_theme_switcher',
    -           'title' => 'Theme'
    +           'title' => 'Theme: ' . $current,
            ) );
    
    -       $themes  = self::get_allowed_themes();
    -       $current = ! empty( self::$theme_name ) ? self::$theme_name : get_option( 'current_theme' );
    
            foreach ( $themes as $theme ) {
    
    commit fc5b37ec22cfab997467a040c5f5befc73e0fd5a
    Author: Leho Kraav <leho@kraav.com>
    Date:   Fri May 4 09:35:45 2012 -0400
    
        add a new node, showing currently used template name
    
        this could be made a plugin option for those that don't need it? i find this
        info invaluable, since it's often very difficult to tell what template wordpress
        arrived at.
    
    diff --git a/toolbar-theme-switcher.php b/toolbar-theme-switcher.php
    index 05c7e6c..c68ea9b 100644
    --- a/toolbar-theme-switcher.php
    +++ b/toolbar-theme-switcher.php
    @@ -190,6 +190,7 @@ class Toolbar_Theme_Switcher {
         * @param WP_Admin_Bar $wp_admin_bar
         */
        static function admin_bar_menu( $wp_admin_bar ) {
    +        global $template;
    
            $themes  = self::get_allowed_themes();
            $current = ! empty( self::$theme_name ) ? self::$theme_name : get_option( 'current_theme' );
    @@ -199,6 +200,13 @@ class Toolbar_Theme_Switcher {
                'title' => 'Theme: ' . $current,
            ) );
    
    +        $template_file = basename( $template );
    +        $template_dir = basename( dirname( $template ) );
    +
    +       $wp_admin_bar->add_node( array(
    +           'id'        => 'toolbar_theme_switcher_template',
    +           'title' => $template_dir . '/' . $template_file,
    +       ) );
    
            foreach ( $themes as $theme ) {

    http://wordpress.org/extend/plugins/toolbar-theme-switcher/

  2. Andrey "Rarst" Savchenko
    Member
    Plugin Author

    Posted 2 years ago #

    Version 1.1 released

    http://wordpress.org/extend/plugins/toolbar-theme-switcher/changelog/

    1. Theme name now shown in toolbar, as per your suggestion.
    2. I think technical template details are not in scope for this plugin (I hate those bits all over different pieces of code, thinking about making comprehensive context plugin), but I've added tts_root_title filter so you can add that after title without having to fork or subclass.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic