Version Description
- Plugin now check if file exists in child theme or parent theme.
Download this release
Release Info
Developer | barrykooij |
Plugin | What The File |
Version | 1.3.2 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.3.2
- readme.txt +5 -2
- what-the-file.php +24 -3
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== What The File ===
|
2 |
Contributors: barrykooij
|
3 |
-
Donate link:
|
4 |
Tags: toolbar, development, file, template, template editing, Template Hierarchy, theme, themes, php, php file
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.5.1
|
7 |
-
Stable tag: 1.3.
|
8 |
License: GPL v3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -46,6 +46,9 @@ Yes it does.
|
|
46 |
|
47 |
== Changelog ==
|
48 |
|
|
|
|
|
|
|
49 |
= 1.3.1 =
|
50 |
* Editing files directly through the theme editor now supports child themes.
|
51 |
|
1 |
=== What The File ===
|
2 |
Contributors: barrykooij
|
3 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q7QDZTLCRKSMG
|
4 |
Tags: toolbar, development, file, template, template editing, Template Hierarchy, theme, themes, php, php file
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.5.1
|
7 |
+
Stable tag: 1.3.2
|
8 |
License: GPL v3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
46 |
|
47 |
== Changelog ==
|
48 |
|
49 |
+
= 1.3.2 =
|
50 |
+
* Plugin now check if file exists in child theme or parent theme.
|
51 |
+
|
52 |
= 1.3.1 =
|
53 |
* Editing files directly through the theme editor now supports child themes.
|
54 |
|
what-the-file.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: What The File
|
4 |
Plugin URI: http://www.barrykooij.com/what-the-file/
|
5 |
Description: What The File adds an option to your toolbar showing what file and template parts are used to display the page you’re currently viewing. You can click the file name to directly edit it through the theme editor. Supports BuddyPress and Roots Theme. More information can be found at the <a href='http://wordpress.org/extend/plugins/what-the-file/'>WordPress plugin page</a>.
|
6 |
-
Version: 1.3.
|
7 |
Author: Barry Kooij
|
8 |
Author URI: http://www.barrykooij.com/
|
9 |
License: GPL v3
|
@@ -115,6 +115,11 @@ class WhatTheFile
|
|
115 |
add_action( 'all', array( $this, 'save_template_parts' ), 1, 3 );
|
116 |
}
|
117 |
|
|
|
|
|
|
|
|
|
|
|
118 |
public function save_template_parts( $tag, $slug=null, $name=null )
|
119 |
{
|
120 |
if( 0 !== strpos( $tag, 'get_template_part_' ) ) {
|
@@ -187,13 +192,29 @@ class WhatTheFile
|
|
187 |
global $wp_admin_bar;
|
188 |
|
189 |
$wp_admin_bar->add_menu( array( 'id' => 'wtf-bar', 'parent' => 'top-secondary', 'title' => __( 'What The File', 'what-the-file' ) , 'href' => false ) );
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
if( count( $this->template_parts ) > 0 ) {
|
193 |
$wp_admin_bar->add_menu( array( 'id' => 'wtf-bar-template-parts', 'parent' => 'wtf-bar', 'title' => 'Template Parts', 'href' => false ) );
|
|
|
194 |
foreach( $this->template_parts as $template_part ) {
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
}
|
|
|
197 |
}
|
198 |
}
|
199 |
|
3 |
Plugin Name: What The File
|
4 |
Plugin URI: http://www.barrykooij.com/what-the-file/
|
5 |
Description: What The File adds an option to your toolbar showing what file and template parts are used to display the page you’re currently viewing. You can click the file name to directly edit it through the theme editor. Supports BuddyPress and Roots Theme. More information can be found at the <a href='http://wordpress.org/extend/plugins/what-the-file/'>WordPress plugin page</a>.
|
6 |
+
Version: 1.3.2
|
7 |
Author: Barry Kooij
|
8 |
Author URI: http://www.barrykooij.com/
|
9 |
License: GPL v3
|
115 |
add_action( 'all', array( $this, 'save_template_parts' ), 1, 3 );
|
116 |
}
|
117 |
|
118 |
+
private function file_exists_in_child_theme( $file )
|
119 |
+
{
|
120 |
+
return file_exists( STYLESHEETPATH . '/' . $file );
|
121 |
+
}
|
122 |
+
|
123 |
public function save_template_parts( $tag, $slug=null, $name=null )
|
124 |
{
|
125 |
if( 0 !== strpos( $tag, 'get_template_part_' ) ) {
|
192 |
global $wp_admin_bar;
|
193 |
|
194 |
$wp_admin_bar->add_menu( array( 'id' => 'wtf-bar', 'parent' => 'top-secondary', 'title' => __( 'What The File', 'what-the-file' ) , 'href' => false ) );
|
195 |
+
|
196 |
+
// Check if template file exists in child theme
|
197 |
+
$theme = get_stylesheet();
|
198 |
+
if( !$this->file_exists_in_child_theme( $this->get_current_page() ) ) {
|
199 |
+
$theme = get_template();
|
200 |
+
}
|
201 |
+
|
202 |
+
$wp_admin_bar->add_menu( array( 'id' => 'wtf-bar-template-file', 'parent' => 'wtf-bar', 'title' => $this->get_current_page(), 'href' => get_admin_url() . 'theme-editor.php?file=' . $this->get_current_page() . '&theme=' . $theme ) );
|
203 |
|
204 |
if( count( $this->template_parts ) > 0 ) {
|
205 |
$wp_admin_bar->add_menu( array( 'id' => 'wtf-bar-template-parts', 'parent' => 'wtf-bar', 'title' => 'Template Parts', 'href' => false ) );
|
206 |
+
|
207 |
foreach( $this->template_parts as $template_part ) {
|
208 |
+
|
209 |
+
// Check if template part exists in child theme
|
210 |
+
$theme = get_stylesheet();
|
211 |
+
if( !$this->file_exists_in_child_theme( $template_part ) ) {
|
212 |
+
$theme = get_template();
|
213 |
+
}
|
214 |
+
|
215 |
+
$wp_admin_bar->add_menu( array( 'id' => 'wtf-bar-template-part-' . $template_part, 'parent' => 'wtf-bar-template-parts', 'title' => $template_part, 'href' => get_admin_url() . 'theme-editor.php?file=' . $template_part . '&theme=' . $theme ) );
|
216 |
}
|
217 |
+
|
218 |
}
|
219 |
}
|
220 |
|