Version Description
- Added BuddyPress support.
- Added WordPress.org review notice.
- Fixed admin check.
- Small code changes and refactoring.
- Extended GPL license.
Download this release
Release Info
| Developer | barrykooij |
| Plugin | |
| Version | 1.2.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.1.2 to 1.2.0
- readme.txt +21 -6
- screenshot-1.png +0 -0
- what-the-file.php +154 -27
readme.txt
CHANGED
|
@@ -4,15 +4,15 @@ Donate link:
|
|
| 4 |
Tags: toolbar, development, file, template, template editing, Template Hierarchy, themes
|
| 5 |
Requires at least: 3.1
|
| 6 |
Tested up to: 3.5.1
|
| 7 |
-
Stable tag: 1.
|
| 8 |
-
License:
|
| 9 |
-
License URI: http://www.gnu.org/licenses/gpl-
|
| 10 |
|
| 11 |
-
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
|
| 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.
|
| 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>.
|
|
@@ -26,18 +26,33 @@ For support please visit the <a href='http://wordpress.org/support/plugin/what-t
|
|
| 26 |
|
| 27 |
= Where can I see what template file is used? =
|
| 28 |
|
| 29 |
-
In the toolbar you will find the "What The File" option. Hovering this option will display the currently used template file, clicking the template file name will allow you to edit the template file with the WordPress file editor.
|
| 30 |
|
| 31 |
= I can't find the "What The File" option in the toolbar =
|
| 32 |
|
| 33 |
You have to be an Administrator to see the "What The File" option.
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
== Screenshots ==
|
| 36 |
|
| 37 |
1. What The File shows you what template file is used.
|
| 38 |
|
| 39 |
== Changelog ==
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
= 1.1.2 =
|
| 42 |
* Fixed admin url bug caused when WordPress is installed in a subdirectory.
|
| 43 |
|
| 4 |
Tags: toolbar, development, file, template, template editing, Template Hierarchy, themes
|
| 5 |
Requires at least: 3.1
|
| 6 |
Tested up to: 3.5.1
|
| 7 |
+
Stable tag: 1.2.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 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.
|
| 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>.
|
| 26 |
|
| 27 |
= Where can I see what template file is used? =
|
| 28 |
|
| 29 |
+
In the toolbar you will find the "What The File" option. Hovering this option will display the currently used template file, clicking the template file name will allow you to edit the template file with the WordPress file editor. Please note that some BuddyPress files can't be edited in the WordPress editor.
|
| 30 |
|
| 31 |
= I can't find the "What The File" option in the toolbar =
|
| 32 |
|
| 33 |
You have to be an Administrator to see the "What The File" option.
|
| 34 |
|
| 35 |
+
= Does What The File supports BuddyPress =
|
| 36 |
+
|
| 37 |
+
Yes it does.
|
| 38 |
+
|
| 39 |
+
= Does What The File supports Roots Theme =
|
| 40 |
+
|
| 41 |
+
Yes it does.
|
| 42 |
+
|
| 43 |
== Screenshots ==
|
| 44 |
|
| 45 |
1. What The File shows you what template file is used.
|
| 46 |
|
| 47 |
== Changelog ==
|
| 48 |
|
| 49 |
+
= 1.2.0 =
|
| 50 |
+
* Added BuddyPress support.
|
| 51 |
+
* Added WordPress.org review notice.
|
| 52 |
+
* Fixed admin check.
|
| 53 |
+
* Small code changes and refactoring.
|
| 54 |
+
* Extended GPL license.
|
| 55 |
+
|
| 56 |
= 1.1.2 =
|
| 57 |
* Fixed admin url bug caused when WordPress is installed in a subdirectory.
|
| 58 |
|
screenshot-1.png
DELETED
|
Binary file
|
what-the-file.php
CHANGED
|
@@ -2,42 +2,168 @@
|
|
| 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
|
| 6 |
-
Version: 1.
|
| 7 |
Author: Barry Kooij
|
| 8 |
Author URI: http://www.barrykooij.com/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
*/
|
| 10 |
|
| 11 |
class WhatTheFile
|
| 12 |
{
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
public function __construct()
|
| 16 |
{
|
| 17 |
-
|
| 18 |
-
}
|
| 19 |
-
|
| 20 |
-
private function get_current_page()
|
| 21 |
-
{
|
| 22 |
-
return $this->template_name;
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
-
public function setup()
|
| 26 |
-
{
|
| 27 |
-
if(!is_super_admin() || !is_admin_bar_showing()){return false;}
|
| 28 |
-
if(is_admin()){return false;}
|
| 29 |
-
add_action('wp_head', array(&$this, 'print_css'));
|
| 30 |
-
add_filter('template_include', array(&$this, 'save_current_page'), 1000);
|
| 31 |
-
add_action('admin_bar_menu', array(&$this, 'admin_bar_menu' ), 1000);
|
| 32 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
public function save_current_page($template_name)
|
| 35 |
{
|
| 36 |
-
$this->template_name = basename($template_name);
|
| 37 |
|
| 38 |
// Do Roots Theme check
|
| 39 |
-
if(function_exists('roots_template_path')) {
|
| 40 |
-
$this->template_name = basename(roots_template_path());
|
| 41 |
}
|
| 42 |
|
| 43 |
return $template_name;
|
|
@@ -45,8 +171,8 @@ class WhatTheFile
|
|
| 45 |
|
| 46 |
public function admin_bar_menu() {
|
| 47 |
global $wp_admin_bar;
|
| 48 |
-
$wp_admin_bar->add_menu( array( 'id' => 'wtf-bar', 'parent' => 'top-secondary', 'title' => __('What The File', 'what-the-file'), 'href' => FALSE ) );
|
| 49 |
-
$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='
|
| 50 |
}
|
| 51 |
|
| 52 |
public function print_css()
|
|
@@ -55,5 +181,6 @@ class WhatTheFile
|
|
| 55 |
}
|
| 56 |
|
| 57 |
}
|
| 58 |
-
|
| 59 |
-
|
|
|
| 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.0
|
| 7 |
Author: Barry Kooij
|
| 8 |
Author URI: http://www.barrykooij.com/
|
| 9 |
+
License: GPL v3
|
| 10 |
+
|
| 11 |
+
What The File Plugin
|
| 12 |
+
Copyright (C) 2012-2013, Barry Kooij - barry@cageworks.nl
|
| 13 |
+
|
| 14 |
+
This program is free software: you can redistribute it and/or modify
|
| 15 |
+
it under the terms of the GNU General Public License as published by
|
| 16 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 17 |
+
(at your option) any later version.
|
| 18 |
+
|
| 19 |
+
This program is distributed in the hope that it will be useful,
|
| 20 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 21 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 22 |
+
GNU General Public License for more details.
|
| 23 |
+
|
| 24 |
+
You should have received a copy of the GNU General Public License
|
| 25 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 26 |
*/
|
| 27 |
|
| 28 |
class WhatTheFile
|
| 29 |
{
|
| 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 |
+
{
|
| 36 |
+
self::insert_install_date();
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
public function __construct()
|
| 40 |
{
|
| 41 |
+
$this->hooks();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
}
|
| 43 |
+
|
| 44 |
+
private static function insert_install_date()
|
| 45 |
+
{
|
| 46 |
+
$datetime_now = new DateTime();
|
| 47 |
+
$date_string = $datetime_now->format('Y-m-d');
|
| 48 |
+
add_site_option( self::OPTION_INSTALL_DATE, $date_string, '', 'no' );
|
| 49 |
+
return $date_string;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
private function get_install_date()
|
| 53 |
+
{
|
| 54 |
+
$date_string = get_site_option( self::OPTION_INSTALL_DATE, '' );
|
| 55 |
+
if( $date_string == '' ) {
|
| 56 |
+
// There is no install date, plugin was installed before version 1.2.0. Add it now.
|
| 57 |
+
$date_string = self::insert_install_date();
|
| 58 |
+
}
|
| 59 |
+
return new DateTime( $date_string );
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
private function check_admin()
|
| 63 |
+
{
|
| 64 |
+
if( !is_super_admin() || !is_admin_bar_showing() ){ return false; }
|
| 65 |
+
if( is_admin() ){ return false; }
|
| 66 |
+
return true;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
private function get_current_page()
|
| 70 |
+
{
|
| 71 |
+
return $this->template_name;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
private function get_admin_querystring_array()
|
| 75 |
+
{
|
| 76 |
+
parse_str( $_SERVER['QUERY_STRING'], $params );
|
| 77 |
+
return $params;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
private function hooks()
|
| 81 |
+
{
|
| 82 |
+
// Admin notice hide catch
|
| 83 |
+
add_action( 'admin_init', array( $this, 'catch_hide_notice' ) );
|
| 84 |
+
|
| 85 |
+
// Is admin notice hidden?
|
| 86 |
+
global $current_user;
|
| 87 |
+
$hide_notice = get_user_meta( $current_user->ID, self::OPTION_ADMIN_NOTICE_KEY, true );
|
| 88 |
+
|
| 89 |
+
if( current_user_can( 'install_plugins' ) && $hide_notice == '' ) {
|
| 90 |
+
// Get installation date
|
| 91 |
+
$datetime_install = $this->get_install_date();
|
| 92 |
+
$datetime_past = new DateTime( '-10 days' );
|
| 93 |
+
|
| 94 |
+
if( $datetime_past >= $datetime_install ) {
|
| 95 |
+
// 10 or more days ago, show admin notice
|
| 96 |
+
add_action( 'admin_notices', array( $this, 'display_admin_notice' ) );
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
// Check if is frontend and user is admin
|
| 101 |
+
if( !$this->check_admin() ) {
|
| 102 |
+
return false;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
// WTF actions and filers
|
| 106 |
+
add_action( 'wp_head' , array( $this, 'print_css' ) );
|
| 107 |
+
add_filter( 'template_include' , array( $this, 'save_current_page' ), 1000 );
|
| 108 |
+
add_action( 'admin_bar_menu' , array( $this, 'admin_bar_menu' ), 1000 );
|
| 109 |
+
|
| 110 |
+
// BuddyPress hook
|
| 111 |
+
if( class_exists( 'BuddyPress' ) ) {
|
| 112 |
+
add_action( 'bp_core_pre_load_template', array( $this, 'save_buddy_press_template' ) );
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
public function catch_hide_notice()
|
| 117 |
+
{
|
| 118 |
+
if( isset( $_GET[ self::OPTION_ADMIN_NOTICE_KEY ] ) && current_user_can( 'install_plugins' ) ) {
|
| 119 |
+
// Add user meta
|
| 120 |
+
global $current_user;
|
| 121 |
+
add_user_meta( $current_user->ID, self::OPTION_ADMIN_NOTICE_KEY, '1', true );
|
| 122 |
+
|
| 123 |
+
// Build redirect URL
|
| 124 |
+
$query_params = $this->get_admin_querystring_array();
|
| 125 |
+
unset( $query_params[ self::OPTION_ADMIN_NOTICE_KEY ] );
|
| 126 |
+
$query_string = http_build_query( $query_params );
|
| 127 |
+
if( $query_string != '' ) {
|
| 128 |
+
$query_string = '?' . $query_string;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
$redirect_url = 'http';
|
| 132 |
+
if( isset( $_SERVER[ 'HTTPS' ] ) && $_SERVER[ 'HTTPS' ] == 'on' ) {
|
| 133 |
+
$redirect_url .= 's';
|
| 134 |
+
}
|
| 135 |
+
$redirect_url .= '://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'PHP_SELF' ] . $query_string;
|
| 136 |
+
|
| 137 |
+
// Redirect
|
| 138 |
+
wp_redirect( $redirect_url );
|
| 139 |
+
exit;
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
public function display_admin_notice()
|
| 144 |
+
{
|
| 145 |
+
$query_params = $this->get_admin_querystring_array();
|
| 146 |
+
$query_string = '?' . http_build_query( array_merge( $query_params, array( self::OPTION_ADMIN_NOTICE_KEY => '1' ) ) );
|
| 147 |
+
|
| 148 |
+
echo '<div class="updated"><p>';
|
| 149 |
+
printf(__("You've been using <b>What The File</b> for some time now, could you please give it a review at wordpress.org? <br /><br /> <a href='%s' target='_blank'>Yes, take me there!</a> - <a href='%s'>I've already done this!</a>"), 'http://wordpress.org/support/view/plugin-reviews/what-the-file', $query_string );
|
| 150 |
+
echo "</p></div>";
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
public function save_buddy_press_template( $template )
|
| 154 |
+
{
|
| 155 |
+
if( $this->template_name == '' ) {
|
| 156 |
+
$this->template_name = str_ireplace( get_template_directory() . '/', '', $template );
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
|
| 160 |
+
public function save_current_page( $template_name )
|
| 161 |
{
|
| 162 |
+
$this->template_name = basename( $template_name );
|
| 163 |
|
| 164 |
// Do Roots Theme check
|
| 165 |
+
if( function_exists( 'roots_template_path' ) ) {
|
| 166 |
+
$this->template_name = basename( roots_template_path() );
|
| 167 |
}
|
| 168 |
|
| 169 |
return $template_name;
|
| 171 |
|
| 172 |
public function admin_bar_menu() {
|
| 173 |
global $wp_admin_bar;
|
| 174 |
+
$wp_admin_bar->add_menu( array( 'id' => 'wtf-bar' , 'parent' => 'top-secondary' , 'title' => __( 'What The File', 'what-the-file' ) , 'href' => FALSE ) );
|
| 175 |
+
$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() ) );
|
| 176 |
}
|
| 177 |
|
| 178 |
public function print_css()
|
| 181 |
}
|
| 182 |
|
| 183 |
}
|
| 184 |
+
|
| 185 |
+
add_action( 'plugins_loaded', create_function( '', 'new WhatTheFile();' ) );
|
| 186 |
+
register_activation_hook( __FILE__, array( 'WhatTheFile', 'plugin_activation' ) );
|
