Changeset 1700552
- Timestamp:
- 07/21/2017 06:24:20 PM (9 years ago)
- Location:
- theme-inspector/trunk
- Files:
-
- 3 edited
-
readme.txt (modified) (4 diffs)
-
theme-inspector.css (modified) (6 diffs)
-
theme-inspector.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
theme-inspector/trunk/readme.txt
r1522612 r1700552 3 3 Donate link: http://wordpress.melissacabral.com/donate 4 4 Tags: template, theme, utility, developer, Inspector, tool, wordpress 5 Requires at least: 3.0.16 Tested up to: 4. 6.17 Stable tag: 2.2.38 License: GPLv 3or later9 License URI: http://www.gnu.org/licenses/gpl- 3.0.html5 Requires at least: 4.0 6 Tested up to: 4.8.0 7 Stable tag: 3.0.1 8 License: GPLv2 or later 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 11 A developer's inspector to illuminate the WordPress Template Hierarchy and help with building WordPress themes. … … 15 15 A 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. 16 16 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). 18 18 * Theme Inspector is only visible to logged in Administrators. 19 19 * Appears on the right-side of the Toolbar (admin bar). … … 41 41 == Changelog == 42 42 43 = 3.0 = 44 * Added the complete template hierarchy chain for the currently displayed page 45 * minor CSS improvements 46 43 47 = 2.0 = 44 48 * Moved the display to the admin bar (toolbar) for consistency … … 53 57 == Upgrade Notice == 54 58 59 = 3.0 = 60 Upgrade because this version will save you the step of opening and reading the entire Hiearchy diagram 61 55 62 = 2.0 = 56 63 Upgrade 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 9 9 background-color: rgba(41,200,235,.2); 10 10 } 11 # wpadminbar #theme-helper-toolbar{11 #theme-helper-toolbar{ 12 12 display:none; 13 13 font-family:"Trebuchet MS"!important; 14 background:#fff; 14 background:#fff !important; 15 color:black !important; 15 16 font-size:16px; 16 17 position:absolute; … … 24 25 box-shadow: 0 4px 4px rgba(0,0,0,0.2); 25 26 } 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{ 28 29 display:block; 29 30 } 30 # wpadminbar #theme-helper-toolbar table{31 #theme-helper-toolbar table{ 31 32 width: 100%; 32 33 border-collapse: collapse; 33 34 } 34 # wpadminbar #theme-helper-toolbar th{35 #theme-helper-toolbar th{ 35 36 font-weight: bold; 36 37 background-color:rgba(0,0,0,.06); … … 41 42 text-shadow:none; 42 43 } 43 # wpadminbar #theme-helper-toolbar .file-loaded{44 #theme-helper-toolbar .file-loaded{ 44 45 background-color: #FCFFD2; 45 46 } 46 # wpadminbar #theme-helper-toolbar td{47 #theme-helper-toolbar td{ 47 48 color:black; 48 49 padding:.5em; … … 50 51 text-shadow:none; 51 52 } 52 # wpadminbar #theme-helper-toolbar .condition{53 #theme-helper-toolbar .condition{ 53 54 color:#999; 54 55 text-shadow:none; 56 font-family: monospace !important; 55 57 } 56 # wpadminbar #theme-helper-toolbar .first{58 #theme-helper-toolbar .first{ 57 59 font-weight: bold; 58 60 color:#000; 59 61 } 60 # wpadminbar #theme-helper-toolbar .credits td{62 #theme-helper-toolbar .credits td{ 61 63 text-align: center; 62 64 font: normal 11px/13px sans-serif; … … 64 66 line-height:normal; 65 67 background-color:#EDF5FA; 68 66 69 } 67 # wpadminbar #theme-helper-toolbar .credits a{70 #theme-helper-toolbar .credits a{ 68 71 display:inline; 69 72 font-size:inherit; … … 76 79 line-height:14px; 77 80 } 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 } 82 101 /*Theme Helper CSS end*/ -
theme-inspector/trunk/theme-inspector.php
r1522612 r1700552 5 5 Description: 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 6 6 Author: Melissa Cabral 7 Version: 2.2.37 Version: 3.0.1 8 8 Author URI: http://melissacabral.com/ 9 9 */ … … 14 14 add_action( 'admin_bar_menu', 'mmc_toolbar_link', 999 ); 15 15 function mmc_toolbar_link( $wp_admin_bar ) { 16 if (current_user_can('install_themes') ) {16 if (current_user_can('install_themes') && !is_admin()) { 17 17 $html = mmc_generate_output(); 18 18 $args = array( … … 40 40 ?> 41 41 <!-- WordPress Theme Inspector by Melissa Cabral--> 42 <div id="theme-helper-toolbar">42 <div id="theme-helper-toolbar"> 43 43 <table> 44 44 <?php if(is_admin()){ ?> … … 61 61 <td><?php echo adminhelper_true_conditions()?></td> 62 62 </tr> 63 63 64 <?php if( !is_404() && ! is_search() && get_post_type() ) { ?> 64 65 <tr> … … 72 73 <th>Taxonomy:</th> 73 74 <td><?php 74 echo adminhelper_taxonomy()?>75 echo adminhelper_taxonomy()?> 75 76 </td> 76 77 </tr> … … 87 88 </tr> 88 89 <?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 --> 103 110 <?php 104 111 return ob_get_clean(); … … 163 170 $count = 0; 164 171 if (is_admin()) { $conditions[] = "is_admin()"; } 165 if (is_home()) { $conditions[] = "is_home()"; }166 172 if (is_front_page()) { $conditions[] = "is_front_page()"; } 173 if (is_home()) { $conditions[] = "is_home()"; } 167 174 if (is_attachment() ){ $conditions[] = "is_attachment()"; } 168 175 if (is_single()) { $conditions[] = "is_single()"; } … … 192 199 return $output; 193 200 } 201 /** 202 * Display the current hierarchy chain for this page 203 * @return mixed HTML output 204 * @since 3.0 Added this functionality 205 */ 206 function 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 = ' → '; 283 } 284 285 return $output; 286 } 194 287 function adminhelper_get_current_template( ) { 195 288 if( !isset( $GLOBALS['current_theme_template'] ) ){ … … 213 306 function adminhelper_enqueue_stylesheet(){ 214 307 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.