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