Show Current Template - Version 0.4.0

Version Description

  • Fix not showing all included files with WordPress version 5.4 or greater.
  • Clean up some code.
Download this release

Release Info

Developer tai
Plugin Icon Show Current Template
Version 0.4.0
Comparing to
See all releases

Code changes from version 0.3.4 to 0.4.0

assets/js/replace.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ function replaceFileNames() {
2
+ let c = document.getElementById('included-files-fie-on-wp-footer').innerHTML;
3
+ document.getElementById('included-files-list').innerHTML = c;
4
+ }
5
+ replaceFileNames();
css/style.css CHANGED
@@ -8,25 +8,37 @@
8
  */
9
  #wpadminbar .show-template-name, #wpadminbar .hover .show-template-name {
10
  font-family: monospace;
11
- text-shadow: none; }
 
12
  #wpadminbar #wp-admin-bar-included_files_path .ab-item {
13
  height: auto;
14
- padding-bottom: 1rem; }
15
- #wpadminbar #wp-admin-bar-included_files_path .ab-item div {
16
- font-family: monospace;
17
- text-shadow: none;
18
- color: #fff; }
 
 
19
  #wpadminbar .hover .show-template-name:hover {
20
- color: #2ea2cc; }
 
21
  #wpadminbar #wp-admin-bar-included_files_path .ab-item #included-files-list li {
22
- line-height: 1.5; }
23
- #wpadminbar #wp-admin-bar-included_files_path .ab-item #included-files-list li:hover {
24
- color: #2ea2cc; }
 
 
25
  #wpadminbar #included-files-list {
26
- margin-left: 20px; }
 
27
 
28
  #wp-admin-bar-show_template_file_name_on_top-default {
29
  max-height: 90vh;
30
- overflow-x: hidden; }
 
 
 
 
 
31
 
32
  /*# sourceMappingURL=style.css.map */
8
  */
9
  #wpadminbar .show-template-name, #wpadminbar .hover .show-template-name {
10
  font-family: monospace;
11
+ text-shadow: none;
12
+ }
13
  #wpadminbar #wp-admin-bar-included_files_path .ab-item {
14
  height: auto;
15
+ padding-bottom: 1rem;
16
+ }
17
+ #wpadminbar #wp-admin-bar-included_files_path .ab-item div {
18
+ font-family: monospace;
19
+ text-shadow: none;
20
+ color: #fff;
21
+ }
22
  #wpadminbar .hover .show-template-name:hover {
23
+ color: #2ea2cc;
24
+ }
25
  #wpadminbar #wp-admin-bar-included_files_path .ab-item #included-files-list li {
26
+ line-height: 1.5;
27
+ }
28
+ #wpadminbar #wp-admin-bar-included_files_path .ab-item #included-files-list li:hover {
29
+ color: #2ea2cc;
30
+ }
31
  #wpadminbar #included-files-list {
32
+ margin-left: 20px;
33
+ }
34
 
35
  #wp-admin-bar-show_template_file_name_on_top-default {
36
  max-height: 90vh;
37
+ overflow-x: hidden;
38
+ }
39
+
40
+ #included-files-fie-on-wp-footer {
41
+ display: none;
42
+ }
43
 
44
  /*# sourceMappingURL=style.css.map */
