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