Plugin Directory

Changeset 1548644


Ignore:
Timestamp:
12/08/2016 04:41:57 AM (9 years ago)
Author:
tommcfarlin
Message:
  • Verifies WordPress 4.7 compatibility.
  • Adds Composer support for PHP Unit and PHP CodeSniffer.
  • Adds CHANGELOG.md for users on GitHub.
  • Updates screenshot for the most recent version of WordPress.
  • Updates code to the WordPress Coding Standards.
  • Removes the implementation of the Singleton Pattern.
  • Removes the locale property in place of actual strings for i18n.
Location:
page-template-dashboard/trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • page-template-dashboard/trunk/README.txt

    r1149113 r1548644  
    44Tags: page, templates
    55Requires at least: 3.4
    6 Tested up to: 4.2.1
    7 Stable tag: 1.6.0
     6Tested up to: 4.7.0
     7Stable tag: 1.7.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2222does not exist in the current theme
    2323
    24 The plugin is also fully localized for translation.
     24The plugin is also fully internationalized for translation.
    2525
    26 For more information or to follow the project, check out the [project page](http://tommcfarlin.com/projects/page-template-dashboard/).
     26For more information or to follow the project, check out the [GitHub repository](https://github.com/tommcfarlin/page-template-dashboard).
    2727
    2828== Installation ==
     
    4646
    4747== 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.
    4858
    4959= 1.6.0 =
  • page-template-dashboard/trunk/class-page-template-dashboard.php

    r1074105 r1548644  
    77 * @license   GPL-2.0+
    88 * @link      http://tommcfarlin.com/page-template-dashboard/
    9  * @copyright 2013 - 2015 Tom McFarlin
     9 * @copyright 2013 - 2016 Tom McFarlin
    1010 */
    1111
     
    1919class Page_Template_Dashboard {
    2020
    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    }
    2441
    2542    /**
    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.
    9444     */
    9545    public function plugin_textdomain() {
    96         load_plugin_textdomain( 'page-template-dashboard', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
    97     } // end plugin_textdomain
    9846
    99     /*--------------------------------------------*
    100      * Filters
    101      *--------------------------------------------*/
     47        load_plugin_textdomain(
     48            'page-template-dashboard',
     49            false,
     50            dirname( plugin_basename( __FILE__ ) ) . '/lang'
     51        );
     52    }
    10253
    10354    /**
     
    10556     * for the given page.
    10657     *
    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.
    11161     */
    11262    public function add_template_column( $page_columns ) {
    11363
    114         $page_columns['template'] = __( 'Page Template', $this->locale );
    115 
     64        $page_columns['template'] = __( 'Page Template', 'page-template-dashboard-locale' );
    11665        return $page_columns;
    117 
    118     } // end add_template_column
    119 
    120     /*--------------------------------------------*
    121      * Actions
    122      *--------------------------------------------*/
     66    }
    12367
    12468    /**
     
    12670     * template is used, but will use the friendly name of the template if one is applied.
    12771     *
    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.
    13173     */
    132      public function add_template_data( $column_name ) {
     74    public function add_template_data( $column_name ) {
    13375
    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.
    13582        global $post;
    13683
    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;
    13987
    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 );
    14297
    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  
    66 *
    77 * @package   PTD
    8  * @author    Your Name <email@example.com>
     8 * @author    Tom McFarlin <tom@tommcfarlin.com>
    99 * @license   GPL-2.0+
    10  * @link      http://tommcfarlin.com/page-template-dashboard/
    11  * @copyright 2013 - 2015 Tom McFarlin
     10 * @link      https://tommcfarlin.com/page-template-dashboard/
     11 * @copyright 2013 - 2016 Tom McFarlin
    1212 *
    1313 * @wordpress-plugin
    1414 * Plugin Name: Page Template Dashboard
    15  * Plugin URI:  http://tommcfarlin.com/page-template-dashboard/
     15 * Plugin URI:  https://tommcfarlin.com/page-template-dashboard/
    1616 * Description: An easy way to see which templates your pages are using without having to view the page editor.
    17  * Version:     1.6.0
     17 * Version:     1.7.0
    1818 * Author:      Tom McFarlin
    19  * Author URI:  http://tommcfarlin.com/
     19 * Author URI:  https://tommcfarlin.com/
    2020 * Text Domain: page-template-dashboard-locale
    2121 * License:     GPL-2.0+
     
    2424 */
    2525
    26 // If this file is called directly, abort.
    27 if ( ! defined( 'WPINC' ) ) {
    28     die;
     26defined( 'WPINC' ) || die;
     27
     28include_once 'class-page-template-dashboard.php' ;
     29
     30add_action( 'plugins_loaded', 'ptd_start' );
     31/**
     32 * Starts the plugin.
     33 */
     34function ptd_start() {
     35
     36    $plugin = new Page_Template_Dashboard();
     37    $plugin->init();
    2938}
    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.