Changeset 1548644
- Timestamp:
- 12/08/2016 04:41:57 AM (9 years ago)
- Location:
- page-template-dashboard/trunk
- Files:
-
- 3 added
- 4 edited
-
CHANGELOG.md (added)
-
README.md (added)
-
README.txt (modified) (3 diffs)
-
class-page-template-dashboard.php (modified) (4 diffs)
-
composer.json (added)
-
page-template-dashboard.php (modified) (2 diffs)
-
screenshot-1.png (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
page-template-dashboard/trunk/README.txt
r1149113 r1548644 4 4 Tags: page, templates 5 5 Requires at least: 3.4 6 Tested up to: 4. 2.17 Stable tag: 1. 6.06 Tested up to: 4.7.0 7 Stable tag: 1.7.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 22 22 does not exist in the current theme 23 23 24 The plugin is also fully localized for translation.24 The plugin is also fully internationalized for translation. 25 25 26 For more information or to follow the project, check out the [ project page](http://tommcfarlin.com/projects/page-template-dashboard/).26 For more information or to follow the project, check out the [GitHub repository](https://github.com/tommcfarlin/page-template-dashboard). 27 27 28 28 == Installation == … … 46 46 47 47 == Changelog == 48 49 = 1.7.0 = 50 51 * Verifies WordPress 4.7 compatibility. 52 * Adds Composer support for PHP Unit and PHP CodeSniffer. 53 * Adds CHANGELOG.md for users on GitHub. 54 * Updates screenshot for the most recent version of WordPress. 55 * Updates code to the WordPress Coding Standards. 56 * Removes the implementation of the Singleton Pattern. 57 * Removes the locale property in place of actual strings for i18n. 48 58 49 59 = 1.6.0 = -
page-template-dashboard/trunk/class-page-template-dashboard.php
r1074105 r1548644 7 7 * @license GPL-2.0+ 8 8 * @link http://tommcfarlin.com/page-template-dashboard/ 9 * @copyright 2013 - 201 5Tom McFarlin9 * @copyright 2013 - 2016 Tom McFarlin 10 10 */ 11 11 … … 19 19 class Page_Template_Dashboard { 20 20 21 /*--------------------------------------------* 22 * Attributes 23 *--------------------------------------------*/ 21 /** 22 * Registers all hooks necessary for plugin functionality. 23 */ 24 public function init() { 25 26 add_action( 27 'init', 28 array( $this, 'plugin_textdomain' ) 29 ); 30 31 add_filter( 32 'manage_edit-page_columns', 33 array( $this, 'add_template_column' ) 34 ); 35 36 add_action( 37 'manage_page_posts_custom_column', 38 array( $this, 'add_template_data' ) 39 ); 40 } 24 41 25 42 /** 26 * The locale of this plugin. 27 * 28 * @since 1.2.0 29 * 30 * @var string 31 */ 32 private $locale; 33 34 /** 35 * Instance of this class. 36 * 37 * @since 1.2.0 38 * 39 * @var object 40 */ 41 protected static $instance = null; 42 43 /*--------------------------------------------* 44 * Constructor 45 *--------------------------------------------*/ 46 47 /** 48 * Return an instance of this class. 49 * 50 * @since 1.0.0 51 * 52 * @return object A single instance of this class. 53 */ 54 public static function get_instance() { 55 56 // If the single instance hasn't been set, set it now. 57 if ( null == self::$instance ) { 58 self::$instance = new self; 59 } // end if 60 61 return self::$instance; 62 63 } // end get_instance 64 65 /** 66 * Initializes the plugin by setting localization, filters, and administration functions. 67 * 68 * @version 1.0 69 * @since 1.0 70 */ 71 private function __construct() { 72 73 // Set the locale for the plugin 74 $this->locale = 'page-template-dashboard-locale'; 75 76 // Load plugin textdomain 77 add_action( 'init', array( $this, 'plugin_textdomain' ) ); 78 79 // Define the actions and filters 80 add_filter( 'manage_edit-page_columns', array( $this, 'add_template_column' ) ); 81 add_action( 'manage_page_posts_custom_column', array( $this, 'add_template_data' ) ); 82 83 } // end constructor 84 85 /*--------------------------------------------* 86 * Core Functions 87 *--------------------------------------------*/ 88 89 /** 90 * Loads the plugin text domain for translation 91 * 92 * @version 1.0 93 * @since 1.0 43 * Loads the plugin text domain for translation. 94 44 */ 95 45 public function plugin_textdomain() { 96 load_plugin_textdomain( 'page-template-dashboard', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );97 } // end plugin_textdomain98 46 99 /*--------------------------------------------* 100 * Filters 101 *--------------------------------------------*/ 47 load_plugin_textdomain( 48 'page-template-dashboard', 49 false, 50 dirname( plugin_basename( __FILE__ ) ) . '/lang' 51 ); 52 } 102 53 103 54 /** … … 105 56 * for the given page. 106 57 * 107 * @param array $page_columns The array of columns rendering page meta data./ 108 * @return array The update array of page columns. 109 * @version 1.0 110 * @since 1.0 58 * @param array $page_columns The array of columns rendering page meta data. 59 * 60 * @return array $page_columns The update array of page columns. 111 61 */ 112 62 public function add_template_column( $page_columns ) { 113 63 114 $page_columns['template'] = __( 'Page Template', $this->locale ); 115 64 $page_columns['template'] = __( 'Page Template', 'page-template-dashboard-locale' ); 116 65 return $page_columns; 117 118 } // end add_template_column 119 120 /*--------------------------------------------* 121 * Actions 122 *--------------------------------------------*/ 66 } 123 67 124 68 /** … … 126 70 * template is used, but will use the friendly name of the template if one is applied. 127 71 * 128 * @param string $column_name The name of the column being rendered 129 * @version 1.0 130 * @since 1.0 72 * @param string $column_name The name of the column being rendered. 131 73 */ 132 public function add_template_data( $column_name ) {74 public function add_template_data( $column_name ) { 133 75 134 // Grab a reference to the post that's currently being rendered 76 // If we're not looking at the 'Template' column, then we're done. 77 if ( 'template' !== $column_name ) { 78 return; 79 } 80 81 // Grab a reference to the post that's currently being rendered. 135 82 global $post; 136 83 137 // If we're looking at our custom column, then let's get ready to render some information. 138 if( 'template' == $column_name ) { 84 // First, the get name of the template. 85 $template_name = get_page_template_slug( $post->ID ); 86 $template = untrailingslashit( get_stylesheet_directory() ) . '/' . $template_name; 139 87 140 // First, the get name of the template 141 $template_name = get_page_template_slug( $post->ID ); 88 /** 89 * If the file name is empty or the template file doesn't exist (because, say, 90 * meta data is left from a previous theme). 91 * Otherwise, let's actually get the friendly name of the file rather than the name of the file itself 92 * by using the WordPress `get_file_description` function 93 */ 94 $template_name = ( 0 === strlen( trim( $template_name ) ) || ! file_exists( $template ) ) ? 95 __( 'Default', 'page-template-dashboard-locale' ) : 96 get_file_description( $template ); 142 97 143 // If the file name is empty or the template file doesn't exist (because, say, meta data is left from a previous theme)... 144 if( 0 == strlen( trim( $template_name ) ) || ! file_exists( get_stylesheet_directory() . '/' . $template_name ) ) { 145 146 // ...then we'll set it as default 147 $template_name = __( 'Default', $this->locale ); 148 149 // Otherwise, let's actually get the friendly name of the file rather than the name of the file itself 150 // by using the WordPress `get_file_description` function 151 } else { 152 153 $template_name = get_file_description( get_stylesheet_directory() . '/' . $template_name ); 154 155 } // end if 156 157 } // end if 158 159 // Finally, render the template name 160 echo $template_name; 161 162 } // end add_template_data 163 164 } // end class 98 // Finally, render the template name. 99 echo esc_html( $template_name ); 100 } 101 } -
page-template-dashboard/trunk/page-template-dashboard.php
r1149112 r1548644 6 6 * 7 7 * @package PTD 8 * @author Your Name <email@example.com>8 * @author Tom McFarlin <tom@tommcfarlin.com> 9 9 * @license GPL-2.0+ 10 * @link http ://tommcfarlin.com/page-template-dashboard/11 * @copyright 2013 - 201 5Tom McFarlin10 * @link https://tommcfarlin.com/page-template-dashboard/ 11 * @copyright 2013 - 2016 Tom McFarlin 12 12 * 13 13 * @wordpress-plugin 14 14 * Plugin Name: Page Template Dashboard 15 * Plugin URI: http ://tommcfarlin.com/page-template-dashboard/15 * Plugin URI: https://tommcfarlin.com/page-template-dashboard/ 16 16 * Description: An easy way to see which templates your pages are using without having to view the page editor. 17 * Version: 1. 6.017 * Version: 1.7.0 18 18 * Author: Tom McFarlin 19 * Author URI: http ://tommcfarlin.com/19 * Author URI: https://tommcfarlin.com/ 20 20 * Text Domain: page-template-dashboard-locale 21 21 * License: GPL-2.0+ … … 24 24 */ 25 25 26 // If this file is called directly, abort. 27 if ( ! defined( 'WPINC' ) ) { 28 die; 26 defined( 'WPINC' ) || die; 27 28 include_once 'class-page-template-dashboard.php' ; 29 30 add_action( 'plugins_loaded', 'ptd_start' ); 31 /** 32 * Starts the plugin. 33 */ 34 function ptd_start() { 35 36 $plugin = new Page_Template_Dashboard(); 37 $plugin->init(); 29 38 } 30 31 require_once( plugin_dir_path( __FILE__ ) . 'class-page-template-dashboard.php' );32 Page_Template_Dashboard::get_instance();
Note: See TracChangeset
for help on using the changeset viewer.