PluginProbe
My WP Customize Admin/Frontend / 1.8
My WP Customize Admin/Frontend v1.8
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 1.8, at developer/abstract.developer.module.php

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