PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.8.5
Advanced Custom Fields: Extended v0.8.5
0.9.2.6 0.9.2.5 0.8.6 0.8.6.1 0.8.6.3 0.8.6.5 0.8.6.6 0.8.6.7 0.8.6.8 0.8.6.9 0.8.7 0.8.7.1 0.8.7.2 0.8.7.3 0.8.7.4 0.8.7.5 0.8.7.6 0.8.8 0.8.8.1 0.8.8.10 0.8.8.11 0.8.8.2 0.8.8.3 0.8.8.4 0.8.8.5 0.8.8.6 0.8.8.7 0.8.8.8 0.8.8.9 0.8.9 0.8.9.1 0.8.9.2 0.8.9.3 0.8.9.4 0.8.9.5 0.9 0.9.0.1 0.9.0.2 0.9.0.3 0.9.0.4 0.9.0.5 0.9.0.6 0.9.0.7 0.9.0.8 0.9.0.9 0.9.1 0.9.1.1 0.9.2 0.9.2.1 0.9.2.2 0.9.2.3 0.9.2.4 trunk 0.5 0.5.1 0.5.2 0.5.2.1 0.5.2.3 0.5.5 0.5.5.1 0.5.8 0.5.8.1 0.6 0.6.0.1 0.6.0.2 0.6.1 0.6.3 0.6.5 0.6.7 0.6.7.2 0.7 0.7.0.3 0.7.5 0.7.5.5 0.7.8 0.7.9 0.7.9.3 0.7.9.4 0.7.9.9.8 0.7.9.9.9 0.8 0.8.1 0.8.2 0.8.3 0.8.3.1 0.8.4 0.8.4.1 0.8.4.5 0.8.4.6 0.8.5 0.8.5.5
acf-extended / includes / modules / dev.php
acf-extended / includes / modules Last commit date
form 6 years ago author.php 6 years ago autosync.php 6 years ago dev.php 6 years ago dynamic-block-type.php 6 years ago dynamic-form.php 6 years ago dynamic-options-page.php 6 years ago dynamic-post-type.php 6 years ago dynamic-taxonomy.php 6 years ago single-meta.php 6 years ago taxonomy.php 6 years ago
dev.php
443 lines
1 <?php
2
3 if(!defined('ABSPATH'))
4 exit;
5
6 // Check setting
7 if(!acfe_is_dev() && !acfe_is_super_dev())
8 return;
9
10 if(!class_exists('acfe_dev')):
11
12 class acfe_dev{
13
14 public $wp_meta = array();
15 public $acf_meta = array();
16
17 function __construct(){
18
19 // Script debug
20 if(!defined('SCRIPT_DEBUG'))
21 define('SCRIPT_DEBUG', true);
22
23 // Post
24 add_action('load-post.php', array($this, 'load_post'));
25 add_action('load-post-new.php', array($this, 'load_post'));
26
27 // Term
28 add_action('load-term.php', array($this, 'load_term'));
29
30 // User
31 add_action('show_user_profile', array($this, 'load_user'));
32 add_action('edit_user_profile', array($this, 'load_user'));
33
34 // Admin
35 add_action('acf/options_page/submitbox_before_major_actions', array($this, 'load_admin'));
36
37 }
38
39 /*
40 * Post
41 */
42 function load_post(){
43
44 global $typenow;
45
46 $post_type = $typenow;
47
48 // Remove WP post meta box
49 remove_meta_box('postcustom', false, 'normal');
50
51 if(!acfe_is_super_dev()){
52
53 $restricted = array('acf-field-group', 'acfe-dbt', 'acfe-dop', 'acfe-dpt', 'acfe-dt', 'acfe-form', 'acfe-template');
54
55 if(in_array($post_type, $restricted))
56 return;
57
58 }
59
60 // actions
61 add_action('add_meta_boxes', array($this, 'add_post_meta_boxes'), 10, 2);
62
63 }
64
65 function add_post_meta_boxes($post_type, $post){
66
67 // Add Meta Boxes
68 $this->add_meta_boxes(0, $post_type);
69
70 }
71
72 /*
73 * Term
74 */
75 function load_term(){
76
77 $screen = get_current_screen();
78 $taxonomy = $screen->taxonomy;
79
80 // actions
81 add_action("{$taxonomy}_edit_form", array($this, 'edit_term'), 20, 2);
82
83 }
84
85 function edit_term($term, $taxonomy){
86
87 // Get Term ID
88 $post_id = acf_get_term_post_id($term->taxonomy, $term->term_id);
89
90 // Add Meta Boxes
91 $this->add_meta_boxes($post_id, 'edit-term');
92
93 // Poststuff
94 echo '<div id="poststuff">';
95
96 do_meta_boxes('edit-term', 'normal', array());
97
98 echo '</div>';
99
100 }
101
102 /*
103 * User
104 */
105 function load_user(){
106
107 // Get User ID
108 global $user_id;
109 $user_id = (int) $user_id;
110
111 if(empty($user_id))
112 return;
113
114 // Add Meta Boxes
115 $this->add_meta_boxes('user_' . $user_id, 'edit-user');
116
117 // Poststuff
118 echo '<div id="poststuff">';
119
120 do_meta_boxes('edit-user', 'normal', array());
121
122 echo '</div>';
123
124 }
125
126 /*
127 * Admin
128 */
129 function load_admin($page){
130
131 $this->add_meta_boxes($page['post_id'], 'acf_options_page');
132
133 }
134
135 /*
136 * Add Meta Boxes
137 */
138 function add_meta_boxes($post_id = 0, $object_type){
139
140 // Get Meta
141 $this->get_meta($post_id);
142
143 // WP Metabox
144 if(!empty($this->wp_meta)){
145
146 $id = 'acfe-wp-custom-fields';
147 $title = 'WP Custom fields <span style="background: #72777c;padding: 1px 5px;border-radius: 4px;color: #fff;margin-left: 3px;font-size: 12px;">' . count($this->wp_meta) . '</span>';
148 $context = 'normal';
149 $priority = 'low';
150
151 add_meta_box($id, $title, array($this, 'wp_render_meta_box'), $object_type, $context, $priority);
152
153 }
154
155 // ACF Metabox
156 if(!empty($this->acf_meta)){
157
158 $id = 'acfe-acf-custom-fields';
159 $title = 'ACF Custom fields <span style="background: #72777c;padding: 1px 5px;border-radius: 4px;color: #fff;margin-left: 3px;font-size: 12px;">' . count($this->acf_meta) . '</span>';
160 $context = 'normal';
161 $priority = 'low';
162
163 add_meta_box($id, $title, array($this, 'acf_render_meta_box'), $object_type, $context, $priority);
164
165 }
166
167 }
168
169 function wp_render_meta_box($post, $metabox){
170
171 ?>
172 <table class="wp-list-table widefat fixed striped" style="border:0;">
173
174 <thead>
175 <tr>
176 <th scope="col" style="width:30%;">Name</th>
177 <th scope="col" style="width:auto;">Value</th>
178 </tr>
179 </thead>
180
181 <tbody>
182
183 <?php foreach($this->wp_meta as $meta_key => $meta_value){ ?>
184
185 <?php
186 $value_display = $this->render_meta_value($meta_value);
187 ?>
188
189 <tr>
190 <td><strong><?php echo esc_attr($meta_key); ?></strong></td>
191 <td><?php echo $value_display; ?></td>
192 </tr>
193
194 <?php } ?>
195
196 </tbody>
197
198 </table>
199 <?php
200
201 }
202
203 function acf_render_meta_box($post, $metabox){
204
205 ?>
206 <table class="wp-list-table widefat fixed striped" style="border:0;">
207
208 <thead>
209 <tr>
210 <th scope="col" style="width:30%;">Name</th>
211 <th scope="col" style="width:auto;">Value</th>
212 <th scope="col" style="width:120px;">Field group</a></th>
213 </tr>
214 </thead>
215
216 <tbody>
217
218 <?php foreach($this->acf_meta as $meta){ ?>
219
220 <?php
221
222 // Field
223 $field = $meta['field'];
224 $meta_key = $meta['key'];
225 $value = $meta['value'];
226
227 // Field Group
228 $field_group_display = __('Local', 'acf');
229 $field_group = $meta['field_group'];
230
231 if($field_group){
232
233 $field_group_display = $field_group['title'];
234
235 if(!empty($field_group['ID'])){
236
237 $post_status = get_post_status($field_group['ID']);
238
239 if($post_status === 'publish' || $post_status === 'acf-disabled'){
240
241 $field_group_display = '<a href="' . admin_url('post.php?post=' . $field_group['ID'] . '&action=edit') . '">' . $field_group['title'] . '</a>';
242
243 }
244
245 }
246
247 }
248
249 $value_display = $this->render_meta_value($meta['value']);
250
251 ?>
252
253 <tr>
254 <td><strong><?php echo esc_attr($meta_key); ?></strong></td>
255 <td><?php echo $value_display; ?></td>
256 <td><?php echo $field_group_display; ?></td>
257 </tr>
258
259 <?php } ?>
260
261 </tbody>
262
263 </table>
264 <?php
265
266 }
267
268 function render_meta_value($value){
269
270 $return = '';
271
272 // Serialized
273 if(is_serialized($value)){
274
275 $return = '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(maybe_unserialize($value), true) . '</pre>';
276 $return .= '<pre style="max-height:200px; overflow:auto; white-space: pre; margin-top:10px;">' . print_r($value, true) . '</pre>';
277
278 }
279
280 // HTML
281 elseif($value != strip_tags($value)){
282
283 $return = '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(htmlentities($value), true) . '</pre>';
284
285 }
286
287 // Json
288 elseif(acfe_is_json($value)){
289
290 $return = '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(json_decode($value), true) . '</pre>';
291 $return .= '<pre style="max-height:200px; overflow:auto; white-space: pre; margin-top:10px;">' . print_r($value, true) . '</pre>';
292
293 }
294
295 // String
296 else{
297
298 $css = '';
299
300 if(empty($value)){
301
302 $css = 'color:#aaa;';
303 $value = '(' . __('empty', 'acf') . ')';
304
305 }
306
307 $return = '<pre style="max-height:200px; overflow:auto; white-space: pre; ' . $css . '">' . print_r($value, true) . '</pre>';
308
309 }
310
311 return $return;
312
313 }
314
315 function get_meta($post_id = 0){
316
317 if(!$post_id)
318 $post_id = acf_get_valid_post_id();
319
320 if(empty($post_id))
321 return;
322
323 $info = acf_get_post_id_info($post_id);
324
325 global $wpdb;
326
327 // Post
328 if($info['type'] === 'post'){
329
330 $get_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d ", $info['id']));
331
332 }
333
334 // Term
335 elseif($info['type'] === 'term'){
336
337 $get_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->termmeta WHERE term_id = %d ", $info['id']));
338
339 }
340
341 // User
342 elseif($info['type'] === 'user'){
343
344 $get_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d ", $info['id']));
345
346 }
347
348 // Option
349 elseif($info['type'] === 'option'){
350
351 $id = $info['id'];
352
353 $search = "{$id}_%";
354 $_search = "_{$id}_%";
355
356 $search = str_replace('_', '\_', $search);
357 $_search = str_replace('_', '\_', $_search);
358
359 $get_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->options WHERE option_name LIKE %s OR option_name LIKE %s", $search, $_search));
360
361 }
362
363 if(empty($get_meta))
364 return;
365
366 $wp_meta = array();
367
368 // Post / Term / User
369 if($info['type'] !== 'option'){
370
371 usort($get_meta, function($a, $b){
372 return strcmp($a->meta_key, $b->meta_key);
373 });
374
375 foreach($get_meta as $meta){
376
377 $wp_meta[$meta->meta_key] = $meta->meta_value;
378
379 }
380
381 // Option
382 }else{
383
384 usort($get_meta, function($a, $b){
385 return strcmp($a->option_name, $b->option_name);
386 });
387
388 foreach($get_meta as $meta){
389
390 $wp_meta[$meta->option_name] = $meta->option_value;
391
392 }
393
394 }
395
396 $acf_meta = array();
397
398 foreach($wp_meta as $key => $value){
399
400 // ACF Meta
401 if(isset($wp_meta["_$key"])){
402
403 $field = false;
404 $field_group = false;
405
406 if(acf_is_field_key($wp_meta["_$key"])){
407
408 $field = acf_get_field($wp_meta["_$key"]);
409 $field_group = acfe_get_field_group_from_field($field);
410
411 }
412
413 $acf_meta[] = array(
414 'key' => "_$key",
415 'value' => $wp_meta["_$key"],
416 'field' => $field,
417 'field_group' => $field_group,
418 );
419
420 $acf_meta[] = array(
421 'key' => $key,
422 'value' => $wp_meta[$key],
423 'field' => $field,
424 'field_group' => $field_group,
425 );
426
427 unset($wp_meta["_$key"]);
428 unset($wp_meta[$key]);
429
430 }
431
432 }
433
434 $this->wp_meta = $wp_meta;
435 $this->acf_meta = $acf_meta;
436
437 }
438
439 }
440
441 new acfe_dev();
442
443 endif;