Plugin Directory

Changeset 1700552


Ignore:
Timestamp:
07/21/2017 06:24:20 PM (9 years ago)
Author:
Melissa Cabral
Message:

version 3.0 complete

Location:
theme-inspector/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • theme-inspector/trunk/readme.txt

    r1522612 r1700552  
    33Donate link: http://wordpress.melissacabral.com/donate
    44Tags: template, theme, utility, developer, Inspector, tool, wordpress
    5 Requires at least: 3.0.1
    6 Tested up to: 4.6.1
    7 Stable tag: 2.2.3
    8 License: GPLv3 or later
    9 License URI: http://www.gnu.org/licenses/gpl-3.0.html
     5Requires at least: 4.0
     6Tested up to: 4.8.0
     7Stable tag: 3.0.1
     8License: GPLv2 or later
     9License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    1111A developer's inspector to illuminate the WordPress Template Hierarchy and help with building WordPress themes.
     
    1515A simple, lightweight plugin that displays useful technical information on pages and posts to aid in developing Wordpress themes. Provides quick access to things that are sometimes hidden, like post/page ID, slug, taxonomy terms, and post type slug. Theme Inspector tells you exactly what conditional tags are true on each view, and what template file loaded on each page view.
    1616
    17 * Use In Conjunction with the [WP Template Hierarchy Document](https://docs.google.com/drawings/d/1hJ0MpHO3HKBT5KsTpGtc_gDYZ5pi-HyxNcRtmPBBULE).
     17* Use In Conjunction with the [WP Template Hierarchy Document](https://docs.google.com/drawings/d/1hJ0MpHO3HKBT5KsTpGtc_gDYZ5pi-HyxNcRtmPBBULE/edit).
    1818* Theme Inspector is only visible to logged in Administrators.
    1919* Appears on the right-side of the Toolbar (admin bar).
     
    4141== Changelog ==
    4242
     43= 3.0 =
     44* Added the complete template hierarchy chain for the currently displayed page
     45* minor CSS improvements
     46
    4347= 2.0 =
    4448* Moved the display to the admin bar (toolbar) for consistency
     
    5357== Upgrade Notice ==
    5458
     59= 3.0 =
     60Upgrade because this version will save you the step of opening and reading the entire Hiearchy diagram
     61
    5562= 2.0 =
    5663Upgrade because this version is way better than the last one and addresses a handful of minor bugs.
     64
     65
  • theme-inspector/trunk/theme-inspector.css

    r1305862 r1700552  
    99    background-color: rgba(41,200,235,.2);
    1010 }
    11  #wpadminbar #theme-helper-toolbar{
     11 #theme-helper-toolbar{
    1212    display:none;
    1313    font-family:"Trebuchet MS"!important;
    14     background:#fff;
     14    background:#fff !important;
     15    color:black !important;
    1516    font-size:16px;
    1617    position:absolute;
     
    2425    box-shadow: 0 4px 4px rgba(0,0,0,0.2);
    2526 }
    26  #wpadminbar .theme-helper:hover #theme-helper-toolbar,
    27  #wpadminbar .theme-helper:focus #theme-helper-toolbar{
     27 .theme-helper:hover #theme-helper-toolbar,
     28 .theme-helper:focus #theme-helper-toolbar{
    2829    display:block;
    2930 }
    30  #wpadminbar #theme-helper-toolbar table{
     31 #theme-helper-toolbar table{
    3132    width: 100%;
    3233    border-collapse: collapse;
    3334 }
    34  #wpadminbar #theme-helper-toolbar th{
     35 #theme-helper-toolbar th{
    3536    font-weight: bold;
    3637    background-color:rgba(0,0,0,.06);
     
    4142    text-shadow:none;
    4243 }
    43  #wpadminbar #theme-helper-toolbar .file-loaded{
     44 #theme-helper-toolbar .file-loaded{
    4445    background-color: #FCFFD2;
    4546 }
    46  #wpadminbar #theme-helper-toolbar td{
     47 #theme-helper-toolbar td{
    4748    color:black;
    4849    padding:.5em;
     
    5051    text-shadow:none;
    5152 }
    52  #wpadminbar #theme-helper-toolbar .condition{
     53 #theme-helper-toolbar .condition{
    5354    color:#999;
    5455    text-shadow:none;
     56        font-family: monospace !important;
    5557 }
    56  #wpadminbar #theme-helper-toolbar .first{
     58 #theme-helper-toolbar .first{
    5759    font-weight: bold;
    5860    color:#000;
    5961 }
    60  #wpadminbar #theme-helper-toolbar .credits td{
     62 #theme-helper-toolbar .credits td{
    6163    text-align: center;
    6264    font: normal 11px/13px sans-serif;
     
    6466    line-height:normal;
    6567    background-color:#EDF5FA;
     68
    6669 }
    67  #wpadminbar #theme-helper-toolbar .credits a{
     70 #theme-helper-toolbar .credits a{
    6871    display:inline;
    6972    font-size:inherit;
     
    7679    line-height:14px;
    7780 }
    78  #wpadminbar #theme-helper-toolbar .usewith td{
    79 border-top:none;
    80 }
    81 
     81 #theme-helper-toolbar .usewith td{
     82    border-top:none;
     83    border-bottom:solid 1px #ddd;
     84 }
     85 #theme-helper-toolbar .hierarchy {
     86    font-family: monospace !important;
     87    color:#999 !important;
     88 }
     89 #theme-helper-toolbar .template{
     90    font-family: inherit;
     91    color:black;
     92    background-color:rgba(0,0,0,.04);
     93    padding:.15em .4em;
     94    white-space:nowrap;
     95    border:solid 1px rgba(0,0,0,.1);
     96 }
     97 #theme-helper-toolbar .current-template{
     98    background-color: #FCFFD2;
     99    font-weight: bold;
     100 }
    82101/*Theme Helper CSS end*/
  • theme-inspector/trunk/theme-inspector.php

    r1522612 r1700552  
    55Description:  displays useful technical information on pages and posts to aid in developing Wordpress themes. Only visible to administrators.  Use In Conjunction with the WP Template Hierarchy Document
    66Author: Melissa Cabral
    7 Version: 2.2.3
     7Version: 3.0.1
    88Author URI: http://melissacabral.com/
    99*/
     
    1414add_action( 'admin_bar_menu', 'mmc_toolbar_link', 999 );
    1515function mmc_toolbar_link( $wp_admin_bar ) {   
    16     if (current_user_can('install_themes')) {
     16    if (current_user_can('install_themes') && !is_admin()) {
    1717        $html = mmc_generate_output();
    1818        $args = array(
     
    4040        ?>
    4141        <!-- WordPress Theme Inspector by Melissa Cabral-->
    42             <div id="theme-helper-toolbar">
     42        <div id="theme-helper-toolbar">
    4343            <table>
    4444                <?php if(is_admin()){ ?>
     
    6161                    <td><?php echo adminhelper_true_conditions()?></td>
    6262                </tr>
     63               
    6364                <?php if( !is_404() && ! is_search() &&  get_post_type() ) { ?>
    6465                <tr>
     
    7273                    <th>Taxonomy:</th>
    7374                    <td><?php
    74                     echo adminhelper_taxonomy()?>
     75                        echo adminhelper_taxonomy()?>
    7576                    </td>
    7677                </tr>
     
    8788                </tr>       
    8889                <?php
    89                 }   ?>
    90                 <tr class="file-loaded">
    91                     <th>File Loaded:</th>
    92                     <td><?php echo adminhelper_get_current_template() ?></td>
    93                 </tr>
    94                 <?php } //end not admin ?>
    95                 <tr class="credits">
    96                     <td colspan="2">Theme Inspector by <a href="https://wordpress.org/plugins/theme-inspector">Melissa Cabral</a>.</td>
    97                 </tr>
    98                 <tr class="credits usewith">
    99                     <td colspan="2">Use with <a target="_blank" href="https://docs.google.com/drawings/d/1hJ0MpHO3HKBT5KsTpGtc_gDYZ5pi-HyxNcRtmPBBULE">Hierarchy Diagram</a></td>
    100                 </tr>
    101             </table>
    102         </div><!-- End Theme Inspector -->
     90            }   ?>
     91            <tr class="file-loaded">
     92                <th>Template File Loaded:</th>
     93                <td><?php echo adminhelper_get_current_template() ?></td>
     94            </tr>
     95            <tr>
     96                <td colspan="2" class="hierarchy">
     97                <i>Template Hierarchy for this screen:</i><br>
     98                <?php echo adminhelper_hierarchy()?>
     99                </td>
     100            </tr>
     101            <?php } //end not admin ?>
     102            <tr class="credits">
     103                <td colspan="2">Theme Inspector Plugin by <a href="https://wordpress.org/plugins/theme-inspector">Melissa Cabral</a>.</td>
     104            </tr>
     105            <tr class="credits usewith">
     106                <td colspan="2">Use with the WordPress <a target="_blank" href="https://docs.google.com/drawings/d/1hJ0MpHO3HKBT5KsTpGtc_gDYZ5pi-HyxNcRtmPBBULE">Hierarchy Diagram</a></td>
     107            </tr>
     108        </table>
     109    </div><!-- End Theme Inspector -->
    103110    <?php   
    104111    return ob_get_clean();         
     
    163170    $count = 0;
    164171    if (is_admin()) { $conditions[] = "is_admin()"; }
    165     if (is_home()) { $conditions[] = "is_home()"; }
    166172    if (is_front_page()) { $conditions[] = "is_front_page()"; }
     173    if (is_home()) { $conditions[] = "is_home()"; }
    167174    if (is_attachment() ){ $conditions[] = "is_attachment()"; }
    168175    if (is_single()) { $conditions[] = "is_single()"; }
     
    192199    return $output;
    193200}
     201/**
     202 * Display the current hierarchy chain for this page
     203 * @return mixed HTML output
     204 * @since  3.0 Added this functionality
     205 */
     206function adminhelper_hierarchy(){
     207    global $post;
     208    $output = '';
     209    $hierarchy = array();
     210
     211    //current post info
     212    $slug = $post->post_name;
     213    $id = $post->ID;
     214    $type = get_post_type();   
     215
     216    if( is_404() ){
     217        $hierarchy[] = '404.php';
     218    }elseif( is_search() ){
     219        $hierarchy[] = 'search.php';
     220    }elseif( is_front_page() ){
     221        if( is_page() ){
     222            $hierarchy = array('front-page.php', '<i>custom template</i>', "page-$slug.php",  "page-$id.php", 'page.php', 'singular.php') ;
     223        }else{
     224            $hierarchy = array('front-page.php', 'home.php') ;
     225        }
     226    }elseif( is_home() ){
     227        $hierarchy[] = 'home.php';
     228    }elseif( is_archive() ){
     229        if( is_author() ){         
     230            $author_id = $post->post_author;
     231            $nicename = get_the_author_meta('nicename');
     232            $hierarchy = array( "author-$nicename.php", "author-$author_id.php", 'author.php' );
     233        }elseif( is_category() ){
     234            $cat = get_category( get_query_var( 'cat' ) );
     235            $cat_slug = $cat->slug;
     236            $cat_id = $cat->cat_ID;
     237            $hierarchy = array( "category-$cat_slug.php", "category-$cat_id.php", 'category.php' );
     238        }elseif(is_tag()){
     239            $tag = get_queried_object();
     240            $tag_slug =  $tag->slug;       
     241            $tag_id = $tag->term_id;
     242            $hierarchy = array( "tag-$tag_slug.php", "tag-$tag_id.php", 'tag.php' );
     243        }elseif(is_tax()){
     244            $tax = get_queried_object();
     245            $tax_name = $tax->taxonomy;
     246            $term =  $tax->slug;   
     247       
     248            $hierarchy = array( "taxonomy-$tax_name-$term.php", "taxonomy-$tax_name.php", 'taxonomy.php' );
     249        }elseif( is_post_type_archive()  ){         
     250            $hierarchy = array( "archive-$type.php" );
     251        }elseif( is_date() ){
     252            $hierarchy = array( "date.php" );
     253        }
     254        $hierarchy[] = 'archive.php';
     255    }elseif(is_singular()){
     256        if(is_page()){         
     257            $hierarchy = array( '<i>custom template</i>', "page-$slug.php",  "page-$id.php", 'page.php' );
     258        }elseif(is_attachment()){
     259            $mime = get_post_mime_type();
     260            $type = explode( '/', $mime );
     261            $hierarchy = array( "$type[0]-$type[1].php", "$type[1].php",  "$type[0].php", 'attachment', 'single.php' );
     262        }elseif( is_singular('post') ){
     263            $hierarchy = array('<i>custom template</i>', 'single-post.php', 'single.php');
     264        }else{
     265            //single custom post           
     266            $hierarchy = array('<i>custom template</i>', "single-$type-$slug.php", "single-$type.php", 'single.php');
     267        }
     268       
     269        $hierarchy[] = 'singular.php';
     270    }
     271   
     272    //default template:
     273    $hierarchy[] = 'index.php';
     274
     275    $sep = '';
     276    foreach($hierarchy as $value){
     277        $class = 'template';
     278        if($GLOBALS['current_theme_template'] == $value){
     279            $class .= ' current-template';
     280        }
     281        $output.=  $sep .  '<span class="' . $class . '">' . $value . '</span>';
     282        $sep = ' &rarr; ';
     283    }
     284   
     285    return $output;
     286}
    194287function adminhelper_get_current_template(  ) {
    195288    if( !isset( $GLOBALS['current_theme_template'] ) ){
     
    213306function adminhelper_enqueue_stylesheet(){
    214307    if(is_user_logged_in() && is_admin_bar_showing()){
    215     $src = plugins_url( 'theme-inspector.css', __FILE__ );
    216     wp_register_style( 'themehelper-style', $src, '', '', 'screen' );
    217     wp_enqueue_style( 'themehelper-style' );
    218     }
    219 }
     308        $src = plugins_url( 'theme-inspector.css', __FILE__ );
     309        wp_register_style( 'themehelper-style', $src, '', '', 'screen' );
     310        wp_enqueue_style( 'themehelper-style' );
     311    }
     312}
Note: See TracChangeset for help on using the changeset viewer.