| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Child Theme Check |
| 4 |
* Description: This plugin can warn you about old template files in your child theme |
| 5 |
* Version: 1.0.10 |
| 6 |
* Plugin URI: https://github.com/Zodiac1978/tl-template-checker |
| 7 |
* Author: Torsten Landsiedel |
| 8 |
* Author URI: https://torstenlandsiedel.de |
| 9 |
* Text Domain: child-theme-check |
| 10 |
* Domain Path: /languages |
| 11 |
* License: GPLv2 |
| 12 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html |
| 13 |
* GitHub Plugin URI: https://github.com/Zodiac1978/tl-template-checker |
| 14 |
* GitHub Branch: master |
| 15 |
*/ |
| 16 |
|
| 17 |
if ( ! defined( 'ABSPATH' ) ) { |
| 18 |
exit; // Exit if accessed directly. |
| 19 |
} |
| 20 |
|
| 21 |
if ( ! class_exists( 'TLTemplateChecker' ) ) : |
| 22 |
|
| 23 |
/** |
| 24 |
* Main TL-Template-Checker Class |
| 25 |
* |
| 26 |
* @class TLTemplateChecker |
| 27 |
* @version 1.0.0 |
| 28 |
*/ |
| 29 |
final class TLTemplateChecker { |
| 30 |
|
| 31 |
/** |
| 32 |
* @var string |
| 33 |
*/ |
| 34 |
public $version = '1.0.10'; |
| 35 |
|
| 36 |
/** |
| 37 |
* @var TLTemplateChecker|null The single instance of the class |
| 38 |
* @since 1.0.0 |
| 39 |
*/ |
| 40 |
protected static $_instance = null; |
| 41 |
|
| 42 |
/** |
| 43 |
* Main TLTemplateChecker Instance |
| 44 |
* |
| 45 |
* Ensures only one instance of TLTemplateChecker is loaded or can be loaded. |
| 46 |
* |
| 47 |
* @since 1.0.0 |
| 48 |
* @static |
| 49 |
* @return TLTemplateChecker - Main instance |
| 50 |
*/ |
| 51 |
public static function instance() { |
| 52 |
if ( is_null( self::$_instance ) ) { |
| 53 |
self::$_instance = new self(); |
| 54 |
} |
| 55 |
return self::$_instance; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* TLTemplateChecker Constructor. |
| 60 |
*/ |
| 61 |
public function __construct() { |
| 62 |
$this->includes(); |
| 63 |
$this->hooks(); |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Hook into actions and filters |
| 68 |
* |
| 69 |
* @since 1.0.0 |
| 70 |
*/ |
| 71 |
private function hooks() { |
| 72 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) ); |
| 73 |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_settings_link' ) ); |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Include required files used in admin. |
| 78 |
* |
| 79 |
* @since 1.0.0 |
| 80 |
*/ |
| 81 |
public function includes() { |
| 82 |
if ( is_admin() ) { |
| 83 |
include_once 'includes/admin/class-tplc-admin.php'; |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* Load styles in admin. |
| 89 |
* |
| 90 |
* @since 1.0.0 |
| 91 |
*/ |
| 92 |
public function admin_styles() { |
| 93 |
if ( is_admin() ) { |
| 94 |
wp_enqueue_style( 'tplc_admin_styles', plugins_url( '/assets/css/admin.min.css', __FILE__ ), array(), $this->version ); |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
/** |
| 99 |
* Add link on plugin page |
| 100 |
* |
| 101 |
* @param Array $links Array of links for plugin list table view. |
| 102 |
* @return mixed |
| 103 |
* @since 1.0.0 |
| 104 |
*/ |
| 105 |
public function plugin_settings_link( $links ) { |
| 106 |
$settings_link = '<a href="tools.php?page=tplc-status">' . __( 'Status', 'child-theme-check' ) . '</a>'; |
| 107 |
array_unshift( $links, $settings_link ); |
| 108 |
|
| 109 |
return $links; |
| 110 |
} |
| 111 |
|
| 112 |
} |
| 113 |
|
| 114 |
endif; |
| 115 |
|
| 116 |
/** |
| 117 |
* Returns the main instance of TPLC to prevent the need to use globals. |
| 118 |
* |
| 119 |
* @since 1.0.10 |
| 120 |
*/ |
| 121 |
function tplc() { |
| 122 |
return TLTemplateChecker::instance(); |
| 123 |
} |
| 124 |
|
| 125 |
$GLOBALS['tplc_template_checker'] = tplc(); |
| 126 |
|