css/style.css.map CHANGED
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "mappings": "AAAA;;;;;;;EAOE;AAGA,uEAAgD;EAC9C,WAAW,EAAE,SAAS;EACtB,WAAW,EAAE,IAAI;AAGnB,sDAA2C;EAOzC,MAAM,EAAE,IAAI;EACZ,cAAc,EAAE,IAAI;EAPpB,0DAAI;IACF,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,IAAI;IACjB,KAAK,EAAE,IAAI;AAOf,4CAAiC;EAC/B,KAAK,EAAE,OAAO;AAGhB,8EAAmE;EAKjE,WAAW,EAAE,GAAG;EAJhB,oFAAQ;IACN,KAAK,EAAE,OAAO;AAMlB,gCAAqB;EACnB,WAAW,EAAE,IAAI;;AAIrB,oDAAqD;EACjD,UAAU,EAAE,IAAI;EAChB,UAAU,EAAE,MAAM",
4
- "sources": ["../sass/style.scss"],
5
- "names": [],
6
- "file": "style.css"
7
- }
1
+ {"version":3,"sourceRoot":"","sources":["../sass/style.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUE;EACE;EACA;;AAGF;EAOE;EACA;;AAPA;EACE;EACA;EACA;;AAOJ;EACE;;AAGF;EAKE;;AAJA;EACE;;AAMJ;EACE;;;AAIJ;EACI;EACA;;;AAGJ;EACC","file":"style.css"}
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: tai
3
  Donate link: https://wp.tekapo.com/is-my-plugin-useful/
4
  Tags: template, toolbar
5
  Requires at least: 3.5
6
- Tested up to: 5.3
7
- Stable tag: 0.3.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -33,7 +33,12 @@ Inspired by (and big thanks to):
33
 
34
  == Frequently Asked Questions ==
35
 
36
- None so far.
 
 
 
 
 
37
 
38
  == Screenshots ==
39
 
@@ -45,6 +50,10 @@ None so far.
45
 
46
  == Changelog ==
47
 
 
 
 
 
48
  = 0.3.4 =
49
  * No functional change at all except the version number in the plugin php file and donation url.
50
 
3
  Donate link: https://wp.tekapo.com/is-my-plugin-useful/
4
  Tags: template, toolbar
5
  Requires at least: 3.5
6
+ Tested up to: 5.6
7
+ Stable tag: 0.4.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
33
 
34
  == Frequently Asked Questions ==
35
 
36
+ = I don't see the toolbar. =
37
+ Is the Toolbar (Show Toolbar when viewing site) option in your profile page is checked?
38
+ You can find your profile page is in your WordPress admin -> Users -> Profile.
39
+
40
+ = I don't see the current template file name in the toolbar. =
41
+ Do you logged in as "Administrator"? Other role users like "Editor" can't see the file name.
42
 
43
  == Screenshots ==
44
 
50
 
51
  == Changelog ==
52
 
53
+ = 0.4.0 =
54
+ * Fix not showing all included files with WordPress version 5.4 or greater.
55
+ * Clean up some code.
56
+
57
  = 0.3.4 =
58
  * No functional change at all except the version number in the plugin php file and donation url.
59
 
sass/style.scss CHANGED
@@ -44,4 +44,8 @@
44
  #wp-admin-bar-show_template_file_name_on_top-default {
45
  max-height: 90vh;
46
  overflow-x: hidden;
 
 
 
 
47
  }
44
  #wp-admin-bar-show_template_file_name_on_top-default {
45
  max-height: 90vh;
46
  overflow-x: hidden;
47
+ }
48
+
49
+ #included-files-fie-on-wp-footer {
50
+ display: none;
51
  }
show-current-template.php CHANGED
@@ -1,35 +1,36 @@
1
  <?php
2
-
3
- /*
4
- Plugin Name: Show Current Template
5
- Plugin URI: https://wp.tekapo.com/
6
- Description: Show the current template file name in the tool bar. <a href="https://wp.tekapo.com/is-my-plugin-useful/">Is this useful for you?</a>
7
- Author: JOTAKI Taisuke
8
- Version: 0.3.4
9
- Author URI: https://tekapo.com/
10
- Text Domain: show-current-template
11
- Domain Path: /languages/
12
-
13
- License:
14
- Released under the GPL license
15
- http://www.gnu.org/copyleft/gpl.html
16
-
17
- Copyright 2013 (email : tekapo@gmail.com)
18
-
19
- This program is free software; you can redistribute it and/or modify
20
- it under the terms of the GNU General Public License as published by
21
- the Free Software Foundation; either version 2 of the License, or
22
- (at your option) any later version.
23
-
24
- This program is distributed in the hope that it will be useful,
25
- but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- GNU General Public License for more details.
28
-
29
- You should have received a copy of the GNU General Public License
30
- along with this program; if not, write to the Free Software
31
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32
- */
 
33
 
