PluginProbe
My WP Customize Admin/Frontend / 1.3.2
My WP Customize Admin/Frontend v1.3.2
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.3.2, at developer/class.developer.php

375 lines 7.1 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_func_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 / Object] %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 / Object] %s :: %s()' , $filter_function['class'] , $filter_function['function'] );
233
234 }
235
236 } elseif( is_object( $filter_array['function'] ) ) {
237
238 $filter_function['class'] = get_class( $filter_array['function'] );
239 $print_format = sprintf( '[Class / Object] %s' , print_r( $filter_array['function'] , true ) );
240
241 } else {
242
243 $filter_function['function'] = $filter_array['function'];
244 $print_format = sprintf( '%s()' , $filter_function['function'] );
245
246 }
247
248 $filter_function['print_format'] = $print_format;
249
250 $filter_to_func[] = $filter_function;
251
252 }
253
254 }
255
256 return $filter_to_func;
257
258 }
259
260 public static function get_current_filter() {
261
262 $filter = current_filter();
263
264 if( empty( $filter ) ) {
265
266 $called_text = sprintf( '%s::%s()' , __CLASS__ );
267
268 MywpHelper::error_not_found_message( 'filter' , $called_text );
269
270 return false;
271
272 }
273
274 return $filter;
275
276 }
277
278 public static function exists_function( $functions = false ) {
279
280 if( empty( $functions ) ) {
281
282 $called_text = sprintf( '%s::%s( %s )' , __CLASS__ , __FUNCTION__ , '$functions' );
283
284 MywpHelper::error_not_found_message( '$functions' , $called_text );
285
286 return false;
287
288 }
289
290 if( is_array( $functions ) ) {
291
292 foreach( $functions as $function_name ) {
293
294 self::exists_function( $function_name );
295
296 }
297
298 } else {
299
300 $exists = false;
301
302 if( function_exists( $functions ) ) {
303
304 $exists = true;
305
306 }
307
308 printf( '%s: %s' , $functions , $exists );
309 echo "\n";
310
311 }
312
313 }
314
315 public static function exists_define( $defines = false ) {
316
317 if( empty( $defines ) ) {
318
319 $called_text = sprintf( '%s::%s( %s )' , __CLASS__ , __FUNCTION__ , '$defines' );
320
321 MywpHelper::error_not_found_message( '$defines' , $called_text );
322
323 return false;
324
325 }
326
327 if( is_array( $defines ) ) {
328
329 foreach( $defines as $define_name ) {
330
331 self::exists_define( $define_name );
332
333 }
334
335 } else {
336
337 $exists = false;
338
339 if( defined( $defines ) ) {
340
341 $exists = true;
342
343 }
344
345 printf( '%s: %s' , $defines , $exists );
346 echo "\n";
347
348 }
349
350 }
351
352 public static function get_process() {
353
354 $load_avg = false;
355
356 if( function_exists( 'sys_getloadavg' ) ) {
357
358 $sys_getloadavg = sys_getloadavg();
359
360 if( isset( $sys_getloadavg[0] ) ) {
361
362 $load_avg = $sys_getloadavg[0];
363
364 }
365
366 }
367
368 return array( 'microtime' => microtime( true ) , 'memory_get_usage' => memory_get_usage() , 'load_avg' => $load_avg );
369
370 }
371
372 }
373
374 endif;
375