PluginProbe
My WP Customize Admin/Frontend / trunk
My WP Customize Admin/Frontend vtrunk
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 / abstract.developer.module.php

abstract.developer.module.php in My WP Customize Admin/Frontend trunk, at developer/abstract.developer.module.php

167 lines 3.0 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( 'MywpDeveloperAbstractModule' ) ) :
8
9 abstract class MywpDeveloperAbstractModule {
10
11 static protected $id = '';
12
13 static protected $priority = 10;
14
15 public static function init() {
16
17 $class = get_called_class();
18
19 if( empty( static::$id ) ) {
20
21 $called_text = sprintf( 'class %s' , $class );
22
23 MywpHelper::error_require_message( '"static protected $id"' , $called_text );
24
25 return false;
26
27 }
28
29 add_filter( 'mywp_debug_types' , array( $class , 'mywp_debug_types' ) , static::$priority );
30
31 add_filter( 'mywp_debug_renders' , array( $class , 'mywp_debug_renders' ) , static::$priority );
32
33 add_action( 'mywp_debug_render' , array( $class , 'pre_mywp_debug_render' ) , static::$priority );
34
35 add_action( 'mywp_developer_debug' , array( $class , 'pre_mywp_developer_debug' ) , static::$priority );
36
37 add_action( 'mywp_debug_render_footer' , array( $class , 'mywp_debug_render_footer' ) , static::$priority );
38
39 static::after_init();
40
41 }
42
43 protected static function after_init() {}
44
45 public static function mywp_debug_types( $debug_types ) {
46
47 return $debug_types;
48
49 }
50
51 public static function mywp_debug_renders( $debug_renders ) {
52
53 return $debug_renders;
54
55 }
56
57 public static function pre_mywp_debug_render( $render_id ) {
58
59 if( $render_id !== static::$id ) {
60
61 return false;
62
63 }
64
65 static::mywp_debug_render();
66
67 }
68
69 protected static function mywp_debug_render() {
70
71 $debug_lists = static::get_debug_lists();
72
73 if( empty( $debug_lists ) ) {
74
75 return false;
76
77 }
78
79 echo '<table class="debug-table">';
80
81 foreach( $debug_lists as $key => $val ) {
82
83 echo '<tr>';
84
85 printf( '<th>%s</th>' , esc_html( $key ) );
86
87 echo '<td>';
88
89 if( is_array( $val ) or is_object( $val ) ) {
90
91 printf( '<textarea readonly="readonly">%s</textarea>' , esc_textarea( print_r( $val , true ) ) );
92
93 } else {
94
95 echo esc_html( $val );
96
97 }
98
99 echo '</td>';
100
101 echo '</tr>';
102
103 }
104
105 echo '</table>';
106
107 }
108
109 public static function pre_mywp_developer_debug( $include_debug_modules ) {
110
111 if( ! empty( $include_debug_modules ) ) {
112
113 if( ! in_array( static::$id , $include_debug_modules ) ) {
114
115 return false;
116
117 }
118
119 }
120
121 printf( '--- mywp developer debug render: %s ---' , esc_html( static::$id ) );
122
123 echo "\n";
124
125 static::mywp_developer_debug();
126
127 echo "\n";
128
129 }
130
131 protected static function mywp_developer_debug() {
132
133 $debug_lists = static::get_debug_lists();
134
135 if( empty( $debug_lists ) ) {
136
137 return false;
138
139 }
140
141 foreach( $debug_lists as $key => $val ) {
142
143 echo esc_html( $key ) . ' = ';
144
145 if( is_array( $val ) or is_object( $val ) ) {
146
147 echo esc_html( print_r( $val , true ) );
148
149 } else {
150
151 echo esc_html( $val );
152
153 }
154 echo "\n";
155
156 }
157
158 }
159
160 protected static function get_debug_lists() {}
161
162 public static function mywp_debug_render_footer() {}
163
164 }
165
166 endif;
167