PluginProbe
QuadMenu – Mega Menu / 1.8.8
QuadMenu – Mega Menu v1.8.8
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / lib / ReduxCore / inc / themecheck / class.redux_themecheck.php

class.redux_themecheck.php in QuadMenu – Mega Menu 1.8.8, at lib/ReduxCore/inc/themecheck/class.redux_themecheck.php

227 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Redux ThemeCheck
4 *
5 * @package ReduxFramework
6 * @author Dovy <[email protected]>
7 * @license GPL-3.0+
8 * @link http://redux.op
9 * @copyright 2015 ReduxFramework
10 */
11
12 /**
13 * Redux-ThemeCheck class
14 *
15 * @package Redux_ThemeCheck
16 * @author Dovy <[email protected]>
17 */
18 // Don't duplicate me!
19 if ( ! class_exists( 'Redux_ThemeCheck' ) ) {
20 class Redux_ThemeCheck {
21
22 /**
23 * Plugin version, used for cache-busting of style and script file references.
24 *
25 * @since 1.0.0
26 * @var string
27 */
28 protected $version = '1.0.0';
29
30 /**
31 * Instance of this class.
32 *
33 * @since 1.0.0
34 * @var object
35 */
36 protected static $instance = null;
37
38 /**
39 * Instance of the Redux class.
40 *
41 * @since 1.0.0
42 * @var object
43 */
44 protected static $redux = null;
45
46 /**
47 * Details of the embedded Redux class.
48 *
49 * @since 1.0.0
50 * @var object
51 */
52 protected static $redux_details = null;
53
54 /**
55 * Slug for various elements.
56 *
57 * @since 1.0.0
58 * @var string
59 */
60 protected $slug = 'redux_themecheck';
61
62 /**
63 * Initialize the plugin by setting localization, filters, and administration functions.
64 *
65 * @since 1.0.0
66 */
67 private function __construct() {
68
69 if ( ! class_exists( 'ThemeCheckMain' ) ) {
70 return;
71 }
72
73 // Load admin style sheet and JavaScript.
74 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
75 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
76
77 add_action( 'themecheck_checks_loaded', array( $this, 'disable_checks' ) );
78 add_action( 'themecheck_checks_loaded', array( $this, 'add_checks' ) );
79
80 }
81
82 /**
83 * Return an instance of this class.
84 *
85 * @since 1.0.0
86 * @return object A single instance of this class.
87 */
88 public static function get_instance() {
89
90 // If the single instance hasn't been set, set it now.
91 if ( null == self::$instance ) {
92 self::$instance = new self;
93 }
94
95 return self::$instance;
96 }
97
98 /**
99 * Return an instance of this class.
100 *
101 * @since 1.0.0
102 * @return object A single instance of this class.
103 */
104 public static function get_redux_instance() {
105
106 // If the single instance hasn't been set, set it now.
107 if ( null == self::$redux && ReduxFramework::$_as_plugin ) {
108 self::$redux = new ReduxFramework();
109 self::$redux->init();
110 }
111
112 return self::$redux;
113 }
114
115 /**
116 * Return the Redux path info, if had.
117 *
118 * @since 1.0.0
119 * @return object A single instance of this class.
120 */
121 public static function get_redux_details( $php_files = array() ) {
122 if ( self::$redux_details === null ) {
123 foreach ( $php_files as $php_key => $phpfile ) {
124 if ( strpos( $phpfile, 'class' . ' ReduxFramework {' ) !== false ) {
125 self::$redux_details = array(
126 'filename' => strtolower( basename( $php_key ) ),
127 'path' => $php_key,
128 );
129 self::$redux_details['dir'] = str_replace( basename( $php_key ), '', $php_key );
130 self::$redux_details['parent_dir'] = str_replace( basename( self::$redux_details['dir'] ) . '/', '', self::$redux_details['dir'] );
131 }
132 }
133 }
134 if ( self::$redux_details === null ) {
135 self::$redux_details = false;
136 }
137
138 return self::$redux_details;
139 }
140
141 /**
142 * Disable Theme-Check checks that aren't relevant for ThemeForest themes
143 *
144 * @since 1.0.0
145 */
146 function disable_checks() {
147 global $themechecks;
148
149 //$checks_to_disable = array(
150 // 'IncludeCheck',
151 // 'I18NCheck',
152 // 'AdminMenu',
153 // 'Bad_Checks',
154 // 'MalwareCheck',
155 // 'Theme_Support',
156 // 'CustomCheck',
157 // 'EditorStyleCheck',
158 // 'IframeCheck',
159 //);
160 //
161 //foreach ( $themechecks as $keyindex => $check ) {
162 // if ( $check instanceof themecheck ) {
163 // $check_class = get_class( $check );
164 // if ( in_array( $check_class, $checks_to_disable ) ) {
165 // unset( $themechecks[$keyindex] );
166 // }
167 // }
168 //}
169 }
170
171 /**
172 * Disable Theme-Check checks that aren't relevant for ThemeForest themes
173 *
174 * @since 1.0.0
175 */
176 function add_checks() {
177 global $themechecks;
178
179 // load all the checks in the checks directory
180 $dir = 'checks';
181 foreach ( glob( dirname( __FILE__ ) . '/' . $dir . '/*.php' ) as $file ) {
182 require_once $file;
183 }
184 }
185
186 /**
187 * Register and enqueue admin-specific style sheet.
188 *
189 * @since 1.0.1
190 */
191 public function enqueue_admin_styles() {
192 $screen = get_current_screen();
193 if ( 'appearance_page_themecheck' == $screen->id ) {
194 wp_enqueue_style( $this->slug . '-admin-styles', ReduxFramework::$_url . 'inc/themecheck/css/admin.css', array(), $this->version );
195 }
196 }
197
198 /**
199 * Register and enqueue admin-specific JavaScript.
200 *
201 * @since 1.0.1
202 */
203 public function enqueue_admin_scripts() {
204
205 $screen = get_current_screen();
206
207 if ( 'appearance_page_themecheck' == $screen->id ) {
208 wp_enqueue_script( $this->slug . '-admin-script', ReduxFramework::$_url . 'inc/themecheck/js/admin.js', array( 'jquery' ), $this->version );
209
210 if ( ! isset( $_POST['themename'] ) ) {
211
212 $intro = '';
213 $intro .= '<h2>Redux Theme-Check</h2>';
214 $intro .= '<p>Extra checks for Redux to ensure you\'re ready for marketplace submission to marketplaces.</p>';
215
216 $redux_check_intro['text'] = $intro;
217
218 wp_localize_script( $this->slug . '-admin-script', 'redux_check_intro', $redux_check_intro );
219
220 }
221 }
222
223 }
224 }
225
226 Redux_ThemeCheck::get_instance();
227 }