Changeset 1195496
- Timestamp:
- 07/09/2015 03:23:29 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
display-template-name/trunk/display-template-name.php
r1130514 r1195496 3 3 Plugin Name: Display Template Name 4 4 Description: Displays the name of the template used by the currently displayed page in the admin bar or inside the pages. Plugins very useful for developing your blog. 5 Version: 1. 65 Version: 1.7 6 6 Author: Aurélien Chappard 7 7 Author URI: http://www.deefuse.fr/ … … 163 163 ?> 164 164 <style type="text/css"> 165 #debug-display-template-name{font-size: 14px;cursor: default; position: fixed; <?php echo $stringCss;?> background: #000; color: #FFF; padding: 5px 7px; border: 1px solid #FFF;z-index: 99999} 165 #debug-display-template-name{ 166 font-size: 14px; 167 cursor: default; 168 position: fixed; 169 <?php echo $stringCss;?> 170 background: #333; 171 color: #FFF; 172 padding: 5px 20px; 173 border: 1px solid #FFF; 174 z-index: 99999 175 } 176 #debug-display-template-name h6{ 177 font-size: 18px; 178 text-transform: uppercase; 179 font-weight: normal; 180 padding-bottom: 10px; 181 border-bottom:1px solid #000; 182 } 166 183 #debug-display-template-name a, #debug-display-template-name a:visited{ 167 184 color: #FFF; … … 186 203 <?php 187 204 $templateInfos = $this->get_current_template(); 205 $child_template = $this->get_child_templates($templateInfos); 188 206 ?> 189 207 <div id="debug-display-template-name"> 190 < p><?php _e('Current template:','display-template-name'); ?></p>208 <h6><?php _e('Current template:','display-template-name'); ?></h6> 191 209 <ul> 192 210 <li> 193 211 <a href="#" title="<?php echo $templateInfos; ?>" target="_blank"><?php echo basename($templateInfos); ?></a> 212 <?php if ( count($child_template > 0) ) : ?> 213 <ul> 214 <?php foreach ($child_template as $tpl) : ?> 215 <li><a title="<?php echo $tpl; ?>"><?php echo basename($tpl); ?></a></li> 216 <?php endforeach ?> 217 </ul> 218 <?php endif; ?> 194 219 </li> 195 220 </ul> … … 225 250 return $GLOBALS['current_theme_template']; 226 251 } 227 228 229 230 function get_header_Action($args){ 231 print_r($args); 232 } 252 253 /** 254 * Récupère les tpl enfant chargé après le template principal (vie get_template_part) 255 * @param $baseTemplateCalled 256 * @return array 257 */ 258 function get_child_templates($baseTemplateCalled){ 259 $child_include = array(); 260 $included_files = get_included_files(); 261 $stylesheet_dir = str_replace( '\\', '/', get_stylesheet_directory() ); 262 $template_dir = str_replace( '\\', '/', get_template_directory() ); 263 $template_de_base_loaded = FALSE; 264 foreach ( $included_files as $key => $path ) { 265 266 $path = str_replace( '\\', '/', $path ); 267 268 if ( false === strpos( $path, $stylesheet_dir ) && false === strpos( $path, $template_dir ) ) 269 unset( $included_files[$key] ); 270 271 // si c'est dans le theme 272 if(!strpos($path, '/wp-content/themes/') === false) { 273 274 if($template_de_base_loaded){ 275 array_push($child_include, $path); 276 } 277 278 if($path == $baseTemplateCalled){ 279 $template_de_base_loaded = TRUE; 280 } 281 282 283 //array_push($child_include, $path. ' = '.$baseTemplateCalled); 284 //echo $key.' = '. $path.'</br></br>'; 285 286 } 287 } 288 return $child_include; 289 } 290 233 291 function dispayTplName_settings_link($links) 234 292 { … … 237 295 return $links; 238 296 } 239 297 298 function custom_css_admin_bar(){ 299 echo '<style> 300 #wp-admin-bar-displayTemplateName .ab-icon:before{ 301 font-family: "dashicons" !important; 302 content: "\f100" !important; 303 } 304 305 #wp-admin-bar-displayTemplateName .ab-icon-child:before{ 306 font-family: "dashicons" !important; 307 content: "\f345" !important; 308 } 309 </style>'; 310 } 311 240 312 function displayTplNameAdminBar() 241 313 { … … 243 315 global $wp_admin_bar; 244 316 $templateInfos = $this->get_current_template(); 245 $wp_admin_bar->add_menu( array( 246 'parent' => false, // use 'false' for a root menu, or pass the ID of the parent menu 247 'id' => 'displayTemplateName', // link ID, defaults to a sanitized title value 248 'title' => __('Current template:','display-template-name') .' <b>'. basename($templateInfos) .'</b>', // link title 249 'meta' => array('title' => $templateInfos) // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' ); 250 )); 251 } 317 $child_template = $this->get_child_templates($templateInfos); 318 $wp_admin_bar->add_menu( array( 319 'parent' => false, // use 'false' for a root menu, or pass the ID of the parent menu 320 'id' => 'displayTemplateName', // link ID, defaults to a sanitized title value 321 'title' => '<span class="ab-icon"></span> '.__('Current template:','display-template-name') .' <b>'. basename($templateInfos) .'</b>', // link title 322 'meta' => array('title' => $templateInfos) // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' ); 323 )); 324 if ( count($child_template > 0) ) { 325 $i = 0; 326 foreach ($child_template as $tpl) { 327 $wp_admin_bar->add_menu( array( 328 'parent' => 'displayTemplateName', // use 'false' for a root menu, or pass the ID of the parent menu 329 'id' => 'displayTemplateName-child-'.$i, // link ID, defaults to a sanitized title value 330 'title' => '<span class="ab-icon-child"></span> '. basename($tpl), 331 'meta' => array('title' => $tpl) // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' ); 332 )); 333 $i++; 334 } 335 } 336 337 338 339 340 } 252 341 253 342 } … … 269 358 add_action( 'wp_footer', array(&$display_template_name_plugin, 'displayTheTemplateName') ); 270 359 add_action('admin_menu', 'DisplaYTemplateName_ap'); 360 add_action('wp_head', array(&$display_template_name_plugin, 'custom_css_admin_bar' )); 271 361 add_action( 'admin_init', array(&$display_template_name_plugin, 'displayTplNameenqueue_my_styles') ); 272 362 add_action( 'wp_before_admin_bar_render', array(&$display_template_name_plugin, 'displayTplNameAdminBar') );
Note: See TracChangeset
for help on using the changeset viewer.