Version Description
- Module: Dynamic Post Types/Taxonomies/Block Types/Options Pages - Slugs can now to edited & updated from the UI
- Module: Dynamic Options Pages - Added a configuration icon on top of options page to easily switch to options page settings
- Module: Dynamic Forms - User Action query var now returns the password if it has been created/generated during the action. This will allow developers to send the password confirmation via an e-mail action using query vars
- Module: Dynamic Forms - Added
{request:name}
&{request:name:key}
template tags to retrieve$_REQUEST
$_GET
&$_POST
data - Module: Dynamic Forms - Added
{get_option:name}
&{get_option:name:key}
template tags to retrieve an option from database - Module: Dynamic Forms - Enhanced "Post Action" query var which now returns post author data in the
{query_var:my-action:post_author_data:field}
template tag - Module: Dynamic Forms - Enhanced JS detection of the
acf
object to avoid potential errors when using aggressive minification - Module: Dynamic Forms - Fixed
{current:user:show_welcome_panel}
which was printed twice in the "Cheatsheet" tab - Module: Dynamic Forms - Fixed
wp_unslash()
on the success message - Module: Dynamic Forms - Fixed undefined
post
key notice which could occurs in some cases - Module: Dynamic Forms - Fixed template tags which were using
id
instead ofID
- Module: Dynamic Forms - Fixed the conditional logic on custom form render when using complex fields like repeaters or flexible content
- Module: Single Meta Save -
acf
meta is now updated on submission instead of being reset each time it is saved. This fix a potential problem when fields wouldn't be displayed to specific user roles - Module: PHP AutoSync - PHP files are now included only if the filename starts with
group_*.php
- Field: Columns - Added responsive breakpoints
- Field: Button - Added Advanced Settings compatibility
- Field: Advanced Link - Fixed a bug which could render an empty "Archive" default value artifact in post objects fields
- Field: Advanced Link - Fixed required field validation
- Field: Code Editor - Fixed line wrap in terms views
- Field: WYSIWYG - Fixed the automatic smart delayed initialization in flexible content layouts which could break when trying to open a layout before the complete page load
- General: Settings API - Enhanced upgrade process
- General: Settings API -
acfe
option now regenerate Post Types/Taxonomies/Block Types/Options Pages on reset
Download this release
Release Info
Developer | hwk-fr |
Plugin | Advanced Custom Fields: Extended |
Version | 0.8.6 |
Comparing to | |
See all releases |
Code changes from version 0.8.5.5 to 0.8.6
- acf-extended.php +3 -3
- assets/acf-extended-admin.css +36 -28
- assets/acf-extended-fc-control.js +0 -2
- assets/acf-extended-fc-modal-edit.js +0 -2
- assets/acf-extended-fc.css +1 -1
- assets/acf-extended-fc.js +29 -47
- assets/acf-extended-fg.css +4 -0
- assets/acf-extended-form.js +10 -5
- assets/acf-extended.css +24 -0
- assets/acf-extended.js +3 -0
- includes/admin/tools/dbt-import.php +0 -1
- includes/admin/tools/dop-export.php +2 -2
- includes/admin/tools/dop-import.php +5 -7
- includes/admin/tools/dpt-import.php +0 -1
- includes/admin/tools/dt-import.php +0 -1
- includes/core/settings.php +134 -18
- includes/core/upgrades.php +94 -3
- includes/fields-settings/settings.php +1 -1
- includes/fields/field-advanced-link.php +3 -3
- includes/modules/autosync.php +1 -1
- includes/modules/dynamic-block-type.php +126 -94
- includes/modules/dynamic-options-page.php +238 -207
- includes/modules/dynamic-post-type.php +112 -108
- includes/modules/dynamic-taxonomy.php +151 -148
- includes/modules/form/actions/post.php +30 -0
- includes/modules/form/actions/user.php +7 -0
- includes/modules/form/admin.php +246 -110
- includes/modules/form/field-group.php +30 -0
- includes/modules/form/form-front.php +1 -1
- includes/modules/single-meta.php +5 -0
- readme.txt +26 -2
acf-extended.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
* Description: Enhancement Suite which improves Advanced Custom Fields administration
|
5 |
-
* Version: 0.8.
|
6 |
* Author: ACF Extended
|
7 |
* Author URI: https://www.acf-extended.com
|
8 |
* Text Domain: acfe
|
@@ -16,7 +16,7 @@ if(!class_exists('ACFE')):
|
|
16 |
class ACFE{
|
17 |
|
18 |
// Version
|
19 |
-
var $version = '0.8.
|
20 |
|
21 |
// Settings
|
22 |
var $settings = array();
|
@@ -101,8 +101,8 @@ class ACFE{
|
|
101 |
add_action('acf/include_admin_tools', array($this, 'tools'));
|
102 |
|
103 |
// Additional
|
104 |
-
acfe_include('includes/core/settings.php');
|
105 |
acfe_include('includes/core/compatibility.php');
|
|
|
106 |
acfe_include('includes/core/upgrades.php');
|
107 |
|
108 |
}
|
2 |
/**
|
3 |
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
* Description: Enhancement Suite which improves Advanced Custom Fields administration
|
5 |
+
* Version: 0.8.6
|
6 |
* Author: ACF Extended
|
7 |
* Author URI: https://www.acf-extended.com
|
8 |
* Text Domain: acfe
|
16 |
class ACFE{
|
17 |
|
18 |
// Version
|
19 |
+
var $version = '0.8.6';
|
20 |
|
21 |
// Settings
|
22 |
var $settings = array();
|
101 |
add_action('acf/include_admin_tools', array($this, 'tools'));
|
102 |
|
103 |
// Additional
|
|
|
104 |
acfe_include('includes/core/compatibility.php');
|
105 |
+
acfe_include('includes/core/settings.php');
|
106 |
acfe_include('includes/core/upgrades.php');
|
107 |
|
108 |
}
|
assets/acf-extended-admin.css
CHANGED
@@ -207,13 +207,16 @@ html[dir="rtl"] .acfe-postbox-left>.inside>.acf-field>.acf-input {
|
|
207 |
.wrap .acfe-dpt-admin-config,
|
208 |
.wrap .acfe-dpt-admin-config:active,
|
209 |
.wrap .acfe-dt-admin-config,
|
210 |
-
.wrap .acfe-dt-admin-config:active
|
|
|
|
|
211 |
padding-left:4px;
|
212 |
padding-right:4px;
|
213 |
}
|
214 |
|
215 |
.wrap .acfe-dpt-admin-config span,
|
216 |
-
.wrap .acfe-dt-admin-config span
|
|
|
217 |
font-size: 16px;
|
218 |
vertical-align: text-top;
|
219 |
height: 15px;
|
@@ -221,6 +224,11 @@ html[dir="rtl"] .acfe-postbox-left>.inside>.acf-field>.acf-input {
|
|
221 |
line-height: 19px;
|
222 |
}
|
223 |
|
|
|
|
|
|
|
|
|
|
|
224 |
/*
|
225 |
* ACFE: Dynamic Post Type
|
226 |
*/
|
@@ -410,59 +418,59 @@ body.post-type-acfe-form.post-new-php #major-publishing-actions{
|
|
410 |
}
|
411 |
|
412 |
/*
|
413 |
-
*
|
414 |
*/
|
415 |
-
body:not(.acf-admin-5-3) .select2-container .select2-selection{
|
416 |
border-color: #dfdfdf !important;
|
417 |
border-radius:0 !important;
|
418 |
}
|
419 |
|
420 |
-
body:not(.acf-admin-5-3) .select2-container .select2-selection__choice{
|
421 |
border-color: #dfdfdf !important;
|
422 |
border-radius:0 !important;
|
423 |
}
|
424 |
|
425 |
-
body:not(.acf-admin-5-3) .select2-dropdown{
|
426 |
border-color: #dfdfdf !important;
|
427 |
border-radius:0 !important;
|
428 |
}
|
429 |
|
430 |
-
body:not(.acf-admin-5-3) .select2-container .select2-search--inline .select2-search__field{
|
431 |
margin-top:0px !important;
|
432 |
}
|
433 |
|
434 |
/* Select2: Single */
|
435 |
-
.select2-container .select2-selection--single{
|
436 |
border-radius:3px !important;
|
437 |
height:30px !important;
|
438 |
outline:none;
|
439 |
}
|
440 |
|
441 |
-
.select2-container:focus .select2-selection--single,
|
442 |
-
.select2-container.select2-container--open .select2-selection--single{
|
443 |
border-color: #007cba !important;
|
444 |
color: #016087 !important;
|
445 |
box-shadow: 0 0 0 1px #007cba !important;
|
446 |
}
|
447 |
|
448 |
-
.select2-container .select2-selection--single .select2-selection__rendered{
|
449 |
font-size:14px;
|
450 |
height:28px;
|
451 |
line-height: 27px !important;
|
452 |
padding-right:23px !important;
|
453 |
}
|
454 |
|
455 |
-
.select2-container .select2-selection--single .select2-selection__clear{
|
456 |
line-height:26px;
|
457 |
height:28px;
|
458 |
font-size:16px;
|
459 |
}
|
460 |
|
461 |
-
.select2-container--default .select2-selection--single .select2-selection__arrow{
|
462 |
height: 28px !important;
|
463 |
}
|
464 |
|
465 |
-
.select2-container--default .select2-selection--single .select2-selection__arrow b{
|
466 |
background: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%206l5%205%205-5%202%201-7%207-7-7%202-1z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E') no-repeat;
|
467 |
background-size: 16px 16px;
|
468 |
border:0 !important;
|
@@ -472,24 +480,24 @@ body:not(.acf-admin-5-3) .select2-container .select2-search--inline .select2-sea
|
|
472 |
margin-top: -7px !important;
|
473 |
}
|
474 |
|
475 |
-
.select2-container .select2-search--inline .select2-search__field{
|
476 |
margin-top:4px !important;
|
477 |
font-size:14px !important;
|
478 |
padding-left: 2px !important;
|
479 |
}
|
480 |
|
481 |
/* Select2: Multiple */
|
482 |
-
.select2-container .select2-selection--multiple{
|
483 |
min-height: 30px !important;
|
484 |
line-height:1;
|
485 |
border-radius:3px !important;
|
486 |
}
|
487 |
|
488 |
-
.select2-container--default .select2-selection--multiple .select2-selection__rendered{
|
489 |
padding:0 2px !important;
|
490 |
}
|
491 |
|
492 |
-
.select2-container--default .select2-selection--multiple .select2-selection__choice{
|
493 |
margin-right:2px !important;
|
494 |
margin-top:2px !important;
|
495 |
line-height:1.6;
|
@@ -497,21 +505,28 @@ body:not(.acf-admin-5-3) .select2-container .select2-search--inline .select2-sea
|
|
497 |
font-size:14px;
|
498 |
}
|
499 |
|
500 |
-
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{
|
501 |
line-height:15px;
|
502 |
font-size:15px;
|
503 |
}
|
504 |
|
505 |
-
.select2-container--default.select2-container--focus .select2-selection--multiple{
|
506 |
border-color:#7e8993 !important;
|
507 |
}
|
508 |
|
509 |
-
.select2-container--default .select2-selection--multiple .select2-selection__clear{
|
510 |
margin-top: 5px !important;
|
511 |
margin-right: 5px !important;
|
512 |
font-size: 16px;
|
513 |
}
|
514 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
/*
|
516 |
* ACF Field: Tab Badge
|
517 |
*/
|
@@ -534,13 +549,6 @@ body:not(.acf-admin-5-3) .select2-container .select2-search--inline .select2-sea
|
|
534 |
background: #f1f1f1;
|
535 |
}
|
536 |
|
537 |
-
/*
|
538 |
-
* ACF Field: Select2 WPML Fix
|
539 |
-
*/
|
540 |
-
.acf-field > .acf-input > .select2 .select2-search{
|
541 |
-
width:auto;
|
542 |
-
}
|
543 |
-
|
544 |
/*
|
545 |
* Menu Item: Fix Modal z-index
|
546 |
*/
|
207 |
.wrap .acfe-dpt-admin-config,
|
208 |
.wrap .acfe-dpt-admin-config:active,
|
209 |
.wrap .acfe-dt-admin-config,
|
210 |
+
.wrap .acfe-dt-admin-config:active,
|
211 |
+
.wrap .acfe-dop-admin-config,
|
212 |
+
.wrap .acfe-dop-admin-config:active{
|
213 |
padding-left:4px;
|
214 |
padding-right:4px;
|
215 |
}
|
216 |
|
217 |
.wrap .acfe-dpt-admin-config span,
|
218 |
+
.wrap .acfe-dt-admin-config span,
|
219 |
+
.wrap .acfe-dop-admin-config span{
|
220 |
font-size: 16px;
|
221 |
vertical-align: text-top;
|
222 |
height: 15px;
|
224 |
line-height: 19px;
|
225 |
}
|
226 |
|
227 |
+
.wrap .acfe-dop-admin-config{
|
228 |
+
display: inline-block;
|
229 |
+
}
|
230 |
+
|
231 |
+
|
232 |
/*
|
233 |
* ACFE: Dynamic Post Type
|
234 |
*/
|
418 |
}
|
419 |
|
420 |
/*
|
421 |
+
* Select2: WP 5.2 Fix
|
422 |
*/
|
423 |
+
body:not(.acf-admin-5-3) .acf-field .select2-container .select2-selection{
|
424 |
border-color: #dfdfdf !important;
|
425 |
border-radius:0 !important;
|
426 |
}
|
427 |
|
428 |
+
body:not(.acf-admin-5-3) .acf-field .select2-container .select2-selection__choice{
|
429 |
border-color: #dfdfdf !important;
|
430 |
border-radius:0 !important;
|
431 |
}
|
432 |
|
433 |
+
body:not(.acf-admin-5-3) .acf-field .select2-dropdown{
|
434 |
border-color: #dfdfdf !important;
|
435 |
border-radius:0 !important;
|
436 |
}
|
437 |
|
438 |
+
body:not(.acf-admin-5-3) .acf-field .select2-container .select2-search--inline .select2-search__field{
|
439 |
margin-top:0px !important;
|
440 |
}
|
441 |
|
442 |
/* Select2: Single */
|
443 |
+
.acf-field .select2-container .select2-selection--single{
|
444 |
border-radius:3px !important;
|
445 |
height:30px !important;
|
446 |
outline:none;
|
447 |
}
|
448 |
|
449 |
+
.acf-field .select2-container:focus .select2-selection--single,
|
450 |
+
.acf-field .select2-container.select2-container--open .select2-selection--single{
|
451 |
border-color: #007cba !important;
|
452 |
color: #016087 !important;
|
453 |
box-shadow: 0 0 0 1px #007cba !important;
|
454 |
}
|
455 |
|
456 |
+
.acf-field .select2-container .select2-selection--single .select2-selection__rendered{
|
457 |
font-size:14px;
|
458 |
height:28px;
|
459 |
line-height: 27px !important;
|
460 |
padding-right:23px !important;
|
461 |
}
|
462 |
|
463 |
+
.acf-field .select2-container .select2-selection--single .select2-selection__clear{
|
464 |
line-height:26px;
|
465 |
height:28px;
|
466 |
font-size:16px;
|
467 |
}
|
468 |
|
469 |
+
.acf-field .select2-container--default .select2-selection--single .select2-selection__arrow{
|
470 |
height: 28px !important;
|
471 |
}
|
472 |
|
473 |
+
.acf-field .select2-container--default .select2-selection--single .select2-selection__arrow b{
|
474 |
background: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%206l5%205%205-5%202%201-7%207-7-7%202-1z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E') no-repeat;
|
475 |
background-size: 16px 16px;
|
476 |
border:0 !important;
|
480 |
margin-top: -7px !important;
|
481 |
}
|
482 |
|
483 |
+
.acf-field .select2-container .select2-search--inline .select2-search__field{
|
484 |
margin-top:4px !important;
|
485 |
font-size:14px !important;
|
486 |
padding-left: 2px !important;
|
487 |
}
|
488 |
|
489 |
/* Select2: Multiple */
|
490 |
+
.acf-field .select2-container .select2-selection--multiple{
|
491 |
min-height: 30px !important;
|
492 |
line-height:1;
|
493 |
border-radius:3px !important;
|
494 |
}
|
495 |
|
496 |
+
.acf-field .select2-container--default .select2-selection--multiple .select2-selection__rendered{
|
497 |
padding:0 2px !important;
|
498 |
}
|
499 |
|
500 |
+
.acf-field .select2-container--default .select2-selection--multiple .select2-selection__choice{
|
501 |
margin-right:2px !important;
|
502 |
margin-top:2px !important;
|
503 |
line-height:1.6;
|
505 |
font-size:14px;
|
506 |
}
|
507 |
|
508 |
+
.acf-field .select2-container--default .select2-selection--multiple .select2-selection__choice__remove{
|
509 |
line-height:15px;
|
510 |
font-size:15px;
|
511 |
}
|
512 |
|
513 |
+
.acf-field .select2-container--default.select2-container--focus .select2-selection--multiple{
|
514 |
border-color:#7e8993 !important;
|
515 |
}
|
516 |
|
517 |
+
.acf-field .select2-container--default .select2-selection--multiple .select2-selection__clear{
|
518 |
margin-top: 5px !important;
|
519 |
margin-right: 5px !important;
|
520 |
font-size: 16px;
|
521 |
}
|
522 |
|
523 |
+
/*
|
524 |
+
* Select2: WPML Fix
|
525 |
+
*/
|
526 |
+
.acf-field > .acf-input > .select2 .select2-search{
|
527 |
+
width:auto;
|
528 |
+
}
|
529 |
+
|
530 |
/*
|
531 |
* ACF Field: Tab Badge
|
532 |
*/
|
549 |
background: #f1f1f1;
|
550 |
}
|
551 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
552 |
/*
|
553 |
* Menu Item: Fix Modal z-index
|
554 |
*/
|
assets/acf-extended-fc-control.js
CHANGED
@@ -149,8 +149,6 @@
|
|
149 |
footer: acf.__('Close'),
|
150 |
onOpen: function(){
|
151 |
|
152 |
-
flexible.acfeEditorsInit($layout);
|
153 |
-
|
154 |
},
|
155 |
onClose: function(){
|
156 |
|
149 |
footer: acf.__('Close'),
|
150 |
onOpen: function(){
|
151 |
|
|
|
|
|
152 |
},
|
153 |
onClose: function(){
|
154 |
|
assets/acf-extended-fc-modal-edit.js
CHANGED
@@ -42,8 +42,6 @@
|
|
42 |
|
43 |
flexible.openLayout($layout);
|
44 |
|
45 |
-
flexible.acfeEditorsInit($layout);
|
46 |
-
|
47 |
},
|
48 |
onClose: function(){
|
49 |
|
42 |
|
43 |
flexible.openLayout($layout);
|
44 |
|
|
|
|
|
45 |
},
|
46 |
onClose: function(){
|
47 |
|
assets/acf-extended-fc.css
CHANGED
@@ -45,7 +45,7 @@
|
|
45 |
cursor:initial;
|
46 |
}
|
47 |
|
48 |
-
.acf-field-flexible-content[data-acfe-flexible-remove-collapse="1"][data-acfe-flexible-lock
|
49 |
cursor:initial;
|
50 |
}
|
51 |
|
45 |
cursor:initial;
|
46 |
}
|
47 |
|
48 |
+
.acf-field-flexible-content[data-acfe-flexible-remove-collapse="1"]:not([data-acfe-flexible-lock="1"]) > .acf-input > .acf-flexible-content > .values > .layout > .acf-fc-layout-handle{
|
49 |
cursor:initial;
|
50 |
}
|
51 |
|
assets/acf-extended-fc.js
CHANGED
@@ -149,43 +149,29 @@
|
|
149 |
}
|
150 |
|
151 |
};
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
// Closed
|
158 |
-
if(flexible.isLayoutClosed($layout))
|
159 |
-
return;
|
160 |
-
|
161 |
-
// Try to find delayed WYSIWYG
|
162 |
-
var editors = acf.getFields({
|
163 |
-
'type': 'wysiwyg',
|
164 |
-
'parent': $layout
|
165 |
-
});
|
166 |
-
|
167 |
-
if(!editors.length)
|
168 |
return;
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
editor.initializeEditor();
|
182 |
-
|
183 |
-
}
|
184 |
-
|
185 |
-
});
|
186 |
-
|
187 |
};
|
188 |
-
|
|
|
|
|
|
|
|
|
189 |
/*
|
190 |
* Spawn
|
191 |
*/
|
@@ -199,7 +185,7 @@
|
|
199 |
var $all_layouts = $.merge($layouts, $clones);
|
200 |
|
201 |
// Do Actions
|
202 |
-
$
|
203 |
|
204 |
var $layout = $(this);
|
205 |
var $name = $layout.data('layout');
|
@@ -311,18 +297,17 @@
|
|
311 |
|
312 |
acf.addAction('acfe/flexible/layouts', function($layout, flexible){
|
313 |
|
314 |
-
//
|
315 |
-
flexible.acfeEditorsInit($layout);
|
316 |
-
|
317 |
-
// Force open
|
318 |
-
if(flexible.has('acfeFlexibleOpen'))
|
319 |
-
flexible.openLayout($layout);
|
320 |
-
|
321 |
-
// Closed
|
322 |
if(flexible.isLayoutClosed($layout)){
|
323 |
|
324 |
// Placeholder
|
325 |
$layout.find('> .acfe-fc-placeholder').removeClass('acf-hidden');
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
|
327 |
}
|
328 |
|
@@ -335,9 +320,6 @@
|
|
335 |
|
336 |
var flexible = acf.getInstance($layout.closest('.acf-field-flexible-content'));
|
337 |
|
338 |
-
// TinyMCE Init
|
339 |
-
flexible.acfeEditorsInit($layout);
|
340 |
-
|
341 |
// Hide Placeholder
|
342 |
if(!flexible.has('acfeFlexibleModalEdition')){
|
343 |
|
149 |
}
|
150 |
|
151 |
};
|
152 |
+
|
153 |
+
var acfeFlexibleDelayInit = function(editor){
|
154 |
+
|
155 |
+
if(editor.has('id') || !editor.$el.is(':visible'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
return;
|
157 |
+
|
158 |
+
var $wrap = editor.$control();
|
159 |
+
|
160 |
+
if($wrap.hasClass('delay')){
|
161 |
+
|
162 |
+
$wrap.find('.acf-editor-toolbar').remove();
|
163 |
+
|
164 |
+
// initialize
|
165 |
+
editor.initializeEditor();
|
166 |
+
|
167 |
+
}
|
168 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
};
|
170 |
+
|
171 |
+
acf.addAction('show_field/type=wysiwyg', acfeFlexibleDelayInit);
|
172 |
+
acf.addAction('ready_field/type=wysiwyg', acfeFlexibleDelayInit);
|
173 |
+
|
174 |
+
|
175 |
/*
|
176 |
* Spawn
|
177 |
*/
|
185 |
var $all_layouts = $.merge($layouts, $clones);
|
186 |
|
187 |
// Do Actions
|
188 |
+
$layouts.each(function(){
|
189 |
|
190 |
var $layout = $(this);
|
191 |
var $name = $layout.data('layout');
|
297 |
|
298 |
acf.addAction('acfe/flexible/layouts', function($layout, flexible){
|
299 |
|
300 |
+
// Layout Closed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
if(flexible.isLayoutClosed($layout)){
|
302 |
|
303 |
// Placeholder
|
304 |
$layout.find('> .acfe-fc-placeholder').removeClass('acf-hidden');
|
305 |
+
|
306 |
+
if(flexible.has('acfeFlexibleOpen')){
|
307 |
+
|
308 |
+
flexible.openLayout($layout);
|
309 |
+
|
310 |
+
}
|
311 |
|
312 |
}
|
313 |
|
320 |
|
321 |
var flexible = acf.getInstance($layout.closest('.acf-field-flexible-content'));
|
322 |
|
|
|
|
|
|
|
323 |
// Hide Placeholder
|
324 |
if(!flexible.has('acfeFlexibleModalEdition')){
|
325 |
|
assets/acf-extended-fg.css
CHANGED
@@ -235,6 +235,10 @@ body.acf-admin-5-3 .acf-field-setting-fc_layout .acf-input-wrap.select select{
|
|
235 |
margin-right: 10px;
|
236 |
}
|
237 |
|
|
|
|
|
|
|
|
|
238 |
.acf-field-setting-fc_layout > .acf-input > .acf-fc-meta .acf-field[data-name=acfe_flexible_settings_label] > .acf-input{
|
239 |
margin:0;
|
240 |
}
|
235 |
margin-right: 10px;
|
236 |
}
|
237 |
|
238 |
+
.acf-field-setting-fc_layout > .acf-input > .acf-fc-meta .acf-field[data-name=acfe_flexible_settings_size]{
|
239 |
+
border-left:0;
|
240 |
+
}
|
241 |
+
|
242 |
.acf-field-setting-fc_layout > .acf-input > .acf-fc-meta .acf-field[data-name=acfe_flexible_settings_label] > .acf-input{
|
243 |
margin:0;
|
244 |
}
|
assets/acf-extended-form.js
CHANGED
@@ -37,12 +37,17 @@
|
|
37 |
|
38 |
// currently setting up conditions for fieldX, this field is the 'target'
|
39 |
var target = conditions.get('field');
|
40 |
-
|
41 |
-
// use the 'target' to find the 'trigger' field.
|
42 |
// - this field is used to setup the conditional logic events
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
// bail ealry if no target or no field (possible if field doesn't exist due to HTML error)
|
48 |
if( !target || !field ) {
|
37 |
|
38 |
// currently setting up conditions for fieldX, this field is the 'target'
|
39 |
var target = conditions.get('field');
|
40 |
+
|
41 |
+
// use the 'target' to find the 'trigger' field.
|
42 |
// - this field is used to setup the conditional logic events
|
43 |
+
var field = target.getField( rule.field );
|
44 |
+
|
45 |
+
// ACF Extended: Check in all form if targeted field not found
|
46 |
+
if( target && !field ) {
|
47 |
+
|
48 |
+
field = acf.getField( rule.field );
|
49 |
+
|
50 |
+
}
|
51 |
|
52 |
// bail ealry if no target or no field (possible if field doesn't exist due to HTML error)
|
53 |
if( !target || !field ) {
|
assets/acf-extended.css
CHANGED
@@ -85,6 +85,12 @@ body:not(.acf-admin-5-3) .acf-field-acfe-code-editor > .acf-input > .acf-input-w
|
|
85 |
.acf-field-acfe-code-editor > .acf-input > .acf-input-wrap > .CodeMirror-wrap.cm-s-default .CodeMirror-gutters{
|
86 |
background:#f9f9f9;
|
87 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
/*
|
90 |
* ACF Field: Accordion
|
@@ -423,6 +429,24 @@ form.acfe-form.is-invalid[data-errors-position="below"] .acf-field .acf-notice{
|
|
423 |
border-right:0;
|
424 |
}
|
425 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
/*
|
427 |
* ACFE Form: WP Media Modal
|
428 |
*/
|
85 |
.acf-field-acfe-code-editor > .acf-input > .acf-input-wrap > .CodeMirror-wrap.cm-s-default .CodeMirror-gutters{
|
86 |
background:#f9f9f9;
|
87 |
}
|
88 |
+
/*
|
89 |
+
* Fix Code Editor in term view
|
90 |
+
*/
|
91 |
+
.acf-field-acfe-code-editor > td.acf-input{
|
92 |
+
max-width: 1px;
|
93 |
+
}
|
94 |
|
95 |
/*
|
96 |
* ACF Field: Accordion
|
429 |
border-right:0;
|
430 |
}
|
431 |
|
432 |
+
@media only screen and (max-width:1024px){
|
433 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="1/6"],
|
434 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="2/6"],
|
435 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="4/6"],
|
436 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="5/6"] {
|
437 |
+
width: 50%;
|
438 |
+
}
|
439 |
+
}
|
440 |
+
|
441 |
+
@media only screen and (max-width:640px){
|
442 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="1/6"],
|
443 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="2/6"],
|
444 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="4/6"],
|
445 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="5/6"] {
|
446 |
+
width: 100%;
|
447 |
+
}
|
448 |
+
}
|
449 |
+
|
450 |
/*
|
451 |
* ACFE Form: WP Media Modal
|
452 |
*/
|
assets/acf-extended.js
CHANGED
@@ -1,4 +1,7 @@
|
|
1 |
(function($){
|
|
|
|
|
|
|
2 |
|
3 |
// init
|
4 |
var acfe = {};
|
1 |
(function($){
|
2 |
+
|
3 |
+
if(typeof acf === 'undefined')
|
4 |
+
return;
|
5 |
|
6 |
// init
|
7 |
var acfe = {};
|
includes/admin/tools/dbt-import.php
CHANGED
@@ -108,7 +108,6 @@ class ACFE_Admin_Tool_Import_DBT extends ACF_Admin_Tool{
|
|
108 |
|
109 |
// Register Args
|
110 |
update_field('name', $name, $post_id);
|
111 |
-
update_field('title', $args['title'], $post_id);
|
112 |
update_field('description', $args['description'], $post_id);
|
113 |
update_field('category', $args['category'], $post_id);
|
114 |
update_field('keywords', acf_encode_choices($args['keywords'], false), $post_id);
|
108 |
|
109 |
// Register Args
|
110 |
update_field('name', $name, $post_id);
|
|
|
111 |
update_field('description', $args['description'], $post_id);
|
112 |
update_field('category', $args['category'], $post_id);
|
113 |
update_field('keywords', acf_encode_choices($args['keywords'], false), $post_id);
|
includes/admin/tools/dop-export.php
CHANGED
@@ -128,7 +128,7 @@ class ACFE_Admin_Tool_Export_DOP extends ACF_Admin_Tool{
|
|
128 |
|
129 |
|
130 |
?>
|
131 |
-
<p><?php _e("The following code can be used to register
|
132 |
|
133 |
<div id="acf-admin-tool-export">
|
134 |
|
@@ -379,4 +379,4 @@ class ACFE_Admin_Tool_Export_DOP extends ACF_Admin_Tool{
|
|
379 |
|
380 |
acf_register_admin_tool('ACFE_Admin_Tool_Export_DOP');
|
381 |
|
382 |
-
endif;
|
128 |
|
129 |
|
130 |
?>
|
131 |
+
<p><?php _e("The following code can be used to register an options page. Simply copy and paste the following code to your theme's functions.php file or include it within an external file.", 'acf'); ?></p>
|
132 |
|
133 |
<div id="acf-admin-tool-export">
|
134 |
|
379 |
|
380 |
acf_register_admin_tool('ACFE_Admin_Tool_Export_DOP');
|
381 |
|
382 |
+
endif;
|
includes/admin/tools/dop-import.php
CHANGED
@@ -89,13 +89,13 @@ class ACFE_Admin_Tool_Import_DOP extends ACF_Admin_Tool{
|
|
89 |
}
|
90 |
|
91 |
// Vars
|
92 |
-
$
|
93 |
-
$
|
94 |
|
95 |
// Insert post
|
96 |
$post_id = wp_insert_post(array(
|
97 |
-
'post_title' => $
|
98 |
-
'post_name' => $
|
99 |
'post_type' => 'acfe-dop',
|
100 |
'post_status' => 'publish'
|
101 |
));
|
@@ -103,14 +103,12 @@ class ACFE_Admin_Tool_Import_DOP extends ACF_Admin_Tool{
|
|
103 |
// Insert error
|
104 |
if(is_wp_error($post_id)){
|
105 |
|
106 |
-
acf_add_admin_notice(__("Something went wrong with the options page {$
|
107 |
continue;
|
108 |
|
109 |
}
|
110 |
|
111 |
// Register Args
|
112 |
-
update_field('page_title', $args['page_title'], $post_id);
|
113 |
-
update_field('acfe_dop_name', $name, $post_id);
|
114 |
update_field('menu_title', $args['menu_title'], $post_id);
|
115 |
update_field('menu_slug', $args['menu_slug'], $post_id);
|
116 |
update_field('capability', $args['capability'], $post_id);
|
89 |
}
|
90 |
|
91 |
// Vars
|
92 |
+
$page_title = $args['page_title'];
|
93 |
+
$menu_slug = $args['menu_slug'];
|
94 |
|
95 |
// Insert post
|
96 |
$post_id = wp_insert_post(array(
|
97 |
+
'post_title' => $page_title,
|
98 |
+
'post_name' => $menu_slug,
|
99 |
'post_type' => 'acfe-dop',
|
100 |
'post_status' => 'publish'
|
101 |
));
|
103 |
// Insert error
|
104 |
if(is_wp_error($post_id)){
|
105 |
|
106 |
+
acf_add_admin_notice(__("Something went wrong with the options page {$page_title}. Import aborted."), 'warning');
|
107 |
continue;
|
108 |
|
109 |
}
|
110 |
|
111 |
// Register Args
|
|
|
|
|
112 |
update_field('menu_title', $args['menu_title'], $post_id);
|
113 |
update_field('menu_slug', $args['menu_slug'], $post_id);
|
114 |
update_field('capability', $args['capability'], $post_id);
|
includes/admin/tools/dpt-import.php
CHANGED
@@ -108,7 +108,6 @@ class ACFE_Admin_Tool_Import_DPT extends ACF_Admin_Tool{
|
|
108 |
|
109 |
// Register Args
|
110 |
update_field('acfe_dpt_name', $post_type_name, $post_id);
|
111 |
-
update_field('label', $args['label'], $post_id);
|
112 |
update_field('description', $args['description'], $post_id);
|
113 |
update_field('hierarchical', $args['hierarchical'], $post_id);
|
114 |
update_field('supports', $args['supports'], $post_id);
|
108 |
|
109 |
// Register Args
|
110 |
update_field('acfe_dpt_name', $post_type_name, $post_id);
|
|
|
111 |
update_field('description', $args['description'], $post_id);
|
112 |
update_field('hierarchical', $args['hierarchical'], $post_id);
|
113 |
update_field('supports', $args['supports'], $post_id);
|
includes/admin/tools/dt-import.php
CHANGED
@@ -109,7 +109,6 @@ class ACFE_Admin_Tool_Import_DT extends ACF_Admin_Tool{
|
|
109 |
|
110 |
// Register Args
|
111 |
update_field('acfe_dt_name', $taxonomy_name, $post_id);
|
112 |
-
update_field('label', $args['label'], $post_id);
|
113 |
update_field('description', $args['description'], $post_id);
|
114 |
update_field('hierarchical', $args['hierarchical'], $post_id);
|
115 |
update_field('post_types', $args['post_types'], $post_id);
|
109 |
|
110 |
// Register Args
|
111 |
update_field('acfe_dt_name', $taxonomy_name, $post_id);
|
|
|
112 |
update_field('description', $args['description'], $post_id);
|
113 |
update_field('hierarchical', $args['hierarchical'], $post_id);
|
114 |
update_field('post_types', $args['post_types'], $post_id);
|
includes/core/settings.php
CHANGED
@@ -8,6 +8,11 @@ class acfe_settings{
|
|
8 |
|
9 |
public $settings = array();
|
10 |
|
|
|
|
|
|
|
|
|
|
|
11 |
public $model = array(
|
12 |
|
13 |
// Version
|
@@ -69,28 +74,30 @@ class acfe_settings{
|
|
69 |
),
|
70 |
|
71 |
// Upgrades
|
72 |
-
'upgrades' => array(
|
73 |
-
'0_8_5' => true,
|
74 |
-
),
|
75 |
);
|
76 |
|
77 |
function __construct(){
|
78 |
-
|
79 |
-
$option = get_option('acfe', array());
|
80 |
-
|
81 |
$this->settings = acf_get_store('acfe/settings');
|
82 |
|
83 |
-
if(
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
}
|
96 |
|
@@ -308,16 +315,119 @@ class acfe_settings{
|
|
308 |
}
|
309 |
|
310 |
function reset(){
|
|
|
|
|
311 |
|
312 |
$this->set('', $this->model, true);
|
313 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
}
|
315 |
|
316 |
function version(){
|
317 |
|
318 |
$version = $this->get('version');
|
319 |
|
320 |
-
if(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
|
322 |
$data = $this->get();
|
323 |
$model = $this->model;
|
@@ -327,6 +437,12 @@ class acfe_settings{
|
|
327 |
$new_model['version'] = ACFE_VERSION;
|
328 |
|
329 |
$this->set('', $new_model, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
|
331 |
}
|
332 |
|
8 |
|
9 |
public $settings = array();
|
10 |
|
11 |
+
public $upgrades = array(
|
12 |
+
'0_8_5' => '0.8.5',
|
13 |
+
'0_8_6' => '0.8.6',
|
14 |
+
);
|
15 |
+
|
16 |
public $model = array(
|
17 |
|
18 |
// Version
|
74 |
),
|
75 |
|
76 |
// Upgrades
|
77 |
+
'upgrades' => array(),
|
|
|
|
|
78 |
);
|
79 |
|
80 |
function __construct(){
|
81 |
+
|
|
|
|
|
82 |
$this->settings = acf_get_store('acfe/settings');
|
83 |
|
84 |
+
if(empty($this->settings->get_data())){
|
85 |
+
|
86 |
+
$option = get_option('acfe', array());
|
87 |
+
|
88 |
+
if(!empty($option)){
|
89 |
+
|
90 |
+
$this->settings->set($option);
|
91 |
+
|
92 |
+
$this->version();
|
93 |
+
|
94 |
+
}else{
|
95 |
+
|
96 |
+
$this->reset();
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
}
|
101 |
|
102 |
}
|
103 |
|
315 |
}
|
316 |
|
317 |
function reset(){
|
318 |
+
|
319 |
+
$this->model['upgrades'] = $this->upgrades;
|
320 |
|
321 |
$this->set('', $this->model, true);
|
322 |
|
323 |
+
new acfe_upgrades();
|
324 |
+
|
325 |
+
add_action('init', array($this, 'reset_modules'));
|
326 |
+
|
327 |
+
}
|
328 |
+
|
329 |
+
function reset_modules(){
|
330 |
+
|
331 |
+
// Reset Post Types
|
332 |
+
$post_types = get_posts(array(
|
333 |
+
'post_type' => 'acfe-dpt',
|
334 |
+
'posts_per_page' => -1,
|
335 |
+
'fields' => 'ids'
|
336 |
+
));
|
337 |
+
|
338 |
+
if(!empty($post_types)){
|
339 |
+
|
340 |
+
foreach($post_types as $post_id){
|
341 |
+
|
342 |
+
acfe_dpt_filter_save($post_id);
|
343 |
+
|
344 |
+
acf_log('[ACF Extended] Reset: Dynamic Post Type "' . get_post_field('post_title', $post_id) . '"');
|
345 |
+
|
346 |
+
}
|
347 |
+
|
348 |
+
}
|
349 |
+
|
350 |
+
// Reset Taxonomies
|
351 |
+
$taxonomies = get_posts(array(
|
352 |
+
'post_type' => 'acfe-dt',
|
353 |
+
'posts_per_page' => -1,
|
354 |
+
'fields' => 'ids'
|
355 |
+
));
|
356 |
+
|
357 |
+
if(!empty($taxonomies)){
|
358 |
+
|
359 |
+
foreach($taxonomies as $post_id){
|
360 |
+
|
361 |
+
acfe_dt_filter_save($post_id);
|
362 |
+
|
363 |
+
acf_log('[ACF Extended] Reset: Dynamic Taxonomy "' . get_post_field('post_title', $post_id) . '"');
|
364 |
+
|
365 |
+
}
|
366 |
+
|
367 |
+
}
|
368 |
+
|
369 |
+
// Reset Block Types
|
370 |
+
$block_types = get_posts(array(
|
371 |
+
'post_type' => 'acfe-dbt',
|
372 |
+
'posts_per_page' => -1,
|
373 |
+
'fields' => 'ids'
|
374 |
+
));
|
375 |
+
|
376 |
+
if(!empty($block_types)){
|
377 |
+
|
378 |
+
foreach($block_types as $post_id){
|
379 |
+
|
380 |
+
acfe_dbt_filter_save($post_id);
|
381 |
+
|
382 |
+
acf_log('[ACF Extended] Reset: Dynamic Block Type "' . get_post_field('post_title', $post_id) . '"');
|
383 |
+
|
384 |
+
}
|
385 |
+
|
386 |
+
}
|
387 |
+
|
388 |
+
// Reset Options Pages
|
389 |
+
$options_pages = get_posts(array(
|
390 |
+
'post_type' => 'acfe-dop',
|
391 |
+
'posts_per_page' => -1,
|
392 |
+
'fields' => 'ids'
|
393 |
+
));
|
394 |
+
|
395 |
+
if(!empty($options_pages)){
|
396 |
+
|
397 |
+
foreach($options_pages as $post_id){
|
398 |
+
|
399 |
+
acfe_dop_filter_save($post_id);
|
400 |
+
|
401 |
+
acf_log('[ACF Extended] Reset: Dynamic Options Page "' . get_post_field('post_title', $post_id) . '"');
|
402 |
+
|
403 |
+
}
|
404 |
+
|
405 |
+
}
|
406 |
+
|
407 |
}
|
408 |
|
409 |
function version(){
|
410 |
|
411 |
$version = $this->get('version');
|
412 |
|
413 |
+
if(acf_version_compare($version, '<', ACFE_VERSION)){
|
414 |
+
|
415 |
+
if(!empty($this->upgrades)){
|
416 |
+
|
417 |
+
$do_upgrades = false;
|
418 |
+
|
419 |
+
foreach($this->upgrades as $function => $v){
|
420 |
+
|
421 |
+
if(acf_version_compare($v, '<=', $version))
|
422 |
+
continue;
|
423 |
+
|
424 |
+
$do_upgrades = true;
|
425 |
+
|
426 |
+
$this->model['upgrades'][$function] = true;
|
427 |
+
|
428 |
+
}
|
429 |
+
|
430 |
+
}
|
431 |
|
432 |
$data = $this->get();
|
433 |
$model = $this->model;
|
437 |
$new_model['version'] = ACFE_VERSION;
|
438 |
|
439 |
$this->set('', $new_model, true);
|
440 |
+
|
441 |
+
if($do_upgrades){
|
442 |
+
|
443 |
+
new acfe_upgrades();
|
444 |
+
|
445 |
+
}
|
446 |
|
447 |
}
|
448 |
|
includes/core/upgrades.php
CHANGED
@@ -13,9 +13,102 @@ class acfe_upgrades{
|
|
13 |
|
14 |
// ACF Extended: 0.8.5
|
15 |
add_action('acf/init', array($this, 'upgrade_0_8_5'), 999);
|
|
|
|
|
|
|
16 |
|
17 |
}
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
function upgrade_0_8_5(){
|
20 |
|
21 |
$todo = acfe_settings('upgrades.0_8_5');
|
@@ -551,7 +644,7 @@ class acfe_upgrades{
|
|
551 |
}
|
552 |
|
553 |
// Done
|
554 |
-
|
555 |
|
556 |
acf_log('[ACF Extended] 0.8.5 Upgrade: Done');
|
557 |
|
@@ -559,6 +652,4 @@ class acfe_upgrades{
|
|
559 |
|
560 |
}
|
561 |
|
562 |
-
new acfe_upgrades();
|
563 |
-
|
564 |
endif;
|
13 |
|
14 |
// ACF Extended: 0.8.5
|
15 |
add_action('acf/init', array($this, 'upgrade_0_8_5'), 999);
|
16 |
+
|
17 |
+
// ACF Extended: 0.8.6
|
18 |
+
add_action('acf/init', array($this, 'upgrade_0_8_6'), 999);
|
19 |
|
20 |
}
|
21 |
|
22 |
+
function upgrade_0_8_6(){
|
23 |
+
|
24 |
+
$todo = acfe_settings('upgrades.0_8_6');
|
25 |
+
|
26 |
+
if(!$todo)
|
27 |
+
return;
|
28 |
+
|
29 |
+
acf_log('[ACF Extended] 0.8.6 Upgrade: Dynamic Options Pages');
|
30 |
+
|
31 |
+
$get_options = get_posts(array(
|
32 |
+
'post_type' => 'acfe-dop',
|
33 |
+
'posts_per_page' => -1,
|
34 |
+
'fields' => 'ids'
|
35 |
+
));
|
36 |
+
|
37 |
+
if(!empty($get_options)){
|
38 |
+
|
39 |
+
foreach($get_options as $post_id){
|
40 |
+
|
41 |
+
$menu_slug = get_field('menu_slug', $post_id);
|
42 |
+
$acfe_dop_name = get_field('acfe_dop_name', $post_id);
|
43 |
+
$post_name = get_post_field('post_name', $post_id);
|
44 |
+
|
45 |
+
// Update empty 'menu_slug' fields in options pages
|
46 |
+
if(empty($menu_slug)){
|
47 |
+
|
48 |
+
// Page Title
|
49 |
+
$page_title = get_post_field('post_title', $post_id);
|
50 |
+
|
51 |
+
// Menu Title
|
52 |
+
$menu_title = get_field('menu_title', $post_id);
|
53 |
+
|
54 |
+
if(empty($menu_title)){
|
55 |
+
|
56 |
+
$menu_title = $page_title;
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
// Menu Slug
|
61 |
+
$menu_slug = sanitize_title($menu_title);
|
62 |
+
|
63 |
+
// Update field
|
64 |
+
update_field('menu_slug', $menu_slug, $post_id);
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
// Upgrade old name to menu_slug
|
69 |
+
if($acfe_dop_name === $post_name){
|
70 |
+
|
71 |
+
// Get ACFE option
|
72 |
+
$option = acfe_settings('modules.dynamic_option.data');
|
73 |
+
|
74 |
+
// Check ACFE option
|
75 |
+
if(isset($option[$acfe_dop_name])){
|
76 |
+
|
77 |
+
$register_args = $option[$acfe_dop_name];
|
78 |
+
|
79 |
+
// Delete old option page slug
|
80 |
+
unset($option[$acfe_dop_name]);
|
81 |
+
|
82 |
+
// Re-assign to menu_slug
|
83 |
+
$option[$menu_slug] = $register_args;
|
84 |
+
|
85 |
+
// Sort keys ASC
|
86 |
+
ksort($option);
|
87 |
+
|
88 |
+
// Update ACFE option
|
89 |
+
acfe_settings('modules.dynamic_option.data', $option, true);
|
90 |
+
|
91 |
+
// Update post: force menu slug as name
|
92 |
+
wp_update_post(array(
|
93 |
+
'ID' => $post_id,
|
94 |
+
'post_name' => $menu_slug,
|
95 |
+
));
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
// Done
|
106 |
+
acfe_settings()->delete('upgrades.0_8_6');
|
107 |
+
|
108 |
+
acf_log('[ACF Extended] 0.8.6 Upgrade: Done');
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
function upgrade_0_8_5(){
|
113 |
|
114 |
$todo = acfe_settings('upgrades.0_8_5');
|
644 |
}
|
645 |
|
646 |
// Done
|
647 |
+
acfe_settings()->delete('upgrades.0_8_5');
|
648 |
|
649 |
acf_log('[ACF Extended] 0.8.5 Upgrade: Done');
|
650 |
|
652 |
|
653 |
}
|
654 |
|
|
|
|
|
655 |
endif;
|
includes/fields-settings/settings.php
CHANGED
@@ -128,7 +128,7 @@ class acfe_field_settings{
|
|
128 |
$field_type = $field['name'];
|
129 |
|
130 |
// Exclude
|
131 |
-
if(in_array($field_type, array('message', 'accordion', 'tab', '
|
132 |
continue;
|
133 |
|
134 |
add_action('acf/render_field_settings/type=' . $field_type, array($this, 'render_field_settings'), 990);
|
128 |
$field_type = $field['name'];
|
129 |
|
130 |
// Exclude
|
131 |
+
if(in_array($field_type, array('message', 'accordion', 'tab', 'acfe_column', 'acfe_dynamic_message')))
|
132 |
continue;
|
133 |
|
134 |
add_action('acf/render_field_settings/type=' . $field_type, array($this, 'render_field_settings'), 990);
|
includes/fields/field-advanced-link.php
CHANGED
@@ -56,8 +56,8 @@ class acfe_field_advanced_link extends acf_field{
|
|
56 |
}
|
57 |
|
58 |
}
|
59 |
-
|
60 |
-
|
61 |
|
62 |
$post_type = $field['value'];
|
63 |
$post_type_label = acf_get_post_type_label($post_type);
|
@@ -493,7 +493,7 @@ function my_acf_advanced_link_sub_fields($sub_fields, $field, $value){
|
|
493 |
if(empty($value))
|
494 |
return false;
|
495 |
|
496 |
-
if((acf_maybe_get($value, '
|
497 |
return false;
|
498 |
|
499 |
// return
|
56 |
}
|
57 |
|
58 |
}
|
59 |
+
|
60 |
+
if(acf_maybe_get($field, '_name') === 'post' && !empty($field['value']) && !is_array($field['value']) && !is_numeric($field['value'])){
|
61 |
|
62 |
$post_type = $field['value'];
|
63 |
$post_type_label = acf_get_post_type_label($post_type);
|
493 |
if(empty($value))
|
494 |
return false;
|
495 |
|
496 |
+
if((acf_maybe_get($value, 'type') === 'url' && !acf_maybe_get($value, 'url')) || (acf_maybe_get($value, 'type') === 'post' && !acf_maybe_get($value, 'post')) || (acf_maybe_get($value, 'type') === 'term' && !acf_maybe_get($value, 'term')))
|
497 |
return false;
|
498 |
|
499 |
// return
|
includes/modules/autosync.php
CHANGED
@@ -18,7 +18,7 @@ if(!empty($acfe_php) && !empty($acfe_php_load)){
|
|
18 |
|
19 |
acf_update_setting('acfe/php_found', true);
|
20 |
|
21 |
-
$files = glob($path . '
|
22 |
if(empty($files))
|
23 |
continue;
|
24 |
|
18 |
|
19 |
acf_update_setting('acfe/php_found', true);
|
20 |
|
21 |
+
$files = glob($path . '/group_*.php');
|
22 |
if(empty($files))
|
23 |
continue;
|
24 |
|
includes/modules/dynamic-block-type.php
CHANGED
@@ -29,7 +29,7 @@ function acfe_dbt_register(){
|
|
29 |
'edit_item' => 'Edit Block Type',
|
30 |
'add_new_item' => 'New Block Type',
|
31 |
),
|
32 |
-
'supports' =>
|
33 |
'hierarchical' => false,
|
34 |
'public' => false,
|
35 |
'show_ui' => true,
|
@@ -52,7 +52,10 @@ function acfe_dbt_register(){
|
|
52 |
'edit_post' => acf_get_setting('capability'),
|
53 |
'delete_post' => acf_get_setting('capability'),
|
54 |
'read_post' => acf_get_setting('capability'),
|
55 |
-
)
|
|
|
|
|
|
|
56 |
));
|
57 |
|
58 |
}
|
@@ -81,7 +84,7 @@ function acfe_dbt_menu_parent_highlight($parent_file){
|
|
81 |
return $parent_file;
|
82 |
|
83 |
$post_type = get_post_type();
|
84 |
-
if($post_type
|
85 |
return $parent_file;
|
86 |
|
87 |
return 'edit.php?post_type=acf-field-group';
|
@@ -95,11 +98,11 @@ add_filter('submenu_file', 'acfe_dbt_menu_sub_highlight');
|
|
95 |
function acfe_dbt_menu_sub_highlight($submenu_file){
|
96 |
|
97 |
global $pagenow;
|
98 |
-
if($pagenow
|
99 |
return $submenu_file;
|
100 |
|
101 |
$post_type = get_post_type();
|
102 |
-
if($post_type
|
103 |
return $submenu_file;
|
104 |
|
105 |
return 'edit.php?post_type=acfe-dbt';
|
@@ -108,8 +111,10 @@ function acfe_dbt_menu_sub_highlight($submenu_file){
|
|
108 |
|
109 |
/**
|
110 |
* ACF Register Block Types
|
|
|
111 |
*/
|
112 |
-
|
|
|
113 |
function acfe_dbt_registers(){
|
114 |
|
115 |
$dynamic_block_types = acfe_settings('modules.dynamic_block_type.data');
|
@@ -170,22 +175,12 @@ function acfe_dbt_misc_actions($post){
|
|
170 |
add_action('acf/save_post', 'acfe_dbt_filter_save', 20);
|
171 |
function acfe_dbt_filter_save($post_id){
|
172 |
|
173 |
-
if(get_post_type($post_id)
|
174 |
return;
|
175 |
|
176 |
-
$title = get_field('title', $post_id);
|
177 |
-
$name = get_field('name', $post_id);
|
178 |
-
|
179 |
-
// Update post
|
180 |
-
wp_update_post(array(
|
181 |
-
'ID' => $post_id,
|
182 |
-
'post_title' => $title,
|
183 |
-
'post_name' => $name,
|
184 |
-
));
|
185 |
-
|
186 |
// Register Args
|
|
|
187 |
$name = get_field('name', $post_id);
|
188 |
-
$title = get_field('title', $post_id);
|
189 |
$description = get_field('description', $post_id);
|
190 |
$category = get_field('category', $post_id);
|
191 |
$keywords = acf_decode_choices(get_field('keywords', $post_id), true);
|
@@ -213,7 +208,7 @@ function acfe_dbt_filter_save($post_id){
|
|
213 |
// Register: Args
|
214 |
$register_args = array(
|
215 |
'name' => $name,
|
216 |
-
'title' => $
|
217 |
'description' => $description,
|
218 |
'category' => $category,
|
219 |
'keywords' => $keywords,
|
@@ -299,6 +294,12 @@ function acfe_dbt_filter_save($post_id){
|
|
299 |
|
300 |
// Update ACFE option
|
301 |
acfe_settings('modules.dynamic_block_type.data', $option, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
|
303 |
}
|
304 |
|
@@ -308,7 +309,7 @@ function acfe_dbt_filter_save($post_id){
|
|
308 |
add_action('publish_to_trash', 'acfe_dbt_filter_status_trash');
|
309 |
function acfe_dbt_filter_status_trash($post){
|
310 |
|
311 |
-
if(get_post_type($post->ID)
|
312 |
return;
|
313 |
|
314 |
$post_id = $post->ID;
|
@@ -332,52 +333,13 @@ function acfe_dbt_filter_status_trash($post){
|
|
332 |
add_action('trash_to_publish', 'acfe_dbt_filter_status_publish');
|
333 |
function acfe_dbt_filter_status_publish($post){
|
334 |
|
335 |
-
if(get_post_type($post->ID)
|
336 |
return;
|
337 |
|
338 |
acfe_dop_filter_save($post->ID);
|
339 |
|
340 |
}
|
341 |
|
342 |
-
/**
|
343 |
-
* Dynamic Block Type Admin: List
|
344 |
-
*/
|
345 |
-
add_action('pre_get_posts', 'acfe_dbt_admin_pre_get_posts');
|
346 |
-
function acfe_dbt_admin_pre_get_posts($query){
|
347 |
-
|
348 |
-
if(!is_admin() || !$query->is_main_query())
|
349 |
-
return;
|
350 |
-
|
351 |
-
global $pagenow;
|
352 |
-
if($pagenow != 'edit.php')
|
353 |
-
return;
|
354 |
-
|
355 |
-
$post_type = $query->get('post_type');
|
356 |
-
if($post_type != 'acfe-dbt')
|
357 |
-
return;
|
358 |
-
|
359 |
-
$query->set('orderby', 'name');
|
360 |
-
$query->set('order', 'ASC');
|
361 |
-
|
362 |
-
}
|
363 |
-
|
364 |
-
/**
|
365 |
-
* Dynamic Block Type Admin: Posts Per Page
|
366 |
-
*/
|
367 |
-
add_filter('edit_posts_per_page', 'acfe_dbt_admin_ppp', 10, 2);
|
368 |
-
function acfe_dbt_admin_ppp($ppp, $post_type){
|
369 |
-
|
370 |
-
if($post_type != 'acfe-dbt')
|
371 |
-
return $ppp;
|
372 |
-
|
373 |
-
global $pagenow;
|
374 |
-
if($pagenow != 'edit.php')
|
375 |
-
return $ppp;
|
376 |
-
|
377 |
-
return 999;
|
378 |
-
|
379 |
-
}
|
380 |
-
|
381 |
/**
|
382 |
* Admin List Columns
|
383 |
*/
|
@@ -488,20 +450,112 @@ function acfe_dbt_admin_row($actions, $post){
|
|
488 |
|
489 |
}
|
490 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
/**
|
492 |
-
* Admin
|
493 |
*/
|
494 |
-
add_filter('acf/
|
495 |
-
function
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
505 |
}
|
506 |
|
507 |
add_action('load-post.php', 'acfe_dbt_load');
|
@@ -706,28 +760,6 @@ acf_add_local_field_group(array(
|
|
706 |
'placement' => 'top',
|
707 |
'endpoint' => 0,
|
708 |
),
|
709 |
-
array(
|
710 |
-
'key' => 'field_acfe_dbt_title',
|
711 |
-
'label' => 'Title',
|
712 |
-
'name' => 'title',
|
713 |
-
'type' => 'text',
|
714 |
-
'instructions' => '(String) The display title for your block.',
|
715 |
-
'required' => 1,
|
716 |
-
'conditional_logic' => 0,
|
717 |
-
'wrapper' => array(
|
718 |
-
'width' => '',
|
719 |
-
'class' => '',
|
720 |
-
'id' => '',
|
721 |
-
),
|
722 |
-
'acfe_validate' => '',
|
723 |
-
'acfe_update' => '',
|
724 |
-
'acfe_permissions' => '',
|
725 |
-
'default_value' => '',
|
726 |
-
'placeholder' => '',
|
727 |
-
'prepend' => '',
|
728 |
-
'append' => '',
|
729 |
-
'maxlength' => '',
|
730 |
-
),
|
731 |
array(
|
732 |
'key' => 'field_acfe_dbt_name',
|
733 |
'label' => 'Name',
|
29 |
'edit_item' => 'Edit Block Type',
|
30 |
'add_new_item' => 'New Block Type',
|
31 |
),
|
32 |
+
'supports' => array('title'),
|
33 |
'hierarchical' => false,
|
34 |
'public' => false,
|
35 |
'show_ui' => true,
|
52 |
'edit_post' => acf_get_setting('capability'),
|
53 |
'delete_post' => acf_get_setting('capability'),
|
54 |
'read_post' => acf_get_setting('capability'),
|
55 |
+
),
|
56 |
+
'acfe_admin_orderby' => 'title',
|
57 |
+
'acfe_admin_order' => 'ASC',
|
58 |
+
'acfe_admin_ppp' => 999,
|
59 |
));
|
60 |
|
61 |
}
|
84 |
return $parent_file;
|
85 |
|
86 |
$post_type = get_post_type();
|
87 |
+
if($post_type !== 'acfe-dbt')
|
88 |
return $parent_file;
|
89 |
|
90 |
return 'edit.php?post_type=acf-field-group';
|
98 |
function acfe_dbt_menu_sub_highlight($submenu_file){
|
99 |
|
100 |
global $pagenow;
|
101 |
+
if($pagenow !== 'post-new.php')
|
102 |
return $submenu_file;
|
103 |
|
104 |
$post_type = get_post_type();
|
105 |
+
if($post_type !== 'acfe-dbt')
|
106 |
return $submenu_file;
|
107 |
|
108 |
return 'edit.php?post_type=acfe-dbt';
|
111 |
|
112 |
/**
|
113 |
* ACF Register Block Types
|
114 |
+
* Note: We're already in acf/init, 99. No need to re-hook
|
115 |
*/
|
116 |
+
acfe_dbt_registers();
|
117 |
+
|
118 |
function acfe_dbt_registers(){
|
119 |
|
120 |
$dynamic_block_types = acfe_settings('modules.dynamic_block_type.data');
|
175 |
add_action('acf/save_post', 'acfe_dbt_filter_save', 20);
|
176 |
function acfe_dbt_filter_save($post_id){
|
177 |
|
178 |
+
if(get_post_type($post_id) !== 'acfe-dbt')
|
179 |
return;
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
// Register Args
|
182 |
+
$label = get_post_field('post_title', $post_id);
|
183 |
$name = get_field('name', $post_id);
|
|
|
184 |
$description = get_field('description', $post_id);
|
185 |
$category = get_field('category', $post_id);
|
186 |
$keywords = acf_decode_choices(get_field('keywords', $post_id), true);
|
208 |
// Register: Args
|
209 |
$register_args = array(
|
210 |
'name' => $name,
|
211 |
+
'title' => $label,
|
212 |
'description' => $description,
|
213 |
'category' => $category,
|
214 |
'keywords' => $keywords,
|
294 |
|
295 |
// Update ACFE option
|
296 |
acfe_settings('modules.dynamic_block_type.data', $option, true);
|
297 |
+
|
298 |
+
// Update post
|
299 |
+
wp_update_post(array(
|
300 |
+
'ID' => $post_id,
|
301 |
+
'post_name' => $name,
|
302 |
+
));
|
303 |
|
304 |
}
|
305 |
|
309 |
add_action('publish_to_trash', 'acfe_dbt_filter_status_trash');
|
310 |
function acfe_dbt_filter_status_trash($post){
|
311 |
|
312 |
+
if(get_post_type($post->ID) !== 'acfe-dbt')
|
313 |
return;
|
314 |
|
315 |
$post_id = $post->ID;
|
333 |
add_action('trash_to_publish', 'acfe_dbt_filter_status_publish');
|
334 |
function acfe_dbt_filter_status_publish($post){
|
335 |
|
336 |
+
if(get_post_type($post->ID) !== 'acfe-dbt')
|
337 |
return;
|
338 |
|
339 |
acfe_dop_filter_save($post->ID);
|
340 |
|
341 |
}
|
342 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
/**
|
344 |
* Admin List Columns
|
345 |
*/
|
450 |
|
451 |
}
|
452 |
|
453 |
+
add_filter('enter_title_here', 'acfe_dbt_admin_placeholder_title', 10, 2);
|
454 |
+
function acfe_dbt_admin_placeholder_title($placeholder, $post){
|
455 |
+
|
456 |
+
// Get post type
|
457 |
+
global $typenow;
|
458 |
+
|
459 |
+
// Check post type
|
460 |
+
$post_type = $typenow;
|
461 |
+
if($post_type !== 'acfe-dbt')
|
462 |
+
return $placeholder;
|
463 |
+
|
464 |
+
return 'Block Type Title';
|
465 |
+
|
466 |
+
}
|
467 |
+
|
468 |
+
add_action('admin_footer-post.php', 'acfe_dbt_admin_validate_title');
|
469 |
+
function acfe_dbt_admin_validate_title(){
|
470 |
+
|
471 |
+
// Get post type
|
472 |
+
global $typenow;
|
473 |
+
|
474 |
+
// Check post type
|
475 |
+
$post_type = $typenow;
|
476 |
+
if($post_type !== 'acfe-dbt')
|
477 |
+
return;
|
478 |
+
|
479 |
+
?>
|
480 |
+
<script type="text/javascript">
|
481 |
+
(function($){
|
482 |
+
|
483 |
+
if(typeof acf === 'undefined')
|
484 |
+
return;
|
485 |
+
|
486 |
+
$('#post').submit(function(e){
|
487 |
+
|
488 |
+
// vars
|
489 |
+
var $title = $('#titlewrap #title');
|
490 |
+
|
491 |
+
// empty
|
492 |
+
if(!$title.val()){
|
493 |
+
|
494 |
+
// prevent default
|
495 |
+
e.preventDefault();
|
496 |
+
|
497 |
+
// alert
|
498 |
+
alert('Block Type Title is required.');
|
499 |
+
|
500 |
+
// focus
|
501 |
+
$title.focus();
|
502 |
+
|
503 |
+
}
|
504 |
+
|
505 |
+
});
|
506 |
+
|
507 |
+
})(jQuery);
|
508 |
+
</script>
|
509 |
+
<?php
|
510 |
+
}
|
511 |
+
|
512 |
/**
|
513 |
+
* Admin Validate Name
|
514 |
*/
|
515 |
+
add_filter('acf/validate_value/key=field_acfe_dbt_name', 'acfe_dbt_admin_validate_name', 10, 4);
|
516 |
+
function acfe_dbt_admin_validate_name($valid, $value, $field, $input){
|
517 |
+
|
518 |
+
if(!$valid)
|
519 |
+
return $valid;
|
520 |
+
|
521 |
+
// Editing Current Block Type
|
522 |
+
$current_post_id = acf_maybe_get_POST('post_ID');
|
523 |
+
|
524 |
+
if(!empty($current_post_id)){
|
525 |
+
|
526 |
+
$current_name = get_field($field['name'], $current_post_id);
|
527 |
+
|
528 |
+
if($value === $current_name)
|
529 |
+
return $valid;
|
530 |
+
|
531 |
+
}
|
532 |
+
|
533 |
+
// Check existing ACF Block Types
|
534 |
+
if(acf_has_block_type('acf/' . $value)){
|
535 |
+
|
536 |
+
$valid = 'This block type name already exists';
|
537 |
+
|
538 |
+
}
|
539 |
+
|
540 |
+
return $valid;
|
541 |
+
|
542 |
+
}
|
543 |
+
|
544 |
+
add_filter('acf/update_value/key=field_acfe_dbt_name', 'acfe_dbt_admin_update_name', 10, 3);
|
545 |
+
function acfe_dbt_admin_update_name($value, $post_id, $field){
|
546 |
+
|
547 |
+
// Previous value
|
548 |
+
$_value = get_field($field['name'], $post_id);
|
549 |
+
|
550 |
+
// Value Changed. Delete option
|
551 |
+
if($_value !== $value){
|
552 |
+
|
553 |
+
acfe_settings()->delete('modules.dynamic_block_type.data.' . $_value);
|
554 |
+
|
555 |
+
}
|
556 |
+
|
557 |
+
return $value;
|
558 |
+
|
559 |
}
|
560 |
|
561 |
add_action('load-post.php', 'acfe_dbt_load');
|
760 |
'placement' => 'top',
|
761 |
'endpoint' => 0,
|
762 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
763 |
array(
|
764 |
'key' => 'field_acfe_dbt_name',
|
765 |
'label' => 'Name',
|
includes/modules/dynamic-options-page.php
CHANGED
@@ -23,7 +23,7 @@ function acfe_dop_register(){
|
|
23 |
'edit_item' => 'Edit Options Page',
|
24 |
'add_new_item' => 'New Options Page',
|
25 |
),
|
26 |
-
'supports' =>
|
27 |
'hierarchical' => true,
|
28 |
'public' => false,
|
29 |
'show_ui' => true,
|
@@ -46,7 +46,10 @@ function acfe_dop_register(){
|
|
46 |
'edit_post' => acf_get_setting('capability'),
|
47 |
'delete_post' => acf_get_setting('capability'),
|
48 |
'read_post' => acf_get_setting('capability'),
|
49 |
-
)
|
|
|
|
|
|
|
50 |
));
|
51 |
|
52 |
}
|
@@ -71,11 +74,11 @@ add_filter('parent_file', 'acfe_dop_menu_parent_highlight');
|
|
71 |
function acfe_dop_menu_parent_highlight($parent_file){
|
72 |
|
73 |
global $pagenow;
|
74 |
-
if($pagenow
|
75 |
return $parent_file;
|
76 |
|
77 |
$post_type = get_post_type();
|
78 |
-
if($post_type
|
79 |
return $parent_file;
|
80 |
|
81 |
return 'edit.php?post_type=acf-field-group';
|
@@ -89,11 +92,11 @@ add_filter('submenu_file', 'acfe_dop_menu_sub_highlight');
|
|
89 |
function acfe_dop_menu_sub_highlight($submenu_file){
|
90 |
|
91 |
global $pagenow;
|
92 |
-
if($pagenow
|
93 |
return $submenu_file;
|
94 |
|
95 |
$post_type = get_post_type();
|
96 |
-
if($post_type
|
97 |
return $submenu_file;
|
98 |
|
99 |
return 'edit.php?post_type=acfe-dop';
|
@@ -154,7 +157,7 @@ function acfe_dop_exclude($post_types, $args){
|
|
154 |
|
155 |
foreach($post_types as $k => $post_type){
|
156 |
|
157 |
-
if($post_type
|
158 |
continue;
|
159 |
|
160 |
unset($post_types[$k]);
|
@@ -171,7 +174,7 @@ function acfe_dop_misc_actions($post){
|
|
171 |
if($post->post_type !== 'acfe-dop')
|
172 |
return;
|
173 |
|
174 |
-
$name = get_field('
|
175 |
|
176 |
?>
|
177 |
<div class="misc-pub-section misc-pub-acfe-field-group-export" style="padding-top:2px;">
|
@@ -187,18 +190,36 @@ function acfe_dop_misc_actions($post){
|
|
187 |
add_action('acf/save_post', 'acfe_dop_filter_save', 20);
|
188 |
function acfe_dop_filter_save($post_id){
|
189 |
|
190 |
-
if(get_post_type($post_id)
|
191 |
return;
|
192 |
|
193 |
-
|
194 |
-
|
195 |
-
$parent_slug = get_field('parent_slug', $post_id);
|
196 |
-
|
197 |
-
// Force name
|
198 |
-
if(empty($name))
|
199 |
-
$name = sanitize_title($title);
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
$parent = 0;
|
|
|
|
|
|
|
202 |
if(!empty($parent_slug)){
|
203 |
|
204 |
$get_dop_parent = get_posts(array(
|
@@ -213,23 +234,22 @@ function acfe_dop_filter_save($post_id){
|
|
213 |
)
|
214 |
));
|
215 |
|
216 |
-
if(!empty($get_dop_parent))
|
217 |
-
|
|
|
|
|
|
|
218 |
|
219 |
}
|
220 |
|
221 |
// Update post
|
222 |
wp_update_post(array(
|
223 |
'ID' => $post_id,
|
224 |
-
'
|
225 |
-
'post_name' => $name,
|
226 |
'post_parent' => $parent,
|
227 |
));
|
228 |
|
229 |
// Register Args
|
230 |
-
$page_title = get_field('page_title', $post_id);
|
231 |
-
$menu_title = get_field('menu_title', $post_id);
|
232 |
-
$menu_slug = get_field('menu_slug', $post_id);
|
233 |
$capability = get_field('capability', $post_id);
|
234 |
$position = get_field('position', $post_id);
|
235 |
$icon_url = get_field('icon_url', $post_id);
|
@@ -239,20 +259,6 @@ function acfe_dop_filter_save($post_id){
|
|
239 |
$update_button = get_field('update_button', $post_id);
|
240 |
$updated_message = get_field('updated_message', $post_id);
|
241 |
|
242 |
-
if(empty($menu_title)){
|
243 |
-
|
244 |
-
$menu_title = $page_title;
|
245 |
-
update_field('menu_title', $menu_title, $post_id);
|
246 |
-
|
247 |
-
}
|
248 |
-
|
249 |
-
if(empty($menu_slug)){
|
250 |
-
|
251 |
-
$menu_slug = sanitize_title($menu_title);
|
252 |
-
update_field('menu_slug', $menu_slug, $post_id);
|
253 |
-
|
254 |
-
}
|
255 |
-
|
256 |
// Register: Args
|
257 |
$register_args = array(
|
258 |
'page_title' => $page_title,
|
@@ -269,16 +275,9 @@ function acfe_dop_filter_save($post_id){
|
|
269 |
'updated_message' => $updated_message,
|
270 |
);
|
271 |
|
272 |
-
// Menu title
|
273 |
-
if(empty($menu_title))
|
274 |
-
$register_args['menu_title'] = $page_title;
|
275 |
-
|
276 |
-
// Menu slug
|
277 |
-
if(empty($menu_slug))
|
278 |
-
$register_args['menu_slug'] = sanitize_title($register_args['menu_title']);
|
279 |
-
|
280 |
// Redirect
|
281 |
$register_args['redirect'] = true;
|
|
|
282 |
if(empty($redirect))
|
283 |
$register_args['redirect'] = false;
|
284 |
|
@@ -288,6 +287,7 @@ function acfe_dop_filter_save($post_id){
|
|
288 |
|
289 |
// Autoload
|
290 |
$register_args['autoload'] = true;
|
|
|
291 |
if(empty($autoload))
|
292 |
$register_args['autoload'] = false;
|
293 |
|
@@ -295,7 +295,7 @@ function acfe_dop_filter_save($post_id){
|
|
295 |
$option = acfe_settings('modules.dynamic_option.data');
|
296 |
|
297 |
// Create ACFE option
|
298 |
-
$option[$
|
299 |
|
300 |
// Sort keys ASC
|
301 |
ksort($option);
|
@@ -311,12 +311,11 @@ function acfe_dop_filter_save($post_id){
|
|
311 |
add_action('publish_to_trash', 'acfe_dop_filter_status_trash');
|
312 |
function acfe_dop_filter_status_trash($post){
|
313 |
|
314 |
-
if(get_post_type($post->ID)
|
315 |
return;
|
316 |
|
317 |
$post_id = $post->ID;
|
318 |
-
$
|
319 |
-
$name = get_field('acfe_dop_name', $post_id);
|
320 |
|
321 |
// Get ACFE option
|
322 |
$option = acfe_settings('modules.dynamic_option.data');
|
@@ -336,52 +335,13 @@ function acfe_dop_filter_status_trash($post){
|
|
336 |
add_action('trash_to_publish', 'acfe_dop_filter_status_publish');
|
337 |
function acfe_dop_filter_status_publish($post){
|
338 |
|
339 |
-
if(get_post_type($post->ID)
|
340 |
return;
|
341 |
|
342 |
acfe_dop_filter_save($post->ID);
|
343 |
|
344 |
}
|
345 |
|
346 |
-
/**
|
347 |
-
* Dynamic Options Page Admin: List
|
348 |
-
*/
|
349 |
-
add_action('pre_get_posts', 'acfe_dop_admin_pre_get_posts');
|
350 |
-
function acfe_dop_admin_pre_get_posts($query){
|
351 |
-
|
352 |
-
if(!is_admin() || !$query->is_main_query())
|
353 |
-
return;
|
354 |
-
|
355 |
-
global $pagenow;
|
356 |
-
if($pagenow != 'edit.php')
|
357 |
-
return;
|
358 |
-
|
359 |
-
$post_type = $query->get('post_type');
|
360 |
-
if($post_type != 'acfe-dop')
|
361 |
-
return;
|
362 |
-
|
363 |
-
$query->set('orderby', 'name');
|
364 |
-
$query->set('order', 'ASC');
|
365 |
-
|
366 |
-
}
|
367 |
-
|
368 |
-
/**
|
369 |
-
* Dynamic Options Page Admin: Posts Per Page
|
370 |
-
*/
|
371 |
-
add_filter('edit_posts_per_page', 'acfe_dop_admin_ppp', 10, 2);
|
372 |
-
function acfe_dop_admin_ppp($ppp, $post_type){
|
373 |
-
|
374 |
-
if($post_type != 'acfe-dop')
|
375 |
-
return $ppp;
|
376 |
-
|
377 |
-
global $pagenow;
|
378 |
-
if($pagenow != 'edit.php')
|
379 |
-
return $ppp;
|
380 |
-
|
381 |
-
return 999;
|
382 |
-
|
383 |
-
}
|
384 |
-
|
385 |
/**
|
386 |
* Admin List Columns
|
387 |
*/
|
@@ -391,7 +351,7 @@ function acfe_dop_admin_columns($columns){
|
|
391 |
if(isset($columns['date']))
|
392 |
unset($columns['date']);
|
393 |
|
394 |
-
$columns['name'] = __('
|
395 |
$columns['post_id'] = __('Post ID');
|
396 |
$columns['autoload'] = __('Autoload');
|
397 |
|
@@ -408,7 +368,7 @@ function acfe_dop_admin_columns_html($column, $post_id){
|
|
408 |
// Name
|
409 |
if($column === 'name'){
|
410 |
|
411 |
-
$name = get_field('
|
412 |
|
413 |
echo '<code style="font-size: 12px;">' . $name . '</code>';
|
414 |
|
@@ -448,7 +408,7 @@ function acfe_dop_admin_row($actions, $post){
|
|
448 |
if($post->post_type !== 'acfe-dop' || $post->post_status !== 'publish')
|
449 |
return $actions;
|
450 |
|
451 |
-
$name = get_field('
|
452 |
|
453 |
$actions['acfe_dop_export_php'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dop_export&action=php&keys=' . $name) . '">' . __('PHP') . '</a>';
|
454 |
$actions['acfe_dop_export_json'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dop_export&action=json&keys=' . $name) . '">' . __('Json') . '</a>';
|
@@ -458,53 +418,168 @@ function acfe_dop_admin_row($actions, $post){
|
|
458 |
}
|
459 |
|
460 |
/**
|
461 |
-
* Admin
|
462 |
*/
|
463 |
-
|
464 |
-
function
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
}
|
475 |
|
476 |
/**
|
477 |
-
* Admin
|
478 |
*/
|
479 |
-
|
480 |
-
function
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
508 |
}
|
509 |
|
510 |
/**
|
@@ -534,56 +609,38 @@ acf_add_local_field_group(array(
|
|
534 |
'description' => '',
|
535 |
|
536 |
'fields' => array(
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
'type' => 'acfe_slug',
|
564 |
-
'instructions' => '(string) Options page slug. Must be unique',
|
565 |
-
'required' => 1,
|
566 |
-
'conditional_logic' => 0,
|
567 |
-
'wrapper' => array(
|
568 |
-
'width' => '',
|
569 |
-
'class' => '',
|
570 |
-
'id' => '',
|
571 |
-
),
|
572 |
-
'acfe_validate' => '',
|
573 |
-
'acfe_update' => '',
|
574 |
-
'acfe_permissions' => '',
|
575 |
-
'default_value' => '',
|
576 |
-
'placeholder' => '',
|
577 |
-
'prepend' => '',
|
578 |
-
'append' => '',
|
579 |
-
'maxlength' => '',
|
580 |
-
),
|
581 |
array(
|
582 |
'key' => 'field_acfe_dop_menu_title',
|
583 |
'label' => 'Menu title',
|
584 |
'name' => 'menu_title',
|
585 |
'type' => 'text',
|
586 |
-
'instructions' => '(string) The title displayed in the wp-admin sidebar. Defaults to
|
587 |
'required' => 0,
|
588 |
'conditional_logic' => 0,
|
589 |
'wrapper' => array(
|
@@ -600,32 +657,6 @@ acf_add_local_field_group(array(
|
|
600 |
'append' => '',
|
601 |
'maxlength' => '',
|
602 |
),
|
603 |
-
array(
|
604 |
-
'key' => 'field_acfe_dop_menu_slug',
|
605 |
-
'label' => 'Menu slug',
|
606 |
-
'name' => 'menu_slug',
|
607 |
-
'type' => 'acfe_slug',
|
608 |
-
'instructions' => '(string) The URL slug used to uniquely identify this options page. Defaults to a url friendly version of menu_title',
|
609 |
-
'required' => 0,
|
610 |
-
'conditional_logic' => 0,
|
611 |
-
'wrapper' => array(
|
612 |
-
'width' => '',
|
613 |
-
'class' => '',
|
614 |
-
'id' => '',
|
615 |
-
),
|
616 |
-
'acfe_validate' => '',
|
617 |
-
'acfe_update' => array(
|
618 |
-
'5cd2a4d60fbf2' => array(
|
619 |
-
'acfe_update_function' => 'sanitize_title',
|
620 |
-
),
|
621 |
-
),
|
622 |
-
'acfe_permissions' => '',
|
623 |
-
'default_value' => '',
|
624 |
-
'placeholder' => '',
|
625 |
-
'prepend' => '',
|
626 |
-
'append' => '',
|
627 |
-
'maxlength' => '',
|
628 |
-
),
|
629 |
array(
|
630 |
'key' => 'field_acfe_dop_capability',
|
631 |
'label' => 'Capability',
|
@@ -633,7 +664,7 @@ acf_add_local_field_group(array(
|
|
633 |
'type' => 'text',
|
634 |
'instructions' => '(string) The capability required for this menu to be displayed to the user. Defaults to edit_posts.<br /><br />
|
635 |
|
636 |
-
Read more about capability here: <a href="https://
|
637 |
'required' => 0,
|
638 |
'conditional_logic' => 0,
|
639 |
'wrapper' => array(
|
@@ -834,4 +865,4 @@ Defaults to false.',
|
|
834 |
'maxlength' => '',
|
835 |
),
|
836 |
),
|
837 |
-
));
|
23 |
'edit_item' => 'Edit Options Page',
|
24 |
'add_new_item' => 'New Options Page',
|
25 |
),
|
26 |
+
'supports' => array('title'),
|
27 |
'hierarchical' => true,
|
28 |
'public' => false,
|
29 |
'show_ui' => true,
|
46 |
'edit_post' => acf_get_setting('capability'),
|
47 |
'delete_post' => acf_get_setting('capability'),
|
48 |
'read_post' => acf_get_setting('capability'),
|
49 |
+
),
|
50 |
+
'acfe_admin_orderby' => 'title',
|
51 |
+
'acfe_admin_order' => 'ASC',
|
52 |
+
'acfe_admin_ppp' => 999,
|
53 |
));
|
54 |
|
55 |
}
|
74 |
function acfe_dop_menu_parent_highlight($parent_file){
|
75 |
|
76 |
global $pagenow;
|
77 |
+
if($pagenow !== 'post.php' && $pagenow !== 'post-new.php')
|
78 |
return $parent_file;
|
79 |
|
80 |
$post_type = get_post_type();
|
81 |
+
if($post_type !== 'acfe-dop')
|
82 |
return $parent_file;
|
83 |
|
84 |
return 'edit.php?post_type=acf-field-group';
|
92 |
function acfe_dop_menu_sub_highlight($submenu_file){
|
93 |
|
94 |
global $pagenow;
|
95 |
+
if($pagenow !== 'post-new.php')
|
96 |
return $submenu_file;
|
97 |
|
98 |
$post_type = get_post_type();
|
99 |
+
if($post_type !== 'acfe-dop')
|
100 |
return $submenu_file;
|
101 |
|
102 |
return 'edit.php?post_type=acfe-dop';
|
157 |
|
158 |
foreach($post_types as $k => $post_type){
|
159 |
|
160 |
+
if($post_type !== 'acfe-dop')
|
161 |
continue;
|
162 |
|
163 |
unset($post_types[$k]);
|
174 |
if($post->post_type !== 'acfe-dop')
|
175 |
return;
|
176 |
|
177 |
+
$name = get_field('menu_slug', $post->ID);
|
178 |
|
179 |
?>
|
180 |
<div class="misc-pub-section misc-pub-acfe-field-group-export" style="padding-top:2px;">
|
190 |
add_action('acf/save_post', 'acfe_dop_filter_save', 20);
|
191 |
function acfe_dop_filter_save($post_id){
|
192 |
|
193 |
+
if(get_post_type($post_id) !== 'acfe-dop')
|
194 |
return;
|
195 |
|
196 |
+
// Page Title
|
197 |
+
$page_title = get_post_field('post_title', $post_id);
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
+
// Menu Title
|
200 |
+
$menu_title = get_field('menu_title', $post_id);
|
201 |
+
|
202 |
+
if(empty($menu_title)){
|
203 |
+
|
204 |
+
$menu_title = $page_title;
|
205 |
+
|
206 |
+
}
|
207 |
+
|
208 |
+
// Menu Slug
|
209 |
+
$menu_slug = get_field('menu_slug', $post_id);
|
210 |
+
|
211 |
+
if(empty($menu_slug)){
|
212 |
+
|
213 |
+
$menu_slug = sanitize_title($menu_title);
|
214 |
+
update_field('menu_slug', $menu_slug, $post_id);
|
215 |
+
|
216 |
+
}
|
217 |
+
|
218 |
+
// Parent
|
219 |
$parent = 0;
|
220 |
+
|
221 |
+
$parent_slug = get_field('parent_slug', $post_id);
|
222 |
+
|
223 |
if(!empty($parent_slug)){
|
224 |
|
225 |
$get_dop_parent = get_posts(array(
|
234 |
)
|
235 |
));
|
236 |
|
237 |
+
if(!empty($get_dop_parent)){
|
238 |
+
|
239 |
+
$parent = $get_dop_parent[0];
|
240 |
+
|
241 |
+
}
|
242 |
|
243 |
}
|
244 |
|
245 |
// Update post
|
246 |
wp_update_post(array(
|
247 |
'ID' => $post_id,
|
248 |
+
'post_name' => $menu_slug,
|
|
|
249 |
'post_parent' => $parent,
|
250 |
));
|
251 |
|
252 |
// Register Args
|
|
|
|
|
|
|
253 |
$capability = get_field('capability', $post_id);
|
254 |
$position = get_field('position', $post_id);
|
255 |
$icon_url = get_field('icon_url', $post_id);
|
259 |
$update_button = get_field('update_button', $post_id);
|
260 |
$updated_message = get_field('updated_message', $post_id);
|
261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
// Register: Args
|
263 |
$register_args = array(
|
264 |
'page_title' => $page_title,
|
275 |
'updated_message' => $updated_message,
|
276 |
);
|
277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
// Redirect
|
279 |
$register_args['redirect'] = true;
|
280 |
+
|
281 |
if(empty($redirect))
|
282 |
$register_args['redirect'] = false;
|
283 |
|
287 |
|
288 |
// Autoload
|
289 |
$register_args['autoload'] = true;
|
290 |
+
|
291 |
if(empty($autoload))
|
292 |
$register_args['autoload'] = false;
|
293 |
|
295 |
$option = acfe_settings('modules.dynamic_option.data');
|
296 |
|
297 |
// Create ACFE option
|
298 |
+
$option[$menu_slug] = $register_args;
|
299 |
|
300 |
// Sort keys ASC
|
301 |
ksort($option);
|
311 |
add_action('publish_to_trash', 'acfe_dop_filter_status_trash');
|
312 |
function acfe_dop_filter_status_trash($post){
|
313 |
|
314 |
+
if(get_post_type($post->ID) !== 'acfe-dop')
|
315 |
return;
|
316 |
|
317 |
$post_id = $post->ID;
|
318 |
+
$name = get_field('menu_slug', $post_id);
|
|
|
319 |
|
320 |
// Get ACFE option
|
321 |
$option = acfe_settings('modules.dynamic_option.data');
|
335 |
add_action('trash_to_publish', 'acfe_dop_filter_status_publish');
|
336 |
function acfe_dop_filter_status_publish($post){
|
337 |
|
338 |
+
if(get_post_type($post->ID) !== 'acfe-dop')
|
339 |
return;
|
340 |
|
341 |
acfe_dop_filter_save($post->ID);
|
342 |
|
343 |
}
|
344 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
/**
|
346 |
* Admin List Columns
|
347 |
*/
|
351 |
if(isset($columns['date']))
|
352 |
unset($columns['date']);
|
353 |
|
354 |
+
$columns['name'] = __('Menu slug');
|
355 |
$columns['post_id'] = __('Post ID');
|
356 |
$columns['autoload'] = __('Autoload');
|
357 |
|
368 |
// Name
|
369 |
if($column === 'name'){
|
370 |
|
371 |
+
$name = get_field('menu_slug', $post_id);
|
372 |
|
373 |
echo '<code style="font-size: 12px;">' . $name . '</code>';
|
374 |
|
408 |
if($post->post_type !== 'acfe-dop' || $post->post_status !== 'publish')
|
409 |
return $actions;
|
410 |
|
411 |
+
$name = get_field('menu_slug', $post->ID);
|
412 |
|
413 |
$actions['acfe_dop_export_php'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dop_export&action=php&keys=' . $name) . '">' . __('PHP') . '</a>';
|
414 |
$actions['acfe_dop_export_json'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dop_export&action=json&keys=' . $name) . '">' . __('Json') . '</a>';
|
418 |
}
|
419 |
|
420 |
/**
|
421 |
+
* Admin Add Config Button
|
422 |
*/
|
423 |
+
add_action('admin_footer', 'acfe_dop_admin_footer');
|
424 |
+
function acfe_dop_admin_footer(){
|
425 |
+
|
426 |
+
if(!current_user_can(acf_get_setting('capability')))
|
427 |
+
return;
|
428 |
+
|
429 |
+
global $plugin_page;
|
430 |
+
|
431 |
+
if(!$plugin_page)
|
432 |
+
return;
|
433 |
+
|
434 |
+
$page = acf_get_options_page($plugin_page);
|
435 |
+
|
436 |
+
if(!acf_maybe_get($page, 'menu_slug'))
|
437 |
+
return;
|
438 |
+
|
439 |
+
// Get Dynamic Options Page
|
440 |
+
$acfe_dop_options_page = get_posts(array(
|
441 |
+
'post_type' => 'acfe-dop',
|
442 |
+
'posts_per_page' => 1,
|
443 |
+
'name' => $page['menu_slug']
|
444 |
+
));
|
445 |
+
|
446 |
+
if(empty($acfe_dop_options_page))
|
447 |
+
return;
|
448 |
+
|
449 |
+
$acfe_dop_options_page = $acfe_dop_options_page[0];
|
450 |
+
|
451 |
+
?>
|
452 |
+
<script type="text/html" id="tmpl-acfe-dop-title-config">
|
453 |
+
<a href="<?php echo admin_url('post.php?post=' . $acfe_dop_options_page->ID . '&action=edit'); ?>" class="page-title-action acfe-dop-admin-config"><span class="dashicons dashicons-admin-generic"></span></a>
|
454 |
+
</script>
|
455 |
+
|
456 |
+
<script type="text/javascript">
|
457 |
+
(function($){
|
458 |
+
|
459 |
+
// Add button
|
460 |
+
$('.wrap h1').append($('#tmpl-acfe-dop-title-config').html());
|
461 |
+
|
462 |
+
})(jQuery);
|
463 |
+
</script>
|
464 |
+
<?php
|
465 |
+
|
466 |
+
}
|
467 |
+
|
468 |
+
add_filter('enter_title_here', 'acfe_dop_admin_placeholder_title', 10, 2);
|
469 |
+
function acfe_dop_admin_placeholder_title($placeholder, $post){
|
470 |
+
|
471 |
+
// Get post type
|
472 |
+
global $typenow;
|
473 |
+
|
474 |
+
// Check post type
|
475 |
+
$post_type = $typenow;
|
476 |
+
if($post_type !== 'acfe-dop')
|
477 |
+
return $placeholder;
|
478 |
+
|
479 |
+
return 'Options Page Title';
|
480 |
+
|
481 |
+
}
|
482 |
+
|
483 |
+
add_action('admin_footer-post.php', 'acfe_dop_admin_validate_title');
|
484 |
+
function acfe_dop_admin_validate_title(){
|
485 |
+
|
486 |
+
// Get post type
|
487 |
+
global $typenow;
|
488 |
+
|
489 |
+
// Check post type
|
490 |
+
$post_type = $typenow;
|
491 |
+
if($post_type !== 'acfe-dop')
|
492 |
+
return;
|
493 |
+
|
494 |
+
?>
|
495 |
+
<script type="text/javascript">
|
496 |
+
(function($){
|
497 |
+
|
498 |
+
if(typeof acf === 'undefined')
|
499 |
+
return;
|
500 |
+
|
501 |
+
$('#post').submit(function(e){
|
502 |
+
|
503 |
+
// vars
|
504 |
+
var $title = $('#titlewrap #title');
|
505 |
+
|
506 |
+
// empty
|
507 |
+
if(!$title.val()){
|
508 |
+
|
509 |
+
// prevent default
|
510 |
+
e.preventDefault();
|
511 |
+
|
512 |
+
// alert
|
513 |
+
alert('Options Page Title is required.');
|
514 |
+
|
515 |
+
// focus
|
516 |
+
$title.focus();
|
517 |
+
|
518 |
+
}
|
519 |
+
|
520 |
+
});
|
521 |
+
|
522 |
+
})(jQuery);
|
523 |
+
</script>
|
524 |
+
<?php
|
525 |
}
|
526 |
|
527 |
/**
|
528 |
+
* Admin Validate Name
|
529 |
*/
|
530 |
+
add_filter('acf/validate_value/key=field_acfe_dop_menu_slug', 'acfe_dop_admin_validate_name', 10, 4);
|
531 |
+
function acfe_dop_admin_validate_name($valid, $value, $field, $input){
|
532 |
+
|
533 |
+
if(!$valid)
|
534 |
+
return $valid;
|
535 |
+
|
536 |
+
// Editing Current Block Type
|
537 |
+
$current_post_id = acf_maybe_get_POST('post_ID');
|
538 |
+
|
539 |
+
if(!empty($current_post_id)){
|
540 |
+
|
541 |
+
$current_name = get_field($field['name'], $current_post_id);
|
542 |
+
|
543 |
+
if($value === $current_name)
|
544 |
+
return $valid;
|
545 |
+
|
546 |
+
}
|
547 |
+
|
548 |
+
// Check existing ACF Options Pages
|
549 |
+
$pages = acf_get_options_pages();
|
550 |
+
|
551 |
+
if(!empty($pages)){
|
552 |
+
|
553 |
+
foreach($pages as $slug => $page){
|
554 |
+
|
555 |
+
if($slug !== $value)
|
556 |
+
continue;
|
557 |
+
|
558 |
+
$valid = __('This options page slug already exists');
|
559 |
+
|
560 |
+
}
|
561 |
+
|
562 |
+
}
|
563 |
+
|
564 |
+
return $valid;
|
565 |
+
|
566 |
+
}
|
567 |
+
|
568 |
+
add_filter('acf/update_value/key=field_acfe_dop_menu_slug', 'acfe_dop_admin_update_name', 10, 3);
|
569 |
+
function acfe_dop_admin_update_name($value, $post_id, $field){
|
570 |
+
|
571 |
+
// Previous value
|
572 |
+
$_value = get_field($field['name'], $post_id);
|
573 |
+
|
574 |
+
// Value Changed. Delete option
|
575 |
+
if($_value !== $value){
|
576 |
+
|
577 |
+
acfe_settings()->delete('modules.dynamic_option.data.' . $_value);
|
578 |
+
|
579 |
+
}
|
580 |
+
|
581 |
+
return $value;
|
582 |
+
|
583 |
}
|
584 |
|
585 |
/**
|
609 |
'description' => '',
|
610 |
|
611 |
'fields' => array(
|
612 |
+
array(
|
613 |
+
'key' => 'field_acfe_dop_menu_slug',
|
614 |
+
'label' => 'Menu slug',
|
615 |
+
'name' => 'menu_slug',
|
616 |
+
'type' => 'acfe_slug',
|
617 |
+
'instructions' => '(string) The URL slug used to uniquely identify this options page. Defaults to a url friendly version of Menu Title',
|
618 |
+
'required' => 1,
|
619 |
+
'conditional_logic' => 0,
|
620 |
+
'wrapper' => array(
|
621 |
+
'width' => '',
|
622 |
+
'class' => '',
|
623 |
+
'id' => '',
|
624 |
+
),
|
625 |
+
'acfe_validate' => '',
|
626 |
+
'acfe_update' => array(
|
627 |
+
'5cd2a4d60fbf2' => array(
|
628 |
+
'acfe_update_function' => 'sanitize_title',
|
629 |
+
),
|
630 |
+
),
|
631 |
+
'acfe_permissions' => '',
|
632 |
+
'default_value' => '',
|
633 |
+
'placeholder' => '',
|
634 |
+
'prepend' => '',
|
635 |
+
'append' => '',
|
636 |
+
'maxlength' => '',
|
637 |
+
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
638 |
array(
|
639 |
'key' => 'field_acfe_dop_menu_title',
|
640 |
'label' => 'Menu title',
|
641 |
'name' => 'menu_title',
|
642 |
'type' => 'text',
|
643 |
+
'instructions' => '(string) The title displayed in the wp-admin sidebar. Defaults to Page Title',
|
644 |
'required' => 0,
|
645 |
'conditional_logic' => 0,
|
646 |
'wrapper' => array(
|
657 |
'append' => '',
|
658 |
'maxlength' => '',
|
659 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
660 |
array(
|
661 |
'key' => 'field_acfe_dop_capability',
|
662 |
'label' => 'Capability',
|
664 |
'type' => 'text',
|
665 |
'instructions' => '(string) The capability required for this menu to be displayed to the user. Defaults to edit_posts.<br /><br />
|
666 |
|
667 |
+
Read more about capability here: <a href="https://wordpress.org/support/article/roles-and-capabilities/">https://wordpress.org/support/article/roles-and-capabilities/</a>',
|
668 |
'required' => 0,
|
669 |
'conditional_logic' => 0,
|
670 |
'wrapper' => array(
|
865 |
'maxlength' => '',
|
866 |
),
|
867 |
),
|
868 |
+
));
|
includes/modules/dynamic-post-type.php
CHANGED
@@ -23,7 +23,7 @@ function acfe_dpt_register(){
|
|
23 |
'edit_item' => 'Edit Post Type',
|
24 |
'add_new_item' => 'New Post Type',
|
25 |
),
|
26 |
-
'supports' =>
|
27 |
'hierarchical' => false,
|
28 |
'public' => false,
|
29 |
'show_ui' => true,
|
@@ -46,7 +46,10 @@ function acfe_dpt_register(){
|
|
46 |
'edit_post' => acf_get_setting('capability'),
|
47 |
'delete_post' => acf_get_setting('capability'),
|
48 |
'read_post' => acf_get_setting('capability'),
|
49 |
-
)
|
|
|
|
|
|
|
50 |
));
|
51 |
|
52 |
}
|
@@ -82,7 +85,7 @@ function acfe_dpt_exclude($post_types, $args){
|
|
82 |
|
83 |
foreach($post_types as $k => $post_type){
|
84 |
|
85 |
-
if($post_type
|
86 |
continue;
|
87 |
|
88 |
unset($post_types[$k]);
|
@@ -118,18 +121,9 @@ function acfe_dpt_filter_save($post_id){
|
|
118 |
if(get_post_type($post_id) !== 'acfe-dpt')
|
119 |
return;
|
120 |
|
121 |
-
$title = get_field('label', $post_id);
|
122 |
-
$name = get_field('acfe_dpt_name', $post_id);
|
123 |
-
|
124 |
-
// Update post
|
125 |
-
wp_update_post(array(
|
126 |
-
'ID' => $post_id,
|
127 |
-
'post_title' => $title,
|
128 |
-
'post_name' => $name,
|
129 |
-
));
|
130 |
-
|
131 |
// Register Args
|
132 |
-
|
|
|
133 |
$description = get_field('description', $post_id);
|
134 |
$hierarchical = get_field('hierarchical', $post_id);
|
135 |
$supports = get_field('supports', $post_id);
|
@@ -288,6 +282,12 @@ function acfe_dpt_filter_save($post_id){
|
|
288 |
|
289 |
// Update ACFE option
|
290 |
acfe_settings('modules.dynamic_post_type.data', $option, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
|
292 |
// Flush permalinks
|
293 |
flush_rewrite_rules();
|
@@ -300,7 +300,7 @@ function acfe_dpt_filter_save($post_id){
|
|
300 |
add_action('publish_to_trash', 'acfe_dpt_filter_status_trash');
|
301 |
function acfe_dpt_filter_status_trash($post){
|
302 |
|
303 |
-
if(get_post_type($post->ID)
|
304 |
return;
|
305 |
|
306 |
$post_id = $post->ID;
|
@@ -327,52 +327,13 @@ function acfe_dpt_filter_status_trash($post){
|
|
327 |
add_action('trash_to_publish', 'acfe_dpt_filter_status_publish');
|
328 |
function acfe_dpt_filter_status_publish($post){
|
329 |
|
330 |
-
if(get_post_type($post->ID)
|
331 |
return;
|
332 |
|
333 |
acfe_dpt_filter_save($post->ID);
|
334 |
|
335 |
}
|
336 |
|
337 |
-
/**
|
338 |
-
* Dynamic Post Type Admin: List
|
339 |
-
*/
|
340 |
-
add_action('pre_get_posts', 'acfe_dpt_admin_pre_get_posts');
|
341 |
-
function acfe_dpt_admin_pre_get_posts($query){
|
342 |
-
|
343 |
-
if(!is_admin() || !$query->is_main_query())
|
344 |
-
return;
|
345 |
-
|
346 |
-
global $pagenow;
|
347 |
-
if($pagenow != 'edit.php')
|
348 |
-
return;
|
349 |
-
|
350 |
-
$post_type = $query->get('post_type');
|
351 |
-
if($post_type != 'acfe-dpt')
|
352 |
-
return;
|
353 |
-
|
354 |
-
$query->set('orderby', 'name');
|
355 |
-
$query->set('order', 'ASC');
|
356 |
-
|
357 |
-
}
|
358 |
-
|
359 |
-
/**
|
360 |
-
* Dynamic Post Type Admin: Posts Per Page
|
361 |
-
*/
|
362 |
-
add_filter('edit_posts_per_page', 'acfe_dpt_admin_ppp', 10, 2);
|
363 |
-
function acfe_dpt_admin_ppp($ppp, $post_type){
|
364 |
-
|
365 |
-
if($post_type != 'acfe-dpt')
|
366 |
-
return $ppp;
|
367 |
-
|
368 |
-
global $pagenow;
|
369 |
-
if($pagenow != 'edit.php')
|
370 |
-
return $ppp;
|
371 |
-
|
372 |
-
return 999;
|
373 |
-
|
374 |
-
}
|
375 |
-
|
376 |
/**
|
377 |
* Filter Admin: List
|
378 |
*/
|
@@ -406,7 +367,7 @@ add_filter('edit_posts_per_page', 'acfe_dpt_filter_admin_ppp', 10, 2);
|
|
406 |
function acfe_dpt_filter_admin_ppp($ppp, $post_type){
|
407 |
|
408 |
global $pagenow;
|
409 |
-
if($pagenow
|
410 |
return $ppp;
|
411 |
|
412 |
$post_type_obj = get_post_type_object($post_type);
|
@@ -656,20 +617,63 @@ function acfe_dpt_admin_footer(){
|
|
656 |
|
657 |
}
|
658 |
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
673 |
}
|
674 |
|
675 |
/**
|
@@ -712,34 +716,59 @@ function acfe_dpt_admin_validate_name($valid, $value, $field, $input){
|
|
712 |
|
713 |
);
|
714 |
|
|
|
715 |
if(in_array($value, $excludes))
|
716 |
return __('This post type name is reserved');
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
|
|
|
|
729 |
global $wp_post_types;
|
|
|
730 |
if(!empty($wp_post_types)){
|
|
|
731 |
foreach($wp_post_types as $post_type){
|
732 |
-
|
|
|
733 |
continue;
|
734 |
|
735 |
$valid = __('This post type name already exists');
|
|
|
736 |
}
|
|
|
737 |
}
|
738 |
|
739 |
return $valid;
|
740 |
|
741 |
}
|
742 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
743 |
/**
|
744 |
* Add Local Field Group
|
745 |
*/
|
@@ -784,31 +813,6 @@ acf_add_local_field_group(array(
|
|
784 |
'placement' => 'top',
|
785 |
'endpoint' => 0,
|
786 |
),
|
787 |
-
array(
|
788 |
-
'key' => 'field_acfe_dpt_label',
|
789 |
-
'label' => 'Label',
|
790 |
-
'name' => 'label',
|
791 |
-
'type' => 'text',
|
792 |
-
'instructions' => 'General name for the post type, usually plural. Default is Posts/Pages',
|
793 |
-
'required' => 1,
|
794 |
-
'conditional_logic' => 0,
|
795 |
-
'wrapper' => array(
|
796 |
-
'width' => '',
|
797 |
-
'class' => '',
|
798 |
-
'id' => '',
|
799 |
-
),
|
800 |
-
'acfe_validate' => '',
|
801 |
-
'acfe_update' => '',
|
802 |
-
'acfe_permissions' => '',
|
803 |
-
'user_roles' => array(
|
804 |
-
0 => 'all',
|
805 |
-
),
|
806 |
-
'default_value' => '',
|
807 |
-
'placeholder' => '',
|
808 |
-
'prepend' => '',
|
809 |
-
'append' => '',
|
810 |
-
'maxlength' => '',
|
811 |
-
),
|
812 |
array(
|
813 |
'key' => 'field_acfe_dpt_name',
|
814 |
'label' => 'Name',
|
23 |
'edit_item' => 'Edit Post Type',
|
24 |
'add_new_item' => 'New Post Type',
|
25 |
),
|
26 |
+
'supports' => array('title'),
|
27 |
'hierarchical' => false,
|
28 |
'public' => false,
|
29 |
'show_ui' => true,
|
46 |
'edit_post' => acf_get_setting('capability'),
|
47 |
'delete_post' => acf_get_setting('capability'),
|
48 |
'read_post' => acf_get_setting('capability'),
|
49 |
+
),
|
50 |
+
'acfe_admin_orderby' => 'title',
|
51 |
+
'acfe_admin_order' => 'ASC',
|
52 |
+
'acfe_admin_ppp' => 999,
|
53 |
));
|
54 |
|
55 |
}
|
85 |
|
86 |
foreach($post_types as $k => $post_type){
|
87 |
|
88 |
+
if($post_type !== 'acfe-dpt')
|
89 |
continue;
|
90 |
|
91 |
unset($post_types[$k]);
|
121 |
if(get_post_type($post_id) !== 'acfe-dpt')
|
122 |
return;
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
// Register Args
|
125 |
+
$label = get_post_field('post_title', $post_id);
|
126 |
+
$name = get_field('acfe_dpt_name', $post_id);
|
127 |
$description = get_field('description', $post_id);
|
128 |
$hierarchical = get_field('hierarchical', $post_id);
|
129 |
$supports = get_field('supports', $post_id);
|
282 |
|
283 |
// Update ACFE option
|
284 |
acfe_settings('modules.dynamic_post_type.data', $option, true);
|
285 |
+
|
286 |
+
// Update post
|
287 |
+
wp_update_post(array(
|
288 |
+
'ID' => $post_id,
|
289 |
+
'post_name' => $name,
|
290 |
+
));
|
291 |
|
292 |
// Flush permalinks
|
293 |
flush_rewrite_rules();
|
300 |
add_action('publish_to_trash', 'acfe_dpt_filter_status_trash');
|
301 |
function acfe_dpt_filter_status_trash($post){
|
302 |
|
303 |
+
if(get_post_type($post->ID) !== 'acfe-dpt')
|
304 |
return;
|
305 |
|
306 |
$post_id = $post->ID;
|
327 |
add_action('trash_to_publish', 'acfe_dpt_filter_status_publish');
|
328 |
function acfe_dpt_filter_status_publish($post){
|
329 |
|
330 |
+
if(get_post_type($post->ID) !== 'acfe-dpt')
|
331 |
return;
|
332 |
|
333 |
acfe_dpt_filter_save($post->ID);
|
334 |
|
335 |
}
|
336 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
337 |
/**
|
338 |
* Filter Admin: List
|
339 |
*/
|
367 |
function acfe_dpt_filter_admin_ppp($ppp, $post_type){
|
368 |
|
369 |
global $pagenow;
|
370 |
+
if($pagenow !== 'edit.php')
|
371 |
return $ppp;
|
372 |
|
373 |
$post_type_obj = get_post_type_object($post_type);
|
617 |
|
618 |
}
|
619 |
|
620 |
+
add_filter('enter_title_here', 'acfe_dpt_admin_placeholder_title', 10, 2);
|
621 |
+
function acfe_dpt_admin_placeholder_title($placeholder, $post){
|
622 |
+
|
623 |
+
// Get post type
|
624 |
+
global $typenow;
|
625 |
+
|
626 |
+
// Check post type
|
627 |
+
$post_type = $typenow;
|
628 |
+
if($post_type !== 'acfe-dpt')
|
629 |
+
return $placeholder;
|
630 |
+
|
631 |
+
return 'Post Type Label';
|
632 |
+
|
633 |
+
}
|
634 |
+
|
635 |
+
add_action('admin_footer-post.php', 'acfe_dpt_admin_validate_title');
|
636 |
+
function acfe_dpt_admin_validate_title(){
|
637 |
+
|
638 |
+
// Get post type
|
639 |
+
global $typenow;
|
640 |
+
|
641 |
+
// Check post type
|
642 |
+
$post_type = $typenow;
|
643 |
+
if($post_type !== 'acfe-dpt')
|
644 |
+
return;
|
645 |
+
|
646 |
+
?>
|
647 |
+
<script type="text/javascript">
|
648 |
+
(function($){
|
649 |
+
|
650 |
+
if(typeof acf === 'undefined')
|
651 |
+
return;
|
652 |
+
|
653 |
+
$('#post').submit(function(e){
|
654 |
+
|
655 |
+
// vars
|
656 |
+
var $title = $('#titlewrap #title');
|
657 |
+
|
658 |
+
// empty
|
659 |
+
if(!$title.val()){
|
660 |
+
|
661 |
+
// prevent default
|
662 |
+
e.preventDefault();
|
663 |
+
|
664 |
+
// alert
|
665 |
+
alert('Post Type Label is required.');
|
666 |
+
|
667 |
+
// focus
|
668 |
+
$title.focus();
|
669 |
+
|
670 |
+
}
|
671 |
+
|
672 |
+
});
|
673 |
+
|
674 |
+
})(jQuery);
|
675 |
+
</script>
|
676 |
+
<?php
|
677 |
}
|
678 |
|
679 |
/**
|
716 |
|
717 |
);
|
718 |
|
719 |
+
// Reserved Names
|
720 |
if(in_array($value, $excludes))
|
721 |
return __('This post type name is reserved');
|
722 |
+
|
723 |
+
// Editing Current Dynamic Post Type
|
724 |
+
$current_post_id = acf_maybe_get_POST('post_ID');
|
725 |
+
|
726 |
+
if(!empty($current_post_id)){
|
727 |
+
|
728 |
+
$current_name = get_field($field['name'], $current_post_id);
|
729 |
+
|
730 |
+
if($value === $current_name)
|
731 |
+
return $valid;
|
732 |
+
|
733 |
+
}
|
734 |
+
|
735 |
+
// Check existing WP Post Types
|
736 |
global $wp_post_types;
|
737 |
+
|
738 |
if(!empty($wp_post_types)){
|
739 |
+
|
740 |
foreach($wp_post_types as $post_type){
|
741 |
+
|
742 |
+
if($value !== $post_type->name)
|
743 |
continue;
|
744 |
|
745 |
$valid = __('This post type name already exists');
|
746 |
+
|
747 |
}
|
748 |
+
|
749 |
}
|
750 |
|
751 |
return $valid;
|
752 |
|
753 |
}
|
754 |
|
755 |
+
add_filter('acf/update_value/name=acfe_dpt_name', 'acfe_dpt_admin_update_name', 10, 3);
|
756 |
+
function acfe_dpt_admin_update_name($value, $post_id, $field){
|
757 |
+
|
758 |
+
// Previous value
|
759 |
+
$_value = get_field($field['name'], $post_id);
|
760 |
+
|
761 |
+
// Value Changed. Delete option
|
762 |
+
if($_value !== $value){
|
763 |
+
|
764 |
+
acfe_settings()->delete('modules.dynamic_post_type.data.' . $_value);
|
765 |
+
|
766 |
+
}
|
767 |
+
|
768 |
+
return $value;
|
769 |
+
|
770 |
+
}
|
771 |
+
|
772 |
/**
|
773 |
* Add Local Field Group
|
774 |
*/
|
813 |
'placement' => 'top',
|
814 |
'endpoint' => 0,
|
815 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
816 |
array(
|
817 |
'key' => 'field_acfe_dpt_name',
|
818 |
'label' => 'Name',
|
includes/modules/dynamic-taxonomy.php
CHANGED
@@ -23,7 +23,7 @@ function acfe_dt_register(){
|
|
23 |
'edit_item' => 'Edit Taxonomy',
|
24 |
'add_new_item' => 'New Taxonomy',
|
25 |
),
|
26 |
-
'supports' =>
|
27 |
'hierarchical' => false,
|
28 |
'public' => false,
|
29 |
'show_ui' => true,
|
@@ -46,7 +46,10 @@ function acfe_dt_register(){
|
|
46 |
'edit_post' => acf_get_setting('capability'),
|
47 |
'delete_post' => acf_get_setting('capability'),
|
48 |
'read_post' => acf_get_setting('capability'),
|
49 |
-
)
|
|
|
|
|
|
|
50 |
));
|
51 |
|
52 |
}
|
@@ -88,7 +91,7 @@ function acfe_dt_exclude($post_types, $args){
|
|
88 |
|
89 |
foreach($post_types as $k => $post_type){
|
90 |
|
91 |
-
if($post_type
|
92 |
continue;
|
93 |
|
94 |
unset($post_types[$k]);
|
@@ -124,18 +127,9 @@ function acfe_dt_filter_save($post_id){
|
|
124 |
if(get_post_type($post_id) !== 'acfe-dt')
|
125 |
return;
|
126 |
|
127 |
-
$title = get_field('label', $post_id);
|
128 |
-
$name = get_field('acfe_dt_name', $post_id);
|
129 |
-
|
130 |
-
// Update post
|
131 |
-
wp_update_post(array(
|
132 |
-
'ID' => $post_id,
|
133 |
-
'post_title' => $title,
|
134 |
-
'post_name' => $name,
|
135 |
-
));
|
136 |
-
|
137 |
// Register Args
|
138 |
-
|
|
|
139 |
$description = get_field('description', $post_id);
|
140 |
$hierarchical = get_field('hierarchical', $post_id);
|
141 |
$post_types = get_field('post_types', $post_id);
|
@@ -262,6 +256,12 @@ function acfe_dt_filter_save($post_id){
|
|
262 |
|
263 |
// Update ACFE option
|
264 |
acfe_settings('modules.dynamic_taxonomy.data', $option, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
|
266 |
// Flush permalinks
|
267 |
flush_rewrite_rules();
|
@@ -274,7 +274,7 @@ function acfe_dt_filter_save($post_id){
|
|
274 |
add_action('publish_to_trash', 'acfe_dt_filter_status_trash');
|
275 |
function acfe_dt_filter_status_trash($post){
|
276 |
|
277 |
-
if(get_post_type($post->ID)
|
278 |
return;
|
279 |
|
280 |
$post_id = $post->ID;
|
@@ -301,52 +301,13 @@ function acfe_dt_filter_status_trash($post){
|
|
301 |
add_action('trash_to_publish', 'acfe_dt_filter_status_publish');
|
302 |
function acfe_dt_filter_status_publish($post){
|
303 |
|
304 |
-
if(get_post_type($post->ID)
|
305 |
return;
|
306 |
|
307 |
acfe_dt_filter_save($post->ID);
|
308 |
|
309 |
}
|
310 |
|
311 |
-
/**
|
312 |
-
* Dynamic Taxonomy Admin: List
|
313 |
-
*/
|
314 |
-
add_action('pre_get_posts', 'acfe_dt_admin_pre_get_posts');
|
315 |
-
function acfe_dt_admin_pre_get_posts($query){
|
316 |
-
|
317 |
-
if(!is_admin() || !$query->is_main_query())
|
318 |
-
return;
|
319 |
-
|
320 |
-
global $pagenow;
|
321 |
-
if($pagenow != 'edit.php')
|
322 |
-
return;
|
323 |
-
|
324 |
-
$post_type = $query->get('post_type');
|
325 |
-
if($post_type != 'acfe-dt')
|
326 |
-
return;
|
327 |
-
|
328 |
-
$query->set('orderby', 'name');
|
329 |
-
$query->set('order', 'ASC');
|
330 |
-
|
331 |
-
}
|
332 |
-
|
333 |
-
/**
|
334 |
-
* Dynamic Taxonomy Admin: Posts Per Page
|
335 |
-
*/
|
336 |
-
add_filter('edit_posts_per_page', 'acfe_dt_admin_ppp', 10, 2);
|
337 |
-
function acfe_dt_admin_ppp($ppp, $post_type){
|
338 |
-
|
339 |
-
if($post_type != 'acfe-dt')
|
340 |
-
return $ppp;
|
341 |
-
|
342 |
-
global $pagenow;
|
343 |
-
if($pagenow != 'edit.php')
|
344 |
-
return $ppp;
|
345 |
-
|
346 |
-
return 999;
|
347 |
-
|
348 |
-
}
|
349 |
-
|
350 |
/**
|
351 |
* Filter Admin: List
|
352 |
*/
|
@@ -357,7 +318,7 @@ function acfe_dt_filter_admin_list($args, $taxonomies){
|
|
357 |
return $args;
|
358 |
|
359 |
global $pagenow;
|
360 |
-
if($pagenow
|
361 |
return $args;
|
362 |
|
363 |
if(empty($taxonomies))
|
@@ -385,7 +346,7 @@ function acfe_dt_filter_admin_list($args, $taxonomies){
|
|
385 |
function acfe_dt_filter_admin_ppp($ppp){
|
386 |
|
387 |
global $pagenow;
|
388 |
-
if($pagenow
|
389 |
return $ppp;
|
390 |
|
391 |
$taxonomy = $_GET['taxonomy'];
|
@@ -451,7 +412,7 @@ function acfe_dt_filter_template($template){
|
|
451 |
$taxonomy_obj = get_queried_object()->taxonomy;
|
452 |
|
453 |
foreach(get_taxonomies(array('public' => true), 'objects') as $taxonomy){
|
454 |
-
if($taxonomy_obj
|
455 |
continue;
|
456 |
|
457 |
if($locate = locate_template(array($taxonomy->acfe_single_template)))
|
@@ -570,19 +531,107 @@ function acfe_dt_admin_row($actions, $post){
|
|
570 |
}
|
571 |
|
572 |
/**
|
573 |
-
* Admin
|
574 |
*/
|
575 |
-
|
576 |
-
function
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
586 |
}
|
587 |
|
588 |
/**
|
@@ -683,81 +732,57 @@ function acfe_dt_admin_validate_name($valid, $value, $field, $input){
|
|
683 |
|
684 |
);
|
685 |
|
|
|
686 |
if(in_array($value, $excludes))
|
687 |
return __('This taxonomy name is reserved');
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
|
|
|
|
700 |
global $wp_taxonomies;
|
701 |
|
702 |
if(!empty($wp_taxonomies)){
|
703 |
|
704 |
foreach($wp_taxonomies as $taxonomy){
|
705 |
|
706 |
-
if($value
|
707 |
continue;
|
708 |
|
709 |
$valid = __('This taxonomy name already exists');
|
710 |
|
711 |
}
|
|
|
712 |
}
|
713 |
|
714 |
return $valid;
|
715 |
|
716 |
}
|
717 |
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
return;
|
734 |
-
|
735 |
-
// Taxonomy object
|
736 |
-
$taxonomy_obj = get_taxonomy($taxonomy);
|
737 |
-
if(!isset($taxonomy_obj->acfe_admin_ppp))
|
738 |
-
return;
|
739 |
-
|
740 |
-
// Get Dynamic Post Type Post
|
741 |
-
$acfe_dt_post_type = get_page_by_path($taxonomy, 'OBJECT', 'acfe-dt');
|
742 |
-
|
743 |
-
if(empty($acfe_dt_post_type))
|
744 |
-
return;
|
745 |
-
|
746 |
-
?>
|
747 |
-
<script type="text/html" id="tmpl-acfe-dt-title-config">
|
748 |
-
<a href="<?php echo admin_url('post.php?post=' . $acfe_dt_post_type->ID . '&action=edit'); ?>" class="page-title-action acfe-dt-admin-config"><span class="dashicons dashicons-admin-generic"></span></a>
|
749 |
-
</script>
|
750 |
-
|
751 |
-
<script type="text/javascript">
|
752 |
-
(function($){
|
753 |
-
|
754 |
-
// Add button
|
755 |
-
$('.wrap .wp-heading-inline').after($('#tmpl-acfe-dt-title-config').html());
|
756 |
-
|
757 |
-
})(jQuery);
|
758 |
-
</script>
|
759 |
-
<?php
|
760 |
-
|
761 |
}
|
762 |
|
763 |
/**
|
@@ -804,28 +829,6 @@ acf_add_local_field_group(array(
|
|
804 |
'placement' => 'top',
|
805 |
'endpoint' => 0,
|
806 |
),
|
807 |
-
array(
|
808 |
-
'key' => 'field_acfe_dt_label',
|
809 |
-
'label' => 'Label',
|
810 |
-
'name' => 'label',
|
811 |
-
'type' => 'text',
|
812 |
-
'instructions' => 'A plural descriptive name for the taxonomy marked for translation',
|
813 |
-
'required' => 1,
|
814 |
-
'conditional_logic' => 0,
|
815 |
-
'wrapper' => array(
|
816 |
-
'width' => '',
|
817 |
-
'class' => '',
|
818 |
-
'id' => '',
|
819 |
-
),
|
820 |
-
'acfe_validate' => '',
|
821 |
-
'acfe_update' => '',
|
822 |
-
'acfe_permissions' => '',
|
823 |
-
'default_value' => '',
|
824 |
-
'placeholder' => '',
|
825 |
-
'prepend' => '',
|
826 |
-
'append' => '',
|
827 |
-
'maxlength' => '',
|
828 |
-
),
|
829 |
array(
|
830 |
'key' => 'field_acfe_dt_name',
|
831 |
'label' => 'Name',
|
23 |
'edit_item' => 'Edit Taxonomy',
|
24 |
'add_new_item' => 'New Taxonomy',
|
25 |
),
|
26 |
+
'supports' => array('title'),
|
27 |
'hierarchical' => false,
|
28 |
'public' => false,
|
29 |
'show_ui' => true,
|
46 |
'edit_post' => acf_get_setting('capability'),
|
47 |
'delete_post' => acf_get_setting('capability'),
|
48 |
'read_post' => acf_get_setting('capability'),
|
49 |
+
),
|
50 |
+
'acfe_admin_orderby' => 'title',
|
51 |
+
'acfe_admin_order' => 'ASC',
|
52 |
+
'acfe_admin_ppp' => 999,
|
53 |
));
|
54 |
|
55 |
}
|
91 |
|
92 |
foreach($post_types as $k => $post_type){
|
93 |
|
94 |
+
if($post_type !== 'acfe-dt')
|
95 |
continue;
|
96 |
|
97 |
unset($post_types[$k]);
|
127 |
if(get_post_type($post_id) !== 'acfe-dt')
|
128 |
return;
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
// Register Args
|
131 |
+
$label = get_post_field('post_title', $post_id);
|
132 |
+
$name = get_field('acfe_dt_name', $post_id);
|
133 |
$description = get_field('description', $post_id);
|
134 |
$hierarchical = get_field('hierarchical', $post_id);
|
135 |
$post_types = get_field('post_types', $post_id);
|
256 |
|
257 |
// Update ACFE option
|
258 |
acfe_settings('modules.dynamic_taxonomy.data', $option, true);
|
259 |
+
|
260 |
+
// Update post
|
261 |
+
wp_update_post(array(
|
262 |
+
'ID' => $post_id,
|
263 |
+
'post_name' => $name,
|
264 |
+
));
|
265 |
|
266 |
// Flush permalinks
|
267 |
flush_rewrite_rules();
|
274 |
add_action('publish_to_trash', 'acfe_dt_filter_status_trash');
|
275 |
function acfe_dt_filter_status_trash($post){
|
276 |
|
277 |
+
if(get_post_type($post->ID) !== 'acfe-dt')
|
278 |
return;
|
279 |
|
280 |
$post_id = $post->ID;
|
301 |
add_action('trash_to_publish', 'acfe_dt_filter_status_publish');
|
302 |
function acfe_dt_filter_status_publish($post){
|
303 |
|
304 |
+
if(get_post_type($post->ID) !== 'acfe-dt')
|
305 |
return;
|
306 |
|
307 |
acfe_dt_filter_save($post->ID);
|
308 |
|
309 |
}
|
310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
/**
|
312 |
* Filter Admin: List
|
313 |
*/
|
318 |
return $args;
|
319 |
|
320 |
global $pagenow;
|
321 |
+
if($pagenow !== 'edit-tags.php')
|
322 |
return $args;
|
323 |
|
324 |
if(empty($taxonomies))
|
346 |
function acfe_dt_filter_admin_ppp($ppp){
|
347 |
|
348 |
global $pagenow;
|
349 |
+
if($pagenow !== 'edit-tags.php')
|
350 |
return $ppp;
|
351 |
|
352 |
$taxonomy = $_GET['taxonomy'];
|
412 |
$taxonomy_obj = get_queried_object()->taxonomy;
|
413 |
|
414 |
foreach(get_taxonomies(array('public' => true), 'objects') as $taxonomy){
|
415 |
+
if($taxonomy_obj !== $taxonomy->name || !isset($taxonomy->acfe_single_template))
|
416 |
continue;
|
417 |
|
418 |
if($locate = locate_template(array($taxonomy->acfe_single_template)))
|
531 |
}
|
532 |
|
533 |
/**
|
534 |
+
* Admin Add Config Button
|
535 |
*/
|
536 |
+
add_action('admin_footer-edit-tags.php', 'acfe_dt_admin_footer', 99);
|
537 |
+
function acfe_dt_admin_footer(){
|
538 |
+
|
539 |
+
if(!current_user_can(acf_get_setting('capability')))
|
540 |
+
return;
|
541 |
+
|
542 |
+
// Get taxonomy
|
543 |
+
global $taxnow;
|
544 |
+
|
545 |
+
// Check taxonomy
|
546 |
+
$taxonomy = $taxnow;
|
547 |
+
if(empty($taxonomy))
|
548 |
+
return;
|
549 |
+
|
550 |
+
// Taxonomy object
|
551 |
+
$taxonomy_obj = get_taxonomy($taxonomy);
|
552 |
+
if(!isset($taxonomy_obj->acfe_admin_ppp))
|
553 |
+
return;
|
554 |
+
|
555 |
+
// Get Dynamic Post Type Post
|
556 |
+
$acfe_dt_post_type = get_page_by_path($taxonomy, 'OBJECT', 'acfe-dt');
|
557 |
+
|
558 |
+
if(empty($acfe_dt_post_type))
|
559 |
+
return;
|
560 |
+
|
561 |
+
?>
|
562 |
+
<script type="text/html" id="tmpl-acfe-dt-title-config">
|
563 |
+
<a href="<?php echo admin_url('post.php?post=' . $acfe_dt_post_type->ID . '&action=edit'); ?>" class="page-title-action acfe-dt-admin-config"><span class="dashicons dashicons-admin-generic"></span></a>
|
564 |
+
</script>
|
565 |
+
|
566 |
+
<script type="text/javascript">
|
567 |
+
(function($){
|
568 |
+
|
569 |
+
// Add button
|
570 |
+
$('.wrap .wp-heading-inline').after($('#tmpl-acfe-dt-title-config').html());
|
571 |
+
|
572 |
+
})(jQuery);
|
573 |
+
</script>
|
574 |
+
<?php
|
575 |
+
|
576 |
+
}
|
577 |
+
|
578 |
+
add_filter('enter_title_here', 'acfe_dt_admin_placeholder_title', 10, 2);
|
579 |
+
function acfe_dt_admin_placeholder_title($placeholder, $post){
|
580 |
+
|
581 |
+
// Get post type
|
582 |
+
global $typenow;
|
583 |
+
|
584 |
+
// Check post type
|
585 |
+
$post_type = $typenow;
|
586 |
+
if($post_type !== 'acfe-dt')
|
587 |
+
return $placeholder;
|
588 |
+
|
589 |
+
return 'Taxonomy Name';
|
590 |
+
|
591 |
+
}
|
592 |
+
|
593 |
+
add_action('admin_footer-post.php', 'acfe_dt_admin_validate_title');
|
594 |
+
function acfe_dt_admin_validate_title(){
|
595 |
+
|
596 |
+
// Get post type
|
597 |
+
global $typenow;
|
598 |
+
|
599 |
+
// Check post type
|
600 |
+
$post_type = $typenow;
|
601 |
+
if($post_type !== 'acfe-dt')
|
602 |
+
return;
|
603 |
+
|
604 |
+
?>
|
605 |
+
<script type="text/javascript">
|
606 |
+
(function($){
|
607 |
+
|
608 |
+
if(typeof acf === 'undefined')
|
609 |
+
return;
|
610 |
+
|
611 |
+
$('#post').submit(function(e){
|
612 |
+
|
613 |
+
// vars
|
614 |
+
var $title = $('#titlewrap #title');
|
615 |
+
|
616 |
+
// empty
|
617 |
+
if(!$title.val()){
|
618 |
+
|
619 |
+
// prevent default
|
620 |
+
e.preventDefault();
|
621 |
+
|
622 |
+
// alert
|
623 |
+
alert('Taxonomy Name is required.');
|
624 |
+
|
625 |
+
// focus
|
626 |
+
$title.focus();
|
627 |
+
|
628 |
+
}
|
629 |
+
|
630 |
+
});
|
631 |
+
|
632 |
+
})(jQuery);
|
633 |
+
</script>
|
634 |
+
<?php
|
635 |
}
|
636 |
|
637 |
/**
|
732 |
|
733 |
);
|
734 |
|
735 |
+
// Reserved Names
|
736 |
if(in_array($value, $excludes))
|
737 |
return __('This taxonomy name is reserved');
|
738 |
+
|
739 |
+
// Editing Current Dynamic Taxonomy
|
740 |
+
$current_post_id = acf_maybe_get_POST('post_ID');
|
741 |
+
|
742 |
+
if(!empty($current_post_id)){
|
743 |
+
|
744 |
+
$current_name = get_field($field['name'], $current_post_id);
|
745 |
+
|
746 |
+
if($value === $current_name)
|
747 |
+
return $valid;
|
748 |
+
|
749 |
+
}
|
750 |
+
|
751 |
+
// Check existing WP Taxonomies
|
752 |
global $wp_taxonomies;
|
753 |
|
754 |
if(!empty($wp_taxonomies)){
|
755 |
|
756 |
foreach($wp_taxonomies as $taxonomy){
|
757 |
|
758 |
+
if($value !== $taxonomy->name)
|
759 |
continue;
|
760 |
|
761 |
$valid = __('This taxonomy name already exists');
|
762 |
|
763 |
}
|
764 |
+
|
765 |
}
|
766 |
|
767 |
return $valid;
|
768 |
|
769 |
}
|
770 |
|
771 |
+
add_filter('acf/update_value/name=acfe_dt_name', 'acfe_dt_admin_update_name', 10, 3);
|
772 |
+
function acfe_dt_admin_update_name($value, $post_id, $field){
|
773 |
+
|
774 |
+
// Previous value
|
775 |
+
$_value = get_field($field['name'], $post_id);
|
776 |
+
|
777 |
+
// Value Changed. Delete option
|
778 |
+
if($_value !== $value){
|
779 |
+
|
780 |
+
acfe_settings()->delete('modules.dynamic_taxonomy.data.' . $_value);
|
781 |
+
|
782 |
+
}
|
783 |
+
|
784 |
+
return $value;
|
785 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
786 |
}
|
787 |
|
788 |
/**
|
829 |
'placement' => 'top',
|
830 |
'endpoint' => 0,
|
831 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
832 |
array(
|
833 |
'key' => 'field_acfe_dt_name',
|
834 |
'label' => 'Name',
|
includes/modules/form/actions/post.php
CHANGED
@@ -586,6 +586,36 @@ class acfe_form_post{
|
|
586 |
$post_object['permalink'] = get_permalink($_post_id);
|
587 |
$post_object['admin_url'] = admin_url('post.php?post=' . $_post_id . '&action=edit');
|
588 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
589 |
$post_object = apply_filters('acfe/form/query_var/post', $post_object, $_post_id, $post_action, $args, $form, $action);
|
590 |
$post_object = apply_filters('acfe/form/query_var/post/form=' . $form_name, $post_object, $_post_id, $post_action, $args, $form, $action);
|
591 |
$post_object = apply_filters('acfe/form/query_var/post/action=' . $action, $post_object, $_post_id, $post_action, $args, $form, $action);
|
586 |
$post_object['permalink'] = get_permalink($_post_id);
|
587 |
$post_object['admin_url'] = admin_url('post.php?post=' . $_post_id . '&action=edit');
|
588 |
|
589 |
+
// Retrieve Post Author data
|
590 |
+
$post_author = $post_object['post_author'];
|
591 |
+
$user_object = get_user_by('ID', $post_author);
|
592 |
+
|
593 |
+
if(isset($user_object->data)){
|
594 |
+
|
595 |
+
$user = json_decode(json_encode($user_object->data), true);
|
596 |
+
|
597 |
+
$user_object_meta = get_user_meta($user['ID']);
|
598 |
+
|
599 |
+
$user_meta = array();
|
600 |
+
|
601 |
+
foreach($user_object_meta as $k => $v){
|
602 |
+
|
603 |
+
if(!isset($v[0]))
|
604 |
+
continue;
|
605 |
+
|
606 |
+
$user_meta[$k] = $v[0];
|
607 |
+
|
608 |
+
}
|
609 |
+
|
610 |
+
$user_array = array_merge($user, $user_meta);
|
611 |
+
|
612 |
+
$user_array['permalink'] = get_author_posts_url($post_author);
|
613 |
+
$user_array['admin_url'] = admin_url('user-edit.php?user_id=' . $post_author);
|
614 |
+
|
615 |
+
$post_object['post_author_data'] = $user_array;
|
616 |
+
|
617 |
+
}
|
618 |
+
|
619 |
$post_object = apply_filters('acfe/form/query_var/post', $post_object, $_post_id, $post_action, $args, $form, $action);
|
620 |
$post_object = apply_filters('acfe/form/query_var/post/form=' . $form_name, $post_object, $_post_id, $post_action, $args, $form, $action);
|
621 |
$post_object = apply_filters('acfe/form/query_var/post/action=' . $action, $post_object, $_post_id, $post_action, $args, $form, $action);
|
includes/modules/form/actions/user.php
CHANGED
@@ -816,6 +816,13 @@ class acfe_form_user{
|
|
816 |
|
817 |
$user_array['permalink'] = get_author_posts_url($_user_id);
|
818 |
$user_array['admin_url'] = admin_url('user-edit.php?user_id=' . $_user_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
819 |
|
820 |
$user_array = apply_filters('acfe/form/query_var/user', $user_array, $_user_id, $user_action, $args, $form, $action);
|
821 |
$user_array = apply_filters('acfe/form/query_var/user/form=' . $form_name, $user_array, $_user_id, $user_action, $args, $form, $action);
|
816 |
|
817 |
$user_array['permalink'] = get_author_posts_url($_user_id);
|
818 |
$user_array['admin_url'] = admin_url('user-edit.php?user_id=' . $_user_id);
|
819 |
+
|
820 |
+
// Replace the hash password with the real password
|
821 |
+
if(acf_maybe_get($args, 'user_pass')){
|
822 |
+
|
823 |
+
$user_array['user_pass'] = $args['user_pass'];
|
824 |
+
|
825 |
+
}
|
826 |
|
827 |
$user_array = apply_filters('acfe/form/query_var/user', $user_array, $_user_id, $user_action, $args, $form, $action);
|
828 |
$user_array = apply_filters('acfe/form/query_var/user/form=' . $form_name, $user_array, $_user_id, $user_action, $args, $form, $action);
|
includes/modules/form/admin.php
CHANGED
@@ -57,7 +57,9 @@ class acfe_form{
|
|
57 |
add_action('acf/render_field/name=acfe_form_cheatsheet_field', array($this, 'doc_field'));
|
58 |
add_action('acf/render_field/name=acfe_form_cheatsheet_fields', array($this, 'doc_fields'));
|
59 |
add_action('acf/render_field/name=acfe_form_cheatsheet_get_field', array($this, 'doc_get_field'));
|
|
|
60 |
add_action('acf/render_field/name=acfe_form_cheatsheet_query_var', array($this, 'doc_query_var'));
|
|
|
61 |
add_action('acf/render_field/name=acfe_form_cheatsheet_current_post', array($this, 'doc_current_post'));
|
62 |
add_action('acf/render_field/name=acfe_form_cheatsheet_current_term', array($this, 'doc_current_term'));
|
63 |
add_action('acf/render_field/name=acfe_form_cheatsheet_current_user', array($this, 'doc_current_user'));
|
@@ -171,96 +173,100 @@ class acfe_form{
|
|
171 |
add_action('post_submitbox_misc_actions', array($this, 'misc_actions'));
|
172 |
|
173 |
// Actions
|
174 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
-
|
177 |
-
|
178 |
-
while(have_rows('acfe_form_actions', $form_id)): the_row();
|
179 |
-
|
180 |
-
$action = get_row_layout();
|
181 |
-
|
182 |
-
// Custom Action
|
183 |
-
if($action === 'custom')
|
184 |
-
continue;
|
185 |
-
|
186 |
-
$alias = get_sub_field('acfe_form_custom_alias');
|
187 |
-
$query_var = get_sub_field('acfe_form_custom_query_var');
|
188 |
-
|
189 |
-
$action_label = '';
|
190 |
-
$action_type = '';
|
191 |
-
|
192 |
-
if($action === 'post'){
|
193 |
-
|
194 |
-
$action_label = 'Post';
|
195 |
-
|
196 |
-
$post_action = get_sub_field('acfe_form_post_action');
|
197 |
-
|
198 |
-
if($post_action === 'insert_post'){
|
199 |
-
|
200 |
-
$action_type = 'Create Post';
|
201 |
-
|
202 |
-
}elseif($post_action === 'update_post'){
|
203 |
-
|
204 |
-
$action_type = 'Update Post';
|
205 |
-
|
206 |
-
}
|
207 |
-
|
208 |
-
|
209 |
-
}elseif($action === 'term'){
|
210 |
-
|
211 |
-
$action_label = 'Term';
|
212 |
-
|
213 |
-
$term_action = get_sub_field('acfe_form_term_action');
|
214 |
-
|
215 |
-
if($term_action === 'insert_term'){
|
216 |
-
|
217 |
-
$action_type = 'Create Term';
|
218 |
-
|
219 |
-
}elseif($term_action === 'update_term'){
|
220 |
-
|
221 |
-
$action_type = 'Update Term';
|
222 |
-
|
223 |
-
}
|
224 |
-
|
225 |
-
}elseif($action === 'user'){
|
226 |
-
|
227 |
-
$action_label = 'User';
|
228 |
-
|
229 |
-
$term_action = get_sub_field('acfe_form_user_action');
|
230 |
-
|
231 |
-
if($term_action === 'insert_user'){
|
232 |
-
|
233 |
-
$action_type = 'Create User';
|
234 |
-
|
235 |
-
}elseif($term_action === 'update_user'){
|
236 |
-
|
237 |
-
$action_type = 'Update User';
|
238 |
-
|
239 |
-
}elseif($term_action === 'log_user'){
|
240 |
-
|
241 |
-
$action_type = 'Log User';
|
242 |
-
|
243 |
-
}
|
244 |
-
|
245 |
-
}elseif($action === 'email'){
|
246 |
-
|
247 |
-
$action_label = 'E-mail';
|
248 |
-
$action_type = 'Send';
|
249 |
-
|
250 |
-
}
|
251 |
-
|
252 |
-
if(empty($alias) || empty($query_var))
|
253 |
-
continue;
|
254 |
-
|
255 |
-
$this->query_vars[] = array(
|
256 |
-
'action' => $action,
|
257 |
-
'action_label' => $action_label,
|
258 |
-
'action_type' => $action_type,
|
259 |
-
'alias' => $alias
|
260 |
-
);
|
261 |
-
|
262 |
-
endwhile;
|
263 |
-
endif;
|
264 |
|
265 |
}
|
266 |
|
@@ -791,7 +797,7 @@ class acfe_form{
|
|
791 |
if($action === 'post'){
|
792 |
|
793 |
$tags = array(
|
794 |
-
"{query_var:$alias:
|
795 |
"{query_var:$alias:post_title}" => 'Title',
|
796 |
"{query_var:$alias:permalink}" => 'Permalink',
|
797 |
"{query_var:$alias:admin_url}" => 'Admin URL',
|
@@ -802,7 +808,7 @@ class acfe_form{
|
|
802 |
elseif($action === 'term'){
|
803 |
|
804 |
$tags = array(
|
805 |
-
"{query_var:$alias:
|
806 |
"{query_var:$alias:name}" => 'Name',
|
807 |
"{query_var:$alias:permalink}" => 'Permalink',
|
808 |
"{query_var:$alias:admin_url}" => 'Admin URL',
|
@@ -813,7 +819,7 @@ class acfe_form{
|
|
813 |
elseif($action === 'user'){
|
814 |
|
815 |
$tags = array(
|
816 |
-
"{query_var:$alias:
|
817 |
"{query_var:$alias:user_email}" => 'E-mail',
|
818 |
"{query_var:$alias:permalink}" => 'Permalink',
|
819 |
);
|
@@ -842,24 +848,24 @@ class acfe_form{
|
|
842 |
}
|
843 |
|
844 |
// Templates Tags Examples
|
845 |
-
$field['choices']["Current: Post"]['{current:post:
|
846 |
$field['choices']["Current: Post"]['{current:post:post_title}'] = 'Title {current:post:post_title}';
|
847 |
$field['choices']["Current: Post"]['{current:post:permalink}'] = 'Permalink {current:post:permalink}';
|
848 |
$field['choices']["Current: Post"]['{current:post:post_author}'] = 'Author {current:post:post_author}';
|
849 |
|
850 |
-
$field['choices']["Current: Term"]['{current:term:
|
851 |
$field['choices']["Current: Term"]['{current:term:name}'] = 'Name {current:term:name}';
|
852 |
$field['choices']["Current: Term"]['{current:term:permalink}'] = 'Permalink {current:term:permalink}';
|
853 |
|
854 |
-
$field['choices']["Current: User"]['{current:user:
|
855 |
$field['choices']["Current: User"]['{current:user:user_email}'] = 'E-mail {current:user:user_email}';
|
856 |
$field['choices']["Current: User"]['{current:user:permalink}'] = 'Permalink {current:user:permalink}';
|
857 |
|
858 |
-
$field['choices']["Current: Author"]['{current:author:
|
859 |
$field['choices']["Current: Author"]['{current:author:user_email}'] = 'E-mail {current:author:user_email}';
|
860 |
$field['choices']["Current: Author"]['{current:author:permalink}'] = 'Permalink {current:author:permalink}';
|
861 |
|
862 |
-
$field['choices']["Current: Form"]['{current:form:
|
863 |
$field['choices']["Current: Form"]['{current:form:title}'] = 'Title {current:form:title}';
|
864 |
$field['choices']["Current: Form"]['{current:form:name}'] = 'Name {current:form:name}';
|
865 |
|
@@ -1416,21 +1422,27 @@ class acfe_form{
|
|
1416 |
|
1417 |
// Match field_abcdef123456
|
1418 |
$c = acfe_form_map_field_key($c);
|
1419 |
-
|
1420 |
// Match {field:name} {field:key}
|
1421 |
$c = acfe_form_map_field($c);
|
1422 |
-
|
1423 |
// Match {fields}
|
1424 |
$c = acfe_form_map_fields($c);
|
1425 |
-
|
1426 |
// Match current_post {current:post:id}
|
1427 |
$c = acfe_form_map_current($c, $post_id, $form);
|
1428 |
-
|
1429 |
// Match {get_field:name} {get_field:name:123}
|
1430 |
$c = acfe_form_map_get_field($c, $post_id);
|
1431 |
|
|
|
|
|
|
|
1432 |
// Match {query_var:name} {query_var:name:key}
|
1433 |
$c = acfe_form_map_query_var($c);
|
|
|
|
|
|
|
1434 |
|
1435 |
}
|
1436 |
|
@@ -1464,9 +1476,15 @@ class acfe_form{
|
|
1464 |
// Match {get_field:name} {get_field:name:123}
|
1465 |
$c = acfe_form_map_get_field($c, $post_id);
|
1466 |
|
|
|
|
|
|
|
1467 |
// Match {query_var:name} {query_var:name:key}
|
1468 |
$c = acfe_form_map_query_var($c);
|
1469 |
|
|
|
|
|
|
|
1470 |
}
|
1471 |
|
1472 |
if($is_array)
|
@@ -1874,6 +1892,23 @@ function my_form_submit($form, $post_id){
|
|
1874 |
<?php
|
1875 |
}
|
1876 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1877 |
function doc_query_var($field){
|
1878 |
?>
|
1879 |
<table class="acf-table">
|
@@ -1983,6 +2018,23 @@ function my_form_submit($form, $post_id){
|
|
1983 |
<?php
|
1984 |
}
|
1985 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1986 |
function doc_current_post($field){
|
1987 |
?>
|
1988 |
<table class="acf-table">
|
@@ -2282,10 +2334,6 @@ function my_form_submit($form, $post_id){
|
|
2282 |
<td width="35%"><code>{current:user:show_welcome_panel}</code></td>
|
2283 |
<td>1</td>
|
2284 |
</tr>
|
2285 |
-
<tr class="acf-row">
|
2286 |
-
<td width="35%"><code>{current:user:show_welcome_panel}</code></td>
|
2287 |
-
<td>1</td>
|
2288 |
-
</tr>
|
2289 |
</tbody>
|
2290 |
</table>
|
2291 |
<?php
|
@@ -2407,10 +2455,6 @@ function my_form_submit($form, $post_id){
|
|
2407 |
<td width="35%"><code>{current:author:show_welcome_panel}</code></td>
|
2408 |
<td>1</td>
|
2409 |
</tr>
|
2410 |
-
<tr class="acf-row">
|
2411 |
-
<td width="35%"><code>{current:author:show_welcome_panel}</code></td>
|
2412 |
-
<td>1</td>
|
2413 |
-
</tr>
|
2414 |
</tbody>
|
2415 |
</table>
|
2416 |
<?php
|
@@ -2593,7 +2637,7 @@ function acfe_form_map_current($content, $post_id = 0, $form = array()){
|
|
2593 |
// Match {current:post:id}
|
2594 |
elseif(strpos($content, '{current:') !== false){
|
2595 |
|
2596 |
-
// Match {
|
2597 |
if(preg_match_all('/{current:(.*?)}/', $content, $matches)){
|
2598 |
|
2599 |
foreach($matches[1] as $i => $name){
|
@@ -2908,6 +2952,12 @@ function acfe_form_map_query_var($content){
|
|
2908 |
if(is_array($query_var) && isset($query_var[$explode[1]])){
|
2909 |
|
2910 |
$query_var = $query_var[$explode[1]];
|
|
|
|
|
|
|
|
|
|
|
|
|
2911 |
|
2912 |
}
|
2913 |
|
@@ -2923,6 +2973,50 @@ function acfe_form_map_query_var($content){
|
|
2923 |
|
2924 |
}
|
2925 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2926 |
// Match {get_field:name} {get_field:name:123}
|
2927 |
function acfe_form_map_get_field($content, $post_id = 0){
|
2928 |
|
@@ -2974,6 +3068,48 @@ function acfe_form_map_get_field($content, $post_id = 0){
|
|
2974 |
|
2975 |
}
|
2976 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2977 |
// Match {field:name} {field:key}
|
2978 |
function acfe_form_map_field($content){
|
2979 |
|
57 |
add_action('acf/render_field/name=acfe_form_cheatsheet_field', array($this, 'doc_field'));
|
58 |
add_action('acf/render_field/name=acfe_form_cheatsheet_fields', array($this, 'doc_fields'));
|
59 |
add_action('acf/render_field/name=acfe_form_cheatsheet_get_field', array($this, 'doc_get_field'));
|
60 |
+
add_action('acf/render_field/name=acfe_form_cheatsheet_get_option', array($this, 'doc_get_option'));
|
61 |
add_action('acf/render_field/name=acfe_form_cheatsheet_query_var', array($this, 'doc_query_var'));
|
62 |
+
add_action('acf/render_field/name=acfe_form_cheatsheet_request', array($this, 'doc_request'));
|
63 |
add_action('acf/render_field/name=acfe_form_cheatsheet_current_post', array($this, 'doc_current_post'));
|
64 |
add_action('acf/render_field/name=acfe_form_cheatsheet_current_term', array($this, 'doc_current_term'));
|
65 |
add_action('acf/render_field/name=acfe_form_cheatsheet_current_user', array($this, 'doc_current_user'));
|
173 |
add_action('post_submitbox_misc_actions', array($this, 'misc_actions'));
|
174 |
|
175 |
// Actions
|
176 |
+
if(isset($_REQUEST['post']) && !empty($_REQUEST['post'])){
|
177 |
+
|
178 |
+
$form_id = $_REQUEST['post'];
|
179 |
+
|
180 |
+
if(have_rows('acfe_form_actions', $form_id)):
|
181 |
+
|
182 |
+
while(have_rows('acfe_form_actions', $form_id)): the_row();
|
183 |
+
|
184 |
+
$action = get_row_layout();
|
185 |
+
|
186 |
+
// Custom Action
|
187 |
+
if($action === 'custom')
|
188 |
+
continue;
|
189 |
+
|
190 |
+
$alias = get_sub_field('acfe_form_custom_alias');
|
191 |
+
$query_var = get_sub_field('acfe_form_custom_query_var');
|
192 |
+
|
193 |
+
$action_label = '';
|
194 |
+
$action_type = '';
|
195 |
+
|
196 |
+
if($action === 'post'){
|
197 |
+
|
198 |
+
$action_label = 'Post';
|
199 |
+
|
200 |
+
$post_action = get_sub_field('acfe_form_post_action');
|
201 |
+
|
202 |
+
if($post_action === 'insert_post'){
|
203 |
+
|
204 |
+
$action_type = 'Create Post';
|
205 |
+
|
206 |
+
}elseif($post_action === 'update_post'){
|
207 |
+
|
208 |
+
$action_type = 'Update Post';
|
209 |
+
|
210 |
+
}
|
211 |
+
|
212 |
+
|
213 |
+
}elseif($action === 'term'){
|
214 |
+
|
215 |
+
$action_label = 'Term';
|
216 |
+
|
217 |
+
$term_action = get_sub_field('acfe_form_term_action');
|
218 |
+
|
219 |
+
if($term_action === 'insert_term'){
|
220 |
+
|
221 |
+
$action_type = 'Create Term';
|
222 |
+
|
223 |
+
}elseif($term_action === 'update_term'){
|
224 |
+
|
225 |
+
$action_type = 'Update Term';
|
226 |
+
|
227 |
+
}
|
228 |
+
|
229 |
+
}elseif($action === 'user'){
|
230 |
+
|
231 |
+
$action_label = 'User';
|
232 |
+
|
233 |
+
$term_action = get_sub_field('acfe_form_user_action');
|
234 |
+
|
235 |
+
if($term_action === 'insert_user'){
|
236 |
+
|
237 |
+
$action_type = 'Create User';
|
238 |
+
|
239 |
+
}elseif($term_action === 'update_user'){
|
240 |
+
|
241 |
+
$action_type = 'Update User';
|
242 |
+
|
243 |
+
}elseif($term_action === 'log_user'){
|
244 |
+
|
245 |
+
$action_type = 'Log User';
|
246 |
+
|
247 |
+
}
|
248 |
+
|
249 |
+
}elseif($action === 'email'){
|
250 |
+
|
251 |
+
$action_label = 'E-mail';
|
252 |
+
$action_type = 'Send';
|
253 |
+
|
254 |
+
}
|
255 |
+
|
256 |
+
if(empty($alias) || empty($query_var))
|
257 |
+
continue;
|
258 |
+
|
259 |
+
$this->query_vars[] = array(
|
260 |
+
'action' => $action,
|
261 |
+
'action_label' => $action_label,
|
262 |
+
'action_type' => $action_type,
|
263 |
+
'alias' => $alias
|
264 |
+
);
|
265 |
+
|
266 |
+
endwhile;
|
267 |
+
endif;
|
268 |
|
269 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
|
271 |
}
|
272 |
|
797 |
if($action === 'post'){
|
798 |
|
799 |
$tags = array(
|
800 |
+
"{query_var:$alias:ID}" => 'Post ID',
|
801 |
"{query_var:$alias:post_title}" => 'Title',
|
802 |
"{query_var:$alias:permalink}" => 'Permalink',
|
803 |
"{query_var:$alias:admin_url}" => 'Admin URL',
|
808 |
elseif($action === 'term'){
|
809 |
|
810 |
$tags = array(
|
811 |
+
"{query_var:$alias:ID}" => 'Term ID',
|
812 |
"{query_var:$alias:name}" => 'Name',
|
813 |
"{query_var:$alias:permalink}" => 'Permalink',
|
814 |
"{query_var:$alias:admin_url}" => 'Admin URL',
|
819 |
elseif($action === 'user'){
|
820 |
|
821 |
$tags = array(
|
822 |
+
"{query_var:$alias:ID}" => 'User ID',
|
823 |
"{query_var:$alias:user_email}" => 'E-mail',
|
824 |
"{query_var:$alias:permalink}" => 'Permalink',
|
825 |
);
|
848 |
}
|
849 |
|
850 |
// Templates Tags Examples
|
851 |
+
$field['choices']["Current: Post"]['{current:post:ID}'] = 'Post ID {current:post:ID}';
|
852 |
$field['choices']["Current: Post"]['{current:post:post_title}'] = 'Title {current:post:post_title}';
|
853 |
$field['choices']["Current: Post"]['{current:post:permalink}'] = 'Permalink {current:post:permalink}';
|
854 |
$field['choices']["Current: Post"]['{current:post:post_author}'] = 'Author {current:post:post_author}';
|
855 |
|
856 |
+
$field['choices']["Current: Term"]['{current:term:ID}'] = 'Term ID {current:term:ID}';
|
857 |
$field['choices']["Current: Term"]['{current:term:name}'] = 'Name {current:term:name}';
|
858 |
$field['choices']["Current: Term"]['{current:term:permalink}'] = 'Permalink {current:term:permalink}';
|
859 |
|
860 |
+
$field['choices']["Current: User"]['{current:user:ID}'] = 'User ID {current:user:ID}';
|
861 |
$field['choices']["Current: User"]['{current:user:user_email}'] = 'E-mail {current:user:user_email}';
|
862 |
$field['choices']["Current: User"]['{current:user:permalink}'] = 'Permalink {current:user:permalink}';
|
863 |
|
864 |
+
$field['choices']["Current: Author"]['{current:author:ID}'] = 'Author ID {current:author:ID}';
|
865 |
$field['choices']["Current: Author"]['{current:author:user_email}'] = 'E-mail {current:author:user_email}';
|
866 |
$field['choices']["Current: Author"]['{current:author:permalink}'] = 'Permalink {current:author:permalink}';
|
867 |
|
868 |
+
$field['choices']["Current: Form"]['{current:form:ID}'] = 'Form ID {current:form:ID}';
|
869 |
$field['choices']["Current: Form"]['{current:form:title}'] = 'Title {current:form:title}';
|
870 |
$field['choices']["Current: Form"]['{current:form:name}'] = 'Name {current:form:name}';
|
871 |
|
1422 |
|
1423 |
// Match field_abcdef123456
|
1424 |
$c = acfe_form_map_field_key($c);
|
1425 |
+
|
1426 |
// Match {field:name} {field:key}
|
1427 |
$c = acfe_form_map_field($c);
|
1428 |
+
|
1429 |
// Match {fields}
|
1430 |
$c = acfe_form_map_fields($c);
|
1431 |
+
|
1432 |
// Match current_post {current:post:id}
|
1433 |
$c = acfe_form_map_current($c, $post_id, $form);
|
1434 |
+
|
1435 |
// Match {get_field:name} {get_field:name:123}
|
1436 |
$c = acfe_form_map_get_field($c, $post_id);
|
1437 |
|
1438 |
+
// Match {get_option:name}
|
1439 |
+
$c = acfe_form_map_get_option($c);
|
1440 |
+
|
1441 |
// Match {query_var:name} {query_var:name:key}
|
1442 |
$c = acfe_form_map_query_var($c);
|
1443 |
+
|
1444 |
+
// Match {request:name}
|
1445 |
+
$c = acfe_form_map_request($c);
|
1446 |
|
1447 |
}
|
1448 |
|
1476 |
// Match {get_field:name} {get_field:name:123}
|
1477 |
$c = acfe_form_map_get_field($c, $post_id);
|
1478 |
|
1479 |
+
// Match {get_option:name}
|
1480 |
+
$c = acfe_form_map_get_option($c);
|
1481 |
+
|
1482 |
// Match {query_var:name} {query_var:name:key}
|
1483 |
$c = acfe_form_map_query_var($c);
|
1484 |
|
1485 |
+
// Match {request:name}
|
1486 |
+
$c = acfe_form_map_request($c);
|
1487 |
+
|
1488 |
}
|
1489 |
|
1490 |
if($is_array)
|
1892 |
<?php
|
1893 |
}
|
1894 |
|
1895 |
+
function doc_get_option($field){
|
1896 |
+
?>
|
1897 |
+
<table class="acf-table">
|
1898 |
+
<tbody>
|
1899 |
+
<tr class="acf-row">
|
1900 |
+
<td width="35%"><code>{get_option:my_option}</code></td>
|
1901 |
+
<td>DB value</td>
|
1902 |
+
</tr>
|
1903 |
+
<tr class="acf-row">
|
1904 |
+
<td width="35%"><code>{get_option:my_option_array:key}</code></td>
|
1905 |
+
<td>DB value</td>
|
1906 |
+
</tr>
|
1907 |
+
</tbody>
|
1908 |
+
</table>
|
1909 |
+
<?php
|
1910 |
+
}
|
1911 |
+
|
1912 |
function doc_query_var($field){
|
1913 |
?>
|
1914 |
<table class="acf-table">
|
2018 |
<?php
|
2019 |
}
|
2020 |
|
2021 |
+
function doc_request($field){
|
2022 |
+
?>
|
2023 |
+
<table class="acf-table">
|
2024 |
+
<tbody>
|
2025 |
+
<tr class="acf-row">
|
2026 |
+
<td width="35%"><code>{request:name}</code></td>
|
2027 |
+
<td><code>$_REQUEST['name']</code> (including <code>$_GET</code> & <code>$_POST</code>)</td>
|
2028 |
+
</tr>
|
2029 |
+
<tr class="acf-row">
|
2030 |
+
<td width="35%"><code>{request:name:key}</code></td>
|
2031 |
+
<td><code>$_REQUEST['name']['key']</code> (including <code>$_GET</code> & <code>$_POST</code>)</td>
|
2032 |
+
</tr>
|
2033 |
+
</tbody>
|
2034 |
+
</table>
|
2035 |
+
<?php
|
2036 |
+
}
|
2037 |
+
|
2038 |
function doc_current_post($field){
|
2039 |
?>
|
2040 |
<table class="acf-table">
|
2334 |
<td width="35%"><code>{current:user:show_welcome_panel}</code></td>
|
2335 |
<td>1</td>
|
2336 |
</tr>
|
|
|
|
|
|
|
|
|
2337 |
</tbody>
|
2338 |
</table>
|
2339 |
<?php
|
2455 |
<td width="35%"><code>{current:author:show_welcome_panel}</code></td>
|
2456 |
<td>1</td>
|
2457 |
</tr>
|
|
|
|
|
|
|
|
|
2458 |
</tbody>
|
2459 |
</table>
|
2460 |
<?php
|
2637 |
// Match {current:post:id}
|
2638 |
elseif(strpos($content, '{current:') !== false){
|
2639 |
|
2640 |
+
// Match {current:name}
|
2641 |
if(preg_match_all('/{current:(.*?)}/', $content, $matches)){
|
2642 |
|
2643 |
foreach($matches[1] as $i => $name){
|
2952 |
if(is_array($query_var) && isset($query_var[$explode[1]])){
|
2953 |
|
2954 |
$query_var = $query_var[$explode[1]];
|
2955 |
+
|
2956 |
+
if(is_array($query_var) && isset($query_var[$explode[2]])){
|
2957 |
+
|
2958 |
+
$query_var = $query_var[$explode[2]];
|
2959 |
+
|
2960 |
+
}
|
2961 |
|
2962 |
}
|
2963 |
|
2973 |
|
2974 |
}
|
2975 |
|
2976 |
+
// Match {request:name} {request:name:key}
|
2977 |
+
function acfe_form_map_request($content){
|
2978 |
+
|
2979 |
+
if(empty($content) || !is_string($content))
|
2980 |
+
return $content;
|
2981 |
+
|
2982 |
+
if(strpos($content, '{request:') === false)
|
2983 |
+
return $content;
|
2984 |
+
|
2985 |
+
// Match {request:name}
|
2986 |
+
if(preg_match_all('/{request:(.*?)}/', $content, $matches)){
|
2987 |
+
|
2988 |
+
foreach($matches[1] as $i => $name){
|
2989 |
+
|
2990 |
+
$request = false;
|
2991 |
+
|
2992 |
+
if(isset($_REQUEST[$name]))
|
2993 |
+
$request = $_REQUEST[$name];
|
2994 |
+
|
2995 |
+
if(strpos($name, ':') !== false){
|
2996 |
+
|
2997 |
+
$explode = explode(':', $name);
|
2998 |
+
|
2999 |
+
if(isset($_REQUEST[$explode[0]]))
|
3000 |
+
$request = $_REQUEST[$explode[0]];
|
3001 |
+
|
3002 |
+
if(is_array($request) && isset($request[$explode[1]])){
|
3003 |
+
|
3004 |
+
$request = $request[$explode[1]];
|
3005 |
+
|
3006 |
+
}
|
3007 |
+
|
3008 |
+
}
|
3009 |
+
|
3010 |
+
$content = str_replace('{request:' . $name . '}', $request, $content);
|
3011 |
+
|
3012 |
+
}
|
3013 |
+
|
3014 |
+
}
|
3015 |
+
|
3016 |
+
return $content;
|
3017 |
+
|
3018 |
+
}
|
3019 |
+
|
3020 |
// Match {get_field:name} {get_field:name:123}
|
3021 |
function acfe_form_map_get_field($content, $post_id = 0){
|
3022 |
|
3068 |
|
3069 |
}
|
3070 |
|
3071 |
+
// Match {get_option:name} {get_option:name:key}
|
3072 |
+
function acfe_form_map_get_option($content){
|
3073 |
+
|
3074 |
+
if(empty($content) || !is_string($content))
|
3075 |
+
return $content;
|
3076 |
+
|
3077 |
+
if(strpos($content, '{get_option:') === false)
|
3078 |
+
return $content;
|
3079 |
+
|
3080 |
+
// Match {get_option:name}
|
3081 |
+
if(preg_match_all('/{get_option:(.*?)}/', $content, $matches)){
|
3082 |
+
|
3083 |
+
foreach($matches[1] as $i => $name){
|
3084 |
+
|
3085 |
+
if(strpos($name, ':') === false){
|
3086 |
+
|
3087 |
+
$get_option = get_option($name);
|
3088 |
+
|
3089 |
+
}else{
|
3090 |
+
|
3091 |
+
$explode = explode(':', $name);
|
3092 |
+
|
3093 |
+
$get_option = get_option($explode[0]);
|
3094 |
+
|
3095 |
+
if(is_array($get_option) && isset($get_option[$explode[1]])){
|
3096 |
+
|
3097 |
+
$get_option = $get_option[$explode[1]];
|
3098 |
+
|
3099 |
+
}
|
3100 |
+
|
3101 |
+
}
|
3102 |
+
|
3103 |
+
$content = str_replace('{get_option:' . $name . '}', $get_option, $content);
|
3104 |
+
|
3105 |
+
}
|
3106 |
+
|
3107 |
+
}
|
3108 |
+
|
3109 |
+
return $content;
|
3110 |
+
|
3111 |
+
}
|
3112 |
+
|
3113 |
// Match {field:name} {field:key}
|
3114 |
function acfe_form_map_field($content){
|
3115 |
|
includes/modules/form/field-group.php
CHANGED
@@ -5303,6 +5303,21 @@ If used, you have to include the following code <code>%s</code> to print the act
|
|
5303 |
'id' => '',
|
5304 |
),
|
5305 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5306 |
array(
|
5307 |
'key' => 'field_acfe_form_cheatsheet_query_var',
|
5308 |
'label' => 'Query Var',
|
@@ -5318,6 +5333,21 @@ If used, you have to include the following code <code>%s</code> to print the act
|
|
5318 |
'id' => '',
|
5319 |
),
|
5320 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5321 |
array(
|
5322 |
'key' => 'field_acfe_form_cheatsheet_current_post',
|
5323 |
'label' => 'Current Post',
|
5303 |
'id' => '',
|
5304 |
),
|
5305 |
),
|
5306 |
+
array(
|
5307 |
+
'key' => 'field_acfe_form_cheatsheet_get_option',
|
5308 |
+
'label' => 'Get Option',
|
5309 |
+
'name' => 'acfe_form_cheatsheet_get_option',
|
5310 |
+
'type' => 'acfe_dynamic_message',
|
5311 |
+
'value' => '',
|
5312 |
+
'instructions' => 'Retrieve option value from database',
|
5313 |
+
'required' => 0,
|
5314 |
+
'conditional_logic' => 0,
|
5315 |
+
'wrapper' => array(
|
5316 |
+
'width' => '',
|
5317 |
+
'class' => '',
|
5318 |
+
'id' => '',
|
5319 |
+
),
|
5320 |
+
),
|
5321 |
array(
|
5322 |
'key' => 'field_acfe_form_cheatsheet_query_var',
|
5323 |
'label' => 'Query Var',
|
5333 |
'id' => '',
|
5334 |
),
|
5335 |
),
|
5336 |
+
array(
|
5337 |
+
'key' => 'field_acfe_form_cheatsheet_request',
|
5338 |
+
'label' => 'Request',
|
5339 |
+
'name' => 'acfe_form_cheatsheet_request',
|
5340 |
+
'type' => 'acfe_dynamic_message',
|
5341 |
+
'value' => '',
|
5342 |
+
'instructions' => 'Retrieve <code>$_REQUEST</code> value',
|
5343 |
+
'required' => 0,
|
5344 |
+
'conditional_logic' => 0,
|
5345 |
+
'wrapper' => array(
|
5346 |
+
'width' => '',
|
5347 |
+
'class' => '',
|
5348 |
+
'id' => '',
|
5349 |
+
),
|
5350 |
+
),
|
5351 |
array(
|
5352 |
'key' => 'field_acfe_form_cheatsheet_current_post',
|
5353 |
'label' => 'Current Post',
|
includes/modules/form/form-front.php
CHANGED
@@ -472,7 +472,7 @@ class acfe_form_front{
|
|
472 |
|
473 |
if(!empty($args['html_updated_message'])){
|
474 |
|
475 |
-
printf($args['html_updated_message'], $message);
|
476 |
|
477 |
}else{
|
478 |
|
472 |
|
473 |
if(!empty($args['html_updated_message'])){
|
474 |
|
475 |
+
printf($args['html_updated_message'], wp_unslash($message));
|
476 |
|
477 |
}else{
|
478 |
|
includes/modules/single-meta.php
CHANGED
@@ -80,6 +80,7 @@ class acfe_single_meta{
|
|
80 |
// Store not found
|
81 |
}else{
|
82 |
|
|
|
83 |
// Submitting acf/save_post
|
84 |
if($is_save_post){
|
85 |
|
@@ -93,6 +94,10 @@ class acfe_single_meta{
|
|
93 |
$acf = acf_get_metadata($post_id, 'acf');
|
94 |
|
95 |
}
|
|
|
|
|
|
|
|
|
96 |
|
97 |
// Set Store: ACF meta
|
98 |
$store->set("$post_id:acf", $acf);
|
80 |
// Store not found
|
81 |
}else{
|
82 |
|
83 |
+
/*
|
84 |
// Submitting acf/save_post
|
85 |
if($is_save_post){
|
86 |
|
94 |
$acf = acf_get_metadata($post_id, 'acf');
|
95 |
|
96 |
}
|
97 |
+
*/
|
98 |
+
|
99 |
+
// Get ACF meta
|
100 |
+
$acf = acf_get_metadata($post_id, 'acf');
|
101 |
|
102 |
// Set Store: ACF meta
|
103 |
$store->set("$post_id:acf", $acf);
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: acf, custom fields, meta, admin, fields, form, repeater, content
|
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.4
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 0.8.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -60,7 +60,7 @@ All-in-one enhancement suite that improves WordPress & Advanced Custom Fields.
|
|
60 |
|
61 |
**This plugin requires at least ACF Pro 5.7.10**
|
62 |
|
63 |
-
If you don't already own [ACF Pro](https://www.advancedcustomfields.com/pro/), you should consider it. It's one of the most powerful WordPress plugin
|
64 |
|
65 |
== 🏷️ Features ==
|
66 |
|
@@ -689,6 +689,30 @@ function my_acfe_modules(){
|
|
689 |
|
690 |
== Changelog ==
|
691 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
692 |
= 0.8.5.5 =
|
693 |
* Field: Button - Added nominative JS hooks `action('acfe/fields/button/before/name=my_field', response, $el, data);`
|
694 |
* Field: Button - Added nominative JS hooks `action('acfe/fields/button/success/name=my_field', response, $el, data);`
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.4
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 0.8.6
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
60 |
|
61 |
**This plugin requires at least ACF Pro 5.7.10**
|
62 |
|
63 |
+
If you don't already own [ACF Pro](https://www.advancedcustomfields.com/pro/), you should consider it. It's one of the most powerful WordPress plugin available.
|
64 |
|
65 |
== 🏷️ Features ==
|
66 |
|
689 |
|
690 |
== Changelog ==
|
691 |
|
692 |
+
= 0.8.6 =
|
693 |
+
* Module: Dynamic Post Types/Taxonomies/Block Types/Options Pages - Slugs can now to edited & updated from the UI
|
694 |
+
* Module: Dynamic Options Pages - Added a configuration icon on top of options page to easily switch to options page settings
|
695 |
+
* Module: Dynamic Forms - User Action query var now returns the password if it has been created/generated during the action. This will allow developers to send the password confirmation via an e-mail action using query vars
|
696 |
+
* Module: Dynamic Forms - Added `{request:name}` & `{request:name:key}` template tags to retrieve `$_REQUEST` `$_GET` & `$_POST` data
|
697 |
+
* Module: Dynamic Forms - Added `{get_option:name}` & `{get_option:name:key}` template tags to retrieve an option from database
|
698 |
+
* Module: Dynamic Forms - Enhanced "Post Action" query var which now returns post author data in the `{query_var:my-action:post_author_data:field}` template tag
|
699 |
+
* Module: Dynamic Forms - Enhanced JS detection of the `acf` object to avoid potential errors when using aggressive minification
|
700 |
+
* Module: Dynamic Forms - Fixed `{current:user:show_welcome_panel}` which was printed twice in the "Cheatsheet" tab
|
701 |
+
* Module: Dynamic Forms - Fixed `wp_unslash()` on the success message
|
702 |
+
* Module: Dynamic Forms - Fixed undefined `post` key notice which could occurs in some cases
|
703 |
+
* Module: Dynamic Forms - Fixed template tags which were using `id` instead of `ID`
|
704 |
+
* Module: Dynamic Forms - Fixed the conditional logic on custom form render when using complex fields like repeaters or flexible content
|
705 |
+
* Module: Single Meta Save - `acf` meta is now updated on submission instead of being reset each time it is saved. This fix a potential problem when fields wouldn't be displayed to specific user roles
|
706 |
+
* Module: PHP AutoSync - PHP files are now included only if the filename starts with `group_*.php`
|
707 |
+
* Field: Columns - Added responsive breakpoints
|
708 |
+
* Field: Button - Added Advanced Settings compatibility
|
709 |
+
* Field: Advanced Link - Fixed a bug which could render an empty "Archive" default value artifact in post objects fields
|
710 |
+
* Field: Advanced Link - Fixed required field validation
|
711 |
+
* Field: Code Editor - Fixed line wrap in terms views
|
712 |
+
* Field: WYSIWYG - Fixed the automatic smart delayed initialization in flexible content layouts which could break when trying to open a layout before the complete page load
|
713 |
+
* General: Settings API - Enhanced upgrade process
|
714 |
+
* General: Settings API - `acfe` option now regenerate Post Types/Taxonomies/Block Types/Options Pages on reset
|
715 |
+
|
716 |
= 0.8.5.5 =
|
717 |
* Field: Button - Added nominative JS hooks `action('acfe/fields/button/before/name=my_field', response, $el, data);`
|
718 |
* Field: Button - Added nominative JS hooks `action('acfe/fields/button/success/name=my_field', response, $el, data);`
|