34
  load_plugin_textdomain( 'show-current-template', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
35
 
@@ -37,33 +38,36 @@ new Show_Template_File_Name();
37
 
38
  class Show_Template_File_Name {
39
 
40
- function __construct() {
41
- add_action( "admin_bar_menu", array( &$this, "show_template_file_name_on_top" ), 9999 );
42
- add_action( 'wp_enqueue_scripts', array( &$this, "add_current_template_stylesheet" ), 9999 );
 
 
 
43
  }
44
 
45
  public function show_template_file_name_on_top( $wp_admin_bar ) {
46
 
47
- if ( is_admin() or ! is_super_admin() ) {
48
  return;
49
  }
50
 
51
  global $template;
52
 
53
- $template_file_name = basename( $template );
54
- $template_relative_path = str_replace( ABSPATH . 'wp-content/', '', $template );
55
 
56
- $current_theme = wp_get_theme();
57
- $current_theme_name = $current_theme->Name;
58
- $parent_theme_name = '';
59
 
60
  if ( is_child_theme() ) {
61
- $child_theme_name = __( 'Theme name: ', 'show-current-template' )
62
  . $current_theme_name;
63
- $parent_theme_name = $current_theme->parent()->Name;
64
- $parent_theme_name = ' (' . $parent_theme_name
65
- . __( "'s child", 'show-current-template' ) . ")";
66
- $parent_or_child = $child_theme_name . $parent_theme_name;
67
  } else {
68
  $parent_or_child = __( 'Theme name: ', 'show-current-template' )
69
  . $current_theme_name . ' (' . __( 'NOT a child theme', 'show-current-template' ) . ')';
@@ -76,7 +80,7 @@ class Show_Template_File_Name {
76
  foreach ( $included_files as $filename ) {
77
  if ( strstr( $filename, 'themes' ) ) {
78
  $filepath = strstr( $filename, 'themes' );
79
- if ( $template_relative_path == $filepath ) {
80
  $included_files_list .= '';
81
  } else {
82
  $included_files_list .= '<li>' . "$filepath" . '</li>';
@@ -86,39 +90,70 @@ class Show_Template_File_Name {
86
 
87
  global $wp_admin_bar;
88
  $args = array(
89
- 'id' => 'show_template_file_name_on_top',
90
- 'title' => __( 'Template:', 'show-current-template' )
91
  . '<span class="show-template-name"> ' . $template_file_name . '</span>',
92
  );
93
 
94
  $wp_admin_bar->add_node( $args );
95
 
96
- $wp_admin_bar->add_menu( array(
97
- 'parent' => 'show_template_file_name_on_top',
98
- 'id' => 'template_relative_path',
99
- 'title' => __( 'Template relative path:', 'show-current-template' )
100
- . '<span class="show-template-name"> ' . $template_relative_path . '</span>',
101
- ) );
102
-
103
- $wp_admin_bar->add_menu( array(
104
- 'parent' => 'show_template_file_name_on_top',
105
- 'id' => 'is_child_theme',
106
- 'title' => $parent_or_child,
107
- ) );
108
-
109
- $wp_admin_bar->add_menu( array(
110
- 'parent' => 'show_template_file_name_on_top',
111
- 'id' => 'included_files_path',
112
- 'title' => __( 'Also, below template files are included:', 'show-current-template' )
113
- . '<br /><ul id="included-files-list">'
114
- . $included_files_list
115
- . '</ul>',
116
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  }
118
 
119
  public function add_current_template_stylesheet() {
120
 
121
- if ( is_admin() or ! is_super_admin() ) {
122
  return;
123
  }
124
 
@@ -129,10 +164,25 @@ class Show_Template_File_Name {
129
  } else {
130
  $is_older_than_3_8 = '-old';
131
  }
132
-
133
  $stylesheet_path = plugins_url( 'css/style' . $is_older_than_3_8 . '.css', __FILE__ );
134
- wp_register_style( 'current-template-style', $stylesheet_path );
135
  wp_enqueue_style( 'current-template-style' );
136
  }
 
 
 
 
 
 
 
137
 
 
 
 
 
 
 
 
 
138
  }
1
  <?php
2
+ /**
3
+ Plugin Name: Show Current Template
4
+ Plugin URI: https://wp.tekapo.com/
5
+ Description: Show the current template file name in the tool bar. <a href="https://wp.tekapo.com/is-my-plugin-useful/">Is this useful for you?</a>
6
+ Author: JOTAKI Taisuke
7
+ Version: 0.4.0
8
+ Author URI: https://tekapo.com/
9
+ Text Domain: show-current-template
10
+ Domain Path: /languages/
11
+
12
+ License:
13
+ Released under the GPL license
14
+ http://www.gnu.org/copyleft/gpl.html
15
+
16
+ Copyright 2013 (email : tekapo@gmail.com)
17
+
18
+ This program is free software; you can redistribute it and/or modify
19
+ it under the terms of the GNU General Public License as published by
20
+ the Free Software Foundation; either version 2 of the License, or
21
+ (at your option) any later version.
22
+
23
+ This program is distributed in the hope that it will be useful,
24
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
25
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
+ GNU General Public License for more details.
27
+
28
+ You should have received a copy of the GNU General Public License
29
+ along with this program; if not, write to the Free Software
30
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
+ * */
32
+
33
+ define( 'WPSCT_VERSION', '0.4.0' );
34
 
35
  load_plugin_textdomain( 'show-current-template', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
36
 
38
 
39
  class Show_Template_File_Name {
40
 
41
+ public function __construct() {
42
+ add_action( 'wp_footer', array( $this, 'get_included_files_at_footr' ) );
43
+
44
+ add_action( 'admin_bar_menu', array( &$this, 'show_template_file_name_on_top' ), 9999 );
45
+ add_action( 'wp_enqueue_scripts', array( &$this, 'add_current_template_stylesheet' ), 9999 );
46
+ add_action( 'wp_enqueue_scripts', array( &$this, 'add_current_template_js' ), 9999 );
47
  }
48
 
49
  public function show_template_file_name_on_top( $wp_admin_bar ) {
50
 
51
+ if ( is_admin() || ! is_super_admin() ) {
52
  return;
53
  }
54
 
55
  global $template;
56
 
57
+ $template_file_name = basename( $template );
58
+ $template_relative_path = str_replace( ABSPATH . 'wp-content/', '', $template );
59
 
60
+ $current_theme = wp_get_theme();
61
+ $current_theme_name = $current_theme->Name;
62
+ $parent_theme_name = '';
63
 
64
  if ( is_child_theme() ) {
65
+ $child_theme_name = __( 'Theme name: ', 'show-current-template' )
66
  . $current_theme_name;
67
+ $parent_theme_name = $current_theme->parent()->Name;
68
+ $parent_theme_name = ' (' . $parent_theme_name
69
+ . __( "'s child", 'show-current-template' ) . ')';
70
+ $parent_or_child = $child_theme_name . $parent_theme_name;
71
  } else {
72
  $parent_or_child = __( 'Theme name: ', 'show-current-template' )
73
  . $current_theme_name . ' (' . __( 'NOT a child theme', 'show-current-template' ) . ')';
80
  foreach ( $included_files as $filename ) {
81
  if ( strstr( $filename, 'themes' ) ) {
82
  $filepath = strstr( $filename, 'themes' );
83
+ if ( $template_relative_path === $filepath ) {
84
  $included_files_list .= '';
85
  } else {
86
  $included_files_list .= '<li>' . "$filepath" . '</li>';
90
 
91
  global $wp_admin_bar;
92
  $args = array(
93
+ 'id' => 'show_template_file_name_on_top',
94
+ 'title' => __( 'Template:', 'show-current-template' )
95
  . '<span class="show-template-name"> ' . $template_file_name . '</span>',
96
  );
97
 
98
  $wp_admin_bar->add_node( $args );
99
 
100
+ $wp_admin_bar->add_menu(
101
+ array(
102
+ 'parent' => 'show_template_file_name_on_top',
103
+ 'id' => 'template_relative_path',
104
+ 'title' => __( 'Template relative path:', 'show-current-template' )
105
+ . '<span class="show-template-name"> ' . $template_relative_path . '</span>',
106
+ )
107
+ );
108
+
109
+ $wp_admin_bar->add_menu(
110
+ array(
111
+ 'parent' => 'show_template_file_name_on_top',
112
+ 'id' => 'is_child_theme',
113
+ 'title' => $parent_or_child,
114
+ )
115
+ );
116
+
117
+ $wp_admin_bar->add_menu(
118
+ array(
119
+ 'parent' => 'show_template_file_name_on_top',
120
+ 'id' => 'included_files_path',
121
+ 'title' => __( 'Also, below template files are included:', 'show-current-template' )
122
+ . '<br /><ul id="included-files-list">'
123
+ . $included_files_list
124
+ . '</ul>',
125
+ )
126
+ );
127
+ }
128
+
129
+ public function get_included_files_at_footr() {
130
+ $included_files = get_included_files();
131
+ global $template;
132
+
133
+ $template_relative_path = str_replace( ABSPATH . 'wp-content/', '', $template );
134
+
135
+ sort( $included_files );
136
+ $included_files_list = '';
137
+ foreach ( $included_files as $filename ) {
138
+ if ( strstr( $filename, 'themes/' ) ) {
139
+ $filepath = strstr( $filename, 'themes' );
140
+ if ( $template_relative_path === $filepath ) {
141
+ $included_files_list .= '';
142
+ } else {
143
+ $included_files_list .= '<li>' . "$filepath" . '</li>';
144
+ }
145
+ }
146
+ }
147
+ $included_files_format = '<ol id="included-files-fie-on-wp-footer">'
148
+ . '%s'
149
+ . '</ol>';
150
+ $included_files_html = sprintf( $included_files_format, $included_files_list );
151
+ echo wp_kses_post( $included_files_html );
152
  }
153
 
154
  public function add_current_template_stylesheet() {
155
 
156
+ if ( is_admin() || ! is_super_admin() ) {
157
  return;
158
  }
159
 
164
  } else {
165
  $is_older_than_3_8 = '-old';
166
  }
167
+
168
  $stylesheet_path = plugins_url( 'css/style' . $is_older_than_3_8 . '.css', __FILE__ );
169
+ wp_register_style( 'current-template-style', $stylesheet_path, array(), WPSCT_VERSION );
170
  wp_enqueue_style( 'current-template-style' );
171
  }
172
+ public function add_current_template_js() {
173
+
174
+ if ( is_admin() || ! is_super_admin() ) {
175
+ return;
176
+ }
177
+
178
+ $wp_version = get_bloginfo( 'version' );
179
 
180
+ if ( $wp_version >= '5.4' ) {
181
+ $js_path = plugins_url( 'assets/js/replace.js', __FILE__ );
182
+ wp_register_script( 'current-template-js', $js_path, array(), 6, true );
183
+ wp_enqueue_script( 'current-template-js' );
184
+ } else {
185
+ return;
186
+ }
187
+ }
188
  }