first
This commit is contained in:
BIN
wp-content/plugins/what-the-file/assets/images/never5-logo.png
Normal file
BIN
wp-content/plugins/what-the-file/assets/images/never5-logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
39
wp-content/plugins/what-the-file/assets/js/what-the-file.js
Normal file
39
wp-content/plugins/what-the-file/assets/js/what-the-file.js
Normal file
@ -0,0 +1,39 @@
|
||||
window.addEventListener('load', (event) => {
|
||||
|
||||
if (wtf_templates === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check if there are templates
|
||||
if (wtf_templates.length > 0) {
|
||||
// the parent selector
|
||||
var parent = document.querySelector("#wp-admin-bar-wtf-bar-template-parts #wp-admin-bar-wtf-bar-template-parts-default");
|
||||
|
||||
// clear the loading
|
||||
parent.replaceChildren();
|
||||
|
||||
// add new children
|
||||
for (let i = 0; i < wtf_templates.length; i++) {
|
||||
let listItem = document.createElement("li");
|
||||
listItem.id = "wp-admin-bar-wtf-bar-template-part-template-parts/" + i;
|
||||
|
||||
let templateName;
|
||||
|
||||
if(wtf_templates[i].edit_url !== false) {
|
||||
templateName = document.createElement("a");
|
||||
templateName.className ="ab-item";
|
||||
templateName.href = wtf_templates[i].edit_url;
|
||||
}else {
|
||||
templateName = document.createElement("span");
|
||||
templateName.className ="ab-item ab-empty-item";
|
||||
}
|
||||
templateName.textContent = wtf_templates[i].file;
|
||||
|
||||
listItem.appendChild(templateName);
|
||||
parent.appendChild(listItem);
|
||||
}
|
||||
} else {
|
||||
// we have no template parts, remove the menu item for this page
|
||||
document.querySelector("#wp-admin-bar-wtf-bar-template-parts").remove();
|
||||
}
|
||||
});
|
118
wp-content/plugins/what-the-file/classes/class-nag.php
Normal file
118
wp-content/plugins/what-the-file/classes/class-nag.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
class WTF_Nag {
|
||||
|
||||
/**
|
||||
* Setup the class
|
||||
*/
|
||||
public function setup() {
|
||||
// catch nag hide
|
||||
$this->catch_hide_notice();
|
||||
|
||||
// bind nag
|
||||
$this->bind();
|
||||
}
|
||||
|
||||
/**
|
||||
* Catch the hide nag request
|
||||
*/
|
||||
private function catch_hide_notice() {
|
||||
if ( isset( $_GET[ WhatTheFile::OPTION_ADMIN_NOTICE_KEY ] ) && current_user_can( 'install_plugins' ) ) {
|
||||
// Add user meta
|
||||
global $current_user;
|
||||
add_user_meta( $current_user->ID, WhatTheFile::OPTION_ADMIN_NOTICE_KEY, '1', true );
|
||||
|
||||
// Build redirect URL
|
||||
$query_params = $this->get_admin_querystring_array();
|
||||
unset( $query_params[ WhatTheFile::OPTION_ADMIN_NOTICE_KEY ] );
|
||||
$query_string = http_build_query( $query_params );
|
||||
if ( $query_string != '' ) {
|
||||
$query_string = '?' . $query_string;
|
||||
}
|
||||
|
||||
$redirect_url = 'http';
|
||||
if ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) {
|
||||
$redirect_url .= 's';
|
||||
}
|
||||
$redirect_url .= '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . $query_string;
|
||||
|
||||
// Redirect
|
||||
wp_redirect( $redirect_url );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind nag message
|
||||
*/
|
||||
private function bind() {
|
||||
// Is admin notice hidden?
|
||||
$current_user = wp_get_current_user();
|
||||
$hide_notice = get_user_meta( $current_user->ID, WhatTheFile::OPTION_ADMIN_NOTICE_KEY, true );
|
||||
|
||||
// Check if we need to display the notice
|
||||
if ( current_user_can( 'install_plugins' ) && '' == $hide_notice ) {
|
||||
// Get installation date
|
||||
$datetime_install = $this->get_install_date();
|
||||
$datetime_past = new DateTime( '-10 days' );
|
||||
|
||||
if ( $datetime_past >= $datetime_install ) {
|
||||
// 10 or more days ago, show admin notice
|
||||
add_action( 'admin_notices', array( $this, 'display_admin_notice' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the install data
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
private function get_install_date() {
|
||||
$date_string = get_site_option( WhatTheFile::OPTION_INSTALL_DATE, '' );
|
||||
if ( $date_string == '' ) {
|
||||
// There is no install date, plugin was installed before version 1.2.0. Add it now.
|
||||
$date_string = self::insert_install_date();
|
||||
}
|
||||
|
||||
return new DateTime( $date_string );
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the admin query string
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_admin_querystring_array() {
|
||||
parse_str( $_SERVER['QUERY_STRING'], $params );
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the install date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function insert_install_date() {
|
||||
$datetime_now = new DateTime();
|
||||
$date_string = $datetime_now->format( 'Y-m-d' );
|
||||
add_site_option( WhatTheFile::OPTION_INSTALL_DATE, $date_string );
|
||||
|
||||
return $date_string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the admin notice
|
||||
*/
|
||||
public function display_admin_notice() {
|
||||
|
||||
$query_params = $this->get_admin_querystring_array();
|
||||
$query_string = '?' . http_build_query( array_merge( $query_params, array( WhatTheFile::OPTION_ADMIN_NOTICE_KEY => '1' ) ) );
|
||||
|
||||
echo '<div class="updated"><p>';
|
||||
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><br/><br/><small><a href='http://www.never5.com/' target='_blank'>Check out other Never5 plugins</a></small>" ), 'http://wordpress.org/support/view/plugin-reviews/what-the-file', $query_string );
|
||||
echo "</p></div>";
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
class WTF_Plugin_Links {
|
||||
|
||||
/**
|
||||
* Setup class
|
||||
*/
|
||||
public function setup() {
|
||||
add_filter( 'plugin_action_links_what-the-file/what-the-file.php', array( $this, 'add_links' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to links
|
||||
*
|
||||
* @param array $links
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_links( $links ) {
|
||||
array_unshift( $links, '<a href="http://www.never5.com/?utm_source=plugin&utm_medium=link&utm_campaign=what-the-file" target="_blank" style="color:#ffa100;font-weight:bold;">' . __( 'More Never5 Plugins', 'what-the-file' ) . '</a>' );
|
||||
return $links;
|
||||
}
|
||||
|
||||
}
|
137
wp-content/plugins/what-the-file/readme.txt
Normal file
137
wp-content/plugins/what-the-file/readme.txt
Normal file
@ -0,0 +1,137 @@
|
||||
=== What The File ===
|
||||
Contributors: never5, barrykooij
|
||||
Donate link: http://www.barrykooij.com/donate/
|
||||
Tags: toolbar, development, file, template, template editing, Template Hierarchy, theme, themes, php, php file, template part
|
||||
Requires at least: 3.1
|
||||
Requires PHP: 5.3
|
||||
Tested up to: 6.3
|
||||
Stable tag: 1.6.0
|
||||
License: GPL v3
|
||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
What The File is the best tool to find out what template parts are used to display the page you're currently viewing!
|
||||
|
||||
== 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, though I don't recommend this for bigger changes.
|
||||
|
||||
What The File supports BuddyPress and Roots Theme based themes.
|
||||
|
||||
More information can be found <a href='http://www.barrykooij.com/what-the-file/'>here</a>.
|
||||
|
||||
= Looking for a great related posts plugin for WordPress? =
|
||||
Another plugin I've built, that I'm very proud of is Related Posts for WordPress. Related Posts for WordPress offers you the ability to link related posts to each other with just 1 click! And it's 100% free! [Check it out on the WordPress repository.](https://wordpress.org/plugins/related-posts-for-wp/)
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. Upload `what-the-file` to the `/wp-content/plugins/` directory
|
||||
2. Activate the plugin through the 'Plugins' menu in WordPress
|
||||
|
||||
== Frequently asked questions ==
|
||||
|
||||
= Where can I see what template file is used? =
|
||||
|
||||
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.
|
||||
|
||||
= I can't find the "What The File" option in the toolbar =
|
||||
|
||||
You have to be an Administrator to see the "What The File" option.
|
||||
|
||||
= What PHP version are supported / tested? =
|
||||
|
||||
What The File works supports starts at PHP 5.3 and is tested on every major release up until PHP 8.1.
|
||||
|
||||
= Does What The File supports BuddyPress =
|
||||
|
||||
Yes it does.
|
||||
|
||||
= Does What The File supports Roots Theme =
|
||||
|
||||
Yes it does.
|
||||
|
||||
= You saved me so much time, is there any way I can thank you? =
|
||||
|
||||
Glad to hear I could help you! You can thank me in various ways, please see [my donation page](http://www.barrykooij.com/donate/) to find out more.
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. What The File shows you what template file is used.
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.6.0: September 19, 2022 =
|
||||
* Feature: Now correctly working with the wp_body_open tag. Full template part support is back.
|
||||
* Tweak: Used proper add_site_option argument count. props @szepeviktor
|
||||
* Tweak: Optimized file editing allowed function. props @szepeviktor
|
||||
* Tweak: Change template_include priority from 1000 to PHP_INT_MAX for wider support. props @greenshady
|
||||
* Tweak: Version and meta update.
|
||||
|
||||
= 1.5.4: October 8, 2017 =
|
||||
* Version and meta update.
|
||||
|
||||
= 1.5.3: May 2, 2016 =
|
||||
* Appended an extra check for the Sage starter theme, props [remyvv](https://github.com/remyvv).
|
||||
|
||||
= 1.5.2 =
|
||||
* Fixed a CSS bug with admin bar.
|
||||
|
||||
= 1.5.1 =
|
||||
* Fixed a bug where some themes make _all_ images display block.
|
||||
|
||||
= 1.5.0 =
|
||||
* Only add edit link if direct file editing is allowed. Props szepeviktor
|
||||
* Wrapped initiation in hooks and split frontend and admin code.
|
||||
* Removed use of create_function.
|
||||
* Various code optimizations.
|
||||
|
||||
= 1.4.1 =
|
||||
* Fixed wrongly aligned arrow in MP6 - props [remyvv](https://github.com/remyvv).
|
||||
* Template parts are now correctly shown in child themes - props [remyvv](https://github.com/remyvv).
|
||||
* Code style change.
|
||||
|
||||
= 1.4.0 =
|
||||
* Fixed a template part bug, props remyvv
|
||||
* Code style change
|
||||
|
||||
= 1.3.2 =
|
||||
* Plugin now check if file exists in child theme or parent theme.
|
||||
|
||||
= 1.3.1 =
|
||||
* Editing files directly through the theme editor now supports child themes.
|
||||
|
||||
= 1.3.0 =
|
||||
* Added template part support.
|
||||
|
||||
= 1.2.1 =
|
||||
* Improved the admin panel and administrator role check.
|
||||
|
||||
= 1.2.0 =
|
||||
* Added BuddyPress support.
|
||||
* Added WordPress.org review notice.
|
||||
* Fixed admin check.
|
||||
* Small code changes and refactoring.
|
||||
* Extended GPL license.
|
||||
|
||||
= 1.1.2 =
|
||||
* Fixed admin url bug caused when WordPress is installed in a subdirectory.
|
||||
|
||||
= 1.1.1 =
|
||||
* Small meta information changes.
|
||||
|
||||
= 1.1.0 =
|
||||
* Added Roots Theme support.
|
||||
* Added WordPress 3.5.1 support.
|
||||
* Meta information changed.
|
||||
|
||||
= 1.0.3 =
|
||||
* Added WordPress 3.5 support.
|
||||
* Small meta information changes.
|
||||
|
||||
= 1.0.2 =
|
||||
* Fixed incorrect url when theme directory name differs from theme name.
|
||||
|
||||
= 1.0.1 =
|
||||
* Changed the way the plugin initializes.
|
||||
* Moved CSS from file to inline CSS.
|
340
wp-content/plugins/what-the-file/what-the-file.php
Normal file
340
wp-content/plugins/what-the-file/what-the-file.php
Normal file
@ -0,0 +1,340 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: What The File
|
||||
Plugin URI: http://www.barrykooij.com/what-the-file/
|
||||
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>.
|
||||
Version: 1.6.0
|
||||
Author: Never5
|
||||
Author URI: http://www.never5.com/
|
||||
License: GPL v3
|
||||
Requires PHP: 5.3
|
||||
|
||||
What The File Plugin
|
||||
Copyright (C) 2012-2022, Never5 - www.never5.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class WhatTheFile {
|
||||
|
||||
const OPTION_INSTALL_DATE = 'whatthefile-install-date';
|
||||
const OPTION_ADMIN_NOTICE_KEY = 'whatthefile-hide-notice';
|
||||
|
||||
CONST VERSION = '1.6.0';
|
||||
|
||||
/** @var string $template_name */
|
||||
private $template_name = '';
|
||||
|
||||
/** @var array $template_parts */
|
||||
private $template_parts = array();
|
||||
|
||||
/**
|
||||
* Method run on plugin activation
|
||||
*/
|
||||
public static function plugin_activation() {
|
||||
// include nag class
|
||||
require_once( plugin_dir_path( __FILE__ ) . '/classes/class-nag.php' );
|
||||
|
||||
// insert install date
|
||||
WTF_Nag::insert_install_date();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( $this, 'frontend_hooks' ) );
|
||||
add_action( 'admin_init', array( $this, 'admin_hooks' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the admin hooks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function admin_hooks() {
|
||||
|
||||
// Check if user is an administrator
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// include nag class
|
||||
require_once( plugin_dir_path( __FILE__ ) . '/classes/class-nag.php' );
|
||||
|
||||
// setup nag
|
||||
$nag = new WTF_Nag();
|
||||
$nag->setup();
|
||||
|
||||
// include plugin links class
|
||||
require_once( plugin_dir_path( __FILE__ ) . '/classes/class-plugin-links.php' );
|
||||
|
||||
// setup plugin links
|
||||
$plugin_links = new WTF_Plugin_Links();
|
||||
$plugin_links->setup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the frontend hooks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function frontend_hooks() {
|
||||
// Don't run in admin or if the admin bar isn't showing
|
||||
if ( is_admin() || ! is_admin_bar_showing() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// WTF actions and filers
|
||||
add_action( 'wp_head', array( $this, 'print_css' ) );
|
||||
add_action( 'wp_footer', array( $this, 'print_frontend_js' ), 50 );
|
||||
add_filter( 'template_include', array( $this, 'save_current_page' ), PHP_INT_MAX );
|
||||
add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 1000 );
|
||||
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_script' ) );
|
||||
|
||||
// BuddyPress support
|
||||
if ( class_exists( 'BuddyPress' ) ) {
|
||||
add_action( 'bp_core_pre_load_template', array( $this, 'save_buddy_press_template' ) );
|
||||
}
|
||||
|
||||
// Template part hooks
|
||||
add_action( 'all', array( $this, 'save_template_parts' ), 1, 3 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current page
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function get_current_page() {
|
||||
return $this->template_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file exists in child theme
|
||||
*
|
||||
* @param $file
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function file_exists_in_child_theme( $file ) {
|
||||
return file_exists( get_stylesheet_directory() . '/' . $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if direct file editing through WordPress is allowed
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function is_file_editing_allowed() {
|
||||
return ! ( ( defined( 'DISALLOW_FILE_EDIT' ) && true == DISALLOW_FILE_EDIT ) || ( defined( 'DISALLOW_FILE_MODS' ) && true == DISALLOW_FILE_MODS ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the template parts in our array
|
||||
*
|
||||
* @param string $tag
|
||||
* @param string|null $slug
|
||||
* @param string|null $name
|
||||
*/
|
||||
public function save_template_parts( $tag, $slug = null, $name = null ) {
|
||||
if ( 0 !== strpos( $tag, 'get_template_part_' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if slug is set
|
||||
if ( $slug != null ) {
|
||||
|
||||
// Templates array
|
||||
$templates = array();
|
||||
|
||||
// Add possible template part to array
|
||||
if ( $name != null ) {
|
||||
$templates[] = "{$slug}-{$name}.php";
|
||||
}
|
||||
|
||||
// Add possible template part to array
|
||||
$templates[] = "{$slug}.php";
|
||||
|
||||
// Get the correct template part
|
||||
$template_part = str_replace( get_template_directory() . '/', '', locate_template( $templates ) );
|
||||
$template_part = str_replace( get_stylesheet_directory() . '/', '', $template_part );
|
||||
|
||||
// Add template part if found
|
||||
if ( $template_part != '' ) {
|
||||
$this->template_parts[] = $template_part;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the BuddyPress template
|
||||
*
|
||||
* @param $template
|
||||
*/
|
||||
public function save_buddy_press_template( $template ) {
|
||||
|
||||
if ( '' == $this->template_name ) {
|
||||
$template_name = $template;
|
||||
$template_name = str_ireplace( get_template_directory() . '/', '', $template_name );
|
||||
$template_name = str_ireplace( get_stylesheet_directory() . '/', '', $template_name );
|
||||
$this->template_name = $template_name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the current page in our local var
|
||||
*
|
||||
* @param $template_name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function save_current_page( $template_name ) {
|
||||
$this->template_name = basename( $template_name );
|
||||
|
||||
// Do Roots Theme check
|
||||
if ( function_exists( 'roots_template_path' ) ) {
|
||||
$this->template_name = basename( roots_template_path() );
|
||||
} else if( function_exists( 'Roots\Sage\Wrapper\template_path' ) ) {
|
||||
$this->template_name = basename( Roots\Sage\Wrapper\template_path() );
|
||||
}
|
||||
|
||||
return $template_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the admin bar menu
|
||||
*/
|
||||
public function admin_bar_menu() {
|
||||
global $wp_admin_bar;
|
||||
|
||||
// Check if direct file editing is allowed
|
||||
$edit_allowed = $this->is_file_editing_allowed();
|
||||
|
||||
// Add top menu
|
||||
$wp_admin_bar->add_menu( array(
|
||||
'id' => 'wtf-bar',
|
||||
'parent' => 'top-secondary',
|
||||
'title' => __( 'What The File', 'what-the-file' ),
|
||||
'href' => false
|
||||
) );
|
||||
|
||||
// Check if template file exists in child theme
|
||||
$theme = get_stylesheet();
|
||||
if ( ! $this->file_exists_in_child_theme( $this->get_current_page() ) ) {
|
||||
$theme = get_template();
|
||||
}
|
||||
|
||||
// Add current page
|
||||
$wp_admin_bar->add_menu( array(
|
||||
'id' => 'wtf-bar-template-file',
|
||||
'parent' => 'wtf-bar',
|
||||
'title' => $this->get_current_page(),
|
||||
'href' => ( ( $edit_allowed ) ? get_admin_url() . 'theme-editor.php?file=' . $this->get_current_page() . '&theme=' . $theme : false )
|
||||
) );
|
||||
|
||||
// Add template parts menu item
|
||||
$wp_admin_bar->add_menu( array(
|
||||
'id' => 'wtf-bar-template-parts',
|
||||
'parent' => 'wtf-bar',
|
||||
'title' => 'Template Parts',
|
||||
'href' => false
|
||||
) );
|
||||
|
||||
// add a dummy child, we replace this via JS
|
||||
$wp_admin_bar->add_menu( array(
|
||||
'id' => 'wtf-bar-template-part-loading',
|
||||
'parent' => 'wtf-bar-template-parts',
|
||||
'title' => 'Loading...',
|
||||
'href' => false
|
||||
) );
|
||||
|
||||
// Add powered by
|
||||
$wp_admin_bar->add_menu( array(
|
||||
'id' => 'wtf-bar-powered-by',
|
||||
'parent' => 'wtf-bar',
|
||||
'title' => 'Powered by Never5',
|
||||
'href' => 'http://www.never5.com?utm_source=plugin&utm_medium=wtf-bar&utm_campaign=what-the-file'
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the custom CSS
|
||||
*/
|
||||
public function print_css() {
|
||||
echo "<style type=\"text/css\" media=\"screen\">#wp-admin-bar-wtf-bar > .ab-item{padding-right:26px !important;background: url('" . plugins_url( 'assets/images/never5-logo.png', __FILE__ ) . "')center right no-repeat !important;} #wp-admin-bar-wtf-bar.hover > .ab-item {background-color: #32373c !important; } #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;} #wp-admin-bar-wtf-bar-template-parts.menupop > .ab-item:before{ right:auto !important; }#wp-admin-bar-wtf-bar-powered-by{text-align: right;}#wp-admin-bar-wtf-bar-powered-by a{color:#ffa100 !important;} #wpadminbar .ab-top-secondary .menupop .menupop > .ab-item .wp-admin-bar-arrow:before {right: auto !important;}</style>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue frontend JS
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_frontend_script() {
|
||||
wp_enqueue_script( 'rp4wp-frontend-js', plugin_dir_url( __FILE__ ) . 'assets/js/what-the-file.js', array(), self::VERSION, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print frontend JS
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function print_frontend_js() {
|
||||
|
||||
$edit_allowed = $this->is_file_editing_allowed();
|
||||
|
||||
$templates = array();
|
||||
|
||||
foreach ( $this->template_parts as $template_part ) {
|
||||
|
||||
// dedupe template parts
|
||||
foreach ( $templates as $t ) {
|
||||
if ( $t['file'] == $template_part ) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$theme = get_stylesheet();
|
||||
if ( ! $this->file_exists_in_child_theme( $template_part ) ) {
|
||||
$theme = get_template();
|
||||
}
|
||||
|
||||
$templates[] = array(
|
||||
"edit_url" => ( ( $edit_allowed ) ? get_admin_url() . 'theme-editor.php?file=' . $template_part . '&theme=' . $theme : false ),
|
||||
"file" => $template_part
|
||||
);
|
||||
}
|
||||
|
||||
echo "<script type='text/javascript'>var wtf_templates = " . json_encode( $templates ) . ";</script>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* What The File main function
|
||||
*/
|
||||
function __what_the_file_main() {
|
||||
new WhatTheFile();
|
||||
}
|
||||
|
||||
// Init plugin
|
||||
add_action( 'plugins_loaded', '__what_the_file_main' );
|
||||
|
||||
// Register hook
|
||||
register_activation_hook( __FILE__, array( 'WhatTheFile', 'plugin_activation' ) );
|
Reference in New Issue
Block a user