PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.8.3.1
Advanced Custom Fields: Extended v0.8.3.1
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 taxonomy.php 6 years ago
dev.php
341 lines
1 <?php
2
3 if(!defined('ABSPATH'))
4 exit;
5
6 // Check setting
7 if((!acf_get_setting('acfe/dev') && (!defined('ACFE_dev') || !ACFE_dev)) && (!acf_get_setting('acfe/super_dev') && (!defined('ACFE_super_dev') || !ACFE_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 public $is_super_dev = false;
18
19 function __construct(){
20
21 // Script debug
22 if(!defined('SCRIPT_DEBUG'))
23 define('SCRIPT_DEBUG', true);
24
25 if(acf_get_setting('acfe/super_dev', false) || (defined('ACFE_super_dev') && ACFE_super_dev))
26 $this->is_super_dev = true;
27
28 add_action('load-post.php', array($this, 'load_post'));
29 add_action('load-post-new.php', array($this, 'load_post'));
30
31 add_action('load-term.php', array($this, 'load_term'));
32
33 }
34
35 function load_post(){
36
37 global $typenow;
38
39 $post_type = $typenow;
40
41 // Remove WP post meta box
42 remove_meta_box('postcustom', false, 'normal');
43
44 if(!$this->is_super_dev){
45
46 $restricted = array('acfe-dbt', 'acfe-dop', 'acfe-dpt', 'acfe-dt', 'acfe-form');
47
48 if(in_array($post_type, $restricted))
49 return;
50
51 }
52
53 // actions
54 add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 10, 2);
55
56 }
57
58 function load_term(){
59
60 $screen = get_current_screen();
61 $taxonomy = $screen->taxonomy;
62
63 // actions
64 add_action("{$taxonomy}_edit_form", array($this, 'edit_term'), 20, 2);
65
66 }
67
68 function edit_term($term, $taxonomy){
69
70 $post_id = acf_get_term_post_id($term->taxonomy, $term->term_id);
71
72 $this->get_meta($post_id);
73
74 if(!empty($this->wp_meta)){
75
76 add_meta_box('acfe-wp-custom-fields', 'WP Custom fields', array($this, 'wp_render_meta_box'), 'edit-term', 'normal', 'low');
77
78 }
79
80 if(!empty($this->acf_meta)){
81
82 add_meta_box('acfe-acf-custom-fields', 'ACF Custom fields', array($this, 'acf_render_meta_box'), 'edit-term', 'normal', 'low');
83
84 }
85
86 echo '<div id="poststuff">';
87
88 do_meta_boxes('edit-term', 'normal', array());
89
90 echo '</div>';
91
92 }
93
94 function get_meta($post_id = 0){
95
96 if(!$post_id)
97 $post_id = acf_get_valid_post_id();
98
99 if(empty($post_id))
100 return;
101
102 $info = acf_get_post_id_info($post_id);
103
104
105 global $wpdb;
106
107 // Post
108 if($info['type'] === 'post'){
109
110 $get_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d ", $info['id']));
111
112 }
113
114 // Term
115 elseif($info['type'] === 'term'){
116
117 $get_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->termmeta WHERE term_id = %d ", $info['id']));
118
119 }
120
121 usort($get_meta, function($a, $b){
122 return strcmp($a->meta_key, $b->meta_key);
123 });
124
125 if(empty($get_meta))
126 return;
127
128 $wp_meta = array();
129
130 foreach($get_meta as $meta){
131
132 $wp_meta[$meta->meta_key] = $meta->meta_value;
133
134 }
135
136 $acf_meta = array();
137
138 foreach($wp_meta as $key => $value){
139
140 // ACF Meta
141 if(isset($wp_meta["_$key"])){
142
143 $field = false;
144 $field_group = false;
145
146 if(acf_is_field_key($wp_meta["_$key"])){
147
148 $field = acf_get_field($wp_meta["_$key"]);
149 $field_group = acfe_get_field_group_from_field($field);
150
151 }
152
153 $acf_meta[] = array(
154 'key' => "_$key",
155 'value' => $wp_meta["_$key"],
156 'field' => $field,
157 'field_group' => $field_group,
158 );
159
160 $acf_meta[] = array(
161 'key' => $key,
162 'value' => $wp_meta[$key],
163 'field' => $field,
164 'field_group' => $field_group,
165 );
166
167 unset($wp_meta["_$key"]);
168 unset($wp_meta[$key]);
169
170 }
171
172 }
173
174 $this->wp_meta = $wp_meta;
175 $this->acf_meta = $acf_meta;
176
177 }
178
179 function add_meta_boxes($post_type, $post){
180
181 $this->get_meta();
182
183 if(!empty($this->wp_meta)){
184
185 add_meta_box('acfe-wp-custom-fields', '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>', array($this, 'wp_render_meta_box'), $post_type, 'normal', 'low');
186
187 }
188
189 if(!empty($this->acf_meta)){
190
191 add_meta_box('acfe-acf-custom-fields', '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>', array($this, 'acf_render_meta_box'), $post_type, 'normal', 'low');
192
193 }
194
195 }
196
197 function wp_render_meta_box($post, $metabox){
198
199 ?>
200 <table class="wp-list-table widefat fixed striped" style="border:0;">
201
202 <thead>
203 <tr>
204 <th scope="col" style="width:30%;">Name</th>
205 <th scope="col" style="width:auto;">Value</th>
206 </tr>
207 </thead>
208
209 <tbody>
210
211 <?php foreach($this->wp_meta as $meta_key => $meta_value){ ?>
212
213 <?php
214 $value_display = $this->render_meta_value($meta_value);
215 ?>
216
217 <tr>
218 <td><strong><?php echo esc_attr($meta_key); ?></strong></td>
219 <td><?php echo $value_display; ?></td>
220 </tr>
221
222 <?php } ?>
223
224 </tbody>
225
226 </table>
227 <?php
228
229 }
230
231 function acf_render_meta_box($post, $metabox){
232
233 ?>
234 <table class="wp-list-table widefat fixed striped" style="border:0;">
235
236 <thead>
237 <tr>
238 <th scope="col" style="width:30%;">Name</th>
239 <th scope="col" style="width:auto;">Value</th>
240 <th scope="col" style="width:120px;">Field group</a></th>
241 </tr>
242 </thead>
243
244 <tbody>
245
246 <?php foreach($this->acf_meta as $meta){ ?>
247
248 <?php
249 $meta_key = $meta['key'];
250 $value = $meta['value'];
251
252 $field = $meta['field'];
253 $field_group = $meta['field_group'];
254 $field_group_display = '<span style="color:#aaa;">' . __('Unknown', 'acf') . '</span>';
255
256 if($field_group){
257
258 $field_group_display = $field_group['title'];
259
260 if(!empty($field_group['ID'])){
261
262 $post_status = get_post_status($field_group['ID']);
263
264 if($post_status === 'publish')
265 $field_group_display = '<a href="' . admin_url('post.php?post=' . $field_group['ID'] . '&action=edit') . '">' . $field_group['title'] . '</a>';
266
267 }
268
269 }
270
271 $value_display = $this->render_meta_value($meta['value']);
272
273 ?>
274
275 <tr>
276 <td><strong><?php echo esc_attr($meta_key); ?></strong></td>
277 <td><?php echo $value_display; ?></td>
278 <td><?php echo $field_group_display; ?></td>
279 </tr>
280
281 <?php } ?>
282
283 </tbody>
284
285 </table>
286 <?php
287
288 }
289
290 function render_meta_value($value){
291
292 $return = '';
293
294 // Serialized
295 if(is_serialized($value)){
296
297 $return = '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(maybe_unserialize($value), true) . '</pre>';
298 $return .= '<pre style="max-height:200px; overflow:auto; white-space: pre; margin-top:10px;">' . print_r($value, true) . '</pre>';
299
300 }
301
302 // HTML
303 elseif($value != strip_tags($value)){
304
305 $return = '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(htmlentities($value), true) . '</pre>';
306
307 }
308
309 // Json
310 elseif(acfe_is_json($value)){
311
312 $return = '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(json_decode($value), true) . '</pre>';
313 $return .= '<pre style="max-height:200px; overflow:auto; white-space: pre; margin-top:10px;">' . print_r($value, true) . '</pre>';
314
315 }
316
317 // String
318 else{
319
320 $css = '';
321
322 if(empty($value)){
323
324 $css = 'color:#aaa;';
325 $value = '(' . __('empty', 'acf') . ')';
326
327 }
328
329 $return = '<pre style="max-height:200px; overflow:auto; white-space: pre; ' . $css . '">' . print_r($value, true) . '</pre>';
330
331 }
332
333 return $return;
334
335 }
336
337 }
338
339 new acfe_dev();
340
341 endif;