PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.8.8.9
Advanced Custom Fields: Extended v0.8.8.9
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 / module.php
acf-extended / includes / modules Last commit date
author.php 3 years ago autosync.php 3 years ago block-types.php 3 years ago dev-clean-meta.php 3 years ago dev-delete-meta.php 3 years ago dev.php 3 years ago forms-action-custom.php 3 years ago forms-action-email.php 3 years ago forms-action-post.php 3 years ago forms-action-redirect.php 3 years ago forms-action-term.php 3 years ago forms-action-user.php 3 years ago forms-cheatsheet.php 3 years ago forms-front.php 3 years ago forms-helpers.php 3 years ago forms-hooks.php 3 years ago forms-shortcode.php 3 years ago forms.php 3 years ago module.php 3 years ago options-pages.php 3 years ago options.class.php 3 years ago options.php 3 years ago post-types.php 3 years ago single-meta.php 3 years ago taxonomies.php 3 years ago ui-attachment.php 3 years ago ui-settings.php 3 years ago ui-term.php 3 years ago ui-user.php 3 years ago ui.php 3 years ago
module.php
560 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_dynamic_module')):
8
9 class acfe_dynamic_module{
10
11 // vars
12 public $name = '',
13 $active = false,
14 $settings = '',
15 $post_type = '',
16 $label = '',
17 $textdomain = '',
18 $tool = '',
19 $columns = array(),
20 $tools = array();
21
22 /*
23 * Construct
24 */
25 function __construct(){
26
27 $this->initialize();
28
29 if(!$this->active) return;
30
31 $this->actions();
32 $this->add_local_field_group();
33
34 add_action('init', array($this, 'init'));
35 add_action('current_screen', array($this, '_current_screen'));
36
37 add_action('acf/save_post', array($this, '_save_post'), 20);
38 add_action('trashed_post', array($this, '_trashed_post'));
39 add_action('untrashed_post', array($this, '_untrashed_post'));
40 add_filter('acf/get_post_types', array($this, 'get_post_types'), 10, 2);
41
42 }
43
44 /*
45 * Initialize
46 */
47 function initialize(){
48 // ...
49 }
50
51 /*
52 * Init
53 */
54 function actions(){
55 // ...
56 }
57
58 /*
59 * Get Name
60 */
61 function get_name($post_id){
62 return false;
63 }
64
65 /*
66 * Init
67 */
68 function init(){
69 // ...
70 }
71
72 /*
73 * Current Screen
74 */
75 function _current_screen(){
76
77 $this->current_screen();
78
79 // Single
80 if(acf_is_screen($this->post_type)){
81
82 remove_meta_box('slugdiv', $this->post_type, 'normal');
83
84 add_action('admin_enqueue_scripts', array($this, '_post_head'));
85 add_filter('admin_body_class', array($this, 'post_body_class'));
86 add_action('post_submitbox_misc_actions', array($this, '_post_submitbox_misc_actions'));
87 add_filter('enter_title_here', array($this, 'post_enter_title_here'), 10, 2);
88 add_action('admin_footer', array($this, '_post_footer'));
89 add_action('load-post.php', array($this, 'post_load'));
90 add_action('load-post-new.php', array($this, 'post_new_load'));
91 add_filter('submenu_file', array($this, 'submenu_file'));
92 add_filter('acfe/localize_data', array($this, 'post_localize_data'));
93
94 $this->post_screen();
95
96 // List
97 }elseif(acf_is_screen("edit-{$this->post_type}")){
98
99 global $wp_post_statuses;
100 $wp_post_statuses['publish']->label_count = _n_noop( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', 'acf' );
101
102 add_action('admin_enqueue_scripts', array($this, '_edit_head'));
103 add_filter('admin_body_class', array($this, 'edit_body_class'));
104 add_filter("manage_edit-{$this->post_type}_columns", array($this, '_edit_columns'));
105 add_action("manage_{$this->post_type}_posts_custom_column", array($this, 'edit_columns_html'), 10, 2);
106 add_filter('display_post_states', array($this, 'display_post_states'), 10, 2);
107 add_filter('post_row_actions', array($this, '_edit_row_actions'), 10, 2);
108 add_filter('page_row_actions', array($this, '_edit_row_actions'), 10, 2);
109 add_action('admin_footer', array($this, 'edit_footer'));
110 add_action('load-edit.php', array($this, 'edit_load'));
111 add_filter("bulk_actions-edit-{$this->post_type}", array($this, 'bulk_actions'));
112 add_filter("handle_bulk_actions-edit-{$this->post_type}", array($this, 'handle_bulk_actions'), 10, 3);
113 add_filter('acfe/localize_data', array($this, 'edit_localize_data'));
114
115 $this->edit_screen();
116
117 }
118
119 }
120
121 function post_body_class($classes){
122
123 $classes .= " acfe-module acfe-module-post acfe-module-{$this->name}";
124 return $classes;
125
126 }
127
128 function edit_body_class($classes){
129
130 $classes .= " acfe-module acfe-module-posts acfe-module-{$this->name}";
131 return $classes;
132
133 }
134
135 function post_localize_data($data){
136
137 $data['module'] = array(
138 'name' => $this->name,
139 'screen' => 'post',
140 );
141
142 return $data;
143
144 }
145
146 function edit_localize_data($data){
147
148 $data['module'] = array(
149 'name' => $this->name,
150 'screen' => 'posts',
151 );
152
153 return $data;
154
155 }
156
157 function current_screen(){
158 // ...
159 }
160
161 function post_screen(){
162 // ...
163 }
164
165 function post_load(){
166 // ...
167 }
168
169 function post_new_load(){
170 // ...
171 }
172
173 function submenu_file($submenu_file){
174 return "edit.php?post_type={$this->post_type}";
175 }
176
177 function edit_screen(){
178 // ...
179 }
180
181 function edit_load(){
182 // ...
183 }
184
185 function bulk_actions($actions){
186
187 acfe_unset($actions, 'edit');
188
189 foreach($this->tools as $action){
190
191 $action_name = $action === 'php' ? 'PHP' : 'Json';
192 $actions["export_{$action}"] = __('Export ', 'acf') . $action_name;
193
194 }
195
196 return $actions;
197
198 }
199
200 function handle_bulk_actions($redirect, $action, $post_ids){
201
202 $post_ids = acfe_maybe_get_REQUEST('post');
203
204 if(!$post_ids){
205 return $redirect;
206 }
207
208 foreach($this->tools as $tool_action){
209
210 if($action !== "export_{$tool_action}") continue;
211
212 $keys = array();
213 foreach($post_ids as $post_id){
214
215 $name = $this->get_name($post_id);
216
217 if(!$name) continue;
218
219 $keys[] = $name;
220
221 }
222
223 $keys = implode('+', $keys);
224 $url = admin_url("edit.php?post_type=acf-field-group&page=acf-tools&tool={$this->tool}&action={$tool_action}&keys={$keys}");
225
226 wp_redirect($url);
227 exit;
228
229 }
230
231 return $redirect;
232
233 }
234
235 /*
236 * Post Head
237 */
238 function _post_head(){
239
240 // no autosave
241 wp_dequeue_script('autosave');
242
243 $this->post_head();
244
245 }
246
247 function post_head(){
248 // ...
249 }
250
251 /*
252 * Post Submit Box
253 */
254 function _post_submitbox_misc_actions($post){
255
256 $status = $post->post_status === 'publish' || $post->post_status === 'auto-draft' ? __("Active",'acf') : __("Inactive",'acf');
257 $name = $this->get_name($post->ID);
258
259 $tools = array();
260
261 foreach($this->tools as $action){
262
263 $action_name = $action === 'php' ? 'PHP' : 'Json';
264 $tools[] = '<a href="' . admin_url("edit.php?post_type=acf-field-group&page=acf-tools&tool={$this->tool}&action={$action}&keys={$name}") . '">' . $action_name . '</a>';
265
266 }
267
268 if($tools){ ?>
269 <div class="misc-pub-section acfe-misc-export">
270 <span class="dashicons dashicons-editor-code"></span>
271 Export: <?php echo implode(' ', $tools); ?>
272 </div>
273 <?php } ?>
274 <script type="text/javascript">
275 (function($) {
276 $('#post-status-display').html('<?php echo $status; ?>');
277 <?php if($tools){ ?>$('.acfe-misc-export').insertAfter('.misc-pub-post-status');<?php } ?>
278 })(jQuery);
279 </script>
280 <?php
281
282 $this->post_submitbox_misc_actions($post);
283
284 }
285
286 function post_submitbox_misc_actions($post){
287 // ...
288 }
289
290 /*
291 * Post Enter Title Here
292 */
293 function post_enter_title_here($placeholder, $post){
294 return $this->label;
295 }
296
297 /*
298 * Post Footer
299 */
300 function _post_footer(){
301
302 ?>
303 <script type="text/javascript">
304 (function($){
305
306 $('#post').submit(function(e){
307
308 // vars
309 var $title = $('#titlewrap #title');
310
311 // empty
312 if($title.val()) return;
313
314 e.preventDefault();
315
316 alert('<?php echo $this->label; ?> is required.');
317
318 $title.focus();
319 });
320
321 })(jQuery);
322 </script>
323 <?php
324
325 $this->post_footer();
326
327 }
328
329 function post_footer(){
330 // ...
331 }
332
333 function _edit_head(){
334
335 // enqueue acf global js for tooltips
336 acf_enqueue_script('acf');
337 }
338
339 /*
340 * Edit Columns
341 */
342 function _edit_columns($columns){
343
344 if(empty($this->columns)){
345 return $columns;
346 }
347
348 $columns = array_merge(array('cb' => $columns['cb'], 'title' => $columns['title']), $this->columns);
349
350 return $this->edit_columns($columns);
351
352 }
353
354 function edit_columns($columns){
355 return $columns;
356 }
357
358 /*
359 * Edit Columns HTML
360 */
361 function edit_columns_html($column, $post_id){
362 // ...
363 }
364
365 /*
366 * Display Post States
367 */
368 function display_post_states($post_states, $post){
369
370 if($post->post_status === 'acf-disabled'){
371 $post_states['acf-disabled'] = '<span class="dashicons dashicons-hidden acf-js-tooltip" title="' . _x('Disabled', 'post status', 'acf') . '"></span>';
372 }
373
374 return $post_states;
375
376 }
377
378 /*
379 * Edit Row Actions
380 */
381 function _edit_row_actions($actions, $post){
382
383 if(!in_array($post->post_status, array('publish', 'acf-disabled'))){
384 return $actions;
385 }
386
387 $post_id = $post->ID;
388 $name = $this->get_name($post_id);
389
390 acfe_unset($actions, 'inline hide-if-no-js');
391
392 // View
393 $view = $this->edit_row_actions_view($post, $name);
394
395 if($view){
396 $actions['view'] = $view;
397 }
398
399 // Tools
400 foreach($this->tools as $action){
401
402 $action_name = $action === 'php' ? 'PHP' : 'Json';
403 $actions[$action] = '<a href="' . admin_url("edit.php?post_type=acf-field-group&page=acf-tools&tool={$this->tool}&action={$action}&keys={$name}") . '">' . $action_name . '</a>';
404
405 }
406
407 return $this->edit_row_actions($actions, $post);
408
409 }
410
411 function edit_row_actions($actions, $post){
412 return $actions;
413 }
414
415 function edit_row_actions_view($post, $name){
416 return false;
417 }
418
419 /*
420 * Edit Foot
421 */
422 function edit_footer(){
423 // ...
424 }
425
426 /*
427 * ACF Save post
428 */
429 function _save_post($post_id){
430
431 if(!is_numeric($post_id) || get_post_type($post_id) !== $this->post_type){
432 return;
433 }
434
435 $this->save_post($post_id);
436
437 }
438
439 function save_post($post_id){
440 // ...
441 }
442
443 /*
444 * Trashed Post Type
445 */
446 function _trashed_post($post_id){
447
448 if(get_post_type($post_id) !== $this->post_type){
449 return;
450 }
451
452 $this->trashed_post($post_id);
453
454 }
455
456 function trashed_post($post_id){
457 // ...
458 }
459
460 /*
461 * Untrashed Post Type
462 */
463 function _untrashed_post($post_id){
464
465 if(get_post_type($post_id) !== $this->post_type){
466 return;
467 }
468
469 $this->_save_post($post_id);
470 $this->untrashed_post($post_id);
471
472 }
473
474 function untrashed_post($post_id){
475 // ...
476 }
477
478 /*
479 * Import
480 */
481 function import($name, $args){
482 // ...
483 }
484
485 /*
486 * Export
487 */
488 function export_choices(){
489 return array();
490 }
491
492 function export_data($name){
493 // ...
494 }
495
496 function export_php($data){
497 return false;
498 }
499
500 /*
501 * Reset
502 */
503 function reset(){
504 // ...
505 }
506
507 /*
508 * Exclude Post Type
509 */
510 function get_post_types($post_types, $args){
511
512 foreach($post_types as $k => $post_type){
513
514 if($post_type !== $this->post_type) continue;
515
516 unset($post_types[$k]);
517
518 }
519
520 return $post_types;
521
522 }
523
524 /*
525 * Get Field Labels Recursive
526 */
527 function get_fields_labels_recursive(&$array, $field){
528
529 $label = '';
530
531 $ancestors = isset($field['ancestors']) ? $field['ancestors'] : count(acf_get_field_ancestors($field));
532 $label = str_repeat('- ', $ancestors) . $label;
533
534 $label .= !empty($field['label']) ? $field['label'] : '(' . __('no label', 'acf') . ')';
535 $label .= $field['required'] ? ' <span class="acf-required">*</span>' : '';
536
537 $array[$field['key']] = $label;
538
539 if(isset($field['sub_fields']) && !empty($field['sub_fields'])){
540
541 foreach($field['sub_fields'] as $s_field){
542
543 $this->get_fields_labels_recursive($array, $s_field);
544
545 }
546
547 }
548
549 }
550
551 /*
552 * Add Local Field Group
553 */
554 function add_local_field_group(){
555 // ...
556 }
557
558 }
559
560 endif;