PluginProbe
QuadMenu – Mega Menu / 3.3.8
QuadMenu – Mega Menu v3.3.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 / redux / ReduxCore / inc / themecheck / class.redux_themecheck.php

class.redux_themecheck.php in QuadMenu – Mega Menu 3.3.8, at redux/ReduxCore/inc/themecheck/class.redux_themecheck.php

226 lines 5.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 ReduxFrameworkLegacy
6 * @author Dovy <[email protected]>
7 * @license GPL-3.0+
8 * @link http://redux.op
9 * @copyright 2015 ReduxFrameworkLegacy
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( 'ReduxLegacy_ThemeCheck' ) ) {
20 class ReduxLegacy_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 * Return an instance of this class.
83 *
84 * @since 1.0.0
85 * @return object A single instance of this class.
86 */
87 public static function get_instance() {
88
89 // If the single instance hasn't been set, set it now.
90 if ( null == self::$instance ) {
91 self::$instance = new self();
92 }
93
94 return self::$instance;
95 }
96
97 /**
98 * Return an instance of this class.
99 *
100 * @since 1.0.0
101 * @return object A single instance of this class.
102 */
103 public static function get_redux_instance() {
104
105 // If the single instance hasn't been set, set it now.
106 if ( null == self::$redux && ReduxFrameworkLegacy::$_as_plugin ) {
107 self::$redux = new ReduxFrameworkLegacy();
108 self::$redux->init();
109 }
110
111 return self::$redux;
112 }
113
114 /**
115 * Return the Redux path info, if had.
116 *
117 * @since 1.0.0
118 * @return object A single instance of this class.
119 */
120 public static function get_redux_details( $php_files = array() ) {
121 if ( self::$redux_details === null ) {
122 foreach ( $php_files as $php_key => $phpfile ) {
123 if ( strpos( $phpfile, 'class' . ' ReduxFrameworkLegacy {' ) !== false ) {
124 self::$redux_details = array(
125 'filename' => strtolower( basename( $php_key ) ),
126 'path' => $php_key,
127 );
128 self::$redux_details['dir'] = str_replace( basename( $php_key ), '', $php_key );
129 self::$redux_details['parent_dir'] = str_replace( basename( self::$redux_details['dir'] ) . '/', '', self::$redux_details['dir'] );
130 }
131 }
132 }
133 if ( self::$redux_details === null ) {
134 self::$redux_details = false;
135 }
136
137 return self::$redux_details;
138 }
139
140 /**
141 * Disable Theme-Check checks that aren't relevant for ThemeForest themes
142 *
143 * @since 1.0.0
144 */
145 function disable_checks() {
146 global $themechecks;
147
148 // $checks_to_disable = array(
149 // 'IncludeCheck',
150 // 'I18NCheck',
151 // 'AdminMenu',
152 // 'Bad_Checks',
153 // 'MalwareCheck',
154 // 'Theme_Support',
155 // 'CustomCheck',
156 // 'EditorStyleCheck',
157 // 'IframeCheck',
158 // );
159 //
160 // foreach ( $themechecks as $keyindex => $check ) {
161 // if ( $check instanceof themecheck ) {
162 // $check_class = get_class( $check );
163 // if ( in_array( $check_class, $checks_to_disable ) ) {
164 // unset( $themechecks[$keyindex] );
165 // }
166 // }
167 // }
168 }
169
170 /**
171 * Disable Theme-Check checks that aren't relevant for ThemeForest themes
172 *
173 * @since 1.0.0
174 */
175 function add_checks() {
176 global $themechecks;
177
178 // load all the checks in the checks directory
179 $dir = 'checks';
180 foreach ( glob( __DIR__ . '/' . $dir . '/*.php' ) as $file ) {
181 require_once $file;
182 }
183 }
184
185 /**
186 * Register and enqueue admin-specific style sheet.
187 *
188 * @since 1.0.1
189 */
190 public function enqueue_admin_styles() {
191 $screen = get_current_screen();
192 if ( 'appearance_page_themecheck' == $screen->id ) {
193 wp_enqueue_style( $this->slug . '-admin-styles', ReduxFrameworkLegacy::$_url . 'inc/themecheck/css/admin.css', array(), $this->version );
194 }
195 }
196
197 /**
198 * Register and enqueue admin-specific JavaScript.
199 *
200 * @since 1.0.1
201 */
202 public function enqueue_admin_scripts() {
203
204 $screen = get_current_screen();
205
206 if ( 'appearance_page_themecheck' == $screen->id ) {
207 wp_enqueue_script( $this->slug . '-admin-script', ReduxFrameworkLegacy::$_url . 'inc/themecheck/js/admin.js', array( 'jquery' ), $this->version );
208
209 if ( ! isset( $_POST['themename'] ) ) {
210
211 $intro = '';
212 $intro .= '<h2>Redux Theme-Check</h2>';
213 $intro .= '<p>Extra checks for Redux to ensure you\'re ready for marketplace submission to marketplaces.</p>';
214
215 $redux_check_intro['text'] = $intro;
216
217 wp_localize_script( $this->slug . '-admin-script', 'redux_check_intro', $redux_check_intro );
218
219 }
220 }
221 }
222 }
223
224 ReduxLegacy_ThemeCheck::get_instance();
225 }
226