PluginProbe
My WP Customize Admin/Frontend / 1.1.4
My WP Customize Admin/Frontend v1.1.4
1.27.4 1.27.3 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.10 1.10.1 1.10.2 1.11 1.12 1.12.1 1.12.2 1.13 1.13.1 1.13.2 1.14 1.15.0 1.16 1.17.0 All 76 releases
my-wp / developer / class.developer.php

class.developer.php in My WP Customize Admin/Frontend 1.1.4, at developer/class.developer.php

370 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 if ( ! class_exists( 'MywpDeveloper' ) ) :
8
9 final class MywpDeveloper {
10
11 private static $instance;
12
13 private function __construct() {}
14
15 public static function get_instance() {
16
17 if ( !isset( self::$instance ) ) {
18
19 self::$instance = new self();
20
21 }
22
23 return self::$instance;
24
25 }
26
27 private function __clone() {}
28
29 private function __wakeup() {}
30
31 public static function is_debug() {
32
33 $is_debug = false;
34
35 return apply_filters( 'mywp_is_debug' , $is_debug );
36
37 }
38
39 public static function get_debug_types() {
40
41 $debug_types = array();
42
43 return apply_filters( 'mywp_debug_types' , $debug_types );
44
45 }
46
47 public static function get_debug_renders() {
48
49 $pre_debug_renders = apply_filters( 'mywp_debug_renders' , array() );
50
51 if( empty( $pre_debug_renders ) ) {
52
53 return false;
54
55 }
56
57 $default = array(
58 'debug_type' => 'custom',
59 'title' => '',
60 );
61
62 $debug_renders = array();
63
64 foreach( $pre_debug_renders as $render_id => $render ) {
65
66 $debug_renders[ $render_id ] = wp_parse_args( $render , $default );
67
68 }
69
70 return $debug_renders;
71
72 }
73
74 public static function debug( $include_debug_modules = array() ) {
75
76 do_action( 'mywp_developer_debug' , $include_debug_modules );
77
78 echo "\n\n ----- mywp_developer_debug ----- \n\n";
79
80 }
81
82 public static function debug_die( $include_debug_modules = array() ) {
83
84 self::debug( $include_debug_modules );
85
86 die();
87
88 }
89
90 public static function debug_action( $action = false ) {
91
92 if( $action === false ) {
93
94 $called_text = sprintf( '%s::%s( %s )' , __CLASS__ , __FUNCTION__ , '$action' );
95
96 MywpHelper::error_not_found_message( '$action' , $called_text );
97
98 return false;
99
100 }
101
102 $action = strip_tags( $action );
103
104 printf( 'debug_action = %s' , $action );
105 echo "\n";
106
107 printf( 'has_action = %s' , has_action( $action ) );
108 echo "\n";
109
110 printf( 'did_action = %s' , did_action( $action ) );
111 echo "\n";
112
113 echo 'actions = ' . "\n";
114
115 $filter_to_func = self::get_filter_to_func( $action );
116
117 if( !empty( $filter_to_func ) ) {
118
119 foreach( $filter_to_func as $func ) {
120
121 printf( ' (%d) %s' , $func['priority'] , $func['print_format'] );
122 echo "\n";
123
124 }
125
126 }
127
128 echo "\n\n";
129
130 }
131
132 public static function debug_filter( $filter = false ) {
133
134 if( $filter === false ) {
135
136 $called_text = sprintf( '%s::%s( %s )' , __CLASS__ , __FUNCTION__ , '$filter' );
137
138 MywpHelper::error_not_found_message( '$filter' , $called_text );
139
140 return false;
141
142 }
143
144 $filter = strip_tags( $filter );
145
146 printf( 'debug_filter = %s' , $filter );
147 echo "\n";
148
149 printf( 'has_filter = %s' , has_filter( $filter ) );
150 echo "\n";
151
152 echo 'filters = ' . "\n";
153
154 $filter_to_func = self::get_filter_to_func( $filter );
155
156 if( !empty( $filter_to_func ) ) {
157
158 foreach( $filter_to_func as $func ) {
159
160 printf( ' (%d) %s' , $func['priority'] , $func['print_format'] );
161 echo "\n";
162
163 }
164
165 }
166
167 echo "\n\n";
168
169 }
170
171 public static function get_filter_to_func( $filter_name = fasle ) {
172
173 global $wp_filter;
174
175 if( empty( $filter_name ) ) {
176
177 $called_text = sprintf( '%s::%s( %s )' , __CLASS__ , __FUNCTION__ , '$filter_name' );
178
179 MywpHelper::error_not_found_message( '$filter_name' , $called_text );
180
181 return false;
182
183 }
184
185 $wp_filters = $wp_filter;
186
187 if( empty( $wp_filters[ $filter_name ] ) ) {
188
189 return false;
190
191 }
192
193 $filter_to_func = array();
194
195 $defaults = array(
196 'priority' => false,
197 'function' => false,
198 'class' => false,
199 'static' => false,
200 'print_format' => false,
201 );
202
203 foreach( $wp_filters[ $filter_name ] as $priority => $filters ) {
204
205 foreach( $filters as $filter_name => $filter_array ) {
206
207 if( is_null( $filter_array['function'] ) ) {
208
209 continue;
210
211 }
212
213 $filter_function = $defaults;
214
215 $filter_function['priority'] = $priority;
216
217 $print_format = '';
218
219 if( is_array( $filter_array['function'] ) ) {
220
221 $filter_function['function'] = $filter_array['function'][1];
222
223 if( is_object( $filter_array['function'][0] ) ) {
224
225 $filter_function['class'] = get_class( $filter_array['function'][0] );
226 $print_format = sprintf( 'class %s -> %s()' , $filter_function['class'] , $filter_function['function'] );
227
228 } else {
229
230 $filter_function['class'] = $filter_array['function'][0];
231 $filter_function['static'] = 1;
232 $print_format = sprintf( 'class %s :: %s()' , $filter_function['class'] , $filter_function['function'] );
233
234 }
235
236 } else {
237
238 $filter_function['function'] = $filter_array['function'];
239 $print_format = sprintf( '%s()' , $filter_function['function'] );
240
241 }
242
243 $filter_function['print_format'] = $print_format;
244
245 $filter_to_func[] = $filter_function;
246
247 }
248
249 }
250
251 return $filter_to_func;
252
253 }
254
255 public static function get_current_filter() {
256
257 $filter = current_filter();
258
259 if( empty( $filter ) ) {
260
261 $called_text = sprintf( '%s::%s()' , __CLASS__ );
262
263 MywpHelper::error_not_found_message( 'filter' , $called_text );
264
265 return false;
266
267 }
268
269 return $filter;
270
271 }
272
273 public static function exists_function( $functions = false ) {
274
275 if( empty( $functions ) ) {
276
277 $called_text = sprintf( '%s::%s( %s )' , __CLASS__ , __FUNCTION__ , '$functions' );
278
279 MywpHelper::error_not_found_message( '$functions' , $called_text );
280
281 return false;
282
283 }
284
285 if( is_array( $functions ) ) {
286
287 foreach( $functions as $function_name ) {
288
289 self::exists_function( $function_name );
290
291 }
292
293 } else {
294
295 $exists = false;
296
297 if( function_exists( $functions ) ) {
298
299 $exists = true;
300
301 }
302
303 printf( '%s: %s' , $functions , $exists );
304 echo "\n";
305
306 }
307
308 }
309
310 public static function exists_define( $defines = false ) {
311
312 if( empty( $defines ) ) {
313
314 $called_text = sprintf( '%s::%s( %s )' , __CLASS__ , __FUNCTION__ , '$defines' );
315
316 MywpHelper::error_not_found_message( '$defines' , $called_text );
317
318 return false;
319
320 }
321
322 if( is_array( $defines ) ) {
323
324 foreach( $defines as $define_name ) {
325
326 self::exists_define( $define_name );
327
328 }
329
330 } else {
331
332 $exists = false;
333
334 if( defined( $defines ) ) {
335
336 $exists = true;
337
338 }
339
340 printf( '%s: %s' , $defines , $exists );
341 echo "\n";
342
343 }
344
345 }
346
347 public static function get_process() {
348
349 $load_avg = false;
350
351 if( function_exists( 'sys_getloadavg' ) ) {
352
353 $sys_getloadavg = sys_getloadavg();
354
355 if( isset( $sys_getloadavg[0] ) ) {
356
357 $load_avg = $sys_getloadavg[0];
358
359 }
360
361 }
362
363 return array( 'microtime' => microtime( true ) , 'memory_get_usage' => memory_get_usage() , 'load_avg' => $load_avg );
364
365 }
366
367 }
368
369 endif;
370