Version Description
- Improved the admin panel and administrator role check.
Download this release
Release Info
Developer | barrykooij |
Plugin | What The File |
Version | 1.2.1 |
Comparing to | |
See all releases |
Code changes from version 1.2.0 to 1.2.1
- readme.txt +6 -3
- what-the-file.php +33 -35
readme.txt
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
=== What The File ===
|
2 |
Contributors: barrykooij
|
3 |
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.2.
|
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.
|
12 |
|
13 |
== Description ==
|
14 |
|
@@ -46,6 +46,9 @@ Yes it does.
|
|
46 |
|
47 |
== Changelog ==
|
48 |
|
|
|
|
|
|
|
49 |
= 1.2.0 =
|
50 |
* Added BuddyPress support.
|
51 |
* Added WordPress.org review notice.
|
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.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 |
|
46 |
|
47 |
== Changelog ==
|
48 |
|
49 |
+
= 1.2.1 =
|
50 |
+
* Improved the admin panel and administrator role check.
|
51 |
+
|
52 |
= 1.2.0 =
|
53 |
* Added BuddyPress support.
|
54 |
* Added WordPress.org review notice.
|
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 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.
|
7 |
Author: Barry Kooij
|
8 |
Author URI: http://www.barrykooij.com/
|
9 |
License: GPL v3
|
@@ -29,17 +29,17 @@ class WhatTheFile
|
|
29 |
{
|
30 |
const OPTION_INSTALL_DATE = 'whatthefile-install-date';
|
31 |
const OPTION_ADMIN_NOTICE_KEY = 'whatthefile-hide-notice';
|
32 |
-
|
33 |
|
34 |
public static function plugin_activation()
|
35 |
{
|
36 |
self::insert_install_date();
|
37 |
}
|
38 |
|
39 |
-
|
40 |
-
|
41 |
$this->hooks();
|
42 |
-
|
43 |
|
44 |
private static function insert_install_date()
|
45 |
{
|
@@ -59,13 +59,6 @@ class WhatTheFile
|
|
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;
|
@@ -79,11 +72,16 @@ class WhatTheFile
|
|
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 |
-
|
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 == '' ) {
|
@@ -97,9 +95,9 @@ class WhatTheFile
|
|
97 |
}
|
98 |
}
|
99 |
|
100 |
-
//
|
101 |
-
if(
|
102 |
-
return
|
103 |
}
|
104 |
|
105 |
// WTF actions and filers
|
@@ -146,8 +144,8 @@ class WhatTheFile
|
|
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 |
-
|
150 |
-
|
151 |
}
|
152 |
|
153 |
public function save_buddy_press_template( $template )
|
@@ -156,9 +154,9 @@ class WhatTheFile
|
|
156 |
$this->template_name = str_ireplace( get_template_directory() . '/', '', $template );
|
157 |
}
|
158 |
}
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
$this->template_name = basename( $template_name );
|
163 |
|
164 |
// Do Roots Theme check
|
@@ -166,20 +164,20 @@ class WhatTheFile
|
|
166 |
$this->template_name = basename( roots_template_path() );
|
167 |
}
|
168 |
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
}
|
184 |
|
185 |
add_action( 'plugins_loaded', create_function( '', 'new WhatTheFile();' ) );
|
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
|
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 |
{
|
59 |
return new DateTime( $date_string );
|
60 |
}
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
private function get_current_page()
|
63 |
{
|
64 |
return $this->template_name;
|
72 |
|
73 |
private function hooks()
|
74 |
{
|
75 |
+
// Check if user is an administrator
|
76 |
+
if( !current_user_can('manage_options') ) {
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
|
80 |
// Admin notice hide catch
|
81 |
add_action( 'admin_init', array( $this, 'catch_hide_notice' ) );
|
82 |
|
83 |
// Is admin notice hidden?
|
84 |
+
$current_user = wp_get_current_user();
|
85 |
$hide_notice = get_user_meta( $current_user->ID, self::OPTION_ADMIN_NOTICE_KEY, true );
|
86 |
|
87 |
if( current_user_can( 'install_plugins' ) && $hide_notice == '' ) {
|
95 |
}
|
96 |
}
|
97 |
|
98 |
+
// Don't add admin bar option in admin panel
|
99 |
+
if( is_admin() || !is_admin_bar_showing() ) {
|
100 |
+
return;
|
101 |
}
|
102 |
|
103 |
// WTF actions and filers
|
144 |
$query_string = '?' . http_build_query( array_merge( $query_params, array( self::OPTION_ADMIN_NOTICE_KEY => '1' ) ) );
|
145 |
|
146 |
echo '<div class="updated"><p>';
|
147 |
+
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 );
|
148 |
+
echo "</p></div>";
|
149 |
}
|
150 |
|
151 |
public function save_buddy_press_template( $template )
|
154 |
$this->template_name = str_ireplace( get_template_directory() . '/', '', $template );
|
155 |
}
|
156 |
}
|
157 |
+
|
158 |
+
public function save_current_page( $template_name )
|
159 |
+
{
|
160 |
$this->template_name = basename( $template_name );
|
161 |
|
162 |
// Do Roots Theme check
|
164 |
$this->template_name = basename( roots_template_path() );
|
165 |
}
|
166 |
|
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 |
}
|
182 |
|
183 |
add_action( 'plugins_loaded', create_function( '', 'new WhatTheFile();' ) );
|