What The File - Version 1.3.0

Version Description

  • Added template part support.
Download this release

Release Info

Developer barrykooij
Plugin Icon 128x128 What The File
Version 1.3.0
Comparing to
See all releases

Code changes from version 1.2.1 to 1.3.0

Files changed (2) hide show
  1. readme.txt +6 -3
  2. what-the-file.php +30 -6
readme.txt CHANGED
@@ -4,15 +4,15 @@ 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.2.1
8
  License: GPL v3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
- What The File adds an option to your toolbar showing you what file is used to display the page you’re on. Click to edit directly through the theme editor. Supports BuddyPress and Roots Theme.
12
 
13
  == Description ==
14
 
15
- What The File adds an option to your toolbar showing you what file is used to display the page you’re on. If you want to you can click the file name to edit it directly through the theme editor, though I don’t recommend this for bigger changes. What The File also supports BuddyPress and Roots Theme based themes.
16
 
17
  More information can be found <a href='http://www.barrykooij.com/what-the-file/'>here</a>.
18
  For support please visit the <a href='http://wordpress.org/support/plugin/what-the-file'>Support forum</a>.
@@ -46,6 +46,9 @@ Yes it does.
46
 
47
  == Changelog ==
48
 
 
 
 
49
  = 1.2.1 =
50
  * Improved the admin panel and administrator role check.
51
 
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.0
8
  License: GPL v3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
+ 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.
12
 
13
  == Description ==
14
 
15
+ 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, though I don’t recommend this for bigger changes. What The File supports BuddyPress and Roots Theme based themes.
16
 
17
  More information can be found <a href='http://www.barrykooij.com/what-the-file/'>here</a>.
18
  For support please visit the <a href='http://wordpress.org/support/plugin/what-the-file'>Support forum</a>.
46
 
47
  == Changelog ==
48
 
49
+ = 1.3.0 =
50
+ * Added template part support.
51
+
52
  = 1.2.1 =
53
  * Improved the admin panel and administrator role check.
54
 
what-the-file.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
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 you what file is used to display the page you’re on. If you want to you can click the file name to edit it directly 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.2.1
7
  Author: Barry Kooij
8
  Author URI: http://www.barrykooij.com/
9
  License: GPL v3
@@ -30,6 +30,7 @@ class WhatTheFile
30
  const OPTION_INSTALL_DATE = 'whatthefile-install-date';
31
  const OPTION_ADMIN_NOTICE_KEY = 'whatthefile-hide-notice';
32
  private $template_name = '';
 
33
 
34
  public static function plugin_activation()
35
  {
@@ -109,6 +110,20 @@ class WhatTheFile
109
  if( class_exists( 'BuddyPress' ) ) {
110
  add_action( 'bp_core_pre_load_template', array( $this, 'save_buddy_press_template' ) );
111
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
113
 
114
  public function catch_hide_notice()
@@ -167,15 +182,24 @@ class WhatTheFile
167
  return $template_name;
168
  }
169
 
170
- public function admin_bar_menu() {
 
171
  global $wp_admin_bar;
172
- $wp_admin_bar->add_menu( array( 'id' => 'wtf-bar' , 'parent' => 'top-secondary' , 'title' => __( 'What The File', 'what-the-file' ) , 'href' => FALSE ) );
173
- $wp_admin_bar->add_menu( array( 'id' => 'wtf-bar-sub' , 'parent' => 'wtf-bar' , 'title' => $this->get_current_page() , 'href' => get_admin_url() . 'theme-editor.php?file=' . $this->get_current_page() . '&theme=' . get_template() ) );
 
 
 
 
 
 
 
 
174
  }
175
 
176
  public function print_css()
177
  {
178
- echo "<style type=\"text/css\" media=\"screen\">#wp-admin-bar-wtf-bar #wp-admin-bar-wtf-bar-sub .ab-item{display: block !important;text-align: right;}</style>\n";
179
  }
180
 
181
  }
2
  /*
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.0
7
  Author: Barry Kooij
8
  Author URI: http://www.barrykooij.com/
9
  License: GPL v3
30
  const OPTION_INSTALL_DATE = 'whatthefile-install-date';
31
  const OPTION_ADMIN_NOTICE_KEY = 'whatthefile-hide-notice';
32
  private $template_name = '';
33
+ private $template_parts = array();
34
 
35
  public static function plugin_activation()
36
  {
110
  if( class_exists( 'BuddyPress' ) ) {
111
  add_action( 'bp_core_pre_load_template', array( $this, 'save_buddy_press_template' ) );
112
  }
113
+
114
+ // Template part hooks
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_' ) ) {
121
+ return;
122
+ }
123
+
124
+ if( $slug != null && $name != null ){
125
+ $this->template_parts[] = $slug . '-' . $name . '.php';
126
+ }
127
  }
128
 
129
  public function catch_hide_notice()
182
  return $template_name;
183
  }
184
 
185
+ public function admin_bar_menu()
186
+ {
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
+ $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=' . get_template() ) );
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
+ $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=' . get_template() ) );
196
+ }
197
+ }
198
  }
199
 
200
  public function print_css()
201
  {
202
+ echo "<style type=\"text/css\" media=\"screen\">#wp-admin-bar-wtf-bar #wp-admin-bar-wtf-bar-template-file .ab-item, #wp-admin-bar-wtf-bar #wp-admin-bar-wtf-bar-template-parts {text-align:right;}</style>\n";
203
  }
204
 
205
  }