Version Description
- Field: Flexible Content - Fixed Clone & Copy/Paste functions in multi level flexible content (flexible inside flexible inside flexible...) (Thanks @AsmussenBrandon)
- Field: Flexible Content - Fixed CSS border glitch
Download this release
Release Info
Developer | hwk-fr |
Plugin | Advanced Custom Fields: Extended |
Version | 0.7.9.9.8 |
Comparing to | |
See all releases |
Code changes from version 0.7.9.4 to 0.7.9.9.8
- acf-extended.php +137 -136
- assets/acf-extended-fc-control.css +65 -65
- assets/acf-extended-fc-control.js +683 -606
- assets/acf-extended-fc-modal-edit.css +5 -5
- assets/acf-extended-fc-modal-edit.js +85 -81
- assets/acf-extended-fc-modal-select.js +295 -194
- assets/acf-extended-fc.css +276 -275
- assets/acf-extended-fc.js +349 -344
- assets/acf-extended-fg.css +142 -139
- assets/acf-extended-fg.js +23 -23
- assets/acf-extended-fields.js +28 -28
- assets/acf-extended-modal.css +463 -449
- assets/acf-extended-taxonomies.css +125 -0
- assets/acf-extended.css +216 -336
- assets/acf-extended.js +155 -167
- includes/admin/options.class.php +272 -272
- includes/admin/options.php +578 -575
- includes/admin/plugins.php +41 -41
- includes/admin/settings.php +237 -237
- includes/admin/tools/dbt-export.php +183 -179
- includes/admin/tools/dbt-import.php +218 -214
- includes/admin/tools/dop-export.php +183 -179
- includes/admin/tools/dop-import.php +208 -204
- includes/admin/tools/dpt-export.php +183 -179
- includes/admin/tools/dpt-import.php +242 -238
- includes/admin/tools/dt-export.php +183 -179
- includes/admin/tools/dt-import.php +218 -214
- includes/admin/views/html-options-edit.php +60 -60
- includes/admin/views/html-options-list.php +37 -37
- includes/core/compatibility.php +54 -54
- includes/core/enqueue.php +71 -64
- includes/core/helpers.php +356 -280
- includes/core/menu.php +98 -84
- includes/field-groups/field-group-category.php +146 -146
- includes/field-groups/field-group.php +468 -468
- includes/field-groups/field-groups-third-party.php +176 -176
- includes/field-groups/field-groups.php +444 -410
- includes/fields-settings/bidirectional.php +584 -564
- includes/fields-settings/data.php +57 -57
- includes/fields-settings/flexible-content.php +934 -872
- includes/fields-settings/image.php +16 -16
- includes/fields-settings/permissions.php +50 -50
- includes/fields-settings/thumbnail.php +39 -39
- includes/fields-settings/update.php +161 -161
- includes/fields-settings/validation.php +329 -329
- includes/fields/field-button.php +146 -146
- includes/fields/field-dynamic-message.php +17 -17
- includes/fields/field-post-types.php +171 -165
- includes/fields/field-slug.php +136 -136
- includes/fields/field-taxonomies.php +171 -165
- includes/locations/post-type-all.php +44 -43
- includes/locations/post-type-archive.php +409 -409
- includes/locations/taxonomy-archive.php +422 -422
- includes/modules/author.php +233 -229
- includes/modules/autosync.php +290 -290
- includes/modules/dynamic-block-type.php +1175 -1171
- includes/modules/dynamic-options-page.php +809 -805
- includes/modules/dynamic-post-type.php +1745 -2574
acf-extended.php
CHANGED
@@ -1,137 +1,138 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
-
* Description: Enhancement Suite which improves Advanced Custom Fields administration
|
5 |
-
* Version: 0.7.9.
|
6 |
-
* Author: ACF Extended
|
7 |
-
* Author URI: https://www.acf-extended.com
|
8 |
-
* Text Domain: acfe
|
9 |
-
*/
|
10 |
-
|
11 |
-
if(!defined('ABSPATH'))
|
12 |
-
exit;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* ACFE: Constants
|
16 |
-
*/
|
17 |
-
if(!defined('ACFE_FILE')) define('ACFE_FILE', __FILE__);
|
18 |
-
if(!defined('ACFE_PATH')) define('ACFE_PATH', plugin_dir_path(__FILE__));
|
19 |
-
if(!defined('ACFE_URL')) define('ACFE_URL', plugin_dir_url(__FILE__));
|
20 |
-
if(!defined('
|
21 |
-
if(!defined('
|
22 |
-
if(!defined('
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
acf_update_setting('
|
43 |
-
acf_update_setting('
|
44 |
-
acf_update_setting('
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
require_once(ACFE_PATH . 'includes/core/
|
51 |
-
require_once(ACFE_PATH . 'includes/core/
|
52 |
-
require_once(ACFE_PATH . 'includes/core/
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
require_once(ACFE_PATH . 'includes/admin/
|
59 |
-
require_once(ACFE_PATH . 'includes/admin/
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
require_once(ACFE_PATH . 'includes/fields-settings/
|
67 |
-
require_once(ACFE_PATH . 'includes/fields-settings/
|
68 |
-
require_once(ACFE_PATH . 'includes/fields-settings/
|
69 |
-
require_once(ACFE_PATH . 'includes/fields-settings/
|
70 |
-
require_once(ACFE_PATH . 'includes/fields-settings/
|
71 |
-
require_once(ACFE_PATH . 'includes/fields-settings/
|
72 |
-
require_once(ACFE_PATH . 'includes/fields-settings/
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
require_once(ACFE_PATH . 'includes/field-groups/field-group
|
79 |
-
require_once(ACFE_PATH . 'includes/field-groups/field-
|
80 |
-
require_once(ACFE_PATH . 'includes/field-groups/field-groups
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
require_once(ACFE_PATH . 'includes/locations/post-type-
|
87 |
-
require_once(ACFE_PATH . 'includes/locations/
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
require_once(ACFE_PATH . 'includes/modules/
|
94 |
-
require_once(ACFE_PATH . 'includes/modules/
|
95 |
-
require_once(ACFE_PATH . 'includes/modules/dynamic-
|
96 |
-
require_once(ACFE_PATH . 'includes/modules/dynamic-
|
97 |
-
require_once(ACFE_PATH . 'includes/modules/dynamic-
|
98 |
-
require_once(ACFE_PATH . 'includes/modules/taxonomy.php');
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
require_once(ACFE_PATH . 'includes/fields/field-
|
113 |
-
require_once(ACFE_PATH . 'includes/fields/field-
|
114 |
-
require_once(ACFE_PATH . 'includes/fields/field-
|
115 |
-
require_once(ACFE_PATH . 'includes/fields/field-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
require_once(ACFE_PATH . 'includes/admin/tools/dbt-
|
130 |
-
require_once(ACFE_PATH . 'includes/admin/tools/
|
131 |
-
require_once(ACFE_PATH . 'includes/admin/tools/dpt-
|
132 |
-
require_once(ACFE_PATH . 'includes/admin/tools/
|
133 |
-
require_once(ACFE_PATH . 'includes/admin/tools/dt-
|
134 |
-
require_once(ACFE_PATH . 'includes/admin/tools/
|
135 |
-
require_once(ACFE_PATH . 'includes/admin/tools/dop-
|
136 |
-
|
|
|
137 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
+
* Description: Enhancement Suite which improves Advanced Custom Fields administration
|
5 |
+
* Version: 0.7.9.9.8
|
6 |
+
* Author: ACF Extended
|
7 |
+
* Author URI: https://www.acf-extended.com
|
8 |
+
* Text Domain: acfe
|
9 |
+
*/
|
10 |
+
|
11 |
+
if(!defined('ABSPATH'))
|
12 |
+
exit;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* ACFE: Constants
|
16 |
+
*/
|
17 |
+
if(!defined('ACFE_FILE')) define('ACFE_FILE', __FILE__);
|
18 |
+
if(!defined('ACFE_PATH')) define('ACFE_PATH', plugin_dir_path(__FILE__));
|
19 |
+
if(!defined('ACFE_URL')) define('ACFE_URL', plugin_dir_url(__FILE__));
|
20 |
+
if(!defined('ACFE_VERSION')) define('ACFE_VERSION', '0.7.9.9.6');
|
21 |
+
if(!defined('ACFE_BASENAME')) define('ACFE_BASENAME', plugin_basename(__FILE__));
|
22 |
+
if(!defined('ACFE_THEME_PATH')) define('ACFE_THEME_PATH', get_stylesheet_directory());
|
23 |
+
if(!defined('ACFE_THEME_URL')) define('ACFE_THEME_URL', get_stylesheet_directory_uri());
|
24 |
+
|
25 |
+
/**
|
26 |
+
* ACFE: Init
|
27 |
+
*/
|
28 |
+
require_once(ACFE_PATH . 'init.php');
|
29 |
+
|
30 |
+
/**
|
31 |
+
* ACFE: Load
|
32 |
+
*/
|
33 |
+
add_action('acf/init', 'acfe_load', 99);
|
34 |
+
function acfe_load(){
|
35 |
+
|
36 |
+
if(!acfe_is_acf_pro())
|
37 |
+
return;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Settings
|
41 |
+
*/
|
42 |
+
acf_update_setting('acfe_php', true);
|
43 |
+
acf_update_setting('acfe_php_save', ACFE_THEME_PATH . '/acfe-php');
|
44 |
+
acf_update_setting('acfe_php_load', array(ACFE_THEME_PATH . '/acfe-php'));
|
45 |
+
acf_update_setting('acfe_php_found', false);
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Core
|
49 |
+
*/
|
50 |
+
require_once(ACFE_PATH . 'includes/core/compatibility.php');
|
51 |
+
require_once(ACFE_PATH . 'includes/core/enqueue.php');
|
52 |
+
require_once(ACFE_PATH . 'includes/core/helpers.php');
|
53 |
+
require_once(ACFE_PATH . 'includes/core/menu.php');
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Admin Pages
|
57 |
+
*/
|
58 |
+
require_once(ACFE_PATH . 'includes/admin/options.php');
|
59 |
+
require_once(ACFE_PATH . 'includes/admin/plugins.php');
|
60 |
+
require_once(ACFE_PATH . 'includes/admin/settings.php');
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Fields settings
|
65 |
+
*/
|
66 |
+
require_once(ACFE_PATH . 'includes/fields-settings/bidirectional.php');
|
67 |
+
require_once(ACFE_PATH . 'includes/fields-settings/data.php');
|
68 |
+
require_once(ACFE_PATH . 'includes/fields-settings/flexible-content.php');
|
69 |
+
require_once(ACFE_PATH . 'includes/fields-settings/image.php');
|
70 |
+
require_once(ACFE_PATH . 'includes/fields-settings/permissions.php');
|
71 |
+
require_once(ACFE_PATH . 'includes/fields-settings/thumbnail.php');
|
72 |
+
require_once(ACFE_PATH . 'includes/fields-settings/update.php');
|
73 |
+
require_once(ACFE_PATH . 'includes/fields-settings/validation.php');
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Field Groups
|
77 |
+
*/
|
78 |
+
require_once(ACFE_PATH . 'includes/field-groups/field-group.php');
|
79 |
+
require_once(ACFE_PATH . 'includes/field-groups/field-group-category.php');
|
80 |
+
require_once(ACFE_PATH . 'includes/field-groups/field-groups.php');
|
81 |
+
require_once(ACFE_PATH . 'includes/field-groups/field-groups-third-party.php');
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Locations
|
85 |
+
*/
|
86 |
+
require_once(ACFE_PATH . 'includes/locations/post-type-all.php');
|
87 |
+
require_once(ACFE_PATH . 'includes/locations/post-type-archive.php');
|
88 |
+
require_once(ACFE_PATH . 'includes/locations/taxonomy-archive.php');
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Modules
|
92 |
+
*/
|
93 |
+
require_once(ACFE_PATH . 'includes/modules/author.php');
|
94 |
+
require_once(ACFE_PATH . 'includes/modules/autosync.php');
|
95 |
+
require_once(ACFE_PATH . 'includes/modules/dynamic-block-type.php');
|
96 |
+
require_once(ACFE_PATH . 'includes/modules/dynamic-options-page.php');
|
97 |
+
require_once(ACFE_PATH . 'includes/modules/dynamic-post-type.php');
|
98 |
+
require_once(ACFE_PATH . 'includes/modules/dynamic-taxonomy.php');
|
99 |
+
require_once(ACFE_PATH . 'includes/modules/taxonomy.php');
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* ACFE: Fields
|
105 |
+
*/
|
106 |
+
add_action('acf/include_field_types', 'acfe_fields');
|
107 |
+
function acfe_fields(){
|
108 |
+
|
109 |
+
if(!acfe_is_acf_pro())
|
110 |
+
return;
|
111 |
+
|
112 |
+
require_once(ACFE_PATH . 'includes/fields/field-button.php');
|
113 |
+
require_once(ACFE_PATH . 'includes/fields/field-dynamic-message.php');
|
114 |
+
require_once(ACFE_PATH . 'includes/fields/field-post-types.php');
|
115 |
+
require_once(ACFE_PATH . 'includes/fields/field-slug.php');
|
116 |
+
require_once(ACFE_PATH . 'includes/fields/field-taxonomies.php');
|
117 |
+
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* ACFE: Tools
|
122 |
+
*/
|
123 |
+
add_action('acf/include_admin_tools', 'acfe_tools');
|
124 |
+
function acfe_tools(){
|
125 |
+
|
126 |
+
if(!acfe_is_acf_pro())
|
127 |
+
return;
|
128 |
+
|
129 |
+
require_once(ACFE_PATH . 'includes/admin/tools/dbt-export.php');
|
130 |
+
require_once(ACFE_PATH . 'includes/admin/tools/dbt-import.php');
|
131 |
+
require_once(ACFE_PATH . 'includes/admin/tools/dpt-export.php');
|
132 |
+
require_once(ACFE_PATH . 'includes/admin/tools/dpt-import.php');
|
133 |
+
require_once(ACFE_PATH . 'includes/admin/tools/dt-export.php');
|
134 |
+
require_once(ACFE_PATH . 'includes/admin/tools/dt-import.php');
|
135 |
+
require_once(ACFE_PATH . 'includes/admin/tools/dop-export.php');
|
136 |
+
require_once(ACFE_PATH . 'includes/admin/tools/dop-import.php');
|
137 |
+
|
138 |
}
|
assets/acf-extended-fc-control.css
CHANGED
@@ -1,66 +1,66 @@
|
|
1 |
-
/*
|
2 |
-
* ACFE: Flexible Icons
|
3 |
-
*/
|
4 |
-
.acf-flexible-content .layout .acf-icon.acfe-flexible-icon.dashicons{
|
5 |
-
visibility: hidden;
|
6 |
-
}
|
7 |
-
|
8 |
-
.acf-flexible-content .layout .acf-icon.acfe-flexible-icon.dashicons:before{
|
9 |
-
font-family: dashicons;
|
10 |
-
}
|
11 |
-
|
12 |
-
.acf-flexible-content .layout:hover > .acf-fc-layout-controls .acf-icon.acfe-flexible-icon.dashicons{
|
13 |
-
visibility: visible;
|
14 |
-
}
|
15 |
-
|
16 |
-
.acf-flexible-content .layout:hover .acf-fc-layout-controls .acf-icon.-plus,
|
17 |
-
.acf-flexible-content .layout:hover .acf-fc-layout-controls .acf-icon.-minus,
|
18 |
-
.acf-flexible-content .layout.-hover .acf-fc-layout-controls .acf-icon.-plus,
|
19 |
-
.acf-flexible-content .layout.-hover .acf-fc-layout-controls .acf-icon.-minus{
|
20 |
-
visibility: hidden;
|
21 |
-
}
|
22 |
-
|
23 |
-
.acf-flexible-content .layout:hover > .acf-fc-layout-controls .acf-icon.-plus,
|
24 |
-
.acf-flexible-content .layout:hover > .acf-fc-layout-controls .acf-icon.-minus,
|
25 |
-
.acf-flexible-content .layout.-hover > .acf-fc-layout-controls .acf-icon.-plus,
|
26 |
-
.acf-flexible-content .layout.-hover > .acf-fc-layout-controls .acf-icon.-minus{
|
27 |
-
visibility: visible;
|
28 |
-
}
|
29 |
-
|
30 |
-
|
31 |
-
/*
|
32 |
-
* ACFE: Title Edit
|
33 |
-
*/
|
34 |
-
.acf-field-acfe-flexible-layout-title{
|
35 |
-
display:none;
|
36 |
-
}
|
37 |
-
|
38 |
-
input.acfe-flexible-control-title{
|
39 |
-
border:none;
|
40 |
-
box-shadow:none !important;
|
41 |
-
outline:none !important;
|
42 |
-
border-radius:0;
|
43 |
-
border-bottom:1px solid transparent !important;
|
44 |
-
font-weight:600;
|
45 |
-
width:auto !important;
|
46 |
-
padding:0 !important;
|
47 |
-
display:none;
|
48 |
-
}
|
49 |
-
|
50 |
-
.layout > .acf-fc-layout-handle .acfe-layout-title{
|
51 |
-
cursor:text;
|
52 |
-
position:relative;
|
53 |
-
}
|
54 |
-
|
55 |
-
.layout > .acf-fc-layout-handle .acfe-layout-title:hover{
|
56 |
-
background:#f4f4f4;
|
57 |
-
}
|
58 |
-
|
59 |
-
.layout.acfe-flexible-title-edition > .acf-fc-layout-handle .acfe-layout-title input.acfe-flexible-control-title{
|
60 |
-
display:inline-block;
|
61 |
-
border-bottom:1px solid #ddd !important;
|
62 |
-
}
|
63 |
-
|
64 |
-
.layout.acfe-flexible-title-edition > .acf-fc-layout-handle .acfe-layout-title .acfe-layout-title-text{
|
65 |
-
display:none;
|
66 |
}
|
1 |
+
/*
|
2 |
+
* ACFE: Flexible Icons
|
3 |
+
*/
|
4 |
+
.acf-flexible-content .layout .acf-icon.acfe-flexible-icon.dashicons{
|
5 |
+
visibility: hidden;
|
6 |
+
}
|
7 |
+
|
8 |
+
.acf-flexible-content .layout .acf-icon.acfe-flexible-icon.dashicons:before{
|
9 |
+
font-family: dashicons;
|
10 |
+
}
|
11 |
+
|
12 |
+
.acf-flexible-content .layout:hover > .acf-fc-layout-controls .acf-icon.acfe-flexible-icon.dashicons{
|
13 |
+
visibility: visible;
|
14 |
+
}
|
15 |
+
|
16 |
+
.acf-flexible-content .layout:hover .acf-fc-layout-controls .acf-icon.-plus,
|
17 |
+
.acf-flexible-content .layout:hover .acf-fc-layout-controls .acf-icon.-minus,
|
18 |
+
.acf-flexible-content .layout.-hover .acf-fc-layout-controls .acf-icon.-plus,
|
19 |
+
.acf-flexible-content .layout.-hover .acf-fc-layout-controls .acf-icon.-minus{
|
20 |
+
visibility: hidden;
|
21 |
+
}
|
22 |
+
|
23 |
+
.acf-flexible-content .layout:hover > .acf-fc-layout-controls .acf-icon.-plus,
|
24 |
+
.acf-flexible-content .layout:hover > .acf-fc-layout-controls .acf-icon.-minus,
|
25 |
+
.acf-flexible-content .layout.-hover > .acf-fc-layout-controls .acf-icon.-plus,
|
26 |
+
.acf-flexible-content .layout.-hover > .acf-fc-layout-controls .acf-icon.-minus{
|
27 |
+
visibility: visible;
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
/*
|
32 |
+
* ACFE: Title Edit
|
33 |
+
*/
|
34 |
+
.acf-field-acfe-flexible-layout-title{
|
35 |
+
display:none;
|
36 |
+
}
|
37 |
+
|
38 |
+
input.acfe-flexible-control-title{
|
39 |
+
border:none;
|
40 |
+
box-shadow:none !important;
|
41 |
+
outline:none !important;
|
42 |
+
border-radius:0;
|
43 |
+
border-bottom:1px solid transparent !important;
|
44 |
+
font-weight:600;
|
45 |
+
width:auto !important;
|
46 |
+
padding:0 !important;
|
47 |
+
display:none;
|
48 |
+
}
|
49 |
+
|
50 |
+
.layout > .acf-fc-layout-handle .acfe-layout-title{
|
51 |
+
cursor:text;
|
52 |
+
position:relative;
|
53 |
+
}
|
54 |
+
|
55 |
+
.layout > .acf-fc-layout-handle .acfe-layout-title:hover{
|
56 |
+
background:#f4f4f4;
|
57 |
+
}
|
58 |
+
|
59 |
+
.layout.acfe-flexible-title-edition > .acf-fc-layout-handle .acfe-layout-title input.acfe-flexible-control-title{
|
60 |
+
display:inline-block;
|
61 |
+
border-bottom:1px solid #ddd !important;
|
62 |
+
}
|
63 |
+
|
64 |
+
.layout.acfe-flexible-title-edition > .acf-fc-layout-handle .acfe-layout-title .acfe-layout-title-text{
|
65 |
+
display:none;
|
66 |
}
|
assets/acf-extended-fc-control.js
CHANGED
@@ -1,607 +1,684 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
if(typeof acf === 'undefined')
|
4 |
-
return;
|
5 |
-
|
6 |
-
/*
|
7 |
-
* Init
|
8 |
-
*/
|
9 |
-
var flexible = acf.getFieldType('flexible_content');
|
10 |
-
var model = flexible.prototype;
|
11 |
-
|
12 |
-
/*
|
13 |
-
* Actions
|
14 |
-
*/
|
15 |
-
|
16 |
-
// Layout: Edit Title
|
17 |
-
model.events['focusout input.acfe-flexible-control-title'] = 'acfeEditLayoutTitleToggle';
|
18 |
-
model.events['click .acfe-layout-title-text'] = 'acfeEditLayoutTitle';
|
19 |
-
model.acfeEditLayoutTitle = function(e, $el){
|
20 |
-
|
21 |
-
//
|
22 |
-
|
23 |
-
|
24 |
-
//
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
var
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
var $hidden = $layout.find('> .acf-fields > .acf-field-acfe-flexible-layout-title > .acf-input > .acf-input-wrap > input');
|
49 |
-
|
50 |
-
}
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
$layout.
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
$
|
108 |
-
|
109 |
-
$
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
var
|
136 |
-
|
137 |
-
//
|
138 |
-
$
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
$input.
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
//
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
var
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
//
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
//
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
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 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
$
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
$input
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
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 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
'
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
607 |
})(jQuery);
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
if(typeof acf === 'undefined')
|
4 |
+
return;
|
5 |
+
|
6 |
+
/*
|
7 |
+
* Init
|
8 |
+
*/
|
9 |
+
var flexible = acf.getFieldType('flexible_content');
|
10 |
+
var model = flexible.prototype;
|
11 |
+
|
12 |
+
/*
|
13 |
+
* Actions
|
14 |
+
*/
|
15 |
+
|
16 |
+
// Layout: Edit Title
|
17 |
+
model.events['focusout input.acfe-flexible-control-title'] = 'acfeEditLayoutTitleToggle';
|
18 |
+
model.events['click .acfe-layout-title-text'] = 'acfeEditLayoutTitle';
|
19 |
+
model.acfeEditLayoutTitle = function(e, $el){
|
20 |
+
|
21 |
+
// Get Flexible
|
22 |
+
var flexible = this;
|
23 |
+
|
24 |
+
// Title Edition
|
25 |
+
if(!flexible.has('acfeFlexibleTitleEdition'))
|
26 |
+
return;
|
27 |
+
|
28 |
+
// Stop propagation
|
29 |
+
e.stopPropagation();
|
30 |
+
|
31 |
+
// Toggle
|
32 |
+
flexible.acfeEditLayoutTitleToggle(e, $el);
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
model.acfeEditLayoutTitleToggle = function(e, $el){
|
37 |
+
|
38 |
+
var flexible = this;
|
39 |
+
|
40 |
+
// Vars
|
41 |
+
var $layout = $el.closest('.layout');
|
42 |
+
var $handle = $layout.find('> .acf-fc-layout-handle');
|
43 |
+
var $title = $handle.find('.acfe-layout-title');
|
44 |
+
|
45 |
+
|
46 |
+
if(flexible.has('acfeFlexibleModalEdition')){
|
47 |
+
|
48 |
+
var $hidden = $layout.find('> .acfe-modal > .acfe-modal-wrapper > .acfe-modal-content > .acf-fields > .acf-field-acfe-flexible-layout-title > .acf-input > .acf-input-wrap > input');
|
49 |
+
|
50 |
+
}else{
|
51 |
+
|
52 |
+
var $hidden = $layout.find('> .acf-fields > .acf-field-acfe-flexible-layout-title > .acf-input > .acf-input-wrap > input');
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
// Hidden Input
|
57 |
+
if($hidden.length){
|
58 |
+
|
59 |
+
// Add Edit Title
|
60 |
+
$hidden.addClass('acfe-flexible-control-title').attr('data-acfe-flexible-control-title-input', 1).insertAfter($handle);
|
61 |
+
|
62 |
+
// Remove legacy field
|
63 |
+
$layout.find('> .acf-fields > .acf-field-acfe-flexible-layout-title').remove();
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
if($layout.hasClass('acfe-flexible-title-edition')){
|
68 |
+
|
69 |
+
var $input = $title.find('> input[data-acfe-flexible-control-title-input]');
|
70 |
+
|
71 |
+
if($input.val() === '')
|
72 |
+
$input.val($input.attr('placeholder')).trigger('input');
|
73 |
+
|
74 |
+
$layout.removeClass('acfe-flexible-title-edition');
|
75 |
+
|
76 |
+
$input.insertAfter($handle);
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
else{
|
81 |
+
|
82 |
+
var $input = $layout.find('> input[data-acfe-flexible-control-title-input]');
|
83 |
+
|
84 |
+
var $input = $input.appendTo($title);
|
85 |
+
|
86 |
+
$layout.addClass('acfe-flexible-title-edition');
|
87 |
+
$input.focus().attr('size', $input.val().length);
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
// Layout: Edit Title
|
94 |
+
model.events['click input.acfe-flexible-control-title'] = 'acfeEditLayoutTitlePropagation';
|
95 |
+
model.acfeEditLayoutTitlePropagation = function(e, $el){
|
96 |
+
|
97 |
+
e.stopPropagation();
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
// Layout: Edit Title Input
|
102 |
+
model.events['input [data-acfe-flexible-control-title-input]'] = 'acfeEditLayoutTitleInput';
|
103 |
+
model.acfeEditLayoutTitleInput = function(e, $el){
|
104 |
+
|
105 |
+
// Vars
|
106 |
+
var $layout = $el.closest('.layout');
|
107 |
+
var $title = $layout.find('> .acf-fc-layout-handle .acfe-layout-title .acfe-layout-title-text');
|
108 |
+
|
109 |
+
var val = $el.val();
|
110 |
+
|
111 |
+
$el.attr('size', val.length);
|
112 |
+
|
113 |
+
$title.html(val);
|
114 |
+
|
115 |
+
}
|
116 |
+
|
117 |
+
// Layout: Edit Title Input Enter
|
118 |
+
model.events['keypress [data-acfe-flexible-control-title-input]'] = 'acfeEditLayoutTitleInputEnter';
|
119 |
+
model.acfeEditLayoutTitleInputEnter = function(e, $el){
|
120 |
+
|
121 |
+
// Enter Key
|
122 |
+
if(e.keyCode != 13)
|
123 |
+
return;
|
124 |
+
|
125 |
+
e.preventDefault();
|
126 |
+
$el.blur();
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
// Layout: Clone
|
131 |
+
model.events['click [data-acfe-flexible-control-clone]'] = 'acfeCloneLayout';
|
132 |
+
model.acfeCloneLayout = function(e, $el){
|
133 |
+
|
134 |
+
// Get Flexible
|
135 |
+
var flexible = this;
|
136 |
+
|
137 |
+
// Vars
|
138 |
+
var $layout_original = $el.closest('.layout');
|
139 |
+
var $layout = $el.closest('.layout').clone();
|
140 |
+
|
141 |
+
// Fix TinyMCE attribute value
|
142 |
+
$layout.find('textarea').each(function(){
|
143 |
+
$(this).html(this.value);
|
144 |
+
});
|
145 |
+
|
146 |
+
// Clean Layout
|
147 |
+
flexible.acfeCleanLayouts($layout);
|
148 |
+
|
149 |
+
var parent = $el.closest('.acf-flexible-content').find('> input[type=hidden]').attr('name');
|
150 |
+
|
151 |
+
// Clone
|
152 |
+
var $layout_added = flexible.acfeDuplicate({
|
153 |
+
layout: $layout,
|
154 |
+
before: $layout_original,
|
155 |
+
parent: parent
|
156 |
+
});
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
// Layout: Copy
|
161 |
+
model.events['click [data-acfe-flexible-control-copy]'] = 'acfeCopyLayout';
|
162 |
+
model.acfeCopyLayout = function(e, $el){
|
163 |
+
|
164 |
+
// Get Flexible
|
165 |
+
var flexible = this;
|
166 |
+
|
167 |
+
// Vars
|
168 |
+
var $layout = $el.closest('.layout').clone();
|
169 |
+
var source = flexible.$control().find('> input[type=hidden]').attr('name');
|
170 |
+
|
171 |
+
// Fix inputs
|
172 |
+
flexible.acfeFixInputs($layout);
|
173 |
+
|
174 |
+
// Clean layout
|
175 |
+
flexible.acfeCleanLayouts($layout);
|
176 |
+
|
177 |
+
// Get layout data
|
178 |
+
var data = JSON.stringify({
|
179 |
+
source: source,
|
180 |
+
layouts: $layout[0].outerHTML
|
181 |
+
});
|
182 |
+
|
183 |
+
// Append Temp Input
|
184 |
+
var $input = $('<input type="text" style="clip:rect(0,0,0,0);clip-path:rect(0,0,0,0);position:absolute;" value="" />').appendTo($el);
|
185 |
+
$input.attr('value', data).select();
|
186 |
+
|
187 |
+
// Command: Copy
|
188 |
+
if(document.execCommand('copy'))
|
189 |
+
alert('Layout has been transferred to your clipboard');
|
190 |
+
|
191 |
+
// Prompt
|
192 |
+
else
|
193 |
+
prompt('Copy the following layout data to your clipboard', data);
|
194 |
+
|
195 |
+
// Remove the temp input
|
196 |
+
$input.remove();
|
197 |
+
|
198 |
+
}
|
199 |
+
|
200 |
+
// Flexible: Copy Layouts
|
201 |
+
model.acfeCopyLayouts = function(){
|
202 |
+
|
203 |
+
// Get Flexible
|
204 |
+
var flexible = this;
|
205 |
+
|
206 |
+
// Get layouts
|
207 |
+
var $layouts = flexible.$layoutsWrap().clone();
|
208 |
+
var source = flexible.$control().find('> input[type=hidden]').attr('name');
|
209 |
+
|
210 |
+
// Fix inputs
|
211 |
+
flexible.acfeFixInputs($layouts);
|
212 |
+
|
213 |
+
// Clean layout
|
214 |
+
flexible.acfeCleanLayouts($layouts);
|
215 |
+
|
216 |
+
// Get layouts data
|
217 |
+
var data = JSON.stringify({
|
218 |
+
source: source,
|
219 |
+
layouts: $layouts.html()
|
220 |
+
});
|
221 |
+
|
222 |
+
// Append Temp Input
|
223 |
+
var $input = $('<input type="text" style="clip:rect(0,0,0,0);clip-path:rect(0,0,0,0);position:absolute;" value="" />').appendTo(flexible.$el);
|
224 |
+
$input.attr('value', data).select();
|
225 |
+
|
226 |
+
// Command: Copy
|
227 |
+
if(document.execCommand('copy'))
|
228 |
+
alert('Layouts have been transferred to your clipboard');
|
229 |
+
|
230 |
+
// Prompt
|
231 |
+
else
|
232 |
+
prompt('Copy the following layouts data to your clipboard', data);
|
233 |
+
|
234 |
+
$input.remove();
|
235 |
+
|
236 |
+
}
|
237 |
+
|
238 |
+
// Flexible: Paste Layouts
|
239 |
+
model.acfePasteLayouts = function(){
|
240 |
+
|
241 |
+
// Get Flexible
|
242 |
+
var flexible = this;
|
243 |
+
|
244 |
+
var paste = prompt('Paste layouts data in the following field');
|
245 |
+
|
246 |
+
// No input
|
247 |
+
if(paste == null || paste === '')
|
248 |
+
return;
|
249 |
+
|
250 |
+
try{
|
251 |
+
|
252 |
+
// Paste HTML
|
253 |
+
var data = JSON.parse(paste);
|
254 |
+
var source = data.source;
|
255 |
+
var $html = $(data.layouts);
|
256 |
+
|
257 |
+
// Parsed layouts
|
258 |
+
var $html_layouts = $html.closest('[data-layout]');
|
259 |
+
|
260 |
+
if(!$html_layouts.length)
|
261 |
+
return alert('No layouts data available');
|
262 |
+
|
263 |
+
// init
|
264 |
+
var validated_layouts = [];
|
265 |
+
|
266 |
+
// Each first level layouts
|
267 |
+
$html_layouts.each(function(){
|
268 |
+
|
269 |
+
var $this = $(this);
|
270 |
+
|
271 |
+
// Validate layout against available layouts
|
272 |
+
var get_clone_layout = flexible.$clone($this.attr('data-layout'));
|
273 |
+
|
274 |
+
// Layout is invalid
|
275 |
+
if(!get_clone_layout.length)
|
276 |
+
return;
|
277 |
+
|
278 |
+
// Add validated layout
|
279 |
+
validated_layouts.push($this);
|
280 |
+
|
281 |
+
});
|
282 |
+
|
283 |
+
// Nothing to add
|
284 |
+
if(!validated_layouts.length)
|
285 |
+
return alert('No corresponding layouts found');
|
286 |
+
|
287 |
+
// Add layouts
|
288 |
+
$.each(validated_layouts, function(){
|
289 |
+
|
290 |
+
var $layout = $(this);
|
291 |
+
var search = source + '[' + $layout.attr('data-id') + ']';
|
292 |
+
var target = flexible.$control().find('> input[type=hidden]').attr('name');
|
293 |
+
|
294 |
+
flexible.acfeDuplicate({
|
295 |
+
layout: $layout,
|
296 |
+
before: false,
|
297 |
+
search: search,
|
298 |
+
parent: target
|
299 |
+
});
|
300 |
+
|
301 |
+
});
|
302 |
+
|
303 |
+
}catch(e){
|
304 |
+
|
305 |
+
console.log(e);
|
306 |
+
alert('Invalid data');
|
307 |
+
|
308 |
+
}
|
309 |
+
|
310 |
+
}
|
311 |
+
|
312 |
+
// Flexible: Dropdown
|
313 |
+
model.events['click [data-name="acfe-flexible-control-button"]'] = 'acfeControl';
|
314 |
+
model.acfeControl = function(e, $el){
|
315 |
+
|
316 |
+
// Get Flexible
|
317 |
+
var flexible = this;
|
318 |
+
|
319 |
+
// Vars
|
320 |
+
var $dropdown = $el.next('.tmpl-acfe-flexible-control-popup').html();
|
321 |
+
|
322 |
+
// Init Popup
|
323 |
+
var Popup = acf.models.TooltipConfirm.extend({
|
324 |
+
render: function(){
|
325 |
+
this.html(this.get('text'));
|
326 |
+
this.$el.addClass('acf-fc-popup');
|
327 |
+
}
|
328 |
+
});
|
329 |
+
|
330 |
+
// New Popup
|
331 |
+
var popup = new Popup({
|
332 |
+
target: $el,
|
333 |
+
targetConfirm: false,
|
334 |
+
text: $dropdown,
|
335 |
+
context: flexible,
|
336 |
+
confirm: function(e, $el){
|
337 |
+
|
338 |
+
if($el.attr('data-acfe-flexible-control-action') === 'paste')
|
339 |
+
flexible.acfePasteLayouts();
|
340 |
+
|
341 |
+
else if($el.attr('data-acfe-flexible-control-action') === 'copy')
|
342 |
+
flexible.acfeCopyLayouts();
|
343 |
+
|
344 |
+
}
|
345 |
+
});
|
346 |
+
|
347 |
+
popup.on('click', 'a', 'onConfirm');
|
348 |
+
|
349 |
+
}
|
350 |
+
|
351 |
+
// Flexible: Duplicate
|
352 |
+
model.acfeDuplicate = function(args){
|
353 |
+
|
354 |
+
// Arguments
|
355 |
+
args = acf.parseArgs(args, {
|
356 |
+
layout: '',
|
357 |
+
before: false,
|
358 |
+
parent: false,
|
359 |
+
search: '',
|
360 |
+
replace: '',
|
361 |
+
});
|
362 |
+
|
363 |
+
// Validate
|
364 |
+
if(!this.allowAdd())
|
365 |
+
return false;
|
366 |
+
|
367 |
+
var uniqid = acf.uniqid();
|
368 |
+
|
369 |
+
if(args.parent){
|
370 |
+
|
371 |
+
if(!args.search){
|
372 |
+
|
373 |
+
args.search = args.parent + '[' + args.layout.attr('data-id') + ']';
|
374 |
+
|
375 |
+
}
|
376 |
+
|
377 |
+
args.replace = args.parent + '[' + uniqid + ']';
|
378 |
+
|
379 |
+
}
|
380 |
+
|
381 |
+
// Add row
|
382 |
+
var $el = acf.duplicate({
|
383 |
+
target: args.layout,
|
384 |
+
search: args.search,
|
385 |
+
replace: args.replace,
|
386 |
+
append: this.proxy(function($el, $el2){
|
387 |
+
|
388 |
+
// Add class to duplicated layout
|
389 |
+
$el2.addClass('acfe-layout-duplicated');
|
390 |
+
|
391 |
+
// Reset UniqID
|
392 |
+
$el2.attr('data-id', uniqid);
|
393 |
+
|
394 |
+
// append before
|
395 |
+
if(args.before){
|
396 |
+
|
397 |
+
// Fix clone: Use after() instead of native before()
|
398 |
+
args.before.after($el2);
|
399 |
+
|
400 |
+
}
|
401 |
+
|
402 |
+
// append end
|
403 |
+
else{
|
404 |
+
|
405 |
+
this.$layoutsWrap().append($el2);
|
406 |
+
|
407 |
+
}
|
408 |
+
|
409 |
+
// enable
|
410 |
+
acf.enable($el2, this.cid);
|
411 |
+
|
412 |
+
// render
|
413 |
+
this.render();
|
414 |
+
|
415 |
+
})
|
416 |
+
});
|
417 |
+
|
418 |
+
// trigger change for validation errors
|
419 |
+
this.$input().trigger('change');
|
420 |
+
|
421 |
+
// return
|
422 |
+
return $el;
|
423 |
+
|
424 |
+
}
|
425 |
+
|
426 |
+
// Flexible: Fix Inputs
|
427 |
+
model.acfeFixInputs = function($layout){
|
428 |
+
|
429 |
+
$layout.find('input').each(function(){
|
430 |
+
|
431 |
+
$(this).attr('value', this.value);
|
432 |
+
|
433 |
+
});
|
434 |
+
|
435 |
+
$layout.find('textarea').each(function(){
|
436 |
+
|
437 |
+
$(this).html(this.value);
|
438 |
+
|
439 |
+
});
|
440 |
+
|
441 |
+
$layout.find('input:radio,input:checkbox').each(function() {
|
442 |
+
|
443 |
+
if($(this).checked)
|
444 |
+
$(this).attr('checked', 'checked');
|
445 |
+
else
|
446 |
+
$(this).attr('checked', false);
|
447 |
+
|
448 |
+
});
|
449 |
+
|
450 |
+
$layout.find('option').each(function(){
|
451 |
+
if($(this).selected)
|
452 |
+
$(this).attr('selected', 'selected');
|
453 |
+
else
|
454 |
+
$(this).attr('selected', false);
|
455 |
+
});
|
456 |
+
|
457 |
+
}
|
458 |
+
|
459 |
+
// Flexible: Clean Layout
|
460 |
+
model.acfeCleanLayouts = function($layout){
|
461 |
+
|
462 |
+
// Clean WP Editor
|
463 |
+
$layout.find('.acf-editor-wrap').each(function(){
|
464 |
+
|
465 |
+
var $input = $(this);
|
466 |
+
|
467 |
+
$input.find('.wp-editor-container div').remove();
|
468 |
+
$input.find('.wp-editor-container textarea').css('display', '');
|
469 |
+
|
470 |
+
});
|
471 |
+
|
472 |
+
// Clean Date
|
473 |
+
$layout.find('.acf-date-picker').each(function(){
|
474 |
+
|
475 |
+
var $input = $(this);
|
476 |
+
|
477 |
+
$input.find('input.input').removeClass('hasDatepicker').removeAttr('id');
|
478 |
+
|
479 |
+
});
|
480 |
+
|
481 |
+
// Clean Time
|
482 |
+
$layout.find('.acf-time-picker').each(function(){
|
483 |
+
|
484 |
+
var $input = $(this);
|
485 |
+
|
486 |
+
$input.find('input.input').removeClass('hasDatepicker').removeAttr('id');
|
487 |
+
|
488 |
+
});
|
489 |
+
|
490 |
+
// Clean DateTime
|
491 |
+
$layout.find('.acf-date-time-picker').each(function(){
|
492 |
+
|
493 |
+
var $input = $(this);
|
494 |
+
|
495 |
+
$input.find('input.input').removeClass('hasDatepicker').removeAttr('id');
|
496 |
+
|
497 |
+
});
|
498 |
+
|
499 |
+
// Clean Color Picker
|
500 |
+
$layout.find('.acf-color-picker').each(function(){
|
501 |
+
|
502 |
+
var $input = $(this);
|
503 |
+
|
504 |
+
var $color_picker = $input.find('> input');
|
505 |
+
var $color_picker_proxy = $input.find('.wp-picker-container input.wp-color-picker').clone();
|
506 |
+
|
507 |
+
$color_picker.after($color_picker_proxy);
|
508 |
+
|
509 |
+
$input.find('.wp-picker-container').remove();
|
510 |
+
|
511 |
+
});
|
512 |
+
|
513 |
+
// Clean Post Object
|
514 |
+
$layout.find('.acf-field-post-object').each(function(){
|
515 |
+
|
516 |
+
var $input = $(this);
|
517 |
+
|
518 |
+
$input.find('> .acf-input span').remove();
|
519 |
+
|
520 |
+
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden').removeClass();
|
521 |
+
|
522 |
+
});
|
523 |
+
|
524 |
+
// Clean Page Link
|
525 |
+
$layout.find('.acf-field-page-link').each(function(){
|
526 |
+
|
527 |
+
var $input = $(this);
|
528 |
+
|
529 |
+
$input.find('> .acf-input span').remove();
|
530 |
+
|
531 |
+
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden').removeClass();
|
532 |
+
|
533 |
+
});
|
534 |
+
|
535 |
+
// Clean Select2
|
536 |
+
$layout.find('.acf-field-select').each(function(){
|
537 |
+
|
538 |
+
var $input = $(this);
|
539 |
+
|
540 |
+
$input.find('> .acf-input span').remove();
|
541 |
+
|
542 |
+
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden').removeClass();
|
543 |
+
|
544 |
+
});
|
545 |
+
|
546 |
+
// Clean FontAwesome
|
547 |
+
$layout.find('.acf-field-font-awesome').each(function(){
|
548 |
+
|
549 |
+
var $input = $(this);
|
550 |
+
|
551 |
+
$input.find('> .acf-input span').remove();
|
552 |
+
|
553 |
+
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden');
|
554 |
+
|
555 |
+
});
|
556 |
+
|
557 |
+
// Clean Tab
|
558 |
+
$layout.find('.acf-tab-wrap').each(function(){
|
559 |
+
|
560 |
+
var $wrap = $(this);
|
561 |
+
|
562 |
+
var $content = $wrap.closest('.acf-fields');
|
563 |
+
|
564 |
+
var tabs = []
|
565 |
+
$.each($wrap.find('li a'), function(){
|
566 |
+
|
567 |
+
tabs.push($(this));
|
568 |
+
|
569 |
+
});
|
570 |
+
|
571 |
+
$content.find('> .acf-field-tab').each(function(){
|
572 |
+
|
573 |
+
$current_tab = $(this);
|
574 |
+
|
575 |
+
$.each(tabs, function(){
|
576 |
+
|
577 |
+
var $this = $(this);
|
578 |
+
|
579 |
+
if($this.attr('data-key') != $current_tab.attr('data-key'))
|
580 |
+
return;
|
581 |
+
|
582 |
+
$current_tab.find('> .acf-input').append($this);
|
583 |
+
|
584 |
+
});
|
585 |
+
|
586 |
+
});
|
587 |
+
|
588 |
+
$wrap.remove();
|
589 |
+
|
590 |
+
});
|
591 |
+
|
592 |
+
// Clean Accordion
|
593 |
+
$layout.find('.acf-field-accordion').each(function(){
|
594 |
+
|
595 |
+
var $input = $(this);
|
596 |
+
|
597 |
+
$input.find('> .acf-accordion-title > .acf-accordion-icon').remove();
|
598 |
+
|
599 |
+
// Append virtual endpoint after each accordion
|
600 |
+
$input.after('<div class="acf-field acf-field-accordion" data-type="accordion"><div class="acf-input"><div class="acf-fields" data-endpoint="1"></div></div></div>');
|
601 |
+
|
602 |
+
});
|
603 |
+
|
604 |
+
}
|
605 |
+
|
606 |
+
/*
|
607 |
+
* Spawn
|
608 |
+
*/
|
609 |
+
acf.addAction('new_field/type=flexible_content', function(flexible){
|
610 |
+
|
611 |
+
if(!flexible.has('acfeFlexibleCopyPaste'))
|
612 |
+
return;
|
613 |
+
|
614 |
+
/*
|
615 |
+
* Stylised Button
|
616 |
+
*/
|
617 |
+
if(flexible.has('acfeFlexibleStylisedButton')){
|
618 |
+
|
619 |
+
var $dropdown = $('' +
|
620 |
+
'<a href="#" class="button" style="padding-left:5px;padding-right:5px; margin-left:3px;" data-name="acfe-flexible-control-button">' +
|
621 |
+
' <span class="dashicons dashicons-arrow-down-alt2" style="vertical-align:text-top;width:auto;height:auto;font-size:13px;line-height:20px;"></span>' +
|
622 |
+
'</a>' +
|
623 |
+
|
624 |
+
'<script type="text-html" class="tmpl-acfe-flexible-control-popup">' +
|
625 |
+
' <ul>' +
|
626 |
+
' <li><a href="#" data-acfe-flexible-control-action="copy">Copy layouts</a></li>' +
|
627 |
+
' <li><a href="#" data-acfe-flexible-control-action="paste">Paste layouts</a></li>' +
|
628 |
+
' </ul>' +
|
629 |
+
'</script>');
|
630 |
+
|
631 |
+
// Add button
|
632 |
+
flexible.$el.find('> .acf-input > .acf-flexible-content > .acfe-flexible-stylised-button > .acf-actions > .acf-button').after($dropdown);
|
633 |
+
|
634 |
+
|
635 |
+
}
|
636 |
+
|
637 |
+
/*
|
638 |
+
* Unstylised
|
639 |
+
*/
|
640 |
+
else{
|
641 |
+
|
642 |
+
var $dropdown = $('' +
|
643 |
+
'<a href="#" class="button button-primary" style="padding-left:5px;padding-right:5px; margin-left:3px;" data-name="acfe-flexible-control-button">' +
|
644 |
+
' <span class="dashicons dashicons-arrow-down-alt2" style="vertical-align:text-top;width:auto;height:auto;font-size:13px;line-height:20px;"></span>' +
|
645 |
+
'</a>' +
|
646 |
+
|
647 |
+
'<script type="text-html" class="tmpl-acfe-flexible-control-popup">' +
|
648 |
+
' <ul>' +
|
649 |
+
' <li><a href="#" data-acfe-flexible-control-action="copy">Copy layouts</a></li>' +
|
650 |
+
' <li><a href="#" data-acfe-flexible-control-action="paste">Paste layouts</a></li>' +
|
651 |
+
' </ul>' +
|
652 |
+
'</script>');
|
653 |
+
|
654 |
+
// Add button
|
655 |
+
flexible.$el.find('> .acf-input > .acf-flexible-content > .acf-actions > .acf-button').after($dropdown);
|
656 |
+
|
657 |
+
}
|
658 |
+
|
659 |
+
});
|
660 |
+
|
661 |
+
acf.addAction('acfe/flexible/layouts', function($layout, flexible){
|
662 |
+
|
663 |
+
// vars
|
664 |
+
var $controls = $layout.find('> .acf-fc-layout-controls');
|
665 |
+
|
666 |
+
// Button: Copy
|
667 |
+
if(flexible.has('acfeFlexibleCopyPaste') && !$controls.has('[data-acfe-flexible-control-copy]').length){
|
668 |
+
|
669 |
+
$controls.prepend('<a class="acf-icon small light acf-js-tooltip acfe-flexible-icon dashicons dashicons-category" href="#" title="Copy layout" data-acfe-flexible-control-copy="' + $layout.attr('data-layout') + '"></a>');
|
670 |
+
|
671 |
+
}
|
672 |
+
|
673 |
+
// Button: Clone
|
674 |
+
if(!$controls.has('[data-acfe-flexible-control-clone]').length){
|
675 |
+
|
676 |
+
$controls.prepend('<a class="acf-icon small light acf-js-tooltip acfe-flexible-icon dashicons dashicons-admin-page" href="#" title="Clone layout" data-acfe-flexible-control-clone="' + $layout.attr('data-layout') + '"></a>');
|
677 |
+
|
678 |
+
}
|
679 |
+
|
680 |
+
|
681 |
+
|
682 |
+
});
|
683 |
+
|
684 |
})(jQuery);
|
assets/acf-extended-fc-modal-edit.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
/*
|
2 |
-
* Flexible Edit: Hide Collapse
|
3 |
-
*/
|
4 |
-
.acf-field-flexible-content[data-acfe-flexible-modal-edition="1"] > .acf-input > .acf-flexible-content > .values > .layout > .acf-fc-layout-controls > a.-collapse{
|
5 |
-
display:none;
|
6 |
}
|
1 |
+
/*
|
2 |
+
* Flexible Edit: Hide Collapse
|
3 |
+
*/
|
4 |
+
.acf-field-flexible-content[data-acfe-flexible-modal-edition="1"] > .acf-input > .acf-flexible-content > .values > .layout > .acf-fc-layout-controls > a.-collapse{
|
5 |
+
display:none;
|
6 |
}
|
assets/acf-extended-fc-modal-edit.js
CHANGED
@@ -1,82 +1,86 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
if(typeof acf === 'undefined')
|
4 |
-
return;
|
5 |
-
|
6 |
-
/*
|
7 |
-
* Init
|
8 |
-
*/
|
9 |
-
var flexible = acf.getFieldType('flexible_content');
|
10 |
-
var model = flexible.prototype;
|
11 |
-
|
12 |
-
/*
|
13 |
-
* Actions
|
14 |
-
*/
|
15 |
-
model.events['click [data-action="acfe-flexible-modal-edit"]'] = 'acfeModalEdit';
|
16 |
-
model.acfeModalEdit = function(e, $el){
|
17 |
-
|
18 |
-
var flexible = this;
|
19 |
-
|
20 |
-
// Layout
|
21 |
-
var $layout = $el.closest('.layout');
|
22 |
-
|
23 |
-
// Modal data
|
24 |
-
var $modal = $layout.find('> .acfe-modal');
|
25 |
-
var $handle = $layout.find('> .acf-fc-layout-handle');
|
26 |
-
|
27 |
-
var $layout_order = $handle.find('> .acf-fc-layout-order').outerHTML();
|
28 |
-
var $layout_title = $handle.find('.acfe-layout-title-text').text();
|
29 |
-
|
30 |
-
var close = false;
|
31 |
-
if(flexible.has('acfeFlexibleCloseButton')){
|
32 |
-
|
33 |
-
close = 'Close';
|
34 |
-
|
35 |
-
}
|
36 |
-
|
37 |
-
// Open modal
|
38 |
-
acfe.modal.open($modal, {
|
39 |
-
title: $layout_order + ' ' + $layout_title,
|
40 |
-
footer: close,
|
41 |
-
onClose: function(){
|
42 |
-
|
43 |
-
flexible.acfeCloseLayoutInit($layout);
|
44 |
-
|
45 |
-
}
|
46 |
-
});
|
47 |
-
|
48 |
-
};
|
49 |
-
|
50 |
-
/*
|
51 |
-
* Spawn
|
52 |
-
*/
|
53 |
-
acf.addAction('new_field/type=flexible_content', function(flexible){
|
54 |
-
|
55 |
-
if(!flexible.has('acfeFlexibleModalEdition'))
|
56 |
-
return;
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
|
|
82 |
})(jQuery);
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
if(typeof acf === 'undefined')
|
4 |
+
return;
|
5 |
+
|
6 |
+
/*
|
7 |
+
* Init
|
8 |
+
*/
|
9 |
+
var flexible = acf.getFieldType('flexible_content');
|
10 |
+
var model = flexible.prototype;
|
11 |
+
|
12 |
+
/*
|
13 |
+
* Actions
|
14 |
+
*/
|
15 |
+
model.events['click [data-action="acfe-flexible-modal-edit"]'] = 'acfeModalEdit';
|
16 |
+
model.acfeModalEdit = function(e, $el){
|
17 |
+
|
18 |
+
var flexible = this;
|
19 |
+
|
20 |
+
// Layout
|
21 |
+
var $layout = $el.closest('.layout');
|
22 |
+
|
23 |
+
// Modal data
|
24 |
+
var $modal = $layout.find('> .acfe-modal');
|
25 |
+
var $handle = $layout.find('> .acf-fc-layout-handle');
|
26 |
+
|
27 |
+
var $layout_order = $handle.find('> .acf-fc-layout-order').outerHTML();
|
28 |
+
var $layout_title = $handle.find('.acfe-layout-title-text').text();
|
29 |
+
|
30 |
+
var close = false;
|
31 |
+
if(flexible.has('acfeFlexibleCloseButton')){
|
32 |
+
|
33 |
+
close = 'Close';
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
// Open modal
|
38 |
+
acfe.modal.open($modal, {
|
39 |
+
title: $layout_order + ' ' + $layout_title,
|
40 |
+
footer: close,
|
41 |
+
onClose: function(){
|
42 |
+
|
43 |
+
flexible.acfeCloseLayoutInit($layout);
|
44 |
+
|
45 |
+
}
|
46 |
+
});
|
47 |
+
|
48 |
+
};
|
49 |
+
|
50 |
+
/*
|
51 |
+
* Spawn
|
52 |
+
*/
|
53 |
+
acf.addAction('new_field/type=flexible_content', function(flexible){
|
54 |
+
|
55 |
+
if(!flexible.has('acfeFlexibleModalEdition'))
|
56 |
+
return;
|
57 |
+
|
58 |
+
if(flexible.has('acfeFlexiblePlaceholder') || flexible.has('acfeFlexiblePreview')){
|
59 |
+
|
60 |
+
// Remove Collapse Action
|
61 |
+
flexible.removeEvents({'click [data-name="collapse-layout"]': 'onClickCollapse'});
|
62 |
+
|
63 |
+
// Remove placeholder Collapse Action
|
64 |
+
flexible.removeEvents({'click .acfe-flexible-collapsed-placeholder': 'onClickCollapse'});
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
});
|
69 |
+
|
70 |
+
/*
|
71 |
+
* Remove Legacy Collapse
|
72 |
+
*/
|
73 |
+
acf.addAction('acfe/flexible/layouts', function($layout, flexible){
|
74 |
+
|
75 |
+
if(!flexible.has('acfeFlexibleModalEdition'))
|
76 |
+
return;
|
77 |
+
|
78 |
+
// var
|
79 |
+
var $controls = $layout.find('> .acf-fc-layout-controls');
|
80 |
+
|
81 |
+
// Remove collapse button
|
82 |
+
$controls.find('> a.-collapse').remove();
|
83 |
+
|
84 |
+
});
|
85 |
+
|
86 |
})(jQuery);
|
assets/acf-extended-fc-modal-select.js
CHANGED
@@ -1,195 +1,296 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
if(typeof acf === 'undefined')
|
4 |
-
return;
|
5 |
-
|
6 |
-
/*
|
7 |
-
* Init
|
8 |
-
*/
|
9 |
-
var flexible = acf.getFieldType('flexible_content');
|
10 |
-
var model = flexible.prototype;
|
11 |
-
|
12 |
-
/*
|
13 |
-
* Actions
|
14 |
-
*/
|
15 |
-
model.acfeModalSelect = function(e, $el){
|
16 |
-
|
17 |
-
// Get Flexible
|
18 |
-
var flexible = this;
|
19 |
-
|
20 |
-
// Validate
|
21 |
-
if(!flexible.validateAdd())
|
22 |
-
return false;
|
23 |
-
|
24 |
-
// Layout
|
25 |
-
var $layout_source = null;
|
26 |
-
|
27 |
-
if($el.hasClass('acf-icon'))
|
28 |
-
$layout_source = $el.closest('.layout');
|
29 |
-
|
30 |
-
// Get Available Layouts
|
31 |
-
var layouts = flexible.getPopupHTML();
|
32 |
-
|
33 |
-
// Init Categories
|
34 |
-
var categories = {
|
35 |
-
array: [],
|
36 |
-
html: ''
|
37 |
-
};
|
38 |
-
|
39 |
-
// Get Categories
|
40 |
-
$(layouts).find('li a span').each(function(){
|
41 |
-
|
42 |
-
var $link = $(this);
|
43 |
-
|
44 |
-
if(!$link.data('acfe-flexible-category'))
|
45 |
-
return true;
|
46 |
-
|
47 |
-
var category = $link.data('acfe-flexible-category');
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
if(
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
'
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
$modal.
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
var
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
})(jQuery);
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
if(typeof acf === 'undefined')
|
4 |
+
return;
|
5 |
+
|
6 |
+
/*
|
7 |
+
* Init
|
8 |
+
*/
|
9 |
+
var flexible = acf.getFieldType('flexible_content');
|
10 |
+
var model = flexible.prototype;
|
11 |
+
|
12 |
+
/*
|
13 |
+
* Actions
|
14 |
+
*/
|
15 |
+
model.acfeModalSelect = function(e, $el){
|
16 |
+
|
17 |
+
// Get Flexible
|
18 |
+
var flexible = this;
|
19 |
+
|
20 |
+
// Validate
|
21 |
+
if(!flexible.validateAdd())
|
22 |
+
return false;
|
23 |
+
|
24 |
+
// Layout
|
25 |
+
var $layout_source = null;
|
26 |
+
|
27 |
+
if($el.hasClass('acf-icon'))
|
28 |
+
$layout_source = $el.closest('.layout');
|
29 |
+
|
30 |
+
// Get Available Layouts
|
31 |
+
var layouts = flexible.getPopupHTML();
|
32 |
+
|
33 |
+
// Init Categories
|
34 |
+
var categories = {
|
35 |
+
array: [],
|
36 |
+
html: ''
|
37 |
+
};
|
38 |
+
|
39 |
+
// Get Categories
|
40 |
+
$(layouts).find('li a span').each(function(){
|
41 |
+
|
42 |
+
var $link = $(this);
|
43 |
+
|
44 |
+
if(!$link.data('acfe-flexible-category'))
|
45 |
+
return true;
|
46 |
+
|
47 |
+
var category = $link.data('acfe-flexible-category');
|
48 |
+
|
49 |
+
// With pipes
|
50 |
+
if(category.indexOf('|') != -1){
|
51 |
+
|
52 |
+
var cats = category.split('|');
|
53 |
+
|
54 |
+
$(cats).each(function(i, c){
|
55 |
+
|
56 |
+
if(categories.array.indexOf(c) != -1)
|
57 |
+
return true;
|
58 |
+
|
59 |
+
categories.array.push(c);
|
60 |
+
|
61 |
+
});
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
// Without pipes
|
66 |
+
else{
|
67 |
+
|
68 |
+
if(categories.array.indexOf(category) != -1)
|
69 |
+
return true;
|
70 |
+
|
71 |
+
categories.array.push(category);
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
});
|
76 |
+
|
77 |
+
// Categories HTML
|
78 |
+
if(categories.array.length){
|
79 |
+
|
80 |
+
categories.array.sort();
|
81 |
+
|
82 |
+
categories.html += '<h2 class="acfe-flexible-categories nav-tab-wrapper">';
|
83 |
+
|
84 |
+
categories.html += '<a href="#" data-acfe-flexible-category="acfe-all" class="nav-tab nav-tab-active"><span class="dashicons dashicons-menu"></span></a>';
|
85 |
+
|
86 |
+
$(categories.array).each(function(k, category){
|
87 |
+
|
88 |
+
categories.html += '<a href="#" data-acfe-flexible-category="' + category + '" class="nav-tab">' + category + '</a>';
|
89 |
+
|
90 |
+
});
|
91 |
+
|
92 |
+
categories.html += '</h2>';
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
// Modal Title
|
97 |
+
var $modal_title = 'Add Row';
|
98 |
+
|
99 |
+
if(flexible.has('acfeFlexibleModalTitle'))
|
100 |
+
$modal_title = flexible.get('acfeFlexibleModalTitle');
|
101 |
+
|
102 |
+
// Create Modal
|
103 |
+
var $modal = $('' +
|
104 |
+
'<div class="acfe-modal">' +
|
105 |
+
|
106 |
+
categories.html +
|
107 |
+
'<div class="acfe-flex-container">' +
|
108 |
+
layouts +
|
109 |
+
'</div>' +
|
110 |
+
|
111 |
+
'</div>'
|
112 |
+
|
113 |
+
).appendTo('body');
|
114 |
+
|
115 |
+
// Open Modal
|
116 |
+
var $modal = acfe.modal.open($modal, {
|
117 |
+
title: $modal_title,
|
118 |
+
size: 'full',
|
119 |
+
destroy: true
|
120 |
+
});
|
121 |
+
|
122 |
+
// Modal: Columns
|
123 |
+
if(flexible.has('acfeFlexibleModalCol'))
|
124 |
+
$modal.find('.acfe-modal-content .acfe-flex-container').addClass('acfe-col-' + flexible.get('acfeFlexibleModalCol'));
|
125 |
+
|
126 |
+
// Modal: ACF autofocus fix
|
127 |
+
$modal.find('li:first-of-type a').blur();
|
128 |
+
|
129 |
+
// count layouts
|
130 |
+
var $layouts = flexible.$layouts();
|
131 |
+
var countLayouts = function(name){
|
132 |
+
|
133 |
+
return $layouts.filter(function(){
|
134 |
+
return $(this).data('layout') === name;
|
135 |
+
}).length;
|
136 |
+
|
137 |
+
};
|
138 |
+
|
139 |
+
$modal.find('a[data-layout]').each(function(){
|
140 |
+
|
141 |
+
// vars
|
142 |
+
var $a = $(this);
|
143 |
+
var min = $a.data('min') || 0;
|
144 |
+
var max = $a.data('max') || 0;
|
145 |
+
var name = $a.data('layout') || '';
|
146 |
+
var count = countLayouts( name );
|
147 |
+
|
148 |
+
// max
|
149 |
+
if(max && count >= max){
|
150 |
+
$a.addClass('disabled');
|
151 |
+
return;
|
152 |
+
}
|
153 |
+
|
154 |
+
// min
|
155 |
+
if(min && count < min){
|
156 |
+
|
157 |
+
// vars
|
158 |
+
var required = min - count;
|
159 |
+
var title = acf.__('{required} {label} {identifier} required (min {min})');
|
160 |
+
var identifier = acf._n('layout', 'layouts', required);
|
161 |
+
|
162 |
+
// translate
|
163 |
+
title = title.replace('{required}', required);
|
164 |
+
title = title.replace('{label}', name); // 5.5.0
|
165 |
+
title = title.replace('{identifier}', identifier);
|
166 |
+
title = title.replace('{min}', min);
|
167 |
+
|
168 |
+
// badge
|
169 |
+
$a.append('<span class="badge" title="' + title + '">' + required + '</span>');
|
170 |
+
|
171 |
+
}
|
172 |
+
|
173 |
+
});
|
174 |
+
|
175 |
+
// Modal: Click Categories
|
176 |
+
$modal.find('.acfe-flexible-categories a').click(function(e){
|
177 |
+
|
178 |
+
e.preventDefault();
|
179 |
+
|
180 |
+
var $link = $(this);
|
181 |
+
|
182 |
+
$link.closest('.acfe-flexible-categories').find('a').removeClass('nav-tab-active');
|
183 |
+
$link.addClass('nav-tab-active');
|
184 |
+
|
185 |
+
var selected_category = $link.data('acfe-flexible-category');
|
186 |
+
|
187 |
+
$modal.find('a[data-layout] span').each(function(){
|
188 |
+
|
189 |
+
// Get span
|
190 |
+
var $span = $(this);
|
191 |
+
|
192 |
+
// Show All
|
193 |
+
$span.closest('li').show();
|
194 |
+
|
195 |
+
var category = $span.data('acfe-flexible-category');
|
196 |
+
|
197 |
+
// Specific category
|
198 |
+
if(selected_category !== 'acfe-all'){
|
199 |
+
|
200 |
+
// Hide All
|
201 |
+
$span.closest('li').hide();
|
202 |
+
|
203 |
+
// With pipes
|
204 |
+
if(category.indexOf('|') != -1){
|
205 |
+
|
206 |
+
var cats = category.split('|');
|
207 |
+
|
208 |
+
$(cats).each(function(i, c){
|
209 |
+
|
210 |
+
if(selected_category === c){
|
211 |
+
|
212 |
+
$span.closest('li').show();
|
213 |
+
|
214 |
+
return false;
|
215 |
+
|
216 |
+
}
|
217 |
+
|
218 |
+
});
|
219 |
+
|
220 |
+
}
|
221 |
+
|
222 |
+
// Without pipes
|
223 |
+
else{
|
224 |
+
|
225 |
+
if(selected_category === category){
|
226 |
+
|
227 |
+
$span.closest('li').show();
|
228 |
+
|
229 |
+
}
|
230 |
+
|
231 |
+
}
|
232 |
+
|
233 |
+
}
|
234 |
+
|
235 |
+
});
|
236 |
+
|
237 |
+
});
|
238 |
+
|
239 |
+
// Modal: Click Add Layout
|
240 |
+
$modal.on('click', 'a[data-layout]', function(e){
|
241 |
+
|
242 |
+
e.preventDefault();
|
243 |
+
|
244 |
+
// Add layout
|
245 |
+
var $layout_added = flexible.add({
|
246 |
+
layout: $(this).data('layout'),
|
247 |
+
before: $layout_source
|
248 |
+
});
|
249 |
+
|
250 |
+
// Close modal
|
251 |
+
acfe.modal.close(true);
|
252 |
+
|
253 |
+
if(!$layout_added)
|
254 |
+
return;
|
255 |
+
|
256 |
+
// Modal Edition: Open
|
257 |
+
if(flexible.has('acfeFlexibleModalEdition')){
|
258 |
+
|
259 |
+
$layout_added.find('> [data-action="acfe-flexible-modal-edit"]:first').trigger('click');
|
260 |
+
|
261 |
+
}
|
262 |
+
|
263 |
+
// Normal Edition: Open
|
264 |
+
else{
|
265 |
+
|
266 |
+
flexible.openLayout($layout_added);
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
});
|
271 |
+
|
272 |
+
}
|
273 |
+
|
274 |
+
/*
|
275 |
+
* Spawn
|
276 |
+
*/
|
277 |
+
acf.addAction('new_field/type=flexible_content', function(flexible){
|
278 |
+
|
279 |
+
if(!flexible.has('acfeFlexibleModal'))
|
280 |
+
return;
|
281 |
+
|
282 |
+
// Vars
|
283 |
+
var $clones = flexible.$clones();
|
284 |
+
|
285 |
+
if($clones.length <= 1)
|
286 |
+
return;
|
287 |
+
|
288 |
+
// Remove native ACF Tooltip action
|
289 |
+
flexible.removeEvents({'click [data-name="add-layout"]': 'onClickAdd'});
|
290 |
+
|
291 |
+
// Add ACF Extended Modal action
|
292 |
+
flexible.addEvents({'click [data-name="add-layout"]': 'acfeModalSelect'});
|
293 |
+
|
294 |
+
});
|
295 |
+
|
296 |
})(jQuery);
|
assets/acf-extended-fc.css
CHANGED
@@ -1,276 +1,277 @@
|
|
1 |
-
/*
|
2 |
-
* Flexible Sortable
|
3 |
-
*/
|
4 |
-
.acf-flexible-content > .values > .ui-sortable-placeholder{
|
5 |
-
height:147px;
|
6 |
-
border-width:2px;
|
7 |
-
border-color:#ccc;
|
8 |
-
}
|
9 |
-
|
10 |
-
/*
|
11 |
-
* Flexible Layout Handle
|
12 |
-
*/
|
13 |
-
.acf-flexible-content .layout .acf-fc-layout-handle {
|
14 |
-
color: #444;
|
15 |
-
font-weight: 600;
|
16 |
-
}
|
17 |
-
|
18 |
-
/*
|
19 |
-
* Flexible Field Error
|
20 |
-
*/
|
21 |
-
.layout.acfe-flexible-modal-edit-error > .acf-fc-layout-handle{
|
22 |
-
color:#f33b28;
|
23 |
-
}
|
24 |
-
|
25 |
-
.layout.acfe-flexible-modal-edit-error > .acf-fc-layout-handle > .acf-fc-layout-order{
|
26 |
-
background:#f33b28;
|
27 |
-
color:#fff;
|
28 |
-
}
|
29 |
-
|
30 |
-
/*
|
31 |
-
* Flexible Layout Collapsed
|
32 |
-
*/
|
33 |
-
.acf-flexible-content .layout.-collapsed > .acf-fc-layout-handle
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
color: #
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
height:
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
-
|
136 |
-
transition: background-color 200ms linear;
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
.layout > .acfe-flexible-collapsed-placeholder .acfe-flexible-collapsed-overlay
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
*
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
background-
|
168 |
-
background-
|
169 |
-
background-
|
170 |
-
position:
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
font-
|
181 |
-
|
182 |
-
|
183 |
-
text-
|
184 |
-
text-
|
185 |
-
-
|
186 |
-
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
.acfe-
|
216 |
-
|
217 |
-
|
218 |
-
}
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
.acfe-
|
223 |
-
|
224 |
-
|
225 |
-
}
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
*
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
*
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
*
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
|
|
276 |
}
|
1 |
+
/*
|
2 |
+
* Flexible Sortable
|
3 |
+
*/
|
4 |
+
.acf-flexible-content > .values > .ui-sortable-placeholder{
|
5 |
+
height:147px;
|
6 |
+
border-width:2px;
|
7 |
+
border-color:#ccc;
|
8 |
+
}
|
9 |
+
|
10 |
+
/*
|
11 |
+
* Flexible Layout Handle
|
12 |
+
*/
|
13 |
+
.acf-flexible-content .layout .acf-fc-layout-handle {
|
14 |
+
color: #444;
|
15 |
+
font-weight: 600;
|
16 |
+
}
|
17 |
+
|
18 |
+
/*
|
19 |
+
* Flexible Field Error
|
20 |
+
*/
|
21 |
+
.layout.acfe-flexible-modal-edit-error > .acf-fc-layout-handle{
|
22 |
+
color:#f33b28;
|
23 |
+
}
|
24 |
+
|
25 |
+
.layout.acfe-flexible-modal-edit-error > .acf-fc-layout-handle > .acf-fc-layout-order{
|
26 |
+
background:#f33b28;
|
27 |
+
color:#fff;
|
28 |
+
}
|
29 |
+
|
30 |
+
/*
|
31 |
+
* Flexible Layout Collapsed
|
32 |
+
*/
|
33 |
+
.acf-field-flexible-content[data-acfe-flexible-placeholder="1"] > .acf-input > .acf-flexible-content > .values > .layout.-collapsed > .acf-fc-layout-handle,
|
34 |
+
.acf-field-flexible-content[data-acfe-flexible-preview="1"] > .acf-input > .acf-flexible-content > .values > .layout.-collapsed > .acf-fc-layout-handle{
|
35 |
+
border-bottom-width:1px;
|
36 |
+
}
|
37 |
+
|
38 |
+
/*
|
39 |
+
* Flexible Layout: Placeholder
|
40 |
+
*/
|
41 |
+
.layout > .acfe-flexible-collapsed-placeholder{
|
42 |
+
text-align:center;
|
43 |
+
background:#fafafa;
|
44 |
+
display:block;
|
45 |
+
text-decoration:none;
|
46 |
+
position:relative;
|
47 |
+
cursor:pointer;
|
48 |
+
}
|
49 |
+
|
50 |
+
.layout > .acfe-flexible-collapsed-placeholder:focus{
|
51 |
+
border-color: #cccccc;
|
52 |
+
box-shadow: none;
|
53 |
+
}
|
54 |
+
|
55 |
+
.layout > .acfe-flexible-collapsed-placeholder > .acfe-flexible-placeholder{
|
56 |
+
height:110px;
|
57 |
+
overflow:hidden;
|
58 |
+
}
|
59 |
+
|
60 |
+
.layout > .acfe-flexible-collapsed-placeholder > button{
|
61 |
+
z-index:2;
|
62 |
+
position:absolute;
|
63 |
+
top:50%;
|
64 |
+
left:50%;
|
65 |
+
transform:translate(-50%, -50%);
|
66 |
+
background: #fafafa;
|
67 |
+
border-color: #999;
|
68 |
+
color: #23282d;
|
69 |
+
border-radius:100px;
|
70 |
+
box-shadow:none;
|
71 |
+
background:#fff;
|
72 |
+
width: 30px;
|
73 |
+
height: 30px;
|
74 |
+
padding:0;
|
75 |
+
display:block;
|
76 |
+
}
|
77 |
+
|
78 |
+
.layout > .acfe-flexible-collapsed-placeholder > button:active{
|
79 |
+
transform:translate(-50%, -50%);
|
80 |
+
}
|
81 |
+
|
82 |
+
.layout > .acfe-flexible-collapsed-placeholder > button:focus{
|
83 |
+
border-color: #cccccc;
|
84 |
+
box-shadow: none;
|
85 |
+
}
|
86 |
+
|
87 |
+
.layout > .acfe-flexible-collapsed-placeholder > button span{
|
88 |
+
width: 30px;
|
89 |
+
height: 30px;
|
90 |
+
vertical-align:middle;
|
91 |
+
line-height: 28px;
|
92 |
+
font-size:18px;
|
93 |
+
}
|
94 |
+
|
95 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview{
|
96 |
+
background:none;
|
97 |
+
}
|
98 |
+
|
99 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview > .acfe-flexible-placeholder{
|
100 |
+
min-height:55px;
|
101 |
+
height:auto;
|
102 |
+
}
|
103 |
+
|
104 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview > button{
|
105 |
+
display:none;
|
106 |
+
}
|
107 |
+
|
108 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview:hover > button{
|
109 |
+
display:block;
|
110 |
+
}
|
111 |
+
|
112 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview.acfe-is-loading{
|
113 |
+
background:#fafafa;
|
114 |
+
min-height:110px;
|
115 |
+
}
|
116 |
+
|
117 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview.acfe-is-loading > .acfe-flexible-placeholder > .spinner{
|
118 |
+
visibility:visible;
|
119 |
+
float:none;
|
120 |
+
position:absolute;
|
121 |
+
top:50%;
|
122 |
+
left:50%;
|
123 |
+
transform:translate(-50%, -50%);
|
124 |
+
margin:0;
|
125 |
+
z-index:10000;
|
126 |
+
}
|
127 |
+
|
128 |
+
.layout > .acfe-flexible-collapsed-placeholder .acfe-flexible-collapsed-overlay{
|
129 |
+
z-index:1;
|
130 |
+
position:absolute;
|
131 |
+
width:100%;
|
132 |
+
height:100%;
|
133 |
+
padding:0;
|
134 |
+
background-color:rgba(255,255,255,0);
|
135 |
+
-webkit-transition: background-color 200ms linear;
|
136 |
+
-ms-transition: background-color 200ms linear;
|
137 |
+
transition: background-color 200ms linear;
|
138 |
+
}
|
139 |
+
|
140 |
+
.layout > .acfe-flexible-collapsed-placeholder:hover .acfe-flexible-collapsed-overlay,
|
141 |
+
.layout > .acfe-flexible-collapsed-placeholder .acfe-flexible-collapsed-overlay.-hover{
|
142 |
+
background-color:rgba(255,255,255,0.7);
|
143 |
+
}
|
144 |
+
|
145 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview.acfe-is-loading > button span{
|
146 |
+
visibility:hidden;
|
147 |
+
}
|
148 |
+
|
149 |
+
/*
|
150 |
+
* Flexible Layout Collapsed
|
151 |
+
*/
|
152 |
+
.layout > .acfe-flexible-opened-actions{
|
153 |
+
background:#f9f9f9;
|
154 |
+
border-top:1px solid #e1e1e1;
|
155 |
+
padding:12px;
|
156 |
+
text-align:right;
|
157 |
+
}
|
158 |
+
|
159 |
+
/*
|
160 |
+
* Flexible Thumbnails
|
161 |
+
*
|
162 |
+
*/
|
163 |
+
.acfe-flexible-layout-thumbnail{
|
164 |
+
display:block;
|
165 |
+
width:100%;
|
166 |
+
height: 9.8vw; /* 200px / 1080p */
|
167 |
+
background-color:#eee;
|
168 |
+
background-size:cover;
|
169 |
+
background-repeat:no-repeat;
|
170 |
+
background-position:center;
|
171 |
+
position:relative;
|
172 |
+
margin-bottom:10px;
|
173 |
+
}
|
174 |
+
|
175 |
+
.acfe-flexible-layout-thumbnail.acfe-flexible-layout-thumbnail-not-found:after{
|
176 |
+
content: "\f180";
|
177 |
+
font-family: dashicons;
|
178 |
+
display: inline-block;
|
179 |
+
line-height: 1;
|
180 |
+
font-weight: 400;
|
181 |
+
font-style: normal;
|
182 |
+
speak: none;
|
183 |
+
text-decoration: inherit;
|
184 |
+
text-transform: none;
|
185 |
+
text-rendering: auto;
|
186 |
+
-webkit-font-smoothing: antialiased;
|
187 |
+
-moz-osx-font-smoothing: grayscale;
|
188 |
+
vertical-align: top;
|
189 |
+
text-align: center;
|
190 |
+
position:absolute;
|
191 |
+
top:50%;
|
192 |
+
left:50%;
|
193 |
+
transform: translate(-50%, -50%);
|
194 |
+
color:#ccc;
|
195 |
+
font-size: 110px;
|
196 |
+
}
|
197 |
+
|
198 |
+
.acfe-col-2 .acfe-flexible-layout-thumbnail{
|
199 |
+
height:20.5vw;
|
200 |
+
}
|
201 |
+
|
202 |
+
.acfe-col-3 .acfe-flexible-layout-thumbnail{
|
203 |
+
height:13.3vw;
|
204 |
+
}
|
205 |
+
|
206 |
+
.acfe-col-5 .acfe-flexible-layout-thumbnail{
|
207 |
+
height:7.65vw;
|
208 |
+
}
|
209 |
+
|
210 |
+
.acfe-col-6 .acfe-flexible-layout-thumbnail{
|
211 |
+
height:6.2vw;
|
212 |
+
}
|
213 |
+
|
214 |
+
@media only screen and (max-width:960px){
|
215 |
+
.acfe-flexible-layout-thumbnail,
|
216 |
+
.acfe-flex-container .acfe-flexible-layout-thumbnail{
|
217 |
+
height: 18.4vw; /* 200px */
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
@media only screen and (max-width:720px){
|
222 |
+
.acfe-flexible-layout-thumbnail,
|
223 |
+
.acfe-flex-container .acfe-flexible-layout-thumbnail{
|
224 |
+
height: 37.2vw; /* 200px */
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
/*
|
229 |
+
* Flexible Thumbnails (no modal)
|
230 |
+
*
|
231 |
+
*/
|
232 |
+
.acfe-flexible-layout-thumbnail.acfe-flexible-layout-thumbnail-no-modal{
|
233 |
+
display:block;
|
234 |
+
width: 230px;
|
235 |
+
height: 103px;
|
236 |
+
background-color:#1f2329;
|
237 |
+
}
|
238 |
+
|
239 |
+
.acfe-flexible-layout-thumbnail.acfe-flexible-layout-thumbnail-no-modal.acfe-flexible-layout-thumbnail-not-found:after{
|
240 |
+
color:#2F353E;
|
241 |
+
}
|
242 |
+
|
243 |
+
/*
|
244 |
+
* Flexible Stylised Button
|
245 |
+
*
|
246 |
+
*/
|
247 |
+
.acf-field.acf-field-flexible-content[data-acfe-flexible-stylised-button="1"] > .acf-input > .acf-flexible-content:not(.empty) > .values{
|
248 |
+
margin-bottom:15px;
|
249 |
+
}
|
250 |
+
|
251 |
+
.acf-field.acf-field-flexible-content > .acf-input > .acf-flexible-content > .acfe-flexible-stylised-button{
|
252 |
+
padding: 40px 20px;
|
253 |
+
border: #ccc dashed 2px;
|
254 |
+
text-align: center;
|
255 |
+
}
|
256 |
+
|
257 |
+
.acf-field.acf-field-flexible-content > .acf-input > .acf-flexible-content > .acfe-flexible-stylised-button > .acf-actions{
|
258 |
+
text-align: center;
|
259 |
+
}
|
260 |
+
|
261 |
+
.acf-field.acf-field-flexible-content > .acf-input > .acf-flexible-content .acf-actions .acf-button .dashicons{
|
262 |
+
width: auto;
|
263 |
+
height: auto;
|
264 |
+
vertical-align: text-top;
|
265 |
+
}
|
266 |
+
|
267 |
+
/*
|
268 |
+
* Flexible Hide Empty Message
|
269 |
+
*
|
270 |
+
*/
|
271 |
+
.acf-field.acf-field-flexible-content[data-acfe-flexible-hide-empty-message="1"] > .acf-input > .acf-flexible-content > .no-value-message{
|
272 |
+
display:none;
|
273 |
+
}
|
274 |
+
|
275 |
+
.acf-field.acf-field-flexible-content[data-acfe-flexible-hide-empty-message="1"] > .acf-input > .acf-flexible-content.-empty > .values{
|
276 |
+
margin-bottom:0;
|
277 |
}
|
assets/acf-extended-fc.js
CHANGED
@@ -1,345 +1,350 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
if(typeof acf === 'undefined')
|
4 |
-
return;
|
5 |
-
|
6 |
-
/*
|
7 |
-
* Init
|
8 |
-
*/
|
9 |
-
var flexible = acf.getFieldType('flexible_content');
|
10 |
-
var model = flexible.prototype;
|
11 |
-
|
12 |
-
/*
|
13 |
-
* Actions
|
14 |
-
*/
|
15 |
-
model.acfeOneClick = function(e, $el){
|
16 |
-
|
17 |
-
// Get Flexible
|
18 |
-
var flexible = this;
|
19 |
-
|
20 |
-
// Vars
|
21 |
-
var $clones = flexible.$clones();
|
22 |
-
var $layout_name = $($clones[0]).data('layout');
|
23 |
-
|
24 |
-
// Source
|
25 |
-
var $layout_source = null;
|
26 |
-
if($el.hasClass('acf-icon'))
|
27 |
-
$layout_source = $el.closest('.layout');
|
28 |
-
|
29 |
-
// Add
|
30 |
-
var $layout_added = flexible.add({
|
31 |
-
layout: $layout_name,
|
32 |
-
before: $layout_source
|
33 |
-
});
|
34 |
-
|
35 |
-
// Hide native tooltip
|
36 |
-
if($('.acf-fc-popup').length)
|
37 |
-
$('.acf-fc-popup').hide();
|
38 |
-
|
39 |
-
if(!$layout_added)
|
40 |
-
return;
|
41 |
-
|
42 |
-
// Open layout modal edition
|
43 |
-
if(flexible.has('acfeFlexibleModalEdition'))
|
44 |
-
$layout_added.find('> [data-action="acfe-flexible-modal-edit"]').trigger('click');
|
45 |
-
|
46 |
-
};
|
47 |
-
|
48 |
-
model.acfeCloseLayoutInit = function($layout){
|
49 |
-
|
50 |
-
$layout.addClass('-collapsed');
|
51 |
-
acf.doAction('hide', $layout, 'collapse');
|
52 |
-
|
53 |
-
};
|
54 |
-
|
55 |
-
model.acfeLayoutInit = function($layout){
|
56 |
-
|
57 |
-
// Get Flexible
|
58 |
-
var flexible = this;
|
59 |
-
|
60 |
-
// Vars
|
61 |
-
var $controls = $layout.find('> .acf-fc-layout-controls');
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
'
|
81 |
-
'
|
82 |
-
'
|
83 |
-
'
|
84 |
-
' <div class="acfe-flexible-
|
85 |
-
'
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
if
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
//
|
314 |
-
$('
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
|
|
|
|
|
|
|
|
|
|
345 |
})(jQuery);
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
if(typeof acf === 'undefined')
|
4 |
+
return;
|
5 |
+
|
6 |
+
/*
|
7 |
+
* Init
|
8 |
+
*/
|
9 |
+
var flexible = acf.getFieldType('flexible_content');
|
10 |
+
var model = flexible.prototype;
|
11 |
+
|
12 |
+
/*
|
13 |
+
* Actions
|
14 |
+
*/
|
15 |
+
model.acfeOneClick = function(e, $el){
|
16 |
+
|
17 |
+
// Get Flexible
|
18 |
+
var flexible = this;
|
19 |
+
|
20 |
+
// Vars
|
21 |
+
var $clones = flexible.$clones();
|
22 |
+
var $layout_name = $($clones[0]).data('layout');
|
23 |
+
|
24 |
+
// Source
|
25 |
+
var $layout_source = null;
|
26 |
+
if($el.hasClass('acf-icon'))
|
27 |
+
$layout_source = $el.closest('.layout');
|
28 |
+
|
29 |
+
// Add
|
30 |
+
var $layout_added = flexible.add({
|
31 |
+
layout: $layout_name,
|
32 |
+
before: $layout_source
|
33 |
+
});
|
34 |
+
|
35 |
+
// Hide native tooltip
|
36 |
+
if($('.acf-fc-popup').length)
|
37 |
+
$('.acf-fc-popup').hide();
|
38 |
+
|
39 |
+
if(!$layout_added)
|
40 |
+
return;
|
41 |
+
|
42 |
+
// Open layout modal edition
|
43 |
+
if(flexible.has('acfeFlexibleModalEdition'))
|
44 |
+
$layout_added.find('> [data-action="acfe-flexible-modal-edit"]:first').trigger('click');
|
45 |
+
|
46 |
+
};
|
47 |
+
|
48 |
+
model.acfeCloseLayoutInit = function($layout){
|
49 |
+
|
50 |
+
$layout.addClass('-collapsed');
|
51 |
+
acf.doAction('hide', $layout, 'collapse');
|
52 |
+
|
53 |
+
};
|
54 |
+
|
55 |
+
model.acfeLayoutInit = function($layout){
|
56 |
+
|
57 |
+
// Get Flexible
|
58 |
+
var flexible = this;
|
59 |
+
|
60 |
+
// Vars
|
61 |
+
var $controls = $layout.find('> .acf-fc-layout-controls');
|
62 |
+
var $handle = $layout.find('> .acf-fc-layout-handle');
|
63 |
+
|
64 |
+
// Remove duplicate
|
65 |
+
$layout.find('> .acfe-flexible-opened-actions').remove();
|
66 |
+
|
67 |
+
// Placeholder
|
68 |
+
var $placeholder = $layout.find('> .acfe-flexible-collapsed-placeholder');
|
69 |
+
|
70 |
+
// Placeholder: Not found - Create new element
|
71 |
+
if(!$placeholder.length && (flexible.has('acfeFlexiblePlaceholder') || flexible.has('acfeFlexiblePreview'))){
|
72 |
+
|
73 |
+
var placeholder_icon = 'dashicons dashicons-edit';
|
74 |
+
|
75 |
+
if(flexible.has('acfeFlexiblePlaceholderIcon'))
|
76 |
+
placeholder_icon = flexible.get('acfeFlexiblePlaceholderIcon');
|
77 |
+
|
78 |
+
// Placeholder
|
79 |
+
var $placeholder = $('' +
|
80 |
+
'<div class="acfe-flexible-collapsed-placeholder" title="Edit layout">' +
|
81 |
+
' <button class="button" onclick="return false;">' +
|
82 |
+
' <span class="' + placeholder_icon + '"></span>' +
|
83 |
+
' </button>' +
|
84 |
+
' <div class="acfe-flexible-collapsed-overlay"></div>' +
|
85 |
+
' <div class="acfe-flexible-placeholder"></div>' +
|
86 |
+
'</div>'
|
87 |
+
).insertAfter($controls);
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
// Placeholder: Show
|
92 |
+
$placeholder.show();
|
93 |
+
|
94 |
+
// Modal Edition Wrap
|
95 |
+
if(flexible.has('acfeFlexibleModalEdition')){
|
96 |
+
|
97 |
+
if(!$layout.find('> .acfe-modal').length){
|
98 |
+
|
99 |
+
// Wrap content
|
100 |
+
$layout.find('> .acf-fields, > .acf-table').wrapAll('<div class="acfe-modal"><div class="acfe-modal-wrapper"><div class="acfe-modal-content"></div></div></div>');
|
101 |
+
|
102 |
+
// Handle
|
103 |
+
$handle.attr('data-action', 'acfe-flexible-modal-edit');
|
104 |
+
|
105 |
+
// Placeholder
|
106 |
+
if(flexible.has('acfeFlexiblePlaceholder') || flexible.has('acfeFlexiblePreview'))
|
107 |
+
$placeholder.attr('data-action', 'acfe-flexible-modal-edit');
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
}
|
112 |
+
|
113 |
+
else{
|
114 |
+
|
115 |
+
if(!flexible.isLayoutClosed($layout)){
|
116 |
+
|
117 |
+
$placeholder.hide();
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
// Flexible has Preview
|
124 |
+
if(flexible.has('acfeFlexiblePreview')){
|
125 |
+
|
126 |
+
$placeholder.addClass('acfe-flexible-collapsed-preview acfe-is-loading').find('> .acfe-flexible-placeholder').prepend('<span class="spinner"></span>');
|
127 |
+
$placeholder.find('> .acfe-flexible-collapsed-overlay').addClass('-hover');
|
128 |
+
|
129 |
+
// vars
|
130 |
+
var $input = $layout.children('input');
|
131 |
+
var prefix = $input.attr('name').replace('[acf_fc_layout]', '');
|
132 |
+
|
133 |
+
// ajax data
|
134 |
+
var ajaxData = {
|
135 |
+
action: 'acfe/flexible/layout_preview',
|
136 |
+
field_key: flexible.get('key'),
|
137 |
+
i: $layout.index(),
|
138 |
+
layout: $layout.data('layout'),
|
139 |
+
value: acf.serialize($layout, prefix)
|
140 |
+
};
|
141 |
+
|
142 |
+
// ajax
|
143 |
+
$.ajax({
|
144 |
+
url: acf.get('ajaxurl'),
|
145 |
+
data: acf.prepareForAjax(ajaxData),
|
146 |
+
dataType: 'html',
|
147 |
+
type: 'post',
|
148 |
+
success: function(response){
|
149 |
+
if(response){
|
150 |
+
|
151 |
+
$placeholder.find('> .acfe-flexible-placeholder').html(response);
|
152 |
+
|
153 |
+
}else{
|
154 |
+
|
155 |
+
$placeholder.removeClass('acfe-flexible-collapsed-preview');
|
156 |
+
|
157 |
+
}
|
158 |
+
},
|
159 |
+
complete: function(){
|
160 |
+
|
161 |
+
$placeholder.find('> .acfe-flexible-collapsed-overlay').removeClass('-hover');
|
162 |
+
$placeholder.removeClass('acfe-is-loading').find('> .acfe-flexible-placeholder > .spinner').remove();
|
163 |
+
|
164 |
+
}
|
165 |
+
});
|
166 |
+
|
167 |
+
}
|
168 |
+
|
169 |
+
};
|
170 |
+
|
171 |
+
/*
|
172 |
+
* Spawn
|
173 |
+
*/
|
174 |
+
acf.addAction('new_field/type=flexible_content', function(flexible){
|
175 |
+
|
176 |
+
// Vars
|
177 |
+
var $clones = flexible.$clones();
|
178 |
+
var $layouts = flexible.$layouts();
|
179 |
+
|
180 |
+
// Merge
|
181 |
+
var $all_layouts = $.merge($layouts, $clones);
|
182 |
+
|
183 |
+
// Do Actions
|
184 |
+
$all_layouts.each(function(){
|
185 |
+
|
186 |
+
var $layout = $(this);
|
187 |
+
var $name = $layout.data('layout');
|
188 |
+
|
189 |
+
acf.doAction('acfe/flexible/layouts', $layout, flexible);
|
190 |
+
acf.doAction('acfe/flexible/layout/name=' + $name, $layout, flexible);
|
191 |
+
|
192 |
+
});
|
193 |
+
|
194 |
+
// ACFE: Stylised button
|
195 |
+
if(flexible.has('acfeFlexibleStylisedButton')){
|
196 |
+
|
197 |
+
flexible.$button().removeClass('button-primary');
|
198 |
+
flexible.$actions().wrap('<div class="acfe-flexible-stylised-button" />');
|
199 |
+
|
200 |
+
}
|
201 |
+
|
202 |
+
// ACFE: 1 layout available - OneClick
|
203 |
+
if($clones.length === 1){
|
204 |
+
|
205 |
+
// Remove native ACF Tooltip action
|
206 |
+
flexible.removeEvents({'click [data-name="add-layout"]': 'onClickAdd'});
|
207 |
+
|
208 |
+
// Add ACF Extended Modal action
|
209 |
+
flexible.addEvents({'click [data-name="add-layout"]': 'acfeOneClick'});
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
flexible.addEvents({'click .acfe-flexible-collapsed-placeholder': 'onClickCollapse'});
|
214 |
+
|
215 |
+
flexible.addEvents({'click .acfe-flexible-opened-actions > a': 'onClickCollapse'});
|
216 |
+
|
217 |
+
});
|
218 |
+
|
219 |
+
acf.addAction('acfe/flexible/layouts', function($layout, flexible){
|
220 |
+
|
221 |
+
// Flexible has Modal Edition
|
222 |
+
if(flexible.has('acfeFlexibleModalEdition')){
|
223 |
+
|
224 |
+
$layout.addClass('-collapsed');
|
225 |
+
flexible.acfeLayoutInit($layout);
|
226 |
+
|
227 |
+
return;
|
228 |
+
|
229 |
+
}
|
230 |
+
|
231 |
+
// Bail early if layout is clone
|
232 |
+
if($layout.is('.acf-clone'))
|
233 |
+
return;
|
234 |
+
|
235 |
+
// Layout State: Collapse
|
236 |
+
if(flexible.has('acfeFlexibleCollapse')){
|
237 |
+
|
238 |
+
flexible.acfeCloseLayoutInit($layout);
|
239 |
+
|
240 |
+
}
|
241 |
+
|
242 |
+
// Layout State: Open
|
243 |
+
else if(flexible.has('acfeFlexibleOpen')){
|
244 |
+
|
245 |
+
flexible.openLayout($layout);
|
246 |
+
|
247 |
+
}
|
248 |
+
|
249 |
+
// Others
|
250 |
+
else{
|
251 |
+
|
252 |
+
// Action: Close for closed layouts
|
253 |
+
if(flexible.isLayoutClosed($layout)){
|
254 |
+
|
255 |
+
flexible.acfeCloseLayoutInit($layout);
|
256 |
+
|
257 |
+
}
|
258 |
+
|
259 |
+
// Action: Show for opened layouts
|
260 |
+
else{
|
261 |
+
|
262 |
+
flexible.openLayout($layout);
|
263 |
+
|
264 |
+
}
|
265 |
+
|
266 |
+
}
|
267 |
+
|
268 |
+
});
|
269 |
+
|
270 |
+
acf.addAction('show', function($layout, type){
|
271 |
+
|
272 |
+
if(type != 'collapse' || !$layout.is('.layout'))
|
273 |
+
return;
|
274 |
+
|
275 |
+
var flexible = acf.getInstance($layout.closest('.acf-field-flexible-content'));
|
276 |
+
|
277 |
+
// Bail early if Modal Edit
|
278 |
+
if(flexible.has('acfeFlexibleModalEdition'))
|
279 |
+
return;
|
280 |
+
|
281 |
+
// Placeholder
|
282 |
+
$layout.find('> .acfe-flexible-collapsed-placeholder').hide();
|
283 |
+
|
284 |
+
// Close Button
|
285 |
+
if(flexible.has('acfeFlexibleCloseButton')){
|
286 |
+
|
287 |
+
$layout.find('> .acfe-flexible-opened-actions').remove();
|
288 |
+
|
289 |
+
$('<div class="acfe-flexible-opened-actions"><a href="javascript:void(0);" class="button">' + acf.get('close') + '</button></a>').appendTo($layout);
|
290 |
+
|
291 |
+
}
|
292 |
+
|
293 |
+
});
|
294 |
+
|
295 |
+
acf.addAction('hide', function($layout, type){
|
296 |
+
|
297 |
+
if(type != 'collapse' || !$layout.is('.layout') || $layout.is('.acf-clone'))
|
298 |
+
return;
|
299 |
+
|
300 |
+
// Get Flexible
|
301 |
+
var flexible = acf.getInstance($layout.closest('.acf-field-flexible-content'));
|
302 |
+
|
303 |
+
flexible.acfeLayoutInit($layout);
|
304 |
+
|
305 |
+
});
|
306 |
+
|
307 |
+
acf.addAction('append', function($el){
|
308 |
+
|
309 |
+
// Bail early if layout is not clone
|
310 |
+
if(!$el.is('.layout'))
|
311 |
+
return;
|
312 |
+
|
313 |
+
// Get Flexible
|
314 |
+
var flexible = acf.getInstance($el.closest('.acf-field-flexible-content'));
|
315 |
+
|
316 |
+
flexible.acfeLayoutInit($el);
|
317 |
+
|
318 |
+
// Scroll to new layout
|
319 |
+
$('html, body').animate({
|
320 |
+
scrollTop: parseInt($el.offset().top) - 200
|
321 |
+
}, 200);
|
322 |
+
|
323 |
+
});
|
324 |
+
|
325 |
+
/*
|
326 |
+
* Field Error
|
327 |
+
*/
|
328 |
+
acf.addAction('invalid_field', function(field){
|
329 |
+
|
330 |
+
field.$el.parents('.layout').addClass('acfe-flexible-modal-edit-error');
|
331 |
+
|
332 |
+
});
|
333 |
+
|
334 |
+
/*
|
335 |
+
* Field Valid
|
336 |
+
*/
|
337 |
+
acf.addAction('valid_field', function(field){
|
338 |
+
|
339 |
+
field.$el.parents('.layout').each(function(){
|
340 |
+
|
341 |
+
var $layout = $(this);
|
342 |
+
|
343 |
+
if(!$layout.find('.acf-error').length)
|
344 |
+
$layout.removeClass('acfe-flexible-modal-edit-error');
|
345 |
+
|
346 |
+
});
|
347 |
+
|
348 |
+
});
|
349 |
+
|
350 |
})(jQuery);
|
assets/acf-extended-fg.css
CHANGED
@@ -1,140 +1,143 @@
|
|
1 |
-
.acf-field-setting-acfe_permissions > .acf-input > .acf-fields,
|
2 |
-
.acf-field-setting-acfe_validate > .acf-input > .acf-fields,
|
3 |
-
.acf-field-setting-acfe_update > .acf-input > .acf-fields,
|
4 |
-
|
5 |
-
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields,
|
6 |
-
.acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field.acf-field-acfe-validate-rules-or,
|
7 |
-
.acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field.acf-field-acfe-update-functions{
|
8 |
-
border:0;
|
9 |
-
}
|
10 |
-
|
11 |
-
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields > .acf-field,
|
12 |
-
.acf-field-setting-acfe_permissions > .acf-input > .acf-fields > .acf-field,
|
13 |
-
.acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field,
|
14 |
-
.acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field{
|
15 |
-
padding:0;
|
16 |
-
}
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
.acf-field-setting-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
140 |
}
|
1 |
+
.acf-field-setting-acfe_permissions > .acf-input > .acf-fields,
|
2 |
+
.acf-field-setting-acfe_validate > .acf-input > .acf-fields,
|
3 |
+
.acf-field-setting-acfe_update > .acf-input > .acf-fields,
|
4 |
+
|
5 |
+
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields,
|
6 |
+
.acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field.acf-field-acfe-validate-rules-or,
|
7 |
+
.acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field.acf-field-acfe-update-functions{
|
8 |
+
border:0;
|
9 |
+
}
|
10 |
+
|
11 |
+
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields > .acf-field,
|
12 |
+
.acf-field-setting-acfe_permissions > .acf-input > .acf-fields > .acf-field,
|
13 |
+
.acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field,
|
14 |
+
.acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field{
|
15 |
+
padding:0;
|
16 |
+
}
|
17 |
+
|
18 |
+
.acf-field-setting-acfe_field_data{
|
19 |
+
display:none;
|
20 |
+
}
|
21 |
+
|
22 |
+
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields > .acf-field.acf-field-acfe-bidirectional-enabled > .acf-label,
|
23 |
+
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields > .acf-field.acf-field-acfe-bidirectional-related > .acf-label,
|
24 |
+
.acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field.acf-field-acfe-validate-activate > .acf-label,
|
25 |
+
.acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field.acf-field-acfe-update-activate > .acf-label{
|
26 |
+
display:none;
|
27 |
+
}
|
28 |
+
|
29 |
+
.acf-field-setting-acfe_update > .acf-input .acf-repeater.-empty.-table > table,
|
30 |
+
.acf-field-setting-acfe_validate > .acf-input .acf-repeater.-empty.-table > table,
|
31 |
+
.acf-field-acfe-meta > .acf-input .acf-repeater.-empty.-table > table{
|
32 |
+
border:0;
|
33 |
+
display:none;
|
34 |
+
}
|
35 |
+
|
36 |
+
.acf-field-setting-acfe_update > .acf-input .acf-repeater.-empty.-table > table > thead,
|
37 |
+
.acf-field-setting-acfe_validate > .acf-input .acf-repeater.-empty.-table > table > thead,
|
38 |
+
.acf-field-acfe-meta > .acf-input .acf-repeater.-empty.-table > table > thead{
|
39 |
+
display:none;
|
40 |
+
}
|
41 |
+
|
42 |
+
.acf-field-setting-acfe_update > .acf-input > .acf-repeater .acf-actions,
|
43 |
+
.acf-field-setting-acfe_validate > .acf-input > .acf-repeater .acf-actions,
|
44 |
+
.acf-field-acfe-meta > .acf-input > .acf-repeater .acf-actions{
|
45 |
+
text-align:left;
|
46 |
+
}
|
47 |
+
|
48 |
+
.acf-field-setting-acfe_update > .acf-input > .acf-repeater .acf-actions .acf-button.button-primary,
|
49 |
+
.acf-field-setting-acfe_validate > .acf-input > .acf-repeater .acf-actions .acf-button.button-primary,
|
50 |
+
.acf-field-acfe-meta > .acf-input > .acf-repeater .acf-actions .acf-button.button-primary{
|
51 |
+
color: #555;
|
52 |
+
border-color: #ccc;
|
53 |
+
background: #f7f7f7;
|
54 |
+
box-shadow: 0 1px 0 #ccc;
|
55 |
+
text-shadow:none;
|
56 |
+
}
|
57 |
+
|
58 |
+
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields > .acf-field.acf-field-acfe-bidirectional-related{
|
59 |
+
margin-left:10px;
|
60 |
+
}
|
61 |
+
|
62 |
+
.acfe_width_auto{
|
63 |
+
width:auto !important;
|
64 |
+
}
|
65 |
+
|
66 |
+
.column-acf-field-group-category{
|
67 |
+
width:125px;
|
68 |
+
}
|
69 |
+
|
70 |
+
td.acf-field-group-category a{
|
71 |
+
word-wrap: break-word;
|
72 |
+
padding: 2px 5px;
|
73 |
+
margin: 0 1px;
|
74 |
+
border-radius:2px;
|
75 |
+
background: rgba(0,0,0,.05);
|
76 |
+
color:#333;
|
77 |
+
}
|
78 |
+
|
79 |
+
.column-acfe-locations{
|
80 |
+
width:100px;
|
81 |
+
}
|
82 |
+
|
83 |
+
#acf-field-group-wrap .wp-list-table .column-acf-fg-status{
|
84 |
+
width:70px;
|
85 |
+
}
|
86 |
+
|
87 |
+
#acf-field-group-wrap .wp-list-table .column-acf-fg-count{
|
88 |
+
width:70px;
|
89 |
+
}
|
90 |
+
|
91 |
+
.column-acfe-local{
|
92 |
+
width:50px;
|
93 |
+
}
|
94 |
+
|
95 |
+
.column-acfe-autosync-php,
|
96 |
+
.column-acfe-autosync-json{
|
97 |
+
width:65px;
|
98 |
+
text-align:center;
|
99 |
+
}
|
100 |
+
|
101 |
+
.acf-field-image[data-name="acfe_flexible_thumbnail"] > .acf-input > .acf-image-uploader.has-value > .show-if-value.image-wrap{
|
102 |
+
max-width:85px !important;
|
103 |
+
}
|
104 |
+
|
105 |
+
/*
|
106 |
+
* ACFE: Flexible Content
|
107 |
+
*
|
108 |
+
*/
|
109 |
+
.acf-field-acfe-flexible-modal > .acf-input > .acf-fields{
|
110 |
+
border:0;
|
111 |
+
}
|
112 |
+
|
113 |
+
.acf-field-acfe-flexible-modal > .acf-input > .acf-fields .acf-field-acfe-flexible-modal-enabled{
|
114 |
+
padding:0;
|
115 |
+
}
|
116 |
+
|
117 |
+
.acf-field-acfe-flexible-modal > .acf-input > .acf-fields .acf-field-acfe-flexible-modal-enabled .acf-label{
|
118 |
+
display:none;
|
119 |
+
}
|
120 |
+
|
121 |
+
.acf-field-acfe-flexible-modal > .acf-input > .acf-fields .acf-field-acfe-flexible-modal-title,
|
122 |
+
.acf-field-acfe-flexible-modal > .acf-input > .acf-fields .acf-field-acfe-flexible-modal-col,
|
123 |
+
.acf-field-acfe-flexible-modal > .acf-input > .acf-fields .acf-field-acfe-flexible-modal-categories{
|
124 |
+
padding-bottom:0;
|
125 |
+
padding-left:0;
|
126 |
+
border-top:0;
|
127 |
+
border-left:0 !important;
|
128 |
+
min-height:55px;
|
129 |
+
}
|
130 |
+
|
131 |
+
.acf-field-setting-fc_layout > .acf-input > .acf-fc-meta .acf-field[data-name=acfe_flexible_settings_label],
|
132 |
+
.acf-field-setting-fc_layout > .acf-input > .acf-fc-meta .acf-field[data-name=acfe_flexible_thumbnail],
|
133 |
+
.acf-field-setting-fc_layout > .acf-input > .acf-fc-meta .acf-field[data-name=acfe_flexible_category]{
|
134 |
+
margin:0;
|
135 |
+
}
|
136 |
+
|
137 |
+
.acf-field-setting-fc_layout > .acf-input > .acf-fc-meta .acf-field[data-name=acfe_flexible_settings_label] > .acf-input{
|
138 |
+
margin:0;
|
139 |
+
}
|
140 |
+
|
141 |
+
.acf-field-setting-fc_layout > .acf-input > .acf-fc-meta > .acf-fc-meta-label:first-of-type{
|
142 |
+
margin:0;
|
143 |
}
|
assets/acf-extended-fg.js
CHANGED
@@ -1,24 +1,24 @@
|
|
1 |
-
jQuery(document).ready(function($){
|
2 |
-
|
3 |
-
$('.button.edit-field').each(function(k, v){
|
4 |
-
var tbody = $(this).closest('tbody');
|
5 |
-
$(tbody).find('.acfe_modal_open:first').insertAfter($(this));
|
6 |
-
$(tbody).find('.acfe-modal:first').appendTo($('body'));
|
7 |
-
$(tbody).find('tr.acf-field-setting-acfe_field_data:first').remove();
|
8 |
-
});
|
9 |
-
|
10 |
-
$('.acfe_modal_open').click(function(e){
|
11 |
-
e.preventDefault();
|
12 |
-
|
13 |
-
var key = $(this).attr('data-modal-key');
|
14 |
-
|
15 |
-
var $modal = $('.acfe-modal[data-modal-key=' + key + ']');
|
16 |
-
|
17 |
-
acfe.modal.open($modal, {
|
18 |
-
title: 'Data',
|
19 |
-
size: 'small'
|
20 |
-
});
|
21 |
-
|
22 |
-
});
|
23 |
-
|
24 |
});
|
1 |
+
jQuery(document).ready(function($){
|
2 |
+
|
3 |
+
$('.button.edit-field').each(function(k, v){
|
4 |
+
var tbody = $(this).closest('tbody');
|
5 |
+
$(tbody).find('.acfe_modal_open:first').insertAfter($(this));
|
6 |
+
$(tbody).find('.acfe-modal:first').appendTo($('body'));
|
7 |
+
$(tbody).find('tr.acf-field-setting-acfe_field_data:first').remove();
|
8 |
+
});
|
9 |
+
|
10 |
+
$('.acfe_modal_open').click(function(e){
|
11 |
+
e.preventDefault();
|
12 |
+
|
13 |
+
var key = $(this).attr('data-modal-key');
|
14 |
+
|
15 |
+
var $modal = $('.acfe-modal[data-modal-key=' + key + ']');
|
16 |
+
|
17 |
+
acfe.modal.open($modal, {
|
18 |
+
title: 'Data',
|
19 |
+
size: 'small'
|
20 |
+
});
|
21 |
+
|
22 |
+
});
|
23 |
+
|
24 |
});
|
assets/acf-extended-fields.js
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
if(typeof acf
|
4 |
-
return;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Field: Slug
|
8 |
-
*/
|
9 |
-
acf.addAction('prepare_field/type=acfe_slug', function(field){
|
10 |
-
|
11 |
-
field.$el.bind('input', function(e){
|
12 |
-
field.val(field.val().toLowerCase()
|
13 |
-
.replace(/\s+/g, '-') // Replace spaces with -
|
14 |
-
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
15 |
-
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
16 |
-
.replace(/\_\_+/g, '_') // Replace multiple _ with single _
|
17 |
-
.replace(/^-+/, '')); // Trim - from start of text
|
18 |
-
});
|
19 |
-
|
20 |
-
field.$el.on('focusout', function(e){
|
21 |
-
field.val(field.val().toLowerCase()
|
22 |
-
.replace(/-+$/, '') // Trim - from end of text
|
23 |
-
.replace(/_+$/, '')); // Trim _ from end of text
|
24 |
-
});
|
25 |
-
|
26 |
-
|
27 |
-
});
|
28 |
-
|
29 |
})(jQuery);
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
if(typeof acf === 'undefined')
|
4 |
+
return;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Field: Slug
|
8 |
+
*/
|
9 |
+
acf.addAction('prepare_field/type=acfe_slug', function(field){
|
10 |
+
|
11 |
+
field.$el.bind('input', function(e){
|
12 |
+
field.val(field.val().toLowerCase()
|
13 |
+
.replace(/\s+/g, '-') // Replace spaces with -
|
14 |
+
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
15 |
+
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
16 |
+
.replace(/\_\_+/g, '_') // Replace multiple _ with single _
|
17 |
+
.replace(/^-+/, '')); // Trim - from start of text
|
18 |
+
});
|
19 |
+
|
20 |
+
field.$el.on('focusout', function(e){
|
21 |
+
field.val(field.val().toLowerCase()
|
22 |
+
.replace(/-+$/, '') // Trim - from end of text
|
23 |
+
.replace(/_+$/, '')); // Trim _ from end of text
|
24 |
+
});
|
25 |
+
|
26 |
+
|
27 |
+
});
|
28 |
+
|
29 |
})(jQuery);
|
assets/acf-extended-modal.css
CHANGED
@@ -1,450 +1,464 @@
|
|
1 |
-
/*
|
2 |
-
* ACFE Modal Body
|
3 |
-
*/
|
4 |
-
body.acfe-modal-opened{
|
5 |
-
overflow:hidden;
|
6 |
-
}
|
7 |
-
|
8 |
-
/*
|
9 |
-
* ACFE Modal Overlay
|
10 |
-
*/
|
11 |
-
.acfe-modal-overlay{
|
12 |
-
background:rgba(0,0,0,.7);
|
13 |
-
position:fixed;
|
14 |
-
top:0;
|
15 |
-
left:0;
|
16 |
-
right:0;
|
17 |
-
bottom:0;
|
18 |
-
height:100%;
|
19 |
-
width:100%;
|
20 |
-
z-index:100000;
|
21 |
-
}
|
22 |
-
|
23 |
-
/*
|
24 |
-
* ACFE Modal
|
25 |
-
*/
|
26 |
-
.acfe-modal{
|
27 |
-
display:none;
|
28 |
-
-webkit-transition: all 0.3s ease-in-out;
|
29 |
-
-o-transition: all 0.3s ease-in-out;
|
30 |
-
transition: all 0.3s ease-in-out;
|
31 |
-
}
|
32 |
-
|
33 |
-
.acfe-modal.-open{
|
34 |
-
position:fixed;
|
35 |
-
z-index:100001;
|
36 |
-
height:100%;
|
37 |
-
width:100%;
|
38 |
-
top:0;
|
39 |
-
left:0;
|
40 |
-
bottom:0;
|
41 |
-
right:0;
|
42 |
-
-webkit-font-smoothing: subpixel-antialiased;
|
43 |
-
|
44 |
-
display: -webkit-box;
|
45 |
-
display: -ms-flexbox;
|
46 |
-
display: flex;
|
47 |
-
-webkit-box-orient: vertical;
|
48 |
-
-webkit-box-direction: normal;
|
49 |
-
-ms-flex-direction: column;
|
50 |
-
flex-direction: column;
|
51 |
-
-webkit-box-pack: center;
|
52 |
-
-ms-flex-pack: center;
|
53 |
-
justify-content: center;
|
54 |
-
-webkit-box-align: center;
|
55 |
-
-ms-flex-align: center;
|
56 |
-
align-items: center;
|
57 |
-
|
58 |
-
pointer-events:none;
|
59 |
-
}
|
60 |
-
|
61 |
-
/*
|
62 |
-
* ACFE Modal: Wrapper
|
63 |
-
*/
|
64 |
-
.acfe-modal.-open > .acfe-modal-wrapper{
|
65 |
-
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.7);
|
66 |
-
display: -webkit-box;
|
67 |
-
display: -ms-flexbox;
|
68 |
-
display: flex;
|
69 |
-
-webkit-box-orient: vertical;
|
70 |
-
-webkit-box-direction: normal;
|
71 |
-
-ms-flex-direction: column;
|
72 |
-
flex-direction: column;
|
73 |
-
|
74 |
-
width: calc(100vw - 60px);
|
75 |
-
max-width:1100px;
|
76 |
-
max-height: calc(100vh - 60px);
|
77 |
-
}
|
78 |
-
|
79 |
-
/*
|
80 |
-
* ACFE Modal: Sizes
|
81 |
-
*/
|
82 |
-
.acfe-modal.-open.-small > .acfe-modal-wrapper{
|
83 |
-
max-width:700px;
|
84 |
-
}
|
85 |
-
|
86 |
-
.acfe-modal.-open.-full > .acfe-modal-wrapper{
|
87 |
-
max-width:100%;
|
88 |
-
-webkit-box-flex: 1;
|
89 |
-
-ms-flex: 1;
|
90 |
-
flex: 1;
|
91 |
-
}
|
92 |
-
|
93 |
-
/*
|
94 |
-
* ACFE Modal Title
|
95 |
-
*/
|
96 |
-
|
97 |
-
.acfe-modal.-open >.acfe-modal-title,
|
98 |
-
.acfe-modal.-open .acfe-modal-title *{
|
99 |
-
-webkit-box-sizing:border-box;
|
100 |
-
box-sizing:border-box;
|
101 |
-
}
|
102 |
-
|
103 |
-
.acfe-modal.-open .acfe-modal-title{
|
104 |
-
display:block;
|
105 |
-
height: 50px;
|
106 |
-
line-height: 50px;
|
107 |
-
font-size: 22px;
|
108 |
-
color: #23282d;
|
109 |
-
border-bottom: 1px solid #ddd;
|
110 |
-
text-overflow: ellipsis;
|
111 |
-
background: #fcfcfc;
|
112 |
-
padding: 0 0 0 16px;
|
113 |
-
position:relative;
|
114 |
-
text-align:left;
|
115 |
-
pointer-events: auto;
|
116 |
-
}
|
117 |
-
|
118 |
-
.acfe-modal.-open .acfe-modal-title > span.title{
|
119 |
-
line-height: 50px;
|
120 |
-
color: #23282d;
|
121 |
-
font-weight: 600;
|
122 |
-
}
|
123 |
-
|
124 |
-
.acfe-modal.-open .acfe-modal-title > span.title .acf-fc-layout-order{
|
125 |
-
width: 30px;
|
126 |
-
height: 30px;
|
127 |
-
border-radius: 30px;
|
128 |
-
display: inline-block;
|
129 |
-
text-align: center;
|
130 |
-
line-height: 30px;
|
131 |
-
margin: 0 2px 0 0;
|
132 |
-
background: #F1F1F1;
|
133 |
-
font-size: 14px;
|
134 |
-
color: #666;
|
135 |
-
vertical-align: 2px;
|
136 |
-
}
|
137 |
-
|
138 |
-
.acfe-modal.-open .acfe-modal-title > button.close{
|
139 |
-
height: 50px;
|
140 |
-
width: 50px;
|
141 |
-
color: #72777c;
|
142 |
-
border:0;
|
143 |
-
border-left: 1px solid #ddd;
|
144 |
-
margin: 0;
|
145 |
-
padding:0;
|
146 |
-
border-radius: 0;
|
147 |
-
position: absolute;
|
148 |
-
top:0;
|
149 |
-
right:0;
|
150 |
-
transition: color .1s ease-in-out, background .1s ease-in-out;
|
151 |
-
background:none;
|
152 |
-
cursor:pointer;
|
153 |
-
margin: 0;
|
154 |
-
}
|
155 |
-
|
156 |
-
.acfe-modal.-open .acfe-modal-title > button.close:hover{
|
157 |
-
background: #ddd;
|
158 |
-
border-color: #ccc;
|
159 |
-
color: #000;
|
160 |
-
}
|
161 |
-
|
162 |
-
.acfe-modal.-open .acfe-modal-title > button.close:before{
|
163 |
-
height: 50px;
|
164 |
-
width: 50px;
|
165 |
-
line-height: 50px !important;
|
166 |
-
font: normal 22px/1 dashicons;
|
167 |
-
content: "\f335";
|
168 |
-
margin: 0;
|
169 |
-
padding:0;
|
170 |
-
}
|
171 |
-
|
172 |
-
/*
|
173 |
-
* ACFE Modal Content
|
174 |
-
*/
|
175 |
-
.acfe-modal.-open .acfe-modal-content{
|
176 |
-
height:100%;
|
177 |
-
background:#fff;
|
178 |
-
overflow:auto;
|
179 |
-
display:block;
|
180 |
-
position:relative;
|
181 |
-
pointer-events: auto;
|
182 |
-
}
|
183 |
-
|
184 |
-
/*
|
185 |
-
* ACFE Modal Content: Tabs
|
186 |
-
*/
|
187 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper{
|
188 |
-
padding:0;
|
189 |
-
margin:0;
|
190 |
-
border-color:#ddd;
|
191 |
-
}
|
192 |
-
|
193 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a{
|
194 |
-
margin:0;
|
195 |
-
border-left:0;
|
196 |
-
border-top:0;
|
197 |
-
border-bottom:0;
|
198 |
-
background:#fff;
|
199 |
-
transition:color .1s ease-in-out, background .1s ease-in-out;
|
200 |
-
padding:7px 15px;
|
201 |
-
border-color:#ddd;
|
202 |
-
}
|
203 |
-
|
204 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a span.dashicons-menu{
|
205 |
-
line-height:27px;
|
206 |
-
}
|
207 |
-
|
208 |
-
.acfe-modal.-open > .acfe-modal-content .nav-tab-wrapper a:hover{
|
209 |
-
background:#f9f9f9;
|
210 |
-
color:#23282d;
|
211 |
-
}
|
212 |
-
|
213 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a.nav-tab-active,
|
214 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a.nav-tab-active:hover{
|
215 |
-
background:#fcfcfc;
|
216 |
-
color:#23282d;
|
217 |
-
}
|
218 |
-
|
219 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab:focus,
|
220 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab:focus:active {
|
221 |
-
border-bottom: 0;
|
222 |
-
box-shadow: none;
|
223 |
-
outline:0;
|
224 |
-
}
|
225 |
-
|
226 |
-
/*
|
227 |
-
* ACFE Modal Content: Flex
|
228 |
-
*/
|
229 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container,
|
230 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container *{
|
231 |
-
-webkit-box-sizing:border-box;
|
232 |
-
box-sizing:border-box;
|
233 |
-
}
|
234 |
-
|
235 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container{
|
236 |
-
width: 100%;
|
237 |
-
padding: 14px;
|
238 |
-
margin-right: auto;
|
239 |
-
margin-left: auto;
|
240 |
-
}
|
241 |
-
|
242 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul{
|
243 |
-
margin: 0;
|
244 |
-
margin-right: -7px;
|
245 |
-
margin-left: -7px;
|
246 |
-
|
247 |
-
display: -webkit-box;
|
248 |
-
display: -ms-flexbox;
|
249 |
-
display: flex;
|
250 |
-
-ms-flex-wrap: wrap;
|
251 |
-
flex-wrap: wrap;
|
252 |
-
}
|
253 |
-
|
254 |
-
.acfe-modal.-open >.acfe-modal-content .acfe-flex-container ul:after{
|
255 |
-
content:"";
|
256 |
-
clear:both;
|
257 |
-
display:table;
|
258 |
-
}
|
259 |
-
|
260 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li{
|
261 |
-
position: relative;
|
262 |
-
width: 100%;
|
263 |
-
padding-right: 7px;
|
264 |
-
padding-left: 7px;
|
265 |
-
padding-bottom: 14px;
|
266 |
-
margin:0;
|
267 |
-
|
268 |
-
-webkit-box-flex: 0;
|
269 |
-
-ms-flex: 0 0 25%;
|
270 |
-
flex: 0 0 25%;
|
271 |
-
max-width: 25%;
|
272 |
-
}
|
273 |
-
|
274 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a{
|
275 |
-
border:1px solid #ddd;
|
276 |
-
background:#F9F9F9;
|
277 |
-
padding:15px;
|
278 |
-
color:#333;
|
279 |
-
display:block;
|
280 |
-
text-decoration:none;
|
281 |
-
}
|
282 |
-
|
283 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a:hover{
|
284 |
-
background:#0073aa;
|
285 |
-
color:#fff;
|
286 |
-
}
|
287 |
-
|
288 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a span{
|
289 |
-
display:block;
|
290 |
-
font-size:13px;
|
291 |
-
text-align:center;
|
292 |
-
font-weight:600;
|
293 |
-
}
|
294 |
-
|
295 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container
|
296 |
-
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
}
|
361 |
-
}
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
margin-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
body.block-editor-page.
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
}
|
1 |
+
/*
|
2 |
+
* ACFE Modal Body
|
3 |
+
*/
|
4 |
+
body.acfe-modal-opened{
|
5 |
+
overflow:hidden;
|
6 |
+
}
|
7 |
+
|
8 |
+
/*
|
9 |
+
* ACFE Modal Overlay
|
10 |
+
*/
|
11 |
+
.acfe-modal-overlay{
|
12 |
+
background:rgba(0,0,0,.7);
|
13 |
+
position:fixed;
|
14 |
+
top:0;
|
15 |
+
left:0;
|
16 |
+
right:0;
|
17 |
+
bottom:0;
|
18 |
+
height:100%;
|
19 |
+
width:100%;
|
20 |
+
z-index:100000;
|
21 |
+
}
|
22 |
+
|
23 |
+
/*
|
24 |
+
* ACFE Modal
|
25 |
+
*/
|
26 |
+
.acfe-modal{
|
27 |
+
display:none;
|
28 |
+
-webkit-transition: all 0.3s ease-in-out;
|
29 |
+
-o-transition: all 0.3s ease-in-out;
|
30 |
+
transition: all 0.3s ease-in-out;
|
31 |
+
}
|
32 |
+
|
33 |
+
.acfe-modal.-open{
|
34 |
+
position:fixed;
|
35 |
+
z-index:100001;
|
36 |
+
height:100%;
|
37 |
+
width:100%;
|
38 |
+
top:0;
|
39 |
+
left:0;
|
40 |
+
bottom:0;
|
41 |
+
right:0;
|
42 |
+
-webkit-font-smoothing: subpixel-antialiased;
|
43 |
+
|
44 |
+
display: -webkit-box;
|
45 |
+
display: -ms-flexbox;
|
46 |
+
display: flex;
|
47 |
+
-webkit-box-orient: vertical;
|
48 |
+
-webkit-box-direction: normal;
|
49 |
+
-ms-flex-direction: column;
|
50 |
+
flex-direction: column;
|
51 |
+
-webkit-box-pack: center;
|
52 |
+
-ms-flex-pack: center;
|
53 |
+
justify-content: center;
|
54 |
+
-webkit-box-align: center;
|
55 |
+
-ms-flex-align: center;
|
56 |
+
align-items: center;
|
57 |
+
|
58 |
+
pointer-events:none;
|
59 |
+
}
|
60 |
+
|
61 |
+
/*
|
62 |
+
* ACFE Modal: Wrapper
|
63 |
+
*/
|
64 |
+
.acfe-modal.-open > .acfe-modal-wrapper{
|
65 |
+
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.7);
|
66 |
+
display: -webkit-box;
|
67 |
+
display: -ms-flexbox;
|
68 |
+
display: flex;
|
69 |
+
-webkit-box-orient: vertical;
|
70 |
+
-webkit-box-direction: normal;
|
71 |
+
-ms-flex-direction: column;
|
72 |
+
flex-direction: column;
|
73 |
+
|
74 |
+
width: calc(100vw - 60px);
|
75 |
+
max-width:1100px;
|
76 |
+
max-height: calc(100vh - 60px);
|
77 |
+
}
|
78 |
+
|
79 |
+
/*
|
80 |
+
* ACFE Modal: Sizes
|
81 |
+
*/
|
82 |
+
.acfe-modal.-open.-small > .acfe-modal-wrapper{
|
83 |
+
max-width:700px;
|
84 |
+
}
|
85 |
+
|
86 |
+
.acfe-modal.-open.-full > .acfe-modal-wrapper{
|
87 |
+
max-width:100%;
|
88 |
+
-webkit-box-flex: 1;
|
89 |
+
-ms-flex: 1;
|
90 |
+
flex: 1;
|
91 |
+
}
|
92 |
+
|
93 |
+
/*
|
94 |
+
* ACFE Modal Title
|
95 |
+
*/
|
96 |
+
|
97 |
+
.acfe-modal.-open >.acfe-modal-title,
|
98 |
+
.acfe-modal.-open .acfe-modal-title *{
|
99 |
+
-webkit-box-sizing:border-box;
|
100 |
+
box-sizing:border-box;
|
101 |
+
}
|
102 |
+
|
103 |
+
.acfe-modal.-open .acfe-modal-title{
|
104 |
+
display:block;
|
105 |
+
height: 50px;
|
106 |
+
line-height: 50px;
|
107 |
+
font-size: 22px;
|
108 |
+
color: #23282d;
|
109 |
+
border-bottom: 1px solid #ddd;
|
110 |
+
text-overflow: ellipsis;
|
111 |
+
background: #fcfcfc;
|
112 |
+
padding: 0 0 0 16px;
|
113 |
+
position:relative;
|
114 |
+
text-align:left;
|
115 |
+
pointer-events: auto;
|
116 |
+
}
|
117 |
+
|
118 |
+
.acfe-modal.-open .acfe-modal-title > span.title{
|
119 |
+
line-height: 50px;
|
120 |
+
color: #23282d;
|
121 |
+
font-weight: 600;
|
122 |
+
}
|
123 |
+
|
124 |
+
.acfe-modal.-open .acfe-modal-title > span.title .acf-fc-layout-order{
|
125 |
+
width: 30px;
|
126 |
+
height: 30px;
|
127 |
+
border-radius: 30px;
|
128 |
+
display: inline-block;
|
129 |
+
text-align: center;
|
130 |
+
line-height: 30px;
|
131 |
+
margin: 0 2px 0 0;
|
132 |
+
background: #F1F1F1;
|
133 |
+
font-size: 14px;
|
134 |
+
color: #666;
|
135 |
+
vertical-align: 2px;
|
136 |
+
}
|
137 |
+
|
138 |
+
.acfe-modal.-open .acfe-modal-title > button.close{
|
139 |
+
height: 50px;
|
140 |
+
width: 50px;
|
141 |
+
color: #72777c;
|
142 |
+
border:0;
|
143 |
+
border-left: 1px solid #ddd;
|
144 |
+
margin: 0;
|
145 |
+
padding:0;
|
146 |
+
border-radius: 0;
|
147 |
+
position: absolute;
|
148 |
+
top:0;
|
149 |
+
right:0;
|
150 |
+
transition: color .1s ease-in-out, background .1s ease-in-out;
|
151 |
+
background:none;
|
152 |
+
cursor:pointer;
|
153 |
+
margin: 0;
|
154 |
+
}
|
155 |
+
|
156 |
+
.acfe-modal.-open .acfe-modal-title > button.close:hover{
|
157 |
+
background: #ddd;
|
158 |
+
border-color: #ccc;
|
159 |
+
color: #000;
|
160 |
+
}
|
161 |
+
|
162 |
+
.acfe-modal.-open .acfe-modal-title > button.close:before{
|
163 |
+
height: 50px;
|
164 |
+
width: 50px;
|
165 |
+
line-height: 50px !important;
|
166 |
+
font: normal 22px/1 dashicons;
|
167 |
+
content: "\f335";
|
168 |
+
margin: 0;
|
169 |
+
padding:0;
|
170 |
+
}
|
171 |
+
|
172 |
+
/*
|
173 |
+
* ACFE Modal Content
|
174 |
+
*/
|
175 |
+
.acfe-modal.-open .acfe-modal-content{
|
176 |
+
height:100%;
|
177 |
+
background:#fff;
|
178 |
+
overflow:auto;
|
179 |
+
display:block;
|
180 |
+
position:relative;
|
181 |
+
pointer-events: auto;
|
182 |
+
}
|
183 |
+
|
184 |
+
/*
|
185 |
+
* ACFE Modal Content: Tabs
|
186 |
+
*/
|
187 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper{
|
188 |
+
padding:0;
|
189 |
+
margin:0;
|
190 |
+
border-color:#ddd;
|
191 |
+
}
|
192 |
+
|
193 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a{
|
194 |
+
margin:0;
|
195 |
+
border-left:0;
|
196 |
+
border-top:0;
|
197 |
+
border-bottom:0;
|
198 |
+
background:#fff;
|
199 |
+
transition:color .1s ease-in-out, background .1s ease-in-out;
|
200 |
+
padding:7px 15px;
|
201 |
+
border-color:#ddd;
|
202 |
+
}
|
203 |
+
|
204 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a span.dashicons-menu{
|
205 |
+
line-height:27px;
|
206 |
+
}
|
207 |
+
|
208 |
+
.acfe-modal.-open > .acfe-modal-content .nav-tab-wrapper a:hover{
|
209 |
+
background:#f9f9f9;
|
210 |
+
color:#23282d;
|
211 |
+
}
|
212 |
+
|
213 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a.nav-tab-active,
|
214 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a.nav-tab-active:hover{
|
215 |
+
background:#fcfcfc;
|
216 |
+
color:#23282d;
|
217 |
+
}
|
218 |
+
|
219 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab:focus,
|
220 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab:focus:active {
|
221 |
+
border-bottom: 0;
|
222 |
+
box-shadow: none;
|
223 |
+
outline:0;
|
224 |
+
}
|
225 |
+
|
226 |
+
/*
|
227 |
+
* ACFE Modal Content: Flex
|
228 |
+
*/
|
229 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container,
|
230 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container *{
|
231 |
+
-webkit-box-sizing:border-box;
|
232 |
+
box-sizing:border-box;
|
233 |
+
}
|
234 |
+
|
235 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container{
|
236 |
+
width: 100%;
|
237 |
+
padding: 14px;
|
238 |
+
margin-right: auto;
|
239 |
+
margin-left: auto;
|
240 |
+
}
|
241 |
+
|
242 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul{
|
243 |
+
margin: 0;
|
244 |
+
margin-right: -7px;
|
245 |
+
margin-left: -7px;
|
246 |
+
|
247 |
+
display: -webkit-box;
|
248 |
+
display: -ms-flexbox;
|
249 |
+
display: flex;
|
250 |
+
-ms-flex-wrap: wrap;
|
251 |
+
flex-wrap: wrap;
|
252 |
+
}
|
253 |
+
|
254 |
+
.acfe-modal.-open >.acfe-modal-content .acfe-flex-container ul:after{
|
255 |
+
content:"";
|
256 |
+
clear:both;
|
257 |
+
display:table;
|
258 |
+
}
|
259 |
+
|
260 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li{
|
261 |
+
position: relative;
|
262 |
+
width: 100%;
|
263 |
+
padding-right: 7px;
|
264 |
+
padding-left: 7px;
|
265 |
+
padding-bottom: 14px;
|
266 |
+
margin:0;
|
267 |
+
|
268 |
+
-webkit-box-flex: 0;
|
269 |
+
-ms-flex: 0 0 25%;
|
270 |
+
flex: 0 0 25%;
|
271 |
+
max-width: 25%;
|
272 |
+
}
|
273 |
+
|
274 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a{
|
275 |
+
border:1px solid #ddd;
|
276 |
+
background:#F9F9F9;
|
277 |
+
padding:15px;
|
278 |
+
color:#333;
|
279 |
+
display:block;
|
280 |
+
text-decoration:none;
|
281 |
+
}
|
282 |
+
|
283 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a:hover{
|
284 |
+
background:#0073aa;
|
285 |
+
color:#fff;
|
286 |
+
}
|
287 |
+
|
288 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a span{
|
289 |
+
display:block;
|
290 |
+
font-size:13px;
|
291 |
+
text-align:center;
|
292 |
+
font-weight:600;
|
293 |
+
}
|
294 |
+
|
295 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.disabled{
|
296 |
+
pointer-events:none;
|
297 |
+
opacity:0.67;
|
298 |
+
}
|
299 |
+
|
300 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.disabled:hover{
|
301 |
+
cursor:default;
|
302 |
+
}
|
303 |
+
|
304 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.disabled:focus{
|
305 |
+
box-shadow:none;
|
306 |
+
outline:none;
|
307 |
+
}
|
308 |
+
|
309 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-1 ul li{
|
310 |
+
-ms-flex: 0 0 100%;
|
311 |
+
flex: 0 0 100%;
|
312 |
+
max-width: 100%;
|
313 |
+
}
|
314 |
+
|
315 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-2 ul li{
|
316 |
+
-ms-flex: 0 0 50%;
|
317 |
+
flex: 0 0 50%;
|
318 |
+
max-width: 50%;
|
319 |
+
}
|
320 |
+
|
321 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-3 ul li{
|
322 |
+
-ms-flex: 0 0 33.333333%;
|
323 |
+
flex: 0 0 33.333333%;
|
324 |
+
max-width: 33.333333%;
|
325 |
+
}
|
326 |
+
|
327 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-4 ul li{
|
328 |
+
-ms-flex: 0 0 25%;
|
329 |
+
flex: 0 0 25%;
|
330 |
+
max-width: 25%;
|
331 |
+
}
|
332 |
+
|
333 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-5 ul li{
|
334 |
+
-ms-flex: 0 0 20%;
|
335 |
+
flex: 0 0 20%;
|
336 |
+
max-width: 20%;
|
337 |
+
}
|
338 |
+
|
339 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-6 ul li{
|
340 |
+
-ms-flex: 0 0 16.66%;
|
341 |
+
flex: 0 0 16.66%;
|
342 |
+
max-width: 16.66%;
|
343 |
+
}
|
344 |
+
|
345 |
+
@media only screen and (max-width:960px){
|
346 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li{
|
347 |
+
-ms-flex: 0 0 50% !important;
|
348 |
+
flex: 0 0 50% !important;
|
349 |
+
max-width: 50% !important;
|
350 |
+
}
|
351 |
+
|
352 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-1 ul li{
|
353 |
+
-ms-flex: 0 0 100% !important;
|
354 |
+
flex: 0 0 100% !important;
|
355 |
+
max-width: 100% !important;
|
356 |
+
}
|
357 |
+
|
358 |
+
.acfe-modal.-open .acfe-modal-content ul li a{
|
359 |
+
padding:7px;
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
@media only screen and (max-width:720px){
|
364 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li{
|
365 |
+
-ms-flex: 0 0 100% !important;
|
366 |
+
flex: 0 0 100% !important;
|
367 |
+
max-width: 100% !important;
|
368 |
+
}
|
369 |
+
|
370 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-1 ul li{
|
371 |
+
-ms-flex: 0 0 100% !important;
|
372 |
+
flex: 0 0 100% !important;
|
373 |
+
max-width: 100% !important;
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
+
/*
|
378 |
+
* ACFE Modal footer
|
379 |
+
*/
|
380 |
+
.acfe-modal.-open .acfe-modal-footer,
|
381 |
+
.acfe-modal.-open .acfe-modal-footer *{
|
382 |
+
-webkit-box-sizing:border-box;
|
383 |
+
box-sizing:border-box;
|
384 |
+
}
|
385 |
+
|
386 |
+
.acfe-modal.-open .acfe-modal-footer{
|
387 |
+
display:block;
|
388 |
+
height: 50px;
|
389 |
+
line-height: 50px;
|
390 |
+
color: #23282d;
|
391 |
+
background: #fcfcfc;
|
392 |
+
padding: 0 16px;
|
393 |
+
position:relative;
|
394 |
+
text-align:right;
|
395 |
+
border-top: 1px solid #ddd;
|
396 |
+
pointer-events: auto;
|
397 |
+
}
|
398 |
+
|
399 |
+
.acfe-modal.-open .acfe-modal-footer > button{
|
400 |
+
vertical-align: baseline;
|
401 |
+
}
|
402 |
+
|
403 |
+
/*
|
404 |
+
* ACFE Modal Gutenberg Fix
|
405 |
+
*/
|
406 |
+
body.block-editor-page .edit-post-layout .acfe-modal.-open{
|
407 |
+
-webkit-box-pack: start;
|
408 |
+
-ms-flex-pack: start;
|
409 |
+
justify-content: start;
|
410 |
+
-webkit-box-align: start;
|
411 |
+
-ms-flex-align: start;
|
412 |
+
align-items: start;
|
413 |
+
}
|
414 |
+
|
415 |
+
body.block-editor-page .edit-post-layout .acfe-modal.-open > .acfe-modal-wrapper{
|
416 |
+
margin-top: 88px;
|
417 |
+
height: 100%;
|
418 |
+
width: 100%;
|
419 |
+
max-height: calc(100vh - 88px);
|
420 |
+
}
|
421 |
+
|
422 |
+
@media only screen and (max-width: 1080px) {
|
423 |
+
body.block-editor-page .edit-post-layout .acfe-modal.-open > .acfe-modal-wrapper{
|
424 |
+
margin-top: 125px;
|
425 |
+
}
|
426 |
+
}
|
427 |
+
|
428 |
+
body.block-editor-page .edit-post-layout .acfe-modal.-open > .acfe-modal-wrapper{
|
429 |
+
max-width: calc(100vw - 160px);
|
430 |
+
margin-left: 160px;
|
431 |
+
}
|
432 |
+
|
433 |
+
body.block-editor-page .edit-post-layout.is-sidebar-opened .acfe-modal.-open > .acfe-modal-wrapper{
|
434 |
+
max-width: calc(100vw - 440px);
|
435 |
+
}
|
436 |
+
|
437 |
+
|
438 |
+
body.block-editor-page.folded .edit-post-layout .acfe-modal.-open > .acfe-modal-wrapper{
|
439 |
+
max-width: calc(100vw - 36px);
|
440 |
+
margin-left:36px;
|
441 |
+
}
|
442 |
+
|
443 |
+
@media only screen and (max-width: 960px) {
|
444 |
+
body.block-editor-page.auto-fold .edit-post-layout .acfe-modal.-open > .acfe-modal-wrapper{
|
445 |
+
max-width: calc(100vw - 36px);
|
446 |
+
margin-left:36px;
|
447 |
+
}
|
448 |
+
}
|
449 |
+
|
450 |
+
@media only screen and (max-width: 782px) {
|
451 |
+
body.block-editor-page.auto-fold .edit-post-layout .acfe-modal.-open > .acfe-modal-wrapper{
|
452 |
+
max-width: 100vw;
|
453 |
+
margin-left:0;
|
454 |
+
margin-top: 100px;
|
455 |
+
}
|
456 |
+
}
|
457 |
+
|
458 |
+
body.block-editor-page.folded .edit-post-layout.is-sidebar-opened .acfe-modal.-open > .acfe-modal-wrapper{
|
459 |
+
max-width: calc(100vw - 316px);
|
460 |
+
}
|
461 |
+
|
462 |
+
body.block-editor-page .acfe-modal-overlay{
|
463 |
+
display:none;
|
464 |
}
|
assets/acf-extended-taxonomies.css
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* ACFE: Better Taxonomy - Archive
|
3 |
+
*/
|
4 |
+
.edit-tags-php #col-container #col-right{
|
5 |
+
float:none;
|
6 |
+
width:auto;
|
7 |
+
}
|
8 |
+
|
9 |
+
.edit-tags-php #col-container #col-right .col-wrap{
|
10 |
+
padding:0;
|
11 |
+
}
|
12 |
+
|
13 |
+
.edit-tags-php #col-left.acfe-bt{
|
14 |
+
float:none;
|
15 |
+
width:100%;
|
16 |
+
}
|
17 |
+
|
18 |
+
.edit-tags-php #col-left.acfe-bt .col-wrap{
|
19 |
+
padding:0;
|
20 |
+
}
|
21 |
+
|
22 |
+
.edit-tags-php #col-left.acfe-bt #poststuff{
|
23 |
+
min-width:100%;
|
24 |
+
}
|
25 |
+
|
26 |
+
.edit-tags-php #acfe-bt-form .submit.acf-field{
|
27 |
+
display:block !important;
|
28 |
+
margin: 0;
|
29 |
+
}
|
30 |
+
|
31 |
+
/*
|
32 |
+
* ACFE: Better Taxonomy - Edit
|
33 |
+
*/
|
34 |
+
.term-php #edittag{
|
35 |
+
max-width:100%;
|
36 |
+
width: 100%;
|
37 |
+
float:left;
|
38 |
+
}
|
39 |
+
|
40 |
+
.term-php #edittag .form-table{
|
41 |
+
background:#fff;
|
42 |
+
width:100%;
|
43 |
+
border: 1px solid #E1E1E1;
|
44 |
+
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
45 |
+
margin-bottom: 15px; /* Fix for Yoast / Rank Math Metaboxes below the term */
|
46 |
+
}
|
47 |
+
|
48 |
+
.term-php #edittag .form-table > tbody > tr > td{
|
49 |
+
background: #fff;
|
50 |
+
border-top: 1px solid #E1E1E1;
|
51 |
+
position:initial;
|
52 |
+
}
|
53 |
+
|
54 |
+
.term-php #edittag .form-table > tbody > tr:first-of-type > td,
|
55 |
+
.term-php #edittag .form-table > tbody > tr:first-of-type > th{
|
56 |
+
border-top: 1px solid #E1E1E1;
|
57 |
+
}
|
58 |
+
|
59 |
+
.term-php #edittag .form-table > tbody > tr > td p{
|
60 |
+
font-size:13px;
|
61 |
+
}
|
62 |
+
|
63 |
+
.term-php #edittag .form-table > tbody > tr > th,
|
64 |
+
.term-php #edittag .form-table > tbody > tr > td.acf-label{
|
65 |
+
border-top: 1px solid #E1E1E1;
|
66 |
+
border-right: 1px solid #E1E1E1;
|
67 |
+
background: #F9F9F9;
|
68 |
+
padding:15px 12px;
|
69 |
+
width:20%;
|
70 |
+
font-size:13px;
|
71 |
+
position:initial;
|
72 |
+
}
|
73 |
+
|
74 |
+
.term-php #edittag .form-table > tbody > tr.acf-field{
|
75 |
+
position: initial;
|
76 |
+
}
|
77 |
+
|
78 |
+
.term-php #edittag .form-table > tbody > tr.acf-tab-wrap > td{
|
79 |
+
background: #F9F9F9;
|
80 |
+
padding:15px 0 0 0;
|
81 |
+
}
|
82 |
+
|
83 |
+
.term-php #edittag .form-table > tbody > tr.acf-tab-wrap > td ul.acf-tab-group{
|
84 |
+
border-bottom:0;
|
85 |
+
padding:0 0 0 20%;
|
86 |
+
}
|
87 |
+
|
88 |
+
.term-php #edittag .form-table > tbody > tr.acf-tab-wrap > td ul.acf-tab-group > li.active a{
|
89 |
+
background: #fff;
|
90 |
+
}
|
91 |
+
|
92 |
+
.term-php #poststuff.acfe-acfe-bt-admin-column{
|
93 |
+
min-width:auto;
|
94 |
+
padding:0;
|
95 |
+
}
|
96 |
+
|
97 |
+
.term-php #poststuff.acfe-acfe-bt-admin-column .inside{
|
98 |
+
margin: 0;
|
99 |
+
padding: 0;
|
100 |
+
}
|
101 |
+
|
102 |
+
.acf-fields.-left > .acf-field.acfe-bt-no-label{
|
103 |
+
padding-left: 20%;
|
104 |
+
}
|
105 |
+
|
106 |
+
/*
|
107 |
+
* ACFE: Better Taxonomy - Edit (Fix ACF)
|
108 |
+
*/
|
109 |
+
.term-php #edittag .acf-fields.-left > .acf-field {
|
110 |
+
padding-left: 0;
|
111 |
+
}
|
112 |
+
|
113 |
+
.term-php #edittag .acf-fields.-left > .acf-field:before {
|
114 |
+
width:20%;
|
115 |
+
}
|
116 |
+
|
117 |
+
.term-php #edittag .acf-fields.-left > .acf-field > .acf-label {
|
118 |
+
width: 20%;
|
119 |
+
margin-left: 0;
|
120 |
+
padding: 0 12px;
|
121 |
+
}
|
122 |
+
|
123 |
+
.term-php #edittag .acf-fields.-left > .acf-field > .acf-input {
|
124 |
+
padding: 0 12px;
|
125 |
+
}
|
assets/acf-extended.css
CHANGED
@@ -1,337 +1,217 @@
|
|
1 |
-
/*
|
2 |
-
* ACFE: Dynamic Post Type 'Setting' Button
|
3 |
-
*/
|
4 |
-
.wrap .acfe-dpt-admin-config,
|
5 |
-
.wrap .acfe-dpt-admin-config:active,
|
6 |
-
.wrap .acfe-dt-admin-config,
|
7 |
-
.wrap .acfe-dt-admin-config:active{
|
8 |
-
padding-left:4px;
|
9 |
-
padding-right:4px;
|
10 |
-
}
|
11 |
-
|
12 |
-
.wrap .acfe-dpt-admin-config span,
|
13 |
-
.wrap .acfe-dt-admin-config span{
|
14 |
-
font-size: 16px;
|
15 |
-
vertical-align: text-top;
|
16 |
-
color:#444;
|
17 |
-
}
|
18 |
-
|
19 |
-
.wrap .acfe-dpt-admin-config:hover span,
|
20 |
-
.wrap .acfe-dt-admin-config:hover span{
|
21 |
-
color:#fff;
|
22 |
-
}
|
23 |
-
|
24 |
-
/*
|
25 |
-
* ACFE: Dynamic Post Type
|
26 |
-
*/
|
27 |
-
body.post-type-acfe-dpt #minor-publishing{
|
28 |
-
display:none;
|
29 |
-
}
|
30 |
-
|
31 |
-
/*
|
32 |
-
* ACFE: Dynamic Taxonomy
|
33 |
-
*/
|
34 |
-
body.post-type-acfe-dt #minor-publishing{
|
35 |
-
display:none;
|
36 |
-
}
|
37 |
-
|
38 |
-
/*
|
39 |
-
* ACFE: Dynamic Options Page
|
40 |
-
*/
|
41 |
-
body.post-type-acfe-dop #minor-publishing{
|
42 |
-
display:none;
|
43 |
-
}
|
44 |
-
|
45 |
-
/*
|
46 |
-
* ACFE: Dynamic Block Type
|
47 |
-
*/
|
48 |
-
body.post-type-acfe-dbt #minor-publishing{
|
49 |
-
display:none;
|
50 |
-
}
|
51 |
-
|
52 |
-
/*
|
53 |
-
* ACFE:
|
54 |
-
*/
|
55 |
-
.
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
.
|
74 |
-
|
75 |
-
}
|
76 |
-
|
77 |
-
.
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
.
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
.
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
.
|
130 |
-
|
131 |
-
|
132 |
-
}
|
133 |
-
|
134 |
-
.
|
135 |
-
|
136 |
-
|
137 |
-
}
|
138 |
-
|
139 |
-
.
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
.
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
.
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
.acf-repeater.-row > table > tbody > tr > td,
|
219 |
-
.acf-repeater.-block > table > tbody > tr > td{
|
220 |
-
border-top: 1px solid #E1E1E1;
|
221 |
-
border-bottom: 1px solid #E1E1E1;
|
222 |
-
}
|
223 |
-
|
224 |
-
.acf-repeater.-row > table > tbody > tr > td:first-of-type,
|
225 |
-
.acf-repeater.-block > table > tbody > tr > td:first-of-type{
|
226 |
-
border-left: 1px solid #E1E1E1;
|
227 |
-
}
|
228 |
-
|
229 |
-
.acf-repeater.-row > table > tbody > tr > td:last-of-type,
|
230 |
-
.acf-repeater.-block > table > tbody > tr > td:last-of-type{
|
231 |
-
border-right: 1px solid #E1E1E1;
|
232 |
-
}
|
233 |
-
|
234 |
-
/*
|
235 |
-
* ACF: Select2 Fix
|
236 |
-
*/
|
237 |
-
.select2-container .select2-selection{
|
238 |
-
border-color: #dfdfdf !important;
|
239 |
-
border-radius:0 !important;
|
240 |
-
}
|
241 |
-
|
242 |
-
.select2-container .select2-selection__choice{
|
243 |
-
border-color: #dfdfdf !important;
|
244 |
-
border-radius:0 !important;
|
245 |
-
}
|
246 |
-
|
247 |
-
.select2-dropdown{
|
248 |
-
border-color: #dfdfdf !important;
|
249 |
-
border-radius:0 !important;
|
250 |
-
}
|
251 |
-
|
252 |
-
.select2-container .select2-selection--single .select2-selection__arrow,
|
253 |
-
.select2-container .select2-selection--single{
|
254 |
-
height: 32px !important;
|
255 |
-
}
|
256 |
-
|
257 |
-
.select2-container .select2-selection--single .select2-selection__rendered{
|
258 |
-
line-height: 31px !important;
|
259 |
-
}
|
260 |
-
|
261 |
-
.select2-container .select2-selection--single .select2-selection__clear{
|
262 |
-
line-height: 30px;
|
263 |
-
}
|
264 |
-
|
265 |
-
/*
|
266 |
-
* Gutenberg: Fix metaboxes
|
267 |
-
*/
|
268 |
-
.edit-post-layout__metaboxes:not(:empty) .edit-post-meta-boxes-area{
|
269 |
-
margin:10px 10px 0;
|
270 |
-
}
|
271 |
-
|
272 |
-
.edit-post-layout__metaboxes:not(:empty) {
|
273 |
-
background:#f3f4f5;
|
274 |
-
}
|
275 |
-
|
276 |
-
.edit-post-layout__metaboxes .edit-post-meta-boxes-area .postbox{
|
277 |
-
margin-bottom:10px;
|
278 |
-
}
|
279 |
-
|
280 |
-
/* Firefox fix only */
|
281 |
-
@supports (-moz-appearance:meterbar){
|
282 |
-
.edit-post-layout__metaboxes .postbox{
|
283 |
-
box-shadow:0 1px 1px 1px rgba(0,0,0,.04);
|
284 |
-
}
|
285 |
-
}
|
286 |
-
|
287 |
-
/*
|
288 |
-
* ACF Tools
|
289 |
-
*/
|
290 |
-
#acf-admin-tool-acfe_tool_dbt_export ul,
|
291 |
-
#acf-admin-tool-acfe_tool_dpt_export ul,
|
292 |
-
#acf-admin-tool-acfe_tool_dt_export ul,
|
293 |
-
#acf-admin-tool-acfe_tool_dop_export ul{
|
294 |
-
column-width: 200px;
|
295 |
-
}
|
296 |
-
|
297 |
-
/*
|
298 |
-
* ACFE WP Options
|
299 |
-
*/
|
300 |
-
.settings_page_acfe-options .column-option_id{
|
301 |
-
width:65px;
|
302 |
-
}
|
303 |
-
|
304 |
-
.settings_page_acfe-options .column-option_name{
|
305 |
-
width:435px;
|
306 |
-
}
|
307 |
-
|
308 |
-
.settings_page_acfe-options .column-autoload{
|
309 |
-
width:100px;
|
310 |
-
text-align:center;
|
311 |
-
}
|
312 |
-
|
313 |
-
/*
|
314 |
-
* ACFE General
|
315 |
-
*/
|
316 |
-
pre {
|
317 |
-
display: block;
|
318 |
-
padding: 9.5px;
|
319 |
-
margin: 0;
|
320 |
-
font-size: 13px;
|
321 |
-
line-height: 1.42857143;
|
322 |
-
color: #333;
|
323 |
-
word-break: break-all;
|
324 |
-
word-wrap: break-word;
|
325 |
-
background-color: #f5f5f5;
|
326 |
-
border: 1px solid #ccc;
|
327 |
-
border-radius: 4px;
|
328 |
-
white-space: pre-wrap;
|
329 |
-
overflow: auto;
|
330 |
-
}
|
331 |
-
code, kbd, pre, samp {
|
332 |
-
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
|
333 |
-
}
|
334 |
-
code, kbd, pre, samp {
|
335 |
-
font-family: monospace,monospace;
|
336 |
-
font-size: 1em;
|
337 |
}
|
1 |
+
/*
|
2 |
+
* ACFE: Dynamic Post Type 'Setting' Button
|
3 |
+
*/
|
4 |
+
.wrap .acfe-dpt-admin-config,
|
5 |
+
.wrap .acfe-dpt-admin-config:active,
|
6 |
+
.wrap .acfe-dt-admin-config,
|
7 |
+
.wrap .acfe-dt-admin-config:active{
|
8 |
+
padding-left:4px;
|
9 |
+
padding-right:4px;
|
10 |
+
}
|
11 |
+
|
12 |
+
.wrap .acfe-dpt-admin-config span,
|
13 |
+
.wrap .acfe-dt-admin-config span{
|
14 |
+
font-size: 16px;
|
15 |
+
vertical-align: text-top;
|
16 |
+
color:#444;
|
17 |
+
}
|
18 |
+
|
19 |
+
.wrap .acfe-dpt-admin-config:hover span,
|
20 |
+
.wrap .acfe-dt-admin-config:hover span{
|
21 |
+
color:#fff;
|
22 |
+
}
|
23 |
+
|
24 |
+
/*
|
25 |
+
* ACFE: Dynamic Post Type
|
26 |
+
*/
|
27 |
+
body.post-type-acfe-dpt #minor-publishing{
|
28 |
+
display:none;
|
29 |
+
}
|
30 |
+
|
31 |
+
/*
|
32 |
+
* ACFE: Dynamic Taxonomy
|
33 |
+
*/
|
34 |
+
body.post-type-acfe-dt #minor-publishing{
|
35 |
+
display:none;
|
36 |
+
}
|
37 |
+
|
38 |
+
/*
|
39 |
+
* ACFE: Dynamic Options Page
|
40 |
+
*/
|
41 |
+
body.post-type-acfe-dop #minor-publishing{
|
42 |
+
display:none;
|
43 |
+
}
|
44 |
+
|
45 |
+
/*
|
46 |
+
* ACFE: Dynamic Block Type
|
47 |
+
*/
|
48 |
+
body.post-type-acfe-dbt #minor-publishing{
|
49 |
+
display:none;
|
50 |
+
}
|
51 |
+
|
52 |
+
/*
|
53 |
+
* ACFE: Author Label
|
54 |
+
*/
|
55 |
+
.acf-field.acf-field-acfe-author > .acf-label{
|
56 |
+
display:none;
|
57 |
+
}
|
58 |
+
|
59 |
+
/*
|
60 |
+
* ACFE: Postbox
|
61 |
+
*/
|
62 |
+
.acfe-postbox.acfe-postbox-no-handle h2.hndle{
|
63 |
+
cursor:initial;
|
64 |
+
}
|
65 |
+
|
66 |
+
.acfe-postbox.acfe-postbox-no-handle .handlediv{
|
67 |
+
display:none;
|
68 |
+
}
|
69 |
+
|
70 |
+
/*
|
71 |
+
* ACF: Field fix
|
72 |
+
*/
|
73 |
+
.acf-field .acf-label label{
|
74 |
+
font-weight:600 !important;
|
75 |
+
}
|
76 |
+
|
77 |
+
.acf-field p.description{
|
78 |
+
word-break: break-word;
|
79 |
+
}
|
80 |
+
|
81 |
+
/*
|
82 |
+
* ACF: Repeater Block Fix (Add spacing)
|
83 |
+
*/
|
84 |
+
.acf-repeater.-row > table,
|
85 |
+
.acf-repeater.-block > table{
|
86 |
+
border-collapse: separate;
|
87 |
+
border-spacing: 0 15px;
|
88 |
+
background: none;
|
89 |
+
border: 0;
|
90 |
+
margin-top: -15px;
|
91 |
+
margin-bottom: -7px;
|
92 |
+
}
|
93 |
+
|
94 |
+
.acf-repeater.-row > table > *,
|
95 |
+
.acf-repeater.-block > table > *{
|
96 |
+
border-collapse: collapse;
|
97 |
+
border-spacing: 0;
|
98 |
+
}
|
99 |
+
|
100 |
+
.acf-repeater.-row > table > tbody > tr > td,
|
101 |
+
.acf-repeater.-block > table > tbody > tr > td{
|
102 |
+
border-top: 1px solid #E1E1E1;
|
103 |
+
border-bottom: 1px solid #E1E1E1;
|
104 |
+
}
|
105 |
+
|
106 |
+
.acf-repeater.-row > table > tbody > tr > td:first-of-type,
|
107 |
+
.acf-repeater.-block > table > tbody > tr > td:first-of-type{
|
108 |
+
border-left: 1px solid #E1E1E1;
|
109 |
+
}
|
110 |
+
|
111 |
+
.acf-repeater.-row > table > tbody > tr > td:last-of-type,
|
112 |
+
.acf-repeater.-block > table > tbody > tr > td:last-of-type{
|
113 |
+
border-right: 1px solid #E1E1E1;
|
114 |
+
}
|
115 |
+
|
116 |
+
/*
|
117 |
+
* ACF: Select2 Fix
|
118 |
+
*/
|
119 |
+
.select2-container .select2-selection{
|
120 |
+
border-color: #dfdfdf !important;
|
121 |
+
border-radius:0 !important;
|
122 |
+
}
|
123 |
+
|
124 |
+
.select2-container .select2-selection__choice{
|
125 |
+
border-color: #dfdfdf !important;
|
126 |
+
border-radius:0 !important;
|
127 |
+
}
|
128 |
+
|
129 |
+
.select2-dropdown{
|
130 |
+
border-color: #dfdfdf !important;
|
131 |
+
border-radius:0 !important;
|
132 |
+
}
|
133 |
+
|
134 |
+
.select2-container .select2-selection--single .select2-selection__arrow,
|
135 |
+
.select2-container .select2-selection--single{
|
136 |
+
height: 32px !important;
|
137 |
+
}
|
138 |
+
|
139 |
+
.select2-container .select2-selection--single .select2-selection__rendered{
|
140 |
+
line-height: 31px !important;
|
141 |
+
}
|
142 |
+
|
143 |
+
.select2-container .select2-selection--single .select2-selection__clear{
|
144 |
+
line-height: 30px;
|
145 |
+
}
|
146 |
+
|
147 |
+
/*
|
148 |
+
* Gutenberg: Fix metaboxes
|
149 |
+
*/
|
150 |
+
.edit-post-layout__metaboxes:not(:empty) .edit-post-meta-boxes-area{
|
151 |
+
margin:10px 10px 0;
|
152 |
+
}
|
153 |
+
|
154 |
+
.edit-post-layout__metaboxes:not(:empty) {
|
155 |
+
background:#f3f4f5;
|
156 |
+
}
|
157 |
+
|
158 |
+
.edit-post-layout__metaboxes .edit-post-meta-boxes-area .postbox{
|
159 |
+
margin-bottom:10px;
|
160 |
+
}
|
161 |
+
|
162 |
+
/* Firefox fix only */
|
163 |
+
@supports (-moz-appearance:meterbar){
|
164 |
+
.edit-post-layout__metaboxes .postbox{
|
165 |
+
box-shadow:0 1px 1px 1px rgba(0,0,0,.04);
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
/*
|
170 |
+
* ACF Tools
|
171 |
+
*/
|
172 |
+
#acf-admin-tool-acfe_tool_dbt_export ul,
|
173 |
+
#acf-admin-tool-acfe_tool_dpt_export ul,
|
174 |
+
#acf-admin-tool-acfe_tool_dt_export ul,
|
175 |
+
#acf-admin-tool-acfe_tool_dop_export ul{
|
176 |
+
column-width: 200px;
|
177 |
+
}
|
178 |
+
|
179 |
+
/*
|
180 |
+
* ACFE WP Options
|
181 |
+
*/
|
182 |
+
.settings_page_acfe-options .column-option_id{
|
183 |
+
width:65px;
|
184 |
+
}
|
185 |
+
|
186 |
+
.settings_page_acfe-options .column-option_name{
|
187 |
+
width:435px;
|
188 |
+
}
|
189 |
+
|
190 |
+
.settings_page_acfe-options .column-autoload{
|
191 |
+
width:100px;
|
192 |
+
text-align:center;
|
193 |
+
}
|
194 |
+
|
195 |
+
/*
|
196 |
+
* ACFE General
|
197 |
+
*/
|
198 |
+
pre{
|
199 |
+
display: block;
|
200 |
+
padding: 9.5px;
|
201 |
+
margin: 0;
|
202 |
+
font-size: 13px;
|
203 |
+
line-height: 1.42857143;
|
204 |
+
color: #333;
|
205 |
+
word-break: break-all;
|
206 |
+
word-wrap: break-word;
|
207 |
+
background-color: #f5f5f5;
|
208 |
+
border: 1px solid #ccc;
|
209 |
+
border-radius: 4px;
|
210 |
+
white-space: pre-wrap;
|
211 |
+
overflow: auto;
|
212 |
+
}
|
213 |
+
|
214 |
+
code, kbd, pre, samp{
|
215 |
+
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
|
216 |
+
font-size: 1em;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
}
|
assets/acf-extended.js
CHANGED
@@ -1,168 +1,156 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
// init
|
4 |
-
var acfe = {};
|
5 |
-
|
6 |
-
window.acfe = acfe;
|
7 |
-
|
8 |
-
acfe.modal = {
|
9 |
-
|
10 |
-
modals: [],
|
11 |
-
|
12 |
-
// Open
|
13 |
-
open: function($target, args){
|
14 |
-
|
15 |
-
args = acf.parseArgs(args, {
|
16 |
-
title: '',
|
17 |
-
footer: false,
|
18 |
-
size: false,
|
19 |
-
destroy: false,
|
20 |
-
onClose: false,
|
21 |
-
});
|
22 |
-
|
23 |
-
$target.addClass('-open');
|
24 |
-
|
25 |
-
if(args.size){
|
26 |
-
|
27 |
-
$target.addClass('-' + args.size);
|
28 |
-
|
29 |
-
}
|
30 |
-
|
31 |
-
if(!$target.find('> .acfe-modal-wrapper').length){
|
32 |
-
|
33 |
-
$target.wrapInner('<div class="acfe-modal-wrapper" />');
|
34 |
-
|
35 |
-
}
|
36 |
-
|
37 |
-
if(!$target.find('> .acfe-modal-wrapper > .acfe-modal-content').length){
|
38 |
-
|
39 |
-
$target.find('> .acfe-modal-wrapper').wrapInner('<div class="acfe-modal-content" />');
|
40 |
-
|
41 |
-
}
|
42 |
-
|
43 |
-
$target.find('> .acfe-modal-wrapper').prepend('<div class="acfe-modal-title"><span class="title">' + args.title + '</span><button class="close"></button></div>');
|
44 |
-
|
45 |
-
$target.find('.acfe-modal-title > .close').click(function(e){
|
46 |
-
e.preventDefault();
|
47 |
-
acfe.modal.close(args);
|
48 |
-
});
|
49 |
-
|
50 |
-
if(args.footer){
|
51 |
-
|
52 |
-
$target.find('> .acfe-modal-wrapper').append('<div class="acfe-modal-footer"><button class="button button-primary">' + args.footer + '</button></div>');
|
53 |
-
|
54 |
-
$target.find('.acfe-modal-footer > button').click(function(e){
|
55 |
-
e.preventDefault();
|
56 |
-
acfe.modal.close(args);
|
57 |
-
});
|
58 |
-
|
59 |
-
}
|
60 |
-
|
61 |
-
acfe.modal.modals.push($target);
|
62 |
-
|
63 |
-
var $body = $('body');
|
64 |
-
|
65 |
-
if(!$body.hasClass('acfe-modal-opened')){
|
66 |
-
|
67 |
-
var overlay = $('<div class="acfe-modal-overlay" />').click(function(){
|
68 |
-
acfe.modal.close(args);
|
69 |
-
});
|
70 |
-
|
71 |
-
$body.addClass('acfe-modal-opened').append(overlay);
|
72 |
-
|
73 |
-
}
|
74 |
-
|
75 |
-
$(window).keydown(function(e){
|
76 |
-
|
77 |
-
if((e.keyCode != 27
|
78 |
-
return;
|
79 |
-
|
80 |
-
acfe.modal.close(args);
|
81 |
-
return false;
|
82 |
-
|
83 |
-
});
|
84 |
-
|
85 |
-
acfe.modal.multiple();
|
86 |
-
|
87 |
-
return $target;
|
88 |
-
|
89 |
-
},
|
90 |
-
|
91 |
-
// Close
|
92 |
-
close: function(args){
|
93 |
-
|
94 |
-
args = acf.parseArgs(args, {
|
95 |
-
destroy: false,
|
96 |
-
onClose: false,
|
97 |
-
});
|
98 |
-
|
99 |
-
var $target = acfe.modal.modals.pop();
|
100 |
-
|
101 |
-
$target.find('.acfe-modal-title').remove();
|
102 |
-
$target.find('.acfe-modal-footer').remove();
|
103 |
-
|
104 |
-
$target.removeAttr('style');
|
105 |
-
|
106 |
-
$target.removeClass('-open -small -full');
|
107 |
-
|
108 |
-
if(args.destroy){
|
109 |
-
|
110 |
-
$target.remove();
|
111 |
-
|
112 |
-
}
|
113 |
-
|
114 |
-
if(!acfe.modal.modals.length){
|
115 |
-
|
116 |
-
$('.acfe-modal-overlay').remove();
|
117 |
-
$('body').removeClass('acfe-modal-opened');
|
118 |
-
|
119 |
-
}
|
120 |
-
|
121 |
-
acfe.modal.multiple();
|
122 |
-
|
123 |
-
acfe.modal.onClose($target, args);
|
124 |
-
|
125 |
-
},
|
126 |
-
|
127 |
-
// Multiple
|
128 |
-
multiple: function(){
|
129 |
-
|
130 |
-
var last = acfe.modal.modals.length - 1;
|
131 |
-
|
132 |
-
$.each(acfe.modal.modals, function(i){
|
133 |
-
|
134 |
-
if(last == i){
|
135 |
-
$(this).css('margin-left', '');
|
136 |
-
return;
|
137 |
-
}
|
138 |
-
|
139 |
-
$(this).css('margin-left', - (500 / (i+1)));
|
140 |
-
|
141 |
-
});
|
142 |
-
|
143 |
-
},
|
144 |
-
|
145 |
-
onClose: function($target, args){
|
146 |
-
|
147 |
-
if(!args.onClose || !(args.onClose instanceof Function))
|
148 |
-
return;
|
149 |
-
|
150 |
-
args.onClose($target);
|
151 |
-
|
152 |
-
}
|
153 |
-
|
154 |
-
};
|
155 |
-
|
156 |
-
/*
|
157 |
-
$(window).keydown(function(e){
|
158 |
-
|
159 |
-
if((e.keyCode != 27 && e.keyCode != 13) || !$('body').hasClass('acfe-modal-opened'))
|
160 |
-
return;
|
161 |
-
|
162 |
-
acfe.modal.close();
|
163 |
-
return false;
|
164 |
-
|
165 |
-
});
|
166 |
-
*/
|
167 |
-
|
168 |
})(jQuery);
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
// init
|
4 |
+
var acfe = {};
|
5 |
+
|
6 |
+
window.acfe = acfe;
|
7 |
+
|
8 |
+
acfe.modal = {
|
9 |
+
|
10 |
+
modals: [],
|
11 |
+
|
12 |
+
// Open
|
13 |
+
open: function($target, args){
|
14 |
+
|
15 |
+
args = acf.parseArgs(args, {
|
16 |
+
title: '',
|
17 |
+
footer: false,
|
18 |
+
size: false,
|
19 |
+
destroy: false,
|
20 |
+
onClose: false,
|
21 |
+
});
|
22 |
+
|
23 |
+
$target.addClass('-open');
|
24 |
+
|
25 |
+
if(args.size){
|
26 |
+
|
27 |
+
$target.addClass('-' + args.size);
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
if(!$target.find('> .acfe-modal-wrapper').length){
|
32 |
+
|
33 |
+
$target.wrapInner('<div class="acfe-modal-wrapper" />');
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
if(!$target.find('> .acfe-modal-wrapper > .acfe-modal-content').length){
|
38 |
+
|
39 |
+
$target.find('> .acfe-modal-wrapper').wrapInner('<div class="acfe-modal-content" />');
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
$target.find('> .acfe-modal-wrapper').prepend('<div class="acfe-modal-title"><span class="title">' + args.title + '</span><button class="close"></button></div>');
|
44 |
+
|
45 |
+
$target.find('.acfe-modal-title > .close').click(function(e){
|
46 |
+
e.preventDefault();
|
47 |
+
acfe.modal.close(args);
|
48 |
+
});
|
49 |
+
|
50 |
+
if(args.footer){
|
51 |
+
|
52 |
+
$target.find('> .acfe-modal-wrapper').append('<div class="acfe-modal-footer"><button class="button button-primary">' + args.footer + '</button></div>');
|
53 |
+
|
54 |
+
$target.find('.acfe-modal-footer > button').click(function(e){
|
55 |
+
e.preventDefault();
|
56 |
+
acfe.modal.close(args);
|
57 |
+
});
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
acfe.modal.modals.push($target);
|
62 |
+
|
63 |
+
var $body = $('body');
|
64 |
+
|
65 |
+
if(!$body.hasClass('acfe-modal-opened')){
|
66 |
+
|
67 |
+
var overlay = $('<div class="acfe-modal-overlay" />').click(function(){
|
68 |
+
acfe.modal.close(args);
|
69 |
+
});
|
70 |
+
|
71 |
+
$body.addClass('acfe-modal-opened').append(overlay);
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
$(window).keydown(function(e){
|
76 |
+
|
77 |
+
if((e.keyCode != 27) || !$('body').hasClass('acfe-modal-opened'))
|
78 |
+
return;
|
79 |
+
|
80 |
+
acfe.modal.close(args);
|
81 |
+
return false;
|
82 |
+
|
83 |
+
});
|
84 |
+
|
85 |
+
acfe.modal.multiple();
|
86 |
+
|
87 |
+
return $target;
|
88 |
+
|
89 |
+
},
|
90 |
+
|
91 |
+
// Close
|
92 |
+
close: function(args){
|
93 |
+
|
94 |
+
args = acf.parseArgs(args, {
|
95 |
+
destroy: false,
|
96 |
+
onClose: false,
|
97 |
+
});
|
98 |
+
|
99 |
+
var $target = acfe.modal.modals.pop();
|
100 |
+
|
101 |
+
$target.find('.acfe-modal-title').remove();
|
102 |
+
$target.find('.acfe-modal-footer').remove();
|
103 |
+
|
104 |
+
$target.removeAttr('style');
|
105 |
+
|
106 |
+
$target.removeClass('-open -small -full');
|
107 |
+
|
108 |
+
if(args.destroy){
|
109 |
+
|
110 |
+
$target.remove();
|
111 |
+
|
112 |
+
}
|
113 |
+
|
114 |
+
if(!acfe.modal.modals.length){
|
115 |
+
|
116 |
+
$('.acfe-modal-overlay').remove();
|
117 |
+
$('body').removeClass('acfe-modal-opened');
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
acfe.modal.multiple();
|
122 |
+
|
123 |
+
acfe.modal.onClose($target, args);
|
124 |
+
|
125 |
+
},
|
126 |
+
|
127 |
+
// Multiple
|
128 |
+
multiple: function(){
|
129 |
+
|
130 |
+
var last = acfe.modal.modals.length - 1;
|
131 |
+
|
132 |
+
$.each(acfe.modal.modals, function(i){
|
133 |
+
|
134 |
+
if(last == i){
|
135 |
+
$(this).css('margin-left', '');
|
136 |
+
return;
|
137 |
+
}
|
138 |
+
|
139 |
+
$(this).css('margin-left', - (500 / (i+1)));
|
140 |
+
|
141 |
+
});
|
142 |
+
|
143 |
+
},
|
144 |
+
|
145 |
+
onClose: function($target, args){
|
146 |
+
|
147 |
+
if(!args.onClose || !(args.onClose instanceof Function))
|
148 |
+
return;
|
149 |
+
|
150 |
+
args.onClose($target);
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
+
};
|
155 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
})(jQuery);
|
includes/admin/options.class.php
CHANGED
@@ -1,273 +1,273 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if (!class_exists( 'WP_List_Table'))
|
7 |
-
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
8 |
-
|
9 |
-
class ACFE_Admin_Options_List extends WP_List_Table{
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Constructor
|
13 |
-
*
|
14 |
-
*/
|
15 |
-
public function __construct(){
|
16 |
-
|
17 |
-
parent::__construct(array(
|
18 |
-
'singular' => __('Option', 'acfe'),
|
19 |
-
'plural' => __('Options', 'acfe'),
|
20 |
-
'ajax' => false
|
21 |
-
));
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Retrieve data from the database
|
28 |
-
*
|
29 |
-
* @param int $per_page
|
30 |
-
* @param int $page_number
|
31 |
-
*
|
32 |
-
* @return mixed
|
33 |
-
*/
|
34 |
-
public static function get_options($per_page = 100, $page_number = 1, $search = ''){
|
35 |
-
|
36 |
-
global $wpdb;
|
37 |
-
|
38 |
-
$sql = "SELECT * FROM {$wpdb->options}";
|
39 |
-
|
40 |
-
if(!empty($search)){
|
41 |
-
|
42 |
-
$sql .= ' WHERE option_name LIKE \'%' . $search . '%\'';
|
43 |
-
|
44 |
-
}
|
45 |
-
|
46 |
-
if(empty($_REQUEST['orderby'])){
|
47 |
-
|
48 |
-
$sql .= ' ORDER BY option_id ASC';
|
49 |
-
|
50 |
-
}
|
51 |
-
|
52 |
-
else{
|
53 |
-
|
54 |
-
$sql .= ' ORDER BY ' . esc_sql($_REQUEST['orderby']);
|
55 |
-
$sql .= !empty($_REQUEST['order']) ? ' ' . esc_sql($_REQUEST['order']) : ' ASC';
|
56 |
-
|
57 |
-
}
|
58 |
-
|
59 |
-
$sql .= " LIMIT $per_page";
|
60 |
-
$sql .= ' OFFSET ' . ($page_number - 1) * $per_page;
|
61 |
-
|
62 |
-
|
63 |
-
$result = $wpdb->get_results($sql, 'ARRAY_A');
|
64 |
-
|
65 |
-
return $result;
|
66 |
-
|
67 |
-
}
|
68 |
-
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Returns the count of records in the database.
|
72 |
-
*
|
73 |
-
* @return null|string
|
74 |
-
*/
|
75 |
-
public static function record_count($search = ''){
|
76 |
-
|
77 |
-
global $wpdb;
|
78 |
-
|
79 |
-
$sql = "SELECT COUNT(*) FROM {$wpdb->options}";
|
80 |
-
|
81 |
-
if(!empty($search)){
|
82 |
-
|
83 |
-
$sql .= ' WHERE option_name LIKE \'%' . $search . '%\'';
|
84 |
-
|
85 |
-
}
|
86 |
-
|
87 |
-
return $wpdb->get_var($sql);
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
|
92 |
-
/** Text displayed when no data is available */
|
93 |
-
public function no_items(){
|
94 |
-
|
95 |
-
_e('No options avaliable.', 'acfe');
|
96 |
-
|
97 |
-
}
|
98 |
-
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Render a column when no column specific method exist.
|
102 |
-
*
|
103 |
-
* @param array $item
|
104 |
-
* @param string $column_name
|
105 |
-
*
|
106 |
-
* @return mixed
|
107 |
-
*/
|
108 |
-
public function column_default($item, $column_name){
|
109 |
-
|
110 |
-
if($column_name
|
111 |
-
|
112 |
-
return $item['option_id'];
|
113 |
-
|
114 |
-
}
|
115 |
-
|
116 |
-
elseif($column_name
|
117 |
-
|
118 |
-
if(is_serialized($item['option_value']) || $item['option_value'] != strip_tags($item['option_value'])){
|
119 |
-
|
120 |
-
return '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(maybe_unserialize($item['option_value']), true) . '</pre>';
|
121 |
-
|
122 |
-
}elseif(acfe_is_json($item['option_value'])){
|
123 |
-
|
124 |
-
return '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(json_decode($item['option_value']), true) . '</pre>';
|
125 |
-
|
126 |
-
}
|
127 |
-
|
128 |
-
|
129 |
-
return $item['option_value'];
|
130 |
-
|
131 |
-
}
|
132 |
-
|
133 |
-
elseif($column_name
|
134 |
-
|
135 |
-
return $item['autoload'];
|
136 |
-
|
137 |
-
}else{
|
138 |
-
|
139 |
-
return print_r($item, true);
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* Render the bulk edit checkbox
|
147 |
-
*
|
148 |
-
* @param array $item
|
149 |
-
*
|
150 |
-
* @return string
|
151 |
-
*/
|
152 |
-
public function column_cb($item){
|
153 |
-
|
154 |
-
return sprintf(
|
155 |
-
'<input type="checkbox" name="bulk-delete[]" value="%s" />', $item['option_id']
|
156 |
-
);
|
157 |
-
|
158 |
-
}
|
159 |
-
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Method for name column
|
163 |
-
*
|
164 |
-
* @param array $item an array of DB data
|
165 |
-
*
|
166 |
-
* @return string
|
167 |
-
*/
|
168 |
-
public function column_option_name($item){
|
169 |
-
|
170 |
-
$delete_nonce = wp_create_nonce('acfe_options_delete_option');
|
171 |
-
|
172 |
-
$title = '<strong>' . $item['option_name'] . '</strong>';
|
173 |
-
|
174 |
-
$actions = array(
|
175 |
-
'edit' => sprintf('<a href="?page=%s&action=edit&option=%s">' . __('Edit') . '</a>', esc_attr($_REQUEST['page']), absint($item['option_id'])),
|
176 |
-
'delete' => sprintf('<a href="?page=%s&action=delete&option=%s&_wpnonce=%s">' . __('Delete') . '</a>', esc_attr($_REQUEST['page']), absint($item['option_id']), $delete_nonce),
|
177 |
-
);
|
178 |
-
|
179 |
-
return $title . $this->row_actions($actions);
|
180 |
-
|
181 |
-
}
|
182 |
-
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Associative array of columns
|
186 |
-
*
|
187 |
-
* @return array
|
188 |
-
*/
|
189 |
-
public function get_columns(){
|
190 |
-
|
191 |
-
$columns = array(
|
192 |
-
'cb' => '<input type="checkbox" />',
|
193 |
-
'option_id' => __('ID', 'acfe'),
|
194 |
-
'option_name' => __('Name', 'acfe'),
|
195 |
-
'option_value' => __('Value', 'acfe'),
|
196 |
-
'autoload' => __('Autoload', 'acfe'),
|
197 |
-
);
|
198 |
-
|
199 |
-
return $columns;
|
200 |
-
|
201 |
-
}
|
202 |
-
|
203 |
-
|
204 |
-
/**
|
205 |
-
* Columns to make sortable.
|
206 |
-
*
|
207 |
-
* @return array
|
208 |
-
*/
|
209 |
-
public function get_sortable_columns(){
|
210 |
-
|
211 |
-
$sortable_columns = array(
|
212 |
-
'option_id' => array('option_id', true),
|
213 |
-
'option_name' => array('option_name', true),
|
214 |
-
'option_value' => array('option_value', true),
|
215 |
-
'autoload' => array('autoload', true),
|
216 |
-
);
|
217 |
-
|
218 |
-
return $sortable_columns;
|
219 |
-
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Returns an associative array containing the bulk action
|
224 |
-
*
|
225 |
-
* @return array
|
226 |
-
*/
|
227 |
-
public function get_bulk_actions(){
|
228 |
-
|
229 |
-
$actions = array(
|
230 |
-
'bulk-delete' => __('Delete')
|
231 |
-
);
|
232 |
-
|
233 |
-
return $actions;
|
234 |
-
|
235 |
-
}
|
236 |
-
|
237 |
-
|
238 |
-
/**
|
239 |
-
* Handles data query and filter, sorting, and pagination.
|
240 |
-
*/
|
241 |
-
public function prepare_items(){
|
242 |
-
|
243 |
-
// Get columns
|
244 |
-
$this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns());
|
245 |
-
|
246 |
-
// Vars
|
247 |
-
$per_page = $this->get_items_per_page('options_per_page', 100);
|
248 |
-
$current_page = $this->get_pagenum();
|
249 |
-
|
250 |
-
// Search
|
251 |
-
$search = (isset( $_REQUEST['s'])) ? $_REQUEST['s'] : false;
|
252 |
-
|
253 |
-
// Get items
|
254 |
-
$this->items = self::get_options($per_page, $current_page, $search);
|
255 |
-
/*
|
256 |
-
foreach($this->items as &$item){
|
257 |
-
$item = json_encode($item);
|
258 |
-
}*/
|
259 |
-
|
260 |
-
// Get total
|
261 |
-
$total_items = self::record_count($search);
|
262 |
-
|
263 |
-
if(!empty($search))
|
264 |
-
$per_page = $total_items;
|
265 |
-
|
266 |
-
$this->set_pagination_args(array(
|
267 |
-
'total_items' => $total_items,
|
268 |
-
'per_page' => $per_page
|
269 |
-
));
|
270 |
-
|
271 |
-
}
|
272 |
-
|
273 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if (!class_exists( 'WP_List_Table'))
|
7 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
8 |
+
|
9 |
+
class ACFE_Admin_Options_List extends WP_List_Table{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Constructor
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
public function __construct(){
|
16 |
+
|
17 |
+
parent::__construct(array(
|
18 |
+
'singular' => __('Option', 'acfe'),
|
19 |
+
'plural' => __('Options', 'acfe'),
|
20 |
+
'ajax' => false
|
21 |
+
));
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Retrieve data from the database
|
28 |
+
*
|
29 |
+
* @param int $per_page
|
30 |
+
* @param int $page_number
|
31 |
+
*
|
32 |
+
* @return mixed
|
33 |
+
*/
|
34 |
+
public static function get_options($per_page = 100, $page_number = 1, $search = ''){
|
35 |
+
|
36 |
+
global $wpdb;
|
37 |
+
|
38 |
+
$sql = "SELECT * FROM {$wpdb->options}";
|
39 |
+
|
40 |
+
if(!empty($search)){
|
41 |
+
|
42 |
+
$sql .= ' WHERE option_name LIKE \'%' . $search . '%\'';
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
if(empty($_REQUEST['orderby'])){
|
47 |
+
|
48 |
+
$sql .= ' ORDER BY option_id ASC';
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
else{
|
53 |
+
|
54 |
+
$sql .= ' ORDER BY ' . esc_sql($_REQUEST['orderby']);
|
55 |
+
$sql .= !empty($_REQUEST['order']) ? ' ' . esc_sql($_REQUEST['order']) : ' ASC';
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
$sql .= " LIMIT $per_page";
|
60 |
+
$sql .= ' OFFSET ' . ($page_number - 1) * $per_page;
|
61 |
+
|
62 |
+
|
63 |
+
$result = $wpdb->get_results($sql, 'ARRAY_A');
|
64 |
+
|
65 |
+
return $result;
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Returns the count of records in the database.
|
72 |
+
*
|
73 |
+
* @return null|string
|
74 |
+
*/
|
75 |
+
public static function record_count($search = ''){
|
76 |
+
|
77 |
+
global $wpdb;
|
78 |
+
|
79 |
+
$sql = "SELECT COUNT(*) FROM {$wpdb->options}";
|
80 |
+
|
81 |
+
if(!empty($search)){
|
82 |
+
|
83 |
+
$sql .= ' WHERE option_name LIKE \'%' . $search . '%\'';
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
return $wpdb->get_var($sql);
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
/** Text displayed when no data is available */
|
93 |
+
public function no_items(){
|
94 |
+
|
95 |
+
_e('No options avaliable.', 'acfe');
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Render a column when no column specific method exist.
|
102 |
+
*
|
103 |
+
* @param array $item
|
104 |
+
* @param string $column_name
|
105 |
+
*
|
106 |
+
* @return mixed
|
107 |
+
*/
|
108 |
+
public function column_default($item, $column_name){
|
109 |
+
|
110 |
+
if($column_name === 'option_id'){
|
111 |
+
|
112 |
+
return $item['option_id'];
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
elseif($column_name === 'option_value'){
|
117 |
+
|
118 |
+
if(is_serialized($item['option_value']) || $item['option_value'] != strip_tags($item['option_value'])){
|
119 |
+
|
120 |
+
return '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(maybe_unserialize($item['option_value']), true) . '</pre>';
|
121 |
+
|
122 |
+
}elseif(acfe_is_json($item['option_value'])){
|
123 |
+
|
124 |
+
return '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(json_decode($item['option_value']), true) . '</pre>';
|
125 |
+
|
126 |
+
}
|
127 |
+
|
128 |
+
|
129 |
+
return $item['option_value'];
|
130 |
+
|
131 |
+
}
|
132 |
+
|
133 |
+
elseif($column_name === 'autoload'){
|
134 |
+
|
135 |
+
return $item['autoload'];
|
136 |
+
|
137 |
+
}else{
|
138 |
+
|
139 |
+
return print_r($item, true);
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Render the bulk edit checkbox
|
147 |
+
*
|
148 |
+
* @param array $item
|
149 |
+
*
|
150 |
+
* @return string
|
151 |
+
*/
|
152 |
+
public function column_cb($item){
|
153 |
+
|
154 |
+
return sprintf(
|
155 |
+
'<input type="checkbox" name="bulk-delete[]" value="%s" />', $item['option_id']
|
156 |
+
);
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Method for name column
|
163 |
+
*
|
164 |
+
* @param array $item an array of DB data
|
165 |
+
*
|
166 |
+
* @return string
|
167 |
+
*/
|
168 |
+
public function column_option_name($item){
|
169 |
+
|
170 |
+
$delete_nonce = wp_create_nonce('acfe_options_delete_option');
|
171 |
+
|
172 |
+
$title = '<strong>' . $item['option_name'] . '</strong>';
|
173 |
+
|
174 |
+
$actions = array(
|
175 |
+
'edit' => sprintf('<a href="?page=%s&action=edit&option=%s">' . __('Edit') . '</a>', esc_attr($_REQUEST['page']), absint($item['option_id'])),
|
176 |
+
'delete' => sprintf('<a href="?page=%s&action=delete&option=%s&_wpnonce=%s">' . __('Delete') . '</a>', esc_attr($_REQUEST['page']), absint($item['option_id']), $delete_nonce),
|
177 |
+
);
|
178 |
+
|
179 |
+
return $title . $this->row_actions($actions);
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Associative array of columns
|
186 |
+
*
|
187 |
+
* @return array
|
188 |
+
*/
|
189 |
+
public function get_columns(){
|
190 |
+
|
191 |
+
$columns = array(
|
192 |
+
'cb' => '<input type="checkbox" />',
|
193 |
+
'option_id' => __('ID', 'acfe'),
|
194 |
+
'option_name' => __('Name', 'acfe'),
|
195 |
+
'option_value' => __('Value', 'acfe'),
|
196 |
+
'autoload' => __('Autoload', 'acfe'),
|
197 |
+
);
|
198 |
+
|
199 |
+
return $columns;
|
200 |
+
|
201 |
+
}
|
202 |
+
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Columns to make sortable.
|
206 |
+
*
|
207 |
+
* @return array
|
208 |
+
*/
|
209 |
+
public function get_sortable_columns(){
|
210 |
+
|
211 |
+
$sortable_columns = array(
|
212 |
+
'option_id' => array('option_id', true),
|
213 |
+
'option_name' => array('option_name', true),
|
214 |
+
'option_value' => array('option_value', true),
|
215 |
+
'autoload' => array('autoload', true),
|
216 |
+
);
|
217 |
+
|
218 |
+
return $sortable_columns;
|
219 |
+
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Returns an associative array containing the bulk action
|
224 |
+
*
|
225 |
+
* @return array
|
226 |
+
*/
|
227 |
+
public function get_bulk_actions(){
|
228 |
+
|
229 |
+
$actions = array(
|
230 |
+
'bulk-delete' => __('Delete')
|
231 |
+
);
|
232 |
+
|
233 |
+
return $actions;
|
234 |
+
|
235 |
+
}
|
236 |
+
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Handles data query and filter, sorting, and pagination.
|
240 |
+
*/
|
241 |
+
public function prepare_items(){
|
242 |
+
|
243 |
+
// Get columns
|
244 |
+
$this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns());
|
245 |
+
|
246 |
+
// Vars
|
247 |
+
$per_page = $this->get_items_per_page('options_per_page', 100);
|
248 |
+
$current_page = $this->get_pagenum();
|
249 |
+
|
250 |
+
// Search
|
251 |
+
$search = (isset( $_REQUEST['s'])) ? $_REQUEST['s'] : false;
|
252 |
+
|
253 |
+
// Get items
|
254 |
+
$this->items = self::get_options($per_page, $current_page, $search);
|
255 |
+
/*
|
256 |
+
foreach($this->items as &$item){
|
257 |
+
$item = json_encode($item);
|
258 |
+
}*/
|
259 |
+
|
260 |
+
// Get total
|
261 |
+
$total_items = self::record_count($search);
|
262 |
+
|
263 |
+
if(!empty($search))
|
264 |
+
$per_page = $total_items;
|
265 |
+
|
266 |
+
$this->set_pagination_args(array(
|
267 |
+
'total_items' => $total_items,
|
268 |
+
'per_page' => $per_page
|
269 |
+
));
|
270 |
+
|
271 |
+
}
|
272 |
+
|
273 |
}
|
includes/admin/options.php
CHANGED
@@ -1,576 +1,579 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
'
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
//
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
// Do Action
|
80 |
-
do_action('acfe/options/load', $action);
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
//
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
// Do Action
|
102 |
-
do_action('acfe/options/html', $action);
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
$
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
//
|
246 |
-
|
247 |
-
|
248 |
-
//
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
'
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
'
|
298 |
-
'
|
299 |
-
'
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
'
|
309 |
-
'
|
310 |
-
'
|
311 |
-
'
|
312 |
-
'
|
313 |
-
'
|
314 |
-
'
|
315 |
-
'
|
316 |
-
'
|
317 |
-
'
|
318 |
-
'
|
319 |
-
'
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
'
|
344 |
-
'
|
345 |
-
'
|
346 |
-
'
|
347 |
-
'
|
348 |
-
'
|
349 |
-
'
|
350 |
-
'
|
351 |
-
'
|
352 |
-
'
|
353 |
-
'
|
354 |
-
'
|
355 |
-
'
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
$
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
'
|
375 |
-
'
|
376 |
-
'
|
377 |
-
'
|
378 |
-
'
|
379 |
-
'
|
380 |
-
'
|
381 |
-
'
|
382 |
-
'
|
383 |
-
'
|
384 |
-
'
|
385 |
-
'
|
386 |
-
'
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
$
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
'
|
407 |
-
'
|
408 |
-
'
|
409 |
-
'
|
410 |
-
'
|
411 |
-
'
|
412 |
-
'
|
413 |
-
'
|
414 |
-
'
|
415 |
-
'
|
416 |
-
'
|
417 |
-
'
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
'
|
431 |
-
'
|
432 |
-
'
|
433 |
-
'
|
434 |
-
'
|
435 |
-
'
|
436 |
-
'
|
437 |
-
'
|
438 |
-
'
|
439 |
-
'
|
440 |
-
'
|
441 |
-
'
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
'
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
$
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
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 |
-
|
511 |
-
|
512 |
-
//
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
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 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
|
|
|
|
|
|
576 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/options', true))
|
8 |
+
return;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Options WP List Table
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
require_once(ACFE_PATH . 'includes/admin/options.class.php');
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Options Menu
|
18 |
+
*
|
19 |
+
*/
|
20 |
+
add_action('admin_menu', 'acfe_options_menu');
|
21 |
+
function acfe_options_menu(){
|
22 |
+
|
23 |
+
$hook = add_submenu_page(
|
24 |
+
'options-general.php',
|
25 |
+
__('Options'),
|
26 |
+
__('Options'),
|
27 |
+
acf_get_setting('capability'),
|
28 |
+
'acfe-options'
|
29 |
+
);
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Options Screen
|
35 |
+
*
|
36 |
+
*/
|
37 |
+
add_filter('set-screen-option', 'acfe_options_screen', 10, 3);
|
38 |
+
function acfe_options_screen($status, $option, $value){
|
39 |
+
|
40 |
+
return $value;
|
41 |
+
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Options Enqueue
|
46 |
+
*
|
47 |
+
*/
|
48 |
+
add_action('admin_print_scripts-settings_page_acfe-options', 'acfe_options_enqueue');
|
49 |
+
function acfe_options_enqueue(){
|
50 |
+
|
51 |
+
wp_enqueue_style('acf-input');
|
52 |
+
wp_enqueue_script('acf-input');
|
53 |
+
wp_enqueue_style('acf-extended', plugins_url('assets/acf-extended.css', ACFE_FILE), false, null);
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Options Load
|
59 |
+
*
|
60 |
+
*/
|
61 |
+
add_action('load-settings_page_acfe-options', 'acfe_options_load');
|
62 |
+
function acfe_options_load(){
|
63 |
+
|
64 |
+
// Messages
|
65 |
+
if(isset($_REQUEST['message']) && !empty($_REQUEST['message']))
|
66 |
+
do_action('acfe/options/load/message=' . $_REQUEST['message']);
|
67 |
+
|
68 |
+
// Default Action
|
69 |
+
$action = 'list';
|
70 |
+
|
71 |
+
// Request Action
|
72 |
+
if(isset($_REQUEST['action']) && !empty($_REQUEST['action']) && $_REQUEST['action'] != '-1')
|
73 |
+
$action = $_REQUEST['action'];
|
74 |
+
|
75 |
+
// Request Action2
|
76 |
+
elseif(isset($_REQUEST['action2']) && !empty($_REQUEST['action2']) && $_REQUEST['action2'] != '-1')
|
77 |
+
$action = $_REQUEST['action2'];
|
78 |
+
|
79 |
+
// Do Action: Specific
|
80 |
+
do_action('acfe/options/load/action=' . $action, $action);
|
81 |
+
|
82 |
+
// Do Action
|
83 |
+
do_action('acfe/options/load', $action);
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Options HTML
|
89 |
+
*
|
90 |
+
*/
|
91 |
+
add_action('settings_page_acfe-options', 'acfe_options_html');
|
92 |
+
function acfe_options_html(){
|
93 |
+
|
94 |
+
// Default Action
|
95 |
+
$action = 'list';
|
96 |
+
|
97 |
+
// Request Action
|
98 |
+
if(isset($_REQUEST['action']) && !empty($_REQUEST['action']) && $_REQUEST['action'] != '-1')
|
99 |
+
$action = $_REQUEST['action'];
|
100 |
+
|
101 |
+
// Do Action: Specific
|
102 |
+
do_action('acfe/options/html/action=' . $action, $action);
|
103 |
+
|
104 |
+
// Do Action
|
105 |
+
do_action('acfe/options/html', $action);
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Options List: Load
|
111 |
+
*
|
112 |
+
*/
|
113 |
+
add_action('acfe/options/load/action=list', 'acfe_options_load_list');
|
114 |
+
function acfe_options_load_list(){
|
115 |
+
|
116 |
+
add_screen_option('per_page', array(
|
117 |
+
'label' => 'Options',
|
118 |
+
'default' => 100,
|
119 |
+
'option' => 'options_per_page'
|
120 |
+
));
|
121 |
+
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Options List: HTML
|
126 |
+
*
|
127 |
+
*/
|
128 |
+
add_filter('acfe/options/html/action=list', 'acfe_options_html_list');
|
129 |
+
function acfe_options_html_list(){
|
130 |
+
|
131 |
+
acf_get_view(ACFE_PATH . '/includes/admin/views/html-options-list.php');
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Options Delete: Load
|
137 |
+
*
|
138 |
+
*/
|
139 |
+
add_action('acfe/options/load/action=delete', 'acfe_options_load_delete');
|
140 |
+
function acfe_options_load_delete(){
|
141 |
+
|
142 |
+
$nonce = esc_attr($_REQUEST['_wpnonce']);
|
143 |
+
|
144 |
+
if(!wp_verify_nonce($nonce, 'acfe_options_delete_option'))
|
145 |
+
wp_die('Cheatin’, huh?');
|
146 |
+
|
147 |
+
acfe_options_delete_option(absint($_GET['option']));
|
148 |
+
|
149 |
+
wp_redirect(sprintf('?page=%s&message=deleted', esc_attr($_REQUEST['page'])));
|
150 |
+
exit;
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Options Delete: Message
|
156 |
+
*
|
157 |
+
*/
|
158 |
+
add_action('acfe/options/load/message=deleted', 'acfe_options_load_delete_message');
|
159 |
+
function acfe_options_load_delete_message(){
|
160 |
+
|
161 |
+
acf_add_admin_notice(__('Option has been deleted'), 'success');
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Options Bulk Delete: Load
|
167 |
+
*
|
168 |
+
*/
|
169 |
+
add_action('acfe/options/load/action=bulk-delete', 'acfe_options_load_bulk_delete');
|
170 |
+
function acfe_options_load_bulk_delete(){
|
171 |
+
|
172 |
+
$nonce = esc_attr($_REQUEST['_wpnonce']);
|
173 |
+
|
174 |
+
if(!wp_verify_nonce($nonce, 'bulk-options'))
|
175 |
+
wp_die('Cheatin’, huh?');
|
176 |
+
|
177 |
+
$delete_ids = esc_sql($_REQUEST['bulk-delete']);
|
178 |
+
|
179 |
+
foreach($delete_ids as $id){
|
180 |
+
|
181 |
+
acfe_options_delete_option($id);
|
182 |
+
|
183 |
+
}
|
184 |
+
|
185 |
+
wp_redirect(sprintf('?page=%s&message=bulk-deleted', esc_attr($_REQUEST['page'])));
|
186 |
+
exit;
|
187 |
+
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Options Bulk Delete: Message
|
192 |
+
*
|
193 |
+
*/
|
194 |
+
add_action('acfe/options/load/message=bulk-deleted', 'acfe_options_load_bulk_delete_message');
|
195 |
+
function acfe_options_load_bulk_delete_message(){
|
196 |
+
|
197 |
+
acf_add_admin_notice(__('Options have been deleted'), 'success');
|
198 |
+
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Options Delete: Function
|
203 |
+
*
|
204 |
+
*/
|
205 |
+
function acfe_options_delete_option($id){
|
206 |
+
|
207 |
+
global $wpdb;
|
208 |
+
|
209 |
+
$wpdb->delete(
|
210 |
+
"{$wpdb->options}",
|
211 |
+
array('option_id' => $id),
|
212 |
+
array('%d')
|
213 |
+
);
|
214 |
+
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Options Edit: Load
|
219 |
+
*
|
220 |
+
*/
|
221 |
+
add_action('acfe/options/load/action=edit', 'acfe_options_load_edit');
|
222 |
+
add_action('acfe/options/load/action=add', 'acfe_options_load_edit');
|
223 |
+
function acfe_options_load_edit($action){
|
224 |
+
|
225 |
+
// Nonce
|
226 |
+
if(acf_verify_nonce('acfe-options-edit')){
|
227 |
+
|
228 |
+
// Save data
|
229 |
+
if(acf_validate_save_post(true)){
|
230 |
+
|
231 |
+
acf_save_post('acfe_options_edit');
|
232 |
+
|
233 |
+
$redirect = add_query_arg(array('message' => 'updated'));
|
234 |
+
|
235 |
+
if($action === 'add')
|
236 |
+
$redirect = sprintf('?page=%s&message=added', esc_attr($_REQUEST['page']));
|
237 |
+
|
238 |
+
wp_redirect($redirect);
|
239 |
+
exit;
|
240 |
+
|
241 |
+
}
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
// Load acf scripts
|
246 |
+
acf_enqueue_scripts();
|
247 |
+
|
248 |
+
// Actions
|
249 |
+
add_action('acf/input/admin_head', 'acfe_options_edit_metabox');
|
250 |
+
|
251 |
+
// Add columns support
|
252 |
+
add_screen_option('layout_columns', array(
|
253 |
+
'max' => 2,
|
254 |
+
'default' => 2
|
255 |
+
));
|
256 |
+
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Options Edit: HTML
|
261 |
+
*
|
262 |
+
*/
|
263 |
+
add_filter('acfe/options/html/action=edit', 'acfe_options_html_edit');
|
264 |
+
add_filter('acfe/options/html/action=add', 'acfe_options_html_edit');
|
265 |
+
function acfe_options_html_edit(){
|
266 |
+
|
267 |
+
acf_get_view(ACFE_PATH . '/includes/admin/views/html-options-edit.php');
|
268 |
+
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Options Edit: Metabox
|
273 |
+
*
|
274 |
+
*/
|
275 |
+
function acfe_options_edit_metabox(){
|
276 |
+
|
277 |
+
$option = array(
|
278 |
+
'option_id' => 0,
|
279 |
+
'option_name' => '',
|
280 |
+
'option_value' => '',
|
281 |
+
'autoload' => 'no',
|
282 |
+
);
|
283 |
+
|
284 |
+
if(isset($_REQUEST['option']) && !empty($_REQUEST['option'])){
|
285 |
+
|
286 |
+
$option_id = absint($_REQUEST['option']);
|
287 |
+
|
288 |
+
global $wpdb;
|
289 |
+
|
290 |
+
$get_option = $wpdb->get_row("SELECT * FROM {$wpdb->options} WHERE option_id = '$option_id'", 'ARRAY_A');
|
291 |
+
if(!empty($get_option))
|
292 |
+
$option = $get_option;
|
293 |
+
|
294 |
+
}
|
295 |
+
|
296 |
+
$field_group = array(
|
297 |
+
'ID' => 0,
|
298 |
+
'key' => 'group_acfe_options_edit',
|
299 |
+
'style' => 'default',
|
300 |
+
'label_placement' => 'left',
|
301 |
+
'instruction_placement' => 'label',
|
302 |
+
'fields' => array()
|
303 |
+
);
|
304 |
+
|
305 |
+
$fields = array();
|
306 |
+
|
307 |
+
$fields[] = array(
|
308 |
+
'label' => __('Name'),
|
309 |
+
'key' => 'field_acfe_options_edit_name',
|
310 |
+
'name' => 'field_acfe_options_edit_name',
|
311 |
+
'type' => 'text',
|
312 |
+
'prefix' => 'acf',
|
313 |
+
'instructions' => '',
|
314 |
+
'required' => true,
|
315 |
+
'conditional_logic' => false,
|
316 |
+
'default_value' => '',
|
317 |
+
'placeholder' => '',
|
318 |
+
'prepend' => '',
|
319 |
+
'append' => '',
|
320 |
+
'maxlength' => '',
|
321 |
+
'value' => $option['option_name'],
|
322 |
+
'wrapper' => array(
|
323 |
+
'width' => '',
|
324 |
+
'class' => '',
|
325 |
+
'id' => '',
|
326 |
+
),
|
327 |
+
);
|
328 |
+
|
329 |
+
// Serialized || HTML
|
330 |
+
if(is_serialized($option['option_value']) || $option['option_value'] != strip_tags($option['option_value'])){
|
331 |
+
|
332 |
+
$type = 'serilized';
|
333 |
+
$instructions = 'Use this <a href="https://duzun.me/playground/serialize" target="_blank">online tool</a> to unserialize/seriliaze data.';
|
334 |
+
|
335 |
+
if($option['option_value'] != strip_tags($option['option_value'])){
|
336 |
+
|
337 |
+
$type = 'HTML';
|
338 |
+
$instructions = '';
|
339 |
+
|
340 |
+
}
|
341 |
+
|
342 |
+
$fields[] = array(
|
343 |
+
'label' => __('Value <code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">' . $type . '</code>'),
|
344 |
+
'key' => 'field_acfe_options_edit_value',
|
345 |
+
'name' => 'field_acfe_options_edit_value',
|
346 |
+
'type' => 'textarea',
|
347 |
+
'prefix' => 'acf',
|
348 |
+
'instructions' => $instructions,
|
349 |
+
'required' => false,
|
350 |
+
'conditional_logic' => false,
|
351 |
+
'default_value' => '',
|
352 |
+
'placeholder' => '',
|
353 |
+
'prepend' => '',
|
354 |
+
'append' => '',
|
355 |
+
'maxlength' => '',
|
356 |
+
'value' => $option['option_value'],
|
357 |
+
'class' => 'code',
|
358 |
+
'wrapper' => array(
|
359 |
+
'width' => '',
|
360 |
+
'class' => '',
|
361 |
+
'id' => '',
|
362 |
+
),
|
363 |
+
);
|
364 |
+
|
365 |
+
}
|
366 |
+
|
367 |
+
// Serialized || HTML
|
368 |
+
elseif(acfe_is_json($option['option_value'])){
|
369 |
+
|
370 |
+
$type = 'json';
|
371 |
+
$instructions = 'Use this <a href="http://solutions.weblite.ca/php2json/" target="_blank">online tool</a> to decode/encode json.';
|
372 |
+
|
373 |
+
$fields[] = array(
|
374 |
+
'label' => __('Value <code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">' . $type . '</code>'),
|
375 |
+
'key' => 'field_acfe_options_edit_value',
|
376 |
+
'name' => 'field_acfe_options_edit_value',
|
377 |
+
'type' => 'textarea',
|
378 |
+
'prefix' => 'acf',
|
379 |
+
'instructions' => $instructions,
|
380 |
+
'required' => false,
|
381 |
+
'conditional_logic' => false,
|
382 |
+
'default_value' => '',
|
383 |
+
'placeholder' => '',
|
384 |
+
'prepend' => '',
|
385 |
+
'append' => '',
|
386 |
+
'maxlength' => '',
|
387 |
+
'value' => $option['option_value'],
|
388 |
+
'class' => 'code',
|
389 |
+
'wrapper' => array(
|
390 |
+
'width' => '',
|
391 |
+
'class' => '',
|
392 |
+
'id' => '',
|
393 |
+
),
|
394 |
+
);
|
395 |
+
|
396 |
+
}
|
397 |
+
|
398 |
+
// String
|
399 |
+
else{
|
400 |
+
|
401 |
+
$type = '';
|
402 |
+
if(!empty($option['option_value']))
|
403 |
+
$type = '<code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">string</code>';
|
404 |
+
|
405 |
+
$fields[] = array(
|
406 |
+
'label' => __('Value ' . $type),
|
407 |
+
'key' => 'field_acfe_options_edit_value',
|
408 |
+
'name' => 'field_acfe_options_edit_value',
|
409 |
+
'type' => 'text',
|
410 |
+
'prefix' => 'acf',
|
411 |
+
'instructions' => '',
|
412 |
+
'required' => false,
|
413 |
+
'conditional_logic' => false,
|
414 |
+
'default_value' => '',
|
415 |
+
'placeholder' => '',
|
416 |
+
'prepend' => '',
|
417 |
+
'append' => '',
|
418 |
+
'maxlength' => '',
|
419 |
+
'value' => $option['option_value'],
|
420 |
+
'wrapper' => array(
|
421 |
+
'width' => '',
|
422 |
+
'class' => '',
|
423 |
+
'id' => '',
|
424 |
+
),
|
425 |
+
);
|
426 |
+
|
427 |
+
}
|
428 |
+
|
429 |
+
$fields[] = array(
|
430 |
+
'label' => __('Autoload'),
|
431 |
+
'key' => 'field_acfe_options_edit_autoload',
|
432 |
+
'name' => 'field_acfe_options_edit_autoload',
|
433 |
+
'type' => 'select',
|
434 |
+
'prefix' => 'acf',
|
435 |
+
'instructions' => '',
|
436 |
+
'required' => true,
|
437 |
+
'conditional_logic' => false,
|
438 |
+
'default_value' => '',
|
439 |
+
'placeholder' => '',
|
440 |
+
'prepend' => '',
|
441 |
+
'append' => '',
|
442 |
+
'maxlength' => '',
|
443 |
+
'value' => $option['autoload'],
|
444 |
+
'choices' => array(
|
445 |
+
'no' => __('No'),
|
446 |
+
'yes' => __('Yes'),
|
447 |
+
),
|
448 |
+
'wrapper' => array(
|
449 |
+
'width' => '',
|
450 |
+
'class' => '',
|
451 |
+
'id' => '',
|
452 |
+
),
|
453 |
+
);
|
454 |
+
|
455 |
+
$field_group['fields'] = $fields;
|
456 |
+
|
457 |
+
$metabox_submit_title = __('Submit','acf');
|
458 |
+
$metabox_main_title = __('Add Option');
|
459 |
+
|
460 |
+
if(!empty($option['option_id'])){
|
461 |
+
|
462 |
+
$metabox_submit_title = __('Edit','acf');
|
463 |
+
$metabox_main_title = __('Edit Option');
|
464 |
+
|
465 |
+
}
|
466 |
+
|
467 |
+
// Submit Metabox
|
468 |
+
add_meta_box('submitdiv', $metabox_submit_title, function($post, $args) use($option){
|
469 |
+
|
470 |
+
$delete_nonce = wp_create_nonce('acfe_options_delete_option');
|
471 |
+
|
472 |
+
?>
|
473 |
+
<div id="major-publishing-actions">
|
474 |
+
|
475 |
+
<?php if(!empty($option['option_id'])){ ?>
|
476 |
+
|
477 |
+
<div id="delete-action">
|
478 |
+
<a class="submitdelete deletion" style="color:#a00;" href="<?php echo sprintf('?page=%s&action=%s&option=%s&_wpnonce=%s', esc_attr($_REQUEST['page']), 'delete', $option['option_id'], $delete_nonce); ?>"><?php _e('Delete'); ?></a>
|
479 |
+
</div>
|
480 |
+
|
481 |
+
<?php } ?>
|
482 |
+
|
483 |
+
<div id="publishing-action">
|
484 |
+
<span class="spinner"></span>
|
485 |
+
<input type="submit" accesskey="p" value="<?php _e('Update'); ?>" class="button button-primary button-large" id="publish" name="publish">
|
486 |
+
</div>
|
487 |
+
|
488 |
+
<div class="clear"></div>
|
489 |
+
|
490 |
+
</div>
|
491 |
+
<?php
|
492 |
+
}, 'acf_options_page', 'side', 'high');
|
493 |
+
|
494 |
+
// Main Metabox
|
495 |
+
add_meta_box('acf-group_acfe_options_edit', $metabox_main_title, function($post, $args){
|
496 |
+
|
497 |
+
// extract args
|
498 |
+
extract($args); // all variables from the add_meta_box function
|
499 |
+
extract($args); // all variables from the args argument
|
500 |
+
|
501 |
+
// vars
|
502 |
+
$o = array(
|
503 |
+
'id' => $id,
|
504 |
+
'key' => $field_group['key'],
|
505 |
+
'style' => $field_group['style'],
|
506 |
+
'label' => $field_group['label_placement'],
|
507 |
+
'editLink' => '',
|
508 |
+
'editTitle' => __('Edit field group', 'acf'),
|
509 |
+
'visibility' => true
|
510 |
+
);
|
511 |
+
|
512 |
+
// load fields
|
513 |
+
$fields = $field_group['fields'];
|
514 |
+
|
515 |
+
// render
|
516 |
+
acf_render_fields($fields, 'acfe-options-edit', 'div', $field_group['instruction_placement']);
|
517 |
+
|
518 |
+
?>
|
519 |
+
<script type="text/javascript">
|
520 |
+
if(typeof acf !== 'undefined'){
|
521 |
+
|
522 |
+
acf.newPostbox(<?php echo json_encode($o); ?>);
|
523 |
+
|
524 |
+
}
|
525 |
+
</script>
|
526 |
+
<?php
|
527 |
+
|
528 |
+
}, 'acf_options_page', 'normal', 'high', array('field_group' => $field_group));
|
529 |
+
|
530 |
+
}
|
531 |
+
|
532 |
+
/**
|
533 |
+
* Options Edit: Save
|
534 |
+
*
|
535 |
+
*/
|
536 |
+
add_action('acf/save_post', 'acfe_options_edit_save_post', 5);
|
537 |
+
function acfe_options_edit_save_post($post_id){
|
538 |
+
|
539 |
+
// Validate
|
540 |
+
if(!in_array($post_id, array('acfe_options_edit')))
|
541 |
+
return;
|
542 |
+
|
543 |
+
// Vars
|
544 |
+
$option_name = wp_unslash($_POST['acf']['field_acfe_options_edit_name']);
|
545 |
+
$option_value = wp_unslash($_POST['acf']['field_acfe_options_edit_value']);
|
546 |
+
$autoload = $_POST['acf']['field_acfe_options_edit_autoload'];
|
547 |
+
|
548 |
+
// Value serialized?
|
549 |
+
$option_value = maybe_unserialize($option_value);
|
550 |
+
|
551 |
+
// Update
|
552 |
+
update_option($option_name, $option_value, $autoload);
|
553 |
+
|
554 |
+
// Flush ACF
|
555 |
+
$_POST['acf'] = array();
|
556 |
+
|
557 |
+
}
|
558 |
+
|
559 |
+
/**
|
560 |
+
* Options Edit: Message
|
561 |
+
*
|
562 |
+
*/
|
563 |
+
add_action('acfe/options/load/message=updated', 'acfe_options_load_edit_message');
|
564 |
+
function acfe_options_load_edit_message(){
|
565 |
+
|
566 |
+
acf_add_admin_notice(__('Option has been updated'), 'success');
|
567 |
+
|
568 |
+
}
|
569 |
+
|
570 |
+
/**
|
571 |
+
* Options Add: Message
|
572 |
+
*
|
573 |
+
*/
|
574 |
+
add_action('acfe/options/load/message=added', 'acfe_options_load_add_message');
|
575 |
+
function acfe_options_load_add_message(){
|
576 |
+
|
577 |
+
acf_add_admin_notice(__('Option has been added'), 'success');
|
578 |
+
|
579 |
}
|
includes/admin/plugins.php
CHANGED
@@ -1,42 +1,42 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Admin: Plugins Tab
|
8 |
-
*/
|
9 |
-
add_filter('install_plugins_tabs', 'acfe_admin_plugins_tabs');
|
10 |
-
function acfe_admin_plugins_tabs($tabs){
|
11 |
-
|
12 |
-
$tabs['acf'] = __('Advanced Custom Fields');
|
13 |
-
|
14 |
-
return $tabs;
|
15 |
-
|
16 |
-
}
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Admin: Plugins Args
|
20 |
-
*/
|
21 |
-
add_filter('install_plugins_table_api_args_acf', 'acfe_admin_plugins_args');
|
22 |
-
function acfe_admin_plugins_args($args){
|
23 |
-
|
24 |
-
global $paged;
|
25 |
-
|
26 |
-
$args['search'] = 'acf';
|
27 |
-
$args['page'] = $paged;
|
28 |
-
$args['per_page'] = 12;
|
29 |
-
|
30 |
-
return $args;
|
31 |
-
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Admin: Plugins HTML
|
36 |
-
*/
|
37 |
-
add_action('install_plugins_acf', 'acfe_admin_plugins_html');
|
38 |
-
function acfe_admin_plugins_html(){
|
39 |
-
|
40 |
-
display_plugins_table();
|
41 |
-
|
42 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Admin: Plugins Tab
|
8 |
+
*/
|
9 |
+
add_filter('install_plugins_tabs', 'acfe_admin_plugins_tabs');
|
10 |
+
function acfe_admin_plugins_tabs($tabs){
|
11 |
+
|
12 |
+
$tabs['acf'] = __('Advanced Custom Fields');
|
13 |
+
|
14 |
+
return $tabs;
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Admin: Plugins Args
|
20 |
+
*/
|
21 |
+
add_filter('install_plugins_table_api_args_acf', 'acfe_admin_plugins_args');
|
22 |
+
function acfe_admin_plugins_args($args){
|
23 |
+
|
24 |
+
global $paged;
|
25 |
+
|
26 |
+
$args['search'] = 'acf';
|
27 |
+
$args['page'] = $paged;
|
28 |
+
$args['per_page'] = 12;
|
29 |
+
|
30 |
+
return $args;
|
31 |
+
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Admin: Plugins HTML
|
36 |
+
*/
|
37 |
+
add_action('install_plugins_acf', 'acfe_admin_plugins_html');
|
38 |
+
function acfe_admin_plugins_html(){
|
39 |
+
|
40 |
+
display_plugins_table();
|
41 |
+
|
42 |
}
|
includes/admin/settings.php
CHANGED
@@ -1,238 +1,238 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
add_action('admin_menu', 'acfe_admin_settings_menu');
|
7 |
-
function acfe_admin_settings_menu(){
|
8 |
-
|
9 |
-
if(!acf_get_setting('show_admin'))
|
10 |
-
return;
|
11 |
-
|
12 |
-
$submenu_page = add_submenu_page('edit.php?post_type=acf-field-group', __('Settings'), __('Settings'), acf_get_setting('capability'), 'acfe-settings', 'acfe_admin_settings_html');
|
13 |
-
|
14 |
-
add_action('admin_print_scripts-' . $submenu_page, function(){
|
15 |
-
wp_enqueue_style('acf-input');
|
16 |
-
wp_enqueue_script('acf-input');
|
17 |
-
});
|
18 |
-
|
19 |
-
}
|
20 |
-
|
21 |
-
function acfe_admin_settings_html(){
|
22 |
-
?>
|
23 |
-
<div class="wrap" id="acfe-admin-settings">
|
24 |
-
|
25 |
-
<h1><?php _e('Settings'); ?></h1>
|
26 |
-
|
27 |
-
<div id="poststuff">
|
28 |
-
<?php
|
29 |
-
|
30 |
-
$load_json = acf_get_setting('load_json');
|
31 |
-
$load_json_text = '';
|
32 |
-
if(!empty($load_json))
|
33 |
-
$load_json_text = implode("<br />", $load_json);
|
34 |
-
|
35 |
-
$settings = array(
|
36 |
-
array(
|
37 |
-
'name' => 'path',
|
38 |
-
'label' => 'Path',
|
39 |
-
'value' => '<code>' . acf_get_setting('path') . '</code>',
|
40 |
-
'description' => 'Absolute path to ACF plugin folder including trailing slash.<br />Defaults to plugin_dir_path'
|
41 |
-
),
|
42 |
-
array(
|
43 |
-
'name' => 'dir',
|
44 |
-
'label' => 'Directory',
|
45 |
-
'value' => '<code>' . acf_get_setting('dir') . '</code>',
|
46 |
-
'description' => 'URL to ACF plugin folder including trailing slash. Defaults to plugin_dir_url'
|
47 |
-
),
|
48 |
-
array(
|
49 |
-
'name' => 'show_admin',
|
50 |
-
'label' => 'Show menu',
|
51 |
-
'value' => '<code>' . (acf_get_setting('show_admin') ? __('True'): __('False')) . '</code>',
|
52 |
-
'description' => 'Show/hide ACF menu item. Defaults to true'
|
53 |
-
),
|
54 |
-
array(
|
55 |
-
'name' => 'stripslashes',
|
56 |
-
'label' => 'Strip slashes',
|
57 |
-
'value' => '<code>' . (acf_get_setting('stripslashes') ? __('True'): __('False')) . '</code>',
|
58 |
-
'description' => 'Runs the function stripslashes on all $_POST data. Some servers / WP instals may require this extra functioanlity. Defaults to false'
|
59 |
-
),
|
60 |
-
array(
|
61 |
-
'name' => 'local',
|
62 |
-
'label' => 'PHP/Json',
|
63 |
-
'value' => '<code>' . (acf_get_setting('local') ? __('True'): __('False')) . '</code>',
|
64 |
-
'description' => 'Enable/Disable local (PHP/json) fields. Defaults to true'
|
65 |
-
),
|
66 |
-
array(
|
67 |
-
'name' => 'json',
|
68 |
-
'label' => 'Json',
|
69 |
-
'value' => '<code>' . (acf_get_setting('json') ? __('True'): __('False')) . '</code>',
|
70 |
-
'description' => 'Enable/Disable json fields. Defaults to true'
|
71 |
-
),
|
72 |
-
array(
|
73 |
-
'name' => 'save_json',
|
74 |
-
'label' => 'Json folder (save)',
|
75 |
-
'value' => '<code>' . acf_get_setting('dir') . '</code>',
|
76 |
-
'description' => 'Absolute path to folder where json files will be created when field groups are saved.<br />Defaults to ‘acf-json’ folder within current theme'
|
77 |
-
),
|
78 |
-
array(
|
79 |
-
'name' => 'load_json',
|
80 |
-
'label' => 'Json folder (load)',
|
81 |
-
'value' => '<code>' . $load_json_text . '</code>',
|
82 |
-
'description' => 'Array of absolutes paths to folders where field group json files can be read.<br />Defaults to an array containing at index 0, the ‘acf-json’ folder within current theme'
|
83 |
-
),
|
84 |
-
array(
|
85 |
-
'name' => 'default_language',
|
86 |
-
'label' => 'Default language',
|
87 |
-
'value' => '<code>' . acf_get_setting('default_language') . '</code>',
|
88 |
-
'description' => 'Language code of the default language. Defaults to ”.<br />If WPML is active, ACF will default this to the WPML default language setting'
|
89 |
-
),
|
90 |
-
array(
|
91 |
-
'name' => 'current_language',
|
92 |
-
'label' => 'Current language',
|
93 |
-
'value' => '<code>' . acf_get_setting('current_language') . '</code>',
|
94 |
-
'description' => 'Language code of the current post’s language. Defaults to ”.<br />If WPML is active, ACF will default this to the WPML current language'
|
95 |
-
),
|
96 |
-
array(
|
97 |
-
'name' => 'capability',
|
98 |
-
'label' => 'Capability',
|
99 |
-
'value' => '<code>' . acf_get_setting('capability') . '</code>',
|
100 |
-
'description' => 'Capability used for ACF post types and if the current user can see the ACF menu item.<br />Defaults to ‘manage_options’.'
|
101 |
-
),
|
102 |
-
array(
|
103 |
-
'name' => 'show_updates',
|
104 |
-
'label' => 'Show updates',
|
105 |
-
'value' => '<code>' . (acf_get_setting('show_updates') ? __('True'): __('False')) . '</code>',
|
106 |
-
'description' => 'Enable/Disable updates to appear in plugin list and show/hide the ACF updates admin page.<br />Defaults to true.'
|
107 |
-
),
|
108 |
-
array(
|
109 |
-
'name' => 'export_textdomain',
|
110 |
-
'label' => 'Export textdomain',
|
111 |
-
'value' => '<code>' . (acf_get_setting('export_textdomain') ? __('True'): __('False')) . '</code>',
|
112 |
-
'description' => 'Array of keys used during the ‘Export to PHP’ feature to wrap strings within the __() function.<br />Defaults to array(’title’, ’label’, ’instructions’). Depreciated in v5.3.4 – please see l10n_field and l10n_field_group'
|
113 |
-
),
|
114 |
-
array(
|
115 |
-
'name' => 'export_translate',
|
116 |
-
'label' => 'Export translate',
|
117 |
-
'value' => '<code>' . print_r(acf_get_setting('export_translate'), true) . '</code>',
|
118 |
-
'description' => 'Used during the ‘Export to PHP’ feature to wrap strings within the __() function.<br />Depreciated in v5.4.4 – please see l10n_textdomain'
|
119 |
-
),
|
120 |
-
array(
|
121 |
-
'name' => 'autoload',
|
122 |
-
'label' => 'Auto load',
|
123 |
-
'value' => '<code>' . (acf_get_setting('autoload') ? __('True'): __('False')) . '</code>',
|
124 |
-
'description' => 'Sets the text domain used when translating field and field group settings.<br />Defaults to ”. Strings will not be translated if this setting is empty'
|
125 |
-
),
|
126 |
-
array(
|
127 |
-
'name' => 'l10n',
|
128 |
-
'label' => 'l10n',
|
129 |
-
'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>',
|
130 |
-
'description' => 'Allows ACF to translate field and field group settings using the __() function.<br />Defaults to true. Useful to override translation without modifying the textdomain'
|
131 |
-
),
|
132 |
-
array(
|
133 |
-
'name' => 'l10n_textdomain',
|
134 |
-
'label' => 'l10n Textdomain',
|
135 |
-
'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>',
|
136 |
-
'description' => 'Sets the text domain used when translating field and field group settings.<br />Defaults to ”. Strings will not be translated if this setting is empty'
|
137 |
-
),
|
138 |
-
array(
|
139 |
-
'name' => 'l10n_field',
|
140 |
-
'label' => 'l10n Field',
|
141 |
-
'value' => '<code>' . print_r(acf_get_setting('l10n_field'), true) . '</code>',
|
142 |
-
'description' => 'An array of settings to translate when loading and exporting a field.<br />Defaults to array(’label’, ’instructions’). Depreciated in v5.3.6 – please see acf/translate_field filter'
|
143 |
-
),
|
144 |
-
array(
|
145 |
-
'name' => 'l10n_field_group',
|
146 |
-
'label' => 'l10n Field group',
|
147 |
-
'value' => '<code>' . print_r(acf_get_setting('l10n_field_group'), true) . '</code>',
|
148 |
-
'description' => 'An array of settings to translate when loading and exporting a field group.<br />Defaults to array(’title’). Depreciated in v5.3.6 – please see acf/translate_field_group filter'
|
149 |
-
),
|
150 |
-
array(
|
151 |
-
'name' => 'google_api_key',
|
152 |
-
'label' => 'Google API Key',
|
153 |
-
'value' => '<code>' . acf_get_setting('google_api_key') . '</code>',
|
154 |
-
'description' => 'Specify a Google Maps API authentication key to prevent usage limits.<br />Defaults to ”'
|
155 |
-
),
|
156 |
-
array(
|
157 |
-
'name' => 'google_api_client',
|
158 |
-
'label' => 'Google API Key',
|
159 |
-
'value' => '<code>' . acf_get_setting('google_api_client') . '</code>',
|
160 |
-
'description' => 'Specify a Google Maps API Client ID to prevent usage limits.<br />Not needed if using google_api_key. Defaults to ”'
|
161 |
-
),
|
162 |
-
array(
|
163 |
-
'name' => 'enqueue_google_maps',
|
164 |
-
'label' => 'Enqueue Google Maps',
|
165 |
-
'value' => '<code>' . (acf_get_setting('enqueue_google_maps') ? __('True'): __('False')) . '</code>',
|
166 |
-
'description' => 'Allows ACF to enqueue and load the Google Maps API JS library.<br />Defaults to true'
|
167 |
-
),
|
168 |
-
array(
|
169 |
-
'name' => 'enqueue_select2',
|
170 |
-
'label' => 'Enqueue Select2',
|
171 |
-
'value' => '<code>' . (acf_get_setting('enqueue_select2') ? __('True'): __('False')) . '</code>',
|
172 |
-
'description' => 'Allows ACF to enqueue and load the Select2 JS/CSS library.<br />Defaults to true'
|
173 |
-
),
|
174 |
-
array(
|
175 |
-
'name' => 'select2_version',
|
176 |
-
'label' => 'Select2 version',
|
177 |
-
'value' => '<code>' . acf_get_setting('select2_version') . '</code>',
|
178 |
-
'description' => 'Defines which version of Select2 library to enqueue. Either 3 or 4.<br />Defaults to 4 since ACF 5.6.0'
|
179 |
-
),
|
180 |
-
array(
|
181 |
-
'name' => 'enqueue_datepicker',
|
182 |
-
'label' => 'Enqueue Datepicker',
|
183 |
-
'value' => '<code>' . (acf_get_setting('enqueue_datepicker') ? __('True'): __('False')) . '</code>',
|
184 |
-
'description' => 'Allows ACF to enqueue and load the WP datepicker JS/CSS library.<br />Defaults to true'
|
185 |
-
),
|
186 |
-
array(
|
187 |
-
'name' => 'enqueue_datetimepicker',
|
188 |
-
'label' => 'Enqueue Datepiker/time',
|
189 |
-
'value' => '<code>' . (acf_get_setting('enqueue_datetimepicker') ? __('True'): __('False')) . '</code>',
|
190 |
-
'description' => 'Allows ACF to enqueue and load the datetimepicker JS/CSS library.<br />Defaults to true'
|
191 |
-
),
|
192 |
-
array(
|
193 |
-
'name' => 'row_index_offset',
|
194 |
-
'label' => 'Row index offset',
|
195 |
-
'value' => '<code>' . acf_get_setting('row_index_offset') . '</code>',
|
196 |
-
'description' => 'Defines the starting index used in all ‘loop’ and ‘row’ functions.<br />Defaults to 1 (1 is the first row), can be changed to 0 (0 is the first row)'
|
197 |
-
),
|
198 |
-
array(
|
199 |
-
'name' => 'remove_wp_meta_box',
|
200 |
-
'label' => 'Remove WP meta box',
|
201 |
-
'value' => '<code>' . (acf_get_setting('remove_wp_meta_box') ? __('True'): __('False')) . '</code>',
|
202 |
-
'description' => 'Allows ACF to remove the default WP custom fields metabox. Defaults to true'
|
203 |
-
),
|
204 |
-
);
|
205 |
-
|
206 |
-
?>
|
207 |
-
<div class="postbox acf-postbox">
|
208 |
-
<h2 class="hndle ui-sortable-handle"><span><?php _e('ACF Settings'); ?></span></h2>
|
209 |
-
<div class="inside acf-fields -left">
|
210 |
-
|
211 |
-
<?php foreach($settings as $setting){ ?>
|
212 |
-
<div class="acf-field">
|
213 |
-
<div class="acf-label">
|
214 |
-
<label><span class="acf-js-tooltip dashicons dashicons-info" style="float:right; font-size:16px; color:#ccc;" title="<?php echo $setting['description']; ?>"></span><?php echo $setting['label']; ?></label>
|
215 |
-
</div>
|
216 |
-
<div class="acf-input">
|
217 |
-
<?php echo $setting['value']; ?>
|
218 |
-
</div>
|
219 |
-
</div>
|
220 |
-
<?php } ?>
|
221 |
-
|
222 |
-
<script type="text/javascript">
|
223 |
-
if( typeof acf !== 'undefined' ) {
|
224 |
-
|
225 |
-
acf.newPostbox({
|
226 |
-
'id': 'acfe-settings',
|
227 |
-
'label': 'left'
|
228 |
-
});
|
229 |
-
|
230 |
-
}
|
231 |
-
</script>
|
232 |
-
</div>
|
233 |
-
</div>
|
234 |
-
</div>
|
235 |
-
|
236 |
-
</div>
|
237 |
-
<?php
|
238 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
add_action('admin_menu', 'acfe_admin_settings_menu');
|
7 |
+
function acfe_admin_settings_menu(){
|
8 |
+
|
9 |
+
if(!acf_get_setting('show_admin'))
|
10 |
+
return;
|
11 |
+
|
12 |
+
$submenu_page = add_submenu_page('edit.php?post_type=acf-field-group', __('Settings'), __('Settings'), acf_get_setting('capability'), 'acfe-settings', 'acfe_admin_settings_html');
|
13 |
+
|
14 |
+
add_action('admin_print_scripts-' . $submenu_page, function(){
|
15 |
+
wp_enqueue_style('acf-input');
|
16 |
+
wp_enqueue_script('acf-input');
|
17 |
+
});
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
function acfe_admin_settings_html(){
|
22 |
+
?>
|
23 |
+
<div class="wrap" id="acfe-admin-settings">
|
24 |
+
|
25 |
+
<h1><?php _e('Settings'); ?></h1>
|
26 |
+
|
27 |
+
<div id="poststuff">
|
28 |
+
<?php
|
29 |
+
|
30 |
+
$load_json = acf_get_setting('load_json');
|
31 |
+
$load_json_text = '';
|
32 |
+
if(!empty($load_json))
|
33 |
+
$load_json_text = implode("<br />", $load_json);
|
34 |
+
|
35 |
+
$settings = array(
|
36 |
+
array(
|
37 |
+
'name' => 'path',
|
38 |
+
'label' => 'Path',
|
39 |
+
'value' => '<code>' . acf_get_setting('path') . '</code>',
|
40 |
+
'description' => 'Absolute path to ACF plugin folder including trailing slash.<br />Defaults to plugin_dir_path'
|
41 |
+
),
|
42 |
+
array(
|
43 |
+
'name' => 'dir',
|
44 |
+
'label' => 'Directory',
|
45 |
+
'value' => '<code>' . acf_get_setting('dir') . '</code>',
|
46 |
+
'description' => 'URL to ACF plugin folder including trailing slash. Defaults to plugin_dir_url'
|
47 |
+
),
|
48 |
+
array(
|
49 |
+
'name' => 'show_admin',
|
50 |
+
'label' => 'Show menu',
|
51 |
+
'value' => '<code>' . (acf_get_setting('show_admin') ? __('True'): __('False')) . '</code>',
|
52 |
+
'description' => 'Show/hide ACF menu item. Defaults to true'
|
53 |
+
),
|
54 |
+
array(
|
55 |
+
'name' => 'stripslashes',
|
56 |
+
'label' => 'Strip slashes',
|
57 |
+
'value' => '<code>' . (acf_get_setting('stripslashes') ? __('True'): __('False')) . '</code>',
|
58 |
+
'description' => 'Runs the function stripslashes on all $_POST data. Some servers / WP instals may require this extra functioanlity. Defaults to false'
|
59 |
+
),
|
60 |
+
array(
|
61 |
+
'name' => 'local',
|
62 |
+
'label' => 'PHP/Json',
|
63 |
+
'value' => '<code>' . (acf_get_setting('local') ? __('True'): __('False')) . '</code>',
|
64 |
+
'description' => 'Enable/Disable local (PHP/json) fields. Defaults to true'
|
65 |
+
),
|
66 |
+
array(
|
67 |
+
'name' => 'json',
|
68 |
+
'label' => 'Json',
|
69 |
+
'value' => '<code>' . (acf_get_setting('json') ? __('True'): __('False')) . '</code>',
|
70 |
+
'description' => 'Enable/Disable json fields. Defaults to true'
|
71 |
+
),
|
72 |
+
array(
|
73 |
+
'name' => 'save_json',
|
74 |
+
'label' => 'Json folder (save)',
|
75 |
+
'value' => '<code>' . acf_get_setting('dir') . '</code>',
|
76 |
+
'description' => 'Absolute path to folder where json files will be created when field groups are saved.<br />Defaults to ‘acf-json’ folder within current theme'
|
77 |
+
),
|
78 |
+
array(
|
79 |
+
'name' => 'load_json',
|
80 |
+
'label' => 'Json folder (load)',
|
81 |
+
'value' => '<code>' . $load_json_text . '</code>',
|
82 |
+
'description' => 'Array of absolutes paths to folders where field group json files can be read.<br />Defaults to an array containing at index 0, the ‘acf-json’ folder within current theme'
|
83 |
+
),
|
84 |
+
array(
|
85 |
+
'name' => 'default_language',
|
86 |
+
'label' => 'Default language',
|
87 |
+
'value' => '<code>' . acf_get_setting('default_language') . '</code>',
|
88 |
+
'description' => 'Language code of the default language. Defaults to ”.<br />If WPML is active, ACF will default this to the WPML default language setting'
|
89 |
+
),
|
90 |
+
array(
|
91 |
+
'name' => 'current_language',
|
92 |
+
'label' => 'Current language',
|
93 |
+
'value' => '<code>' . acf_get_setting('current_language') . '</code>',
|
94 |
+
'description' => 'Language code of the current post’s language. Defaults to ”.<br />If WPML is active, ACF will default this to the WPML current language'
|
95 |
+
),
|
96 |
+
array(
|
97 |
+
'name' => 'capability',
|
98 |
+
'label' => 'Capability',
|
99 |
+
'value' => '<code>' . acf_get_setting('capability') . '</code>',
|
100 |
+
'description' => 'Capability used for ACF post types and if the current user can see the ACF menu item.<br />Defaults to ‘manage_options’.'
|
101 |
+
),
|
102 |
+
array(
|
103 |
+
'name' => 'show_updates',
|
104 |
+
'label' => 'Show updates',
|
105 |
+
'value' => '<code>' . (acf_get_setting('show_updates') ? __('True'): __('False')) . '</code>',
|
106 |
+
'description' => 'Enable/Disable updates to appear in plugin list and show/hide the ACF updates admin page.<br />Defaults to true.'
|
107 |
+
),
|
108 |
+
array(
|
109 |
+
'name' => 'export_textdomain',
|
110 |
+
'label' => 'Export textdomain',
|
111 |
+
'value' => '<code>' . (acf_get_setting('export_textdomain') ? __('True'): __('False')) . '</code>',
|
112 |
+
'description' => 'Array of keys used during the ‘Export to PHP’ feature to wrap strings within the __() function.<br />Defaults to array(’title’, ’label’, ’instructions’). Depreciated in v5.3.4 – please see l10n_field and l10n_field_group'
|
113 |
+
),
|
114 |
+
array(
|
115 |
+
'name' => 'export_translate',
|
116 |
+
'label' => 'Export translate',
|
117 |
+
'value' => '<code>' . print_r(acf_get_setting('export_translate'), true) . '</code>',
|
118 |
+
'description' => 'Used during the ‘Export to PHP’ feature to wrap strings within the __() function.<br />Depreciated in v5.4.4 – please see l10n_textdomain'
|
119 |
+
),
|
120 |
+
array(
|
121 |
+
'name' => 'autoload',
|
122 |
+
'label' => 'Auto load',
|
123 |
+
'value' => '<code>' . (acf_get_setting('autoload') ? __('True'): __('False')) . '</code>',
|
124 |
+
'description' => 'Sets the text domain used when translating field and field group settings.<br />Defaults to ”. Strings will not be translated if this setting is empty'
|
125 |
+
),
|
126 |
+
array(
|
127 |
+
'name' => 'l10n',
|
128 |
+
'label' => 'l10n',
|
129 |
+
'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>',
|
130 |
+
'description' => 'Allows ACF to translate field and field group settings using the __() function.<br />Defaults to true. Useful to override translation without modifying the textdomain'
|
131 |
+
),
|
132 |
+
array(
|
133 |
+
'name' => 'l10n_textdomain',
|
134 |
+
'label' => 'l10n Textdomain',
|
135 |
+
'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>',
|
136 |
+
'description' => 'Sets the text domain used when translating field and field group settings.<br />Defaults to ”. Strings will not be translated if this setting is empty'
|
137 |
+
),
|
138 |
+
array(
|
139 |
+
'name' => 'l10n_field',
|
140 |
+
'label' => 'l10n Field',
|
141 |
+
'value' => '<code>' . print_r(acf_get_setting('l10n_field'), true) . '</code>',
|
142 |
+
'description' => 'An array of settings to translate when loading and exporting a field.<br />Defaults to array(’label’, ’instructions’). Depreciated in v5.3.6 – please see acf/translate_field filter'
|
143 |
+
),
|
144 |
+
array(
|
145 |
+
'name' => 'l10n_field_group',
|
146 |
+
'label' => 'l10n Field group',
|
147 |
+
'value' => '<code>' . print_r(acf_get_setting('l10n_field_group'), true) . '</code>',
|
148 |
+
'description' => 'An array of settings to translate when loading and exporting a field group.<br />Defaults to array(’title’). Depreciated in v5.3.6 – please see acf/translate_field_group filter'
|
149 |
+
),
|
150 |
+
array(
|
151 |
+
'name' => 'google_api_key',
|
152 |
+
'label' => 'Google API Key',
|
153 |
+
'value' => '<code>' . acf_get_setting('google_api_key') . '</code>',
|
154 |
+
'description' => 'Specify a Google Maps API authentication key to prevent usage limits.<br />Defaults to ”'
|
155 |
+
),
|
156 |
+
array(
|
157 |
+
'name' => 'google_api_client',
|
158 |
+
'label' => 'Google API Key',
|
159 |
+
'value' => '<code>' . acf_get_setting('google_api_client') . '</code>',
|
160 |
+
'description' => 'Specify a Google Maps API Client ID to prevent usage limits.<br />Not needed if using google_api_key. Defaults to ”'
|
161 |
+
),
|
162 |
+
array(
|
163 |
+
'name' => 'enqueue_google_maps',
|
164 |
+
'label' => 'Enqueue Google Maps',
|
165 |
+
'value' => '<code>' . (acf_get_setting('enqueue_google_maps') ? __('True'): __('False')) . '</code>',
|
166 |
+
'description' => 'Allows ACF to enqueue and load the Google Maps API JS library.<br />Defaults to true'
|
167 |
+
),
|
168 |
+
array(
|
169 |
+
'name' => 'enqueue_select2',
|
170 |
+
'label' => 'Enqueue Select2',
|
171 |
+
'value' => '<code>' . (acf_get_setting('enqueue_select2') ? __('True'): __('False')) . '</code>',
|
172 |
+
'description' => 'Allows ACF to enqueue and load the Select2 JS/CSS library.<br />Defaults to true'
|
173 |
+
),
|
174 |
+
array(
|
175 |
+
'name' => 'select2_version',
|
176 |
+
'label' => 'Select2 version',
|
177 |
+
'value' => '<code>' . acf_get_setting('select2_version') . '</code>',
|
178 |
+
'description' => 'Defines which version of Select2 library to enqueue. Either 3 or 4.<br />Defaults to 4 since ACF 5.6.0'
|
179 |
+
),
|
180 |
+
array(
|
181 |
+
'name' => 'enqueue_datepicker',
|
182 |
+
'label' => 'Enqueue Datepicker',
|
183 |
+
'value' => '<code>' . (acf_get_setting('enqueue_datepicker') ? __('True'): __('False')) . '</code>',
|
184 |
+
'description' => 'Allows ACF to enqueue and load the WP datepicker JS/CSS library.<br />Defaults to true'
|
185 |
+
),
|
186 |
+
array(
|
187 |
+
'name' => 'enqueue_datetimepicker',
|
188 |
+
'label' => 'Enqueue Datepiker/time',
|
189 |
+
'value' => '<code>' . (acf_get_setting('enqueue_datetimepicker') ? __('True'): __('False')) . '</code>',
|
190 |
+
'description' => 'Allows ACF to enqueue and load the datetimepicker JS/CSS library.<br />Defaults to true'
|
191 |
+
),
|
192 |
+
array(
|
193 |
+
'name' => 'row_index_offset',
|
194 |
+
'label' => 'Row index offset',
|
195 |
+
'value' => '<code>' . acf_get_setting('row_index_offset') . '</code>',
|
196 |
+
'description' => 'Defines the starting index used in all ‘loop’ and ‘row’ functions.<br />Defaults to 1 (1 is the first row), can be changed to 0 (0 is the first row)'
|
197 |
+
),
|
198 |
+
array(
|
199 |
+
'name' => 'remove_wp_meta_box',
|
200 |
+
'label' => 'Remove WP meta box',
|
201 |
+
'value' => '<code>' . (acf_get_setting('remove_wp_meta_box') ? __('True'): __('False')) . '</code>',
|
202 |
+
'description' => 'Allows ACF to remove the default WP custom fields metabox. Defaults to true'
|
203 |
+
),
|
204 |
+
);
|
205 |
+
|
206 |
+
?>
|
207 |
+
<div class="postbox acf-postbox">
|
208 |
+
<h2 class="hndle ui-sortable-handle"><span><?php _e('ACF Settings'); ?></span></h2>
|
209 |
+
<div class="inside acf-fields -left">
|
210 |
+
|
211 |
+
<?php foreach($settings as $setting){ ?>
|
212 |
+
<div class="acf-field">
|
213 |
+
<div class="acf-label">
|
214 |
+
<label><span class="acf-js-tooltip dashicons dashicons-info" style="float:right; font-size:16px; color:#ccc;" title="<?php echo $setting['description']; ?>"></span><?php echo $setting['label']; ?></label>
|
215 |
+
</div>
|
216 |
+
<div class="acf-input">
|
217 |
+
<?php echo $setting['value']; ?>
|
218 |
+
</div>
|
219 |
+
</div>
|
220 |
+
<?php } ?>
|
221 |
+
|
222 |
+
<script type="text/javascript">
|
223 |
+
if( typeof acf !== 'undefined' ) {
|
224 |
+
|
225 |
+
acf.newPostbox({
|
226 |
+
'id': 'acfe-settings',
|
227 |
+
'label': 'left'
|
228 |
+
});
|
229 |
+
|
230 |
+
}
|
231 |
+
</script>
|
232 |
+
</div>
|
233 |
+
</div>
|
234 |
+
</div>
|
235 |
+
|
236 |
+
</div>
|
237 |
+
<?php
|
238 |
}
|
includes/admin/tools/dbt-export.php
CHANGED
@@ -1,180 +1,184 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
'
|
49 |
-
'
|
50 |
-
'
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
return false;
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
// check $
|
166 |
-
if($keys =
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
|
|
|
|
|
|
|
|
180 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_block_types', true))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Export_DBT')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Export_DBT extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
function initialize(){
|
15 |
+
|
16 |
+
// vars
|
17 |
+
$this->name = 'acfe_tool_dbt_export';
|
18 |
+
$this->title = __('Export Block Types');
|
19 |
+
$this->icon = 'dashicons-upload';
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function html(){
|
24 |
+
|
25 |
+
// vars
|
26 |
+
$choices = array();
|
27 |
+
|
28 |
+
$dynamic_block_types = get_option('acfe_dynamic_block_types', array());
|
29 |
+
|
30 |
+
if($dynamic_block_types){
|
31 |
+
foreach($dynamic_block_types as $block_type_name => $args){
|
32 |
+
|
33 |
+
$choices[$block_type_name] = esc_html($args['title']);
|
34 |
+
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
?>
|
39 |
+
<p><?php _e('Export Block Types', 'acf'); ?></p>
|
40 |
+
|
41 |
+
<div class="acf-fields">
|
42 |
+
<?php
|
43 |
+
|
44 |
+
if(!empty($choices)){
|
45 |
+
|
46 |
+
// render
|
47 |
+
acf_render_field_wrap(array(
|
48 |
+
'label' => __('Select Block Types', 'acf'),
|
49 |
+
'type' => 'checkbox',
|
50 |
+
'name' => 'keys',
|
51 |
+
'prefix' => false,
|
52 |
+
'value' => false,
|
53 |
+
'toggle' => true,
|
54 |
+
'choices' => $choices,
|
55 |
+
));
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
else{
|
60 |
+
|
61 |
+
echo '<div style="padding:15px 12px;">';
|
62 |
+
_e('No dynamic block type available.');
|
63 |
+
echo '</div>';
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
?>
|
68 |
+
</div>
|
69 |
+
|
70 |
+
<?php
|
71 |
+
|
72 |
+
$disabled = '';
|
73 |
+
if(empty($choices))
|
74 |
+
$disabled = 'disabled="disabled"';
|
75 |
+
|
76 |
+
?>
|
77 |
+
|
78 |
+
<p class="acf-submit">
|
79 |
+
<button type="submit" name="action" class="button button-primary" value="download" <?php echo $disabled; ?>><?php _e('Export File'); ?></button>
|
80 |
+
</p>
|
81 |
+
<?php
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
function load(){
|
86 |
+
|
87 |
+
// check $_GET
|
88 |
+
if($this->is_active() && acf_maybe_get_GET('keys')){
|
89 |
+
|
90 |
+
$this->submit();
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
function submit(){
|
97 |
+
|
98 |
+
$json = $this->get_selected();
|
99 |
+
|
100 |
+
// validate
|
101 |
+
if($json === false)
|
102 |
+
return acf_add_admin_notice(__('No block types selected'), 'warning');
|
103 |
+
|
104 |
+
$keys = array();
|
105 |
+
foreach($json as $key => $args){
|
106 |
+
|
107 |
+
$keys[] = $key;
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
// Prefix
|
112 |
+
$prefix = (count($keys) > 1) ? 'block-types' : 'block-type';
|
113 |
+
|
114 |
+
// Slugs
|
115 |
+
$slugs = implode('-', $keys);
|
116 |
+
|
117 |
+
// Date
|
118 |
+
$date = date('Y-m-d');
|
119 |
+
|
120 |
+
// file
|
121 |
+
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
122 |
+
|
123 |
+
// headers
|
124 |
+
header("Content-Description: File Transfer");
|
125 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
126 |
+
header("Content-Type: application/json; charset=utf-8");
|
127 |
+
|
128 |
+
// return
|
129 |
+
echo acf_json_encode($json);
|
130 |
+
die;
|
131 |
+
|
132 |
+
}
|
133 |
+
|
134 |
+
function get_selected(){
|
135 |
+
|
136 |
+
// vars
|
137 |
+
$selected = $this->get_selected_keys();
|
138 |
+
$json = array();
|
139 |
+
|
140 |
+
if(!$selected)
|
141 |
+
return false;
|
142 |
+
|
143 |
+
$dynamic_block_types = get_option('acfe_dynamic_block_types', array());
|
144 |
+
if(empty($dynamic_block_types))
|
145 |
+
return false;
|
146 |
+
|
147 |
+
// construct JSON
|
148 |
+
foreach($selected as $key){
|
149 |
+
|
150 |
+
if(!isset($dynamic_block_types[$key]))
|
151 |
+
continue;
|
152 |
+
|
153 |
+
// add to json array
|
154 |
+
$json[$key] = $dynamic_block_types[$key];
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
// return
|
159 |
+
return $json;
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
function get_selected_keys(){
|
164 |
+
|
165 |
+
// check $_POST
|
166 |
+
if($keys = acf_maybe_get_POST('keys'))
|
167 |
+
return (array) $keys;
|
168 |
+
|
169 |
+
// check $_GET
|
170 |
+
if($keys = acf_maybe_get_GET('keys')){
|
171 |
+
$keys = str_replace(' ', '+', $keys);
|
172 |
+
return explode('+', $keys);
|
173 |
+
}
|
174 |
+
|
175 |
+
// return
|
176 |
+
return false;
|
177 |
+
|
178 |
+
}
|
179 |
+
|
180 |
+
}
|
181 |
+
|
182 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_DBT');
|
183 |
+
|
184 |
endif;
|
includes/admin/tools/dbt-import.php
CHANGED
@@ -1,215 +1,219 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
'
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
</
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
$
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
// Check
|
59 |
-
if(
|
60 |
-
return acf_add_admin_notice(__("
|
61 |
-
|
62 |
-
//
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
//
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
//
|
90 |
-
$
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
update_field('
|
111 |
-
update_field('
|
112 |
-
update_field('
|
113 |
-
update_field('
|
114 |
-
update_field('
|
115 |
-
update_field('
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
//
|
122 |
-
if(!empty($args['
|
123 |
-
update_field('
|
124 |
-
|
125 |
-
// Enqueue
|
126 |
-
if(!empty($args['
|
127 |
-
update_field('
|
128 |
-
|
129 |
-
//
|
130 |
-
if(empty($args['
|
131 |
-
update_field('
|
132 |
-
|
133 |
-
//
|
134 |
-
if(
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
update_field('
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
|
|
|
|
|
|
|
|
215 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_block_types', true))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Import_DBT')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Import_DBT extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
function initialize(){
|
15 |
+
|
16 |
+
// vars
|
17 |
+
$this->name = 'acfe_tool_dbt_import';
|
18 |
+
$this->title = __('Import Block Types');
|
19 |
+
$this->icon = 'dashicons-upload';
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function html(){
|
24 |
+
|
25 |
+
?>
|
26 |
+
<p><?php _e('Import Block Types', 'acf'); ?></p>
|
27 |
+
|
28 |
+
<div class="acf-fields">
|
29 |
+
<?php
|
30 |
+
|
31 |
+
acf_render_field_wrap(array(
|
32 |
+
'label' => __('Select File', 'acf'),
|
33 |
+
'type' => 'file',
|
34 |
+
'name' => 'acf_import_file',
|
35 |
+
'value' => false,
|
36 |
+
'uploader' => 'basic',
|
37 |
+
));
|
38 |
+
|
39 |
+
?>
|
40 |
+
</div>
|
41 |
+
|
42 |
+
<p class="acf-submit">
|
43 |
+
<button type="submit" name="action" class="button button-primary"><?php _e('Import File'); ?></button>
|
44 |
+
</p>
|
45 |
+
<?php
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
function submit(){
|
50 |
+
|
51 |
+
// Check file size.
|
52 |
+
if(empty($_FILES['acf_import_file']['size']))
|
53 |
+
return acf_add_admin_notice(__("No file selected", 'acf'), 'warning');
|
54 |
+
|
55 |
+
// Get file data.
|
56 |
+
$file = $_FILES['acf_import_file'];
|
57 |
+
|
58 |
+
// Check errors.
|
59 |
+
if($file['error'])
|
60 |
+
return acf_add_admin_notice(__("Error uploading file. Please try again", 'acf'), 'warning');
|
61 |
+
|
62 |
+
// Check file type.
|
63 |
+
if(pathinfo($file['name'], PATHINFO_EXTENSION) !== 'json')
|
64 |
+
return acf_add_admin_notice(__("Incorrect file type", 'acf'), 'warning');
|
65 |
+
|
66 |
+
// Read JSON.
|
67 |
+
$json = file_get_contents($file['tmp_name']);
|
68 |
+
$json = json_decode($json, true);
|
69 |
+
|
70 |
+
// Check if empty.
|
71 |
+
if(!$json || !is_array($json))
|
72 |
+
return acf_add_admin_notice(__("Import file empty", 'acf'), 'warning');
|
73 |
+
|
74 |
+
$ids = array();
|
75 |
+
|
76 |
+
$dynamic_block_types = get_option('acfe_dynamic_block_types', array());
|
77 |
+
|
78 |
+
// Loop over json
|
79 |
+
foreach($json as $block_type_name => $args){
|
80 |
+
|
81 |
+
// Check if already exists
|
82 |
+
if(isset($dynamic_block_types[$block_type_name])){
|
83 |
+
|
84 |
+
acf_add_admin_notice(__("Block type {$dynamic_block_types[$block_type_name]['title']} already exists. Import aborted."), 'warning');
|
85 |
+
continue;
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
// Vars
|
90 |
+
$title = $args['title'];
|
91 |
+
$name = $block_type_name;
|
92 |
+
|
93 |
+
// Insert post
|
94 |
+
$post_id = wp_insert_post(array(
|
95 |
+
'post_title' => $title,
|
96 |
+
'post_name' => $name,
|
97 |
+
'post_type' => 'acfe-dbt',
|
98 |
+
'post_status' => 'publish'
|
99 |
+
));
|
100 |
+
|
101 |
+
// Insert error
|
102 |
+
if(is_wp_error($post_id)){
|
103 |
+
|
104 |
+
acf_add_admin_notice(__("Something went wrong with the block type {$title}. Import aborted."), 'warning');
|
105 |
+
continue;
|
106 |
+
|
107 |
+
}
|
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);
|
115 |
+
update_field('post_types', $args['post_types'], $post_id);
|
116 |
+
update_field('mode', $args['mode'], $post_id);
|
117 |
+
update_field('align', $args['align'], $post_id);
|
118 |
+
update_field('render_callback', $args['render_callback'], $post_id);
|
119 |
+
update_field('enqueue_assets', $args['enqueue_assets'], $post_id);
|
120 |
+
|
121 |
+
// Render Template
|
122 |
+
if(!empty($args['render_template']))
|
123 |
+
update_field('render_template', str_replace(ACFE_THEME_PATH . '/', '', $args['render_template']), $post_id);
|
124 |
+
|
125 |
+
// Enqueue Style
|
126 |
+
if(!empty($args['enqueue_style']))
|
127 |
+
update_field('enqueue_style', str_replace(ACFE_THEME_URL . '/', '', $args['enqueue_style']), $post_id);
|
128 |
+
|
129 |
+
// Enqueue Script
|
130 |
+
if(!empty($args['enqueue_script']))
|
131 |
+
update_field('enqueue_script', str_replace(ACFE_THEME_URL . '/', '', $args['enqueue_script']), $post_id);
|
132 |
+
|
133 |
+
// Align
|
134 |
+
if(empty($args['align']))
|
135 |
+
update_field('align', 'none', $post_id);
|
136 |
+
|
137 |
+
// Icon
|
138 |
+
if(!empty($args['icon'])){
|
139 |
+
|
140 |
+
// Simple
|
141 |
+
if(is_string($args['icon'])){
|
142 |
+
|
143 |
+
update_field('icon_type', 'simple', $post_id);
|
144 |
+
|
145 |
+
update_field('icon_text', $args['icon'], $post_id);
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
// Colors
|
150 |
+
elseif(is_array($args['icon'])){
|
151 |
+
|
152 |
+
update_field('icon_type', 'colors', $post_id);
|
153 |
+
|
154 |
+
update_field('icon_background', $args['icon']['background'], $post_id);
|
155 |
+
update_field('icon_foreground', $args['icon']['foreground'], $post_id);
|
156 |
+
update_field('icon_src', $args['icon']['src'], $post_id);
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
// Supports: Align
|
163 |
+
update_field('supports_align', $args['supports']['align'], $post_id);
|
164 |
+
|
165 |
+
if(is_array($args['supports']['align'])){
|
166 |
+
|
167 |
+
update_field('supports_align_args', acf_encode_choices($args['supports']['align'], false), $post_id);
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
// Supports: Mode
|
172 |
+
update_field('supports_mode', $args['supports']['mode'], $post_id);
|
173 |
+
|
174 |
+
// Supports: Multiple
|
175 |
+
update_field('supports_multiple', $args['supports']['multiple'], $post_id);
|
176 |
+
|
177 |
+
// Create ACFE option
|
178 |
+
$dynamic_block_types[$block_type_name] = $args;
|
179 |
+
|
180 |
+
// Sort keys ASC
|
181 |
+
ksort($dynamic_block_types);
|
182 |
+
|
183 |
+
// Update ACFE option
|
184 |
+
update_option('acfe_dynamic_block_types', $dynamic_block_types);
|
185 |
+
|
186 |
+
// append message
|
187 |
+
$ids[] = $post_id;
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
+
if(empty($ids))
|
192 |
+
return;
|
193 |
+
|
194 |
+
// Count total
|
195 |
+
$total = count($ids);
|
196 |
+
|
197 |
+
// Generate text
|
198 |
+
$text = sprintf(_n('1 block type imported', '%s block types imported', $total, 'acf'), $total);
|
199 |
+
|
200 |
+
// Add links to text
|
201 |
+
$links = array();
|
202 |
+
foreach($ids as $id){
|
203 |
+
|
204 |
+
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
205 |
+
|
206 |
+
}
|
207 |
+
|
208 |
+
$text .= ': ' . implode(', ', $links);
|
209 |
+
|
210 |
+
// Add notice
|
211 |
+
acf_add_admin_notice($text, 'success');
|
212 |
+
|
213 |
+
}
|
214 |
+
|
215 |
+
}
|
216 |
+
|
217 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Import_DBT');
|
218 |
+
|
219 |
endif;
|
includes/admin/tools/dop-export.php
CHANGED
@@ -1,180 +1,184 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
'
|
49 |
-
'
|
50 |
-
'
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
return false;
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
// check $
|
166 |
-
if($keys =
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
|
|
|
|
|
|
|
|
180 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_options_pages', true))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Export_DOP')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Export_DOP extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
function initialize(){
|
15 |
+
|
16 |
+
// vars
|
17 |
+
$this->name = 'acfe_tool_dop_export';
|
18 |
+
$this->title = __('Export Options Pages');
|
19 |
+
$this->icon = 'dashicons-upload';
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function html(){
|
24 |
+
|
25 |
+
// vars
|
26 |
+
$choices = array();
|
27 |
+
|
28 |
+
$dynamic_options_pages = get_option('acfe_dynamic_options_pages', array());
|
29 |
+
|
30 |
+
if($dynamic_options_pages){
|
31 |
+
foreach($dynamic_options_pages as $options_page_name => $args){
|
32 |
+
|
33 |
+
$choices[$options_page_name] = esc_html($args['page_title']);
|
34 |
+
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
?>
|
39 |
+
<p><?php _e('Export Options Pages', 'acf'); ?></p>
|
40 |
+
|
41 |
+
<div class="acf-fields">
|
42 |
+
<?php
|
43 |
+
|
44 |
+
if(!empty($choices)){
|
45 |
+
|
46 |
+
// render
|
47 |
+
acf_render_field_wrap(array(
|
48 |
+
'label' => __('Select Options Pages', 'acf'),
|
49 |
+
'type' => 'checkbox',
|
50 |
+
'name' => 'keys',
|
51 |
+
'prefix' => false,
|
52 |
+
'value' => false,
|
53 |
+
'toggle' => true,
|
54 |
+
'choices' => $choices,
|
55 |
+
));
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
else{
|
60 |
+
|
61 |
+
echo '<div style="padding:15px 12px;">';
|
62 |
+
_e('No options page available.');
|
63 |
+
echo '</div>';
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
?>
|
68 |
+
</div>
|
69 |
+
|
70 |
+
<?php
|
71 |
+
|
72 |
+
$disabled = '';
|
73 |
+
if(empty($choices))
|
74 |
+
$disabled = 'disabled="disabled"';
|
75 |
+
|
76 |
+
?>
|
77 |
+
|
78 |
+
<p class="acf-submit">
|
79 |
+
<button type="submit" name="action" class="button button-primary" value="download" <?php echo $disabled; ?>><?php _e('Export File'); ?></button>
|
80 |
+
</p>
|
81 |
+
<?php
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
function load(){
|
86 |
+
|
87 |
+
// check $_GET
|
88 |
+
if($this->is_active() && acf_maybe_get_GET('keys')){
|
89 |
+
|
90 |
+
$this->submit();
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
function submit(){
|
97 |
+
|
98 |
+
$json = $this->get_selected();
|
99 |
+
|
100 |
+
// validate
|
101 |
+
if($json === false)
|
102 |
+
return acf_add_admin_notice(__('No options page selected'), 'warning');
|
103 |
+
|
104 |
+
$keys = array();
|
105 |
+
foreach($json as $key => $args){
|
106 |
+
|
107 |
+
$keys[] = $key;
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
// Prefix
|
112 |
+
$prefix = (count($keys) > 1) ? 'options-pages' : 'options-page';
|
113 |
+
|
114 |
+
// Slugs
|
115 |
+
$slugs = implode('-', $keys);
|
116 |
+
|
117 |
+
// Date
|
118 |
+
$date = date('Y-m-d');
|
119 |
+
|
120 |
+
// file
|
121 |
+
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
122 |
+
|
123 |
+
// headers
|
124 |
+
header("Content-Description: File Transfer");
|
125 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
126 |
+
header("Content-Type: application/json; charset=utf-8");
|
127 |
+
|
128 |
+
// return
|
129 |
+
echo acf_json_encode($json);
|
130 |
+
die;
|
131 |
+
|
132 |
+
}
|
133 |
+
|
134 |
+
function get_selected(){
|
135 |
+
|
136 |
+
// vars
|
137 |
+
$selected = $this->get_selected_keys();
|
138 |
+
$json = array();
|
139 |
+
|
140 |
+
if(!$selected)
|
141 |
+
return false;
|
142 |
+
|
143 |
+
$dynamic_options_pages = get_option('acfe_dynamic_options_pages', array());
|
144 |
+
if(empty($dynamic_options_pages))
|
145 |
+
return false;
|
146 |
+
|
147 |
+
// construct JSON
|
148 |
+
foreach($selected as $key){
|
149 |
+
|
150 |
+
if(!isset($dynamic_options_pages[$key]))
|
151 |
+
continue;
|
152 |
+
|
153 |
+
// add to json array
|
154 |
+
$json[$key] = $dynamic_options_pages[$key];
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
// return
|
159 |
+
return $json;
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
function get_selected_keys(){
|
164 |
+
|
165 |
+
// check $_POST
|
166 |
+
if($keys = acf_maybe_get_POST('keys'))
|
167 |
+
return (array) $keys;
|
168 |
+
|
169 |
+
// check $_GET
|
170 |
+
if($keys = acf_maybe_get_GET('keys')){
|
171 |
+
$keys = str_replace(' ', '+', $keys);
|
172 |
+
return explode('+', $keys);
|
173 |
+
}
|
174 |
+
|
175 |
+
// return
|
176 |
+
return false;
|
177 |
+
|
178 |
+
}
|
179 |
+
|
180 |
+
}
|
181 |
+
|
182 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_DOP');
|
183 |
+
|
184 |
endif;
|
includes/admin/tools/dop-import.php
CHANGED
@@ -1,205 +1,209 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
'
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
</
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
$
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
// Check
|
59 |
-
if(
|
60 |
-
return acf_add_admin_notice(__("
|
61 |
-
|
62 |
-
//
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
//
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
//
|
92 |
-
$
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
update_field('
|
113 |
-
update_field('
|
114 |
-
update_field('
|
115 |
-
update_field('
|
116 |
-
update_field('
|
117 |
-
update_field('
|
118 |
-
update_field('
|
119 |
-
update_field('
|
120 |
-
update_field('
|
121 |
-
|
122 |
-
|
123 |
-
$
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
//
|
145 |
-
if(
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
|
|
|
|
|
|
|
|
205 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_options_pages', true))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Import_DOP')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Import_DOP extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
function initialize(){
|
15 |
+
|
16 |
+
// vars
|
17 |
+
$this->name = 'acfe_tool_dop_import';
|
18 |
+
$this->title = __('Import Options Pages');
|
19 |
+
$this->icon = 'dashicons-upload';
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function html(){
|
24 |
+
|
25 |
+
?>
|
26 |
+
<p><?php _e('Import Options Pages', 'acf'); ?></p>
|
27 |
+
|
28 |
+
<div class="acf-fields">
|
29 |
+
<?php
|
30 |
+
|
31 |
+
acf_render_field_wrap(array(
|
32 |
+
'label' => __('Select File', 'acf'),
|
33 |
+
'type' => 'file',
|
34 |
+
'name' => 'acf_import_file',
|
35 |
+
'value' => false,
|
36 |
+
'uploader' => 'basic',
|
37 |
+
));
|
38 |
+
|
39 |
+
?>
|
40 |
+
</div>
|
41 |
+
|
42 |
+
<p class="acf-submit">
|
43 |
+
<button type="submit" name="action" class="button button-primary"><?php _e('Import File'); ?></button>
|
44 |
+
</p>
|
45 |
+
<?php
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
function submit(){
|
50 |
+
|
51 |
+
// Check file size.
|
52 |
+
if(empty($_FILES['acf_import_file']['size']))
|
53 |
+
return acf_add_admin_notice(__("No file selected", 'acf'), 'warning');
|
54 |
+
|
55 |
+
// Get file data.
|
56 |
+
$file = $_FILES['acf_import_file'];
|
57 |
+
|
58 |
+
// Check errors.
|
59 |
+
if($file['error'])
|
60 |
+
return acf_add_admin_notice(__("Error uploading file. Please try again", 'acf'), 'warning');
|
61 |
+
|
62 |
+
// Check file type.
|
63 |
+
if(pathinfo($file['name'], PATHINFO_EXTENSION) !== 'json')
|
64 |
+
return acf_add_admin_notice(__("Incorrect file type", 'acf'), 'warning');
|
65 |
+
|
66 |
+
// Read JSON.
|
67 |
+
$json = file_get_contents($file['tmp_name']);
|
68 |
+
$json = json_decode($json, true);
|
69 |
+
|
70 |
+
// Check if empty.
|
71 |
+
if(!$json || !is_array($json))
|
72 |
+
return acf_add_admin_notice(__("Import file empty", 'acf'), 'warning');
|
73 |
+
|
74 |
+
$ids = array();
|
75 |
+
|
76 |
+
$dynamic_options_pages = get_option('acfe_dynamic_options_pages', array());
|
77 |
+
|
78 |
+
$dynamic_options_sub_pages = array();
|
79 |
+
|
80 |
+
// Loop over json
|
81 |
+
foreach($json as $options_page_name => $args){
|
82 |
+
|
83 |
+
// Check if already exists
|
84 |
+
if(isset($dynamic_options_pages[$options_page_name])){
|
85 |
+
|
86 |
+
acf_add_admin_notice(__("Options page {$dynamic_options_pages[$options_page_name]['page_title']} already exists. Import aborted."), 'warning');
|
87 |
+
continue;
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
// Vars
|
92 |
+
$title = $args['page_title'];
|
93 |
+
$name = $options_page_name;
|
94 |
+
|
95 |
+
// Insert post
|
96 |
+
$post_id = wp_insert_post(array(
|
97 |
+
'post_title' => $title,
|
98 |
+
'post_name' => $name,
|
99 |
+
'post_type' => 'acfe-dop',
|
100 |
+
'post_status' => 'publish'
|
101 |
+
));
|
102 |
+
|
103 |
+
// Insert error
|
104 |
+
if(is_wp_error($post_id)){
|
105 |
+
|
106 |
+
acf_add_admin_notice(__("Something went wrong with the options page {$title}. Import aborted."), 'warning');
|
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);
|
117 |
+
update_field('position', $args['position'], $post_id);
|
118 |
+
update_field('parent_slug', $args['parent_slug'], $post_id);
|
119 |
+
update_field('icon_url', $args['icon_url'], $post_id);
|
120 |
+
update_field('redirect', $args['redirect'], $post_id);
|
121 |
+
update_field('post_id', $args['post_id'], $post_id);
|
122 |
+
update_field('autoload', $args['autoload'], $post_id);
|
123 |
+
update_field('update_button', $args['update_button'], $post_id);
|
124 |
+
update_field('updated_message', $args['updated_message'], $post_id);
|
125 |
+
|
126 |
+
// Create ACFE option
|
127 |
+
$dynamic_options_pages[$options_page_name] = $args;
|
128 |
+
|
129 |
+
// Sort keys ASC
|
130 |
+
ksort($dynamic_options_pages);
|
131 |
+
|
132 |
+
// Update ACFE option
|
133 |
+
update_option('acfe_dynamic_options_pages', $dynamic_options_pages);
|
134 |
+
|
135 |
+
// Append message
|
136 |
+
$ids[] = $post_id;
|
137 |
+
|
138 |
+
// Add Sub Page
|
139 |
+
if(isset($args['parent_slug']) && !empty($args['parent_slug']))
|
140 |
+
$dynamic_options_sub_pages[$post_id] = $args;
|
141 |
+
|
142 |
+
}
|
143 |
+
|
144 |
+
// Check if pages have been added
|
145 |
+
if(empty($ids))
|
146 |
+
return;
|
147 |
+
|
148 |
+
// Update Options Sub Pages
|
149 |
+
if(!empty($dynamic_options_sub_pages)){
|
150 |
+
|
151 |
+
foreach($dynamic_options_sub_pages as $post_id => $args){
|
152 |
+
|
153 |
+
// Get possible parent options pages
|
154 |
+
$get_dop_parent = get_posts(array(
|
155 |
+
'post_type' => 'acfe-dop',
|
156 |
+
'posts_per_page' => 1,
|
157 |
+
'fields' => 'ids',
|
158 |
+
'meta_query' => array(
|
159 |
+
array(
|
160 |
+
'key' => 'menu_slug',
|
161 |
+
'value' => $args['parent_slug']
|
162 |
+
)
|
163 |
+
)
|
164 |
+
));
|
165 |
+
|
166 |
+
if(empty($get_dop_parent))
|
167 |
+
continue;
|
168 |
+
|
169 |
+
$parent = $get_dop_parent[0];
|
170 |
+
|
171 |
+
// Update sub page post
|
172 |
+
wp_update_post(array(
|
173 |
+
'ID' => $post_id,
|
174 |
+
'post_parent' => $parent,
|
175 |
+
));
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
// Count total
|
182 |
+
$total = count($ids);
|
183 |
+
|
184 |
+
// Generate text
|
185 |
+
$text = sprintf(_n('1 options page imported', '%s options pages imported', $total, 'acf'), $total);
|
186 |
+
|
187 |
+
// Add links to text
|
188 |
+
$links = array();
|
189 |
+
foreach($ids as $id){
|
190 |
+
|
191 |
+
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
192 |
+
|
193 |
+
}
|
194 |
+
|
195 |
+
$text .= ': ' . implode(', ', $links);
|
196 |
+
|
197 |
+
// Add notice
|
198 |
+
acf_add_admin_notice($text, 'success');
|
199 |
+
|
200 |
+
// Flush permalinks
|
201 |
+
flush_rewrite_rules();
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
}
|
206 |
+
|
207 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Import_DOP');
|
208 |
+
|
209 |
endif;
|
includes/admin/tools/dpt-export.php
CHANGED
@@ -1,180 +1,184 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
'
|
49 |
-
'
|
50 |
-
'
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
return false;
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
// check $
|
166 |
-
if($keys =
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
|
|
|
|
|
|
|
|
180 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_post_types', true))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Export_DPT')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Export_DPT extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
function initialize(){
|
15 |
+
|
16 |
+
// vars
|
17 |
+
$this->name = 'acfe_tool_dpt_export';
|
18 |
+
$this->title = __('Export Post Types');
|
19 |
+
$this->icon = 'dashicons-upload';
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function html(){
|
24 |
+
|
25 |
+
// vars
|
26 |
+
$choices = array();
|
27 |
+
|
28 |
+
$dynamic_post_types = get_option('acfe_dynamic_post_types', array());
|
29 |
+
|
30 |
+
if($dynamic_post_types){
|
31 |
+
foreach($dynamic_post_types as $post_type_name => $args){
|
32 |
+
|
33 |
+
$choices[$post_type_name] = esc_html($args['label']);
|
34 |
+
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
?>
|
39 |
+
<p><?php _e('Export Post Types', 'acf'); ?></p>
|
40 |
+
|
41 |
+
<div class="acf-fields">
|
42 |
+
<?php
|
43 |
+
|
44 |
+
if(!empty($choices)){
|
45 |
+
|
46 |
+
// render
|
47 |
+
acf_render_field_wrap(array(
|
48 |
+
'label' => __('Select Post Types', 'acf'),
|
49 |
+
'type' => 'checkbox',
|
50 |
+
'name' => 'keys',
|
51 |
+
'prefix' => false,
|
52 |
+
'value' => false,
|
53 |
+
'toggle' => true,
|
54 |
+
'choices' => $choices,
|
55 |
+
));
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
else{
|
60 |
+
|
61 |
+
echo '<div style="padding:15px 12px;">';
|
62 |
+
_e('No dynamic post type available.');
|
63 |
+
echo '</div>';
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
?>
|
68 |
+
</div>
|
69 |
+
|
70 |
+
<?php
|
71 |
+
|
72 |
+
$disabled = '';
|
73 |
+
if(empty($choices))
|
74 |
+
$disabled = 'disabled="disabled"';
|
75 |
+
|
76 |
+
?>
|
77 |
+
|
78 |
+
<p class="acf-submit">
|
79 |
+
<button type="submit" name="action" class="button button-primary" value="download" <?php echo $disabled; ?>><?php _e('Export File'); ?></button>
|
80 |
+
</p>
|
81 |
+
<?php
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
function load(){
|
86 |
+
|
87 |
+
// check $_GET
|
88 |
+
if($this->is_active() && acf_maybe_get_GET('keys')){
|
89 |
+
|
90 |
+
$this->submit();
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
function submit(){
|
97 |
+
|
98 |
+
$json = $this->get_selected();
|
99 |
+
|
100 |
+
// validate
|
101 |
+
if($json === false)
|
102 |
+
return acf_add_admin_notice(__('No post types selected'), 'warning');
|
103 |
+
|
104 |
+
$keys = array();
|
105 |
+
foreach($json as $key => $args){
|
106 |
+
|
107 |
+
$keys[] = $key;
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
// Prefix
|
112 |
+
$prefix = (count($keys) > 1) ? 'post-types' : 'post-type';
|
113 |
+
|
114 |
+
// Slugs
|
115 |
+
$slugs = implode('-', $keys);
|
116 |
+
|
117 |
+
// Date
|
118 |
+
$date = date('Y-m-d');
|
119 |
+
|
120 |
+
// file
|
121 |
+
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
122 |
+
|
123 |
+
// headers
|
124 |
+
header("Content-Description: File Transfer");
|
125 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
126 |
+
header("Content-Type: application/json; charset=utf-8");
|
127 |
+
|
128 |
+
// return
|
129 |
+
echo acf_json_encode($json);
|
130 |
+
die;
|
131 |
+
|
132 |
+
}
|
133 |
+
|
134 |
+
function get_selected(){
|
135 |
+
|
136 |
+
// vars
|
137 |
+
$selected = $this->get_selected_keys();
|
138 |
+
$json = array();
|
139 |
+
|
140 |
+
if(!$selected)
|
141 |
+
return false;
|
142 |
+
|
143 |
+
$dynamic_post_types = get_option('acfe_dynamic_post_types', array());
|
144 |
+
if(empty($dynamic_post_types))
|
145 |
+
return false;
|
146 |
+
|
147 |
+
// construct JSON
|
148 |
+
foreach($selected as $key){
|
149 |
+
|
150 |
+
if(!isset($dynamic_post_types[$key]))
|
151 |
+
continue;
|
152 |
+
|
153 |
+
// add to json array
|
154 |
+
$json[$key] = $dynamic_post_types[$key];
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
// return
|
159 |
+
return $json;
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
function get_selected_keys(){
|
164 |
+
|
165 |
+
// check $_POST
|
166 |
+
if($keys = acf_maybe_get_POST('keys'))
|
167 |
+
return (array) $keys;
|
168 |
+
|
169 |
+
// check $_GET
|
170 |
+
if($keys = acf_maybe_get_GET('keys')){
|
171 |
+
$keys = str_replace(' ', '+', $keys);
|
172 |
+
return explode('+', $keys);
|
173 |
+
}
|
174 |
+
|
175 |
+
// return
|
176 |
+
return false;
|
177 |
+
|
178 |
+
}
|
179 |
+
|
180 |
+
}
|
181 |
+
|
182 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_DPT');
|
183 |
+
|
184 |
endif;
|
includes/admin/tools/dpt-import.php
CHANGED
@@ -1,239 +1,243 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
'
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
</
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
$
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
// Check
|
59 |
-
if(
|
60 |
-
return acf_add_admin_notice(__("
|
61 |
-
|
62 |
-
//
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
//
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
//
|
90 |
-
$
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
update_field('
|
111 |
-
update_field('
|
112 |
-
update_field('
|
113 |
-
update_field('
|
114 |
-
update_field('
|
115 |
-
update_field('
|
116 |
-
update_field('
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
update_field('
|
135 |
-
update_field('
|
136 |
-
|
137 |
-
|
138 |
-
update_field('
|
139 |
-
update_field('
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
update_field('
|
150 |
-
|
151 |
-
|
152 |
-
update_field('
|
153 |
-
update_field('
|
154 |
-
|
155 |
-
//
|
156 |
-
update_field('
|
157 |
-
update_field('
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
update_field('
|
162 |
-
update_field('
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
//
|
170 |
-
if($args['
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
update_field('
|
177 |
-
|
178 |
-
update_field('
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
//
|
188 |
-
if($args['
|
189 |
-
update_field('
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
$
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
|
|
239 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_post_types', true))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Import_DPT')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Import_DPT extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
function initialize(){
|
15 |
+
|
16 |
+
// vars
|
17 |
+
$this->name = 'acfe_tool_dpt_import';
|
18 |
+
$this->title = __('Import Post Types');
|
19 |
+
$this->icon = 'dashicons-upload';
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function html(){
|
24 |
+
|
25 |
+
?>
|
26 |
+
<p><?php _e('Import Post Types', 'acf'); ?></p>
|
27 |
+
|
28 |
+
<div class="acf-fields">
|
29 |
+
<?php
|
30 |
+
|
31 |
+
acf_render_field_wrap(array(
|
32 |
+
'label' => __('Select File', 'acf'),
|
33 |
+
'type' => 'file',
|
34 |
+
'name' => 'acf_import_file',
|
35 |
+
'value' => false,
|
36 |
+
'uploader' => 'basic',
|
37 |
+
));
|
38 |
+
|
39 |
+
?>
|
40 |
+
</div>
|
41 |
+
|
42 |
+
<p class="acf-submit">
|
43 |
+
<button type="submit" name="action" class="button button-primary"><?php _e('Import File'); ?></button>
|
44 |
+
</p>
|
45 |
+
<?php
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
function submit(){
|
50 |
+
|
51 |
+
// Check file size.
|
52 |
+
if(empty($_FILES['acf_import_file']['size']))
|
53 |
+
return acf_add_admin_notice(__("No file selected", 'acf'), 'warning');
|
54 |
+
|
55 |
+
// Get file data.
|
56 |
+
$file = $_FILES['acf_import_file'];
|
57 |
+
|
58 |
+
// Check errors.
|
59 |
+
if($file['error'])
|
60 |
+
return acf_add_admin_notice(__("Error uploading file. Please try again", 'acf'), 'warning');
|
61 |
+
|
62 |
+
// Check file type.
|
63 |
+
if(pathinfo($file['name'], PATHINFO_EXTENSION) !== 'json')
|
64 |
+
return acf_add_admin_notice(__("Incorrect file type", 'acf'), 'warning');
|
65 |
+
|
66 |
+
// Read JSON.
|
67 |
+
$json = file_get_contents($file['tmp_name']);
|
68 |
+
$json = json_decode($json, true);
|
69 |
+
|
70 |
+
// Check if empty.
|
71 |
+
if(!$json || !is_array($json))
|
72 |
+
return acf_add_admin_notice(__("Import file empty", 'acf'), 'warning');
|
73 |
+
|
74 |
+
$ids = array();
|
75 |
+
|
76 |
+
$dynamic_post_types = get_option('acfe_dynamic_post_types', array());
|
77 |
+
|
78 |
+
// Loop over json
|
79 |
+
foreach($json as $post_type_name => $args){
|
80 |
+
|
81 |
+
// Check if already exists
|
82 |
+
if(isset($dynamic_post_types[$post_type_name])){
|
83 |
+
|
84 |
+
acf_add_admin_notice(__("Post type {$dynamic_post_types[$post_type_name]['label']} already exists. Import aborted."), 'warning');
|
85 |
+
continue;
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
// Vars
|
90 |
+
$title = $args['label'];
|
91 |
+
$name = $post_type_name;
|
92 |
+
|
93 |
+
// Insert post
|
94 |
+
$post_id = wp_insert_post(array(
|
95 |
+
'post_title' => $title,
|
96 |
+
'post_name' => $name,
|
97 |
+
'post_type' => 'acfe-dpt',
|
98 |
+
'post_status' => 'publish'
|
99 |
+
));
|
100 |
+
|
101 |
+
// Insert error
|
102 |
+
if(is_wp_error($post_id)){
|
103 |
+
|
104 |
+
acf_add_admin_notice(__("Something went wrong with the post type {$title}. Import aborted."), 'warning');
|
105 |
+
continue;
|
106 |
+
|
107 |
+
}
|
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);
|
115 |
+
update_field('taxonomies', $args['taxonomies'], $post_id);
|
116 |
+
update_field('public', $args['public'], $post_id);
|
117 |
+
update_field('exclude_from_search', $args['exclude_from_search'], $post_id);
|
118 |
+
update_field('publicly_queryable', $args['publicly_queryable'], $post_id);
|
119 |
+
update_field('can_export', $args['can_export'], $post_id);
|
120 |
+
update_field('delete_with_user', $args['delete_with_user'], $post_id);
|
121 |
+
|
122 |
+
// Labels
|
123 |
+
if(!empty($args['labels'])){
|
124 |
+
|
125 |
+
foreach($args['labels'] as $label_key => $label_value){
|
126 |
+
|
127 |
+
update_field('labels_' . $label_key, $label_value, $post_id);
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
}
|
132 |
+
|
133 |
+
// Menu
|
134 |
+
update_field('menu_position', $args['menu_position'], $post_id);
|
135 |
+
update_field('menu_icon', $args['menu_icon'], $post_id);
|
136 |
+
update_field('show_ui', $args['show_ui'], $post_id);
|
137 |
+
update_field('show_in_menu', $args['show_in_menu'], $post_id);
|
138 |
+
update_field('show_in_nav_menus', $args['show_in_nav_menus'], $post_id);
|
139 |
+
update_field('show_in_admin_bar', $args['show_in_admin_bar'], $post_id);
|
140 |
+
|
141 |
+
// Capability
|
142 |
+
update_field('capability_type', acf_encode_choices($args['capability_type'], false), $post_id);
|
143 |
+
update_field('map_meta_cap', $args['map_meta_cap'], $post_id);
|
144 |
+
|
145 |
+
if(isset($args['capabilities']))
|
146 |
+
update_field('capabilities', acf_encode_choices($args['capabilities'], false), $post_id);
|
147 |
+
|
148 |
+
// Archive
|
149 |
+
update_field('acfe_dpt_archive_template', $args['acfe_archive_template'], $post_id);
|
150 |
+
update_field('acfe_dpt_archive_posts_per_page', $args['acfe_archive_ppp'], $post_id);
|
151 |
+
update_field('acfe_dpt_archive_orderby', $args['acfe_archive_orderby'], $post_id);
|
152 |
+
update_field('acfe_dpt_archive_order', $args['acfe_archive_order'], $post_id);
|
153 |
+
update_field('has_archive', $args['has_archive'], $post_id);
|
154 |
+
|
155 |
+
// Single
|
156 |
+
update_field('acfe_dpt_single_template', $args['acfe_single_template'], $post_id);
|
157 |
+
update_field('rewrite', $args['rewrite'], $post_id);
|
158 |
+
|
159 |
+
// Admin
|
160 |
+
update_field('acfe_dpt_admin_posts_per_page', $args['acfe_admin_ppp'], $post_id);
|
161 |
+
update_field('acfe_dpt_admin_orderby', $args['acfe_admin_orderby'], $post_id);
|
162 |
+
update_field('acfe_dpt_admin_order', $args['acfe_admin_order'], $post_id);
|
163 |
+
|
164 |
+
// REST
|
165 |
+
update_field('show_in_rest', $args['show_in_rest'], $post_id);
|
166 |
+
update_field('rest_base', $args['rest_base'], $post_id);
|
167 |
+
update_field('rest_controller_class', $args['rest_controller_class'], $post_id);
|
168 |
+
|
169 |
+
// Has archive: override
|
170 |
+
if($args['has_archive'])
|
171 |
+
update_field('has_archive_slug', $args['has_archive'], $post_id);
|
172 |
+
|
173 |
+
// Rewrite: override
|
174 |
+
if($args['rewrite'] && is_array($args['rewrite'])){
|
175 |
+
|
176 |
+
update_field('rewrite', true, $post_id);
|
177 |
+
|
178 |
+
update_field('rewrite_args_select', true, $post_id);
|
179 |
+
|
180 |
+
update_field('rewrite_args_acfe_dpt_rewrite_slug', $args['rewrite']['slug'], $post_id);
|
181 |
+
update_field('rewrite_args_acfe_dpt_rewrite_with_front', $args['rewrite']['with_front'], $post_id);
|
182 |
+
update_field('rewrite_args_feeds', $args['rewrite']['feeds'], $post_id);
|
183 |
+
update_field('rewrite_args_pages', $args['rewrite']['pages'], $post_id);
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
// Show in menu (text)
|
188 |
+
if($args['show_in_menu'] && is_string($args['show_in_menu']))
|
189 |
+
update_field('show_in_menu_text', $args['show_in_menu'], $post_id);
|
190 |
+
|
191 |
+
// Map meta cap
|
192 |
+
if($args['map_meta_cap'] === false)
|
193 |
+
update_field('map_meta_cap', 'false', $post_id);
|
194 |
+
|
195 |
+
elseif($args['map_meta_cap'] === true)
|
196 |
+
update_field('map_meta_cap', 'true', $post_id);
|
197 |
+
|
198 |
+
// Create ACFE option
|
199 |
+
$dynamic_post_types[$post_type_name] = $args;
|
200 |
+
|
201 |
+
// Sort keys ASC
|
202 |
+
ksort($dynamic_post_types);
|
203 |
+
|
204 |
+
// Update ACFE option
|
205 |
+
update_option('acfe_dynamic_post_types', $dynamic_post_types);
|
206 |
+
|
207 |
+
// append message
|
208 |
+
$ids[] = $post_id;
|
209 |
+
|
210 |
+
}
|
211 |
+
|
212 |
+
if(empty($ids))
|
213 |
+
return;
|
214 |
+
|
215 |
+
// Count total
|
216 |
+
$total = count($ids);
|
217 |
+
|
218 |
+
// Generate text
|
219 |
+
$text = sprintf(_n('1 post type imported', '%s post types imported', $total, 'acf'), $total);
|
220 |
+
|
221 |
+
// Add links to text
|
222 |
+
$links = array();
|
223 |
+
foreach($ids as $id){
|
224 |
+
|
225 |
+
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
226 |
+
|
227 |
+
}
|
228 |
+
|
229 |
+
$text .= ': ' . implode(', ', $links);
|
230 |
+
|
231 |
+
// Add notice
|
232 |
+
acf_add_admin_notice($text, 'success');
|
233 |
+
|
234 |
+
// Flush permalinks
|
235 |
+
flush_rewrite_rules();
|
236 |
+
|
237 |
+
}
|
238 |
+
|
239 |
+
}
|
240 |
+
|
241 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Import_DPT');
|
242 |
+
|
243 |
endif;
|
includes/admin/tools/dt-export.php
CHANGED
@@ -1,180 +1,184 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
'
|
49 |
-
'
|
50 |
-
'
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
return false;
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
// check $
|
166 |
-
if($keys =
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
|
|
|
|
|
|
|
|
180 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_taxonomies', true))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Export_DT')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Export_DT extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
function initialize(){
|
15 |
+
|
16 |
+
// vars
|
17 |
+
$this->name = 'acfe_tool_dt_export';
|
18 |
+
$this->title = __('Export Taxonomies');
|
19 |
+
$this->icon = 'dashicons-upload';
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function html(){
|
24 |
+
|
25 |
+
// vars
|
26 |
+
$choices = array();
|
27 |
+
|
28 |
+
$dynamic_taxonomies = get_option('acfe_dynamic_taxonomies', array());
|
29 |
+
|
30 |
+
if($dynamic_taxonomies){
|
31 |
+
foreach($dynamic_taxonomies as $taxonomy_name => $args){
|
32 |
+
|
33 |
+
$choices[$taxonomy_name] = esc_html($args['label']);
|
34 |
+
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
?>
|
39 |
+
<p><?php _e('Export Taxonomies', 'acf'); ?></p>
|
40 |
+
|
41 |
+
<div class="acf-fields">
|
42 |
+
<?php
|
43 |
+
|
44 |
+
if(!empty($choices)){
|
45 |
+
|
46 |
+
// render
|
47 |
+
acf_render_field_wrap(array(
|
48 |
+
'label' => __('Select Taxonomies', 'acf'),
|
49 |
+
'type' => 'checkbox',
|
50 |
+
'name' => 'keys',
|
51 |
+
'prefix' => false,
|
52 |
+
'value' => false,
|
53 |
+
'toggle' => true,
|
54 |
+
'choices' => $choices,
|
55 |
+
));
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
else{
|
60 |
+
|
61 |
+
echo '<div style="padding:15px 12px;">';
|
62 |
+
_e('No dynamic taxonomy available.');
|
63 |
+
echo '</div>';
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
?>
|
68 |
+
</div>
|
69 |
+
|
70 |
+
<?php
|
71 |
+
|
72 |
+
$disabled = '';
|
73 |
+
if(empty($choices))
|
74 |
+
$disabled = 'disabled="disabled"';
|
75 |
+
|
76 |
+
?>
|
77 |
+
|
78 |
+
<p class="acf-submit">
|
79 |
+
<button type="submit" name="action" class="button button-primary" value="download" <?php echo $disabled; ?>><?php _e('Export File'); ?></button>
|
80 |
+
</p>
|
81 |
+
<?php
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
function load(){
|
86 |
+
|
87 |
+
// check $_GET
|
88 |
+
if($this->is_active() && acf_maybe_get_GET('keys')){
|
89 |
+
|
90 |
+
$this->submit();
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
function submit(){
|
97 |
+
|
98 |
+
$json = $this->get_selected();
|
99 |
+
|
100 |
+
// validate
|
101 |
+
if($json === false)
|
102 |
+
return acf_add_admin_notice(__('No taxonomies selected'), 'warning');
|
103 |
+
|
104 |
+
$keys = array();
|
105 |
+
foreach($json as $key => $args){
|
106 |
+
|
107 |
+
$keys[] = $key;
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
// Prefix
|
112 |
+
$prefix = (count($keys) > 1) ? 'taxonomies' : 'taxonomy';
|
113 |
+
|
114 |
+
// Slugs
|
115 |
+
$slugs = implode('-', $keys);
|
116 |
+
|
117 |
+
// Date
|
118 |
+
$date = date('Y-m-d');
|
119 |
+
|
120 |
+
// file
|
121 |
+
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
122 |
+
|
123 |
+
// headers
|
124 |
+
header("Content-Description: File Transfer");
|
125 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
126 |
+
header("Content-Type: application/json; charset=utf-8");
|
127 |
+
|
128 |
+
// return
|
129 |
+
echo acf_json_encode($json);
|
130 |
+
die;
|
131 |
+
|
132 |
+
}
|
133 |
+
|
134 |
+
function get_selected(){
|
135 |
+
|
136 |
+
// vars
|
137 |
+
$selected = $this->get_selected_keys();
|
138 |
+
$json = array();
|
139 |
+
|
140 |
+
if(!$selected)
|
141 |
+
return false;
|
142 |
+
|
143 |
+
$dynamic_taxonomies = get_option('acfe_dynamic_taxonomies', array());
|
144 |
+
if(empty($dynamic_taxonomies))
|
145 |
+
return false;
|
146 |
+
|
147 |
+
// construct JSON
|
148 |
+
foreach($selected as $key){
|
149 |
+
|
150 |
+
if(!isset($dynamic_taxonomies[$key]))
|
151 |
+
continue;
|
152 |
+
|
153 |
+
// add to json array
|
154 |
+
$json[$key] = $dynamic_taxonomies[$key];
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
// return
|
159 |
+
return $json;
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
function get_selected_keys(){
|
164 |
+
|
165 |
+
// check $_POST
|
166 |
+
if($keys = acf_maybe_get_POST('keys'))
|
167 |
+
return (array) $keys;
|
168 |
+
|
169 |
+
// check $_GET
|
170 |
+
if($keys = acf_maybe_get_GET('keys')){
|
171 |
+
$keys = str_replace(' ', '+', $keys);
|
172 |
+
return explode('+', $keys);
|
173 |
+
}
|
174 |
+
|
175 |
+
// return
|
176 |
+
return false;
|
177 |
+
|
178 |
+
}
|
179 |
+
|
180 |
+
}
|
181 |
+
|
182 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_DT');
|
183 |
+
|
184 |
endif;
|
includes/admin/tools/dt-import.php
CHANGED
@@ -1,215 +1,219 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
'
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
</
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
$
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
// Check
|
59 |
-
if(
|
60 |
-
return acf_add_admin_notice(__("
|
61 |
-
|
62 |
-
//
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
//
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
//
|
90 |
-
$
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
update_field('
|
112 |
-
update_field('
|
113 |
-
update_field('
|
114 |
-
update_field('
|
115 |
-
update_field('
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
update_field('
|
134 |
-
update_field('
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
//
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
update_field('
|
146 |
-
|
147 |
-
|
148 |
-
update_field('
|
149 |
-
update_field('
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
update_field('
|
154 |
-
update_field('
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
update_field('
|
165 |
-
|
166 |
-
update_field('
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
|
|
|
|
|
|
|
|
215 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_taxonomies', true))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Import_DT')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Import_DT extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
function initialize(){
|
15 |
+
|
16 |
+
// vars
|
17 |
+
$this->name = 'acfe_tool_dt_import';
|
18 |
+
$this->title = __('Import Taxonomies');
|
19 |
+
$this->icon = 'dashicons-upload';
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function html(){
|
24 |
+
|
25 |
+
?>
|
26 |
+
<p><?php _e('Import Taxonomies', 'acf'); ?></p>
|
27 |
+
|
28 |
+
<div class="acf-fields">
|
29 |
+
<?php
|
30 |
+
|
31 |
+
acf_render_field_wrap(array(
|
32 |
+
'label' => __('Select File', 'acf'),
|
33 |
+
'type' => 'file',
|
34 |
+
'name' => 'acf_import_file',
|
35 |
+
'value' => false,
|
36 |
+
'uploader' => 'basic',
|
37 |
+
));
|
38 |
+
|
39 |
+
?>
|
40 |
+
</div>
|
41 |
+
|
42 |
+
<p class="acf-submit">
|
43 |
+
<button type="submit" name="action" class="button button-primary"><?php _e('Import File'); ?></button>
|
44 |
+
</p>
|
45 |
+
<?php
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
function submit(){
|
50 |
+
|
51 |
+
// Check file size.
|
52 |
+
if(empty($_FILES['acf_import_file']['size']))
|
53 |
+
return acf_add_admin_notice(__("No file selected", 'acf'), 'warning');
|
54 |
+
|
55 |
+
// Get file data.
|
56 |
+
$file = $_FILES['acf_import_file'];
|
57 |
+
|
58 |
+
// Check errors.
|
59 |
+
if($file['error'])
|
60 |
+
return acf_add_admin_notice(__("Error uploading file. Please try again", 'acf'), 'warning');
|
61 |
+
|
62 |
+
// Check file type.
|
63 |
+
if(pathinfo($file['name'], PATHINFO_EXTENSION) !== 'json')
|
64 |
+
return acf_add_admin_notice(__("Incorrect file type", 'acf'), 'warning');
|
65 |
+
|
66 |
+
// Read JSON.
|
67 |
+
$json = file_get_contents($file['tmp_name']);
|
68 |
+
$json = json_decode($json, true);
|
69 |
+
|
70 |
+
// Check if empty.
|
71 |
+
if(!$json || !is_array($json))
|
72 |
+
return acf_add_admin_notice(__("Import file empty", 'acf'), 'warning');
|
73 |
+
|
74 |
+
$ids = array();
|
75 |
+
|
76 |
+
$dynamic_taxonomies = get_option('acfe_dynamic_taxonomies', array());
|
77 |
+
|
78 |
+
// Loop over json
|
79 |
+
foreach($json as $taxonomy_name => $args){
|
80 |
+
|
81 |
+
// Check if already exists
|
82 |
+
if(isset($dynamic_taxonomies[$taxonomy_name])){
|
83 |
+
|
84 |
+
acf_add_admin_notice(__("Taxonomy {$dynamic_taxonomies[$taxonomy_name]['label']} already exists. Import aborted."), 'warning');
|
85 |
+
continue;
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
// Vars
|
90 |
+
$title = $args['label'];
|
91 |
+
$name = $taxonomy_name;
|
92 |
+
|
93 |
+
// Insert post
|
94 |
+
$post_id = wp_insert_post(array(
|
95 |
+
'post_title' => $title,
|
96 |
+
'post_name' => $name,
|
97 |
+
'post_type' => 'acfe-dt',
|
98 |
+
'post_status' => 'publish'
|
99 |
+
));
|
100 |
+
|
101 |
+
// Insert error
|
102 |
+
if(is_wp_error($post_id)){
|
103 |
+
|
104 |
+
acf_add_admin_notice(__("Something went wrong with the taxonomy {$title}. Import aborted."), 'warning');
|
105 |
+
continue;
|
106 |
+
|
107 |
+
}
|
108 |
+
|
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);
|
116 |
+
update_field('public', $args['public'], $post_id);
|
117 |
+
update_field('publicly_queryable', $args['publicly_queryable'], $post_id);
|
118 |
+
update_field('update_count_callback', $args['update_count_callback'], $post_id);
|
119 |
+
update_field('sort', $args['sort'], $post_id);
|
120 |
+
|
121 |
+
// Labels
|
122 |
+
if(!empty($args['labels'])){
|
123 |
+
|
124 |
+
foreach($args['labels'] as $label_key => $label_value){
|
125 |
+
|
126 |
+
update_field('labels_' . $label_key, $label_value, $post_id);
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
}
|
131 |
+
|
132 |
+
// Menu
|
133 |
+
update_field('show_ui', $args['show_ui'], $post_id);
|
134 |
+
update_field('show_in_menu', $args['show_in_menu'], $post_id);
|
135 |
+
update_field('show_in_nav_menus', $args['show_in_nav_menus'], $post_id);
|
136 |
+
update_field('show_tagcloud', $args['show_tagcloud'], $post_id);
|
137 |
+
update_field('show_in_quick_edit', $args['show_in_quick_edit'], $post_id);
|
138 |
+
update_field('show_admin_column', $args['show_admin_column'], $post_id);
|
139 |
+
|
140 |
+
// Capability
|
141 |
+
if(isset($args['capabilities']))
|
142 |
+
update_field('capabilities', acf_encode_choices($args['capabilities'], false), $post_id);
|
143 |
+
|
144 |
+
// Single
|
145 |
+
update_field('acfe_dt_single_template', $args['acfe_single_template'], $post_id);
|
146 |
+
update_field('acfe_dt_single_posts_per_page', $args['acfe_single_ppp'], $post_id);
|
147 |
+
update_field('acfe_dt_single_orderby', $args['acfe_single_orderby'], $post_id);
|
148 |
+
update_field('acfe_dt_single_order', $args['acfe_single_order'], $post_id);
|
149 |
+
update_field('rewrite', $args['rewrite'], $post_id);
|
150 |
+
|
151 |
+
// Admin
|
152 |
+
update_field('acfe_dt_admin_terms_per_page', $args['acfe_admin_ppp'], $post_id);
|
153 |
+
update_field('acfe_dt_admin_orderby', $args['acfe_admin_orderby'], $post_id);
|
154 |
+
update_field('acfe_dt_admin_order', $args['acfe_admin_order'], $post_id);
|
155 |
+
|
156 |
+
// REST
|
157 |
+
update_field('show_in_rest', $args['show_in_rest'], $post_id);
|
158 |
+
update_field('rest_base', $args['rest_base'], $post_id);
|
159 |
+
update_field('rest_controller_class', $args['rest_controller_class'], $post_id);
|
160 |
+
|
161 |
+
// Rewrite: override
|
162 |
+
if($args['rewrite'] && is_array($args['rewrite'])){
|
163 |
+
|
164 |
+
update_field('rewrite', true, $post_id);
|
165 |
+
|
166 |
+
update_field('rewrite_args_select', true, $post_id);
|
167 |
+
|
168 |
+
update_field('rewrite_args_acfe_dt_rewrite_slug', $args['rewrite']['slug'], $post_id);
|
169 |
+
update_field('rewrite_args_acfe_dt_rewrite_with_front', $args['rewrite']['with_front'], $post_id);
|
170 |
+
update_field('rewrite_args_hierarchical', $args['rewrite']['hierarchical'], $post_id);
|
171 |
+
|
172 |
+
}
|
173 |
+
|
174 |
+
// Create ACFE option
|
175 |
+
$dynamic_taxonomies[$taxonomy_name] = $args;
|
176 |
+
|
177 |
+
// Sort keys ASC
|
178 |
+
ksort($dynamic_taxonomies);
|
179 |
+
|
180 |
+
// Update ACFE option
|
181 |
+
update_option('acfe_dynamic_taxonomies', $dynamic_taxonomies);
|
182 |
+
|
183 |
+
// append message
|
184 |
+
$ids[] = $post_id;
|
185 |
+
|
186 |
+
}
|
187 |
+
|
188 |
+
if(empty($ids))
|
189 |
+
return;
|
190 |
+
|
191 |
+
// Count total
|
192 |
+
$total = count($ids);
|
193 |
+
|
194 |
+
// Generate text
|
195 |
+
$text = sprintf(_n('1 taxonomy imported', '%s taxonomies imported', $total, 'acf'), $total);
|
196 |
+
|
197 |
+
// Add links to text
|
198 |
+
$links = array();
|
199 |
+
foreach($ids as $id){
|
200 |
+
|
201 |
+
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
$text .= ': ' . implode(', ', $links);
|
206 |
+
|
207 |
+
// Add notice
|
208 |
+
acf_add_admin_notice($text, 'success');
|
209 |
+
|
210 |
+
// Flush permalinks
|
211 |
+
flush_rewrite_rules();
|
212 |
+
|
213 |
+
}
|
214 |
+
|
215 |
+
}
|
216 |
+
|
217 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Import_DT');
|
218 |
+
|
219 |
endif;
|
includes/admin/views/html-options-edit.php
CHANGED
@@ -1,61 +1,61 @@
|
|
1 |
-
<div class="wrap acf-settings-wrap">
|
2 |
-
|
3 |
-
<?php
|
4 |
-
$title = __('Edit Option');
|
5 |
-
if($_REQUEST['action']
|
6 |
-
$title = __('Add Option');
|
7 |
-
?>
|
8 |
-
<h1 class="wp-heading-inline"><?php echo $title; ?></h1>
|
9 |
-
|
10 |
-
<hr class="wp-header-end" />
|
11 |
-
|
12 |
-
<form id="post" method="post" name="post">
|
13 |
-
|
14 |
-
<?php
|
15 |
-
|
16 |
-
// render post data
|
17 |
-
acf_form_data(array(
|
18 |
-
'screen' => 'acfe-options-edit',
|
19 |
-
'post_id' => 'acfe_options_edit',
|
20 |
-
));
|
21 |
-
|
22 |
-
wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
|
23 |
-
wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
|
24 |
-
|
25 |
-
?>
|
26 |
-
|
27 |
-
<div id="poststuff">
|
28 |
-
|
29 |
-
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
|
30 |
-
|
31 |
-
<!--
|
32 |
-
<div id="post-body-content">
|
33 |
-
<div id="titlediv">
|
34 |
-
<div id="titlewrap">
|
35 |
-
<input type="text" name="post_title" size="30" value="Post 4" id="title" spellcheck="true" autocomplete="off" />
|
36 |
-
</div>
|
37 |
-
</div>
|
38 |
-
</div>
|
39 |
-
-->
|
40 |
-
|
41 |
-
<div id="postbox-container-1" class="postbox-container">
|
42 |
-
|
43 |
-
<?php do_meta_boxes('acf_options_page', 'side', null); ?>
|
44 |
-
|
45 |
-
</div>
|
46 |
-
|
47 |
-
<div id="postbox-container-2" class="postbox-container">
|
48 |
-
|
49 |
-
<?php do_meta_boxes('acf_options_page', 'normal', null); ?>
|
50 |
-
|
51 |
-
</div>
|
52 |
-
|
53 |
-
</div>
|
54 |
-
|
55 |
-
<br class="clear" />
|
56 |
-
|
57 |
-
</div>
|
58 |
-
|
59 |
-
</form>
|
60 |
-
|
61 |
</div>
|
1 |
+
<div class="wrap acf-settings-wrap">
|
2 |
+
|
3 |
+
<?php
|
4 |
+
$title = __('Edit Option');
|
5 |
+
if($_REQUEST['action'] === 'add')
|
6 |
+
$title = __('Add Option');
|
7 |
+
?>
|
8 |
+
<h1 class="wp-heading-inline"><?php echo $title; ?></h1>
|
9 |
+
|
10 |
+
<hr class="wp-header-end" />
|
11 |
+
|
12 |
+
<form id="post" method="post" name="post">
|
13 |
+
|
14 |
+
<?php
|
15 |
+
|
16 |
+
// render post data
|
17 |
+
acf_form_data(array(
|
18 |
+
'screen' => 'acfe-options-edit',
|
19 |
+
'post_id' => 'acfe_options_edit',
|
20 |
+
));
|
21 |
+
|
22 |
+
wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
|
23 |
+
wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
|
24 |
+
|
25 |
+
?>
|
26 |
+
|
27 |
+
<div id="poststuff">
|
28 |
+
|
29 |
+
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
|
30 |
+
|
31 |
+
<!--
|
32 |
+
<div id="post-body-content">
|
33 |
+
<div id="titlediv">
|
34 |
+
<div id="titlewrap">
|
35 |
+
<input type="text" name="post_title" size="30" value="Post 4" id="title" spellcheck="true" autocomplete="off" />
|
36 |
+
</div>
|
37 |
+
</div>
|
38 |
+
</div>
|
39 |
+
-->
|
40 |
+
|
41 |
+
<div id="postbox-container-1" class="postbox-container">
|
42 |
+
|
43 |
+
<?php do_meta_boxes('acf_options_page', 'side', null); ?>
|
44 |
+
|
45 |
+
</div>
|
46 |
+
|
47 |
+
<div id="postbox-container-2" class="postbox-container">
|
48 |
+
|
49 |
+
<?php do_meta_boxes('acf_options_page', 'normal', null); ?>
|
50 |
+
|
51 |
+
</div>
|
52 |
+
|
53 |
+
</div>
|
54 |
+
|
55 |
+
<br class="clear" />
|
56 |
+
|
57 |
+
</div>
|
58 |
+
|
59 |
+
</form>
|
60 |
+
|
61 |
</div>
|
includes/admin/views/html-options-list.php
CHANGED
@@ -1,38 +1,38 @@
|
|
1 |
-
<div class="wrap" id="acfe-admin-options">
|
2 |
-
|
3 |
-
<h1 class="wp-heading-inline"><?php _e('Options'); ?></h1> <span style="padding: 4px 6px;border-radius: 2px;background: #555;color: #fff;position: relative;top: -3px;font-weight: 600;margin-left: 4px;">BETA</span>
|
4 |
-
<a href="<?php echo sprintf('?page=%s&action=add', esc_attr($_REQUEST['page'])); ?>" class="page-title-action"><?php _e('Add New'); ?></a>
|
5 |
-
|
6 |
-
<hr class="wp-header-end" />
|
7 |
-
|
8 |
-
<div id="poststuff">
|
9 |
-
|
10 |
-
<div id="post-body" class="metabox-holder">
|
11 |
-
<div id="post-body-content">
|
12 |
-
<div class="meta-box-sortables ui-sortable">
|
13 |
-
<form method="post">
|
14 |
-
|
15 |
-
<?php
|
16 |
-
|
17 |
-
// WP List
|
18 |
-
$acfe_options_list = new ACFE_Admin_Options_List();
|
19 |
-
|
20 |
-
// Prepare items
|
21 |
-
$acfe_options_list->prepare_items();
|
22 |
-
|
23 |
-
$acfe_options_list->search_box('Search', 'search');
|
24 |
-
|
25 |
-
$acfe_options_list->display();
|
26 |
-
|
27 |
-
?>
|
28 |
-
|
29 |
-
</form>
|
30 |
-
</div>
|
31 |
-
</div>
|
32 |
-
</div>
|
33 |
-
|
34 |
-
<br class="clear" />
|
35 |
-
|
36 |
-
</div>
|
37 |
-
|
38 |
</div>
|
1 |
+
<div class="wrap" id="acfe-admin-options">
|
2 |
+
|
3 |
+
<h1 class="wp-heading-inline"><?php _e('Options'); ?></h1> <span style="padding: 4px 6px;border-radius: 2px;background: #555;color: #fff;position: relative;top: -3px;font-weight: 600;margin-left: 4px;">BETA</span>
|
4 |
+
<a href="<?php echo sprintf('?page=%s&action=add', esc_attr($_REQUEST['page'])); ?>" class="page-title-action"><?php _e('Add New'); ?></a>
|
5 |
+
|
6 |
+
<hr class="wp-header-end" />
|
7 |
+
|
8 |
+
<div id="poststuff">
|
9 |
+
|
10 |
+
<div id="post-body" class="metabox-holder">
|
11 |
+
<div id="post-body-content">
|
12 |
+
<div class="meta-box-sortables ui-sortable">
|
13 |
+
<form method="post">
|
14 |
+
|
15 |
+
<?php
|
16 |
+
|
17 |
+
// WP List
|
18 |
+
$acfe_options_list = new ACFE_Admin_Options_List();
|
19 |
+
|
20 |
+
// Prepare items
|
21 |
+
$acfe_options_list->prepare_items();
|
22 |
+
|
23 |
+
$acfe_options_list->search_box('Search', 'search');
|
24 |
+
|
25 |
+
$acfe_options_list->display();
|
26 |
+
|
27 |
+
?>
|
28 |
+
|
29 |
+
</form>
|
30 |
+
</div>
|
31 |
+
</div>
|
32 |
+
</div>
|
33 |
+
|
34 |
+
<br class="clear" />
|
35 |
+
|
36 |
+
</div>
|
37 |
+
|
38 |
</div>
|
includes/core/compatibility.php
CHANGED
@@ -1,55 +1,55 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Plugin: Post Types Order
|
8 |
-
* https://wordpress.org/plugins/post-types-order/
|
9 |
-
* The plugin apply custom order to 'acf-field-group' Post Type. We have to fix this
|
10 |
-
*/
|
11 |
-
add_filter('pto/posts_orderby/ignore', 'acfe_compatibility_pto_acf_field_group', 10, 3);
|
12 |
-
function acfe_compatibility_pto_acf_field_group($ignore, $orderby, $query){
|
13 |
-
|
14 |
-
if(is_admin() && $query->is_main_query() && $query->get('post_type')
|
15 |
-
$ignore = true;
|
16 |
-
|
17 |
-
return $ignore;
|
18 |
-
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Plugin: Category Order and Taxonomy Terms Order
|
23 |
-
* https://wordpress.org/plugins/taxonomy-terms-order/
|
24 |
-
* The plugin add a submenu to 'Custom Fields' to order Field Group Categories. It's unecessary
|
25 |
-
*/
|
26 |
-
add_action('admin_menu', 'acfe_compatibility_cotto_submenu', 999);
|
27 |
-
function acfe_compatibility_cotto_submenu(){
|
28 |
-
|
29 |
-
remove_submenu_page('edit.php?post_type=acf-field-group', 'to-interface-acf-field-group');
|
30 |
-
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Plugin: Rank Math SEO
|
35 |
-
* https://wordpress.org/plugins/seo-by-rank-math/
|
36 |
-
* Fix the plugin post metabox which is always above ACF metaboxes
|
37 |
-
*/
|
38 |
-
add_filter('rank_math/metabox/priority', 'acfe_compatibility_rankmath_metaboxes_priority');
|
39 |
-
function acfe_compatibility_rankmath_metaboxes_priority(){
|
40 |
-
|
41 |
-
return 'default';
|
42 |
-
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Plugin: YOAST SEO
|
47 |
-
* https://wordpress.org/plugins/wordpress-seo/
|
48 |
-
* Fix the plugin post metabox which is always above ACF metaboxes
|
49 |
-
*/
|
50 |
-
add_filter('wpseo_metabox_prio', 'acfe_compatibility_yoast_metaboxes_priority');
|
51 |
-
function acfe_compatibility_yoast_metaboxes_priority(){
|
52 |
-
|
53 |
-
return 'default';
|
54 |
-
|
55 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Plugin: Post Types Order
|
8 |
+
* https://wordpress.org/plugins/post-types-order/
|
9 |
+
* The plugin apply custom order to 'acf-field-group' Post Type. We have to fix this
|
10 |
+
*/
|
11 |
+
add_filter('pto/posts_orderby/ignore', 'acfe_compatibility_pto_acf_field_group', 10, 3);
|
12 |
+
function acfe_compatibility_pto_acf_field_group($ignore, $orderby, $query){
|
13 |
+
|
14 |
+
if(is_admin() && $query->is_main_query() && $query->get('post_type') === 'acf-field-group')
|
15 |
+
$ignore = true;
|
16 |
+
|
17 |
+
return $ignore;
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Plugin: Category Order and Taxonomy Terms Order
|
23 |
+
* https://wordpress.org/plugins/taxonomy-terms-order/
|
24 |
+
* The plugin add a submenu to 'Custom Fields' to order Field Group Categories. It's unecessary
|
25 |
+
*/
|
26 |
+
add_action('admin_menu', 'acfe_compatibility_cotto_submenu', 999);
|
27 |
+
function acfe_compatibility_cotto_submenu(){
|
28 |
+
|
29 |
+
remove_submenu_page('edit.php?post_type=acf-field-group', 'to-interface-acf-field-group');
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Plugin: Rank Math SEO
|
35 |
+
* https://wordpress.org/plugins/seo-by-rank-math/
|
36 |
+
* Fix the plugin post metabox which is always above ACF metaboxes
|
37 |
+
*/
|
38 |
+
add_filter('rank_math/metabox/priority', 'acfe_compatibility_rankmath_metaboxes_priority');
|
39 |
+
function acfe_compatibility_rankmath_metaboxes_priority(){
|
40 |
+
|
41 |
+
return 'default';
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Plugin: YOAST SEO
|
47 |
+
* https://wordpress.org/plugins/wordpress-seo/
|
48 |
+
* Fix the plugin post metabox which is always above ACF metaboxes
|
49 |
+
*/
|
50 |
+
add_filter('wpseo_metabox_prio', 'acfe_compatibility_yoast_metaboxes_priority');
|
51 |
+
function acfe_compatibility_yoast_metaboxes_priority(){
|
52 |
+
|
53 |
+
return 'default';
|
54 |
+
|
55 |
}
|
includes/core/enqueue.php
CHANGED
@@ -1,65 +1,72 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Admin: Enqueue everywhere + conditional
|
8 |
-
*/
|
9 |
-
add_action('admin_enqueue_scripts', 'acfe_enqueue_admin');
|
10 |
-
function acfe_enqueue_admin(){
|
11 |
-
|
12 |
-
// Enqueue ACF input
|
13 |
-
wp_enqueue_style('acf-input');
|
14 |
-
wp_enqueue_script('acf-input');
|
15 |
-
|
16 |
-
// ACF Extended
|
17 |
-
wp_enqueue_script('acf-extended', plugins_url('assets/acf-extended.js', ACFE_FILE), array('jquery'),
|
18 |
-
wp_enqueue_style('acf-extended', plugins_url('assets/acf-extended.css', ACFE_FILE), false,
|
19 |
-
|
20 |
-
//
|
21 |
-
if(
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
// ACF
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Admin: Enqueue everywhere + conditional
|
8 |
+
*/
|
9 |
+
add_action('admin_enqueue_scripts', 'acfe_enqueue_admin');
|
10 |
+
function acfe_enqueue_admin(){
|
11 |
+
|
12 |
+
// Enqueue ACF input
|
13 |
+
wp_enqueue_style('acf-input');
|
14 |
+
wp_enqueue_script('acf-input');
|
15 |
+
|
16 |
+
// ACF Extended
|
17 |
+
wp_enqueue_script('acf-extended', plugins_url('assets/acf-extended.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
18 |
+
wp_enqueue_style('acf-extended', plugins_url('assets/acf-extended.css', ACFE_FILE), false, ACFE_VERSION);
|
19 |
+
|
20 |
+
// Better Taxonomies
|
21 |
+
if(acf_get_setting('acfe/modules/taxonomies', true)){
|
22 |
+
|
23 |
+
wp_enqueue_style('acf-extended-taxonomies', plugins_url('assets/acf-extended-taxonomies.css', ACFE_FILE), false, ACFE_VERSION);
|
24 |
+
|
25 |
+
}
|
26 |
+
|
27 |
+
// ACF Extended: Field Groups only
|
28 |
+
if(acf_is_screen(array('edit-acf-field-group', 'acf-field-group'))){
|
29 |
+
|
30 |
+
wp_enqueue_script('acf-extended-fg', plugins_url('assets/acf-extended-fg.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
31 |
+
wp_enqueue_style('acf-extended-fg', plugins_url('assets/acf-extended-fg.css', ACFE_FILE), false, ACFE_VERSION);
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Admin: Enqueue where ACF is loaded
|
39 |
+
*/
|
40 |
+
add_action('acf/input/admin_enqueue_scripts', 'acfe_enqueue_fields');
|
41 |
+
function acfe_enqueue_fields(){
|
42 |
+
|
43 |
+
// ACF Extended: Fields
|
44 |
+
wp_enqueue_script('acf-extended-fields', plugins_url('assets/acf-extended-fields.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
45 |
+
|
46 |
+
// ACF Extended: Modal
|
47 |
+
wp_enqueue_style('acf-extended-modal', plugins_url('assets/acf-extended-modal.css', ACFE_FILE), false, ACFE_VERSION);
|
48 |
+
|
49 |
+
// Do not enqueue on ACF Field Groups views
|
50 |
+
if(acf_is_screen(array('edit-acf-field-group', 'acf-field-group')))
|
51 |
+
return;
|
52 |
+
|
53 |
+
wp_enqueue_style('acf-extended-fc', plugins_url('assets/acf-extended-fc.css', ACFE_FILE), false, ACFE_VERSION);
|
54 |
+
wp_enqueue_script('acf-extended-fc', plugins_url('assets/acf-extended-fc.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
55 |
+
|
56 |
+
// ACF Extended: Flexible Content Control
|
57 |
+
wp_enqueue_style('acf-extended-fc-control', plugins_url('assets/acf-extended-fc-control.css', ACFE_FILE), false, ACFE_VERSION);
|
58 |
+
wp_enqueue_script('acf-extended-fc-control', plugins_url('assets/acf-extended-fc-control.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
59 |
+
|
60 |
+
// ACF Extended: Flexible Content Modal Select
|
61 |
+
wp_enqueue_style('acf-extended-fc-modal-select', plugins_url('assets/acf-extended-fc-modal-select.css', ACFE_FILE), false, ACFE_VERSION);
|
62 |
+
wp_enqueue_script('acf-extended-fc-modal-select', plugins_url('assets/acf-extended-fc-modal-select.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
63 |
+
|
64 |
+
// ACF Extended: Flexible Content Modal Edit
|
65 |
+
wp_enqueue_style('acf-extended-fc-modal-edit', plugins_url('assets/acf-extended-fc-modal-edit.css', ACFE_FILE), false, ACFE_VERSION);
|
66 |
+
wp_enqueue_script('acf-extended-fc-modal-edit', plugins_url('assets/acf-extended-fc-modal-edit.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
67 |
+
|
68 |
+
acf_localize_data(array(
|
69 |
+
'close' => __('Close', 'acfe')
|
70 |
+
));
|
71 |
+
|
72 |
}
|
includes/core/helpers.php
CHANGED
@@ -1,281 +1,357 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Get Flexible
|
8 |
-
*/
|
9 |
-
if(!function_exists('get_flexible')){
|
10 |
-
|
11 |
-
function get_flexible($selector, $post_id = false){
|
12 |
-
|
13 |
-
if(!have_rows($selector, $post_id))
|
14 |
-
return;
|
15 |
-
|
16 |
-
// Vars
|
17 |
-
$field = acf_get_field($selector);
|
18 |
-
$flexible = acf_get_field_type('flexible_content');
|
19 |
-
$is_preview = false;
|
20 |
-
|
21 |
-
// Actions
|
22 |
-
do_action('acfe/flexible/enqueue', $field, $is_preview);
|
23 |
-
do_action('acfe/flexible/enqueue/name=' . $field['_name'], $field, $is_preview);
|
24 |
-
do_action('acfe/flexible/enqueue/key=' . $field['key'], $field, $is_preview);
|
25 |
-
|
26 |
-
ob_start();
|
27 |
-
|
28 |
-
while(have_rows($selector, $post_id)): the_row();
|
29 |
-
|
30 |
-
// Vars
|
31 |
-
$layout_name = get_row_layout();
|
32 |
-
$layout = $flexible->get_layout($layout_name, $field);
|
33 |
-
|
34 |
-
// Render: HTML Comment
|
35 |
-
echo "\n" . '<!-- ' . $layout['label'] . ' -->' . "\n";
|
36 |
-
|
37 |
-
// Render: Enqueue
|
38 |
-
acfe_flexible_render_layout_enqueue($layout, $field);
|
39 |
-
|
40 |
-
// Render: Template
|
41 |
-
acfe_flexible_render_layout_template($layout, $field);
|
42 |
-
|
43 |
-
endwhile;
|
44 |
-
|
45 |
-
return ob_get_clean();
|
46 |
-
|
47 |
-
}
|
48 |
-
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* The Flexible
|
53 |
-
*/
|
54 |
-
if(!function_exists('the_flexible')){
|
55 |
-
|
56 |
-
function the_flexible($selector, $post_id = false){
|
57 |
-
|
58 |
-
echo get_flexible($selector, $post_id);
|
59 |
-
|
60 |
-
}
|
61 |
-
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Has Flexible
|
66 |
-
*/
|
67 |
-
if(!function_exists('has_flexible')){
|
68 |
-
|
69 |
-
function has_flexible($selector, $post_id = false){
|
70 |
-
|
71 |
-
return have_rows($selector, $post_id);
|
72 |
-
|
73 |
-
}
|
74 |
-
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* ACFE Flexible: Render Template
|
79 |
-
*/
|
80 |
-
function acfe_flexible_render_layout_template($layout, $field){
|
81 |
-
|
82 |
-
// Vars
|
83 |
-
global $is_preview;
|
84 |
-
|
85 |
-
// Template
|
86 |
-
$acfe_flexible_render_template = false;
|
87 |
-
|
88 |
-
// Filters
|
89 |
-
$acfe_flexible_render_template = apply_filters('acfe/flexible/render/template', $acfe_flexible_render_template, $field, $layout, $is_preview);
|
90 |
-
$acfe_flexible_render_template = apply_filters('acfe/flexible/render/template/name=' . $field['_name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
91 |
-
$acfe_flexible_render_template = apply_filters('acfe/flexible/render/template/key=' . $field['key'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
92 |
-
|
93 |
-
$acfe_flexible_render_template = apply_filters('acfe/flexible/layout/render/template/layout=' . $layout['name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
94 |
-
$acfe_flexible_render_template = apply_filters('acfe/flexible/layout/render/template/name=' . $field['_name'] . '&layout=' . $layout['name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
95 |
-
$acfe_flexible_render_template = apply_filters('acfe/flexible/layout/render/template/key=' . $field['key'] . '&layout=' . $layout['name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
96 |
-
|
97 |
-
// Render: Template
|
98 |
-
if(!empty($acfe_flexible_render_template)){
|
99 |
-
|
100 |
-
$
|
101 |
-
|
102 |
-
//
|
103 |
-
if(file_exists($acfe_flexible_render_template)){
|
104 |
-
|
105 |
-
$
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
do_action('acfe/flexible/layout/enqueue/
|
137 |
-
do_action('acfe/flexible/layout/enqueue/
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
$acfe_flexible_render_style =
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
$acfe_flexible_render_style = apply_filters('acfe/flexible/
|
148 |
-
$acfe_flexible_render_style = apply_filters('acfe/flexible/
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
$
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Get Flexible
|
8 |
+
*/
|
9 |
+
if(!function_exists('get_flexible')){
|
10 |
+
|
11 |
+
function get_flexible($selector, $post_id = false){
|
12 |
+
|
13 |
+
if(!have_rows($selector, $post_id))
|
14 |
+
return;
|
15 |
+
|
16 |
+
// Vars
|
17 |
+
$field = acf_get_field($selector);
|
18 |
+
$flexible = acf_get_field_type('flexible_content');
|
19 |
+
$is_preview = false;
|
20 |
+
|
21 |
+
// Actions
|
22 |
+
do_action('acfe/flexible/enqueue', $field, $is_preview);
|
23 |
+
do_action('acfe/flexible/enqueue/name=' . $field['_name'], $field, $is_preview);
|
24 |
+
do_action('acfe/flexible/enqueue/key=' . $field['key'], $field, $is_preview);
|
25 |
+
|
26 |
+
ob_start();
|
27 |
+
|
28 |
+
while(have_rows($selector, $post_id)): the_row();
|
29 |
+
|
30 |
+
// Vars
|
31 |
+
$layout_name = get_row_layout();
|
32 |
+
$layout = $flexible->get_layout($layout_name, $field);
|
33 |
+
|
34 |
+
// Render: HTML Comment
|
35 |
+
echo "\n" . '<!-- ' . $layout['label'] . ' -->' . "\n";
|
36 |
+
|
37 |
+
// Render: Enqueue
|
38 |
+
acfe_flexible_render_layout_enqueue($layout, $field);
|
39 |
+
|
40 |
+
// Render: Template
|
41 |
+
acfe_flexible_render_layout_template($layout, $field);
|
42 |
+
|
43 |
+
endwhile;
|
44 |
+
|
45 |
+
return ob_get_clean();
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* The Flexible
|
53 |
+
*/
|
54 |
+
if(!function_exists('the_flexible')){
|
55 |
+
|
56 |
+
function the_flexible($selector, $post_id = false){
|
57 |
+
|
58 |
+
echo get_flexible($selector, $post_id);
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Has Flexible
|
66 |
+
*/
|
67 |
+
if(!function_exists('has_flexible')){
|
68 |
+
|
69 |
+
function has_flexible($selector, $post_id = false){
|
70 |
+
|
71 |
+
return have_rows($selector, $post_id);
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* ACFE Flexible: Render Template
|
79 |
+
*/
|
80 |
+
function acfe_flexible_render_layout_template($layout, $field){
|
81 |
+
|
82 |
+
// Vars
|
83 |
+
global $is_preview;
|
84 |
+
|
85 |
+
// Template
|
86 |
+
$acfe_flexible_render_template = false;
|
87 |
+
|
88 |
+
// Filters
|
89 |
+
$acfe_flexible_render_template = apply_filters('acfe/flexible/render/template', $acfe_flexible_render_template, $field, $layout, $is_preview);
|
90 |
+
$acfe_flexible_render_template = apply_filters('acfe/flexible/render/template/name=' . $field['_name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
91 |
+
$acfe_flexible_render_template = apply_filters('acfe/flexible/render/template/key=' . $field['key'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
92 |
+
|
93 |
+
$acfe_flexible_render_template = apply_filters('acfe/flexible/layout/render/template/layout=' . $layout['name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
94 |
+
$acfe_flexible_render_template = apply_filters('acfe/flexible/layout/render/template/name=' . $field['_name'] . '&layout=' . $layout['name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
95 |
+
$acfe_flexible_render_template = apply_filters('acfe/flexible/layout/render/template/key=' . $field['key'] . '&layout=' . $layout['name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
96 |
+
|
97 |
+
// Render: Template
|
98 |
+
if(!empty($acfe_flexible_render_template)){
|
99 |
+
|
100 |
+
$acfe_flexible_render_template_path = false;
|
101 |
+
|
102 |
+
// Full path
|
103 |
+
if(file_exists($acfe_flexible_render_template)){
|
104 |
+
|
105 |
+
$acfe_flexible_render_template_path = $acfe_flexible_render_template;
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
// Parent/child relative
|
110 |
+
else{
|
111 |
+
|
112 |
+
$acfe_flexible_render_template_path = locate_template(array($acfe_flexible_render_template));
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
// Include
|
117 |
+
if(!empty($acfe_flexible_render_template_path))
|
118 |
+
include($acfe_flexible_render_template_path);
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* ACFE Flexible: Render Enqueue
|
126 |
+
*/
|
127 |
+
function acfe_flexible_render_layout_enqueue($layout, $field){
|
128 |
+
|
129 |
+
// Vars
|
130 |
+
global $is_preview;
|
131 |
+
$handle = acf_slugify($field['name']) . '-layout-' . acf_slugify($layout['name']);
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Actions
|
135 |
+
*/
|
136 |
+
do_action('acfe/flexible/layout/enqueue/layout=' . $layout['name'], $field, $layout, $is_preview);
|
137 |
+
do_action('acfe/flexible/layout/enqueue/name=' . $field['_name'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
138 |
+
do_action('acfe/flexible/layout/enqueue/key=' . $field['key'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Style
|
142 |
+
*/
|
143 |
+
$acfe_flexible_render_style = false;
|
144 |
+
|
145 |
+
// Filters
|
146 |
+
$acfe_flexible_render_style = apply_filters('acfe/flexible/render/style', $acfe_flexible_render_style, $field, $layout, $is_preview);
|
147 |
+
$acfe_flexible_render_style = apply_filters('acfe/flexible/render/style/name=' . $field['_name'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
148 |
+
$acfe_flexible_render_style = apply_filters('acfe/flexible/render/style/key=' . $field['key'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
149 |
+
|
150 |
+
$acfe_flexible_render_style = apply_filters('acfe/flexible/layout/render/style/layout=' . $layout['name'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
151 |
+
$acfe_flexible_render_style = apply_filters('acfe/flexible/layout/render/style/name=' . $field['_name'] . '&layout=' . $layout['name'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
152 |
+
$acfe_flexible_render_style = apply_filters('acfe/flexible/layout/render/style/key=' . $field['key'] . '&layout=' . $layout['name'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
153 |
+
|
154 |
+
// Enqueue
|
155 |
+
if(!empty($acfe_flexible_render_style)){
|
156 |
+
|
157 |
+
$acfe_flexible_render_style_url = false;
|
158 |
+
|
159 |
+
// Full path
|
160 |
+
if(file_exists($acfe_flexible_render_style)){
|
161 |
+
|
162 |
+
$acfe_flexible_render_style_url = $acfe_flexible_render_style;
|
163 |
+
|
164 |
+
}
|
165 |
+
|
166 |
+
// Parent/child relative
|
167 |
+
else{
|
168 |
+
|
169 |
+
$acfe_flexible_render_style_url = acfe_locate_file_url(array($acfe_flexible_render_style));
|
170 |
+
|
171 |
+
}
|
172 |
+
|
173 |
+
// Include
|
174 |
+
if(!empty($acfe_flexible_render_style_url))
|
175 |
+
wp_enqueue_style($handle, $acfe_flexible_render_style_url, array(), false, 'all');
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Script
|
181 |
+
*/
|
182 |
+
$acfe_flexible_render_script = false;
|
183 |
+
|
184 |
+
// Filters
|
185 |
+
$acfe_flexible_render_script = apply_filters('acfe/flexible/render/script', $acfe_flexible_render_script, $field, $layout, $is_preview);
|
186 |
+
$acfe_flexible_render_script = apply_filters('acfe/flexible/render/script/name=' . $field['_name'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
187 |
+
$acfe_flexible_render_script = apply_filters('acfe/flexible/render/script/key=' . $field['key'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
188 |
+
|
189 |
+
$acfe_flexible_render_script = apply_filters('acfe/flexible/layout/render/script/layout=' . $layout['name'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
190 |
+
$acfe_flexible_render_script = apply_filters('acfe/flexible/layout/render/script/name=' . $field['_name'] . '&layout=' . $layout['name'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
191 |
+
$acfe_flexible_render_script = apply_filters('acfe/flexible/layout/render/script/key=' . $field['key'] . '&layout=' . $layout['name'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
192 |
+
|
193 |
+
// Enqueue
|
194 |
+
if(!empty($acfe_flexible_render_script)){
|
195 |
+
|
196 |
+
$acfe_flexible_render_script_url = false;
|
197 |
+
|
198 |
+
// Full path
|
199 |
+
if(file_exists($acfe_flexible_render_script)){
|
200 |
+
|
201 |
+
$acfe_flexible_render_script_url = $acfe_flexible_render_script;
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
// Parent/child relative
|
206 |
+
else{
|
207 |
+
|
208 |
+
$acfe_flexible_render_script_url = acfe_locate_file_url(array($acfe_flexible_render_script));
|
209 |
+
|
210 |
+
}
|
211 |
+
|
212 |
+
// Include
|
213 |
+
if(!empty($acfe_flexible_render_script_url))
|
214 |
+
wp_enqueue_script($handle, $acfe_flexible_render_script_url, array(), false, true);
|
215 |
+
|
216 |
+
}
|
217 |
+
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Get Field Group from Field
|
222 |
+
*/
|
223 |
+
function acfe_get_field_group_from_field($field){
|
224 |
+
|
225 |
+
$field_parent = $field['parent'];
|
226 |
+
|
227 |
+
if(!$field_ancestors = acf_get_field_ancestors($field))
|
228 |
+
return acf_get_field_group($field_parent);
|
229 |
+
|
230 |
+
// Reverse for DESC order (Top field first)
|
231 |
+
$field_ancestors = array_reverse($field_ancestors);
|
232 |
+
|
233 |
+
$field_top_ancestor = $field_ancestors[0];
|
234 |
+
$field_top_ancestor = acf_get_field($field_top_ancestor);
|
235 |
+
|
236 |
+
return acf_get_field_group($field_top_ancestor['parent']);
|
237 |
+
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Is Json
|
242 |
+
* Source: https://stackoverflow.com/a/6041773
|
243 |
+
*/
|
244 |
+
function acfe_is_json($string){
|
245 |
+
|
246 |
+
// in case string = 1
|
247 |
+
if(is_numeric($string))
|
248 |
+
return false;
|
249 |
+
|
250 |
+
json_decode($string);
|
251 |
+
return (json_last_error() == JSON_ERROR_NONE);
|
252 |
+
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Get Roles
|
257 |
+
*/
|
258 |
+
function acfe_get_roles(){
|
259 |
+
|
260 |
+
global $wp_roles;
|
261 |
+
$choices = array();
|
262 |
+
|
263 |
+
if(is_multisite())
|
264 |
+
$choices['super_admin'] = __('Super Admin');
|
265 |
+
|
266 |
+
foreach($wp_roles->roles as $role => $settings){
|
267 |
+
$choices[$role] = $settings['name'];
|
268 |
+
}
|
269 |
+
|
270 |
+
return $choices;
|
271 |
+
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Get Current Roles
|
276 |
+
*/
|
277 |
+
function acfe_get_current_user_roles(){
|
278 |
+
|
279 |
+
global $current_user;
|
280 |
+
|
281 |
+
if(!is_object($current_user) || !isset($current_user->roles))
|
282 |
+
return false;
|
283 |
+
|
284 |
+
$roles = $current_user->roles;
|
285 |
+
if(is_multisite() && current_user_can('setup_network'))
|
286 |
+
$roles[] = 'super_admin';
|
287 |
+
|
288 |
+
return $roles;
|
289 |
+
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Folder Exists
|
294 |
+
*/
|
295 |
+
function acfe_folder_exists($folder){
|
296 |
+
|
297 |
+
if(!is_dir(ACFE_THEME_PATH . '/' . $folder))
|
298 |
+
return false;
|
299 |
+
|
300 |
+
return true;
|
301 |
+
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Array Keys Recursive
|
306 |
+
*/
|
307 |
+
function acfe_array_keys_r($array){
|
308 |
+
|
309 |
+
$keys = array_keys($array);
|
310 |
+
|
311 |
+
foreach($array as $i){
|
312 |
+
|
313 |
+
if(!is_array($i))
|
314 |
+
continue;
|
315 |
+
|
316 |
+
$keys = array_merge($keys, acfe_array_keys_r($i));
|
317 |
+
|
318 |
+
}
|
319 |
+
|
320 |
+
return $keys;
|
321 |
+
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Locate File URL
|
326 |
+
* Check if file exists locally and return URL (supports parent/child theme)
|
327 |
+
*/
|
328 |
+
function acfe_locate_file_url($filenames){
|
329 |
+
|
330 |
+
$located = '';
|
331 |
+
|
332 |
+
foreach((array) $filenames as $filename){
|
333 |
+
|
334 |
+
if(!$filename)
|
335 |
+
continue;
|
336 |
+
|
337 |
+
// Child
|
338 |
+
if(file_exists(STYLESHEETPATH . '/' . $filename)){
|
339 |
+
|
340 |
+
$located = get_stylesheet_directory_uri() . '/' . $filename;
|
341 |
+
break;
|
342 |
+
|
343 |
+
}
|
344 |
+
|
345 |
+
// Parent
|
346 |
+
elseif(file_exists(TEMPLATEPATH . '/' . $filename)){
|
347 |
+
|
348 |
+
$located = get_template_directory_uri() . '/' . $filename;
|
349 |
+
break;
|
350 |
+
|
351 |
+
}
|
352 |
+
|
353 |
+
}
|
354 |
+
|
355 |
+
return $located;
|
356 |
+
|
357 |
}
|
includes/core/menu.php
CHANGED
@@ -1,85 +1,99 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
add_action('admin_menu', 'acfe_admin_settings_submenu_swap', 999);
|
7 |
-
function acfe_admin_settings_submenu_swap(){
|
8 |
-
|
9 |
-
global $submenu;
|
10 |
-
|
11 |
-
if(!isset($submenu['edit.php?post_type=acf-field-group']) || empty($submenu['edit.php?post_type=acf-field-group']))
|
12 |
-
return;
|
13 |
-
|
14 |
-
$temp_category = false;
|
15 |
-
$temp_category_key = false;
|
16 |
-
|
17 |
-
$temp_settings = false;
|
18 |
-
$temp_settings_key = false;
|
19 |
-
|
20 |
-
$
|
21 |
-
$
|
22 |
-
|
23 |
-
$
|
24 |
-
$
|
25 |
-
|
26 |
-
$
|
27 |
-
$
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
$
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
$submenu['edit.php?post_type=acf-field-group'][$
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
add_action('admin_menu', 'acfe_admin_settings_submenu_swap', 999);
|
7 |
+
function acfe_admin_settings_submenu_swap(){
|
8 |
+
|
9 |
+
global $submenu;
|
10 |
+
|
11 |
+
if(!isset($submenu['edit.php?post_type=acf-field-group']) || empty($submenu['edit.php?post_type=acf-field-group']))
|
12 |
+
return;
|
13 |
+
|
14 |
+
$temp_category = false;
|
15 |
+
$temp_category_key = false;
|
16 |
+
|
17 |
+
$temp_settings = false;
|
18 |
+
$temp_settings_key = false;
|
19 |
+
|
20 |
+
$temp_tools = false;
|
21 |
+
$temp_tools_key = false;
|
22 |
+
|
23 |
+
$temp_infos = false;
|
24 |
+
$temp_infos_key = false;
|
25 |
+
|
26 |
+
$temp_block_type = false;
|
27 |
+
$temp_block_type_key = false;
|
28 |
+
|
29 |
+
$temp_options = false;
|
30 |
+
$temp_options_key = false;
|
31 |
+
|
32 |
+
foreach($submenu['edit.php?post_type=acf-field-group'] as $ikey => $item){
|
33 |
+
|
34 |
+
// ACFE: Field Group Category
|
35 |
+
if($item[2] === 'edit-tags.php?taxonomy=acf-field-group-category'){
|
36 |
+
$temp_category = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
37 |
+
$temp_category_key = $ikey;
|
38 |
+
}
|
39 |
+
|
40 |
+
// ACFE: Settings
|
41 |
+
elseif($item[2] === 'acfe-settings'){
|
42 |
+
$temp_settings = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
43 |
+
$temp_settings_key = $ikey;
|
44 |
+
}
|
45 |
+
|
46 |
+
// Tools
|
47 |
+
elseif($item[2] === 'acf-tools'){
|
48 |
+
$temp_tools = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
49 |
+
$temp_tools_key = $ikey;
|
50 |
+
}
|
51 |
+
|
52 |
+
// Infos
|
53 |
+
elseif($item[2] === 'acf-settings-info'){
|
54 |
+
$temp_infos = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
55 |
+
$temp_infos_key = $ikey;
|
56 |
+
}
|
57 |
+
|
58 |
+
// Block Types
|
59 |
+
elseif($item[2] === 'edit.php?post_type=acfe-dbt'){
|
60 |
+
$temp_block_type = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
61 |
+
$temp_block_type_key = $ikey;
|
62 |
+
}
|
63 |
+
|
64 |
+
// Options Pages
|
65 |
+
elseif($item[2] === 'edit.php?post_type=acfe-dop'){
|
66 |
+
$temp_options = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
67 |
+
$temp_options_key = $ikey;
|
68 |
+
}
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
// Swapping
|
73 |
+
if($temp_tools_key !== false)
|
74 |
+
$submenu['edit.php?post_type=acf-field-group'][$temp_tools_key] = $temp_category;
|
75 |
+
|
76 |
+
if($temp_category_key !== false)
|
77 |
+
$submenu['edit.php?post_type=acf-field-group'][$temp_category_key] = $temp_settings;
|
78 |
+
|
79 |
+
if($temp_settings_key !== false)
|
80 |
+
$submenu['edit.php?post_type=acf-field-group'][$temp_settings_key] = $temp_options;
|
81 |
+
|
82 |
+
if($temp_options_key !== false)
|
83 |
+
$submenu['edit.php?post_type=acf-field-group'][$temp_options_key] = $temp_infos;
|
84 |
+
|
85 |
+
if($temp_infos_key !== false)
|
86 |
+
$submenu['edit.php?post_type=acf-field-group'][$temp_infos_key] = $temp_tools;
|
87 |
+
|
88 |
+
// ACF Pro 5.8 Block Types
|
89 |
+
if($temp_block_type_key !== false){
|
90 |
+
|
91 |
+
if($temp_infos_key !== false)
|
92 |
+
$submenu['edit.php?post_type=acf-field-group'][$temp_infos_key] = $temp_block_type;
|
93 |
+
|
94 |
+
if($temp_block_type_key !== false)
|
95 |
+
$submenu['edit.php?post_type=acf-field-group'][$temp_block_type_key] = $temp_tools;
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
}
|
includes/field-groups/field-group-category.php
CHANGED
@@ -1,147 +1,147 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
add_action('init', 'acfe_field_group_category_register');
|
7 |
-
function acfe_field_group_category_register(){
|
8 |
-
|
9 |
-
register_taxonomy('acf-field-group-category', array('acf-field-group'), array(
|
10 |
-
'hierarchical' => true,
|
11 |
-
'public' => false,
|
12 |
-
'show_ui' => 'ACFE',
|
13 |
-
'show_admin_column' => true,
|
14 |
-
'show_in_menu' => true,
|
15 |
-
'show_in_nav_menus' => true,
|
16 |
-
'show_tagcloud' => false,
|
17 |
-
'rewrite' => false,
|
18 |
-
'labels' => array(
|
19 |
-
'name' => _x('Categories', 'Category'),
|
20 |
-
'singular_name' => _x('Categories', 'Category'),
|
21 |
-
'search_items' => __('Search categories', 'acfe'),
|
22 |
-
'all_items' => __('All categories', 'acfe'),
|
23 |
-
'parent_item' => __('Parent category', 'acfe'),
|
24 |
-
'parent_item_colon' => __('Parent category:', 'acfe'),
|
25 |
-
'edit_item' => __('Edit category', 'acfe'),
|
26 |
-
'update_item' => __('Update category', 'acfe'),
|
27 |
-
'add_new_item' => __('Add New category', 'acfe'),
|
28 |
-
'new_item_name' => __('New category name', 'acfe'),
|
29 |
-
'menu_name' => __('category', 'acfe'),
|
30 |
-
),
|
31 |
-
));
|
32 |
-
|
33 |
-
}
|
34 |
-
|
35 |
-
add_action('admin_menu', 'acfe_field_group_category_submenu');
|
36 |
-
function acfe_field_group_category_submenu(){
|
37 |
-
|
38 |
-
if(!acf_get_setting('show_admin'))
|
39 |
-
return;
|
40 |
-
|
41 |
-
add_submenu_page('edit.php?post_type=acf-field-group', __('Categories'), __('Categories'), acf_get_setting('capability'), 'edit-tags.php?taxonomy=acf-field-group-category');
|
42 |
-
|
43 |
-
}
|
44 |
-
|
45 |
-
add_filter('parent_file', 'acfe_field_group_category_submenu_highlight');
|
46 |
-
function acfe_field_group_category_submenu_highlight($parent_file){
|
47 |
-
|
48 |
-
global $submenu_file, $current_screen, $pagenow;
|
49 |
-
|
50 |
-
if($current_screen->taxonomy
|
51 |
-
$parent_file = 'edit.php?post_type=acf-field-group';
|
52 |
-
|
53 |
-
return $parent_file;
|
54 |
-
|
55 |
-
}
|
56 |
-
|
57 |
-
add_filter('manage_edit-acf-field-group_columns', 'acfe_field_group_category_column', 11);
|
58 |
-
function acfe_field_group_category_column($columns){
|
59 |
-
|
60 |
-
$new_columns = array();
|
61 |
-
foreach($columns as $key => $value) {
|
62 |
-
if($key
|
63 |
-
$new_columns['acf-field-group-category'] = __('Categories');
|
64 |
-
|
65 |
-
$new_columns[$key] = $value;
|
66 |
-
}
|
67 |
-
|
68 |
-
return $new_columns;
|
69 |
-
|
70 |
-
}
|
71 |
-
|
72 |
-
add_action('manage_acf-field-group_posts_custom_column' , 'acfe_field_group_category_column_html', 10, 2);
|
73 |
-
function acfe_field_group_category_column_html($column, $post_id){
|
74 |
-
|
75 |
-
if($column
|
76 |
-
if(!$terms = get_the_terms($post_id, 'acf-field-group-category')){
|
77 |
-
echo '—';
|
78 |
-
return;
|
79 |
-
}
|
80 |
-
|
81 |
-
$categories = array();
|
82 |
-
foreach($terms as $term){
|
83 |
-
$categories[] = '<a href="' . admin_url('edit.php?acf-field-group-category='.$term->slug.'&post_type=acf-field-group') . '">' . $term->name . '</a>';
|
84 |
-
}
|
85 |
-
|
86 |
-
echo implode(' ', $categories);
|
87 |
-
}
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
add_filter('views_edit-acf-field-group', 'acfe_field_group_category_views', 9);
|
92 |
-
function acfe_field_group_category_views($views){
|
93 |
-
|
94 |
-
if(!$terms = get_terms('acf-field-group-category', array('hide_empty' => false)))
|
95 |
-
return $views;
|
96 |
-
|
97 |
-
foreach($terms as $term){
|
98 |
-
|
99 |
-
$groups = get_posts( array(
|
100 |
-
'post_type' => 'acf-field-group',
|
101 |
-
'posts_per_page' => -1,
|
102 |
-
'suppress_filters' => false,
|
103 |
-
'post_status' => array('publish', 'acf-disabled'),
|
104 |
-
'taxonomy' => 'acf-field-group-category',
|
105 |
-
'term' => $term->slug,
|
106 |
-
'fields' => 'ids'
|
107 |
-
));
|
108 |
-
|
109 |
-
$count = count($groups);
|
110 |
-
|
111 |
-
$html = '';
|
112 |
-
if($count > 0)
|
113 |
-
$html = ' <span class="count">(' . $count . ')</span>';
|
114 |
-
|
115 |
-
global $wp_query;
|
116 |
-
$class = '';
|
117 |
-
if(isset($wp_query->query_vars['acf-field-group-category']) && $wp_query->query_vars['acf-field-group-category']
|
118 |
-
$class = ' class="current"';
|
119 |
-
|
120 |
-
$views['category-' . $term->slug] = '<a href="' . admin_url('edit.php?acf-field-group-category=' . $term->slug . '&post_type=acf-field-group') . '"' . $class . '>' . $term->name . $html . '</a>';
|
121 |
-
}
|
122 |
-
|
123 |
-
return $views;
|
124 |
-
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* ACF Exclude Field Group Category from available taxonomies
|
129 |
-
*/
|
130 |
-
add_filter('acf/get_taxonomies', 'acfe_field_group_category_exclude', 10, 2);
|
131 |
-
function acfe_field_group_category_exclude($taxonomies, $args){
|
132 |
-
|
133 |
-
if(empty($taxonomies))
|
134 |
-
return $taxonomies;
|
135 |
-
|
136 |
-
foreach($taxonomies as $k => $taxonomy){
|
137 |
-
|
138 |
-
if($taxonomy != 'acf-field-group-category')
|
139 |
-
continue;
|
140 |
-
|
141 |
-
unset($taxonomies[$k]);
|
142 |
-
|
143 |
-
}
|
144 |
-
|
145 |
-
return $taxonomies;
|
146 |
-
|
147 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
add_action('init', 'acfe_field_group_category_register');
|
7 |
+
function acfe_field_group_category_register(){
|
8 |
+
|
9 |
+
register_taxonomy('acf-field-group-category', array('acf-field-group'), array(
|
10 |
+
'hierarchical' => true,
|
11 |
+
'public' => false,
|
12 |
+
'show_ui' => 'ACFE',
|
13 |
+
'show_admin_column' => true,
|
14 |
+
'show_in_menu' => true,
|
15 |
+
'show_in_nav_menus' => true,
|
16 |
+
'show_tagcloud' => false,
|
17 |
+
'rewrite' => false,
|
18 |
+
'labels' => array(
|
19 |
+
'name' => _x('Categories', 'Category'),
|
20 |
+
'singular_name' => _x('Categories', 'Category'),
|
21 |
+
'search_items' => __('Search categories', 'acfe'),
|
22 |
+
'all_items' => __('All categories', 'acfe'),
|
23 |
+
'parent_item' => __('Parent category', 'acfe'),
|
24 |
+
'parent_item_colon' => __('Parent category:', 'acfe'),
|
25 |
+
'edit_item' => __('Edit category', 'acfe'),
|
26 |
+
'update_item' => __('Update category', 'acfe'),
|
27 |
+
'add_new_item' => __('Add New category', 'acfe'),
|
28 |
+
'new_item_name' => __('New category name', 'acfe'),
|
29 |
+
'menu_name' => __('category', 'acfe'),
|
30 |
+
),
|
31 |
+
));
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
add_action('admin_menu', 'acfe_field_group_category_submenu');
|
36 |
+
function acfe_field_group_category_submenu(){
|
37 |
+
|
38 |
+
if(!acf_get_setting('show_admin'))
|
39 |
+
return;
|
40 |
+
|
41 |
+
add_submenu_page('edit.php?post_type=acf-field-group', __('Categories'), __('Categories'), acf_get_setting('capability'), 'edit-tags.php?taxonomy=acf-field-group-category');
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
add_filter('parent_file', 'acfe_field_group_category_submenu_highlight');
|
46 |
+
function acfe_field_group_category_submenu_highlight($parent_file){
|
47 |
+
|
48 |
+
global $submenu_file, $current_screen, $pagenow;
|
49 |
+
|
50 |
+
if($current_screen->taxonomy === 'acf-field-group-category' && ($pagenow === 'edit-tags.php' || $pagenow === 'term.php'))
|
51 |
+
$parent_file = 'edit.php?post_type=acf-field-group';
|
52 |
+
|
53 |
+
return $parent_file;
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
add_filter('manage_edit-acf-field-group_columns', 'acfe_field_group_category_column', 11);
|
58 |
+
function acfe_field_group_category_column($columns){
|
59 |
+
|
60 |
+
$new_columns = array();
|
61 |
+
foreach($columns as $key => $value) {
|
62 |
+
if($key === 'title')
|
63 |
+
$new_columns['acf-field-group-category'] = __('Categories');
|
64 |
+
|
65 |
+
$new_columns[$key] = $value;
|
66 |
+
}
|
67 |
+
|
68 |
+
return $new_columns;
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
add_action('manage_acf-field-group_posts_custom_column' , 'acfe_field_group_category_column_html', 10, 2);
|
73 |
+
function acfe_field_group_category_column_html($column, $post_id){
|
74 |
+
|
75 |
+
if($column === 'acf-field-group-category'){
|
76 |
+
if(!$terms = get_the_terms($post_id, 'acf-field-group-category')){
|
77 |
+
echo '—';
|
78 |
+
return;
|
79 |
+
}
|
80 |
+
|
81 |
+
$categories = array();
|
82 |
+
foreach($terms as $term){
|
83 |
+
$categories[] = '<a href="' . admin_url('edit.php?acf-field-group-category='.$term->slug.'&post_type=acf-field-group') . '">' . $term->name . '</a>';
|
84 |
+
}
|
85 |
+
|
86 |
+
echo implode(' ', $categories);
|
87 |
+
}
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
add_filter('views_edit-acf-field-group', 'acfe_field_group_category_views', 9);
|
92 |
+
function acfe_field_group_category_views($views){
|
93 |
+
|
94 |
+
if(!$terms = get_terms('acf-field-group-category', array('hide_empty' => false)))
|
95 |
+
return $views;
|
96 |
+
|
97 |
+
foreach($terms as $term){
|
98 |
+
|
99 |
+
$groups = get_posts( array(
|
100 |
+
'post_type' => 'acf-field-group',
|
101 |
+
'posts_per_page' => -1,
|
102 |
+
'suppress_filters' => false,
|
103 |
+
'post_status' => array('publish', 'acf-disabled'),
|
104 |
+
'taxonomy' => 'acf-field-group-category',
|
105 |
+
'term' => $term->slug,
|
106 |
+
'fields' => 'ids'
|
107 |
+
));
|
108 |
+
|
109 |
+
$count = count($groups);
|
110 |
+
|
111 |
+
$html = '';
|
112 |
+
if($count > 0)
|
113 |
+
$html = ' <span class="count">(' . $count . ')</span>';
|
114 |
+
|
115 |
+
global $wp_query;
|
116 |
+
$class = '';
|
117 |
+
if(isset($wp_query->query_vars['acf-field-group-category']) && $wp_query->query_vars['acf-field-group-category'] === $term->slug)
|
118 |
+
$class = ' class="current"';
|
119 |
+
|
120 |
+
$views['category-' . $term->slug] = '<a href="' . admin_url('edit.php?acf-field-group-category=' . $term->slug . '&post_type=acf-field-group') . '"' . $class . '>' . $term->name . $html . '</a>';
|
121 |
+
}
|
122 |
+
|
123 |
+
return $views;
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* ACF Exclude Field Group Category from available taxonomies
|
129 |
+
*/
|
130 |
+
add_filter('acf/get_taxonomies', 'acfe_field_group_category_exclude', 10, 2);
|
131 |
+
function acfe_field_group_category_exclude($taxonomies, $args){
|
132 |
+
|
133 |
+
if(empty($taxonomies))
|
134 |
+
return $taxonomies;
|
135 |
+
|
136 |
+
foreach($taxonomies as $k => $taxonomy){
|
137 |
+
|
138 |
+
if($taxonomy != 'acf-field-group-category')
|
139 |
+
continue;
|
140 |
+
|
141 |
+
unset($taxonomies[$k]);
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
return $taxonomies;
|
146 |
+
|
147 |
}
|
includes/field-groups/field-group.php
CHANGED
@@ -1,469 +1,469 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Field Group Options: Note
|
8 |
-
*/
|
9 |
-
add_action('acf/render_field_group_settings', 'acfe_render_field_group_options');
|
10 |
-
function acfe_render_field_group_options($field_group){
|
11 |
-
|
12 |
-
acf_render_field_wrap(array(
|
13 |
-
'label' => __('Note'),
|
14 |
-
'name' => 'acfe_note',
|
15 |
-
'prefix' => 'acf_field_group',
|
16 |
-
'type' => 'textarea',
|
17 |
-
'instructions' => __('Personal note. Only visible to administrators'),
|
18 |
-
'value' => (isset($field_group['acfe_note'])) ? $field_group['acfe_note'] : '',
|
19 |
-
'required' => false,
|
20 |
-
));
|
21 |
-
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Field Group Options: Data
|
26 |
-
*/
|
27 |
-
add_action('acf/field_group/admin_head', 'acfe_render_field_group_settings');
|
28 |
-
function acfe_render_field_group_settings(){
|
29 |
-
|
30 |
-
add_meta_box('acf-field-group-acfe', __('Data', 'acfe'), function(){
|
31 |
-
|
32 |
-
global $field_group;
|
33 |
-
|
34 |
-
acf_render_field_wrap(array(
|
35 |
-
'label' => __('Custom meta data'),
|
36 |
-
'name' => 'acfe_meta',
|
37 |
-
'key' => 'acfe_meta',
|
38 |
-
'instructions' => '',
|
39 |
-
'prefix' => 'acf_field_group',
|
40 |
-
'type' => 'repeater',
|
41 |
-
'button_label' => __('+ Add row'),
|
42 |
-
'required' => false,
|
43 |
-
'layout' => 'table',
|
44 |
-
'value' => (isset($field_group['acfe_meta'])) ? $field_group['acfe_meta'] : array(),
|
45 |
-
'sub_fields' => array(
|
46 |
-
array(
|
47 |
-
'label' => __('Key'),
|
48 |
-
'name' => 'acfe_meta_key',
|
49 |
-
'key' => 'acfe_meta_key',
|
50 |
-
'prefix' => '',
|
51 |
-
'_name' => '',
|
52 |
-
'_prepare' => '',
|
53 |
-
'type' => 'text',
|
54 |
-
'instructions' => false,
|
55 |
-
'required' => false,
|
56 |
-
'wrapper' => array(
|
57 |
-
'width' => '',
|
58 |
-
'class' => '',
|
59 |
-
'id' => '',
|
60 |
-
),
|
61 |
-
),
|
62 |
-
array(
|
63 |
-
'label' => __('Value'),
|
64 |
-
'name' => 'acfe_meta_value',
|
65 |
-
'key' => 'acfe_meta_value',
|
66 |
-
'prefix' => '',
|
67 |
-
'_name' => '',
|
68 |
-
'_prepare' => '',
|
69 |
-
'type' => 'text',
|
70 |
-
'instructions' => false,
|
71 |
-
'required' => false,
|
72 |
-
'wrapper' => array(
|
73 |
-
'width' => '',
|
74 |
-
'class' => '',
|
75 |
-
'id' => '',
|
76 |
-
),
|
77 |
-
),
|
78 |
-
)
|
79 |
-
));
|
80 |
-
|
81 |
-
acf_render_field_wrap(array(
|
82 |
-
'label' => __('Field group data'),
|
83 |
-
'instructions' => __('View raw data'),
|
84 |
-
'type' => 'acfe_dynamic_message',
|
85 |
-
'name' => 'acfe_data',
|
86 |
-
'prefix' => 'acf_field_group',
|
87 |
-
'value' => $field_group['key'],
|
88 |
-
));
|
89 |
-
|
90 |
-
?>
|
91 |
-
<script type="text/javascript">
|
92 |
-
if(typeof acf !== 'undefined'){
|
93 |
-
acf.postbox.render({
|
94 |
-
'id': 'acf-field-group-acfe',
|
95 |
-
'label': 'left'
|
96 |
-
});
|
97 |
-
}
|
98 |
-
|
99 |
-
jQuery(document).ready(function($){
|
100 |
-
$('#post_name').on('keyup', function(){
|
101 |
-
var val = $(this).val();
|
102 |
-
if(!val.startsWith('group_')){
|
103 |
-
var val = 'group_' + val;
|
104 |
-
$(this).val(val);
|
105 |
-
}
|
106 |
-
|
107 |
-
$('[name="acf_field_group[key]"]').val(val);
|
108 |
-
$('.misc-pub-acfe-field-group-key code').html(val);
|
109 |
-
});
|
110 |
-
});
|
111 |
-
</script>
|
112 |
-
<?php
|
113 |
-
}, 'acf-field-group', 'normal');
|
114 |
-
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Field Group Options: Sidebar - Submit Div
|
119 |
-
*/
|
120 |
-
add_action('post_submitbox_misc_actions', 'acfe_render_field_group_submitbox');
|
121 |
-
function acfe_render_field_group_submitbox(){
|
122 |
-
|
123 |
-
if(get_post_type(get_the_ID()) !== 'acf-field-group')
|
124 |
-
return;
|
125 |
-
|
126 |
-
$field_group = acf_get_field_group(get_the_ID());
|
127 |
-
?>
|
128 |
-
<div class="misc-pub-section misc-pub-acfe-field-group-key">
|
129 |
-
<span style="font-size:16px;color: #82878c;" class="dashicons dashicons-tag"></span> <code style="font-size: 12px;"><?php echo $field_group['key']; ?></code>
|
130 |
-
</div>
|
131 |
-
<script type="text/javascript">
|
132 |
-
(function($) {
|
133 |
-
$('.misc-pub-acfe-field-group-key').insertBefore('.misc-pub-post-status');
|
134 |
-
})(jQuery);
|
135 |
-
</script>
|
136 |
-
<?php
|
137 |
-
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Field Group Options: Sidebar
|
142 |
-
*/
|
143 |
-
add_action('acf/field_group/admin_head', 'acfe_render_field_group_settings_side');
|
144 |
-
function acfe_render_field_group_settings_side(){
|
145 |
-
|
146 |
-
add_meta_box('acf-field-group-acfe-side', __('Advanced Settings', 'acfe'), function(){
|
147 |
-
|
148 |
-
// Global
|
149 |
-
global $field_group;
|
150 |
-
|
151 |
-
// Proxy
|
152 |
-
$_field_group = $field_group;
|
153 |
-
|
154 |
-
acf_render_field_wrap(array(
|
155 |
-
'label' => __('Display title', 'acfe'),
|
156 |
-
'instructions' => __('Render this title on edit post screen', 'acfe'),
|
157 |
-
'type' => 'text',
|
158 |
-
'name' => 'acfe_display_title',
|
159 |
-
'prefix' => 'acf_field_group',
|
160 |
-
'value' => (isset($field_group['acfe_display_title'])) ? $field_group['acfe_display_title'] : '',
|
161 |
-
'placeholder' => '',
|
162 |
-
'prepend' => '',
|
163 |
-
'append' => ''
|
164 |
-
));
|
165 |
-
|
166 |
-
if(acfe_is_field_group_json_desync($field_group)){
|
167 |
-
acf_render_field_wrap(array(
|
168 |
-
'label' => __('Json Desync'),
|
169 |
-
'instructions' => __('Local json file is different from this version. If you manually synchronize it, you will lose your current field group settings'),
|
170 |
-
'type' => 'acfe_dynamic_message',
|
171 |
-
'name' => 'acfe_sync_available',
|
172 |
-
'prefix' => 'acf_field_group',
|
173 |
-
'value' => $field_group['key'],
|
174 |
-
));
|
175 |
-
}
|
176 |
-
|
177 |
-
|
178 |
-
$force_json_sync = false;
|
179 |
-
$json_text = 'Json';
|
180 |
-
|
181 |
-
if(acfe_has_field_group_autosync_file($_field_group, 'json')){
|
182 |
-
|
183 |
-
if(isset($_field_group['acfe_autosync']) && is_array($_field_group['acfe_autosync']))
|
184 |
-
$_field_group['acfe_autosync'][] = 'json';
|
185 |
-
else
|
186 |
-
$_field_group['acfe_autosync'] = array('json');
|
187 |
-
|
188 |
-
$json_text = '<span class="acf-js-tooltip" title="To disable the Json Sync you must manually delete the file: '.$_field_group['key'].'.json">Json</span>';
|
189 |
-
|
190 |
-
$force_json_sync = true;
|
191 |
-
|
192 |
-
}
|
193 |
-
|
194 |
-
$force_php_sync = false;
|
195 |
-
$php_text = 'PHP';
|
196 |
-
acf_enable_filter('local');
|
197 |
-
|
198 |
-
if(acfe_has_field_group_autosync_file($_field_group, 'php')){
|
199 |
-
|
200 |
-
acf_disable_filter('local');
|
201 |
-
|
202 |
-
if(isset($_field_group['acfe_autosync']) && is_array($_field_group['acfe_autosync']))
|
203 |
-
$_field_group['acfe_autosync'][] = 'php';
|
204 |
-
else
|
205 |
-
$_field_group['acfe_autosync'] = array('php');
|
206 |
-
|
207 |
-
$php_text = '<span class="acf-js-tooltip" title="To disable the PHP Sync you must manually delete the file: '.$_field_group['key'].'.php">PHP</span>';
|
208 |
-
|
209 |
-
$force_php_sync = true;
|
210 |
-
|
211 |
-
}
|
212 |
-
|
213 |
-
acf_render_field_wrap(array(
|
214 |
-
'label' => __('Auto Sync'),
|
215 |
-
'instructions' => '',
|
216 |
-
'type' => 'checkbox',
|
217 |
-
'name' => 'acfe_autosync',
|
218 |
-
'prefix' => 'acf_field_group',
|
219 |
-
'value' => (isset($_field_group['acfe_autosync']) && !empty($_field_group['acfe_autosync'])) ? $_field_group['acfe_autosync'] : array(),
|
220 |
-
'choices' => array(
|
221 |
-
'php' => $php_text,
|
222 |
-
'json' => $json_text,
|
223 |
-
)
|
224 |
-
));
|
225 |
-
|
226 |
-
acf_render_field_wrap(array(
|
227 |
-
'label' => __('Permissions'),
|
228 |
-
'name' => 'acfe_permissions',
|
229 |
-
'prefix' => 'acf_field_group',
|
230 |
-
'type' => 'checkbox',
|
231 |
-
'instructions' => __('Select user roles that are allowed to view and edit this field group in post edition'),
|
232 |
-
'required' => false,
|
233 |
-
'default_value' => false,
|
234 |
-
'choices' => acfe_get_roles(),
|
235 |
-
'value' => (isset($field_group['acfe_permissions'])) ? $field_group['acfe_permissions'] : array(),
|
236 |
-
'layout' => 'vertical'
|
237 |
-
));
|
238 |
-
|
239 |
-
?>
|
240 |
-
<script type="text/javascript">
|
241 |
-
if(typeof acf !== 'undefined'){
|
242 |
-
acf.postbox.render({
|
243 |
-
'id': 'acf-field-group-acfe-side',
|
244 |
-
'label': 'top'
|
245 |
-
});
|
246 |
-
}
|
247 |
-
|
248 |
-
(function($){
|
249 |
-
|
250 |
-
<?php if($force_json_sync){ ?>
|
251 |
-
|
252 |
-
$('#acf_field_group-acfe_autosync-json').prop('readonly', true).addClass('disabled').click(function(){
|
253 |
-
return false;
|
254 |
-
});
|
255 |
-
|
256 |
-
$('#acf_field_group-acfe_autosync-json').closest('label').css('color', '#999');
|
257 |
-
|
258 |
-
<?php } ?>
|
259 |
-
|
260 |
-
<?php if($force_php_sync){ ?>
|
261 |
-
|
262 |
-
$('#acf_field_group-acfe_autosync-php').prop('readonly', true).addClass('disabled').click(function(){
|
263 |
-
return false;
|
264 |
-
});
|
265 |
-
|
266 |
-
$('#acf_field_group-acfe_autosync-php').closest('label').css('color', '#999');
|
267 |
-
|
268 |
-
<?php } ?>
|
269 |
-
|
270 |
-
if($('[data-name=acfe_sync_available]').length){
|
271 |
-
|
272 |
-
if($('[data-name=acfe_sync_available]').find('[data-acfe-autosync-json-active]').attr('data-acfe-autosync-json-active')
|
273 |
-
$('#acf_field_group-acfe_autosync-json').change(function(e){
|
274 |
-
if($(this).prop('checked')){
|
275 |
-
if(!confirm('Local json file was found and is different from this version.' + "\n" + 'Enabling json auto sync will erase the local file with the current field group settings')){
|
276 |
-
$(this).prop('checked', false);
|
277 |
-
return false;
|
278 |
-
}
|
279 |
-
}
|
280 |
-
});
|
281 |
-
}
|
282 |
-
|
283 |
-
else{
|
284 |
-
|
285 |
-
$('#publish').click(function(e){
|
286 |
-
if(!confirm('Local json file was found and is different from this version.' + "\n" + 'Proceed to erase the local file with the current field group settings'))
|
287 |
-
e.preventDefault();
|
288 |
-
});
|
289 |
-
|
290 |
-
}
|
291 |
-
}
|
292 |
-
})(jQuery);
|
293 |
-
</script>
|
294 |
-
<?php
|
295 |
-
}, 'acf-field-group', 'side');
|
296 |
-
|
297 |
-
}
|
298 |
-
|
299 |
-
/**
|
300 |
-
* Render: Sync Available
|
301 |
-
*/
|
302 |
-
add_action('acf/render_field/name=acfe_sync_available', 'acfe_render_field_sync_available');
|
303 |
-
function acfe_render_field_sync_available($field){
|
304 |
-
|
305 |
-
$field_group = acf_get_field_group($field['value']);
|
306 |
-
|
307 |
-
$acfe_autosync_active = 0;
|
308 |
-
if(isset($field_group['acfe_autosync']) && is_array($field_group['acfe_autosync']) && in_array('json', $field_group['acfe_autosync']))
|
309 |
-
$acfe_autosync_active = 1;
|
310 |
-
|
311 |
-
$nonce = wp_create_nonce('bulk-posts');
|
312 |
-
echo '<a data-acfe-autosync-json-active="'.$acfe_autosync_active.'" class="button" href="'.admin_url('edit.php?post_type=acf-field-group&post_status=sync&acfsync=' . $field['value'] . '&_wpnonce=' . $nonce).'">Synchronize</a>';
|
313 |
-
|
314 |
-
}
|
315 |
-
|
316 |
-
/**
|
317 |
-
* Render: Sync Warnings
|
318 |
-
*/
|
319 |
-
add_action('acf/render_field', 'acfe_render_field_acfe_sync_warnings', 5);
|
320 |
-
function acfe_render_field_acfe_sync_warnings($field){
|
321 |
-
|
322 |
-
if($field['_name'] != 'acfe_autosync')
|
323 |
-
return;
|
324 |
-
|
325 |
-
global $field_group;
|
326 |
-
|
327 |
-
// PHP
|
328 |
-
|
329 |
-
// Fix to load local fiel groups
|
330 |
-
acf_enable_filters();
|
331 |
-
|
332 |
-
if(acfe_has_field_group_autosync($field_group, 'php') && !acf_get_setting('acfe_php_found')){
|
333 |
-
echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> Folder <code style="font-size:11px;">/acfe-php</code> was not found in your theme. You must create it to activate PHP Sync</p>';
|
334 |
-
}
|
335 |
-
|
336 |
-
elseif(!acfe_has_field_group_autosync($field_group, 'php') && acfe_has_field_group_autosync_file($field_group, 'php')){
|
337 |
-
echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> This field group is registered via a third-party PHP code</p>';
|
338 |
-
}
|
339 |
-
|
340 |
-
elseif(acfe_has_field_group_autosync($field_group, 'php') && !acfe_has_field_group_autosync_file($field_group, 'php')){
|
341 |
-
echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> <code style="font-size:11px;">' . $field_group['key'] . '.php</code> will be created upon update</p>';
|
342 |
-
}
|
343 |
-
|
344 |
-
// Re-disable filters, as natively
|
345 |
-
acf_disable_filters();
|
346 |
-
|
347 |
-
// Json
|
348 |
-
if(acfe_has_field_group_autosync($field_group, 'json') && !acfe_has_field_group_autosync_file($field_group, 'json')){
|
349 |
-
|
350 |
-
if(!acfe_folder_exists('acf-json')){
|
351 |
-
|
352 |
-
echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> Folder <code style="font-size:11px;">/acf-json</code> was not found in your theme. You must create it to activate Json Sync.</p>';
|
353 |
-
|
354 |
-
}
|
355 |
-
|
356 |
-
else{
|
357 |
-
|
358 |
-
echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> <code style="font-size:11px;">' . $field_group['key'] . '.json</code> will be created upon update.</p>';
|
359 |
-
|
360 |
-
}
|
361 |
-
}
|
362 |
-
|
363 |
-
}
|
364 |
-
|
365 |
-
/**
|
366 |
-
* Render: Data button
|
367 |
-
*/
|
368 |
-
add_action('acf/render_field/name=acfe_data', 'acfe_render_field_group_data');
|
369 |
-
function acfe_render_field_group_data($field){
|
370 |
-
|
371 |
-
$field_group = acf_get_field_group($field['value']);
|
372 |
-
if(!$field_group){
|
373 |
-
echo '<a href="#" class="button disabled" disabled>' . __('Data') . '</a>';
|
374 |
-
return;
|
375 |
-
}
|
376 |
-
|
377 |
-
echo '<a href="#" class="button acfe_modal_open" data-modal-key="' . $field_group['key'] . '">' . __('Data') . '</a>';
|
378 |
-
echo '<div class="acfe-modal" data-modal-key="' . $field_group['key'] . '"><div style="padding:15px;"><pre>' . print_r($field_group, true) . '</pre></div>';
|
379 |
-
|
380 |
-
}
|
381 |
-
|
382 |
-
/**
|
383 |
-
* Hooks: Display title (post edit)
|
384 |
-
*/
|
385 |
-
add_filter('acf/get_field_groups', 'acfe_render_field_groups', 999);
|
386 |
-
function acfe_render_field_groups($field_groups){
|
387 |
-
|
388 |
-
if(!is_admin())
|
389 |
-
return $field_groups;
|
390 |
-
|
391 |
-
$check_current_screen = acf_is_screen(array(
|
392 |
-
'edit-acf-field-group',
|
393 |
-
'acf-field-group',
|
394 |
-
'acf_page_acf-tools'
|
395 |
-
));
|
396 |
-
|
397 |
-
if($check_current_screen)
|
398 |
-
return $field_groups;
|
399 |
-
|
400 |
-
foreach($field_groups as &$field_group){
|
401 |
-
if(!isset($field_group['acfe_display_title']) || empty($field_group['acfe_display_title']))
|
402 |
-
continue;
|
403 |
-
|
404 |
-
$field_group['title'] = $field_group['acfe_display_title'];
|
405 |
-
}
|
406 |
-
|
407 |
-
return $field_groups;
|
408 |
-
|
409 |
-
}
|
410 |
-
|
411 |
-
/**
|
412 |
-
* Hooks: Permissions (post edit)
|
413 |
-
*/
|
414 |
-
add_filter('acf/get_field_groups', 'acfe_permissions_field_groups', 999);
|
415 |
-
function acfe_permissions_field_groups($field_groups){
|
416 |
-
|
417 |
-
if(!is_admin())
|
418 |
-
return $field_groups;
|
419 |
-
|
420 |
-
$check_current_screen = acf_is_screen(array(
|
421 |
-
'edit-acf-field-group',
|
422 |
-
'acf-field-group',
|
423 |
-
'acf_page_acf-tools'
|
424 |
-
));
|
425 |
-
|
426 |
-
if($check_current_screen)
|
427 |
-
return $field_groups;
|
428 |
-
|
429 |
-
$current_user_roles = acfe_get_current_user_roles();
|
430 |
-
|
431 |
-
foreach($field_groups as $key => $field_group){
|
432 |
-
if(!isset($field_group['acfe_permissions']) || empty($field_group['acfe_permissions']))
|
433 |
-
continue;
|
434 |
-
|
435 |
-
$render_field_group = false;
|
436 |
-
|
437 |
-
foreach($current_user_roles as $current_user_role){
|
438 |
-
foreach($field_group['acfe_permissions'] as $field_group_role){
|
439 |
-
if($current_user_role !== $field_group_role)
|
440 |
-
continue;
|
441 |
-
|
442 |
-
$render_field_group = true;
|
443 |
-
break;
|
444 |
-
}
|
445 |
-
|
446 |
-
if($render_field_group)
|
447 |
-
break;
|
448 |
-
}
|
449 |
-
|
450 |
-
if(!$render_field_group)
|
451 |
-
unset($field_groups[$key]);
|
452 |
-
}
|
453 |
-
|
454 |
-
return $field_groups;
|
455 |
-
|
456 |
-
}
|
457 |
-
|
458 |
-
/**
|
459 |
-
* Hooks: Default label placement - Left
|
460 |
-
*/
|
461 |
-
add_filter('acf/validate_field_group', 'acfc_field_group_default_options');
|
462 |
-
function acfc_field_group_default_options($field_group){
|
463 |
-
|
464 |
-
if(!isset($field_group['location']) || empty($field_group['location']))
|
465 |
-
$field_group['label_placement'] = 'left';
|
466 |
-
|
467 |
-
return $field_group;
|
468 |
-
|
469 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Field Group Options: Note
|
8 |
+
*/
|
9 |
+
add_action('acf/render_field_group_settings', 'acfe_render_field_group_options');
|
10 |
+
function acfe_render_field_group_options($field_group){
|
11 |
+
|
12 |
+
acf_render_field_wrap(array(
|
13 |
+
'label' => __('Note'),
|
14 |
+
'name' => 'acfe_note',
|
15 |
+
'prefix' => 'acf_field_group',
|
16 |
+
'type' => 'textarea',
|
17 |
+
'instructions' => __('Personal note. Only visible to administrators'),
|
18 |
+
'value' => (isset($field_group['acfe_note'])) ? $field_group['acfe_note'] : '',
|
19 |
+
'required' => false,
|
20 |
+
));
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Field Group Options: Data
|
26 |
+
*/
|
27 |
+
add_action('acf/field_group/admin_head', 'acfe_render_field_group_settings');
|
28 |
+
function acfe_render_field_group_settings(){
|
29 |
+
|
30 |
+
add_meta_box('acf-field-group-acfe', __('Data', 'acfe'), function(){
|
31 |
+
|
32 |
+
global $field_group;
|
33 |
+
|
34 |
+
acf_render_field_wrap(array(
|
35 |
+
'label' => __('Custom meta data'),
|
36 |
+
'name' => 'acfe_meta',
|
37 |
+
'key' => 'acfe_meta',
|
38 |
+
'instructions' => '',
|
39 |
+
'prefix' => 'acf_field_group',
|
40 |
+
'type' => 'repeater',
|
41 |
+
'button_label' => __('+ Add row'),
|
42 |
+
'required' => false,
|
43 |
+
'layout' => 'table',
|
44 |
+
'value' => (isset($field_group['acfe_meta'])) ? $field_group['acfe_meta'] : array(),
|
45 |
+
'sub_fields' => array(
|
46 |
+
array(
|
47 |
+
'label' => __('Key'),
|
48 |
+
'name' => 'acfe_meta_key',
|
49 |
+
'key' => 'acfe_meta_key',
|
50 |
+
'prefix' => '',
|
51 |
+
'_name' => '',
|
52 |
+
'_prepare' => '',
|
53 |
+
'type' => 'text',
|
54 |
+
'instructions' => false,
|
55 |
+
'required' => false,
|
56 |
+
'wrapper' => array(
|
57 |
+
'width' => '',
|
58 |
+
'class' => '',
|
59 |
+
'id' => '',
|
60 |
+
),
|
61 |
+
),
|
62 |
+
array(
|
63 |
+
'label' => __('Value'),
|
64 |
+
'name' => 'acfe_meta_value',
|
65 |
+
'key' => 'acfe_meta_value',
|
66 |
+
'prefix' => '',
|
67 |
+
'_name' => '',
|
68 |
+
'_prepare' => '',
|
69 |
+
'type' => 'text',
|
70 |
+
'instructions' => false,
|
71 |
+
'required' => false,
|
72 |
+
'wrapper' => array(
|
73 |
+
'width' => '',
|
74 |
+
'class' => '',
|
75 |
+
'id' => '',
|
76 |
+
),
|
77 |
+
),
|
78 |
+
)
|
79 |
+
));
|
80 |
+
|
81 |
+
acf_render_field_wrap(array(
|
82 |
+
'label' => __('Field group data'),
|
83 |
+
'instructions' => __('View raw data'),
|
84 |
+
'type' => 'acfe_dynamic_message',
|
85 |
+
'name' => 'acfe_data',
|
86 |
+
'prefix' => 'acf_field_group',
|
87 |
+
'value' => $field_group['key'],
|
88 |
+
));
|
89 |
+
|
90 |
+
?>
|
91 |
+
<script type="text/javascript">
|
92 |
+
if(typeof acf !== 'undefined'){
|
93 |
+
acf.postbox.render({
|
94 |
+
'id': 'acf-field-group-acfe',
|
95 |
+
'label': 'left'
|
96 |
+
});
|
97 |
+
}
|
98 |
+
|
99 |
+
jQuery(document).ready(function($){
|
100 |
+
$('#post_name').on('keyup', function(){
|
101 |
+
var val = $(this).val();
|
102 |
+
if(!val.startsWith('group_')){
|
103 |
+
var val = 'group_' + val;
|
104 |
+
$(this).val(val);
|
105 |
+
}
|
106 |
+
|
107 |
+
$('[name="acf_field_group[key]"]').val(val);
|
108 |
+
$('.misc-pub-acfe-field-group-key code').html(val);
|
109 |
+
});
|
110 |
+
});
|
111 |
+
</script>
|
112 |
+
<?php
|
113 |
+
}, 'acf-field-group', 'normal');
|
114 |
+
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Field Group Options: Sidebar - Submit Div
|
119 |
+
*/
|
120 |
+
add_action('post_submitbox_misc_actions', 'acfe_render_field_group_submitbox');
|
121 |
+
function acfe_render_field_group_submitbox(){
|
122 |
+
|
123 |
+
if(get_post_type(get_the_ID()) !== 'acf-field-group')
|
124 |
+
return;
|
125 |
+
|
126 |
+
$field_group = acf_get_field_group(get_the_ID());
|
127 |
+
?>
|
128 |
+
<div class="misc-pub-section misc-pub-acfe-field-group-key">
|
129 |
+
<span style="font-size:16px;color: #82878c;" class="dashicons dashicons-tag"></span> <code style="font-size: 12px;"><?php echo $field_group['key']; ?></code>
|
130 |
+
</div>
|
131 |
+
<script type="text/javascript">
|
132 |
+
(function($) {
|
133 |
+
$('.misc-pub-acfe-field-group-key').insertBefore('.misc-pub-post-status');
|
134 |
+
})(jQuery);
|
135 |
+
</script>
|
136 |
+
<?php
|
137 |
+
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Field Group Options: Sidebar
|
142 |
+
*/
|
143 |
+
add_action('acf/field_group/admin_head', 'acfe_render_field_group_settings_side');
|
144 |
+
function acfe_render_field_group_settings_side(){
|
145 |
+
|
146 |
+
add_meta_box('acf-field-group-acfe-side', __('Advanced Settings', 'acfe'), function(){
|
147 |
+
|
148 |
+
// Global
|
149 |
+
global $field_group;
|
150 |
+
|
151 |
+
// Proxy
|
152 |
+
$_field_group = $field_group;
|
153 |
+
|
154 |
+
acf_render_field_wrap(array(
|
155 |
+
'label' => __('Display title', 'acfe'),
|
156 |
+
'instructions' => __('Render this title on edit post screen', 'acfe'),
|
157 |
+
'type' => 'text',
|
158 |
+
'name' => 'acfe_display_title',
|
159 |
+
'prefix' => 'acf_field_group',
|
160 |
+
'value' => (isset($field_group['acfe_display_title'])) ? $field_group['acfe_display_title'] : '',
|
161 |
+
'placeholder' => '',
|
162 |
+
'prepend' => '',
|
163 |
+
'append' => ''
|
164 |
+
));
|
165 |
+
|
166 |
+
if(acfe_is_field_group_json_desync($field_group)){
|
167 |
+
acf_render_field_wrap(array(
|
168 |
+
'label' => __('Json Desync'),
|
169 |
+
'instructions' => __('Local json file is different from this version. If you manually synchronize it, you will lose your current field group settings'),
|
170 |
+
'type' => 'acfe_dynamic_message',
|
171 |
+
'name' => 'acfe_sync_available',
|
172 |
+
'prefix' => 'acf_field_group',
|
173 |
+
'value' => $field_group['key'],
|
174 |
+
));
|
175 |
+
}
|
176 |
+
|
177 |
+
|
178 |
+
$force_json_sync = false;
|
179 |
+
$json_text = 'Json';
|
180 |
+
|
181 |
+
if(acfe_has_field_group_autosync_file($_field_group, 'json')){
|
182 |
+
|
183 |
+
if(isset($_field_group['acfe_autosync']) && is_array($_field_group['acfe_autosync']))
|
184 |
+
$_field_group['acfe_autosync'][] = 'json';
|
185 |
+
else
|
186 |
+
$_field_group['acfe_autosync'] = array('json');
|
187 |
+
|
188 |
+
$json_text = '<span class="acf-js-tooltip" title="To disable the Json Sync you must manually delete the file: '.$_field_group['key'].'.json">Json</span>';
|
189 |
+
|
190 |
+
$force_json_sync = true;
|
191 |
+
|
192 |
+
}
|
193 |
+
|
194 |
+
$force_php_sync = false;
|
195 |
+
$php_text = 'PHP';
|
196 |
+
acf_enable_filter('local');
|
197 |
+
|
198 |
+
if(acfe_has_field_group_autosync_file($_field_group, 'php')){
|
199 |
+
|
200 |
+
acf_disable_filter('local');
|
201 |
+
|
202 |
+
if(isset($_field_group['acfe_autosync']) && is_array($_field_group['acfe_autosync']))
|
203 |
+
$_field_group['acfe_autosync'][] = 'php';
|
204 |
+
else
|
205 |
+
$_field_group['acfe_autosync'] = array('php');
|
206 |
+
|
207 |
+
$php_text = '<span class="acf-js-tooltip" title="To disable the PHP Sync you must manually delete the file: '.$_field_group['key'].'.php">PHP</span>';
|
208 |
+
|
209 |
+
$force_php_sync = true;
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
acf_render_field_wrap(array(
|
214 |
+
'label' => __('Auto Sync'),
|
215 |
+
'instructions' => '',
|
216 |
+
'type' => 'checkbox',
|
217 |
+
'name' => 'acfe_autosync',
|
218 |
+
'prefix' => 'acf_field_group',
|
219 |
+
'value' => (isset($_field_group['acfe_autosync']) && !empty($_field_group['acfe_autosync'])) ? $_field_group['acfe_autosync'] : array(),
|
220 |
+
'choices' => array(
|
221 |
+
'php' => $php_text,
|
222 |
+
'json' => $json_text,
|
223 |
+
)
|
224 |
+
));
|
225 |
+
|
226 |
+
acf_render_field_wrap(array(
|
227 |
+
'label' => __('Permissions'),
|
228 |
+
'name' => 'acfe_permissions',
|
229 |
+
'prefix' => 'acf_field_group',
|
230 |
+
'type' => 'checkbox',
|
231 |
+
'instructions' => __('Select user roles that are allowed to view and edit this field group in post edition'),
|
232 |
+
'required' => false,
|
233 |
+
'default_value' => false,
|
234 |
+
'choices' => acfe_get_roles(),
|
235 |
+
'value' => (isset($field_group['acfe_permissions'])) ? $field_group['acfe_permissions'] : array(),
|
236 |
+
'layout' => 'vertical'
|
237 |
+
));
|
238 |
+
|
239 |
+
?>
|
240 |
+
<script type="text/javascript">
|
241 |
+
if(typeof acf !== 'undefined'){
|
242 |
+
acf.postbox.render({
|
243 |
+
'id': 'acf-field-group-acfe-side',
|
244 |
+
'label': 'top'
|
245 |
+
});
|
246 |
+
}
|
247 |
+
|
248 |
+
(function($){
|
249 |
+
|
250 |
+
<?php if($force_json_sync){ ?>
|
251 |
+
|
252 |
+
$('#acf_field_group-acfe_autosync-json').prop('readonly', true).addClass('disabled').click(function(){
|
253 |
+
return false;
|
254 |
+
});
|
255 |
+
|
256 |
+
$('#acf_field_group-acfe_autosync-json').closest('label').css('color', '#999');
|
257 |
+
|
258 |
+
<?php } ?>
|
259 |
+
|
260 |
+
<?php if($force_php_sync){ ?>
|
261 |
+
|
262 |
+
$('#acf_field_group-acfe_autosync-php').prop('readonly', true).addClass('disabled').click(function(){
|
263 |
+
return false;
|
264 |
+
});
|
265 |
+
|
266 |
+
$('#acf_field_group-acfe_autosync-php').closest('label').css('color', '#999');
|
267 |
+
|
268 |
+
<?php } ?>
|
269 |
+
|
270 |
+
if($('[data-name=acfe_sync_available]').length){
|
271 |
+
|
272 |
+
if($('[data-name=acfe_sync_available]').find('[data-acfe-autosync-json-active]').attr('data-acfe-autosync-json-active') === '0'){
|
273 |
+
$('#acf_field_group-acfe_autosync-json').change(function(e){
|
274 |
+
if($(this).prop('checked')){
|
275 |
+
if(!confirm('Local json file was found and is different from this version.' + "\n" + 'Enabling json auto sync will erase the local file with the current field group settings')){
|
276 |
+
$(this).prop('checked', false);
|
277 |
+
return false;
|
278 |
+
}
|
279 |
+
}
|
280 |
+
});
|
281 |
+
}
|
282 |
+
|
283 |
+
else{
|
284 |
+
|
285 |
+
$('#publish').click(function(e){
|
286 |
+
if(!confirm('Local json file was found and is different from this version.' + "\n" + 'Proceed to erase the local file with the current field group settings'))
|
287 |
+
e.preventDefault();
|
288 |
+
});
|
289 |
+
|
290 |
+
}
|
291 |
+
}
|
292 |
+
})(jQuery);
|
293 |
+
</script>
|
294 |
+
<?php
|
295 |
+
}, 'acf-field-group', 'side');
|
296 |
+
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Render: Sync Available
|
301 |
+
*/
|
302 |
+
add_action('acf/render_field/name=acfe_sync_available', 'acfe_render_field_sync_available');
|
303 |
+
function acfe_render_field_sync_available($field){
|
304 |
+
|
305 |
+
$field_group = acf_get_field_group($field['value']);
|
306 |
+
|
307 |
+
$acfe_autosync_active = 0;
|
308 |
+
if(isset($field_group['acfe_autosync']) && is_array($field_group['acfe_autosync']) && in_array('json', $field_group['acfe_autosync']))
|
309 |
+
$acfe_autosync_active = 1;
|
310 |
+
|
311 |
+
$nonce = wp_create_nonce('bulk-posts');
|
312 |
+
echo '<a data-acfe-autosync-json-active="'.$acfe_autosync_active.'" class="button" href="'.admin_url('edit.php?post_type=acf-field-group&post_status=sync&acfsync=' . $field['value'] . '&_wpnonce=' . $nonce).'">Synchronize</a>';
|
313 |
+
|
314 |
+
}
|
315 |
+
|
316 |
+
/**
|
317 |
+
* Render: Sync Warnings
|
318 |
+
*/
|
319 |
+
add_action('acf/render_field', 'acfe_render_field_acfe_sync_warnings', 5);
|
320 |
+
function acfe_render_field_acfe_sync_warnings($field){
|
321 |
+
|
322 |
+
if($field['_name'] != 'acfe_autosync')
|
323 |
+
return;
|
324 |
+
|
325 |
+
global $field_group;
|
326 |
+
|
327 |
+
// PHP
|
328 |
+
|
329 |
+
// Fix to load local fiel groups
|
330 |
+
acf_enable_filters();
|
331 |
+
|
332 |
+
if(acfe_has_field_group_autosync($field_group, 'php') && !acf_get_setting('acfe_php_found')){
|
333 |
+
echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> Folder <code style="font-size:11px;">/acfe-php</code> was not found in your theme. You must create it to activate PHP Sync</p>';
|
334 |
+
}
|
335 |
+
|
336 |
+
elseif(!acfe_has_field_group_autosync($field_group, 'php') && acfe_has_field_group_autosync_file($field_group, 'php')){
|
337 |
+
echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> This field group is registered via a third-party PHP code</p>';
|
338 |
+
}
|
339 |
+
|
340 |
+
elseif(acfe_has_field_group_autosync($field_group, 'php') && !acfe_has_field_group_autosync_file($field_group, 'php')){
|
341 |
+
echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> <code style="font-size:11px;">' . $field_group['key'] . '.php</code> will be created upon update</p>';
|
342 |
+
}
|
343 |
+
|
344 |
+
// Re-disable filters, as natively
|
345 |
+
acf_disable_filters();
|
346 |
+
|
347 |
+
// Json
|
348 |
+
if(acfe_has_field_group_autosync($field_group, 'json') && !acfe_has_field_group_autosync_file($field_group, 'json')){
|
349 |
+
|
350 |
+
if(!acfe_folder_exists('acf-json')){
|
351 |
+
|
352 |
+
echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> Folder <code style="font-size:11px;">/acf-json</code> was not found in your theme. You must create it to activate Json Sync.</p>';
|
353 |
+
|
354 |
+
}
|
355 |
+
|
356 |
+
else{
|
357 |
+
|
358 |
+
echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> <code style="font-size:11px;">' . $field_group['key'] . '.json</code> will be created upon update.</p>';
|
359 |
+
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Render: Data button
|
367 |
+
*/
|
368 |
+
add_action('acf/render_field/name=acfe_data', 'acfe_render_field_group_data');
|
369 |
+
function acfe_render_field_group_data($field){
|
370 |
+
|
371 |
+
$field_group = acf_get_field_group($field['value']);
|
372 |
+
if(!$field_group){
|
373 |
+
echo '<a href="#" class="button disabled" disabled>' . __('Data') . '</a>';
|
374 |
+
return;
|
375 |
+
}
|
376 |
+
|
377 |
+
echo '<a href="#" class="button acfe_modal_open" data-modal-key="' . $field_group['key'] . '">' . __('Data') . '</a>';
|
378 |
+
echo '<div class="acfe-modal" data-modal-key="' . $field_group['key'] . '"><div style="padding:15px;"><pre>' . print_r($field_group, true) . '</pre></div>';
|
379 |
+
|
380 |
+
}
|
381 |
+
|
382 |
+
/**
|
383 |
+
* Hooks: Display title (post edit)
|
384 |
+
*/
|
385 |
+
add_filter('acf/get_field_groups', 'acfe_render_field_groups', 999);
|
386 |
+
function acfe_render_field_groups($field_groups){
|
387 |
+
|
388 |
+
if(!is_admin())
|
389 |
+
return $field_groups;
|
390 |
+
|
391 |
+
$check_current_screen = acf_is_screen(array(
|
392 |
+
'edit-acf-field-group',
|
393 |
+
'acf-field-group',
|
394 |
+
'acf_page_acf-tools'
|
395 |
+
));
|
396 |
+
|
397 |
+
if($check_current_screen)
|
398 |
+
return $field_groups;
|
399 |
+
|
400 |
+
foreach($field_groups as &$field_group){
|
401 |
+
if(!isset($field_group['acfe_display_title']) || empty($field_group['acfe_display_title']))
|
402 |
+
continue;
|
403 |
+
|
404 |
+
$field_group['title'] = $field_group['acfe_display_title'];
|
405 |
+
}
|
406 |
+
|
407 |
+
return $field_groups;
|
408 |
+
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Hooks: Permissions (post edit)
|
413 |
+
*/
|
414 |
+
add_filter('acf/get_field_groups', 'acfe_permissions_field_groups', 999);
|
415 |
+
function acfe_permissions_field_groups($field_groups){
|
416 |
+
|
417 |
+
if(!is_admin())
|
418 |
+
return $field_groups;
|
419 |
+
|
420 |
+
$check_current_screen = acf_is_screen(array(
|
421 |
+
'edit-acf-field-group',
|
422 |
+
'acf-field-group',
|
423 |
+
'acf_page_acf-tools'
|
424 |
+
));
|
425 |
+
|
426 |
+
if($check_current_screen)
|
427 |
+
return $field_groups;
|
428 |
+
|
429 |
+
$current_user_roles = acfe_get_current_user_roles();
|
430 |
+
|
431 |
+
foreach($field_groups as $key => $field_group){
|
432 |
+
if(!isset($field_group['acfe_permissions']) || empty($field_group['acfe_permissions']))
|
433 |
+
continue;
|
434 |
+
|
435 |
+
$render_field_group = false;
|
436 |
+
|
437 |
+
foreach($current_user_roles as $current_user_role){
|
438 |
+
foreach($field_group['acfe_permissions'] as $field_group_role){
|
439 |
+
if($current_user_role !== $field_group_role)
|
440 |
+
continue;
|
441 |
+
|
442 |
+
$render_field_group = true;
|
443 |
+
break;
|
444 |
+
}
|
445 |
+
|
446 |
+
if($render_field_group)
|
447 |
+
break;
|
448 |
+
}
|
449 |
+
|
450 |
+
if(!$render_field_group)
|
451 |
+
unset($field_groups[$key]);
|
452 |
+
}
|
453 |
+
|
454 |
+
return $field_groups;
|
455 |
+
|
456 |
+
}
|
457 |
+
|
458 |
+
/**
|
459 |
+
* Hooks: Default label placement - Left
|
460 |
+
*/
|
461 |
+
add_filter('acf/validate_field_group', 'acfc_field_group_default_options');
|
462 |
+
function acfc_field_group_default_options($field_group){
|
463 |
+
|
464 |
+
if(!isset($field_group['location']) || empty($field_group['location']))
|
465 |
+
$field_group['label_placement'] = 'left';
|
466 |
+
|
467 |
+
return $field_group;
|
468 |
+
|
469 |
}
|
includes/field-groups/field-groups-third-party.php
CHANGED
@@ -1,177 +1,177 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
add_filter('views_edit-acf-field-group', 'acfe_field_groups_third_party_views', 99);
|
7 |
-
function acfe_field_groups_third_party_views($views){
|
8 |
-
|
9 |
-
// Total
|
10 |
-
$total = count(acfe_get_third_party_field_groups());
|
11 |
-
|
12 |
-
// Bail early if empty
|
13 |
-
if($total === 0)
|
14 |
-
return $views;
|
15 |
-
|
16 |
-
// Class
|
17 |
-
$class = '';
|
18 |
-
|
19 |
-
// active
|
20 |
-
if(acf_maybe_get_GET('post_status') === 'acfe-third-party'){
|
21 |
-
|
22 |
-
// actions
|
23 |
-
add_action('admin_footer', 'acfe_field_groups_third_party_footer', 5);
|
24 |
-
|
25 |
-
// set active class
|
26 |
-
$class = ' class="current"';
|
27 |
-
|
28 |
-
// global
|
29 |
-
global $wp_list_table;
|
30 |
-
|
31 |
-
// update pagination
|
32 |
-
$wp_list_table->set_pagination_args(array(
|
33 |
-
'total_items' => $total,
|
34 |
-
'total_pages' => 1,
|
35 |
-
'per_page' => $total
|
36 |
-
));
|
37 |
-
|
38 |
-
}
|
39 |
-
|
40 |
-
// add view
|
41 |
-
$views['acfe-third-party'] = '<a' . $class . ' href="' . admin_url('edit.php?post_type=acf-field-group&post_status=acfe-third-party') . '">' . __('Third party', 'acfe') . ' <span class="count">(' . $total . ')</span></a>';
|
42 |
-
|
43 |
-
// return
|
44 |
-
return $views;
|
45 |
-
|
46 |
-
}
|
47 |
-
|
48 |
-
function acfe_field_groups_third_party_footer(){
|
49 |
-
|
50 |
-
// vars
|
51 |
-
$i = -1;
|
52 |
-
$columns = array(
|
53 |
-
'acfe-count',
|
54 |
-
'acfe-locations',
|
55 |
-
'acfe-local'
|
56 |
-
);
|
57 |
-
|
58 |
-
?>
|
59 |
-
<script type="text/html" id="tmpl-acfe-third-party-tbody">
|
60 |
-
<?php
|
61 |
-
|
62 |
-
foreach(acfe_get_third_party_field_groups() as $field_group ):
|
63 |
-
|
64 |
-
// vars
|
65 |
-
$i++;
|
66 |
-
$key = $field_group['key'];
|
67 |
-
$title = $field_group['title'];
|
68 |
-
$local = $field_group['local'];
|
69 |
-
|
70 |
-
?>
|
71 |
-
<tr <?php if($i%2 == 0): ?>class="alternate"<?php endif; ?>>
|
72 |
-
<td class="post-title page-title column-title">
|
73 |
-
<strong>
|
74 |
-
<span class="row-title"><?php echo esc_html($title); ?></span>
|
75 |
-
</strong>
|
76 |
-
<div class="row-actions">
|
77 |
-
<span class="acfe-key">
|
78 |
-
<span style="color:#555;">
|
79 |
-
<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;"><?php echo esc_html($key); ?></code>
|
80 |
-
</span>
|
81 |
-
</span>
|
82 |
-
</div>
|
83 |
-
</td>
|
84 |
-
<?php foreach($columns as $column): ?>
|
85 |
-
<td class="column-<?php echo esc_attr($column); ?>">
|
86 |
-
<?php echo acfe_field_groups_column_html($column, $key); ?>
|
87 |
-
</td>
|
88 |
-
<?php endforeach; ?>
|
89 |
-
</tr>
|
90 |
-
<?php endforeach; ?>
|
91 |
-
</script>
|
92 |
-
|
93 |
-
<script type="text/javascript">
|
94 |
-
(function($){
|
95 |
-
|
96 |
-
// update table HTML
|
97 |
-
$('#the-list').html($('#tmpl-acfe-third-party-tbody').html());
|
98 |
-
|
99 |
-
})(jQuery);
|
100 |
-
</script>
|
101 |
-
<?php
|
102 |
-
|
103 |
-
}
|
104 |
-
|
105 |
-
function acfe_get_third_party_field_groups(){
|
106 |
-
|
107 |
-
$get_local_field_groups = acf_get_local_field_groups();
|
108 |
-
if(empty($get_local_field_groups))
|
109 |
-
return array();
|
110 |
-
|
111 |
-
$locals = array();
|
112 |
-
|
113 |
-
foreach($get_local_field_groups as $field_group){
|
114 |
-
|
115 |
-
// Exclude ACFE Field Groups
|
116 |
-
if(stripos($field_group['key'], 'group_acfe_') === 0)
|
117 |
-
continue;
|
118 |
-
|
119 |
-
$locals[] = $field_group;
|
120 |
-
|
121 |
-
}
|
122 |
-
|
123 |
-
// Bail early if no local fields
|
124 |
-
if(empty($locals))
|
125 |
-
return $locals;
|
126 |
-
|
127 |
-
// Get DB field groups
|
128 |
-
$get_db_field_groups = acfe_get_db_field_groups();
|
129 |
-
|
130 |
-
// Bail early if no DB field groups
|
131 |
-
if(empty($get_db_field_groups))
|
132 |
-
return $locals;
|
133 |
-
|
134 |
-
foreach($get_db_field_groups as $field_group){
|
135 |
-
|
136 |
-
foreach($locals as $k => $local){
|
137 |
-
|
138 |
-
if($local['key'] === $field_group['key'])
|
139 |
-
unset($locals[$k]);
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
}
|
144 |
-
|
145 |
-
return $locals;
|
146 |
-
|
147 |
-
}
|
148 |
-
|
149 |
-
function acfe_get_db_field_groups(){
|
150 |
-
|
151 |
-
acf_disable_filters();
|
152 |
-
|
153 |
-
$get_db_field_groups = acf_get_field_groups();
|
154 |
-
|
155 |
-
acf_enable_filters();
|
156 |
-
|
157 |
-
return $get_db_field_groups;
|
158 |
-
|
159 |
-
}
|
160 |
-
|
161 |
-
add_filter('bulk_actions-edit-acf-field-group', function($actions){
|
162 |
-
|
163 |
-
if(acf_maybe_get_GET('post_status') === 'acfe-third-party')
|
164 |
-
return array();
|
165 |
-
|
166 |
-
return $actions;
|
167 |
-
|
168 |
-
}, 99);
|
169 |
-
|
170 |
-
add_filter('manage_edit-acf-field-group_sortable_columns', function($sortable_columns){
|
171 |
-
|
172 |
-
if(acf_maybe_get_GET('post_status') === 'acfe-third-party')
|
173 |
-
return array();
|
174 |
-
|
175 |
-
return $sortable_columns;
|
176 |
-
|
177 |
}, 99);
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
add_filter('views_edit-acf-field-group', 'acfe_field_groups_third_party_views', 99);
|
7 |
+
function acfe_field_groups_third_party_views($views){
|
8 |
+
|
9 |
+
// Total
|
10 |
+
$total = count(acfe_get_third_party_field_groups());
|
11 |
+
|
12 |
+
// Bail early if empty
|
13 |
+
if($total === 0)
|
14 |
+
return $views;
|
15 |
+
|
16 |
+
// Class
|
17 |
+
$class = '';
|
18 |
+
|
19 |
+
// active
|
20 |
+
if(acf_maybe_get_GET('post_status') === 'acfe-third-party'){
|
21 |
+
|
22 |
+
// actions
|
23 |
+
add_action('admin_footer', 'acfe_field_groups_third_party_footer', 5);
|
24 |
+
|
25 |
+
// set active class
|
26 |
+
$class = ' class="current"';
|
27 |
+
|
28 |
+
// global
|
29 |
+
global $wp_list_table;
|
30 |
+
|
31 |
+
// update pagination
|
32 |
+
$wp_list_table->set_pagination_args(array(
|
33 |
+
'total_items' => $total,
|
34 |
+
'total_pages' => 1,
|
35 |
+
'per_page' => $total
|
36 |
+
));
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
// add view
|
41 |
+
$views['acfe-third-party'] = '<a' . $class . ' href="' . admin_url('edit.php?post_type=acf-field-group&post_status=acfe-third-party') . '">' . __('Third party', 'acfe') . ' <span class="count">(' . $total . ')</span></a>';
|
42 |
+
|
43 |
+
// return
|
44 |
+
return $views;
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
function acfe_field_groups_third_party_footer(){
|
49 |
+
|
50 |
+
// vars
|
51 |
+
$i = -1;
|
52 |
+
$columns = array(
|
53 |
+
'acfe-count',
|
54 |
+
'acfe-locations',
|
55 |
+
'acfe-local'
|
56 |
+
);
|
57 |
+
|
58 |
+
?>
|
59 |
+
<script type="text/html" id="tmpl-acfe-third-party-tbody">
|
60 |
+
<?php
|
61 |
+
|
62 |
+
foreach(acfe_get_third_party_field_groups() as $field_group ):
|
63 |
+
|
64 |
+
// vars
|
65 |
+
$i++;
|
66 |
+
$key = $field_group['key'];
|
67 |
+
$title = $field_group['title'];
|
68 |
+
$local = $field_group['local'];
|
69 |
+
|
70 |
+
?>
|
71 |
+
<tr <?php if($i%2 == 0): ?>class="alternate"<?php endif; ?>>
|
72 |
+
<td class="post-title page-title column-title">
|
73 |
+
<strong>
|
74 |
+
<span class="row-title"><?php echo esc_html($title); ?></span>
|
75 |
+
</strong>
|
76 |
+
<div class="row-actions">
|
77 |
+
<span class="acfe-key">
|
78 |
+
<span style="color:#555;">
|
79 |
+
<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;"><?php echo esc_html($key); ?></code>
|
80 |
+
</span>
|
81 |
+
</span>
|
82 |
+
</div>
|
83 |
+
</td>
|
84 |
+
<?php foreach($columns as $column): ?>
|
85 |
+
<td class="column-<?php echo esc_attr($column); ?>">
|
86 |
+
<?php echo acfe_field_groups_column_html($column, $key); ?>
|
87 |
+
</td>
|
88 |
+
<?php endforeach; ?>
|
89 |
+
</tr>
|
90 |
+
<?php endforeach; ?>
|
91 |
+
</script>
|
92 |
+
|
93 |
+
<script type="text/javascript">
|
94 |
+
(function($){
|
95 |
+
|
96 |
+
// update table HTML
|
97 |
+
$('#the-list').html($('#tmpl-acfe-third-party-tbody').html());
|
98 |
+
|
99 |
+
})(jQuery);
|
100 |
+
</script>
|
101 |
+
<?php
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
function acfe_get_third_party_field_groups(){
|
106 |
+
|
107 |
+
$get_local_field_groups = acf_get_local_field_groups();
|
108 |
+
if(empty($get_local_field_groups))
|
109 |
+
return array();
|
110 |
+
|
111 |
+
$locals = array();
|
112 |
+
|
113 |
+
foreach($get_local_field_groups as $field_group){
|
114 |
+
|
115 |
+
// Exclude ACFE Field Groups
|
116 |
+
if(stripos($field_group['key'], 'group_acfe_') === 0)
|
117 |
+
continue;
|
118 |
+
|
119 |
+
$locals[] = $field_group;
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
// Bail early if no local fields
|
124 |
+
if(empty($locals))
|
125 |
+
return $locals;
|
126 |
+
|
127 |
+
// Get DB field groups
|
128 |
+
$get_db_field_groups = acfe_get_db_field_groups();
|
129 |
+
|
130 |
+
// Bail early if no DB field groups
|
131 |
+
if(empty($get_db_field_groups))
|
132 |
+
return $locals;
|
133 |
+
|
134 |
+
foreach($get_db_field_groups as $field_group){
|
135 |
+
|
136 |
+
foreach($locals as $k => $local){
|
137 |
+
|
138 |
+
if($local['key'] === $field_group['key'])
|
139 |
+
unset($locals[$k]);
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
return $locals;
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
function acfe_get_db_field_groups(){
|
150 |
+
|
151 |
+
acf_disable_filters();
|
152 |
+
|
153 |
+
$get_db_field_groups = acf_get_field_groups();
|
154 |
+
|
155 |
+
acf_enable_filters();
|
156 |
+
|
157 |
+
return $get_db_field_groups;
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
add_filter('bulk_actions-edit-acf-field-group', function($actions){
|
162 |
+
|
163 |
+
if(acf_maybe_get_GET('post_status') === 'acfe-third-party')
|
164 |
+
return array();
|
165 |
+
|
166 |
+
return $actions;
|
167 |
+
|
168 |
+
}, 99);
|
169 |
+
|
170 |
+
add_filter('manage_edit-acf-field-group_sortable_columns', function($sortable_columns){
|
171 |
+
|
172 |
+
if(acf_maybe_get_GET('post_status') === 'acfe-third-party')
|
173 |
+
return array();
|
174 |
+
|
175 |
+
return $sortable_columns;
|
176 |
+
|
177 |
}, 99);
|
includes/field-groups/field-groups.php
CHANGED
@@ -1,411 +1,445 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Display Title (post states)
|
8 |
-
*/
|
9 |
-
add_filter('display_post_states', 'acfe_field_groups_states', 10, 2);
|
10 |
-
function acfe_field_groups_states($states, $post){
|
11 |
-
|
12 |
-
if(!acf_is_screen('edit-acf-field-group'))
|
13 |
-
return $states;
|
14 |
-
|
15 |
-
if(get_post_type($post->ID) != 'acf-field-group')
|
16 |
-
return $states;
|
17 |
-
|
18 |
-
$field_group = acf_get_field_group($post->ID);
|
19 |
-
|
20 |
-
if(!$field_group || !isset($field_group['acfe_display_title']) || empty($field_group['acfe_display_title']))
|
21 |
-
return $states;
|
22 |
-
|
23 |
-
$states[] = $field_group['acfe_display_title'];
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
unset($columns['acfe-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
unset($columns['
|
69 |
-
unset($columns['acf-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
'
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
$
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
'
|
126 |
-
'
|
127 |
-
'
|
128 |
-
'
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
'
|
133 |
-
'
|
134 |
-
'
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
'
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
'
|
143 |
-
'
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
'
|
148 |
-
'
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
'
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
if(!
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
return;
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
echo '<span
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
}
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Display Title (post states)
|
8 |
+
*/
|
9 |
+
add_filter('display_post_states', 'acfe_field_groups_states', 10, 2);
|
10 |
+
function acfe_field_groups_states($states, $post){
|
11 |
+
|
12 |
+
if(!acf_is_screen('edit-acf-field-group'))
|
13 |
+
return $states;
|
14 |
+
|
15 |
+
if(get_post_type($post->ID) != 'acf-field-group')
|
16 |
+
return $states;
|
17 |
+
|
18 |
+
$field_group = acf_get_field_group($post->ID);
|
19 |
+
|
20 |
+
if(!$field_group || !isset($field_group['acfe_display_title']) || empty($field_group['acfe_display_title']))
|
21 |
+
return $states;
|
22 |
+
|
23 |
+
$states[] = $field_group['acfe_display_title'];
|
24 |
+
|
25 |
+
return $states;
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Table Columns
|
31 |
+
*/
|
32 |
+
add_filter('manage_edit-acf-field-group_columns', 'acfe_field_groups_column', 999);
|
33 |
+
function acfe_field_groups_column($columns){
|
34 |
+
|
35 |
+
// Locations
|
36 |
+
$columns['acfe-locations'] = __('Locations');
|
37 |
+
|
38 |
+
// Load
|
39 |
+
$columns['acfe-local'] = __('Load');
|
40 |
+
|
41 |
+
// PHP sync
|
42 |
+
if(acf_get_setting('acfe_php'))
|
43 |
+
$columns['acfe-autosync-php'] = __('PHP sync');
|
44 |
+
|
45 |
+
// Json sync
|
46 |
+
if(acf_get_setting('json'))
|
47 |
+
$columns['acfe-autosync-json'] = __('Json sync');
|
48 |
+
|
49 |
+
// Fix 'Sync' screen columns
|
50 |
+
if(acf_maybe_get_GET('post_status') === 'sync'){
|
51 |
+
|
52 |
+
unset($columns['acf-field-group-category']);
|
53 |
+
|
54 |
+
unset($columns['acfe-locations']);
|
55 |
+
unset($columns['acfe-local']);
|
56 |
+
|
57 |
+
if(isset($columns['acfe-autosync-php']))
|
58 |
+
unset($columns['acfe-autosync-php']);
|
59 |
+
|
60 |
+
if(isset($columns['acfe-autosync-json']))
|
61 |
+
unset($columns['acfe-autosync-json']);
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
// Fix 'Third party' screen columns
|
66 |
+
elseif(acf_maybe_get_GET('post_status') === 'acfe-third-party'){
|
67 |
+
|
68 |
+
unset($columns['cb']);
|
69 |
+
unset($columns['acf-field-group-category']);
|
70 |
+
unset($columns['acf-fg-status']);
|
71 |
+
|
72 |
+
if(isset($columns['acfe-autosync-php']))
|
73 |
+
unset($columns['acfe-autosync-php']);
|
74 |
+
|
75 |
+
if(isset($columns['acfe-autosync-json']))
|
76 |
+
unset($columns['acfe-autosync-json']);
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
// Remove 'Field Group Category' column if there is no terms
|
81 |
+
$categories = get_terms(array(
|
82 |
+
'taxonomy' => 'acf-field-group-category',
|
83 |
+
'hide_empty' => false,
|
84 |
+
));
|
85 |
+
|
86 |
+
if(empty($categories))
|
87 |
+
unset($columns['acf-field-group-category']);
|
88 |
+
|
89 |
+
return $columns;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Table Columns HTML
|
94 |
+
*/
|
95 |
+
add_action('manage_acf-field-group_posts_custom_column', 'acfe_field_groups_column_html', 10, 2);
|
96 |
+
function acfe_field_groups_column_html($column, $post_id){
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Count
|
100 |
+
*/
|
101 |
+
if($column === 'acfe-count'){
|
102 |
+
|
103 |
+
$field_group = acf_get_field_group($post_id);
|
104 |
+
echo esc_html(acf_get_field_count($field_group));
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Locations
|
110 |
+
*/
|
111 |
+
elseif($column === 'acfe-locations'){
|
112 |
+
|
113 |
+
$field_group = acf_get_field_group($post_id);
|
114 |
+
$choices = acf_get_location_rule_types();
|
115 |
+
|
116 |
+
if(!isset($field_group['location']) || empty($field_group['location']) ||empty($choices))
|
117 |
+
return;
|
118 |
+
|
119 |
+
$final = array();
|
120 |
+
|
121 |
+
$icon_default = 'admin-generic';
|
122 |
+
|
123 |
+
$icons = array(
|
124 |
+
'edit' => array(
|
125 |
+
'post_type',
|
126 |
+
'post_template',
|
127 |
+
'post_status',
|
128 |
+
'post_format',
|
129 |
+
'post',
|
130 |
+
),
|
131 |
+
'media-default' => array(
|
132 |
+
'page_template',
|
133 |
+
'page_type',
|
134 |
+
'page_parent',
|
135 |
+
'page',
|
136 |
+
),
|
137 |
+
'admin-users' => array(
|
138 |
+
'current_user',
|
139 |
+
'user_form',
|
140 |
+
),
|
141 |
+
'welcome-widgets-menus' => array(
|
142 |
+
'widget',
|
143 |
+
'nav_menu',
|
144 |
+
'nav_menu_item',
|
145 |
+
),
|
146 |
+
'category' => array(
|
147 |
+
'taxonomy',
|
148 |
+
'post_category',
|
149 |
+
'post_taxonomy',
|
150 |
+
),
|
151 |
+
'admin-comments' => array(
|
152 |
+
'comment',
|
153 |
+
),
|
154 |
+
'paperclip' => array(
|
155 |
+
'attachment',
|
156 |
+
),
|
157 |
+
'admin-settings' => array(
|
158 |
+
'options_page',
|
159 |
+
),
|
160 |
+
'businessman' => array(
|
161 |
+
'current_user_role',
|
162 |
+
'user_role',
|
163 |
+
),
|
164 |
+
);
|
165 |
+
|
166 |
+
foreach($choices as $key => $sub_choices){
|
167 |
+
|
168 |
+
foreach($sub_choices as $choice_slug => $choice_name){
|
169 |
+
|
170 |
+
$final_icon = $icon_default;
|
171 |
+
foreach($icons as $icon => $icon_slugs){
|
172 |
+
foreach($icon_slugs as $icon_slug){
|
173 |
+
if($choice_slug != $icon_slug)
|
174 |
+
continue;
|
175 |
+
|
176 |
+
$final_icon = $icon;
|
177 |
+
break(2);
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
$final[$choice_slug] = array(
|
182 |
+
'name' => $choice_name,
|
183 |
+
'icon' => $final_icon
|
184 |
+
);
|
185 |
+
|
186 |
+
}
|
187 |
+
|
188 |
+
}
|
189 |
+
|
190 |
+
|
191 |
+
|
192 |
+
$html = array();
|
193 |
+
foreach($field_group['location'] as $or){
|
194 |
+
|
195 |
+
foreach($or as $and){
|
196 |
+
|
197 |
+
if(!isset($final[$and['param']]))
|
198 |
+
continue;
|
199 |
+
|
200 |
+
$final_name = $and['value'];
|
201 |
+
$values = acf_get_location_rule_values($and);
|
202 |
+
|
203 |
+
if(!empty($values) && is_array($values)){
|
204 |
+
|
205 |
+
foreach($values as $value_slug => $value_name){
|
206 |
+
|
207 |
+
if($and['value'] != $value_slug)
|
208 |
+
continue;
|
209 |
+
|
210 |
+
if(is_array($value_name) && isset($value_name[$and['value']])){
|
211 |
+
|
212 |
+
$final_name = $value_name[$and['value']];
|
213 |
+
|
214 |
+
}else{
|
215 |
+
|
216 |
+
$final_name = $value_name;
|
217 |
+
|
218 |
+
}
|
219 |
+
|
220 |
+
break;
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
}
|
225 |
+
|
226 |
+
$name = '<span class="acf-js-tooltip dashicons dashicons-' . $final[$and['param']]['icon'] . '" title="' . $final[$and['param']]['name'] . ' = ' . $final_name . '"></span>';
|
227 |
+
if($and['operator'] === '!=')
|
228 |
+
$name = '<span class="acf-js-tooltip dashicons dashicons-' . $final[$and['param']]['icon'] . '" title="' . $final[$and['param']]['name'] . ' != ' . $final_name . '" style="color:#ccc;"></span>';
|
229 |
+
|
230 |
+
$html[] = $name;
|
231 |
+
|
232 |
+
}
|
233 |
+
|
234 |
+
}
|
235 |
+
|
236 |
+
echo implode(' ', $html);
|
237 |
+
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Load
|
242 |
+
*/
|
243 |
+
elseif($column === 'acfe-local'){
|
244 |
+
|
245 |
+
if(!$field_group = acf_get_field_group($post_id))
|
246 |
+
return;
|
247 |
+
|
248 |
+
$local_field_group = acf_get_local_field_group($field_group['key']);
|
249 |
+
$local_field_group_type = acf_maybe_get($local_field_group, 'local', false);
|
250 |
+
|
251 |
+
if($local_field_group_type === 'php'){
|
252 |
+
|
253 |
+
echo '<span class="acf-js-tooltip" title="' . $field_group['key'] . ' is registered locally">php</span>';
|
254 |
+
|
255 |
+
return;
|
256 |
+
|
257 |
+
}
|
258 |
+
|
259 |
+
elseif($local_field_group_type === 'json'){
|
260 |
+
|
261 |
+
echo '<span class="acf-js-tooltip" title="' . $field_group['key'] . ' is registered locally">json</span>';
|
262 |
+
|
263 |
+
return;
|
264 |
+
|
265 |
+
}
|
266 |
+
|
267 |
+
else{
|
268 |
+
|
269 |
+
echo '<span class="acf-js-tooltip" title="' . $field_group['key'] . ' is not registered locally">DB</span>';
|
270 |
+
|
271 |
+
return;
|
272 |
+
|
273 |
+
}
|
274 |
+
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* PHP sync
|
279 |
+
*/
|
280 |
+
elseif($column === 'acfe-autosync-php'){
|
281 |
+
|
282 |
+
if(!$field_group = acf_get_field_group($post_id))
|
283 |
+
return;
|
284 |
+
|
285 |
+
if(!acfe_has_field_group_autosync($field_group, 'php')){
|
286 |
+
|
287 |
+
echo '<span style="color:#ccc" class="dashicons dashicons-no-alt"></span>';
|
288 |
+
|
289 |
+
if(acfe_has_field_group_autosync_file($field_group, 'php')){
|
290 |
+
echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Field group: ' . $field_group['key'] . ' is registered via a third-party PHP code"></span>';
|
291 |
+
}
|
292 |
+
|
293 |
+
return;
|
294 |
+
|
295 |
+
}
|
296 |
+
|
297 |
+
if(!acf_get_setting('acfe_php_found')){
|
298 |
+
|
299 |
+
echo '<span style="color:#ccc" class="dashicons dashicons-yes"></span>';
|
300 |
+
|
301 |
+
echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Folder \'/acfe-php\' was not found in your theme.<br />You must create it to activate this setting"></span>';
|
302 |
+
|
303 |
+
}
|
304 |
+
|
305 |
+
elseif(!acfe_has_field_group_autosync_file($field_group, 'php')){
|
306 |
+
|
307 |
+
echo '<span style="color:#ccc" class="dashicons dashicons-yes"></span>';
|
308 |
+
echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Local file ' . $field_group['key'] . '.php will be created upon update"></span>';
|
309 |
+
|
310 |
+
}
|
311 |
+
|
312 |
+
else{
|
313 |
+
|
314 |
+
echo '<span class="dashicons dashicons-yes"></span>';
|
315 |
+
|
316 |
+
}
|
317 |
+
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Json sync
|
322 |
+
*/
|
323 |
+
elseif($column === 'acfe-autosync-json'){
|
324 |
+
|
325 |
+
if(!$field_group = acf_get_field_group($post_id))
|
326 |
+
return;
|
327 |
+
|
328 |
+
if(acfe_has_field_group_autosync_file($field_group, 'json')){
|
329 |
+
|
330 |
+
echo '<span class="dashicons dashicons-yes"></span>';
|
331 |
+
|
332 |
+
}
|
333 |
+
|
334 |
+
else{
|
335 |
+
|
336 |
+
if(!acfe_has_field_group_autosync($field_group, 'json')){
|
337 |
+
|
338 |
+
echo '<span style="color:#ccc" class="dashicons dashicons-no-alt"></span>';
|
339 |
+
|
340 |
+
}else{
|
341 |
+
|
342 |
+
echo '<span style="color:#ccc" class="dashicons dashicons-yes"></span>';
|
343 |
+
|
344 |
+
if(!acfe_folder_exists('acf-json')){
|
345 |
+
|
346 |
+
echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Folder \'/acf-json\' was not found in your theme.<br />You must create it to activate this setting"></span>';
|
347 |
+
|
348 |
+
}
|
349 |
+
|
350 |
+
else{
|
351 |
+
|
352 |
+
echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Local file ' . $field_group['key'] . '.json will be created upon update."></span>';
|
353 |
+
|
354 |
+
}
|
355 |
+
|
356 |
+
|
357 |
+
|
358 |
+
}
|
359 |
+
|
360 |
+
}
|
361 |
+
|
362 |
+
}
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Table Row Actions
|
367 |
+
*/
|
368 |
+
add_filter('page_row_actions', 'hwk_post_type_exemple_row_actions', 10, 2);
|
369 |
+
function hwk_post_type_exemple_row_actions($actions, $post){
|
370 |
+
|
371 |
+
if(!isset($post->post_type) || $post->post_type != 'acf-field-group')
|
372 |
+
return $actions;
|
373 |
+
|
374 |
+
$field_group = acf_get_field_group($post->ID);
|
375 |
+
|
376 |
+
$actions['acfe-export-php'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=export&keys=' . $field_group['key']) . '">PHP</a>';
|
377 |
+
$actions['acfe-export-json'] = '<span class="acfe-form" data-action="'.admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=export').'"><input type="hidden" name="_acf_nonce" value="' . wp_create_nonce('export') . '" /><input type="hidden" name="action" value="download" /><input type="hidden" name="keys" value="' . $field_group['key'] . '" /><a href="#">Json</a></span>';
|
378 |
+
//$actions['acfe-id'] = '<span style="color:#555;">ID: ' . $field_group['ID'] . '</span>';
|
379 |
+
$actions['acfe-key'] = '<span style="color:#555;"><code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . $field_group['key'] . '</code></span>';
|
380 |
+
|
381 |
+
return $actions;
|
382 |
+
|
383 |
+
}
|
384 |
+
|
385 |
+
/**
|
386 |
+
* Sidebar
|
387 |
+
*/
|
388 |
+
add_action('current_screen', function(){
|
389 |
+
|
390 |
+
if(!acf_is_screen('edit-acf-field-group'))
|
391 |
+
return;
|
392 |
+
|
393 |
+
add_action('admin_footer', function(){
|
394 |
+
?>
|
395 |
+
|
396 |
+
<!-- ACFE: Label -->
|
397 |
+
<script type="text/html" id="tmpl-acfe-label">
|
398 |
+
<span style="word-wrap: break-word;padding: 2px 6px;margin-left:1px;border-radius:2px;background:#ca4a1f;color: #fff; font-size: 14px;vertical-align: text-bottom;font-style: italic;">Extended</span>
|
399 |
+
</script>
|
400 |
+
|
401 |
+
<!-- ACFE: Debug -->
|
402 |
+
<script type="text/html" id="tmpl-acfe-debug">
|
403 |
+
<div class="acf-box">
|
404 |
+
</div>
|
405 |
+
</script>
|
406 |
+
|
407 |
+
<script type="text/javascript">
|
408 |
+
(function($){
|
409 |
+
|
410 |
+
// ACFE: Label
|
411 |
+
$('.acf-column-2 > .acf-box > .inner > h2').append($('#tmpl-acfe-label').html());
|
412 |
+
|
413 |
+
// ACFE: Debug
|
414 |
+
//$('#posts-filter').append($('#tmpl-acfe-debug').html());
|
415 |
+
|
416 |
+
|
417 |
+
// Fix no field groups found
|
418 |
+
$('#the-list tr.no-items td').attr('colspan', 9);
|
419 |
+
|
420 |
+
// ACFE: Table Row Actions - Export Wrap Form
|
421 |
+
$('.acfe-export-json .acfe-form').each(function(k, v){
|
422 |
+
$(this).wrapAll('<form action="' + $(this).attr('data-action') + '" method="post" style="display:inline;"></form>');
|
423 |
+
});
|
424 |
+
|
425 |
+
// ACFE: Table Row Actions - Export Submit Form
|
426 |
+
$('.acfe-export-json a').click(function(e){
|
427 |
+
e.preventDefault();
|
428 |
+
$(this).closest('form').submit();
|
429 |
+
});
|
430 |
+
})(jQuery);
|
431 |
+
</script>
|
432 |
+
<?php
|
433 |
+
});
|
434 |
+
|
435 |
+
});
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Hooks: Posts per page
|
439 |
+
*/
|
440 |
+
add_filter('edit_acf-field-group_per_page', 'acfe_field_groups_posts_per_page');
|
441 |
+
function acfe_field_groups_posts_per_page(){
|
442 |
+
|
443 |
+
return 999;
|
444 |
+
|
445 |
}
|
includes/fields-settings/bidirectional.php
CHANGED
@@ -1,565 +1,585 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Field Setting
|
8 |
-
*/
|
9 |
-
add_action('acf/render_field_settings/type=relationship', 'acfe_bidirectional_settings');
|
10 |
-
add_action('acf/render_field_settings/type=post_object', 'acfe_bidirectional_settings');
|
11 |
-
add_action('acf/render_field_settings/type=user', 'acfe_bidirectional_settings');
|
12 |
-
add_action('acf/render_field_settings/type=taxonomy', 'acfe_bidirectional_settings');
|
13 |
-
function acfe_bidirectional_settings($field){
|
14 |
-
|
15 |
-
// Settings
|
16 |
-
acf_render_field_setting($field, array(
|
17 |
-
'label' => __('Bidirectional'),
|
18 |
-
'key' => 'acfe_bidirectional',
|
19 |
-
'name' => 'acfe_bidirectional',
|
20 |
-
'instructions' => __('Set the field as bidirectional'),
|
21 |
-
'type' => 'group',
|
22 |
-
'required' => false,
|
23 |
-
'conditional_logic' => false,
|
24 |
-
'wrapper' => array(
|
25 |
-
'width' => '',
|
26 |
-
'class' => '',
|
27 |
-
'id' => '',
|
28 |
-
),
|
29 |
-
'layout' => 'block',
|
30 |
-
'sub_fields' => array(
|
31 |
-
array(
|
32 |
-
'label' => false,
|
33 |
-
'key' => 'acfe_bidirectional_enabled',
|
34 |
-
'name' => 'acfe_bidirectional_enabled',
|
35 |
-
'type' => 'true_false',
|
36 |
-
'instructions' => '',
|
37 |
-
'required' => false,
|
38 |
-
'wrapper' => array(
|
39 |
-
'width' => '15',
|
40 |
-
'class' => 'acfe_width_auto',
|
41 |
-
'id' => '',
|
42 |
-
),
|
43 |
-
'message' => '',
|
44 |
-
'default_value' => false,
|
45 |
-
'ui' => true,
|
46 |
-
'ui_on_text' => '',
|
47 |
-
'ui_off_text' => '',
|
48 |
-
'conditional_logic' => false,
|
49 |
-
),
|
50 |
-
array(
|
51 |
-
'label' => false,
|
52 |
-
'key' => 'acfe_bidirectional_related',
|
53 |
-
'name' => 'acfe_bidirectional_related',
|
54 |
-
'type' => 'select',
|
55 |
-
'instructions' => '',
|
56 |
-
'required' => false,
|
57 |
-
'wrapper' => array(
|
58 |
-
'width' => 50,
|
59 |
-
'class' => '',
|
60 |
-
'id' => '',
|
61 |
-
),
|
62 |
-
'choices' => array(),
|
63 |
-
'default_value' => array(),
|
64 |
-
'allow_null' => 1,
|
65 |
-
'multiple' => 0,
|
66 |
-
'ui' => 1,
|
67 |
-
'ajax' => 1,
|
68 |
-
'return_format' => 'value',
|
69 |
-
'placeholder' => '',
|
70 |
-
'conditional_logic' => array(
|
71 |
-
array(
|
72 |
-
array(
|
73 |
-
'field' => 'acfe_bidirectional_enabled',
|
74 |
-
'operator' => '==',
|
75 |
-
'value' => '1',
|
76 |
-
),
|
77 |
-
),
|
78 |
-
),
|
79 |
-
),
|
80 |
-
),
|
81 |
-
));
|
82 |
-
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Field Setting: Ajax Handler
|
87 |
-
*/
|
88 |
-
add_action('wp_ajax_acf/fields/select/query', 'acfe_bidirectional_ajax', 0);
|
89 |
-
add_action('wp_ajax_nopriv_acf/fields/select/query', 'acfe_bidirectional_ajax', 0);
|
90 |
-
function acfe_bidirectional_ajax(){
|
91 |
-
|
92 |
-
// Do not die to let ACF handle others ajax requests
|
93 |
-
if(!acf_verify_ajax())
|
94 |
-
return;
|
95 |
-
|
96 |
-
$options = acf_parse_args($_POST, array(
|
97 |
-
'post_id' => 0,
|
98 |
-
's' => '',
|
99 |
-
'field_key' => '',
|
100 |
-
'paged' => 1
|
101 |
-
));
|
102 |
-
|
103 |
-
// Not our field setting. Stop
|
104 |
-
if($options['field_key'] != 'acfe_bidirectional_related')
|
105 |
-
return;
|
106 |
-
|
107 |
-
$response = acfe_bidirectional_ajax_query($options);
|
108 |
-
|
109 |
-
acf_send_ajax_results($response);
|
110 |
-
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Field Setting: Ajax Query
|
115 |
-
*/
|
116 |
-
function acfe_bidirectional_ajax_query($options = array()){
|
117 |
-
|
118 |
-
// Current field group
|
119 |
-
$field_group = acf_get_field_group($options['post_id']);
|
120 |
-
|
121 |
-
// Get field groups
|
122 |
-
$r_field_groups = acf_get_field_groups();
|
123 |
-
if(empty($r_field_groups))
|
124 |
-
return false;
|
125 |
-
|
126 |
-
$choices = array();
|
127 |
-
|
128 |
-
foreach($r_field_groups as $r_field_group){
|
129 |
-
|
130 |
-
// Bypass current field group
|
131 |
-
if($r_field_group['key']
|
132 |
-
continue;
|
133 |
-
|
134 |
-
// Bypass ACFE native groups
|
135 |
-
if(in_array($r_field_group['key'], array('group_acfe_author', 'group_acfe_dynamic_post_type', 'group_acfe_dynamic_taxonomy')))
|
136 |
-
continue;
|
137 |
-
|
138 |
-
// Get related fields
|
139 |
-
$r_fields = acf_get_fields($r_field_group['key']);
|
140 |
-
if(empty($r_fields))
|
141 |
-
continue;
|
142 |
-
|
143 |
-
// Filter & find possible related fields
|
144 |
-
foreach($r_fields as $r_field){
|
145 |
-
|
146 |
-
acfe_bidirectional_setting_find_related($r_field, $r_field_group, $choices);
|
147 |
-
|
148 |
-
}
|
149 |
-
|
150 |
-
}
|
151 |
-
|
152 |
-
// vars
|
153 |
-
$results = array();
|
154 |
-
$s = null;
|
155 |
-
|
156 |
-
if(!empty($choices)){
|
157 |
-
|
158 |
-
// search
|
159 |
-
if($options['s'] !== ''){
|
160 |
-
|
161 |
-
// strip slashes (search may be integer)
|
162 |
-
$s = strval($options['s']);
|
163 |
-
$s = wp_unslash($s);
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
foreach($choices as $field_group_title => $childs){
|
168 |
-
|
169 |
-
$field_group_title = strval($field_group_title);
|
170 |
-
|
171 |
-
$childrens = array();
|
172 |
-
foreach($childs as $child_key => $child_label){
|
173 |
-
|
174 |
-
$child_label = strval($child_label);
|
175 |
-
|
176 |
-
// if searching, but doesn't exist
|
177 |
-
if(is_string($s) && stripos($child_label, $s) === false && stripos($field_group_title, $s) === false)
|
178 |
-
continue(2);
|
179 |
-
|
180 |
-
$childrens[] = array(
|
181 |
-
'id' => $child_key,
|
182 |
-
'text' => $child_label,
|
183 |
-
);
|
184 |
-
|
185 |
-
}
|
186 |
-
|
187 |
-
$results[] = array(
|
188 |
-
'text' => $field_group_title,
|
189 |
-
'children' => $childrens
|
190 |
-
);
|
191 |
-
|
192 |
-
}
|
193 |
-
|
194 |
-
}
|
195 |
-
|
196 |
-
return array(
|
197 |
-
'results' => $results
|
198 |
-
);
|
199 |
-
|
200 |
-
}
|
201 |
-
|
202 |
-
function acfe_bidirectional_setting_find_related($r_field, $r_field_group, &$choices){
|
203 |
-
|
204 |
-
if(in_array($r_field['type'], array('repeater', 'flexible_content')))
|
205 |
-
return;
|
206 |
-
|
207 |
-
// Recursive search for sub_fields (groups & clones)
|
208 |
-
if(isset($r_field['sub_fields']) && !empty($r_field['sub_fields'])){
|
209 |
-
|
210 |
-
foreach($r_field['sub_fields'] as $r_sub_field){
|
211 |
-
|
212 |
-
// Recursive call
|
213 |
-
return acfe_bidirectional_setting_find_related($r_sub_field, $r_field_group, $choices);
|
214 |
-
|
215 |
-
}
|
216 |
-
|
217 |
-
}
|
218 |
-
|
219 |
-
// Allow only specific fields
|
220 |
-
$allowed_fields_types = array('relationship', 'post_object', 'user', 'taxonomy');
|
221 |
-
if(!in_array($r_field['type'], $allowed_fields_types))
|
222 |
-
return false;
|
223 |
-
|
224 |
-
$choices[$r_field_group['title']][$r_field['key']] = (!empty($r_field['label']) ? $r_field['label'] : $r_field['name']) . ' (' . $r_field['key'] . ')';
|
225 |
-
|
226 |
-
}
|
227 |
-
|
228 |
-
/**
|
229 |
-
* Field Setting: Default Value
|
230 |
-
*/
|
231 |
-
add_filter('acf/prepare_field/name=acfe_bidirectional_related', 'acfe_bidirectional_setting_value');
|
232 |
-
function acfe_bidirectional_setting_value($field){
|
233 |
-
|
234 |
-
if(!isset($field['value']) || empty($field['value']))
|
235 |
-
return $field;
|
236 |
-
|
237 |
-
// Get related field
|
238 |
-
$r_field = acf_get_field($field['value']);
|
239 |
-
|
240 |
-
// Related field not found
|
241 |
-
if(!$r_field){
|
242 |
-
|
243 |
-
// Unset & updatevalue
|
244 |
-
$field['value'] = false;
|
245 |
-
acf_update_field($field);
|
246 |
-
|
247 |
-
return $field;
|
248 |
-
|
249 |
-
}
|
250 |
-
|
251 |
-
$r_field_group = acfe_get_field_group_from_field($r_field);
|
252 |
-
|
253 |
-
$field['choices'] = array($r_field['key'] => (!empty($r_field['label']) ? $r_field['label'] : $r_field['name']) . ' (' . $r_field['key'] . ')');
|
254 |
-
|
255 |
-
return $field;
|
256 |
-
|
257 |
-
}
|
258 |
-
|
259 |
-
/**
|
260 |
-
* Field Setting Update
|
261 |
-
*/
|
262 |
-
add_filter('acf/update_field/type=relationship', 'acfe_bidirectional_setting_update');
|
263 |
-
add_filter('acf/update_field/type=post_object', 'acfe_bidirectional_setting_update');
|
264 |
-
add_filter('acf/update_field/type=user', 'acfe_bidirectional_setting_update');
|
265 |
-
add_filter('acf/update_field/type=taxonomy', 'acfe_bidirectional_setting_update');
|
266 |
-
function acfe_bidirectional_setting_update($field){
|
267 |
-
|
268 |
-
$do_update = apply_filters('acfe/bidirectional/setting/update', true);
|
269 |
-
if(!$do_update)
|
270 |
-
return $field;
|
271 |
-
|
272 |
-
// Previous setting values
|
273 |
-
$_field = acf_get_field($field['key']);
|
274 |
-
|
275 |
-
// Turning off - Remove related field
|
276 |
-
if(acfe_has_field_bidirectional($_field) && !acfe_has_field_bidirectional($field)){
|
277 |
-
|
278 |
-
// Get related bidirectional related
|
279 |
-
$r_field = acf_get_field($_field['acfe_bidirectional']['acfe_bidirectional_related']);
|
280 |
-
|
281 |
-
// Reset related bidirectional related
|
282 |
-
$r_field['acfe_bidirectional']['acfe_bidirectional_enabled'] = false;
|
283 |
-
$r_field['acfe_bidirectional']['acfe_bidirectional_related'] = false;
|
284 |
-
|
285 |
-
add_filter('acfe/bidirectional/setting/update', '__return_false');
|
286 |
-
|
287 |
-
// Update related bidirectional
|
288 |
-
acf_update_field($r_field);
|
289 |
-
|
290 |
-
remove_filter('acfe/bidirectional/setting/update', '__return_false');
|
291 |
-
|
292 |
-
return $field;
|
293 |
-
|
294 |
-
}
|
295 |
-
|
296 |
-
// Turning on - Add related field
|
297 |
-
elseif(!acfe_has_field_bidirectional($_field) && acfe_has_field_bidirectional($field)){
|
298 |
-
|
299 |
-
// Get related bidirectional related
|
300 |
-
$r_field = acf_get_field($field['acfe_bidirectional']['acfe_bidirectional_related']);
|
301 |
-
|
302 |
-
// Reset related bidirectional related
|
303 |
-
$r_field['acfe_bidirectional']['acfe_bidirectional_enabled'] = true;
|
304 |
-
$r_field['acfe_bidirectional']['acfe_bidirectional_related'] = $field['key'];
|
305 |
-
|
306 |
-
add_filter('acfe/bidirectional/setting/update', '__return_false');
|
307 |
-
|
308 |
-
// Update related bidirectional
|
309 |
-
acf_update_field($r_field);
|
310 |
-
|
311 |
-
remove_filter('acfe/bidirectional/setting/update', '__return_false');
|
312 |
-
|
313 |
-
return $field;
|
314 |
-
|
315 |
-
}
|
316 |
-
|
317 |
-
// Return
|
318 |
-
return $field;
|
319 |
-
|
320 |
-
}
|
321 |
-
|
322 |
-
/**
|
323 |
-
* Field Setting Deleted
|
324 |
-
*/
|
325 |
-
add_action('acf/delete_field/type=relationship', 'acfe_bidirectional_setting_delete');
|
326 |
-
add_filter('acf/delete_field/type=post_object', 'acfe_bidirectional_setting_delete');
|
327 |
-
add_filter('acf/delete_field/type=user', 'acfe_bidirectional_setting_delete');
|
328 |
-
add_filter('acf/delete_field/type=taxonomy', 'acfe_bidirectional_setting_delete');
|
329 |
-
function acfe_bidirectional_setting_delete($field){
|
330 |
-
|
331 |
-
if(!acfe_has_field_bidirectional($field))
|
332 |
-
return;
|
333 |
-
|
334 |
-
// Get related bidirectional related
|
335 |
-
$r_field = acf_get_field($field['acfe_bidirectional']['acfe_bidirectional_related']);
|
336 |
-
|
337 |
-
// Reset related bidirectional related
|
338 |
-
$r_field['acfe_bidirectional']['acfe_bidirectional_related'] = false;
|
339 |
-
|
340 |
-
// Update related bidirectional
|
341 |
-
acf_update_field($r_field);
|
342 |
-
|
343 |
-
}
|
344 |
-
|
345 |
-
/**
|
346 |
-
* Update Value
|
347 |
-
*/
|
348 |
-
add_filter('acf/update_value/type=relationship', 'acfe_bidirectional_update_value', 11, 3);
|
349 |
-
add_filter('acf/update_value/type=post_object', 'acfe_bidirectional_update_value', 11, 3);
|
350 |
-
add_filter('acf/update_value/type=user', 'acfe_bidirectional_update_value', 11, 3);
|
351 |
-
add_filter('acf/update_value/type=taxonomy', 'acfe_bidirectional_update_value', 11, 3);
|
352 |
-
function acfe_bidirectional_update_value($value, $post_id, $field){
|
353 |
-
|
354 |
-
$ignore = apply_filters('acfe/bidirectional/ignore', false, $value, $post_id, $field);
|
355 |
-
if($ignore)
|
356 |
-
return $value;
|
357 |
-
|
358 |
-
// Check if bidirectional
|
359 |
-
if(!acfe_get_field_bidirectional($field))
|
360 |
-
return $value;
|
361 |
-
|
362 |
-
// Decode current post_id (ie: user_1)
|
363 |
-
$request = acf_decode_post_id($post_id);
|
364 |
-
|
365 |
-
// Values
|
366 |
-
$old_values = acf_get_array(acf_get_metadata($post_id, $field['name']));
|
367 |
-
$new_values = acf_get_array($value);
|
368 |
-
|
369 |
-
// Bail early if no difference
|
370 |
-
//if($old_values
|
371 |
-
// return $value;
|
372 |
-
|
373 |
-
// Values have been removed
|
374 |
-
if(!empty($old_values)){
|
375 |
-
foreach($old_values as $r_id){
|
376 |
-
|
377 |
-
if(in_array($r_id, $new_values))
|
378 |
-
continue;
|
379 |
-
|
380 |
-
acfe_bidirectional_relationship('remove', $r_id, $field, $request['id']);
|
381 |
-
|
382 |
-
}
|
383 |
-
}
|
384 |
-
|
385 |
-
// Values have been added
|
386 |
-
if(!empty($new_values)){
|
387 |
-
foreach($new_values as $r_id){
|
388 |
-
|
389 |
-
if(in_array($r_id, $old_values))
|
390 |
-
continue;
|
391 |
-
|
392 |
-
acfe_bidirectional_relationship('add', $r_id, $field, $request['id']);
|
393 |
-
|
394 |
-
}
|
395 |
-
}
|
396 |
-
|
397 |
-
return $value;
|
398 |
-
|
399 |
-
}
|
400 |
-
|
401 |
-
/**
|
402 |
-
* Establish Relationship
|
403 |
-
*
|
404 |
-
* $type: add|remove
|
405 |
-
* $r_id: the post_id to add the relationship to
|
406 |
-
* $p_field: the parent field
|
407 |
-
* $p_id: the relationship to add
|
408 |
-
*/
|
409 |
-
function acfe_bidirectional_relationship($type = 'add', $r_id, $p_field, $p_value){
|
410 |
-
|
411 |
-
// Get Related Field Configuration
|
412 |
-
$r_field = acf_get_field($p_field['acfe_bidirectional']['acfe_bidirectional_related']);
|
413 |
-
|
414 |
-
// Get if bidirectional is active
|
415 |
-
if(!acfe_get_field_bidirectional($r_field))
|
416 |
-
return;
|
417 |
-
|
418 |
-
// Get Related Data Type ({post_id}, user_{id} ...)
|
419 |
-
$r_mtype = '';
|
420 |
-
if($p_field['type']
|
421 |
-
$r_mtype = 'user_';
|
422 |
-
elseif($p_field['type']
|
423 |
-
$r_mtype = 'term_';
|
424 |
-
|
425 |
-
// Get Related Field Ancestors
|
426 |
-
$r_field_ancestors = acf_get_field_ancestors($r_field);
|
427 |
-
|
428 |
-
// Ancestors - Complexe field (group|clone)
|
429 |
-
if(!empty($r_field_ancestors)){
|
430 |
-
|
431 |
-
// Get ancestors
|
432 |
-
$r_field_ancestors = array_reverse($r_field_ancestors);
|
433 |
-
$r_field_ancestors_fields = array_map('acf_get_field', $r_field_ancestors);
|
434 |
-
|
435 |
-
// Get top ancestor
|
436 |
-
$r_ref_field = $r_field_ancestors_fields[0];
|
437 |
-
$r_ref_values = acf_get_array(acf_get_value($r_mtype.$r_id, $r_ref_field));
|
438 |
-
|
439 |
-
// Get values
|
440 |
-
$r_values = acf_get_array(acfe_get_value_from_ancestor($r_ref_values, $r_field));
|
441 |
-
|
442 |
-
// Unset top ancestor for update (not needed)
|
443 |
-
unset($r_field_ancestors_fields[0]);
|
444 |
-
|
445 |
-
// Add related field to get
|
446 |
-
$r_values_query = array($r_field['key']);
|
447 |
-
|
448 |
-
// If > 1 ancestors, return ancestors keys only
|
449 |
-
if(!empty($r_field_ancestors_fields)){
|
450 |
-
|
451 |
-
$r_field_ancestors_keys = array_map(function($field){
|
452 |
-
return $field['key'];
|
453 |
-
}, $r_field_ancestors_fields);
|
454 |
-
|
455 |
-
// Add ancestors to get
|
456 |
-
$r_values_query = array_merge($r_field_ancestors_keys, $r_values_query);
|
457 |
-
|
458 |
-
}
|
459 |
-
|
460 |
-
}
|
461 |
-
|
462 |
-
// No Ancestors - Simple field
|
463 |
-
else{
|
464 |
-
|
465 |
-
// Refence field
|
466 |
-
$r_ref_field = $r_field;
|
467 |
-
|
468 |
-
// Values
|
469 |
-
$r_values = acf_get_array(acf_get_value($r_mtype.$r_id, $r_field));
|
470 |
-
|
471 |
-
}
|
472 |
-
|
473 |
-
//
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
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 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
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 |
-
|
564 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
565 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Field Setting
|
8 |
+
*/
|
9 |
+
add_action('acf/render_field_settings/type=relationship', 'acfe_bidirectional_settings');
|
10 |
+
add_action('acf/render_field_settings/type=post_object', 'acfe_bidirectional_settings');
|
11 |
+
add_action('acf/render_field_settings/type=user', 'acfe_bidirectional_settings');
|
12 |
+
add_action('acf/render_field_settings/type=taxonomy', 'acfe_bidirectional_settings');
|
13 |
+
function acfe_bidirectional_settings($field){
|
14 |
+
|
15 |
+
// Settings
|
16 |
+
acf_render_field_setting($field, array(
|
17 |
+
'label' => __('Bidirectional'),
|
18 |
+
'key' => 'acfe_bidirectional',
|
19 |
+
'name' => 'acfe_bidirectional',
|
20 |
+
'instructions' => __('Set the field as bidirectional'),
|
21 |
+
'type' => 'group',
|
22 |
+
'required' => false,
|
23 |
+
'conditional_logic' => false,
|
24 |
+
'wrapper' => array(
|
25 |
+
'width' => '',
|
26 |
+
'class' => '',
|
27 |
+
'id' => '',
|
28 |
+
),
|
29 |
+
'layout' => 'block',
|
30 |
+
'sub_fields' => array(
|
31 |
+
array(
|
32 |
+
'label' => false,
|
33 |
+
'key' => 'acfe_bidirectional_enabled',
|
34 |
+
'name' => 'acfe_bidirectional_enabled',
|
35 |
+
'type' => 'true_false',
|
36 |
+
'instructions' => '',
|
37 |
+
'required' => false,
|
38 |
+
'wrapper' => array(
|
39 |
+
'width' => '15',
|
40 |
+
'class' => 'acfe_width_auto',
|
41 |
+
'id' => '',
|
42 |
+
),
|
43 |
+
'message' => '',
|
44 |
+
'default_value' => false,
|
45 |
+
'ui' => true,
|
46 |
+
'ui_on_text' => '',
|
47 |
+
'ui_off_text' => '',
|
48 |
+
'conditional_logic' => false,
|
49 |
+
),
|
50 |
+
array(
|
51 |
+
'label' => false,
|
52 |
+
'key' => 'acfe_bidirectional_related',
|
53 |
+
'name' => 'acfe_bidirectional_related',
|
54 |
+
'type' => 'select',
|
55 |
+
'instructions' => '',
|
56 |
+
'required' => false,
|
57 |
+
'wrapper' => array(
|
58 |
+
'width' => 50,
|
59 |
+
'class' => '',
|
60 |
+
'id' => '',
|
61 |
+
),
|
62 |
+
'choices' => array(),
|
63 |
+
'default_value' => array(),
|
64 |
+
'allow_null' => 1,
|
65 |
+
'multiple' => 0,
|
66 |
+
'ui' => 1,
|
67 |
+
'ajax' => 1,
|
68 |
+
'return_format' => 'value',
|
69 |
+
'placeholder' => '',
|
70 |
+
'conditional_logic' => array(
|
71 |
+
array(
|
72 |
+
array(
|
73 |
+
'field' => 'acfe_bidirectional_enabled',
|
74 |
+
'operator' => '==',
|
75 |
+
'value' => '1',
|
76 |
+
),
|
77 |
+
),
|
78 |
+
),
|
79 |
+
),
|
80 |
+
),
|
81 |
+
));
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Field Setting: Ajax Handler
|
87 |
+
*/
|
88 |
+
add_action('wp_ajax_acf/fields/select/query', 'acfe_bidirectional_ajax', 0);
|
89 |
+
add_action('wp_ajax_nopriv_acf/fields/select/query', 'acfe_bidirectional_ajax', 0);
|
90 |
+
function acfe_bidirectional_ajax(){
|
91 |
+
|
92 |
+
// Do not die to let ACF handle others ajax requests
|
93 |
+
if(!acf_verify_ajax())
|
94 |
+
return;
|
95 |
+
|
96 |
+
$options = acf_parse_args($_POST, array(
|
97 |
+
'post_id' => 0,
|
98 |
+
's' => '',
|
99 |
+
'field_key' => '',
|
100 |
+
'paged' => 1
|
101 |
+
));
|
102 |
+
|
103 |
+
// Not our field setting. Stop
|
104 |
+
if($options['field_key'] != 'acfe_bidirectional_related')
|
105 |
+
return;
|
106 |
+
|
107 |
+
$response = acfe_bidirectional_ajax_query($options);
|
108 |
+
|
109 |
+
acf_send_ajax_results($response);
|
110 |
+
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Field Setting: Ajax Query
|
115 |
+
*/
|
116 |
+
function acfe_bidirectional_ajax_query($options = array()){
|
117 |
+
|
118 |
+
// Current field group
|
119 |
+
$field_group = acf_get_field_group($options['post_id']);
|
120 |
+
|
121 |
+
// Get field groups
|
122 |
+
$r_field_groups = acf_get_field_groups();
|
123 |
+
if(empty($r_field_groups))
|
124 |
+
return false;
|
125 |
+
|
126 |
+
$choices = array();
|
127 |
+
|
128 |
+
foreach($r_field_groups as $r_field_group){
|
129 |
+
|
130 |
+
// Bypass current field group
|
131 |
+
if($r_field_group['key'] === $field_group['key'])
|
132 |
+
continue;
|
133 |
+
|
134 |
+
// Bypass ACFE native groups
|
135 |
+
if(in_array($r_field_group['key'], array('group_acfe_author', 'group_acfe_dynamic_post_type', 'group_acfe_dynamic_taxonomy')))
|
136 |
+
continue;
|
137 |
+
|
138 |
+
// Get related fields
|
139 |
+
$r_fields = acf_get_fields($r_field_group['key']);
|
140 |
+
if(empty($r_fields))
|
141 |
+
continue;
|
142 |
+
|
143 |
+
// Filter & find possible related fields
|
144 |
+
foreach($r_fields as $r_field){
|
145 |
+
|
146 |
+
acfe_bidirectional_setting_find_related($r_field, $r_field_group, $choices);
|
147 |
+
|
148 |
+
}
|
149 |
+
|
150 |
+
}
|
151 |
+
|
152 |
+
// vars
|
153 |
+
$results = array();
|
154 |
+
$s = null;
|
155 |
+
|
156 |
+
if(!empty($choices)){
|
157 |
+
|
158 |
+
// search
|
159 |
+
if($options['s'] !== ''){
|
160 |
+
|
161 |
+
// strip slashes (search may be integer)
|
162 |
+
$s = strval($options['s']);
|
163 |
+
$s = wp_unslash($s);
|
164 |
+
|
165 |
+
}
|
166 |
+
|
167 |
+
foreach($choices as $field_group_title => $childs){
|
168 |
+
|
169 |
+
$field_group_title = strval($field_group_title);
|
170 |
+
|
171 |
+
$childrens = array();
|
172 |
+
foreach($childs as $child_key => $child_label){
|
173 |
+
|
174 |
+
$child_label = strval($child_label);
|
175 |
+
|
176 |
+
// if searching, but doesn't exist
|
177 |
+
if(is_string($s) && stripos($child_label, $s) === false && stripos($field_group_title, $s) === false)
|
178 |
+
continue(2);
|
179 |
+
|
180 |
+
$childrens[] = array(
|
181 |
+
'id' => $child_key,
|
182 |
+
'text' => $child_label,
|
183 |
+
);
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
$results[] = array(
|
188 |
+
'text' => $field_group_title,
|
189 |
+
'children' => $childrens
|
190 |
+
);
|
191 |
+
|
192 |
+
}
|
193 |
+
|
194 |
+
}
|
195 |
+
|
196 |
+
return array(
|
197 |
+
'results' => $results
|
198 |
+
);
|
199 |
+
|
200 |
+
}
|
201 |
+
|
202 |
+
function acfe_bidirectional_setting_find_related($r_field, $r_field_group, &$choices){
|
203 |
+
|
204 |
+
if(in_array($r_field['type'], array('repeater', 'flexible_content')))
|
205 |
+
return;
|
206 |
+
|
207 |
+
// Recursive search for sub_fields (groups & clones)
|
208 |
+
if(isset($r_field['sub_fields']) && !empty($r_field['sub_fields'])){
|
209 |
+
|
210 |
+
foreach($r_field['sub_fields'] as $r_sub_field){
|
211 |
+
|
212 |
+
// Recursive call
|
213 |
+
return acfe_bidirectional_setting_find_related($r_sub_field, $r_field_group, $choices);
|
214 |
+
|
215 |
+
}
|
216 |
+
|
217 |
+
}
|
218 |
+
|
219 |
+
// Allow only specific fields
|
220 |
+
$allowed_fields_types = array('relationship', 'post_object', 'user', 'taxonomy');
|
221 |
+
if(!in_array($r_field['type'], $allowed_fields_types))
|
222 |
+
return false;
|
223 |
+
|
224 |
+
$choices[$r_field_group['title']][$r_field['key']] = (!empty($r_field['label']) ? $r_field['label'] : $r_field['name']) . ' (' . $r_field['key'] . ')';
|
225 |
+
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Field Setting: Default Value
|
230 |
+
*/
|
231 |
+
add_filter('acf/prepare_field/name=acfe_bidirectional_related', 'acfe_bidirectional_setting_value');
|
232 |
+
function acfe_bidirectional_setting_value($field){
|
233 |
+
|
234 |
+
if(!isset($field['value']) || empty($field['value']))
|
235 |
+
return $field;
|
236 |
+
|
237 |
+
// Get related field
|
238 |
+
$r_field = acf_get_field($field['value']);
|
239 |
+
|
240 |
+
// Related field not found
|
241 |
+
if(!$r_field){
|
242 |
+
|
243 |
+
// Unset & updatevalue
|
244 |
+
$field['value'] = false;
|
245 |
+
acf_update_field($field);
|
246 |
+
|
247 |
+
return $field;
|
248 |
+
|
249 |
+
}
|
250 |
+
|
251 |
+
$r_field_group = acfe_get_field_group_from_field($r_field);
|
252 |
+
|
253 |
+
$field['choices'] = array($r_field['key'] => (!empty($r_field['label']) ? $r_field['label'] : $r_field['name']) . ' (' . $r_field['key'] . ')');
|
254 |
+
|
255 |
+
return $field;
|
256 |
+
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Field Setting Update
|
261 |
+
*/
|
262 |
+
add_filter('acf/update_field/type=relationship', 'acfe_bidirectional_setting_update');
|
263 |
+
add_filter('acf/update_field/type=post_object', 'acfe_bidirectional_setting_update');
|
264 |
+
add_filter('acf/update_field/type=user', 'acfe_bidirectional_setting_update');
|
265 |
+
add_filter('acf/update_field/type=taxonomy', 'acfe_bidirectional_setting_update');
|
266 |
+
function acfe_bidirectional_setting_update($field){
|
267 |
+
|
268 |
+
$do_update = apply_filters('acfe/bidirectional/setting/update', true);
|
269 |
+
if(!$do_update)
|
270 |
+
return $field;
|
271 |
+
|
272 |
+
// Previous setting values
|
273 |
+
$_field = acf_get_field($field['key']);
|
274 |
+
|
275 |
+
// Turning off - Remove related field
|
276 |
+
if(acfe_has_field_bidirectional($_field) && !acfe_has_field_bidirectional($field)){
|
277 |
+
|
278 |
+
// Get related bidirectional related
|
279 |
+
$r_field = acf_get_field($_field['acfe_bidirectional']['acfe_bidirectional_related']);
|
280 |
+
|
281 |
+
// Reset related bidirectional related
|
282 |
+
$r_field['acfe_bidirectional']['acfe_bidirectional_enabled'] = false;
|
283 |
+
$r_field['acfe_bidirectional']['acfe_bidirectional_related'] = false;
|
284 |
+
|
285 |
+
add_filter('acfe/bidirectional/setting/update', '__return_false');
|
286 |
+
|
287 |
+
// Update related bidirectional
|
288 |
+
acf_update_field($r_field);
|
289 |
+
|
290 |
+
remove_filter('acfe/bidirectional/setting/update', '__return_false');
|
291 |
+
|
292 |
+
return $field;
|
293 |
+
|
294 |
+
}
|
295 |
+
|
296 |
+
// Turning on - Add related field
|
297 |
+
elseif(!acfe_has_field_bidirectional($_field) && acfe_has_field_bidirectional($field)){
|
298 |
+
|
299 |
+
// Get related bidirectional related
|
300 |
+
$r_field = acf_get_field($field['acfe_bidirectional']['acfe_bidirectional_related']);
|
301 |
+
|
302 |
+
// Reset related bidirectional related
|
303 |
+
$r_field['acfe_bidirectional']['acfe_bidirectional_enabled'] = true;
|
304 |
+
$r_field['acfe_bidirectional']['acfe_bidirectional_related'] = $field['key'];
|
305 |
+
|
306 |
+
add_filter('acfe/bidirectional/setting/update', '__return_false');
|
307 |
+
|
308 |
+
// Update related bidirectional
|
309 |
+
acf_update_field($r_field);
|
310 |
+
|
311 |
+
remove_filter('acfe/bidirectional/setting/update', '__return_false');
|
312 |
+
|
313 |
+
return $field;
|
314 |
+
|
315 |
+
}
|
316 |
+
|
317 |
+
// Return
|
318 |
+
return $field;
|
319 |
+
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Field Setting Deleted
|
324 |
+
*/
|
325 |
+
add_action('acf/delete_field/type=relationship', 'acfe_bidirectional_setting_delete');
|
326 |
+
add_filter('acf/delete_field/type=post_object', 'acfe_bidirectional_setting_delete');
|
327 |
+
add_filter('acf/delete_field/type=user', 'acfe_bidirectional_setting_delete');
|
328 |
+
add_filter('acf/delete_field/type=taxonomy', 'acfe_bidirectional_setting_delete');
|
329 |
+
function acfe_bidirectional_setting_delete($field){
|
330 |
+
|
331 |
+
if(!acfe_has_field_bidirectional($field))
|
332 |
+
return;
|
333 |
+
|
334 |
+
// Get related bidirectional related
|
335 |
+
$r_field = acf_get_field($field['acfe_bidirectional']['acfe_bidirectional_related']);
|
336 |
+
|
337 |
+
// Reset related bidirectional related
|
338 |
+
$r_field['acfe_bidirectional']['acfe_bidirectional_related'] = false;
|
339 |
+
|
340 |
+
// Update related bidirectional
|
341 |
+
acf_update_field($r_field);
|
342 |
+
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Update Value
|
347 |
+
*/
|
348 |
+
add_filter('acf/update_value/type=relationship', 'acfe_bidirectional_update_value', 11, 3);
|
349 |
+
add_filter('acf/update_value/type=post_object', 'acfe_bidirectional_update_value', 11, 3);
|
350 |
+
add_filter('acf/update_value/type=user', 'acfe_bidirectional_update_value', 11, 3);
|
351 |
+
add_filter('acf/update_value/type=taxonomy', 'acfe_bidirectional_update_value', 11, 3);
|
352 |
+
function acfe_bidirectional_update_value($value, $post_id, $field){
|
353 |
+
|
354 |
+
$ignore = apply_filters('acfe/bidirectional/ignore', false, $value, $post_id, $field);
|
355 |
+
if($ignore)
|
356 |
+
return $value;
|
357 |
+
|
358 |
+
// Check if bidirectional
|
359 |
+
if(!acfe_get_field_bidirectional($field))
|
360 |
+
return $value;
|
361 |
+
|
362 |
+
// Decode current post_id (ie: user_1)
|
363 |
+
$request = acf_decode_post_id($post_id);
|
364 |
+
|
365 |
+
// Values
|
366 |
+
$old_values = acf_get_array(acf_get_metadata($post_id, $field['name']));
|
367 |
+
$new_values = acf_get_array($value);
|
368 |
+
|
369 |
+
// Bail early if no difference
|
370 |
+
// if($old_values === $new_values)
|
371 |
+
// return $value;
|
372 |
+
|
373 |
+
// Values have been removed
|
374 |
+
if(!empty($old_values)){
|
375 |
+
foreach($old_values as $r_id){
|
376 |
+
|
377 |
+
if(in_array($r_id, $new_values))
|
378 |
+
continue;
|
379 |
+
|
380 |
+
acfe_bidirectional_relationship('remove', $r_id, $field, $request['id']);
|
381 |
+
|
382 |
+
}
|
383 |
+
}
|
384 |
+
|
385 |
+
// Values have been added
|
386 |
+
if(!empty($new_values)){
|
387 |
+
foreach($new_values as $r_id){
|
388 |
+
|
389 |
+
if(in_array($r_id, $old_values))
|
390 |
+
continue;
|
391 |
+
|
392 |
+
acfe_bidirectional_relationship('add', $r_id, $field, $request['id']);
|
393 |
+
|
394 |
+
}
|
395 |
+
}
|
396 |
+
|
397 |
+
return $value;
|
398 |
+
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Establish Relationship
|
403 |
+
*
|
404 |
+
* $type: add|remove
|
405 |
+
* $r_id: the post_id to add the relationship to
|
406 |
+
* $p_field: the parent field
|
407 |
+
* $p_id: the relationship to add
|
408 |
+
*/
|
409 |
+
function acfe_bidirectional_relationship($type = 'add', $r_id, $p_field, $p_value){
|
410 |
+
|
411 |
+
// Get Related Field Configuration
|
412 |
+
$r_field = acf_get_field($p_field['acfe_bidirectional']['acfe_bidirectional_related']);
|
413 |
+
|
414 |
+
// Get if bidirectional is active
|
415 |
+
if(!acfe_get_field_bidirectional($r_field))
|
416 |
+
return;
|
417 |
+
|
418 |
+
// Get Related Data Type ({post_id}, user_{id} ...)
|
419 |
+
$r_mtype = '';
|
420 |
+
if($p_field['type'] === 'user')
|
421 |
+
$r_mtype = 'user_';
|
422 |
+
elseif($p_field['type'] === 'taxonomy')
|
423 |
+
$r_mtype = 'term_';
|
424 |
+
|
425 |
+
// Get Related Field Ancestors
|
426 |
+
$r_field_ancestors = acf_get_field_ancestors($r_field);
|
427 |
+
|
428 |
+
// Ancestors - Complexe field (group|clone)
|
429 |
+
if(!empty($r_field_ancestors)){
|
430 |
+
|
431 |
+
// Get ancestors
|
432 |
+
$r_field_ancestors = array_reverse($r_field_ancestors);
|
433 |
+
$r_field_ancestors_fields = array_map('acf_get_field', $r_field_ancestors);
|
434 |
+
|
435 |
+
// Get top ancestor
|
436 |
+
$r_ref_field = $r_field_ancestors_fields[0];
|
437 |
+
$r_ref_values = acf_get_array(acf_get_value($r_mtype.$r_id, $r_ref_field));
|
438 |
+
|
439 |
+
// Get values
|
440 |
+
$r_values = acf_get_array(acfe_get_value_from_ancestor($r_ref_values, $r_field));
|
441 |
+
|
442 |
+
// Unset top ancestor for update (not needed)
|
443 |
+
unset($r_field_ancestors_fields[0]);
|
444 |
+
|
445 |
+
// Add related field to get
|
446 |
+
$r_values_query = array($r_field['key']);
|
447 |
+
|
448 |
+
// If > 1 ancestors, return ancestors keys only
|
449 |
+
if(!empty($r_field_ancestors_fields)){
|
450 |
+
|
451 |
+
$r_field_ancestors_keys = array_map(function($field){
|
452 |
+
return $field['key'];
|
453 |
+
}, $r_field_ancestors_fields);
|
454 |
+
|
455 |
+
// Add ancestors to get
|
456 |
+
$r_values_query = array_merge($r_field_ancestors_keys, $r_values_query);
|
457 |
+
|
458 |
+
}
|
459 |
+
|
460 |
+
}
|
461 |
+
|
462 |
+
// No Ancestors - Simple field
|
463 |
+
else{
|
464 |
+
|
465 |
+
// Refence field
|
466 |
+
$r_ref_field = $r_field;
|
467 |
+
|
468 |
+
// Values
|
469 |
+
$r_values = acf_get_array(acf_get_value($r_mtype.$r_id, $r_field));
|
470 |
+
|
471 |
+
}
|
472 |
+
|
473 |
+
// Convert strings to integers
|
474 |
+
$r_values = acf_parse_types($r_values);
|
475 |
+
|
476 |
+
// Add Value
|
477 |
+
if($type === 'add'){
|
478 |
+
|
479 |
+
if(!in_array($p_value, $r_values))
|
480 |
+
$r_values[] = $p_value;
|
481 |
+
|
482 |
+
}
|
483 |
+
|
484 |
+
// Remove Value
|
485 |
+
elseif($type === 'remove'){
|
486 |
+
|
487 |
+
$r_new_values = array();
|
488 |
+
foreach($r_values as $r_value){
|
489 |
+
|
490 |
+
if($r_value === $p_value)
|
491 |
+
continue;
|
492 |
+
|
493 |
+
$r_new_values[] = $r_value;
|
494 |
+
|
495 |
+
}
|
496 |
+
|
497 |
+
$r_values = $r_new_values;
|
498 |
+
|
499 |
+
}
|
500 |
+
|
501 |
+
/*
|
502 |
+
* Post Object & User 'Allow Multiple' Disabled
|
503 |
+
* Value must not be inside array
|
504 |
+
*/
|
505 |
+
if(($r_ref_field['type'] === 'post_object' || $r_ref_field['type'] === 'user') && empty($r_ref_field['multiple']) && isset($r_values[0])){
|
506 |
+
|
507 |
+
// Get latest value
|
508 |
+
$r_values = end($r_values);
|
509 |
+
|
510 |
+
}
|
511 |
+
|
512 |
+
/*
|
513 |
+
* Remove potential empty serialized array in meta value 'a:0:{}'
|
514 |
+
*/
|
515 |
+
if(empty($r_values))
|
516 |
+
$r_values = false;
|
517 |
+
|
518 |
+
/*
|
519 |
+
* Construct a value array in case of ancestors. ie:
|
520 |
+
* $related_values = Array(
|
521 |
+
* [field_aaa] => Array(
|
522 |
+
* [field_bbb] => Array(
|
523 |
+
* [0] => xxxx
|
524 |
+
* )
|
525 |
+
* )
|
526 |
+
* )
|
527 |
+
*/
|
528 |
+
if(!empty($r_field_ancestors)){
|
529 |
+
|
530 |
+
for($i = count($r_values_query)-1; $i>=0; $i--){
|
531 |
+
$r_values = array($r_values_query[$i] => $r_values);
|
532 |
+
}
|
533 |
+
|
534 |
+
}
|
535 |
+
|
536 |
+
// Filter acf_update_value (to avoid infinite loop)
|
537 |
+
add_filter('acfe/bidirectional/ignore', '__return_true');
|
538 |
+
|
539 |
+
// Update Related Field
|
540 |
+
acf_update_value($r_values, $r_mtype.$r_id, $r_ref_field);
|
541 |
+
|
542 |
+
// Remove acf_update_value filter
|
543 |
+
remove_filter('acfe/bidirectional/ignore', '__return_true');
|
544 |
+
|
545 |
+
}
|
546 |
+
|
547 |
+
function acfe_get_value_from_ancestor($r_ref_values, $r_field){
|
548 |
+
|
549 |
+
foreach($r_ref_values as $r_ref_key => $r_ref_value){
|
550 |
+
|
551 |
+
if($r_ref_key != $r_field['key']){
|
552 |
+
|
553 |
+
if(is_array($r_ref_value))
|
554 |
+
return acfe_get_value_from_ancestor($r_ref_value, $r_field);
|
555 |
+
|
556 |
+
return false;
|
557 |
+
|
558 |
+
}
|
559 |
+
|
560 |
+
return $r_ref_value;
|
561 |
+
|
562 |
+
}
|
563 |
+
|
564 |
+
}
|
565 |
+
|
566 |
+
function acfe_is_field_bidirectional($field){
|
567 |
+
|
568 |
+
return isset($field['acfe_bidirectional']['acfe_bidirectional_enabled']) && !empty($field['acfe_bidirectional']['acfe_bidirectional_enabled']);
|
569 |
+
|
570 |
+
}
|
571 |
+
|
572 |
+
function acfe_has_field_bidirectional($field){
|
573 |
+
|
574 |
+
return isset($field['acfe_bidirectional']['acfe_bidirectional_related']) && !empty($field['acfe_bidirectional']['acfe_bidirectional_related']);
|
575 |
+
|
576 |
+
}
|
577 |
+
|
578 |
+
function acfe_get_field_bidirectional($field){
|
579 |
+
|
580 |
+
if(!acfe_is_field_bidirectional($field) || !acfe_has_field_bidirectional($field))
|
581 |
+
return false;
|
582 |
+
|
583 |
+
return $field['acfe_bidirectional']['acfe_bidirectional_related'];
|
584 |
+
|
585 |
}
|
includes/fields-settings/data.php
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Setting: Field Data
|
8 |
-
*/
|
9 |
-
add_action('acf/render_field_settings', 'acfe_settings_field_data', 992);
|
10 |
-
function acfe_settings_field_data($field){
|
11 |
-
|
12 |
-
if(!isset($field['ID']) || $field['ID']
|
13 |
-
return;
|
14 |
-
|
15 |
-
$acfe_field_data_id = false;
|
16 |
-
if($field['ID'] != 'acfcloneindex')
|
17 |
-
$acfe_field_data_id = $field['ID'];
|
18 |
-
|
19 |
-
acf_render_field_setting($field, array(
|
20 |
-
'label' => false,
|
21 |
-
'instructions' => '',
|
22 |
-
'type' => 'acfe_dynamic_message',
|
23 |
-
'required' => false,
|
24 |
-
'name' => 'acfe_field_data',
|
25 |
-
'key' => 'acfe_field_data',
|
26 |
-
'value' => $acfe_field_data_id,
|
27 |
-
), true);
|
28 |
-
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Render: Field Data
|
33 |
-
*/
|
34 |
-
add_filter('acf/render_field/name=acfe_field_data', 'acfe_render_field_data');
|
35 |
-
function acfe_render_field_data($field){
|
36 |
-
|
37 |
-
$acfe_field_data_id = $field['value'];
|
38 |
-
|
39 |
-
$get_field = acf_get_field($acfe_field_data_id);
|
40 |
-
$get_field_debug = '<pre style="margin-bottom:15px;">' . print_r($get_field, true) . '</pre>';
|
41 |
-
|
42 |
-
if(!$get_field)
|
43 |
-
$get_field_debug = '<pre>Field data unavailable</pre>';
|
44 |
-
|
45 |
-
$get_post = get_post($acfe_field_data_id);
|
46 |
-
$get_post_debug = '<pre>' . print_r($get_post, true) . '</pre>';
|
47 |
-
|
48 |
-
if(!$get_post || $get_post->post_type !== 'acf-field'){
|
49 |
-
$get_post_debug = '<pre>Post object unavailable</pre>';
|
50 |
-
}
|
51 |
-
|
52 |
-
$button = '<a href="#" class="button acfe_modal_open" style="margin-left:5px;" data-modal-key="' . $acfe_field_data_id . '">' . __('Data') . '</a>';
|
53 |
-
if(!$get_field && !$get_post)
|
54 |
-
$button = '<a href="#" class="button disabled" disabled>' . __('Data') . '</a>';
|
55 |
-
|
56 |
-
echo $button . '<div class="acfe-modal" data-modal-key="' . $acfe_field_data_id . '"><div style="padding:15px;">' . $get_field_debug . $get_post_debug . '</div></div>';
|
57 |
-
|
58 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Setting: Field Data
|
8 |
+
*/
|
9 |
+
add_action('acf/render_field_settings', 'acfe_settings_field_data', 992);
|
10 |
+
function acfe_settings_field_data($field){
|
11 |
+
|
12 |
+
if(!isset($field['ID']) || $field['ID'] === 'acfcloneindex')
|
13 |
+
return;
|
14 |
+
|
15 |
+
$acfe_field_data_id = false;
|
16 |
+
if($field['ID'] != 'acfcloneindex')
|
17 |
+
$acfe_field_data_id = $field['ID'];
|
18 |
+
|
19 |
+
acf_render_field_setting($field, array(
|
20 |
+
'label' => false,
|
21 |
+
'instructions' => '',
|
22 |
+
'type' => 'acfe_dynamic_message',
|
23 |
+
'required' => false,
|
24 |
+
'name' => 'acfe_field_data',
|
25 |
+
'key' => 'acfe_field_data',
|
26 |
+
'value' => $acfe_field_data_id,
|
27 |
+
), true);
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Render: Field Data
|
33 |
+
*/
|
34 |
+
add_filter('acf/render_field/name=acfe_field_data', 'acfe_render_field_data');
|
35 |
+
function acfe_render_field_data($field){
|
36 |
+
|
37 |
+
$acfe_field_data_id = $field['value'];
|
38 |
+
|
39 |
+
$get_field = acf_get_field($acfe_field_data_id);
|
40 |
+
$get_field_debug = '<pre style="margin-bottom:15px;">' . print_r($get_field, true) . '</pre>';
|
41 |
+
|
42 |
+
if(!$get_field)
|
43 |
+
$get_field_debug = '<pre>Field data unavailable</pre>';
|
44 |
+
|
45 |
+
$get_post = get_post($acfe_field_data_id);
|
46 |
+
$get_post_debug = '<pre>' . print_r($get_post, true) . '</pre>';
|
47 |
+
|
48 |
+
if(!$get_post || $get_post->post_type !== 'acf-field'){
|
49 |
+
$get_post_debug = '<pre>Post object unavailable</pre>';
|
50 |
+
}
|
51 |
+
|
52 |
+
$button = '<a href="#" class="button acfe_modal_open" style="margin-left:5px;" data-modal-key="' . $acfe_field_data_id . '">' . __('Data') . '</a>';
|
53 |
+
if(!$get_field && !$get_post)
|
54 |
+
$button = '<a href="#" class="button disabled" disabled>' . __('Data') . '</a>';
|
55 |
+
|
56 |
+
echo $button . '<div class="acfe-modal" data-modal-key="' . $acfe_field_data_id . '"><div style="padding:15px;">' . $get_field_debug . $get_post_debug . '</div></div>';
|
57 |
+
|
58 |
}
|
includes/fields-settings/flexible-content.php
CHANGED
@@ -1,873 +1,935 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Add Settings
|
8 |
-
*/
|
9 |
-
add_action('acf/render_field_settings/type=flexible_content', 'acfe_flexible_settings', 0);
|
10 |
-
function acfe_flexible_settings($field){
|
11 |
-
|
12 |
-
// Stylised button
|
13 |
-
acf_render_field_setting($field, array(
|
14 |
-
'label' => __('Stylised Button'),
|
15 |
-
'name' => 'acfe_flexible_stylised_button',
|
16 |
-
'key' => 'acfe_flexible_stylised_button',
|
17 |
-
'instructions' => __('Better layouts button integration'),
|
18 |
-
'type' => 'true_false',
|
19 |
-
'message' => '',
|
20 |
-
'default_value' => false,
|
21 |
-
'ui' => true,
|
22 |
-
'ui_on_text' => '',
|
23 |
-
'ui_off_text' => '',
|
24 |
-
)
|
25 |
-
|
26 |
-
// Hide Empty Message
|
27 |
-
acf_render_field_setting($field, array(
|
28 |
-
'label' => __('Hide Empty Message'),
|
29 |
-
'name' => 'acfe_flexible_hide_empty_message',
|
30 |
-
'key' => 'acfe_flexible_hide_empty_message',
|
31 |
-
'instructions' => __('Hide the empty message box'),
|
32 |
-
'type' => 'true_false',
|
33 |
-
'message' => '',
|
34 |
-
'default_value' => false,
|
35 |
-
'ui' => true,
|
36 |
-
'ui_on_text' => '',
|
37 |
-
'ui_off_text' => '',
|
38 |
-
'conditional_logic' => array(
|
39 |
-
array(
|
40 |
-
array(
|
41 |
-
'field' => 'acfe_flexible_stylised_button',
|
42 |
-
'operator' => '!=',
|
43 |
-
'value' => '1',
|
44 |
-
),
|
45 |
-
)
|
46 |
-
)
|
47 |
-
)
|
48 |
-
|
49 |
-
// Empty Message
|
50 |
-
acf_render_field_setting($field, array(
|
51 |
-
'label' => __('Empty Message'),
|
52 |
-
'name' => 'acfe_flexible_empty_message',
|
53 |
-
'key' => 'acfe_flexible_empty_message',
|
54 |
-
'instructions' => __('Text displayed when the flexible field is empty'),
|
55 |
-
'type' => 'text',
|
56 |
-
'placeholder' => __('Click the "Add Row" button below to start creating your layout'),
|
57 |
-
'conditional_logic' => array(
|
58 |
-
array(
|
59 |
-
array(
|
60 |
-
'field' => 'acfe_flexible_stylised_button',
|
61 |
-
'operator' => '!=',
|
62 |
-
'value' => '1',
|
63 |
-
),
|
64 |
-
array(
|
65 |
-
'field' => 'acfe_flexible_hide_empty_message',
|
66 |
-
'operator' => '!=',
|
67 |
-
'value' => '1',
|
68 |
-
)
|
69 |
-
)
|
70 |
-
)
|
71 |
-
)
|
72 |
-
|
73 |
-
// Layouts thumbnails
|
74 |
-
acf_render_field_setting($field, array(
|
75 |
-
'label' => __('Layouts: Thumbnails'),
|
76 |
-
'name' => 'acfe_flexible_layouts_thumbnails',
|
77 |
-
'key' => 'acfe_flexible_layouts_thumbnails',
|
78 |
-
'instructions' => __('Set a thumbnail for each layouts. You must save the field group to apply this setting'),
|
79 |
-
'type' => 'true_false',
|
80 |
-
'message' => '',
|
81 |
-
'default_value' => false,
|
82 |
-
'ui' => true,
|
83 |
-
'ui_on_text' => '',
|
84 |
-
'ui_off_text' => '',
|
85 |
-
)
|
86 |
-
|
87 |
-
// Layouts: Render
|
88 |
-
acf_render_field_setting($field, array(
|
89 |
-
'label' => __('Layouts: Render'),
|
90 |
-
'name' => 'acfe_flexible_layouts_templates',
|
91 |
-
'key' => 'acfe_flexible_layouts_templates',
|
92 |
-
'instructions' => __('Set template, style & javascript files for each layouts
|
93 |
-
'type' => 'true_false',
|
94 |
-
'message' => '',
|
95 |
-
'default_value' => false,
|
96 |
-
'ui' => true,
|
97 |
-
'ui_on_text' => '',
|
98 |
-
'ui_off_text' => '',
|
99 |
-
)
|
100 |
-
|
101 |
-
// Layouts: Preview
|
102 |
-
acf_render_field_setting($field, array(
|
103 |
-
'label' => __('Layouts: Dynamic Preview'),
|
104 |
-
'name' => 'acfe_flexible_layouts_previews',
|
105 |
-
'key' => 'acfe_flexible_layouts_previews',
|
106 |
-
'instructions' => __('Use layouts render settings to display a dynamic preview in the post administration'),
|
107 |
-
'type' => 'true_false',
|
108 |
-
'message' => '',
|
109 |
-
'default_value' => false,
|
110 |
-
'ui' => true,
|
111 |
-
'ui_on_text' => '',
|
112 |
-
'ui_off_text' => '',
|
113 |
-
'conditional_logic' => array(
|
114 |
-
array(
|
115 |
-
array(
|
116 |
-
'field' => 'acfe_flexible_layouts_templates',
|
117 |
-
'operator' => '==',
|
118 |
-
'value' => '1',
|
119 |
-
)
|
120 |
-
)
|
121 |
-
)
|
122 |
-
)
|
123 |
-
|
124 |
-
// Layouts:
|
125 |
-
acf_render_field_setting($field, array(
|
126 |
-
'label' => __('Layouts:
|
127 |
-
'name' => '
|
128 |
-
'key' => '
|
129 |
-
'instructions' => __('Display a
|
130 |
-
'type' => 'true_false',
|
131 |
-
'message' => '',
|
132 |
-
'default_value' => false,
|
133 |
-
'ui' => true,
|
134 |
-
'ui_on_text' => '',
|
135 |
-
'ui_off_text' => '',
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
'
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
'
|
155 |
-
'
|
156 |
-
'
|
157 |
-
'
|
158 |
-
'
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
'
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
'
|
169 |
-
'
|
170 |
-
'
|
171 |
-
'
|
172 |
-
'
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
'
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
'
|
225 |
-
'
|
226 |
-
'
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
'
|
235 |
-
'
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
'
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
'
|
257 |
-
'
|
258 |
-
'
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
'
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
'
|
385 |
-
'
|
386 |
-
'
|
387 |
-
'
|
388 |
-
'
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
'
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
'
|
471 |
-
|
472 |
-
|
473 |
-
'
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
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 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
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 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
$
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
$
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
//
|
737 |
-
$
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
$
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
return $
|
872 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
873 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Add Settings
|
8 |
+
*/
|
9 |
+
add_action('acf/render_field_settings/type=flexible_content', 'acfe_flexible_settings', 0);
|
10 |
+
function acfe_flexible_settings($field){
|
11 |
+
|
12 |
+
// Stylised button
|
13 |
+
acf_render_field_setting($field, array(
|
14 |
+
'label' => __('Stylised Button'),
|
15 |
+
'name' => 'acfe_flexible_stylised_button',
|
16 |
+
'key' => 'acfe_flexible_stylised_button',
|
17 |
+
'instructions' => __('Better layouts button integration'),
|
18 |
+
'type' => 'true_false',
|
19 |
+
'message' => '',
|
20 |
+
'default_value' => false,
|
21 |
+
'ui' => true,
|
22 |
+
'ui_on_text' => '',
|
23 |
+
'ui_off_text' => '',
|
24 |
+
));
|
25 |
+
|
26 |
+
// Hide Empty Message
|
27 |
+
acf_render_field_setting($field, array(
|
28 |
+
'label' => __('Hide Empty Message'),
|
29 |
+
'name' => 'acfe_flexible_hide_empty_message',
|
30 |
+
'key' => 'acfe_flexible_hide_empty_message',
|
31 |
+
'instructions' => __('Hide the empty message box'),
|
32 |
+
'type' => 'true_false',
|
33 |
+
'message' => '',
|
34 |
+
'default_value' => false,
|
35 |
+
'ui' => true,
|
36 |
+
'ui_on_text' => '',
|
37 |
+
'ui_off_text' => '',
|
38 |
+
'conditional_logic' => array(
|
39 |
+
array(
|
40 |
+
array(
|
41 |
+
'field' => 'acfe_flexible_stylised_button',
|
42 |
+
'operator' => '!=',
|
43 |
+
'value' => '1',
|
44 |
+
),
|
45 |
+
)
|
46 |
+
)
|
47 |
+
));
|
48 |
+
|
49 |
+
// Empty Message
|
50 |
+
acf_render_field_setting($field, array(
|
51 |
+
'label' => __('Empty Message'),
|
52 |
+
'name' => 'acfe_flexible_empty_message',
|
53 |
+
'key' => 'acfe_flexible_empty_message',
|
54 |
+
'instructions' => __('Text displayed when the flexible field is empty'),
|
55 |
+
'type' => 'text',
|
56 |
+
'placeholder' => __('Click the "Add Row" button below to start creating your layout'),
|
57 |
+
'conditional_logic' => array(
|
58 |
+
array(
|
59 |
+
array(
|
60 |
+
'field' => 'acfe_flexible_stylised_button',
|
61 |
+
'operator' => '!=',
|
62 |
+
'value' => '1',
|
63 |
+
),
|
64 |
+
array(
|
65 |
+
'field' => 'acfe_flexible_hide_empty_message',
|
66 |
+
'operator' => '!=',
|
67 |
+
'value' => '1',
|
68 |
+
)
|
69 |
+
)
|
70 |
+
)
|
71 |
+
));
|
72 |
+
|
73 |
+
// Layouts thumbnails
|
74 |
+
acf_render_field_setting($field, array(
|
75 |
+
'label' => __('Layouts: Thumbnails'),
|
76 |
+
'name' => 'acfe_flexible_layouts_thumbnails',
|
77 |
+
'key' => 'acfe_flexible_layouts_thumbnails',
|
78 |
+
'instructions' => __('Set a thumbnail for each layouts. You must save the field group to apply this setting'),
|
79 |
+
'type' => 'true_false',
|
80 |
+
'message' => '',
|
81 |
+
'default_value' => false,
|
82 |
+
'ui' => true,
|
83 |
+
'ui_on_text' => '',
|
84 |
+
'ui_off_text' => '',
|
85 |
+
));
|
86 |
+
|
87 |
+
// Layouts: Render
|
88 |
+
acf_render_field_setting($field, array(
|
89 |
+
'label' => __('Layouts: Render'),
|
90 |
+
'name' => 'acfe_flexible_layouts_templates',
|
91 |
+
'key' => 'acfe_flexible_layouts_templates',
|
92 |
+
'instructions' => __('Set template, style & javascript files for each layouts. This setting is mandatory in order to use <code style="font-size:11px;">get_flexible()</code> function. You must save the field group to apply this setting'),
|
93 |
+
'type' => 'true_false',
|
94 |
+
'message' => '',
|
95 |
+
'default_value' => false,
|
96 |
+
'ui' => true,
|
97 |
+
'ui_on_text' => '',
|
98 |
+
'ui_off_text' => '',
|
99 |
+
));
|
100 |
+
|
101 |
+
// Layouts: Preview
|
102 |
+
acf_render_field_setting($field, array(
|
103 |
+
'label' => __('Layouts: Dynamic Preview'),
|
104 |
+
'name' => 'acfe_flexible_layouts_previews',
|
105 |
+
'key' => 'acfe_flexible_layouts_previews',
|
106 |
+
'instructions' => __('Use layouts render settings to display a dynamic preview in the post administration'),
|
107 |
+
'type' => 'true_false',
|
108 |
+
'message' => '',
|
109 |
+
'default_value' => false,
|
110 |
+
'ui' => true,
|
111 |
+
'ui_on_text' => '',
|
112 |
+
'ui_off_text' => '',
|
113 |
+
'conditional_logic' => array(
|
114 |
+
array(
|
115 |
+
array(
|
116 |
+
'field' => 'acfe_flexible_layouts_templates',
|
117 |
+
'operator' => '==',
|
118 |
+
'value' => '1',
|
119 |
+
)
|
120 |
+
)
|
121 |
+
)
|
122 |
+
));
|
123 |
+
|
124 |
+
// Layouts: Placholder
|
125 |
+
acf_render_field_setting($field, array(
|
126 |
+
'label' => __('Layouts: Placeholder'),
|
127 |
+
'name' => 'acfe_flexible_layouts_placeholder',
|
128 |
+
'key' => 'acfe_flexible_layouts_placeholder',
|
129 |
+
'instructions' => __('Display a placeholder with a pencil icon, making edition easier'),
|
130 |
+
'type' => 'true_false',
|
131 |
+
'message' => '',
|
132 |
+
'default_value' => false,
|
133 |
+
'ui' => true,
|
134 |
+
'ui_on_text' => '',
|
135 |
+
'ui_off_text' => '',
|
136 |
+
'conditional_logic' => array(
|
137 |
+
array(
|
138 |
+
array(
|
139 |
+
'field' => 'acfe_flexible_layouts_previews',
|
140 |
+
'operator' => '==',
|
141 |
+
'value' => '',
|
142 |
+
)
|
143 |
+
)
|
144 |
+
)
|
145 |
+
));
|
146 |
+
|
147 |
+
// Layouts: Close Button
|
148 |
+
acf_render_field_setting($field, array(
|
149 |
+
'label' => __('Layouts: Close Button'),
|
150 |
+
'name' => 'acfe_flexible_close_button',
|
151 |
+
'key' => 'acfe_flexible_close_button',
|
152 |
+
'instructions' => __('Display a close button to collapse the layout'),
|
153 |
+
'type' => 'true_false',
|
154 |
+
'message' => '',
|
155 |
+
'default_value' => false,
|
156 |
+
'ui' => true,
|
157 |
+
'ui_on_text' => '',
|
158 |
+
'ui_off_text' => '',
|
159 |
+
));
|
160 |
+
|
161 |
+
// Layouts: Title Edition
|
162 |
+
acf_render_field_setting($field, array(
|
163 |
+
'label' => __('Layouts: Title Edition'),
|
164 |
+
'name' => 'acfe_flexible_title_edition',
|
165 |
+
'key' => 'acfe_flexible_title_edition',
|
166 |
+
'instructions' => __('Allow layout title edition'),
|
167 |
+
'type' => 'true_false',
|
168 |
+
'message' => '',
|
169 |
+
'default_value' => false,
|
170 |
+
'ui' => true,
|
171 |
+
'ui_on_text' => '',
|
172 |
+
'ui_off_text' => '',
|
173 |
+
));
|
174 |
+
|
175 |
+
// Layouts: Copy/Paste
|
176 |
+
acf_render_field_setting($field, array(
|
177 |
+
'label' => __('Layouts: Copy/Paste'),
|
178 |
+
'name' => 'acfe_flexible_copy_paste',
|
179 |
+
'key' => 'acfe_flexible_copy_paste',
|
180 |
+
'instructions' => __('Allow copy/paste layouts functions'),
|
181 |
+
'type' => 'true_false',
|
182 |
+
'message' => '',
|
183 |
+
'default_value' => false,
|
184 |
+
'ui' => true,
|
185 |
+
'ui_on_text' => '',
|
186 |
+
'ui_off_text' => '',
|
187 |
+
));
|
188 |
+
|
189 |
+
// Modal: Edition
|
190 |
+
acf_render_field_setting($field, array(
|
191 |
+
'label' => __('Layouts Modal: Edition'),
|
192 |
+
'name' => 'acfe_flexible_modal_edition',
|
193 |
+
'key' => 'acfe_flexible_modal_edition',
|
194 |
+
'instructions' => __('Edit layout content in a modal'),
|
195 |
+
'type' => 'true_false',
|
196 |
+
'message' => '',
|
197 |
+
'default_value' => false,
|
198 |
+
'ui' => true,
|
199 |
+
'ui_on_text' => '',
|
200 |
+
'ui_off_text' => '',
|
201 |
+
));
|
202 |
+
|
203 |
+
// Modal: Selection
|
204 |
+
acf_render_field_setting($field, array(
|
205 |
+
'label' => __('Layouts Modal: Selection'),
|
206 |
+
'name' => 'acfe_flexible_modal',
|
207 |
+
'key' => 'acfe_flexible_modal',
|
208 |
+
'instructions' => __('Select layouts in a modal'),
|
209 |
+
'type' => 'group',
|
210 |
+
'layout' => 'block',
|
211 |
+
'sub_fields' => array(
|
212 |
+
array(
|
213 |
+
'label' => '',
|
214 |
+
'name' => 'acfe_flexible_modal_enabled',
|
215 |
+
'key' => 'acfe_flexible_modal_enabled',
|
216 |
+
'type' => 'true_false',
|
217 |
+
'instructions' => '',
|
218 |
+
'required' => false,
|
219 |
+
'wrapper' => array(
|
220 |
+
'width' => '',
|
221 |
+
'class' => '',
|
222 |
+
'id' => '',
|
223 |
+
),
|
224 |
+
'message' => '',
|
225 |
+
'default_value' => false,
|
226 |
+
'ui' => true,
|
227 |
+
'ui_on_text' => '',
|
228 |
+
'ui_off_text' => '',
|
229 |
+
'conditional_logic' => false,
|
230 |
+
),
|
231 |
+
array(
|
232 |
+
'label' => '',
|
233 |
+
'name' => 'acfe_flexible_modal_title',
|
234 |
+
'key' => 'acfe_flexible_modal_title',
|
235 |
+
'type' => 'text',
|
236 |
+
'prepend' => __('Modal Title'),
|
237 |
+
'placeholder' => 'Add Row',
|
238 |
+
'instructions' => false,
|
239 |
+
'required' => false,
|
240 |
+
'wrapper' => array(
|
241 |
+
'width' => '35',
|
242 |
+
'class' => '',
|
243 |
+
'id' => '',
|
244 |
+
),
|
245 |
+
'conditional_logic' => array(
|
246 |
+
array(
|
247 |
+
array(
|
248 |
+
'field' => 'acfe_flexible_modal_enabled',
|
249 |
+
'operator' => '==',
|
250 |
+
'value' => '1',
|
251 |
+
)
|
252 |
+
)
|
253 |
+
)
|
254 |
+
),
|
255 |
+
array(
|
256 |
+
'label' => '',
|
257 |
+
'name' => 'acfe_flexible_modal_col',
|
258 |
+
'key' => 'acfe_flexible_modal_col',
|
259 |
+
'type' => 'select',
|
260 |
+
'prepend' => '',
|
261 |
+
'instructions' => false,
|
262 |
+
'required' => false,
|
263 |
+
'choices' => array(
|
264 |
+
'1' => '1 column',
|
265 |
+
'2' => '2 columns',
|
266 |
+
'3' => '3 columns',
|
267 |
+
'4' => '4 columns',
|
268 |
+
'5' => '5 columns',
|
269 |
+
'6' => '6 columns',
|
270 |
+
),
|
271 |
+
'default_value' => '4',
|
272 |
+
'wrapper' => array(
|
273 |
+
'width' => '15',
|
274 |
+
'class' => '',
|
275 |
+
'id' => '',
|
276 |
+
),
|
277 |
+
'conditional_logic' => array(
|
278 |
+
array(
|
279 |
+
array(
|
280 |
+
'field' => 'acfe_flexible_modal_enabled',
|
281 |
+
'operator' => '==',
|
282 |
+
'value' => '1',
|
283 |
+
)
|
284 |
+
)
|
285 |
+
)
|
286 |
+
),
|
287 |
+
array(
|
288 |
+
'label' => '',
|
289 |
+
'name' => 'acfe_flexible_modal_categories',
|
290 |
+
'key' => 'acfe_flexible_modal_categories',
|
291 |
+
'type' => 'true_false',
|
292 |
+
'message' => __('Categories'),
|
293 |
+
'instructions' => false,
|
294 |
+
'required' => false,
|
295 |
+
'wrapper' => array(
|
296 |
+
'width' => '25',
|
297 |
+
'class' => '',
|
298 |
+
'id' => '',
|
299 |
+
),
|
300 |
+
'conditional_logic' => array(
|
301 |
+
array(
|
302 |
+
array(
|
303 |
+
'field' => 'acfe_flexible_modal_enabled',
|
304 |
+
'operator' => '==',
|
305 |
+
'value' => '1',
|
306 |
+
)
|
307 |
+
)
|
308 |
+
)
|
309 |
+
),
|
310 |
+
)
|
311 |
+
));
|
312 |
+
|
313 |
+
// Layouts: Force State
|
314 |
+
acf_render_field_setting($field, array(
|
315 |
+
'label' => __('Layouts: Force State'),
|
316 |
+
'name' => 'acfe_flexible_layouts_state',
|
317 |
+
'key' => 'acfe_flexible_layouts_state',
|
318 |
+
'instructions' => __('Force layouts to be collapsed or opened'),
|
319 |
+
'type' => 'select',
|
320 |
+
'allow_null' => true,
|
321 |
+
'choices' => array(
|
322 |
+
'collapse' => 'Collapsed',
|
323 |
+
'open' => 'Opened',
|
324 |
+
),
|
325 |
+
'conditional_logic' => array(
|
326 |
+
array(
|
327 |
+
array(
|
328 |
+
'field' => 'acfe_flexible_modal_edition',
|
329 |
+
'operator' => '!=',
|
330 |
+
'value' => '1',
|
331 |
+
)
|
332 |
+
)
|
333 |
+
)
|
334 |
+
));
|
335 |
+
|
336 |
+
}
|
337 |
+
|
338 |
+
add_action('acf/render_field', 'acfe_flexible_layouts_settings_before', 0);
|
339 |
+
function acfe_flexible_layouts_settings_before($field){
|
340 |
+
|
341 |
+
if($field['_name'] != 'label' || stripos($field['name'], '[layouts]') === false)
|
342 |
+
return;
|
343 |
+
|
344 |
+
echo '</li>';
|
345 |
+
|
346 |
+
acf_render_field_wrap(array(
|
347 |
+
'label' => __('Settings'),
|
348 |
+
'type' => 'hidden',
|
349 |
+
'name' => 'acfe_flexible_settings_label'
|
350 |
+
), 'ul');
|
351 |
+
|
352 |
+
echo '<li>';
|
353 |
+
|
354 |
+
}
|
355 |
+
|
356 |
+
add_action('acf/render_field', 'acfe_flexible_layouts_settings', 10);
|
357 |
+
function acfe_flexible_layouts_settings($field){
|
358 |
+
|
359 |
+
if($field['_name'] != 'max' || stripos($field['name'], '[layouts]') === false)
|
360 |
+
return;
|
361 |
+
|
362 |
+
$layout_prefix = $field['prefix'];
|
363 |
+
|
364 |
+
parse_str($layout_prefix, $output);
|
365 |
+
$keys = acfe_array_keys_r($output);
|
366 |
+
|
367 |
+
$_field_id = $keys[1];
|
368 |
+
$_layout_key = $keys[3];
|
369 |
+
|
370 |
+
$field_flexible = acf_get_field($_field_id);
|
371 |
+
$layout = $field_flexible['layouts'][$_layout_key];
|
372 |
+
|
373 |
+
$is_flexible_layouts_thumbnails = isset($field_flexible['acfe_flexible_layouts_thumbnails']) && !empty($field_flexible['acfe_flexible_layouts_thumbnails']);
|
374 |
+
$is_flexible_layouts_templates = isset($field_flexible['acfe_flexible_layouts_templates']) && !empty($field_flexible['acfe_flexible_layouts_templates']);
|
375 |
+
$is_flexible_modal_enabled = isset($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_enabled']) && !empty($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_enabled']);
|
376 |
+
$is_flexible_modal_categories = isset($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_categories']) && !empty($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_categories']);
|
377 |
+
|
378 |
+
// Category
|
379 |
+
if($is_flexible_modal_enabled && $is_flexible_modal_categories){
|
380 |
+
|
381 |
+
$acfe_flexible_category = isset($layout['acfe_flexible_category']) ? $layout['acfe_flexible_category'] : '';
|
382 |
+
|
383 |
+
acf_render_field_wrap(array(
|
384 |
+
'prepend' => __('Category'),
|
385 |
+
'name' => 'acfe_flexible_category',
|
386 |
+
'type' => 'text',
|
387 |
+
'class' => 'acf-fc-meta-name',
|
388 |
+
'prefix' => $layout_prefix,
|
389 |
+
'value' => $acfe_flexible_category,
|
390 |
+
'placeholder' => __('Multiple categories can be set using "|"')
|
391 |
+
|
392 |
+
/*
|
393 |
+
'conditional_logic' => array(
|
394 |
+
array(
|
395 |
+
array(
|
396 |
+
'field' => 'acfe_flexible_modal_enabled',
|
397 |
+
'operator' => '==',
|
398 |
+
'value' => '1',
|
399 |
+
),
|
400 |
+
array(
|
401 |
+
'field' => 'acfe_flexible_modal_categories',
|
402 |
+
'operator' => '==',
|
403 |
+
'value' => '1',
|
404 |
+
)
|
405 |
+
)
|
406 |
+
)
|
407 |
+
*/
|
408 |
+
|
409 |
+
), 'ul');
|
410 |
+
|
411 |
+
}
|
412 |
+
|
413 |
+
// Template
|
414 |
+
if($is_flexible_layouts_templates){
|
415 |
+
|
416 |
+
$acfe_flexible_render_template = isset($layout['acfe_flexible_render_template']) ? $layout['acfe_flexible_render_template'] : '';
|
417 |
+
|
418 |
+
acf_render_field_wrap(array(
|
419 |
+
'label' => __('Render'),
|
420 |
+
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
421 |
+
'name' => 'acfe_flexible_render_template',
|
422 |
+
'type' => 'text',
|
423 |
+
'class' => 'acf-fc-meta-name',
|
424 |
+
'prefix' => $layout_prefix,
|
425 |
+
'value' => $acfe_flexible_render_template,
|
426 |
+
'placeholder' => 'template.php',
|
427 |
+
|
428 |
+
/*
|
429 |
+
'conditional_logic' => array(
|
430 |
+
array(
|
431 |
+
array(
|
432 |
+
'field' => 'acfe_flexible_layouts_templates',
|
433 |
+
'operator' => '==',
|
434 |
+
'value' => '1',
|
435 |
+
)
|
436 |
+
)
|
437 |
+
)
|
438 |
+
*/
|
439 |
+
|
440 |
+
), 'ul');
|
441 |
+
|
442 |
+
$acfe_flexible_render_style = isset($layout['acfe_flexible_render_style']) ? $layout['acfe_flexible_render_style'] : '';
|
443 |
+
|
444 |
+
acf_render_field_wrap(array(
|
445 |
+
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
446 |
+
'name' => 'acfe_flexible_render_style',
|
447 |
+
'type' => 'text',
|
448 |
+
'class' => 'acf-fc-meta-name',
|
449 |
+
'prefix' => $layout_prefix,
|
450 |
+
'value' => $acfe_flexible_render_style,
|
451 |
+
'placeholder' => 'style.css',
|
452 |
+
|
453 |
+
/*
|
454 |
+
'conditional_logic' => array(
|
455 |
+
array(
|
456 |
+
array(
|
457 |
+
'field' => 'acfe_flexible_layouts_templates',
|
458 |
+
'operator' => '==',
|
459 |
+
'value' => '1',
|
460 |
+
)
|
461 |
+
)
|
462 |
+
)
|
463 |
+
*/
|
464 |
+
|
465 |
+
), 'ul');
|
466 |
+
|
467 |
+
$acfe_flexible_render_script = isset($layout['acfe_flexible_render_script']) ? $layout['acfe_flexible_render_script'] : '';
|
468 |
+
|
469 |
+
acf_render_field_wrap(array(
|
470 |
+
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
471 |
+
'name' => 'acfe_flexible_render_script',
|
472 |
+
'type' => 'text',
|
473 |
+
'class' => 'acf-fc-meta-name',
|
474 |
+
'prefix' => $layout_prefix,
|
475 |
+
'value' => $acfe_flexible_render_script,
|
476 |
+
'placeholder' => 'script.js',
|
477 |
+
|
478 |
+
/*
|
479 |
+
'conditional_logic' => array(
|
480 |
+
array(
|
481 |
+
array(
|
482 |
+
'field' => 'acfe_flexible_layouts_templates',
|
483 |
+
'operator' => '==',
|
484 |
+
'value' => '1',
|
485 |
+
)
|
486 |
+
)
|
487 |
+
)
|
488 |
+
*/
|
489 |
+
|
490 |
+
), 'ul');
|
491 |
+
|
492 |
+
}
|
493 |
+
|
494 |
+
// Thumbnail
|
495 |
+
if($is_flexible_layouts_thumbnails){
|
496 |
+
|
497 |
+
$acfe_flexible_thumbnail = isset($layout['acfe_flexible_thumbnail']) ? $layout['acfe_flexible_thumbnail'] : '';
|
498 |
+
|
499 |
+
acf_render_field_wrap(array(
|
500 |
+
'label' => __('Thumbnail'),
|
501 |
+
'name' => 'acfe_flexible_thumbnail',
|
502 |
+
'type' => 'image',
|
503 |
+
'class' => '',
|
504 |
+
'prefix' => $layout_prefix,
|
505 |
+
'value' => $acfe_flexible_thumbnail,
|
506 |
+
'return_format' => 'array',
|
507 |
+
'preview_size' => 'thumbnail',
|
508 |
+
'library' => 'all',
|
509 |
+
|
510 |
+
/*
|
511 |
+
'conditional_logic' => array(
|
512 |
+
array(
|
513 |
+
array(
|
514 |
+
'field' => 'acfe_flexible_layouts_thumbnails',
|
515 |
+
'operator' => '==',
|
516 |
+
'value' => '1',
|
517 |
+
)
|
518 |
+
)
|
519 |
+
)
|
520 |
+
*/
|
521 |
+
|
522 |
+
), 'ul');
|
523 |
+
|
524 |
+
}
|
525 |
+
|
526 |
+
}
|
527 |
+
|
528 |
+
add_filter('acf/field_wrapper_attributes', 'acfe_flexible_wrapper', 10, 2);
|
529 |
+
function acfe_flexible_wrapper($wrapper, $field){
|
530 |
+
|
531 |
+
if($field['type'] != 'flexible_content')
|
532 |
+
return $wrapper;
|
533 |
+
|
534 |
+
// Stylised button
|
535 |
+
if(isset($field['acfe_flexible_stylised_button']) && !empty($field['acfe_flexible_stylised_button'])){
|
536 |
+
|
537 |
+
$wrapper['data-acfe-flexible-stylised-button'] = 1;
|
538 |
+
|
539 |
+
}
|
540 |
+
|
541 |
+
// Hide Empty Message
|
542 |
+
if(isset($field['acfe_flexible_hide_empty_message']) && !empty($field['acfe_flexible_hide_empty_message']) || isset($field['acfe_flexible_stylised_button']) && !empty($field['acfe_flexible_stylised_button'])){
|
543 |
+
|
544 |
+
$wrapper['data-acfe-flexible-hide-empty-message'] = 1;
|
545 |
+
|
546 |
+
}
|
547 |
+
|
548 |
+
// Modal: Edition
|
549 |
+
if(isset($field['acfe_flexible_modal_edition']) && !empty($field['acfe_flexible_modal_edition'])){
|
550 |
+
|
551 |
+
$wrapper['data-acfe-flexible-modal-edition'] = 1;
|
552 |
+
|
553 |
+
}
|
554 |
+
|
555 |
+
// Modal: Selection
|
556 |
+
if(isset($field['acfe_flexible_modal']['acfe_flexible_modal_enabled']) && !empty($field['acfe_flexible_modal']['acfe_flexible_modal_enabled'])){
|
557 |
+
|
558 |
+
$wrapper['data-acfe-flexible-modal'] = 1;
|
559 |
+
|
560 |
+
// Columns
|
561 |
+
if(isset($field['acfe_flexible_modal']['acfe_flexible_modal_col']) && !empty($field['acfe_flexible_modal']['acfe_flexible_modal_col']))
|
562 |
+
$wrapper['data-acfe-flexible-modal-col'] = $field['acfe_flexible_modal']['acfe_flexible_modal_col'];
|
563 |
+
|
564 |
+
// Title
|
565 |
+
if(isset($field['acfe_flexible_modal']['acfe_flexible_modal_title']) && !empty($field['acfe_flexible_modal']['acfe_flexible_modal_title']))
|
566 |
+
$wrapper['data-acfe-flexible-modal-title'] = $field['acfe_flexible_modal']['acfe_flexible_modal_title'];
|
567 |
+
|
568 |
+
}
|
569 |
+
|
570 |
+
// Layouts: Title Edition
|
571 |
+
if(isset($field['acfe_flexible_title_edition']) && !empty($field['acfe_flexible_title_edition'])){
|
572 |
+
|
573 |
+
$wrapper['data-acfe-flexible-title-edition'] = 1;
|
574 |
+
|
575 |
+
}
|
576 |
+
|
577 |
+
// Layouts: Close Button
|
578 |
+
if(isset($field['acfe_flexible_close_button']) && !empty($field['acfe_flexible_close_button'])){
|
579 |
+
|
580 |
+
$wrapper['data-acfe-flexible-close-button'] = 1;
|
581 |
+
|
582 |
+
}
|
583 |
+
|
584 |
+
// Layouts: Copy/paste
|
585 |
+
if(isset($field['acfe_flexible_copy_paste']) && !empty($field['acfe_flexible_copy_paste'])){
|
586 |
+
|
587 |
+
$wrapper['data-acfe-flexible-copy-paste'] = 1;
|
588 |
+
|
589 |
+
}
|
590 |
+
|
591 |
+
// Layouts: State
|
592 |
+
if(isset($field['acfe_flexible_layouts_state']) && !empty($field['acfe_flexible_layouts_state'])){
|
593 |
+
|
594 |
+
// Collapse
|
595 |
+
if($field['acfe_flexible_layouts_state'] === 'collapse'){
|
596 |
+
|
597 |
+
$wrapper['data-acfe-flexible-collapse'] = 1;
|
598 |
+
|
599 |
+
}
|
600 |
+
|
601 |
+
// Open
|
602 |
+
elseif($field['acfe_flexible_layouts_state'] === 'open'){
|
603 |
+
|
604 |
+
$wrapper['data-acfe-flexible-open'] = 1;
|
605 |
+
|
606 |
+
}
|
607 |
+
|
608 |
+
}
|
609 |
+
|
610 |
+
// Layouts Placeholder
|
611 |
+
if(isset($field['acfe_flexible_layouts_placeholder']) && !empty($field['acfe_flexible_layouts_placeholder'])){
|
612 |
+
|
613 |
+
$wrapper['data-acfe-flexible-placeholder'] = 1;
|
614 |
+
|
615 |
+
}
|
616 |
+
|
617 |
+
// Layouts Previews
|
618 |
+
if(isset($field['acfe_flexible_layouts_templates']) && !empty($field['acfe_flexible_layouts_templates']) && isset($field['acfe_flexible_layouts_previews']) && !empty($field['acfe_flexible_layouts_previews'])){
|
619 |
+
|
620 |
+
$wrapper['data-acfe-flexible-preview'] = 1;
|
621 |
+
|
622 |
+
}
|
623 |
+
|
624 |
+
// Placeholder Icon
|
625 |
+
$layout_placeholder_icon = false;
|
626 |
+
$layout_placeholder_icon = apply_filters('acfe/flexible/placeholder/icon', $layout_placeholder_icon, $field);
|
627 |
+
$layout_placeholder_icon = apply_filters('acfe/flexible/placeholder/icon/name=' . $field['_name'], $layout_placeholder_icon, $field);
|
628 |
+
$layout_placeholder_icon = apply_filters('acfe/flexible/placeholder/icon/key=' . $field['key'], $layout_placeholder_icon, $field);
|
629 |
+
|
630 |
+
if(!empty($layout_placeholder_icon))
|
631 |
+
$wrapper['data-acfe-flexible-placeholder-icon'] = $layout_placeholder_icon;
|
632 |
+
|
633 |
+
return $wrapper;
|
634 |
+
|
635 |
+
}
|
636 |
+
|
637 |
+
add_filter('acf/fields/flexible_content/no_value_message', 'acfe_flexible_empty_message', 10, 2);
|
638 |
+
function acfe_flexible_empty_message($message, $field){
|
639 |
+
|
640 |
+
if(!isset($field['acfe_flexible_empty_message']) || empty($field['acfe_flexible_empty_message']))
|
641 |
+
return $message;
|
642 |
+
|
643 |
+
return $field['acfe_flexible_empty_message'];
|
644 |
+
|
645 |
+
}
|
646 |
+
|
647 |
+
add_filter('acf/prepare_field/type=flexible_content', 'acfe_flexible_layout_title_prepare');
|
648 |
+
function acfe_flexible_layout_title_prepare($field){
|
649 |
+
|
650 |
+
if(empty($field['layouts']))
|
651 |
+
return $field;
|
652 |
+
|
653 |
+
foreach($field['layouts'] as $k => &$layout){
|
654 |
+
|
655 |
+
// Thumbnail
|
656 |
+
$thumbnail = false;
|
657 |
+
if(isset($field['acfe_flexible_layouts_thumbnails']) && !empty($field['acfe_flexible_layouts_thumbnails'])){
|
658 |
+
|
659 |
+
$class = $style = array();
|
660 |
+
$class[] = 'acfe-flexible-layout-thumbnail';
|
661 |
+
|
662 |
+
// Modal disabled
|
663 |
+
if(!isset($field['acfe_flexible_modal']['acfe_flexible_modal_enabled']) || empty($field['acfe_flexible_modal']['acfe_flexible_modal_enabled']))
|
664 |
+
$class[] = 'acfe-flexible-layout-thumbnail-no-modal';
|
665 |
+
|
666 |
+
// Thumbnail is set
|
667 |
+
$thumbnail_found = false;
|
668 |
+
|
669 |
+
$acfe_flexible_thumbnail = false;
|
670 |
+
if(isset($layout['acfe_flexible_thumbnail']) && !empty($layout['acfe_flexible_thumbnail']))
|
671 |
+
$acfe_flexible_thumbnail = $layout['acfe_flexible_thumbnail'];
|
672 |
+
|
673 |
+
// Filter: acfe/flexible/layout/thumbnail/name={field:flexible:name}&layout={field:flexible:layout_name}
|
674 |
+
// Flexible Thumbnails
|
675 |
+
$acfe_flexible_thumbnail = apply_filters('acfe/flexible/thumbnail/name=' . $field['_name'], $acfe_flexible_thumbnail, $field, $layout);
|
676 |
+
$acfe_flexible_thumbnail = apply_filters('acfe/flexible/thumbnail/key=' . $field['key'], $acfe_flexible_thumbnail, $field, $layout);
|
677 |
+
|
678 |
+
$acfe_flexible_thumbnail = apply_filters('acfe/flexible/layout/thumbnail/layout=' . $layout['name'], $acfe_flexible_thumbnail, $field, $layout);
|
679 |
+
$acfe_flexible_thumbnail = apply_filters('acfe/flexible/layout/thumbnail/name=' . $field['_name'] . '&layout=' . $layout['name'], $acfe_flexible_thumbnail, $field, $layout);
|
680 |
+
$acfe_flexible_thumbnail = apply_filters('acfe/flexible/layout/thumbnail/key=' . $field['key'] . '&layout=' . $layout['name'], $acfe_flexible_thumbnail, $field, $layout);
|
681 |
+
|
682 |
+
if(!empty($acfe_flexible_thumbnail)){
|
683 |
+
|
684 |
+
// Thumbnail ID
|
685 |
+
if(is_numeric($acfe_flexible_thumbnail)){
|
686 |
+
|
687 |
+
if($thumbnail_src = wp_get_attachment_url($acfe_flexible_thumbnail)){
|
688 |
+
|
689 |
+
$thumbnail_found = true;
|
690 |
+
$style[] = 'background-image:url(' . $thumbnail_src . ');';
|
691 |
+
|
692 |
+
}
|
693 |
+
|
694 |
+
}
|
695 |
+
|
696 |
+
// Thumbnail URL
|
697 |
+
else{
|
698 |
+
|
699 |
+
$thumbnail_found = true;
|
700 |
+
$style[] = 'background-image:url(' . $acfe_flexible_thumbnail . ');';
|
701 |
+
|
702 |
+
}
|
703 |
+
|
704 |
+
}
|
705 |
+
|
706 |
+
// Thumbnail not found
|
707 |
+
if(!$thumbnail_found){
|
708 |
+
|
709 |
+
$class[] = 'acfe-flexible-layout-thumbnail-not-found';
|
710 |
+
|
711 |
+
}
|
712 |
+
|
713 |
+
$thumbnail = '<div class="' . implode(' ', $class) . '" style="' . implode(' ', $style) . '"></div>';
|
714 |
+
|
715 |
+
}
|
716 |
+
|
717 |
+
// Category
|
718 |
+
$category = '';
|
719 |
+
if(isset($layout['acfe_flexible_category']) && !empty($layout['acfe_flexible_category'])){
|
720 |
+
|
721 |
+
$category = 'data-acfe-flexible-category="' . $layout['acfe_flexible_category'] . '"';
|
722 |
+
|
723 |
+
}
|
724 |
+
|
725 |
+
$layout['label'] = $thumbnail . '<span '.$category.'>' . $layout['label'] . '</span>';
|
726 |
+
|
727 |
+
}
|
728 |
+
|
729 |
+
return $field;
|
730 |
+
|
731 |
+
}
|
732 |
+
|
733 |
+
add_filter('acf/fields/flexible_content/layout_title', 'acfe_flexible_layout_title_ajax', 0, 4);
|
734 |
+
function acfe_flexible_layout_title_ajax($title, $field, $layout, $i){
|
735 |
+
|
736 |
+
// Remove thumbnail
|
737 |
+
$title = preg_replace('#<div class="acfe-flexible-layout-thumbnail(.*?)</div>#', '', $title);
|
738 |
+
|
739 |
+
// Title Edition
|
740 |
+
if(isset($field['acfe_flexible_title_edition']) && !empty($field['acfe_flexible_title_edition'])){
|
741 |
+
|
742 |
+
// Get Layout Title
|
743 |
+
$acfe_flexible_layout_title = get_sub_field('acfe_flexible_layout_title');
|
744 |
+
if(!empty($acfe_flexible_layout_title))
|
745 |
+
$title = wp_unslash($acfe_flexible_layout_title);
|
746 |
+
|
747 |
+
// Return
|
748 |
+
return '<span class="acfe-layout-title acf-js-tooltip" title="' . __('Layout', 'acfe') . ': ' . esc_attr(strip_tags($layout['label'])) . '"><span class="acfe-layout-title-text">' . $title . '</span></span>';
|
749 |
+
|
750 |
+
}
|
751 |
+
|
752 |
+
// Return
|
753 |
+
return '<span class="acfe-layout-title-text">' . $title . '</span></span>';
|
754 |
+
|
755 |
+
}
|
756 |
+
|
757 |
+
add_action('acf/render_field/type=flexible_content', 'acfe_flexible_render_field');
|
758 |
+
function acfe_flexible_render_field($field){
|
759 |
+
|
760 |
+
if(!isset($field['acfe_flexible_layouts_templates']) || empty($field['acfe_flexible_layouts_templates']) || !isset($field['acfe_flexible_layouts_previews']) || empty($field['acfe_flexible_layouts_previews']) || empty($field['layouts']))
|
761 |
+
return;
|
762 |
+
|
763 |
+
// Vars
|
764 |
+
$is_preview = true;
|
765 |
+
|
766 |
+
// Actions
|
767 |
+
do_action('acfe/flexible/enqueue', $field, $is_preview);
|
768 |
+
do_action('acfe/flexible/enqueue/name=' . $field['_name'], $field, $is_preview);
|
769 |
+
do_action('acfe/flexible/enqueue/key=' . $field['key'], $field, $is_preview);
|
770 |
+
|
771 |
+
// Layouts Previews
|
772 |
+
foreach($field['layouts'] as $layout_key => $layout){
|
773 |
+
|
774 |
+
// Render: Enqueue
|
775 |
+
acfe_flexible_render_layout_enqueue($layout, $field);
|
776 |
+
|
777 |
+
}
|
778 |
+
|
779 |
+
}
|
780 |
+
|
781 |
+
add_action('wp_ajax_acfe/flexible/layout_preview', 'acfe_flexible_layout_preview');
|
782 |
+
function acfe_flexible_layout_preview(){
|
783 |
+
|
784 |
+
// Options
|
785 |
+
$options = acf_parse_args($_POST, array(
|
786 |
+
'post_id' => 0,
|
787 |
+
'i' => 0,
|
788 |
+
'field_key' => '',
|
789 |
+
'nonce' => '',
|
790 |
+
'layout' => '',
|
791 |
+
'value' => array()
|
792 |
+
));
|
793 |
+
|
794 |
+
// Load field
|
795 |
+
$field = acf_get_field($options['field_key']);
|
796 |
+
if(!$field)
|
797 |
+
die;
|
798 |
+
|
799 |
+
// Get Flexible
|
800 |
+
$flexible = acf_get_field_type('flexible_content');
|
801 |
+
|
802 |
+
// Vars
|
803 |
+
$layout = $flexible->get_layout($options['layout'], $field);
|
804 |
+
if(!$layout)
|
805 |
+
die;
|
806 |
+
|
807 |
+
// Flexible Thumbnails
|
808 |
+
$layout['acfe_flexible_thumbnail'] = apply_filters('acfe/flexible/thumbnail/name=' . $field['_name'], $layout['acfe_flexible_thumbnail'], $field, $layout);
|
809 |
+
$layout['acfe_flexible_thumbnail'] = apply_filters('acfe/flexible/thumbnail/key=' . $field['key'], $layout['acfe_flexible_thumbnail'], $field, $layout);
|
810 |
+
|
811 |
+
// Layout Thumbnails
|
812 |
+
$layout['acfe_flexible_thumbnail'] = apply_filters('acfe/flexible/layout/thumbnail/layout=' . $layout['name'], $layout['acfe_flexible_thumbnail'], $field, $layout);
|
813 |
+
$layout['acfe_flexible_thumbnail'] = apply_filters('acfe/flexible/layout/thumbnail/name=' . $field['_name'] . '&layout=' . $layout['name'], $layout['acfe_flexible_thumbnail'], $field, $layout);
|
814 |
+
$layout['acfe_flexible_thumbnail'] = apply_filters('acfe/flexible/layout/thumbnail/key=' . $field['key'] . '&layout=' . $layout['name'], $layout['acfe_flexible_thumbnail'], $field, $layout);
|
815 |
+
|
816 |
+
$get_field_object = get_field_object($options['field_key'], $options['post_id'], false, false);
|
817 |
+
|
818 |
+
$preview_key = 'preview_' . $options['field_key'];
|
819 |
+
$get_field_object['key'] = $preview_key;
|
820 |
+
|
821 |
+
acf_add_local_field($get_field_object);
|
822 |
+
|
823 |
+
add_filter('acf/load_value/key=' . $preview_key, function($value, $post_id, $field) use($options){
|
824 |
+
|
825 |
+
$value = array();
|
826 |
+
$value[0] = wp_unslash($options['value']);
|
827 |
+
|
828 |
+
return $value;
|
829 |
+
|
830 |
+
}, 10, 3);
|
831 |
+
|
832 |
+
if(have_rows($preview_key)):
|
833 |
+
while(have_rows($preview_key)): the_row();
|
834 |
+
|
835 |
+
// Flexible Preview
|
836 |
+
do_action('acfe/flexible/preview/name=' . $field['_name'], $field, $layout);
|
837 |
+
do_action('acfe/flexible/preview/key=' . $field['key'], $field, $layout);
|
838 |
+
|
839 |
+
// Flexible Layout Preview
|
840 |
+
do_action('acfe/flexible/layout/preview/layout=' . $layout['name'], $field, $layout);
|
841 |
+
do_action('acfe/flexible/layout/preview/name=' . $field['_name'] . '&layout=' . $layout['name'], $field, $layout);
|
842 |
+
do_action('acfe/flexible/layout/preview/key=' . $field['key'] . '&layout=' . $layout['name'], $field, $layout);
|
843 |
+
|
844 |
+
// ACFE: All Flexible Preview
|
845 |
+
do_action('acfe/flexible/preview', $field, $layout);
|
846 |
+
|
847 |
+
endwhile;
|
848 |
+
endif;
|
849 |
+
|
850 |
+
die;
|
851 |
+
|
852 |
+
}
|
853 |
+
|
854 |
+
add_action('acfe/flexible/preview', 'acfe_flexible_layout_preview_render', 99, 2);
|
855 |
+
function acfe_flexible_layout_preview_render($field, $layout){
|
856 |
+
|
857 |
+
global $is_preview;
|
858 |
+
|
859 |
+
$is_preview = true;
|
860 |
+
|
861 |
+
acfe_flexible_render_layout_template($layout, $field);
|
862 |
+
|
863 |
+
}
|
864 |
+
|
865 |
+
add_filter('acfe/flexible/render/template', 'acfe_flexible_layout_render_template_setting', 0, 4);
|
866 |
+
function acfe_flexible_layout_render_template_setting($return, $field, $layout, $is_preview){
|
867 |
+
|
868 |
+
if(isset($layout['acfe_flexible_render_template']) && !empty($layout['acfe_flexible_render_template']))
|
869 |
+
$return = $layout['acfe_flexible_render_template'];
|
870 |
+
|
871 |
+
return $return;
|
872 |
+
|
873 |
+
}
|
874 |
+
|
875 |
+
add_filter('acfe/flexible/render/style', 'acfe_flexible_layout_render_style_setting', 0, 4);
|
876 |
+
function acfe_flexible_layout_render_style_setting($return, $field, $layout, $is_preview){
|
877 |
+
|
878 |
+
if(isset($layout['acfe_flexible_render_style']) && !empty($layout['acfe_flexible_render_style']))
|
879 |
+
$return = $layout['acfe_flexible_render_style'];
|
880 |
+
|
881 |
+
return $return;
|
882 |
+
|
883 |
+
}
|
884 |
+
|
885 |
+
add_filter('acfe/flexible/render/script', 'acfe_flexible_layout_render_script_setting', 0, 4);
|
886 |
+
function acfe_flexible_layout_render_script_setting($return, $field, $layout, $is_preview){
|
887 |
+
|
888 |
+
if(isset($layout['acfe_flexible_render_script']) && !empty($layout['acfe_flexible_render_script']))
|
889 |
+
$return = $layout['acfe_flexible_render_script'];
|
890 |
+
|
891 |
+
return $return;
|
892 |
+
|
893 |
+
}
|
894 |
+
|
895 |
+
add_filter('acf/load_field/type=flexible_content', 'acfe_flexible_layout_title_subfield');
|
896 |
+
function acfe_flexible_layout_title_subfield($field){
|
897 |
+
|
898 |
+
global $typenow;
|
899 |
+
|
900 |
+
if(acf_is_screen(array('edit-acf-field-group', 'acf-field-group')) || (isset($typenow) && $typenow === 'acf-field-group'))
|
901 |
+
return $field;
|
902 |
+
|
903 |
+
if(!isset($field['layouts']) || empty($field['layouts']))
|
904 |
+
return $field;
|
905 |
+
|
906 |
+
if(!isset($field['acfe_flexible_title_edition']) || empty($field['acfe_flexible_title_edition']))
|
907 |
+
return $field;
|
908 |
+
|
909 |
+
foreach($field['layouts'] as $layout_key => &$layout){
|
910 |
+
|
911 |
+
// Add the input as the first sub_field
|
912 |
+
array_unshift($layout['sub_fields'] , array(
|
913 |
+
'ID' => false,
|
914 |
+
'label' => false,
|
915 |
+
'key' => 'field_acfe_flexible_layout_title',
|
916 |
+
'name' => 'acfe_flexible_layout_title',
|
917 |
+
'_name' => 'acfe_flexible_layout_title',
|
918 |
+
'type' => 'text',
|
919 |
+
'required' => 0,
|
920 |
+
'maxlength' => null,
|
921 |
+
'parent' => false,
|
922 |
+
'default_value' => $layout['label'],
|
923 |
+
'placeholder' => $layout['label'],
|
924 |
+
'wrapper' => array(
|
925 |
+
'id' => '',
|
926 |
+
'class' => '',
|
927 |
+
'width' => '',
|
928 |
+
)
|
929 |
+
));
|
930 |
+
|
931 |
+
}
|
932 |
+
|
933 |
+
return $field;
|
934 |
+
|
935 |
}
|
includes/fields-settings/image.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
add_filter('gettext', 'acfe_field_image_text', 99, 3);
|
7 |
-
function acfe_field_image_text($translated_text, $text, $domain){
|
8 |
-
|
9 |
-
if($domain != 'acf')
|
10 |
-
return $translated_text;
|
11 |
-
|
12 |
-
if($text === 'No image selected')
|
13 |
-
return '';
|
14 |
-
|
15 |
-
return $translated_text;
|
16 |
-
|
17 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
add_filter('gettext', 'acfe_field_image_text', 99, 3);
|
7 |
+
function acfe_field_image_text($translated_text, $text, $domain){
|
8 |
+
|
9 |
+
if($domain != 'acf')
|
10 |
+
return $translated_text;
|
11 |
+
|
12 |
+
if($text === 'No image selected')
|
13 |
+
return '';
|
14 |
+
|
15 |
+
return $translated_text;
|
16 |
+
|
17 |
}
|
includes/fields-settings/permissions.php
CHANGED
@@ -1,51 +1,51 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
add_action('acf/render_field_settings', 'acfe_permissions_settings', 999);
|
7 |
-
function acfe_permissions_settings($field){
|
8 |
-
|
9 |
-
// Settings
|
10 |
-
acf_render_field_setting($field, array(
|
11 |
-
'label' => __('Permissions'),
|
12 |
-
'name' => 'acfe_permissions',
|
13 |
-
'key' => 'acfe_permissions',
|
14 |
-
'instructions' => __('Select user roles that are allowed to view and edit this field. If nothing is selected, then this field will be available to everyone.'),
|
15 |
-
'type' => 'checkbox',
|
16 |
-
'required' => false,
|
17 |
-
'default_value' => false,
|
18 |
-
'choices' => acfe_get_roles(),
|
19 |
-
'layout' => 'horizontal'
|
20 |
-
), true);
|
21 |
-
|
22 |
-
}
|
23 |
-
|
24 |
-
add_filter('acf/prepare_field', 'acfe_roles_prepare_field');
|
25 |
-
function acfe_roles_prepare_field($field){
|
26 |
-
|
27 |
-
if(!isset($field['acfe_permissions']) || empty($field['acfe_permissions']))
|
28 |
-
return $field;
|
29 |
-
|
30 |
-
$current_user_roles = acfe_get_current_user_roles();
|
31 |
-
$render_field = false;
|
32 |
-
|
33 |
-
foreach($current_user_roles as $current_user_role){
|
34 |
-
foreach($field['acfe_permissions'] as $field_role){
|
35 |
-
if($current_user_role !== $field_role)
|
36 |
-
continue;
|
37 |
-
|
38 |
-
$render_field = true;
|
39 |
-
break;
|
40 |
-
}
|
41 |
-
|
42 |
-
if($render_field)
|
43 |
-
break;
|
44 |
-
}
|
45 |
-
|
46 |
-
if(!$render_field)
|
47 |
-
return false;
|
48 |
-
|
49 |
-
return $field;
|
50 |
-
|
51 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
add_action('acf/render_field_settings', 'acfe_permissions_settings', 999);
|
7 |
+
function acfe_permissions_settings($field){
|
8 |
+
|
9 |
+
// Settings
|
10 |
+
acf_render_field_setting($field, array(
|
11 |
+
'label' => __('Permissions'),
|
12 |
+
'name' => 'acfe_permissions',
|
13 |
+
'key' => 'acfe_permissions',
|
14 |
+
'instructions' => __('Select user roles that are allowed to view and edit this field. If nothing is selected, then this field will be available to everyone.'),
|
15 |
+
'type' => 'checkbox',
|
16 |
+
'required' => false,
|
17 |
+
'default_value' => false,
|
18 |
+
'choices' => acfe_get_roles(),
|
19 |
+
'layout' => 'horizontal'
|
20 |
+
), true);
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
add_filter('acf/prepare_field', 'acfe_roles_prepare_field');
|
25 |
+
function acfe_roles_prepare_field($field){
|
26 |
+
|
27 |
+
if(!isset($field['acfe_permissions']) || empty($field['acfe_permissions']))
|
28 |
+
return $field;
|
29 |
+
|
30 |
+
$current_user_roles = acfe_get_current_user_roles();
|
31 |
+
$render_field = false;
|
32 |
+
|
33 |
+
foreach($current_user_roles as $current_user_role){
|
34 |
+
foreach($field['acfe_permissions'] as $field_role){
|
35 |
+
if($current_user_role !== $field_role)
|
36 |
+
continue;
|
37 |
+
|
38 |
+
$render_field = true;
|
39 |
+
break;
|
40 |
+
}
|
41 |
+
|
42 |
+
if($render_field)
|
43 |
+
break;
|
44 |
+
}
|
45 |
+
|
46 |
+
if(!$render_field)
|
47 |
+
return false;
|
48 |
+
|
49 |
+
return $field;
|
50 |
+
|
51 |
}
|
includes/fields-settings/thumbnail.php
CHANGED
@@ -1,40 +1,40 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Field Setting
|
8 |
-
*/
|
9 |
-
add_action('acf/render_field_settings/type=image', 'acfe_thumbnail_settings');
|
10 |
-
function acfe_thumbnail_settings($field){
|
11 |
-
|
12 |
-
acf_render_field_setting($field, array(
|
13 |
-
'label' => __('Featured thumbnail'),
|
14 |
-
'name' => 'acfe_thumbnail',
|
15 |
-
'key' => 'acfe_thumbnail',
|
16 |
-
'instructions' => __('Make this image the featured thumbnail'),
|
17 |
-
'type' => 'true_false',
|
18 |
-
'default_value' => false,
|
19 |
-
'ui' => true,
|
20 |
-
'ui_on_text' => '',
|
21 |
-
'ui_off_text' => '',
|
22 |
-
'required' => false,
|
23 |
-
));
|
24 |
-
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Field Value Update
|
29 |
-
*/
|
30 |
-
add_filter('acf/update_value/type=image', 'acfe_thumbnail_update', 10, 3);
|
31 |
-
function acfe_thumbnail_update($value, $post_id, $field){
|
32 |
-
|
33 |
-
if(!isset($field['acfe_thumbnail']) || empty($field['acfe_thumbnail']) || empty($value) || empty(get_post_type($post_id)))
|
34 |
-
return $value;
|
35 |
-
|
36 |
-
update_post_meta($post_id, '_thumbnail_id', $value);
|
37 |
-
|
38 |
-
return $value;
|
39 |
-
|
40 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Field Setting
|
8 |
+
*/
|
9 |
+
add_action('acf/render_field_settings/type=image', 'acfe_thumbnail_settings');
|
10 |
+
function acfe_thumbnail_settings($field){
|
11 |
+
|
12 |
+
acf_render_field_setting($field, array(
|
13 |
+
'label' => __('Featured thumbnail'),
|
14 |
+
'name' => 'acfe_thumbnail',
|
15 |
+
'key' => 'acfe_thumbnail',
|
16 |
+
'instructions' => __('Make this image the featured thumbnail'),
|
17 |
+
'type' => 'true_false',
|
18 |
+
'default_value' => false,
|
19 |
+
'ui' => true,
|
20 |
+
'ui_on_text' => '',
|
21 |
+
'ui_off_text' => '',
|
22 |
+
'required' => false,
|
23 |
+
));
|
24 |
+
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Field Value Update
|
29 |
+
*/
|
30 |
+
add_filter('acf/update_value/type=image', 'acfe_thumbnail_update', 10, 3);
|
31 |
+
function acfe_thumbnail_update($value, $post_id, $field){
|
32 |
+
|
33 |
+
if(!isset($field['acfe_thumbnail']) || empty($field['acfe_thumbnail']) || empty($value) || empty(get_post_type($post_id)))
|
34 |
+
return $value;
|
35 |
+
|
36 |
+
update_post_meta($post_id, '_thumbnail_id', $value);
|
37 |
+
|
38 |
+
return $value;
|
39 |
+
|
40 |
}
|
includes/fields-settings/update.php
CHANGED
@@ -1,162 +1,162 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Setting: Native functions
|
8 |
-
*/
|
9 |
-
add_filter('acfe/update/functions', 'acfe_update_functions', 0);
|
10 |
-
function acfe_update_functions($choices){
|
11 |
-
|
12 |
-
return array(
|
13 |
-
'Sanitize' => array(
|
14 |
-
'sanitize_email' => 'Sanitize email (sanitize_email)',
|
15 |
-
'sanitize_file_name' => 'Sanitize file name (sanitize_file_name)',
|
16 |
-
'sanitize_html_class' => 'Sanitize html class (sanitize_html_class)',
|
17 |
-
'sanitize_key' => 'Sanitize key (sanitize_key)',
|
18 |
-
'sanitize_meta' => 'Sanitize meta (sanitize_meta)',
|
19 |
-
'sanitize_mime_type' => 'Sanitize mime type (sanitize_mime_type)',
|
20 |
-
'sanitize_option' => 'Sanitize option (sanitize_option)',
|
21 |
-
'sanitize_text_field' => 'Sanitize text field (sanitize_text_field)',
|
22 |
-
'sanitize_title' => 'Sanitize title (sanitize_title)',
|
23 |
-
'sanitize_user' => 'Sanitize user (sanitize_user)',
|
24 |
-
),
|
25 |
-
);
|
26 |
-
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Exclude layout advanced fields
|
31 |
-
*/
|
32 |
-
add_filter('acfe/update/exclude', 'acfe_update_exclude', 0, 2);
|
33 |
-
function acfe_update_exclude($exclude, $type){
|
34 |
-
|
35 |
-
$excludes = array('message', 'accordion', 'tab', 'group', 'repeater', 'flexible_content', 'clone', 'acfe_dynamic_message');
|
36 |
-
if(in_array($type, $excludes))
|
37 |
-
$exclude = true;
|
38 |
-
|
39 |
-
return $exclude;
|
40 |
-
|
41 |
-
}
|
42 |
-
|
43 |
-
foreach(acf_get_field_types_info() as $field){
|
44 |
-
|
45 |
-
$type = $field['name'];
|
46 |
-
|
47 |
-
$exclude = apply_filters('acfe/update/exclude', false, $type);
|
48 |
-
if($exclude)
|
49 |
-
continue;
|
50 |
-
|
51 |
-
add_action('acf/render_field_settings/type=' . $type, 'acfe_update_settings', 991);
|
52 |
-
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Add Setting
|
57 |
-
*/
|
58 |
-
function acfe_update_settings($field){
|
59 |
-
|
60 |
-
$choices = apply_filters('acfe/update/functions', array(), $field);
|
61 |
-
if(empty($choices))
|
62 |
-
return;
|
63 |
-
|
64 |
-
// Settings
|
65 |
-
acf_render_field_setting($field, array(
|
66 |
-
'label' => __('Filters'),
|
67 |
-
'name' => 'acfe_update',
|
68 |
-
'key' => 'acfe_update',
|
69 |
-
'instructions' => __('Filter value right before saving'),
|
70 |
-
'type' => 'repeater',
|
71 |
-
'button_label' => __('Add filter'),
|
72 |
-
'required' => false,
|
73 |
-
'sub_fields' => array(
|
74 |
-
array(
|
75 |
-
'label' => 'Function',
|
76 |
-
'name' => 'acfe_update_function',
|
77 |
-
'key' => 'acfe_update_function',
|
78 |
-
'prefix' => '',
|
79 |
-
'_name' => '',
|
80 |
-
'_prepare' => '',
|
81 |
-
'type' => 'select',
|
82 |
-
'choices' => $choices,
|
83 |
-
'instructions' => false,
|
84 |
-
'required' => false,
|
85 |
-
'wrapper' => array(
|
86 |
-
'width' => '',
|
87 |
-
'class' => '',
|
88 |
-
'id' => '',
|
89 |
-
),
|
90 |
-
),
|
91 |
-
)
|
92 |
-
), false);
|
93 |
-
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Process Setting
|
98 |
-
*/
|
99 |
-
add_filter('acf/update_value', 'acfe_update_value', 99, 3);
|
100 |
-
function acfe_update_value($value, $post_id, $field){
|
101 |
-
|
102 |
-
if(!isset($field['acfe_update']) || empty($field['acfe_update']))
|
103 |
-
return $value;
|
104 |
-
|
105 |
-
$exclude = apply_filters('acfe/update/exclude/', false, $field);
|
106 |
-
if($exclude)
|
107 |
-
return $value;
|
108 |
-
|
109 |
-
foreach($field['acfe_update'] as $vkey => $function){
|
110 |
-
|
111 |
-
// Fix possible ACF Clone Index
|
112 |
-
if($vkey
|
113 |
-
continue;
|
114 |
-
|
115 |
-
// Check filters
|
116 |
-
$filters = array(
|
117 |
-
'acfe/update/function/' . $function['acfe_update_function'] . '/key=' . $field['key'],
|
118 |
-
'acfe/update/function/' . $function['acfe_update_function'] . '/name=' . $field['name'],
|
119 |
-
'acfe/update/function/' . $function['acfe_update_function'] . '/type=' . $field['type'],
|
120 |
-
'acfe/update/function/' . $function['acfe_update_function'],
|
121 |
-
);
|
122 |
-
|
123 |
-
$filter_call = false;
|
124 |
-
foreach($filters as $filter){
|
125 |
-
if(has_filter($filter))
|
126 |
-
$filter_call = $filter;
|
127 |
-
}
|
128 |
-
|
129 |
-
if(!$filter_call && !is_callable($function['acfe_update_function']))
|
130 |
-
continue;
|
131 |
-
|
132 |
-
// Apply Filter
|
133 |
-
if($filter_call)
|
134 |
-
$value = apply_filters($filter_call, $value, $post_id, $field);
|
135 |
-
|
136 |
-
// [or] Call Function
|
137 |
-
else
|
138 |
-
$value = call_user_func($function['acfe_update_function'], $value);
|
139 |
-
|
140 |
-
}
|
141 |
-
|
142 |
-
return $value;
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* Process Setting: Variations
|
147 |
-
*/
|
148 |
-
if(function_exists('acf_add_filter_variations'))
|
149 |
-
acf_add_filter_variations('acfe/update/exclude', array('type', 'name', 'key'), 1);
|
150 |
-
|
151 |
-
/**
|
152 |
-
* Setting: ACF Clone Index fix for flexible duplicate
|
153 |
-
*/
|
154 |
-
add_filter('acf/update_field', 'acfe_update_value_clone_index');
|
155 |
-
function acfe_update_value_clone_index($field){
|
156 |
-
|
157 |
-
if(isset($field['acfe_update']['acfcloneindex']))
|
158 |
-
$field['acfe_update'] = false;
|
159 |
-
|
160 |
-
return $field;
|
161 |
-
|
162 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Setting: Native functions
|
8 |
+
*/
|
9 |
+
add_filter('acfe/update/functions', 'acfe_update_functions', 0);
|
10 |
+
function acfe_update_functions($choices){
|
11 |
+
|
12 |
+
return array(
|
13 |
+
'Sanitize' => array(
|
14 |
+
'sanitize_email' => 'Sanitize email (sanitize_email)',
|
15 |
+
'sanitize_file_name' => 'Sanitize file name (sanitize_file_name)',
|
16 |
+
'sanitize_html_class' => 'Sanitize html class (sanitize_html_class)',
|
17 |
+
'sanitize_key' => 'Sanitize key (sanitize_key)',
|
18 |
+
'sanitize_meta' => 'Sanitize meta (sanitize_meta)',
|
19 |
+
'sanitize_mime_type' => 'Sanitize mime type (sanitize_mime_type)',
|
20 |
+
'sanitize_option' => 'Sanitize option (sanitize_option)',
|
21 |
+
'sanitize_text_field' => 'Sanitize text field (sanitize_text_field)',
|
22 |
+
'sanitize_title' => 'Sanitize title (sanitize_title)',
|
23 |
+
'sanitize_user' => 'Sanitize user (sanitize_user)',
|
24 |
+
),
|
25 |
+
);
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Exclude layout advanced fields
|
31 |
+
*/
|
32 |
+
add_filter('acfe/update/exclude', 'acfe_update_exclude', 0, 2);
|
33 |
+
function acfe_update_exclude($exclude, $type){
|
34 |
+
|
35 |
+
$excludes = array('message', 'accordion', 'tab', 'group', 'repeater', 'flexible_content', 'clone', 'acfe_dynamic_message');
|
36 |
+
if(in_array($type, $excludes))
|
37 |
+
$exclude = true;
|
38 |
+
|
39 |
+
return $exclude;
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
foreach(acf_get_field_types_info() as $field){
|
44 |
+
|
45 |
+
$type = $field['name'];
|
46 |
+
|
47 |
+
$exclude = apply_filters('acfe/update/exclude', false, $type);
|
48 |
+
if($exclude)
|
49 |
+
continue;
|
50 |
+
|
51 |
+
add_action('acf/render_field_settings/type=' . $type, 'acfe_update_settings', 991);
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Add Setting
|
57 |
+
*/
|
58 |
+
function acfe_update_settings($field){
|
59 |
+
|
60 |
+
$choices = apply_filters('acfe/update/functions', array(), $field);
|
61 |
+
if(empty($choices))
|
62 |
+
return;
|
63 |
+
|
64 |
+
// Settings
|
65 |
+
acf_render_field_setting($field, array(
|
66 |
+
'label' => __('Filters'),
|
67 |
+
'name' => 'acfe_update',
|
68 |
+
'key' => 'acfe_update',
|
69 |
+
'instructions' => __('Filter value right before saving'),
|
70 |
+
'type' => 'repeater',
|
71 |
+
'button_label' => __('Add filter'),
|
72 |
+
'required' => false,
|
73 |
+
'sub_fields' => array(
|
74 |
+
array(
|
75 |
+
'label' => 'Function',
|
76 |
+
'name' => 'acfe_update_function',
|
77 |
+
'key' => 'acfe_update_function',
|
78 |
+
'prefix' => '',
|
79 |
+
'_name' => '',
|
80 |
+
'_prepare' => '',
|
81 |
+
'type' => 'select',
|
82 |
+
'choices' => $choices,
|
83 |
+
'instructions' => false,
|
84 |
+
'required' => false,
|
85 |
+
'wrapper' => array(
|
86 |
+
'width' => '',
|
87 |
+
'class' => '',
|
88 |
+
'id' => '',
|
89 |
+
),
|
90 |
+
),
|
91 |
+
)
|
92 |
+
), false);
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Process Setting
|
98 |
+
*/
|
99 |
+
add_filter('acf/update_value', 'acfe_update_value', 99, 3);
|
100 |
+
function acfe_update_value($value, $post_id, $field){
|
101 |
+
|
102 |
+
if(!isset($field['acfe_update']) || empty($field['acfe_update']))
|
103 |
+
return $value;
|
104 |
+
|
105 |
+
$exclude = apply_filters('acfe/update/exclude/', false, $field);
|
106 |
+
if($exclude)
|
107 |
+
return $value;
|
108 |
+
|
109 |
+
foreach($field['acfe_update'] as $vkey => $function){
|
110 |
+
|
111 |
+
// Fix possible ACF Clone Index
|
112 |
+
if($vkey === 'acfcloneindex')
|
113 |
+
continue;
|
114 |
+
|
115 |
+
// Check filters
|
116 |
+
$filters = array(
|
117 |
+
'acfe/update/function/' . $function['acfe_update_function'] . '/key=' . $field['key'],
|
118 |
+
'acfe/update/function/' . $function['acfe_update_function'] . '/name=' . $field['name'],
|
119 |
+
'acfe/update/function/' . $function['acfe_update_function'] . '/type=' . $field['type'],
|
120 |
+
'acfe/update/function/' . $function['acfe_update_function'],
|
121 |
+
);
|
122 |
+
|
123 |
+
$filter_call = false;
|
124 |
+
foreach($filters as $filter){
|
125 |
+
if(has_filter($filter))
|
126 |
+
$filter_call = $filter;
|
127 |
+
}
|
128 |
+
|
129 |
+
if(!$filter_call && !is_callable($function['acfe_update_function']))
|
130 |
+
continue;
|
131 |
+
|
132 |
+
// Apply Filter
|
133 |
+
if($filter_call)
|
134 |
+
$value = apply_filters($filter_call, $value, $post_id, $field);
|
135 |
+
|
136 |
+
// [or] Call Function
|
137 |
+
else
|
138 |
+
$value = call_user_func($function['acfe_update_function'], $value);
|
139 |
+
|
140 |
+
}
|
141 |
+
|
142 |
+
return $value;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Process Setting: Variations
|
147 |
+
*/
|
148 |
+
if(function_exists('acf_add_filter_variations'))
|
149 |
+
acf_add_filter_variations('acfe/update/exclude', array('type', 'name', 'key'), 1);
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Setting: ACF Clone Index fix for flexible duplicate
|
153 |
+
*/
|
154 |
+
add_filter('acf/update_field', 'acfe_update_value_clone_index');
|
155 |
+
function acfe_update_value_clone_index($field){
|
156 |
+
|
157 |
+
if(isset($field['acfe_update']['acfcloneindex']))
|
158 |
+
$field['acfe_update'] = false;
|
159 |
+
|
160 |
+
return $field;
|
161 |
+
|
162 |
}
|
includes/fields-settings/validation.php
CHANGED
@@ -1,330 +1,330 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Setting: ACFE addon functions
|
8 |
-
*/
|
9 |
-
add_filter('acfe/validate/function/acfe_get_user_by_id', 'acfe_get_user_by_id', 10, 3);
|
10 |
-
function acfe_get_user_by_id($result, $value, $field){
|
11 |
-
return get_user_by('id', $value);
|
12 |
-
}
|
13 |
-
|
14 |
-
add_filter('acfe/validate/function/acfe_get_user_by_slug', 'acfe_get_user_by_slug', 10, 3);
|
15 |
-
function acfe_get_user_by_slug($result, $value, $field){
|
16 |
-
return get_user_by('slug', $value);
|
17 |
-
}
|
18 |
-
|
19 |
-
add_filter('acfe/validate/function/acfe_get_user_by_email', 'acfe_get_user_by_email', 10, 3);
|
20 |
-
function acfe_get_user_by_email($result, $value, $field){
|
21 |
-
return get_user_by('email', $value);
|
22 |
-
}
|
23 |
-
|
24 |
-
add_filter('acfe/validate/function/acfe_get_user_by_login', 'acfe_get_user_by_login', 10, 3);
|
25 |
-
function acfe_get_user_by_login($result, $value, $field){
|
26 |
-
return get_user_by('login', $value);
|
27 |
-
}
|
28 |
-
|
29 |
-
add_filter('acfe/validate/function/acfe_value', 'acfe_value', 10, 3);
|
30 |
-
function acfe_value($result, $value, $field){
|
31 |
-
return $value;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Setting: Native functions
|
36 |
-
*/
|
37 |
-
add_filter('acfe/validate/functions', 'acfe_validate_functions', 0);
|
38 |
-
function acfe_validate_functions($choices){
|
39 |
-
|
40 |
-
return array(
|
41 |
-
'Global' => array(
|
42 |
-
'acfe_value' => 'Value (acfe_value)',
|
43 |
-
),
|
44 |
-
|
45 |
-
'Exists' => array(
|
46 |
-
'email_exists' => 'Email exists (email_exists)',
|
47 |
-
'post_type_exists' => 'Post type exists (post_type_exists)',
|
48 |
-
'taxonomy_exists' => 'Taxonomy exists (taxonomy_exists)',
|
49 |
-
'term_exists' => 'Term exists (term_exists)',
|
50 |
-
'username_exists' => 'Username exists (username_exists)',
|
51 |
-
),
|
52 |
-
|
53 |
-
'Is' => array(
|
54 |
-
'is_email' => 'Is email (is_email)',
|
55 |
-
),
|
56 |
-
|
57 |
-
'Sanitize' => array(
|
58 |
-
'sanitize_email' => 'Sanitize email (sanitize_email)',
|
59 |
-
'sanitize_file_name' => 'Sanitize file name (sanitize_file_name)',
|
60 |
-
'sanitize_html_class' => 'Sanitize html class (sanitize_html_class)',
|
61 |
-
'sanitize_key' => 'Sanitize key (sanitize_key)',
|
62 |
-
'sanitize_meta' => 'Sanitize meta (sanitize_meta)',
|
63 |
-
'sanitize_mime_type' => 'Sanitize mime type (sanitize_mime_type)',
|
64 |
-
'sanitize_option' => 'Sanitize option (sanitize_option)',
|
65 |
-
'sanitize_text_field' => 'Sanitize text field (sanitize_text_field)',
|
66 |
-
'sanitize_title' => 'Sanitize title (sanitize_title)',
|
67 |
-
'sanitize_user' => 'Sanitize user (sanitize_user)',
|
68 |
-
),
|
69 |
-
|
70 |
-
'User' => array(
|
71 |
-
'acfe_get_user_by_id' => 'Get user by id (acfe_get_user_by_id)',
|
72 |
-
'acfe_get_user_by_slug' => 'Get user by slug (acfe_get_user_by_slug)',
|
73 |
-
'acfe_get_user_by_email' => 'Get user by email (acfe_get_user_by_email)',
|
74 |
-
'acfe_get_user_by_login' => 'Get user by login (acfe_get_user_by_login)',
|
75 |
-
'is_user_logged_in' => 'Is user logged in (is_user_logged_in)',
|
76 |
-
)
|
77 |
-
);
|
78 |
-
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Exclude layout advanced fields
|
83 |
-
*/
|
84 |
-
add_filter('acfe/validate/exclude', 'acfe_validate_exclude', 0, 2);
|
85 |
-
function acfe_validate_exclude($exclude, $type){
|
86 |
-
|
87 |
-
$excludes = array('message', 'accordion', 'tab', 'group', 'repeater', 'flexible_content', 'clone', 'acfe_dynamic_message');
|
88 |
-
if(in_array($type, $excludes))
|
89 |
-
$exclude = true;
|
90 |
-
|
91 |
-
return $exclude;
|
92 |
-
|
93 |
-
}
|
94 |
-
|
95 |
-
foreach(acf_get_field_types_info() as $field){
|
96 |
-
|
97 |
-
$type = $field['name'];
|
98 |
-
|
99 |
-
$exclude = apply_filters('acfe/validate/exclude', false, $type);
|
100 |
-
if($exclude)
|
101 |
-
continue;
|
102 |
-
|
103 |
-
add_action('acf/render_field_settings/type=' . $type, 'acfe_validation_settings', 990);
|
104 |
-
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Add Setting
|
109 |
-
*/
|
110 |
-
function acfe_validation_settings($field){
|
111 |
-
|
112 |
-
$exclude = apply_filters('acfe/validate/exclude', false, $field);
|
113 |
-
if($exclude)
|
114 |
-
return;
|
115 |
-
|
116 |
-
$choices = apply_filters('acfe/validate/functions', array(), $field);
|
117 |
-
if(empty($choices))
|
118 |
-
return;
|
119 |
-
|
120 |
-
// Settings
|
121 |
-
acf_render_field_setting($field, array(
|
122 |
-
'label' => __('Validation'),
|
123 |
-
'name' => 'acfe_validate',
|
124 |
-
'key' => 'acfe_validate',
|
125 |
-
'instructions' => __('Validate value against rules'),
|
126 |
-
'type' => 'repeater',
|
127 |
-
'button_label' => __('Add rule'),
|
128 |
-
'required' => false,
|
129 |
-
'layout' => 'row',
|
130 |
-
'sub_fields' => array(
|
131 |
-
array(
|
132 |
-
'label' => __('Rules'),
|
133 |
-
'name' => 'acfe_validate_rules_and',
|
134 |
-
'key' => 'acfe_validate_rules_and',
|
135 |
-
'instructions' => '',
|
136 |
-
'type' => 'repeater',
|
137 |
-
'button_label' => __('+ AND'),
|
138 |
-
'required' => false,
|
139 |
-
'layout' => 'table',
|
140 |
-
'sub_fields' => array(
|
141 |
-
array(
|
142 |
-
'label' => 'Function',
|
143 |
-
'name' => 'acfe_validate_function',
|
144 |
-
'key' => 'acfe_validate_function',
|
145 |
-
'prefix' => '',
|
146 |
-
'_name' => '',
|
147 |
-
'_prepare' => '',
|
148 |
-
'type' => 'select',
|
149 |
-
'choices' => $choices,
|
150 |
-
'instructions' => false,
|
151 |
-
'required' => false,
|
152 |
-
'wrapper' => array(
|
153 |
-
'width' => '',
|
154 |
-
'class' => '',
|
155 |
-
'id' => '',
|
156 |
-
),
|
157 |
-
),
|
158 |
-
array(
|
159 |
-
'label' => 'Operator',
|
160 |
-
'name' => 'acfe_validate_operator',
|
161 |
-
'key' => 'acfe_validate_operator',
|
162 |
-
'prefix' => '',
|
163 |
-
'_name' => '',
|
164 |
-
'_prepare' => '',
|
165 |
-
'type' => 'select',
|
166 |
-
'choices' => array(
|
167 |
-
'==' => 'Equal',
|
168 |
-
'!=' => 'Not equal',
|
169 |
-
),
|
170 |
-
'instructions' => false,
|
171 |
-
'required' => false,
|
172 |
-
'wrapper' => array(
|
173 |
-
'width' => '',
|
174 |
-
'class' => '',
|
175 |
-
'id' => '',
|
176 |
-
),
|
177 |
-
),
|
178 |
-
array(
|
179 |
-
'label' => 'Match',
|
180 |
-
'name' => 'acfe_validate_match',
|
181 |
-
'key' => 'acfe_validate_match',
|
182 |
-
'prefix' => '',
|
183 |
-
'_name' => '',
|
184 |
-
'_prepare' => '',
|
185 |
-
'type' => 'select',
|
186 |
-
'choices' => array(
|
187 |
-
'true' => 'True',
|
188 |
-
'false' => 'False',
|
189 |
-
'empty' => 'Empty',
|
190 |
-
),
|
191 |
-
'instructions' => false,
|
192 |
-
'required' => false,
|
193 |
-
'wrapper' => array(
|
194 |
-
'width' => '',
|
195 |
-
'class' => '',
|
196 |
-
'id' => '',
|
197 |
-
),
|
198 |
-
),
|
199 |
-
)
|
200 |
-
),
|
201 |
-
array(
|
202 |
-
'label' => 'Error',
|
203 |
-
'name' => 'acfe_validate_error',
|
204 |
-
'key' => 'acfe_validate_error',
|
205 |
-
'prefix' => '',
|
206 |
-
'_name' => '',
|
207 |
-
'_prepare' => '',
|
208 |
-
'type' => 'text',
|
209 |
-
'instructions' => false,
|
210 |
-
'required' => false,
|
211 |
-
'wrapper' => array(
|
212 |
-
'width' => '',
|
213 |
-
'class' => '',
|
214 |
-
'id' => '',
|
215 |
-
),
|
216 |
-
),
|
217 |
-
)
|
218 |
-
), false);
|
219 |
-
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Process Setting
|
224 |
-
*/
|
225 |
-
add_filter('acf/validate_value', 'acfe_validate_value', 99, 4);
|
226 |
-
function acfe_validate_value($valid, $value, $field, $input){
|
227 |
-
|
228 |
-
if(!$valid)
|
229 |
-
return $valid;
|
230 |
-
|
231 |
-
if(!isset($field['acfe_validate']) || empty($field['acfe_validate']))
|
232 |
-
return $valid;
|
233 |
-
|
234 |
-
$exclude = apply_filters('acfe/validate/exclude', false, $field);
|
235 |
-
if($exclude)
|
236 |
-
return $valid;
|
237 |
-
|
238 |
-
foreach($field['acfe_validate'] as $orkey => $rules){
|
239 |
-
|
240 |
-
// Fix possible ACF Clone Index
|
241 |
-
if($orkey
|
242 |
-
continue;
|
243 |
-
|
244 |
-
$acfe_validate_rules_and = isset($rules['acfe_validate_rules_and']) && !empty($rules['acfe_validate_rules_and']);
|
245 |
-
if(!$acfe_validate_rules_and)
|
246 |
-
continue;
|
247 |
-
|
248 |
-
$rule_match = true;
|
249 |
-
|
250 |
-
foreach($rules['acfe_validate_rules_and'] as $andkey => $function){
|
251 |
-
|
252 |
-
if(!$rule_match)
|
253 |
-
break;
|
254 |
-
|
255 |
-
$rule_match = false;
|
256 |
-
|
257 |
-
// Check filters
|
258 |
-
$filters = array(
|
259 |
-
'acfe/validate/function/' . $function['acfe_validate_function'] . '/key=' . $field['key'],
|
260 |
-
'acfe/validate/function/' . $function['acfe_validate_function'] . '/name=' . $field['name'],
|
261 |
-
'acfe/validate/function/' . $function['acfe_validate_function'] . '/type=' . $field['type'],
|
262 |
-
'acfe/validate/function/' . $function['acfe_validate_function'],
|
263 |
-
);
|
264 |
-
|
265 |
-
$filter_call = false;
|
266 |
-
foreach($filters as $filter){
|
267 |
-
if(has_filter($filter))
|
268 |
-
$filter_call = $filter;
|
269 |
-
}
|
270 |
-
|
271 |
-
if(!$filter_call && !is_callable($function['acfe_validate_function']))
|
272 |
-
continue;
|
273 |
-
|
274 |
-
// Apply Filter
|
275 |
-
if($filter_call)
|
276 |
-
$result = apply_filters($filter_call, false, $value, $field);
|
277 |
-
|
278 |
-
// [or] Call Function
|
279 |
-
else
|
280 |
-
$result = call_user_func($function['acfe_validate_function'], $value);
|
281 |
-
|
282 |
-
// Vars
|
283 |
-
$operator = $function['acfe_validate_operator'];
|
284 |
-
$match = $function['acfe_validate_match'];
|
285 |
-
|
286 |
-
// Equal
|
287 |
-
if($operator
|
288 |
-
$rule_match = true;
|
289 |
-
}
|
290 |
-
|
291 |
-
// Not Equal
|
292 |
-
elseif($operator
|
293 |
-
$rule_match = true;
|
294 |
-
}
|
295 |
-
|
296 |
-
}
|
297 |
-
|
298 |
-
// Error
|
299 |
-
$error = $rules['acfe_validate_error'];
|
300 |
-
|
301 |
-
if($rule_match && !empty($error))
|
302 |
-
$valid = $error;
|
303 |
-
|
304 |
-
if(!$valid || is_string($valid))
|
305 |
-
break;
|
306 |
-
|
307 |
-
}
|
308 |
-
|
309 |
-
return $valid;
|
310 |
-
|
311 |
-
}
|
312 |
-
|
313 |
-
/**
|
314 |
-
* Process Setting: Variations
|
315 |
-
*/
|
316 |
-
if(function_exists('acf_add_filter_variations'))
|
317 |
-
acf_add_filter_variations('acfe/validate/exclude', array('type', 'name', 'key'), 1);
|
318 |
-
|
319 |
-
/**
|
320 |
-
* Setting: ACF Clone Index fix for flexible duplicate
|
321 |
-
*/
|
322 |
-
add_filter('acf/update_field', 'acfe_validate_value_clone_index');
|
323 |
-
function acfe_validate_value_clone_index($field){
|
324 |
-
|
325 |
-
if(isset($field['acfe_validate']['acfcloneindex']))
|
326 |
-
$field['acfe_validate'] = false;
|
327 |
-
|
328 |
-
return $field;
|
329 |
-
|
330 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Setting: ACFE addon functions
|
8 |
+
*/
|
9 |
+
add_filter('acfe/validate/function/acfe_get_user_by_id', 'acfe_get_user_by_id', 10, 3);
|
10 |
+
function acfe_get_user_by_id($result, $value, $field){
|
11 |
+
return get_user_by('id', $value);
|
12 |
+
}
|
13 |
+
|
14 |
+
add_filter('acfe/validate/function/acfe_get_user_by_slug', 'acfe_get_user_by_slug', 10, 3);
|
15 |
+
function acfe_get_user_by_slug($result, $value, $field){
|
16 |
+
return get_user_by('slug', $value);
|
17 |
+
}
|
18 |
+
|
19 |
+
add_filter('acfe/validate/function/acfe_get_user_by_email', 'acfe_get_user_by_email', 10, 3);
|
20 |
+
function acfe_get_user_by_email($result, $value, $field){
|
21 |
+
return get_user_by('email', $value);
|
22 |
+
}
|
23 |
+
|
24 |
+
add_filter('acfe/validate/function/acfe_get_user_by_login', 'acfe_get_user_by_login', 10, 3);
|
25 |
+
function acfe_get_user_by_login($result, $value, $field){
|
26 |
+
return get_user_by('login', $value);
|
27 |
+
}
|
28 |
+
|
29 |
+
add_filter('acfe/validate/function/acfe_value', 'acfe_value', 10, 3);
|
30 |
+
function acfe_value($result, $value, $field){
|
31 |
+
return $value;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Setting: Native functions
|
36 |
+
*/
|
37 |
+
add_filter('acfe/validate/functions', 'acfe_validate_functions', 0);
|
38 |
+
function acfe_validate_functions($choices){
|
39 |
+
|
40 |
+
return array(
|
41 |
+
'Global' => array(
|
42 |
+
'acfe_value' => 'Value (acfe_value)',
|
43 |
+
),
|
44 |
+
|
45 |
+
'Exists' => array(
|
46 |
+
'email_exists' => 'Email exists (email_exists)',
|
47 |
+
'post_type_exists' => 'Post type exists (post_type_exists)',
|
48 |
+
'taxonomy_exists' => 'Taxonomy exists (taxonomy_exists)',
|
49 |
+
'term_exists' => 'Term exists (term_exists)',
|
50 |
+
'username_exists' => 'Username exists (username_exists)',
|
51 |
+
),
|
52 |
+
|
53 |
+
'Is' => array(
|
54 |
+
'is_email' => 'Is email (is_email)',
|
55 |
+
),
|
56 |
+
|
57 |
+
'Sanitize' => array(
|
58 |
+
'sanitize_email' => 'Sanitize email (sanitize_email)',
|
59 |
+
'sanitize_file_name' => 'Sanitize file name (sanitize_file_name)',
|
60 |
+
'sanitize_html_class' => 'Sanitize html class (sanitize_html_class)',
|
61 |
+
'sanitize_key' => 'Sanitize key (sanitize_key)',
|
62 |
+
'sanitize_meta' => 'Sanitize meta (sanitize_meta)',
|
63 |
+
'sanitize_mime_type' => 'Sanitize mime type (sanitize_mime_type)',
|
64 |
+
'sanitize_option' => 'Sanitize option (sanitize_option)',
|
65 |
+
'sanitize_text_field' => 'Sanitize text field (sanitize_text_field)',
|
66 |
+
'sanitize_title' => 'Sanitize title (sanitize_title)',
|
67 |
+
'sanitize_user' => 'Sanitize user (sanitize_user)',
|
68 |
+
),
|
69 |
+
|
70 |
+
'User' => array(
|
71 |
+
'acfe_get_user_by_id' => 'Get user by id (acfe_get_user_by_id)',
|
72 |
+
'acfe_get_user_by_slug' => 'Get user by slug (acfe_get_user_by_slug)',
|
73 |
+
'acfe_get_user_by_email' => 'Get user by email (acfe_get_user_by_email)',
|
74 |
+
'acfe_get_user_by_login' => 'Get user by login (acfe_get_user_by_login)',
|
75 |
+
'is_user_logged_in' => 'Is user logged in (is_user_logged_in)',
|
76 |
+
)
|
77 |
+
);
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Exclude layout advanced fields
|
83 |
+
*/
|
84 |
+
add_filter('acfe/validate/exclude', 'acfe_validate_exclude', 0, 2);
|
85 |
+
function acfe_validate_exclude($exclude, $type){
|
86 |
+
|
87 |
+
$excludes = array('message', 'accordion', 'tab', 'group', 'repeater', 'flexible_content', 'clone', 'acfe_dynamic_message');
|
88 |
+
if(in_array($type, $excludes))
|
89 |
+
$exclude = true;
|
90 |
+
|
91 |
+
return $exclude;
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
foreach(acf_get_field_types_info() as $field){
|
96 |
+
|
97 |
+
$type = $field['name'];
|
98 |
+
|
99 |
+
$exclude = apply_filters('acfe/validate/exclude', false, $type);
|
100 |
+
if($exclude)
|
101 |
+
continue;
|
102 |
+
|
103 |
+
add_action('acf/render_field_settings/type=' . $type, 'acfe_validation_settings', 990);
|
104 |
+
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Add Setting
|
109 |
+
*/
|
110 |
+
function acfe_validation_settings($field){
|
111 |
+
|
112 |
+
$exclude = apply_filters('acfe/validate/exclude', false, $field);
|
113 |
+
if($exclude)
|
114 |
+
return;
|
115 |
+
|
116 |
+
$choices = apply_filters('acfe/validate/functions', array(), $field);
|
117 |
+
if(empty($choices))
|
118 |
+
return;
|
119 |
+
|
120 |
+
// Settings
|
121 |
+
acf_render_field_setting($field, array(
|
122 |
+
'label' => __('Validation'),
|
123 |
+
'name' => 'acfe_validate',
|
124 |
+
'key' => 'acfe_validate',
|
125 |
+
'instructions' => __('Validate value against rules'),
|
126 |
+
'type' => 'repeater',
|
127 |
+
'button_label' => __('Add rule'),
|
128 |
+
'required' => false,
|
129 |
+
'layout' => 'row',
|
130 |
+
'sub_fields' => array(
|
131 |
+
array(
|
132 |
+
'label' => __('Rules'),
|
133 |
+
'name' => 'acfe_validate_rules_and',
|
134 |
+
'key' => 'acfe_validate_rules_and',
|
135 |
+
'instructions' => '',
|
136 |
+
'type' => 'repeater',
|
137 |
+
'button_label' => __('+ AND'),
|
138 |
+
'required' => false,
|
139 |
+
'layout' => 'table',
|
140 |
+
'sub_fields' => array(
|
141 |
+
array(
|
142 |
+
'label' => 'Function',
|
143 |
+
'name' => 'acfe_validate_function',
|
144 |
+
'key' => 'acfe_validate_function',
|
145 |
+
'prefix' => '',
|
146 |
+
'_name' => '',
|
147 |
+
'_prepare' => '',
|
148 |
+
'type' => 'select',
|
149 |
+
'choices' => $choices,
|
150 |
+
'instructions' => false,
|
151 |
+
'required' => false,
|
152 |
+
'wrapper' => array(
|
153 |
+
'width' => '',
|
154 |
+
'class' => '',
|
155 |
+
'id' => '',
|
156 |
+
),
|
157 |
+
),
|
158 |
+
array(
|
159 |
+
'label' => 'Operator',
|
160 |
+
'name' => 'acfe_validate_operator',
|
161 |
+
'key' => 'acfe_validate_operator',
|
162 |
+
'prefix' => '',
|
163 |
+
'_name' => '',
|
164 |
+
'_prepare' => '',
|
165 |
+
'type' => 'select',
|
166 |
+
'choices' => array(
|
167 |
+
'==' => 'Equal',
|
168 |
+
'!=' => 'Not equal',
|
169 |
+
),
|
170 |
+
'instructions' => false,
|
171 |
+
'required' => false,
|
172 |
+
'wrapper' => array(
|
173 |
+
'width' => '',
|
174 |
+
'class' => '',
|
175 |
+
'id' => '',
|
176 |
+
),
|
177 |
+
),
|
178 |
+
array(
|
179 |
+
'label' => 'Match',
|
180 |
+
'name' => 'acfe_validate_match',
|
181 |
+
'key' => 'acfe_validate_match',
|
182 |
+
'prefix' => '',
|
183 |
+
'_name' => '',
|
184 |
+
'_prepare' => '',
|
185 |
+
'type' => 'select',
|
186 |
+
'choices' => array(
|
187 |
+
'true' => 'True',
|
188 |
+
'false' => 'False',
|
189 |
+
'empty' => 'Empty',
|
190 |
+
),
|
191 |
+
'instructions' => false,
|
192 |
+
'required' => false,
|
193 |
+
'wrapper' => array(
|
194 |
+
'width' => '',
|
195 |
+
'class' => '',
|
196 |
+
'id' => '',
|
197 |
+
),
|
198 |
+
),
|
199 |
+
)
|
200 |
+
),
|
201 |
+
array(
|
202 |
+
'label' => 'Error',
|
203 |
+
'name' => 'acfe_validate_error',
|
204 |
+
'key' => 'acfe_validate_error',
|
205 |
+
'prefix' => '',
|
206 |
+
'_name' => '',
|
207 |
+
'_prepare' => '',
|
208 |
+
'type' => 'text',
|
209 |
+
'instructions' => false,
|
210 |
+
'required' => false,
|
211 |
+
'wrapper' => array(
|
212 |
+
'width' => '',
|
213 |
+
'class' => '',
|
214 |
+
'id' => '',
|
215 |
+
),
|
216 |
+
),
|
217 |
+
)
|
218 |
+
), false);
|
219 |
+
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Process Setting
|
224 |
+
*/
|
225 |
+
add_filter('acf/validate_value', 'acfe_validate_value', 99, 4);
|
226 |
+
function acfe_validate_value($valid, $value, $field, $input){
|
227 |
+
|
228 |
+
if(!$valid)
|
229 |
+
return $valid;
|
230 |
+
|
231 |
+
if(!isset($field['acfe_validate']) || empty($field['acfe_validate']))
|
232 |
+
return $valid;
|
233 |
+
|
234 |
+
$exclude = apply_filters('acfe/validate/exclude', false, $field);
|
235 |
+
if($exclude)
|
236 |
+
return $valid;
|
237 |
+
|
238 |
+
foreach($field['acfe_validate'] as $orkey => $rules){
|
239 |
+
|
240 |
+
// Fix possible ACF Clone Index
|
241 |
+
if($orkey === 'acfcloneindex')
|
242 |
+
continue;
|
243 |
+
|
244 |
+
$acfe_validate_rules_and = isset($rules['acfe_validate_rules_and']) && !empty($rules['acfe_validate_rules_and']);
|
245 |
+
if(!$acfe_validate_rules_and)
|
246 |
+
continue;
|
247 |
+
|
248 |
+
$rule_match = true;
|
249 |
+
|
250 |
+
foreach($rules['acfe_validate_rules_and'] as $andkey => $function){
|
251 |
+
|
252 |
+
if(!$rule_match)
|
253 |
+
break;
|
254 |
+
|
255 |
+
$rule_match = false;
|
256 |
+
|
257 |
+
// Check filters
|
258 |
+
$filters = array(
|
259 |
+
'acfe/validate/function/' . $function['acfe_validate_function'] . '/key=' . $field['key'],
|
260 |
+
'acfe/validate/function/' . $function['acfe_validate_function'] . '/name=' . $field['name'],
|
261 |
+
'acfe/validate/function/' . $function['acfe_validate_function'] . '/type=' . $field['type'],
|
262 |
+
'acfe/validate/function/' . $function['acfe_validate_function'],
|
263 |
+
);
|
264 |
+
|
265 |
+
$filter_call = false;
|
266 |
+
foreach($filters as $filter){
|
267 |
+
if(has_filter($filter))
|
268 |
+
$filter_call = $filter;
|
269 |
+
}
|
270 |
+
|
271 |
+
if(!$filter_call && !is_callable($function['acfe_validate_function']))
|
272 |
+
continue;
|
273 |
+
|
274 |
+
// Apply Filter
|
275 |
+
if($filter_call)
|
276 |
+
$result = apply_filters($filter_call, false, $value, $field);
|
277 |
+
|
278 |
+
// [or] Call Function
|
279 |
+
else
|
280 |
+
$result = call_user_func($function['acfe_validate_function'], $value);
|
281 |
+
|
282 |
+
// Vars
|
283 |
+
$operator = $function['acfe_validate_operator'];
|
284 |
+
$match = $function['acfe_validate_match'];
|
285 |
+
|
286 |
+
// Equal
|
287 |
+
if($operator === '==' && (($match === 'true' && $result) || ($match === 'false' && !$result) || ($match === 'empty' && empty($result)))){
|
288 |
+
$rule_match = true;
|
289 |
+
}
|
290 |
+
|
291 |
+
// Not Equal
|
292 |
+
elseif($operator === '!=' && (($match === 'true' && !$result) || ($match === 'false' && $result) || ($match === 'empty' && !empty($result)))){
|
293 |
+
$rule_match = true;
|
294 |
+
}
|
295 |
+
|
296 |
+
}
|
297 |
+
|
298 |
+
// Error
|
299 |
+
$error = $rules['acfe_validate_error'];
|
300 |
+
|
301 |
+
if($rule_match && !empty($error))
|
302 |
+
$valid = $error;
|
303 |
+
|
304 |
+
if(!$valid || is_string($valid))
|
305 |
+
break;
|
306 |
+
|
307 |
+
}
|
308 |
+
|
309 |
+
return $valid;
|
310 |
+
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Process Setting: Variations
|
315 |
+
*/
|
316 |
+
if(function_exists('acf_add_filter_variations'))
|
317 |
+
acf_add_filter_variations('acfe/validate/exclude', array('type', 'name', 'key'), 1);
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Setting: ACF Clone Index fix for flexible duplicate
|
321 |
+
*/
|
322 |
+
add_filter('acf/update_field', 'acfe_validate_value_clone_index');
|
323 |
+
function acfe_validate_value_clone_index($field){
|
324 |
+
|
325 |
+
if(isset($field['acfe_validate']['acfcloneindex']))
|
326 |
+
$field['acfe_validate'] = false;
|
327 |
+
|
328 |
+
return $field;
|
329 |
+
|
330 |
}
|
includes/fields/field-button.php
CHANGED
@@ -1,147 +1,147 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
class acfe_field_button extends acf_field{
|
7 |
-
|
8 |
-
function __construct(){
|
9 |
-
|
10 |
-
$this->name = 'button';
|
11 |
-
$this->label = __('Button', 'acfe');
|
12 |
-
$this->category = 'basic';
|
13 |
-
|
14 |
-
parent::__construct();
|
15 |
-
|
16 |
-
}
|
17 |
-
|
18 |
-
function render_field_settings($field){
|
19 |
-
|
20 |
-
acf_render_field_setting($field, array(
|
21 |
-
'label' => __('Button value', 'acfe'),
|
22 |
-
'instructions' => __('Set a default value for the field', 'acfe'),
|
23 |
-
'type' => 'text',
|
24 |
-
'name' => 'button_value',
|
25 |
-
'default_value' => __('Submit', 'acfe')
|
26 |
-
));
|
27 |
-
|
28 |
-
acf_render_field_setting($field, array(
|
29 |
-
'label' => __('Button attributes', 'acfe'),
|
30 |
-
'instructions' => __('Set button attributes', 'acfe'),
|
31 |
-
'type' => 'group',
|
32 |
-
'name' => 'button_attributes',
|
33 |
-
'sub_fields' => array(
|
34 |
-
array(
|
35 |
-
'label' => '',
|
36 |
-
'instructions' => '',
|
37 |
-
'type' => 'select',
|
38 |
-
'name' => 'button_type',
|
39 |
-
'_name' => 'button_type',
|
40 |
-
'key' => 'button_type',
|
41 |
-
'required' => false,
|
42 |
-
'default_value' => 'button',
|
43 |
-
'choices' => array(
|
44 |
-
'button' => __('Button', 'acfe'),
|
45 |
-
'submit' => __('Submit', 'acfe'),
|
46 |
-
),
|
47 |
-
'wrapper' => array(
|
48 |
-
'width' => 33
|
49 |
-
)
|
50 |
-
),
|
51 |
-
|
52 |
-
array(
|
53 |
-
'label' => '',
|
54 |
-
'instructions' => '',
|
55 |
-
'type' => 'text',
|
56 |
-
'name' => 'button_class',
|
57 |
-
'_name' => 'button_class',
|
58 |
-
'key' => 'button_class',
|
59 |
-
'required' => false,
|
60 |
-
'prepend' => 'class',
|
61 |
-
'wrapper' => array(
|
62 |
-
'width' => 33
|
63 |
-
)
|
64 |
-
),
|
65 |
-
|
66 |
-
array(
|
67 |
-
'label' => '',
|
68 |
-
'instructions' => '',
|
69 |
-
'type' => 'text',
|
70 |
-
'name' => 'button_id',
|
71 |
-
'_name' => 'button_id',
|
72 |
-
'key' => 'button_id',
|
73 |
-
'required' => false,
|
74 |
-
'prepend' => 'id',
|
75 |
-
'wrapper' => array(
|
76 |
-
'width' => 33
|
77 |
-
)
|
78 |
-
),
|
79 |
-
|
80 |
-
|
81 |
-
)
|
82 |
-
));
|
83 |
-
|
84 |
-
acf_render_field_setting($field, array(
|
85 |
-
'label' => __('Button wrapper', 'acfe'),
|
86 |
-
'instructions' => __('Set button wrapper', 'acfe'),
|
87 |
-
'type' => 'group',
|
88 |
-
'name' => 'button_wrapper',
|
89 |
-
'sub_fields' => array(
|
90 |
-
|
91 |
-
array(
|
92 |
-
'label' => '',
|
93 |
-
'instructions' => '',
|
94 |
-
'type' => 'text',
|
95 |
-
'name' => 'button_before',
|
96 |
-
'_name' => 'button_before',
|
97 |
-
'key' => 'button_before',
|
98 |
-
'required' => false,
|
99 |
-
'prepend' => __('Before'),
|
100 |
-
'wrapper' => array(
|
101 |
-
'width' => 50
|
102 |
-
)
|
103 |
-
),
|
104 |
-
|
105 |
-
array(
|
106 |
-
'label' => '',
|
107 |
-
'instructions' => '',
|
108 |
-
'type' => 'text',
|
109 |
-
'name' => 'button_after',
|
110 |
-
'_name' => 'button_after',
|
111 |
-
'key' => 'button_after',
|
112 |
-
'required' => false,
|
113 |
-
'prepend' => __('After'),
|
114 |
-
'wrapper' => array(
|
115 |
-
'width' => 50
|
116 |
-
)
|
117 |
-
),
|
118 |
-
|
119 |
-
|
120 |
-
)
|
121 |
-
));
|
122 |
-
|
123 |
-
}
|
124 |
-
|
125 |
-
function render_field($field){
|
126 |
-
|
127 |
-
if(!empty($field['button_wrapper']['button_before'])){
|
128 |
-
echo $field['button_wrapper']['button_before'];
|
129 |
-
}
|
130 |
-
|
131 |
-
echo '<input
|
132 |
-
type="' . esc_attr($field['button_attributes']['button_type']) . '"
|
133 |
-
name="' . esc_attr($field['name']) . '"
|
134 |
-
id="' . esc_attr($field['button_attributes']['button_id']) . '"
|
135 |
-
class="' . esc_attr($field['button_attributes']['button_class']) . '"
|
136 |
-
value="' . esc_attr($field['button_value']) . '"
|
137 |
-
/>';
|
138 |
-
|
139 |
-
if(!empty($field['button_wrapper']['button_after'])){
|
140 |
-
echo $field['button_wrapper']['button_after'];
|
141 |
-
}
|
142 |
-
|
143 |
-
}
|
144 |
-
|
145 |
-
}
|
146 |
-
|
147 |
new acfe_field_button();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
class acfe_field_button extends acf_field{
|
7 |
+
|
8 |
+
function __construct(){
|
9 |
+
|
10 |
+
$this->name = 'button';
|
11 |
+
$this->label = __('Button', 'acfe');
|
12 |
+
$this->category = 'basic';
|
13 |
+
|
14 |
+
parent::__construct();
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
+
function render_field_settings($field){
|
19 |
+
|
20 |
+
acf_render_field_setting($field, array(
|
21 |
+
'label' => __('Button value', 'acfe'),
|
22 |
+
'instructions' => __('Set a default value for the field', 'acfe'),
|
23 |
+
'type' => 'text',
|
24 |
+
'name' => 'button_value',
|
25 |
+
'default_value' => __('Submit', 'acfe')
|
26 |
+
));
|
27 |
+
|
28 |
+
acf_render_field_setting($field, array(
|
29 |
+
'label' => __('Button attributes', 'acfe'),
|
30 |
+
'instructions' => __('Set button attributes', 'acfe'),
|
31 |
+
'type' => 'group',
|
32 |
+
'name' => 'button_attributes',
|
33 |
+
'sub_fields' => array(
|
34 |
+
array(
|
35 |
+
'label' => '',
|
36 |
+
'instructions' => '',
|
37 |
+
'type' => 'select',
|
38 |
+
'name' => 'button_type',
|
39 |
+
'_name' => 'button_type',
|
40 |
+
'key' => 'button_type',
|
41 |
+
'required' => false,
|
42 |
+
'default_value' => 'button',
|
43 |
+
'choices' => array(
|
44 |
+
'button' => __('Button', 'acfe'),
|
45 |
+
'submit' => __('Submit', 'acfe'),
|
46 |
+
),
|
47 |
+
'wrapper' => array(
|
48 |
+
'width' => 33
|
49 |
+
)
|
50 |
+
),
|
51 |
+
|
52 |
+
array(
|
53 |
+
'label' => '',
|
54 |
+
'instructions' => '',
|
55 |
+
'type' => 'text',
|
56 |
+
'name' => 'button_class',
|
57 |
+
'_name' => 'button_class',
|
58 |
+
'key' => 'button_class',
|
59 |
+
'required' => false,
|
60 |
+
'prepend' => 'class',
|
61 |
+
'wrapper' => array(
|
62 |
+
'width' => 33
|
63 |
+
)
|
64 |
+
),
|
65 |
+
|
66 |
+
array(
|
67 |
+
'label' => '',
|
68 |
+
'instructions' => '',
|
69 |
+
'type' => 'text',
|
70 |
+
'name' => 'button_id',
|
71 |
+
'_name' => 'button_id',
|
72 |
+
'key' => 'button_id',
|
73 |
+
'required' => false,
|
74 |
+
'prepend' => 'id',
|
75 |
+
'wrapper' => array(
|
76 |
+
'width' => 33
|
77 |
+
)
|
78 |
+
),
|
79 |
+
|
80 |
+
|
81 |
+
)
|
82 |
+
));
|
83 |
+
|
84 |
+
acf_render_field_setting($field, array(
|
85 |
+
'label' => __('Button wrapper', 'acfe'),
|
86 |
+
'instructions' => __('Set button wrapper', 'acfe'),
|
87 |
+
'type' => 'group',
|
88 |
+
'name' => 'button_wrapper',
|
89 |
+
'sub_fields' => array(
|
90 |
+
|
91 |
+
array(
|
92 |
+
'label' => '',
|
93 |
+
'instructions' => '',
|
94 |
+
'type' => 'text',
|
95 |
+
'name' => 'button_before',
|
96 |
+
'_name' => 'button_before',
|
97 |
+
'key' => 'button_before',
|
98 |
+
'required' => false,
|
99 |
+
'prepend' => __('Before'),
|
100 |
+
'wrapper' => array(
|
101 |
+
'width' => 50
|
102 |
+
)
|
103 |
+
),
|
104 |
+
|
105 |
+
array(
|
106 |
+
'label' => '',
|
107 |
+
'instructions' => '',
|
108 |
+
'type' => 'text',
|
109 |
+
'name' => 'button_after',
|
110 |
+
'_name' => 'button_after',
|
111 |
+
'key' => 'button_after',
|
112 |
+
'required' => false,
|
113 |
+
'prepend' => __('After'),
|
114 |
+
'wrapper' => array(
|
115 |
+
'width' => 50
|
116 |
+
)
|
117 |
+
),
|
118 |
+
|
119 |
+
|
120 |
+
)
|
121 |
+
));
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
function render_field($field){
|
126 |
+
|
127 |
+
if(!empty($field['button_wrapper']['button_before'])){
|
128 |
+
echo $field['button_wrapper']['button_before'];
|
129 |
+
}
|
130 |
+
|
131 |
+
echo '<input
|
132 |
+
type="' . esc_attr($field['button_attributes']['button_type']) . '"
|
133 |
+
name="' . esc_attr($field['name']) . '"
|
134 |
+
id="' . esc_attr($field['button_attributes']['button_id']) . '"
|
135 |
+
class="' . esc_attr($field['button_attributes']['button_class']) . '"
|
136 |
+
value="' . esc_attr($field['button_value']) . '"
|
137 |
+
/>';
|
138 |
+
|
139 |
+
if(!empty($field['button_wrapper']['button_after'])){
|
140 |
+
echo $field['button_wrapper']['button_after'];
|
141 |
+
}
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
}
|
146 |
+
|
147 |
new acfe_field_button();
|
includes/fields/field-dynamic-message.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
class acfe_field_dynamic_message extends acf_field{
|
7 |
-
|
8 |
-
function __construct(){
|
9 |
-
$this->name = 'acfe_dynamic_message';
|
10 |
-
$this->label = __('Dynamic Message', 'acfe');
|
11 |
-
$this->category = 'layout';
|
12 |
-
|
13 |
-
parent::__construct();
|
14 |
-
}
|
15 |
-
|
16 |
-
}
|
17 |
-
|
18 |
new acfe_field_dynamic_message();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
class acfe_field_dynamic_message extends acf_field{
|
7 |
+
|
8 |
+
function __construct(){
|
9 |
+
$this->name = 'acfe_dynamic_message';
|
10 |
+
$this->label = __('Dynamic Message', 'acfe');
|
11 |
+
$this->category = 'layout';
|
12 |
+
|
13 |
+
parent::__construct();
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
new acfe_field_dynamic_message();
|
includes/fields/field-post-types.php
CHANGED
@@ -1,166 +1,172 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
class acfe_field_post_types extends acf_field{
|
7 |
-
|
8 |
-
function __construct(){
|
9 |
-
$this->name = 'acfe_post_types';
|
10 |
-
$this->label = __('Post types', 'acfe');
|
11 |
-
$this->category = 'relational';
|
12 |
-
$this->defaults = array(
|
13 |
-
'field_type' => 'checkbox',
|
14 |
-
'return_format' => 'name',
|
15 |
-
);
|
16 |
-
|
17 |
-
parent::__construct();
|
18 |
-
}
|
19 |
-
|
20 |
-
function render_field($field){
|
21 |
-
|
22 |
-
// force value to array
|
23 |
-
$field['value'] = acf_get_array($field['value']);
|
24 |
-
|
25 |
-
if(
|
26 |
-
|
27 |
-
$this->render_field_select(
|
28 |
-
|
29 |
-
}
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
'
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
new acfe_field_post_types();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
class acfe_field_post_types extends acf_field{
|
7 |
+
|
8 |
+
function __construct(){
|
9 |
+
$this->name = 'acfe_post_types';
|
10 |
+
$this->label = __('Post types', 'acfe');
|
11 |
+
$this->category = 'relational';
|
12 |
+
$this->defaults = array(
|
13 |
+
'field_type' => 'checkbox',
|
14 |
+
'return_format' => 'name',
|
15 |
+
);
|
16 |
+
|
17 |
+
parent::__construct();
|
18 |
+
}
|
19 |
+
|
20 |
+
function render_field($field){
|
21 |
+
|
22 |
+
// force value to array
|
23 |
+
$field['value'] = acf_get_array($field['value']);
|
24 |
+
|
25 |
+
if($field['field_type'] === 'select'){
|
26 |
+
|
27 |
+
$this->render_field_select($field);
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
elseif($field['field_type'] === 'radio'){
|
32 |
+
|
33 |
+
$this->render_field_checkbox($field);
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
elseif($field['field_type'] === 'checkbox'){
|
38 |
+
|
39 |
+
$this->render_field_checkbox($field);
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
function render_field_select($field){
|
46 |
+
|
47 |
+
// Change Field into a select
|
48 |
+
$field['type'] = 'select';
|
49 |
+
$field['ui'] = 0;
|
50 |
+
$field['ajax'] = 0;
|
51 |
+
$field['allow_null'] = 0;
|
52 |
+
$field['multiple'] = 0;
|
53 |
+
$field['choices'] = get_post_types(array(
|
54 |
+
'public' => true,
|
55 |
+
'show_ui' => true
|
56 |
+
), 'names');
|
57 |
+
|
58 |
+
acf_render_field($field);
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
function render_field_checkbox($field){
|
63 |
+
|
64 |
+
acf_hidden_input(array(
|
65 |
+
'type' => 'hidden',
|
66 |
+
'name' => $field['name'],
|
67 |
+
));
|
68 |
+
|
69 |
+
if($field['field_type'] === 'checkbox')
|
70 |
+
$field['name'] .= '[]';
|
71 |
+
|
72 |
+
$taxonomies = get_post_types(array(
|
73 |
+
'public' => true,
|
74 |
+
'show_ui' => true
|
75 |
+
), 'objects');
|
76 |
+
|
77 |
+
?>
|
78 |
+
<div class="categorychecklist-holder">
|
79 |
+
<ul class="acf-checkbox-list acf-bl">
|
80 |
+
|
81 |
+
<?php if(!empty($taxonomies)){ ?>
|
82 |
+
<?php foreach($taxonomies as $taxonomy){ ?>
|
83 |
+
<?php $selected = in_array($taxonomy->name, $field['value']); ?>
|
84 |
+
<li>
|
85 |
+
<label <?php echo $selected ? 'class="selected"' : ''; ?>>
|
86 |
+
<input type="<?php echo $field['field_type']; ?>" name="<?php echo $field['name']; ?>" value="<?php echo $taxonomy->name; ?>" <?php echo $selected ? 'checked="checked"' : ''; ?> />
|
87 |
+
<span><?php echo $taxonomy->label; ?></span>
|
88 |
+
</label>
|
89 |
+
</li>
|
90 |
+
|
91 |
+
<?php } ?>
|
92 |
+
<?php } ?>
|
93 |
+
|
94 |
+
</ul>
|
95 |
+
</div>
|
96 |
+
<?php
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
function render_field_settings($field){
|
101 |
+
|
102 |
+
// field_type
|
103 |
+
acf_render_field_setting( $field, array(
|
104 |
+
'label' => __('Appearance','acf'),
|
105 |
+
'instructions' => __('Select the appearance of this field', 'acf'),
|
106 |
+
'type' => 'select',
|
107 |
+
'name' => 'field_type',
|
108 |
+
'optgroup' => true,
|
109 |
+
'choices' => array(
|
110 |
+
'checkbox' => __('Checkbox', 'acf'),
|
111 |
+
'radio' => __('Radio Buttons', 'acf'),
|
112 |
+
'select' => _x('Select', 'noun', 'acf')
|
113 |
+
)
|
114 |
+
));
|
115 |
+
|
116 |
+
// return_format
|
117 |
+
acf_render_field_setting( $field, array(
|
118 |
+
'label' => __('Return Value', 'acf'),
|
119 |
+
'instructions' => '',
|
120 |
+
'type' => 'radio',
|
121 |
+
'name' => 'return_format',
|
122 |
+
'choices' => array(
|
123 |
+
'object' => __("Post Type Object", 'acfe'),
|
124 |
+
'name' => __("Post Type Name", 'acfe')
|
125 |
+
),
|
126 |
+
'layout' => 'horizontal',
|
127 |
+
));
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
function format_value($value, $post_id, $field){
|
132 |
+
|
133 |
+
if(empty($value))
|
134 |
+
return false;
|
135 |
+
|
136 |
+
// force value to array
|
137 |
+
$value = acf_get_array($value);
|
138 |
+
|
139 |
+
// format = name
|
140 |
+
if($field['return_format'] === 'name'){
|
141 |
+
|
142 |
+
if($field['field_type'] === 'select' || $field['field_type'] === 'radio')
|
143 |
+
return array_shift($value);
|
144 |
+
|
145 |
+
return $value;
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
// format = object
|
150 |
+
elseif($field['return_format'] === 'object'){
|
151 |
+
|
152 |
+
$post_types = array();
|
153 |
+
|
154 |
+
foreach($value as $post_type){
|
155 |
+
$post_types[] = get_post_type_object($post_type);
|
156 |
+
}
|
157 |
+
|
158 |
+
if($field['field_type'] === 'select' || $field['field_type'] === 'radio')
|
159 |
+
return array_shift($post_types);
|
160 |
+
|
161 |
+
return $post_types;
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
// return
|
166 |
+
return $value;
|
167 |
+
|
168 |
+
}
|
169 |
+
|
170 |
+
}
|
171 |
+
|
172 |
new acfe_field_post_types();
|
includes/fields/field-slug.php
CHANGED
@@ -1,137 +1,137 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
class acfe_field_slug extends acf_field{
|
7 |
-
|
8 |
-
function __construct(){
|
9 |
-
$this->name = 'acfe_slug';
|
10 |
-
$this->label = __('Slug', 'acfe');
|
11 |
-
$this->category = 'basic';
|
12 |
-
$this->defaults = array(
|
13 |
-
'default_value' => '',
|
14 |
-
'maxlength' => '',
|
15 |
-
'placeholder' => '',
|
16 |
-
'prepend' => '',
|
17 |
-
'append' => ''
|
18 |
-
);
|
19 |
-
|
20 |
-
parent::__construct();
|
21 |
-
}
|
22 |
-
|
23 |
-
function render_field( $field ) {
|
24 |
-
|
25 |
-
// vars
|
26 |
-
$atts = array();
|
27 |
-
$keys = array('type', 'id', 'class', 'name', 'value', 'placeholder', 'maxlength', 'pattern');
|
28 |
-
$keys2 = array('readonly', 'disabled', 'required');
|
29 |
-
$html = '';
|
30 |
-
|
31 |
-
// prepend
|
32 |
-
if($field['prepend'] !== ''){
|
33 |
-
$field['class'] .= ' acf-is-prepended';
|
34 |
-
$html .= '<div class="acf-input-prepend">' . acf_esc_html($field['prepend']) . '</div>';
|
35 |
-
}
|
36 |
-
|
37 |
-
// append
|
38 |
-
if($field['append'] !== ''){
|
39 |
-
$field['class'] .= ' acf-is-appended';
|
40 |
-
$html .= '<div class="acf-input-append">' . acf_esc_html($field['append']) . '</div>';
|
41 |
-
}
|
42 |
-
|
43 |
-
// atts (value="123")
|
44 |
-
foreach($keys as $k){
|
45 |
-
if(isset($field[ $k ]))
|
46 |
-
$atts[ $k ] = $field[ $k ];
|
47 |
-
}
|
48 |
-
|
49 |
-
// atts2 (disabled="disabled")
|
50 |
-
foreach($keys2 as $k ){
|
51 |
-
if(!empty($field[ $k ]))
|
52 |
-
$atts[ $k ] = $k;
|
53 |
-
}
|
54 |
-
|
55 |
-
// remove empty atts
|
56 |
-
$atts = acf_clean_atts($atts);
|
57 |
-
|
58 |
-
// override type
|
59 |
-
$atts['type'] = 'text';
|
60 |
-
|
61 |
-
// render
|
62 |
-
$html .= '<div class="acf-input-wrap">' . acf_get_text_input($atts) . '</div>';
|
63 |
-
|
64 |
-
|
65 |
-
// return
|
66 |
-
echo $html;
|
67 |
-
|
68 |
-
}
|
69 |
-
|
70 |
-
function render_field_settings($field){
|
71 |
-
|
72 |
-
// default_value
|
73 |
-
acf_render_field_setting( $field, array(
|
74 |
-
'label' => __('Default Value','acf'),
|
75 |
-
'instructions' => __('Appears when creating a new post','acf'),
|
76 |
-
'type' => 'text',
|
77 |
-
'name' => 'default_value',
|
78 |
-
));
|
79 |
-
|
80 |
-
|
81 |
-
// placeholder
|
82 |
-
acf_render_field_setting( $field, array(
|
83 |
-
'label' => __('Placeholder Text','acf'),
|
84 |
-
'instructions' => __('Appears within the input','acf'),
|
85 |
-
'type' => 'text',
|
86 |
-
'name' => 'placeholder',
|
87 |
-
));
|
88 |
-
|
89 |
-
|
90 |
-
// prepend
|
91 |
-
acf_render_field_setting( $field, array(
|
92 |
-
'label' => __('Prepend','acf'),
|
93 |
-
'instructions' => __('Appears before the input','acf'),
|
94 |
-
'type' => 'text',
|
95 |
-
'name' => 'prepend',
|
96 |
-
));
|
97 |
-
|
98 |
-
|
99 |
-
// append
|
100 |
-
acf_render_field_setting( $field, array(
|
101 |
-
'label' => __('Append','acf'),
|
102 |
-
'instructions' => __('Appears after the input','acf'),
|
103 |
-
'type' => 'text',
|
104 |
-
'name' => 'append',
|
105 |
-
));
|
106 |
-
|
107 |
-
|
108 |
-
// maxlength
|
109 |
-
acf_render_field_setting( $field, array(
|
110 |
-
'label' => __('Character Limit','acf'),
|
111 |
-
'instructions' => __('Leave blank for no limit','acf'),
|
112 |
-
'type' => 'number',
|
113 |
-
'name' => 'maxlength',
|
114 |
-
));
|
115 |
-
|
116 |
-
}
|
117 |
-
|
118 |
-
function validate_value($valid, $value, $field, $input){
|
119 |
-
|
120 |
-
$value = sanitize_title($value);
|
121 |
-
|
122 |
-
if($field['maxlength'] && mb_strlen(wp_unslash($value)) > $field['maxlength'])
|
123 |
-
return sprintf(__('Value must not exceed %d characters', 'acf'), $field['maxlength']);
|
124 |
-
|
125 |
-
return $valid;
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
function update_value($value, $post_id, $field){
|
130 |
-
|
131 |
-
return sanitize_title($value);
|
132 |
-
|
133 |
-
}
|
134 |
-
|
135 |
-
}
|
136 |
-
|
137 |
new acfe_field_slug();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
class acfe_field_slug extends acf_field{
|
7 |
+
|
8 |
+
function __construct(){
|
9 |
+
$this->name = 'acfe_slug';
|
10 |
+
$this->label = __('Slug', 'acfe');
|
11 |
+
$this->category = 'basic';
|
12 |
+
$this->defaults = array(
|
13 |
+
'default_value' => '',
|
14 |
+
'maxlength' => '',
|
15 |
+
'placeholder' => '',
|
16 |
+
'prepend' => '',
|
17 |
+
'append' => ''
|
18 |
+
);
|
19 |
+
|
20 |
+
parent::__construct();
|
21 |
+
}
|
22 |
+
|
23 |
+
function render_field( $field ) {
|
24 |
+
|
25 |
+
// vars
|
26 |
+
$atts = array();
|
27 |
+
$keys = array('type', 'id', 'class', 'name', 'value', 'placeholder', 'maxlength', 'pattern');
|
28 |
+
$keys2 = array('readonly', 'disabled', 'required');
|
29 |
+
$html = '';
|
30 |
+
|
31 |
+
// prepend
|
32 |
+
if($field['prepend'] !== ''){
|
33 |
+
$field['class'] .= ' acf-is-prepended';
|
34 |
+
$html .= '<div class="acf-input-prepend">' . acf_esc_html($field['prepend']) . '</div>';
|
35 |
+
}
|
36 |
+
|
37 |
+
// append
|
38 |
+
if($field['append'] !== ''){
|
39 |
+
$field['class'] .= ' acf-is-appended';
|
40 |
+
$html .= '<div class="acf-input-append">' . acf_esc_html($field['append']) . '</div>';
|
41 |
+
}
|
42 |
+
|
43 |
+
// atts (value="123")
|
44 |
+
foreach($keys as $k){
|
45 |
+
if(isset($field[ $k ]))
|
46 |
+
$atts[ $k ] = $field[ $k ];
|
47 |
+
}
|
48 |
+
|
49 |
+
// atts2 (disabled="disabled")
|
50 |
+
foreach($keys2 as $k ){
|
51 |
+
if(!empty($field[ $k ]))
|
52 |
+
$atts[ $k ] = $k;
|
53 |
+
}
|
54 |
+
|
55 |
+
// remove empty atts
|
56 |
+
$atts = acf_clean_atts($atts);
|
57 |
+
|
58 |
+
// override type
|
59 |
+
$atts['type'] = 'text';
|
60 |
+
|
61 |
+
// render
|
62 |
+
$html .= '<div class="acf-input-wrap">' . acf_get_text_input($atts) . '</div>';
|
63 |
+
|
64 |
+
|
65 |
+
// return
|
66 |
+
echo $html;
|
67 |
+
|
68 |
+
}
|
69 |
+
|
70 |
+
function render_field_settings($field){
|
71 |
+
|
72 |
+
// default_value
|
73 |
+
acf_render_field_setting( $field, array(
|
74 |
+
'label' => __('Default Value','acf'),
|
75 |
+
'instructions' => __('Appears when creating a new post','acf'),
|
76 |
+
'type' => 'text',
|
77 |
+
'name' => 'default_value',
|
78 |
+
));
|
79 |
+
|
80 |
+
|
81 |
+
// placeholder
|
82 |
+
acf_render_field_setting( $field, array(
|
83 |
+
'label' => __('Placeholder Text','acf'),
|
84 |
+
'instructions' => __('Appears within the input','acf'),
|
85 |
+
'type' => 'text',
|
86 |
+
'name' => 'placeholder',
|
87 |
+
));
|
88 |
+
|
89 |
+
|
90 |
+
// prepend
|
91 |
+
acf_render_field_setting( $field, array(
|
92 |
+
'label' => __('Prepend','acf'),
|
93 |
+
'instructions' => __('Appears before the input','acf'),
|
94 |
+
'type' => 'text',
|
95 |
+
'name' => 'prepend',
|
96 |
+
));
|
97 |
+
|
98 |
+
|
99 |
+
// append
|
100 |
+
acf_render_field_setting( $field, array(
|
101 |
+
'label' => __('Append','acf'),
|
102 |
+
'instructions' => __('Appears after the input','acf'),
|
103 |
+
'type' => 'text',
|
104 |
+
'name' => 'append',
|
105 |
+
));
|
106 |
+
|
107 |
+
|
108 |
+
// maxlength
|
109 |
+
acf_render_field_setting( $field, array(
|
110 |
+
'label' => __('Character Limit','acf'),
|
111 |
+
'instructions' => __('Leave blank for no limit','acf'),
|
112 |
+
'type' => 'number',
|
113 |
+
'name' => 'maxlength',
|
114 |
+
));
|
115 |
+
|
116 |
+
}
|
117 |
+
|
118 |
+
function validate_value($valid, $value, $field, $input){
|
119 |
+
|
120 |
+
$value = sanitize_title($value);
|
121 |
+
|
122 |
+
if($field['maxlength'] && mb_strlen(wp_unslash($value)) > $field['maxlength'])
|
123 |
+
return sprintf(__('Value must not exceed %d characters', 'acf'), $field['maxlength']);
|
124 |
+
|
125 |
+
return $valid;
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
function update_value($value, $post_id, $field){
|
130 |
+
|
131 |
+
return sanitize_title($value);
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
}
|
136 |
+
|
137 |
new acfe_field_slug();
|
includes/fields/field-taxonomies.php
CHANGED
@@ -1,166 +1,172 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
class acfe_field_taxonomies extends acf_field{
|
7 |
-
|
8 |
-
function __construct(){
|
9 |
-
$this->name = 'acfe_taxonomies';
|
10 |
-
$this->label = __('Taxonomies', 'acfe');
|
11 |
-
$this->category = 'relational';
|
12 |
-
$this->defaults = array(
|
13 |
-
'field_type' => 'checkbox',
|
14 |
-
'return_format' => 'name',
|
15 |
-
);
|
16 |
-
|
17 |
-
parent::__construct();
|
18 |
-
}
|
19 |
-
|
20 |
-
function render_field($field){
|
21 |
-
|
22 |
-
// force value to array
|
23 |
-
$field['value'] = acf_get_array($field['value']);
|
24 |
-
|
25 |
-
if(
|
26 |
-
|
27 |
-
$this->render_field_select(
|
28 |
-
|
29 |
-
}
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
'
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
new acfe_field_taxonomies();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
class acfe_field_taxonomies extends acf_field{
|
7 |
+
|
8 |
+
function __construct(){
|
9 |
+
$this->name = 'acfe_taxonomies';
|
10 |
+
$this->label = __('Taxonomies', 'acfe');
|
11 |
+
$this->category = 'relational';
|
12 |
+
$this->defaults = array(
|
13 |
+
'field_type' => 'checkbox',
|
14 |
+
'return_format' => 'name',
|
15 |
+
);
|
16 |
+
|
17 |
+
parent::__construct();
|
18 |
+
}
|
19 |
+
|
20 |
+
function render_field($field){
|
21 |
+
|
22 |
+
// force value to array
|
23 |
+
$field['value'] = acf_get_array($field['value']);
|
24 |
+
|
25 |
+
if($field['field_type'] === 'select'){
|
26 |
+
|
27 |
+
$this->render_field_select($field);
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
elseif($field['field_type'] === 'radio'){
|
32 |
+
|
33 |
+
$this->render_field_checkbox($field);
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
elseif($field['field_type'] === 'checkbox'){
|
38 |
+
|
39 |
+
$this->render_field_checkbox($field);
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
function render_field_select($field){
|
46 |
+
|
47 |
+
// Change Field into a select
|
48 |
+
$field['type'] = 'select';
|
49 |
+
$field['ui'] = 0;
|
50 |
+
$field['ajax'] = 0;
|
51 |
+
$field['allow_null'] = 0;
|
52 |
+
$field['multiple'] = 0;
|
53 |
+
$field['choices'] = get_taxonomies(array(
|
54 |
+
'public' => true,
|
55 |
+
'show_ui' => true
|
56 |
+
), 'names');
|
57 |
+
|
58 |
+
acf_render_field($field);
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
function render_field_checkbox($field){
|
63 |
+
|
64 |
+
acf_hidden_input(array(
|
65 |
+
'type' => 'hidden',
|
66 |
+
'name' => $field['name'],
|
67 |
+
));
|
68 |
+
|
69 |
+
if($field['field_type'] === 'checkbox')
|
70 |
+
$field['name'] .= '[]';
|
71 |
+
|
72 |
+
$taxonomies = get_taxonomies(array(
|
73 |
+
'public' => true,
|
74 |
+
'show_ui' => true
|
75 |
+
), 'objects');
|
76 |
+
|
77 |
+
?>
|
78 |
+
<div class="categorychecklist-holder">
|
79 |
+
<ul class="acf-checkbox-list acf-bl">
|
80 |
+
|
81 |
+
<?php if(!empty($taxonomies)){ ?>
|
82 |
+
<?php foreach($taxonomies as $taxonomy){ ?>
|
83 |
+
<?php $selected = in_array($taxonomy->name, $field['value']); ?>
|
84 |
+
<li>
|
85 |
+
<label <?php echo $selected ? 'class="selected"' : ''; ?>>
|
86 |
+
<input type="<?php echo $field['field_type']; ?>" name="<?php echo $field['name']; ?>" value="<?php echo $taxonomy->name; ?>" <?php echo $selected ? 'checked="checked"' : ''; ?> />
|
87 |
+
<span><?php echo $taxonomy->label; ?></span>
|
88 |
+
</label>
|
89 |
+
</li>
|
90 |
+
|
91 |
+
<?php } ?>
|
92 |
+
<?php } ?>
|
93 |
+
|
94 |
+
</ul>
|
95 |
+
</div>
|
96 |
+
<?php
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
function render_field_settings($field){
|
101 |
+
|
102 |
+
// field_type
|
103 |
+
acf_render_field_setting( $field, array(
|
104 |
+
'label' => __('Appearance','acf'),
|
105 |
+
'instructions' => __('Select the appearance of this field', 'acf'),
|
106 |
+
'type' => 'select',
|
107 |
+
'name' => 'field_type',
|
108 |
+
'optgroup' => true,
|
109 |
+
'choices' => array(
|
110 |
+
'checkbox' => __('Checkbox', 'acf'),
|
111 |
+
'radio' => __('Radio Buttons', 'acf'),
|
112 |
+
'select' => _x('Select', 'noun', 'acf')
|
113 |
+
)
|
114 |
+
));
|
115 |
+
|
116 |
+
// return_format
|
117 |
+
acf_render_field_setting( $field, array(
|
118 |
+
'label' => __('Return Value', 'acf'),
|
119 |
+
'instructions' => '',
|
120 |
+
'type' => 'radio',
|
121 |
+
'name' => 'return_format',
|
122 |
+
'choices' => array(
|
123 |
+
'object' => __("Taxonomy Object", 'acfe'),
|
124 |
+
'name' => __("Taxonomy Name", 'acfe')
|
125 |
+
),
|
126 |
+
'layout' => 'horizontal',
|
127 |
+
));
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
function format_value($value, $post_id, $field){
|
132 |
+
|
133 |
+
if(empty($value))
|
134 |
+
return false;
|
135 |
+
|
136 |
+
// force value to array
|
137 |
+
$value = acf_get_array($value);
|
138 |
+
|
139 |
+
// format = name
|
140 |
+
if($field['return_format'] === 'name'){
|
141 |
+
|
142 |
+
if($field['field_type'] === 'select' || $field['field_type'] === 'radio')
|
143 |
+
return array_shift($value);
|
144 |
+
|
145 |
+
return $value;
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
// format = object
|
150 |
+
elseif($field['return_format'] === 'object'){
|
151 |
+
|
152 |
+
$taxonomies = array();
|
153 |
+
|
154 |
+
foreach($value as $taxonomy){
|
155 |
+
$taxonomies[] = get_taxonomy($taxonomy);
|
156 |
+
}
|
157 |
+
|
158 |
+
if($field['field_type'] === 'select' || $field['field_type'] === 'radio')
|
159 |
+
return array_shift($taxonomies);
|
160 |
+
|
161 |
+
return $taxonomies;
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
// return
|
166 |
+
return $value;
|
167 |
+
|
168 |
+
}
|
169 |
+
|
170 |
+
}
|
171 |
+
|
172 |
new acfe_field_taxonomies();
|
includes/locations/post-type-all.php
CHANGED
@@ -1,44 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* ACFE Location: Post Type All Choices
|
8 |
-
*/
|
9 |
-
add_filter('acf/location/rule_values/post_type', 'acfe_location_post_type_all_choices');
|
10 |
-
function acfe_location_post_type_all_choices($choices){
|
11 |
-
|
12 |
-
$choices = array_merge(array('all' => __('All')), $choices);
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
44 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* ACFE Location: Post Type All Choices
|
8 |
+
*/
|
9 |
+
add_filter('acf/location/rule_values/post_type', 'acfe_location_post_type_all_choices');
|
10 |
+
function acfe_location_post_type_all_choices($choices){
|
11 |
+
|
12 |
+
$choices = array_merge(array('all' => __('All')), $choices);
|
13 |
+
|
14 |
+
return $choices;
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* ACFE Location: Post Type All Matching
|
20 |
+
*/
|
21 |
+
add_filter('acf/location/rule_match', 'acfe_location_post_type_all_match', 10, 3);
|
22 |
+
function acfe_location_post_type_all_match($match, $rule, $options){
|
23 |
+
|
24 |
+
if($rule['param'] != 'post_type' || $rule['value'] != 'all')
|
25 |
+
return $match;
|
26 |
+
|
27 |
+
if($rule['operator'] == "=="){
|
28 |
+
|
29 |
+
$match = false;
|
30 |
+
|
31 |
+
$post_types = acf_get_post_types();
|
32 |
+
if(isset($options['post_type']) && !empty($options['post_type']) && in_array($options['post_type'], $post_types))
|
33 |
+
$match = true;
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
elseif($rule['operator'] == "!="){
|
38 |
+
|
39 |
+
$match = !isset($options['post_type']) || empty($options['post_type']);
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
return $match;
|
44 |
+
|
45 |
}
|
includes/locations/post-type-archive.php
CHANGED
@@ -1,410 +1,410 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* ACFE Location: Post Type Archive Choices
|
8 |
-
*/
|
9 |
-
add_filter('acf/location/rule_values/post_type', 'acfe_location_post_type_archive_choices', 999);
|
10 |
-
function acfe_location_post_type_archive_choices($choices){
|
11 |
-
|
12 |
-
$return = array();
|
13 |
-
|
14 |
-
foreach($choices as $choice => $choice_label){
|
15 |
-
|
16 |
-
$return[$choice] = $choice_label;
|
17 |
-
$return[$choice . '_archive'] = $choice_label . ' Archive' . ($choice
|
18 |
-
|
19 |
-
}
|
20 |
-
|
21 |
-
$choices = $return;
|
22 |
-
|
23 |
-
return $choices;
|
24 |
-
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* ACFE Location: Post Type Archive Save
|
29 |
-
*/
|
30 |
-
add_action('load-edit.php', 'acfe_location_post_type_archive_save');
|
31 |
-
function acfe_location_post_type_archive_save(){
|
32 |
-
|
33 |
-
// Enqueue ACF JS
|
34 |
-
acf_enqueue_scripts();
|
35 |
-
|
36 |
-
// Success message
|
37 |
-
if(isset($_GET['message']) && $_GET['message']
|
38 |
-
acf_add_admin_notice('Options have been saved', 'success');
|
39 |
-
|
40 |
-
// Verify Nonce
|
41 |
-
if(!acf_verify_nonce('post_type_archive_options'))
|
42 |
-
return;
|
43 |
-
|
44 |
-
// Get post type
|
45 |
-
global $typenow;
|
46 |
-
|
47 |
-
// Check post type
|
48 |
-
$post_type = $typenow;
|
49 |
-
if(empty($post_type))
|
50 |
-
return;
|
51 |
-
|
52 |
-
// Validate
|
53 |
-
if(acf_validate_save_post(true)){
|
54 |
-
|
55 |
-
// Autoload
|
56 |
-
acf_update_setting('autoload', false);
|
57 |
-
|
58 |
-
// Post ID
|
59 |
-
$post_id = $post_type . '_options';
|
60 |
-
|
61 |
-
// Languages Support
|
62 |
-
$dl = acf_get_setting('default_language');
|
63 |
-
$cl = acf_get_setting('current_language');
|
64 |
-
|
65 |
-
if($cl && $cl !== $dl)
|
66 |
-
$post_id .= '_' . $cl;
|
67 |
-
|
68 |
-
// Save
|
69 |
-
acf_save_post($post_id);
|
70 |
-
|
71 |
-
// Redirect
|
72 |
-
wp_redirect(add_query_arg(array('message' => 'acfe_post_type_archive')));
|
73 |
-
exit;
|
74 |
-
|
75 |
-
}
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* ACFE Location: Post Type Archive Footer
|
81 |
-
*/
|
82 |
-
add_action('admin_footer', 'acfe_location_post_type_archive_footer');
|
83 |
-
function acfe_location_post_type_archive_footer(){
|
84 |
-
|
85 |
-
// Check current screen
|
86 |
-
global $pagenow;
|
87 |
-
if($pagenow !== 'edit.php')
|
88 |
-
return;
|
89 |
-
|
90 |
-
// Get post type
|
91 |
-
global $typenow;
|
92 |
-
|
93 |
-
// Check post type
|
94 |
-
$post_type = $typenow;
|
95 |
-
if(empty($post_type) || !in_array($post_type, acf_get_post_types()))
|
96 |
-
return;
|
97 |
-
|
98 |
-
// Check location = All archives
|
99 |
-
$field_groups_all = acf_get_field_groups(array(
|
100 |
-
'post_type' => 'all_archive',
|
101 |
-
));
|
102 |
-
|
103 |
-
// Check location = Post type archive
|
104 |
-
$field_groups_specific = acf_get_field_groups(array(
|
105 |
-
'post_type' => $post_type . '_archive'
|
106 |
-
));
|
107 |
-
|
108 |
-
$field_groups = array_merge($field_groups_all, $field_groups_specific);
|
109 |
-
|
110 |
-
// Check field groups
|
111 |
-
if(empty($field_groups))
|
112 |
-
return;
|
113 |
-
|
114 |
-
// Init field groups by position
|
115 |
-
$field_groups_position = array(
|
116 |
-
'acf_after_title' => array(),
|
117 |
-
'normal' => array(),
|
118 |
-
'side' => array()
|
119 |
-
);
|
120 |
-
|
121 |
-
foreach($field_groups as $field_group){
|
122 |
-
|
123 |
-
$field_groups_position[$field_group['position']][] = $field_group;
|
124 |
-
|
125 |
-
}
|
126 |
-
|
127 |
-
// Reset to $field_groups
|
128 |
-
$field_groups = $field_groups_position;
|
129 |
-
|
130 |
-
// Position: After Title
|
131 |
-
if(!empty($field_groups['acf_after_title'])){
|
132 |
-
|
133 |
-
$total = count($field_groups['acf_after_title']);
|
134 |
-
|
135 |
-
$current = 0; foreach($field_groups['acf_after_title'] as $field_group){ $current++;
|
136 |
-
|
137 |
-
add_meta_box(
|
138 |
-
|
139 |
-
// ID
|
140 |
-
'acf-' . $field_group['ID'],
|
141 |
-
|
142 |
-
// Title
|
143 |
-
$field_group['title'],
|
144 |
-
|
145 |
-
// Render
|
146 |
-
'acfe_post_type_archive_render_mb',
|
147 |
-
|
148 |
-
// Screen
|
149 |
-
'edit',
|
150 |
-
|
151 |
-
// Position
|
152 |
-
$field_group['position'],
|
153 |
-
|
154 |
-
// Priority
|
155 |
-
'default',
|
156 |
-
|
157 |
-
// Args
|
158 |
-
array(
|
159 |
-
'total' => $total,
|
160 |
-
'current' => $current,
|
161 |
-
'field_group' => $field_group
|
162 |
-
)
|
163 |
-
|
164 |
-
);
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
?>
|
169 |
-
<div id="tmpl-acf-after-title" class="acfe-postbox acfe-postbox-no-handle">
|
170 |
-
<form class="acf-form" action="" method="post">
|
171 |
-
|
172 |
-
<div id="poststuff" style="padding-top:0;">
|
173 |
-
|
174 |
-
<?php do_meta_boxes('edit', 'acf_after_title', array()); ?>
|
175 |
-
|
176 |
-
</div>
|
177 |
-
|
178 |
-
</form>
|
179 |
-
</div>
|
180 |
-
<script type="text/javascript">
|
181 |
-
(function($){
|
182 |
-
|
183 |
-
// add after title
|
184 |
-
$('.subsubsub').before($('#tmpl-acf-after-title'));
|
185 |
-
|
186 |
-
})(jQuery);
|
187 |
-
</script>
|
188 |
-
<?php
|
189 |
-
|
190 |
-
}
|
191 |
-
|
192 |
-
// Position: Normal
|
193 |
-
if(!empty($field_groups['normal'])){
|
194 |
-
|
195 |
-
$total = count($field_groups['normal']);
|
196 |
-
|
197 |
-
$current = 0; foreach($field_groups['normal'] as $field_group){ $current++;
|
198 |
-
|
199 |
-
add_meta_box(
|
200 |
-
|
201 |
-
// ID
|
202 |
-
'acf-' . $field_group['ID'],
|
203 |
-
|
204 |
-
// Title
|
205 |
-
$field_group['title'],
|
206 |
-
|
207 |
-
// Render
|
208 |
-
'acfe_post_type_archive_render_mb',
|
209 |
-
|
210 |
-
// Screen
|
211 |
-
'edit',
|
212 |
-
|
213 |
-
// Position
|
214 |
-
$field_group['position'],
|
215 |
-
|
216 |
-
// Priority
|
217 |
-
'default',
|
218 |
-
|
219 |
-
// Args
|
220 |
-
array(
|
221 |
-
'total' => $total,
|
222 |
-
'current' => $current,
|
223 |
-
'field_group' => $field_group
|
224 |
-
)
|
225 |
-
|
226 |
-
);
|
227 |
-
|
228 |
-
}
|
229 |
-
|
230 |
-
?>
|
231 |
-
<div id="tmpl-acf-normal" class="acfe-postbox acfe-postbox-no-handle">
|
232 |
-
<form class="acf-form" action="" method="post">
|
233 |
-
|
234 |
-
<div id="poststuff">
|
235 |
-
|
236 |
-
<?php do_meta_boxes('edit', 'normal', array()); ?>
|
237 |
-
|
238 |
-
</div>
|
239 |
-
|
240 |
-
</form>
|
241 |
-
</div>
|
242 |
-
<script type="text/javascript">
|
243 |
-
(function($){
|
244 |
-
|
245 |
-
// add normal
|
246 |
-
$('#posts-filter').after($('#tmpl-acf-normal'));
|
247 |
-
|
248 |
-
})(jQuery);
|
249 |
-
</script>
|
250 |
-
<?php
|
251 |
-
|
252 |
-
}
|
253 |
-
|
254 |
-
// Position: Side
|
255 |
-
if(!empty($field_groups['side'])){
|
256 |
-
|
257 |
-
$total = count($field_groups['side']);
|
258 |
-
|
259 |
-
$current = 0; foreach($field_groups['side'] as $field_group){ $current++;
|
260 |
-
|
261 |
-
add_meta_box(
|
262 |
-
|
263 |
-
// ID
|
264 |
-
'acf-' . $field_group['ID'],
|
265 |
-
|
266 |
-
// Title
|
267 |
-
$field_group['title'],
|
268 |
-
|
269 |
-
// Render
|
270 |
-
'acfe_post_type_archive_render_mb',
|
271 |
-
|
272 |
-
// Screen
|
273 |
-
'edit',
|
274 |
-
|
275 |
-
// Position
|
276 |
-
$field_group['position'],
|
277 |
-
|
278 |
-
// Priority
|
279 |
-
'default',
|
280 |
-
|
281 |
-
// Args
|
282 |
-
array(
|
283 |
-
'total' => $total,
|
284 |
-
'current' => $current,
|
285 |
-
'field_group' => $field_group
|
286 |
-
)
|
287 |
-
|
288 |
-
);
|
289 |
-
|
290 |
-
}
|
291 |
-
|
292 |
-
?>
|
293 |
-
<div id="tmpl-acf-side" class="acfe-postbox acfe-postbox-no-handle">
|
294 |
-
<div class="acf-column-2">
|
295 |
-
<form class="acf-form" action="" method="post">
|
296 |
-
|
297 |
-
<div id="poststuff" style="padding-top:0; min-width:auto;">
|
298 |
-
|
299 |
-
<?php do_meta_boxes('edit', 'side', array()); ?>
|
300 |
-
|
301 |
-
</div>
|
302 |
-
|
303 |
-
</form>
|
304 |
-
</div>
|
305 |
-
</div>
|
306 |
-
<script type="text/javascript">
|
307 |
-
(function($){
|
308 |
-
|
309 |
-
// wrap form
|
310 |
-
$('#posts-filter').wrap('<div class="acf-columns-2" />');
|
311 |
-
|
312 |
-
// Move subsubsub inside column
|
313 |
-
$('#posts-filter').prepend($('.subsubsub'));
|
314 |
-
|
315 |
-
// Move After title field group
|
316 |
-
$('#posts-filter').prepend($('#tmpl-acf-after-title'));
|
317 |
-
|
318 |
-
// Move Normal field group
|
319 |
-
$('#posts-filter').append($('#tmpl-acf-normal'));
|
320 |
-
|
321 |
-
// add column main
|
322 |
-
$('#posts-filter').addClass('acf-column-1');
|
323 |
-
|
324 |
-
// add column side
|
325 |
-
$('#posts-filter').after($('#tmpl-acf-side'));
|
326 |
-
|
327 |
-
})(jQuery);
|
328 |
-
</script>
|
329 |
-
<?php
|
330 |
-
|
331 |
-
}
|
332 |
-
|
333 |
-
}
|
334 |
-
|
335 |
-
function acfe_post_type_archive_render_mb($array, $args){
|
336 |
-
|
337 |
-
global $typenow;
|
338 |
-
|
339 |
-
$total = $args['args']['total'];
|
340 |
-
$current = $args['args']['current'];
|
341 |
-
$field_group = $args['args']['field_group'];
|
342 |
-
|
343 |
-
// Set post_id
|
344 |
-
$post_id = $typenow . '_options';
|
345 |
-
|
346 |
-
// Languages Support
|
347 |
-
$dl = acf_get_setting('default_language');
|
348 |
-
$cl = acf_get_setting('current_language');
|
349 |
-
|
350 |
-
if($cl && $cl !== $dl)
|
351 |
-
$post_id .= '_' . $cl;
|
352 |
-
|
353 |
-
// Set form data
|
354 |
-
acf_form_data(array(
|
355 |
-
'screen' => 'post_type_archive_options',
|
356 |
-
'post_id' => $post_id,
|
357 |
-
));
|
358 |
-
|
359 |
-
// Fix WP media upload conflict with underscore.json_decode
|
360 |
-
// Force basic uploader
|
361 |
-
acf_update_setting('uploader', 'basic');
|
362 |
-
|
363 |
-
// Get fields
|
364 |
-
$fields = acf_get_fields($field_group);
|
365 |
-
|
366 |
-
// Render fields
|
367 |
-
acf_render_fields($fields, $post_id, 'div', $field_group['instruction_placement']);
|
368 |
-
|
369 |
-
if($current === $total){ ?>
|
370 |
-
|
371 |
-
<?php
|
372 |
-
$id = ($field_group['style'] != 'seamless') ? 'major-publishing-actions' : '';
|
373 |
-
$style = ($field_group['style']
|
374 |
-
?>
|
375 |
-
|
376 |
-
<div id="<?php echo $id; ?>" style="<?php echo $style; ?>">
|
377 |
-
|
378 |
-
<div id="publishing-action">
|
379 |
-
|
380 |
-
<div class="acf-form-submit">
|
381 |
-
<input type="submit" class="acf-button button button-primary button-large" value="<?php _e('Update', 'acfe'); ?>" />
|
382 |
-
<span class="acf-spinner"></span>
|
383 |
-
</div>
|
384 |
-
|
385 |
-
</div>
|
386 |
-
<div class="clear"></div>
|
387 |
-
|
388 |
-
</div>
|
389 |
-
|
390 |
-
<?php }
|
391 |
-
|
392 |
-
// Create metabox localized data.
|
393 |
-
$data = array(
|
394 |
-
'id' => 'acf-' . $field_group['ID'],
|
395 |
-
'key' => $field_group['key'],
|
396 |
-
'style' => $field_group['style'],
|
397 |
-
'label' => $field_group['label_placement'],
|
398 |
-
'edit' => acf_get_field_group_edit_link($field_group['ID'])
|
399 |
-
);
|
400 |
-
|
401 |
-
?>
|
402 |
-
<script type="text/javascript">
|
403 |
-
if( typeof acf !== 'undefined' ) {
|
404 |
-
acf.newPostbox(<?php echo wp_json_encode($data); ?>);
|
405 |
-
}
|
406 |
-
</script>
|
407 |
-
|
408 |
-
<?php
|
409 |
-
|
410 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* ACFE Location: Post Type Archive Choices
|
8 |
+
*/
|
9 |
+
add_filter('acf/location/rule_values/post_type', 'acfe_location_post_type_archive_choices', 999);
|
10 |
+
function acfe_location_post_type_archive_choices($choices){
|
11 |
+
|
12 |
+
$return = array();
|
13 |
+
|
14 |
+
foreach($choices as $choice => $choice_label){
|
15 |
+
|
16 |
+
$return[$choice] = $choice_label;
|
17 |
+
$return[$choice . '_archive'] = $choice_label . ' Archive' . ($choice === 'all' ? 's' : '');
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
$choices = $return;
|
22 |
+
|
23 |
+
return $choices;
|
24 |
+
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* ACFE Location: Post Type Archive Save
|
29 |
+
*/
|
30 |
+
add_action('load-edit.php', 'acfe_location_post_type_archive_save');
|
31 |
+
function acfe_location_post_type_archive_save(){
|
32 |
+
|
33 |
+
// Enqueue ACF JS
|
34 |
+
acf_enqueue_scripts();
|
35 |
+
|
36 |
+
// Success message
|
37 |
+
if(isset($_GET['message']) && $_GET['message'] === 'acfe_post_type_archive')
|
38 |
+
acf_add_admin_notice('Options have been saved', 'success');
|
39 |
+
|
40 |
+
// Verify Nonce
|
41 |
+
if(!acf_verify_nonce('post_type_archive_options'))
|
42 |
+
return;
|
43 |
+
|
44 |
+
// Get post type
|
45 |
+
global $typenow;
|
46 |
+
|
47 |
+
// Check post type
|
48 |
+
$post_type = $typenow;
|
49 |
+
if(empty($post_type))
|
50 |
+
return;
|
51 |
+
|
52 |
+
// Validate
|
53 |
+
if(acf_validate_save_post(true)){
|
54 |
+
|
55 |
+
// Autoload
|
56 |
+
acf_update_setting('autoload', false);
|
57 |
+
|
58 |
+
// Post ID
|
59 |
+
$post_id = $post_type . '_options';
|
60 |
+
|
61 |
+
// Languages Support
|
62 |
+
$dl = acf_get_setting('default_language');
|
63 |
+
$cl = acf_get_setting('current_language');
|
64 |
+
|
65 |
+
if($cl && $cl !== $dl)
|
66 |
+
$post_id .= '_' . $cl;
|
67 |
+
|
68 |
+
// Save
|
69 |
+
acf_save_post($post_id);
|
70 |
+
|
71 |
+
// Redirect
|
72 |
+
wp_redirect(add_query_arg(array('message' => 'acfe_post_type_archive')));
|
73 |
+
exit;
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* ACFE Location: Post Type Archive Footer
|
81 |
+
*/
|
82 |
+
add_action('admin_footer', 'acfe_location_post_type_archive_footer');
|
83 |
+
function acfe_location_post_type_archive_footer(){
|
84 |
+
|
85 |
+
// Check current screen
|
86 |
+
global $pagenow;
|
87 |
+
if($pagenow !== 'edit.php')
|
88 |
+
return;
|
89 |
+
|
90 |
+
// Get post type
|
91 |
+
global $typenow;
|
92 |
+
|
93 |
+
// Check post type
|
94 |
+
$post_type = $typenow;
|
95 |
+
if(empty($post_type) || !in_array($post_type, acf_get_post_types()))
|
96 |
+
return;
|
97 |
+
|
98 |
+
// Check location = All archives
|
99 |
+
$field_groups_all = acf_get_field_groups(array(
|
100 |
+
'post_type' => 'all_archive',
|
101 |
+
));
|
102 |
+
|
103 |
+
// Check location = Post type archive
|
104 |
+
$field_groups_specific = acf_get_field_groups(array(
|
105 |
+
'post_type' => $post_type . '_archive'
|
106 |
+
));
|
107 |
+
|
108 |
+
$field_groups = array_merge($field_groups_all, $field_groups_specific);
|
109 |
+
|
110 |
+
// Check field groups
|
111 |
+
if(empty($field_groups))
|
112 |
+
return;
|
113 |
+
|
114 |
+
// Init field groups by position
|
115 |
+
$field_groups_position = array(
|
116 |
+
'acf_after_title' => array(),
|
117 |
+
'normal' => array(),
|
118 |
+
'side' => array()
|
119 |
+
);
|
120 |
+
|
121 |
+
foreach($field_groups as $field_group){
|
122 |
+
|
123 |
+
$field_groups_position[$field_group['position']][] = $field_group;
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
+
// Reset to $field_groups
|
128 |
+
$field_groups = $field_groups_position;
|
129 |
+
|
130 |
+
// Position: After Title
|
131 |
+
if(!empty($field_groups['acf_after_title'])){
|
132 |
+
|
133 |
+
$total = count($field_groups['acf_after_title']);
|
134 |
+
|
135 |
+
$current = 0; foreach($field_groups['acf_after_title'] as $field_group){ $current++;
|
136 |
+
|
137 |
+
add_meta_box(
|
138 |
+
|
139 |
+
// ID
|
140 |
+
'acf-' . $field_group['ID'],
|
141 |
+
|
142 |
+
// Title
|
143 |
+
$field_group['title'],
|
144 |
+
|
145 |
+
// Render
|
146 |
+
'acfe_post_type_archive_render_mb',
|
147 |
+
|
148 |
+
// Screen
|
149 |
+
'edit',
|
150 |
+
|
151 |
+
// Position
|
152 |
+
$field_group['position'],
|
153 |
+
|
154 |
+
// Priority
|
155 |
+
'default',
|
156 |
+
|
157 |
+
// Args
|
158 |
+
array(
|
159 |
+
'total' => $total,
|
160 |
+
'current' => $current,
|
161 |
+
'field_group' => $field_group
|
162 |
+
)
|
163 |
+
|
164 |
+
);
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
?>
|
169 |
+
<div id="tmpl-acf-after-title" class="acfe-postbox acfe-postbox-no-handle">
|
170 |
+
<form class="acf-form" action="" method="post">
|
171 |
+
|
172 |
+
<div id="poststuff" style="padding-top:0;">
|
173 |
+
|
174 |
+
<?php do_meta_boxes('edit', 'acf_after_title', array()); ?>
|
175 |
+
|
176 |
+
</div>
|
177 |
+
|
178 |
+
</form>
|
179 |
+
</div>
|
180 |
+
<script type="text/javascript">
|
181 |
+
(function($){
|
182 |
+
|
183 |
+
// add after title
|
184 |
+
$('.subsubsub').before($('#tmpl-acf-after-title'));
|
185 |
+
|
186 |
+
})(jQuery);
|
187 |
+
</script>
|
188 |
+
<?php
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
// Position: Normal
|
193 |
+
if(!empty($field_groups['normal'])){
|
194 |
+
|
195 |
+
$total = count($field_groups['normal']);
|
196 |
+
|
197 |
+
$current = 0; foreach($field_groups['normal'] as $field_group){ $current++;
|
198 |
+
|
199 |
+
add_meta_box(
|
200 |
+
|
201 |
+
// ID
|
202 |
+
'acf-' . $field_group['ID'],
|
203 |
+
|
204 |
+
// Title
|
205 |
+
$field_group['title'],
|
206 |
+
|
207 |
+
// Render
|
208 |
+
'acfe_post_type_archive_render_mb',
|
209 |
+
|
210 |
+
// Screen
|
211 |
+
'edit',
|
212 |
+
|
213 |
+
// Position
|
214 |
+
$field_group['position'],
|
215 |
+
|
216 |
+
// Priority
|
217 |
+
'default',
|
218 |
+
|
219 |
+
// Args
|
220 |
+
array(
|
221 |
+
'total' => $total,
|
222 |
+
'current' => $current,
|
223 |
+
'field_group' => $field_group
|
224 |
+
)
|
225 |
+
|
226 |
+
);
|
227 |
+
|
228 |
+
}
|
229 |
+
|
230 |
+
?>
|
231 |
+
<div id="tmpl-acf-normal" class="acfe-postbox acfe-postbox-no-handle">
|
232 |
+
<form class="acf-form" action="" method="post">
|
233 |
+
|
234 |
+
<div id="poststuff">
|
235 |
+
|
236 |
+
<?php do_meta_boxes('edit', 'normal', array()); ?>
|
237 |
+
|
238 |
+
</div>
|
239 |
+
|
240 |
+
</form>
|
241 |
+
</div>
|
242 |
+
<script type="text/javascript">
|
243 |
+
(function($){
|
244 |
+
|
245 |
+
// add normal
|
246 |
+
$('#posts-filter').after($('#tmpl-acf-normal'));
|
247 |
+
|
248 |
+
})(jQuery);
|
249 |
+
</script>
|
250 |
+
<?php
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
// Position: Side
|
255 |
+
if(!empty($field_groups['side'])){
|
256 |
+
|
257 |
+
$total = count($field_groups['side']);
|
258 |
+
|
259 |
+
$current = 0; foreach($field_groups['side'] as $field_group){ $current++;
|
260 |
+
|
261 |
+
add_meta_box(
|
262 |
+
|
263 |
+
// ID
|
264 |
+
'acf-' . $field_group['ID'],
|
265 |
+
|
266 |
+
// Title
|
267 |
+
$field_group['title'],
|
268 |
+
|
269 |
+
// Render
|
270 |
+
'acfe_post_type_archive_render_mb',
|
271 |
+
|
272 |
+
// Screen
|
273 |
+
'edit',
|
274 |
+
|
275 |
+
// Position
|
276 |
+
$field_group['position'],
|
277 |
+
|
278 |
+
// Priority
|
279 |
+
'default',
|
280 |
+
|
281 |
+
// Args
|
282 |
+
array(
|
283 |
+
'total' => $total,
|
284 |
+
'current' => $current,
|
285 |
+
'field_group' => $field_group
|
286 |
+
)
|
287 |
+
|
288 |
+
);
|
289 |
+
|
290 |
+
}
|
291 |
+
|
292 |
+
?>
|
293 |
+
<div id="tmpl-acf-side" class="acfe-postbox acfe-postbox-no-handle">
|
294 |
+
<div class="acf-column-2">
|
295 |
+
<form class="acf-form" action="" method="post">
|
296 |
+
|
297 |
+
<div id="poststuff" style="padding-top:0; min-width:auto;">
|
298 |
+
|
299 |
+
<?php do_meta_boxes('edit', 'side', array()); ?>
|
300 |
+
|
301 |
+
</div>
|
302 |
+
|
303 |
+
</form>
|
304 |
+
</div>
|
305 |
+
</div>
|
306 |
+
<script type="text/javascript">
|
307 |
+
(function($){
|
308 |
+
|
309 |
+
// wrap form
|
310 |
+
$('#posts-filter').wrap('<div class="acf-columns-2" />');
|
311 |
+
|
312 |
+
// Move subsubsub inside column
|
313 |
+
$('#posts-filter').prepend($('.subsubsub'));
|
314 |
+
|
315 |
+
// Move After title field group
|
316 |
+
$('#posts-filter').prepend($('#tmpl-acf-after-title'));
|
317 |
+
|
318 |
+
// Move Normal field group
|
319 |
+
$('#posts-filter').append($('#tmpl-acf-normal'));
|
320 |
+
|
321 |
+
// add column main
|
322 |
+
$('#posts-filter').addClass('acf-column-1');
|
323 |
+
|
324 |
+
// add column side
|
325 |
+
$('#posts-filter').after($('#tmpl-acf-side'));
|
326 |
+
|
327 |
+
})(jQuery);
|
328 |
+
</script>
|
329 |
+
<?php
|
330 |
+
|
331 |
+
}
|
332 |
+
|
333 |
+
}
|
334 |
+
|
335 |
+
function acfe_post_type_archive_render_mb($array, $args){
|
336 |
+
|
337 |
+
global $typenow;
|
338 |
+
|
339 |
+
$total = $args['args']['total'];
|
340 |
+
$current = $args['args']['current'];
|
341 |
+
$field_group = $args['args']['field_group'];
|
342 |
+
|
343 |
+
// Set post_id
|
344 |
+
$post_id = $typenow . '_options';
|
345 |
+
|
346 |
+
// Languages Support
|
347 |
+
$dl = acf_get_setting('default_language');
|
348 |
+
$cl = acf_get_setting('current_language');
|
349 |
+
|
350 |
+
if($cl && $cl !== $dl)
|
351 |
+
$post_id .= '_' . $cl;
|
352 |
+
|
353 |
+
// Set form data
|
354 |
+
acf_form_data(array(
|
355 |
+
'screen' => 'post_type_archive_options',
|
356 |
+
'post_id' => $post_id,
|
357 |
+
));
|
358 |
+
|
359 |
+
// Fix WP media upload conflict with underscore.json_decode
|
360 |
+
// Force basic uploader
|
361 |
+
acf_update_setting('uploader', 'basic');
|
362 |
+
|
363 |
+
// Get fields
|
364 |
+
$fields = acf_get_fields($field_group);
|
365 |
+
|
366 |
+
// Render fields
|
367 |
+
acf_render_fields($fields, $post_id, 'div', $field_group['instruction_placement']);
|
368 |
+
|
369 |
+
if($current === $total){ ?>
|
370 |
+
|
371 |
+
<?php
|
372 |
+
$id = ($field_group['style'] != 'seamless') ? 'major-publishing-actions' : '';
|
373 |
+
$style = ($field_group['style'] === 'seamless') ? 'padding:0 12px;' : '';
|
374 |
+
?>
|
375 |
+
|
376 |
+
<div id="<?php echo $id; ?>" style="<?php echo $style; ?>">
|
377 |
+
|
378 |
+
<div id="publishing-action">
|
379 |
+
|
380 |
+
<div class="acf-form-submit">
|
381 |
+
<input type="submit" class="acf-button button button-primary button-large" value="<?php _e('Update', 'acfe'); ?>" />
|
382 |
+
<span class="acf-spinner"></span>
|
383 |
+
</div>
|
384 |
+
|
385 |
+
</div>
|
386 |
+
<div class="clear"></div>
|
387 |
+
|
388 |
+
</div>
|
389 |
+
|
390 |
+
<?php }
|
391 |
+
|
392 |
+
// Create metabox localized data.
|
393 |
+
$data = array(
|
394 |
+
'id' => 'acf-' . $field_group['ID'],
|
395 |
+
'key' => $field_group['key'],
|
396 |
+
'style' => $field_group['style'],
|
397 |
+
'label' => $field_group['label_placement'],
|
398 |
+
'edit' => acf_get_field_group_edit_link($field_group['ID'])
|
399 |
+
);
|
400 |
+
|
401 |
+
?>
|
402 |
+
<script type="text/javascript">
|
403 |
+
if( typeof acf !== 'undefined' ) {
|
404 |
+
acf.newPostbox(<?php echo wp_json_encode($data); ?>);
|
405 |
+
}
|
406 |
+
</script>
|
407 |
+
|
408 |
+
<?php
|
409 |
+
|
410 |
}
|
includes/locations/taxonomy-archive.php
CHANGED
@@ -1,423 +1,423 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* ACFE Location: Taxonomy Archive Choices
|
8 |
-
*/
|
9 |
-
add_filter('acf/location/rule_values/taxonomy', 'acfe_location_taxonomy_archive_choices', 999);
|
10 |
-
function acfe_location_taxonomy_archive_choices($choices){
|
11 |
-
|
12 |
-
$return = array();
|
13 |
-
|
14 |
-
foreach($choices as $choice => $choice_label){
|
15 |
-
|
16 |
-
$return[$choice] = $choice_label;
|
17 |
-
$return[$choice . '_archive'] = $choice_label . ' Archive' . ($choice
|
18 |
-
|
19 |
-
}
|
20 |
-
|
21 |
-
$choices = $return;
|
22 |
-
|
23 |
-
return $choices;
|
24 |
-
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* ACFE Location: Fix Native ACF 'Taxonomy == All' Location Matching Taxonomies Archives
|
29 |
-
*/
|
30 |
-
add_filter('acf/location/rule_match/taxonomy', 'acfe_location_taxonomy_archive_fix_all', 10, 3);
|
31 |
-
function acfe_location_taxonomy_archive_fix_all($result, $rule, $screen){
|
32 |
-
|
33 |
-
if(!isset($screen['taxonomy']) || empty($screen['taxonomy']))
|
34 |
-
return $result;
|
35 |
-
|
36 |
-
if($rule['operator']
|
37 |
-
|
38 |
-
// Current screen taxonomy ends with '_archive'?
|
39 |
-
$length = strlen('_archive');
|
40 |
-
if(substr($screen['taxonomy'], -$length) === '_archive')
|
41 |
-
$result = false;
|
42 |
-
|
43 |
-
}
|
44 |
-
|
45 |
-
return $result;
|
46 |
-
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* ACFE Location: Taxonomy Archive Save
|
51 |
-
*/
|
52 |
-
add_action('load-edit-tags.php', 'acfe_location_taxonomy_archive_save');
|
53 |
-
function acfe_location_taxonomy_archive_save(){
|
54 |
-
|
55 |
-
// Enqueue ACF JS
|
56 |
-
acf_enqueue_scripts();
|
57 |
-
|
58 |
-
// Success message
|
59 |
-
if(isset($_GET['message']) && $_GET['message']
|
60 |
-
acf_add_admin_notice('Options have been saved', 'success');
|
61 |
-
|
62 |
-
// Verify Nonce
|
63 |
-
if(!acf_verify_nonce('taxonomy_archive_options'))
|
64 |
-
return;
|
65 |
-
|
66 |
-
// Get taxonomy
|
67 |
-
global $taxnow;
|
68 |
-
|
69 |
-
// Check taxonomy
|
70 |
-
$taxonomy = $taxnow;
|
71 |
-
if(empty($taxonomy))
|
72 |
-
return;
|
73 |
-
|
74 |
-
// Validate
|
75 |
-
if(acf_validate_save_post(true)){
|
76 |
-
|
77 |
-
// Autoload
|
78 |
-
acf_update_setting('autoload', false);
|
79 |
-
|
80 |
-
// Post ID
|
81 |
-
$post_id = 'tax_' . $taxonomy . '_options';
|
82 |
-
|
83 |
-
// Languages Support
|
84 |
-
$dl = acf_get_setting('default_language');
|
85 |
-
$cl = acf_get_setting('current_language');
|
86 |
-
|
87 |
-
if($cl && $cl !== $dl)
|
88 |
-
$post_id .= '_' . $cl;
|
89 |
-
|
90 |
-
// Save
|
91 |
-
acf_save_post($post_id);
|
92 |
-
|
93 |
-
// Redirect
|
94 |
-
wp_redirect(add_query_arg(array('message' => 'acfe_taxonomy_archive')));
|
95 |
-
exit;
|
96 |
-
|
97 |
-
}
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* ACFE Location: Taxonomy Archive Footer
|
103 |
-
*/
|
104 |
-
add_action('admin_footer', 'acfe_location_taxonomy_archive_footer');
|
105 |
-
function acfe_location_taxonomy_archive_footer(){
|
106 |
-
|
107 |
-
// Check current screen
|
108 |
-
global $pagenow;
|
109 |
-
if($pagenow !== 'edit-tags.php')
|
110 |
-
return;
|
111 |
-
|
112 |
-
// Get taxonomy
|
113 |
-
global $taxnow;
|
114 |
-
|
115 |
-
// Check taxonomy
|
116 |
-
$taxonomy = $taxnow;
|
117 |
-
if(empty($taxonomy) || !in_array($taxonomy, acf_get_taxonomies()))
|
118 |
-
return;
|
119 |
-
|
120 |
-
// Check location = All archives
|
121 |
-
$field_groups_all = acf_get_field_groups(array(
|
122 |
-
'taxonomy' => 'all_archive',
|
123 |
-
));
|
124 |
-
|
125 |
-
// Check location = Taxonomy archive
|
126 |
-
$field_groups_specific = acf_get_field_groups(array(
|
127 |
-
'taxonomy' => $taxonomy . '_archive'
|
128 |
-
));
|
129 |
-
|
130 |
-
$field_groups = array_merge($field_groups_all, $field_groups_specific);
|
131 |
-
|
132 |
-
// Check field groups
|
133 |
-
if(empty($field_groups))
|
134 |
-
return;
|
135 |
-
|
136 |
-
// Init field groups by position
|
137 |
-
$field_groups_position = array(
|
138 |
-
'acf_after_title' => array(),
|
139 |
-
'normal' => array(),
|
140 |
-
'side' => array()
|
141 |
-
);
|
142 |
-
|
143 |
-
foreach($field_groups as $field_group){
|
144 |
-
|
145 |
-
$field_groups_position[$field_group['position']][] = $field_group;
|
146 |
-
|
147 |
-
}
|
148 |
-
|
149 |
-
// Reset to $field_groups
|
150 |
-
$field_groups = $field_groups_position;
|
151 |
-
|
152 |
-
// Position: After Title
|
153 |
-
if(!empty($field_groups['acf_after_title'])){
|
154 |
-
|
155 |
-
$total = count($field_groups['acf_after_title']);
|
156 |
-
|
157 |
-
$current = 0; foreach($field_groups['acf_after_title'] as $field_group){ $current++;
|
158 |
-
|
159 |
-
add_meta_box(
|
160 |
-
|
161 |
-
// ID
|
162 |
-
'acf-' . $field_group['ID'],
|
163 |
-
|
164 |
-
// Title
|
165 |
-
$field_group['title'],
|
166 |
-
|
167 |
-
// Render
|
168 |
-
'acfe_taxonomy_archive_render_mb',
|
169 |
-
|
170 |
-
// Screen
|
171 |
-
'edit',
|
172 |
-
|
173 |
-
// Position
|
174 |
-
$field_group['position'],
|
175 |
-
|
176 |
-
// Priority
|
177 |
-
'default',
|
178 |
-
|
179 |
-
// Args
|
180 |
-
array(
|
181 |
-
'total' => $total,
|
182 |
-
'current' => $current,
|
183 |
-
'field_group' => $field_group
|
184 |
-
)
|
185 |
-
|
186 |
-
);
|
187 |
-
|
188 |
-
}
|
189 |
-
|
190 |
-
?>
|
191 |
-
<div id="tmpl-acf-after-title" class="acfe-postbox acfe-postbox-no-handle">
|
192 |
-
<form class="acf-form" action="" method="post">
|
193 |
-
|
194 |
-
<div id="poststuff">
|
195 |
-
|
196 |
-
<?php do_meta_boxes('edit', 'acf_after_title', array()); ?>
|
197 |
-
|
198 |
-
</div>
|
199 |
-
|
200 |
-
</form>
|
201 |
-
</div>
|
202 |
-
<script type="text/javascript">
|
203 |
-
(function($){
|
204 |
-
|
205 |
-
// add after title
|
206 |
-
$('.search-form').before($('#tmpl-acf-after-title'));
|
207 |
-
|
208 |
-
})(jQuery);
|
209 |
-
</script>
|
210 |
-
<?php
|
211 |
-
|
212 |
-
}
|
213 |
-
|
214 |
-
// Position: Normal
|
215 |
-
if(!empty($field_groups['normal'])){
|
216 |
-
|
217 |
-
$total = count($field_groups['normal']);
|
218 |
-
|
219 |
-
$current = 0; foreach($field_groups['normal'] as $field_group){ $current++;
|
220 |
-
|
221 |
-
add_meta_box(
|
222 |
-
|
223 |
-
// ID
|
224 |
-
'acf-' . $field_group['ID'],
|
225 |
-
|
226 |
-
// Title
|
227 |
-
$field_group['title'],
|
228 |
-
|
229 |
-
// Render
|
230 |
-
'acfe_taxonomy_archive_render_mb',
|
231 |
-
|
232 |
-
// Screen
|
233 |
-
'edit',
|
234 |
-
|
235 |
-
// Position
|
236 |
-
$field_group['position'],
|
237 |
-
|
238 |
-
// Priority
|
239 |
-
'default',
|
240 |
-
|
241 |
-
// Args
|
242 |
-
array(
|
243 |
-
'total' => $total,
|
244 |
-
'current' => $current,
|
245 |
-
'field_group' => $field_group
|
246 |
-
)
|
247 |
-
|
248 |
-
);
|
249 |
-
|
250 |
-
}
|
251 |
-
|
252 |
-
?>
|
253 |
-
<div id="tmpl-acf-normal" class="acfe-postbox acfe-postbox-no-handle">
|
254 |
-
<form class="acf-form" action="" method="post">
|
255 |
-
|
256 |
-
<div id="poststuff">
|
257 |
-
|
258 |
-
<?php do_meta_boxes('edit', 'normal', array()); ?>
|
259 |
-
|
260 |
-
</div>
|
261 |
-
|
262 |
-
</form>
|
263 |
-
</div>
|
264 |
-
<script type="text/javascript">
|
265 |
-
(function($){
|
266 |
-
|
267 |
-
// add normal
|
268 |
-
$('#posts-filter').after($('#tmpl-acf-normal'));
|
269 |
-
|
270 |
-
})(jQuery);
|
271 |
-
</script>
|
272 |
-
<?php
|
273 |
-
|
274 |
-
}
|
275 |
-
|
276 |
-
// Position: Side
|
277 |
-
if(!empty($field_groups['side'])){
|
278 |
-
|
279 |
-
$total = count($field_groups['side']);
|
280 |
-
|
281 |
-
$current = 0; foreach($field_groups['side'] as $field_group){ $current++;
|
282 |
-
|
283 |
-
add_meta_box(
|
284 |
-
|
285 |
-
// ID
|
286 |
-
'acf-' . $field_group['ID'],
|
287 |
-
|
288 |
-
// Title
|
289 |
-
$field_group['title'],
|
290 |
-
|
291 |
-
// Render
|
292 |
-
'acfe_taxonomy_archive_render_mb',
|
293 |
-
|
294 |
-
// Screen
|
295 |
-
'edit',
|
296 |
-
|
297 |
-
// Position
|
298 |
-
$field_group['position'],
|
299 |
-
|
300 |
-
// Priority
|
301 |
-
'default',
|
302 |
-
|
303 |
-
// Args
|
304 |
-
array(
|
305 |
-
'total' => $total,
|
306 |
-
'current' => $current,
|
307 |
-
'field_group' => $field_group
|
308 |
-
)
|
309 |
-
|
310 |
-
);
|
311 |
-
|
312 |
-
}
|
313 |
-
|
314 |
-
?>
|
315 |
-
<div id="tmpl-acf-side" class="acfe-postbox acfe-postbox-no-handle">
|
316 |
-
<div class="acf-column-2">
|
317 |
-
<form class="acf-form" action="" method="post">
|
318 |
-
|
319 |
-
<div id="poststuff" style="padding-top:0; min-width:auto;">
|
320 |
-
|
321 |
-
<?php do_meta_boxes('edit', 'side', array()); ?>
|
322 |
-
|
323 |
-
</div>
|
324 |
-
|
325 |
-
</form>
|
326 |
-
</div>
|
327 |
-
</div>
|
328 |
-
<script type="text/javascript">
|
329 |
-
(function($){
|
330 |
-
|
331 |
-
// Wrap form
|
332 |
-
$('.search-form').next('#col-container').andSelf().wrapAll('<div class="acf-columns-2"><div class="acf-column-1"></div></div>');
|
333 |
-
|
334 |
-
// Move After title field group
|
335 |
-
$('.acf-column-1').prepend($('#tmpl-acf-after-title'));
|
336 |
-
|
337 |
-
// Add column side
|
338 |
-
$('.acf-column-1').after($('#tmpl-acf-side'));
|
339 |
-
|
340 |
-
})(jQuery);
|
341 |
-
</script>
|
342 |
-
<?php
|
343 |
-
|
344 |
-
}
|
345 |
-
|
346 |
-
}
|
347 |
-
|
348 |
-
function acfe_taxonomy_archive_render_mb($array, $args){
|
349 |
-
|
350 |
-
global $taxnow;
|
351 |
-
|
352 |
-
$total = $args['args']['total'];
|
353 |
-
$current = $args['args']['current'];
|
354 |
-
$field_group = $args['args']['field_group'];
|
355 |
-
|
356 |
-
// Set post_id
|
357 |
-
$post_id = 'tax_' . $taxnow . '_options';
|
358 |
-
|
359 |
-
// Languages Support
|
360 |
-
$dl = acf_get_setting('default_language');
|
361 |
-
$cl = acf_get_setting('current_language');
|
362 |
-
|
363 |
-
if($cl && $cl !== $dl)
|
364 |
-
$post_id .= '_' . $cl;
|
365 |
-
|
366 |
-
// Set form data
|
367 |
-
acf_form_data(array(
|
368 |
-
'screen' => 'taxonomy_archive_options',
|
369 |
-
'post_id' => $post_id,
|
370 |
-
));
|
371 |
-
|
372 |
-
// Fix WP media upload conflict with underscore.json_decode
|
373 |
-
// Force basic uploader
|
374 |
-
acf_update_setting('uploader', 'basic');
|
375 |
-
|
376 |
-
// Get fields
|
377 |
-
$fields = acf_get_fields($field_group);
|
378 |
-
|
379 |
-
// Render fields
|
380 |
-
acf_render_fields($fields, $post_id, 'div', $field_group['instruction_placement']);
|
381 |
-
|
382 |
-
if($current === $total){ ?>
|
383 |
-
|
384 |
-
<?php
|
385 |
-
$id = ($field_group['style'] != 'seamless') ? 'major-publishing-actions' : '';
|
386 |
-
$style = ($field_group['style']
|
387 |
-
?>
|
388 |
-
|
389 |
-
<div id="<?php echo $id; ?>" style="<?php echo $style; ?>">
|
390 |
-
|
391 |
-
<div id="publishing-action">
|
392 |
-
|
393 |
-
<div class="acf-form-submit">
|
394 |
-
<input type="submit" class="acf-button button button-primary button-large" value="<?php _e('Update', 'acfe'); ?>" />
|
395 |
-
<span class="acf-spinner"></span>
|
396 |
-
</div>
|
397 |
-
|
398 |
-
</div>
|
399 |
-
<div class="clear"></div>
|
400 |
-
|
401 |
-
</div>
|
402 |
-
|
403 |
-
<?php }
|
404 |
-
|
405 |
-
// Create metabox localized data.
|
406 |
-
$data = array(
|
407 |
-
'id' => 'acf-' . $field_group['ID'],
|
408 |
-
'key' => $field_group['key'],
|
409 |
-
'style' => $field_group['style'],
|
410 |
-
'label' => $field_group['label_placement'],
|
411 |
-
'edit' => acf_get_field_group_edit_link($field_group['ID'])
|
412 |
-
);
|
413 |
-
|
414 |
-
?>
|
415 |
-
<script type="text/javascript">
|
416 |
-
if( typeof acf !== 'undefined' ) {
|
417 |
-
acf.newPostbox(<?php echo wp_json_encode($data); ?>);
|
418 |
-
}
|
419 |
-
</script>
|
420 |
-
|
421 |
-
<?php
|
422 |
-
|
423 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* ACFE Location: Taxonomy Archive Choices
|
8 |
+
*/
|
9 |
+
add_filter('acf/location/rule_values/taxonomy', 'acfe_location_taxonomy_archive_choices', 999);
|
10 |
+
function acfe_location_taxonomy_archive_choices($choices){
|
11 |
+
|
12 |
+
$return = array();
|
13 |
+
|
14 |
+
foreach($choices as $choice => $choice_label){
|
15 |
+
|
16 |
+
$return[$choice] = $choice_label;
|
17 |
+
$return[$choice . '_archive'] = $choice_label . ' Archive' . ($choice === 'all' ? 's' : '');
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
$choices = $return;
|
22 |
+
|
23 |
+
return $choices;
|
24 |
+
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* ACFE Location: Fix Native ACF 'Taxonomy == All' Location Matching Taxonomies Archives
|
29 |
+
*/
|
30 |
+
add_filter('acf/location/rule_match/taxonomy', 'acfe_location_taxonomy_archive_fix_all', 10, 3);
|
31 |
+
function acfe_location_taxonomy_archive_fix_all($result, $rule, $screen){
|
32 |
+
|
33 |
+
if(!isset($screen['taxonomy']) || empty($screen['taxonomy']))
|
34 |
+
return $result;
|
35 |
+
|
36 |
+
if($rule['operator'] === '==' && $rule['value'] === 'all'){
|
37 |
+
|
38 |
+
// Current screen taxonomy ends with '_archive'?
|
39 |
+
$length = strlen('_archive');
|
40 |
+
if(substr($screen['taxonomy'], -$length) === '_archive')
|
41 |
+
$result = false;
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
return $result;
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* ACFE Location: Taxonomy Archive Save
|
51 |
+
*/
|
52 |
+
add_action('load-edit-tags.php', 'acfe_location_taxonomy_archive_save');
|
53 |
+
function acfe_location_taxonomy_archive_save(){
|
54 |
+
|
55 |
+
// Enqueue ACF JS
|
56 |
+
acf_enqueue_scripts();
|
57 |
+
|
58 |
+
// Success message
|
59 |
+
if(isset($_GET['message']) && $_GET['message'] === 'acfe_taxonomy_archive')
|
60 |
+
acf_add_admin_notice('Options have been saved', 'success');
|
61 |
+
|
62 |
+
// Verify Nonce
|
63 |
+
if(!acf_verify_nonce('taxonomy_archive_options'))
|
64 |
+
return;
|
65 |
+
|
66 |
+
// Get taxonomy
|
67 |
+
global $taxnow;
|
68 |
+
|
69 |
+
// Check taxonomy
|
70 |
+
$taxonomy = $taxnow;
|
71 |
+
if(empty($taxonomy))
|
72 |
+
return;
|
73 |
+
|
74 |
+
// Validate
|
75 |
+
if(acf_validate_save_post(true)){
|
76 |
+
|
77 |
+
// Autoload
|
78 |
+
acf_update_setting('autoload', false);
|
79 |
+
|
80 |
+
// Post ID
|
81 |
+
$post_id = 'tax_' . $taxonomy . '_options';
|
82 |
+
|
83 |
+
// Languages Support
|
84 |
+
$dl = acf_get_setting('default_language');
|
85 |
+
$cl = acf_get_setting('current_language');
|
86 |
+
|
87 |
+
if($cl && $cl !== $dl)
|
88 |
+
$post_id .= '_' . $cl;
|
89 |
+
|
90 |
+
// Save
|
91 |
+
acf_save_post($post_id);
|
92 |
+
|
93 |
+
// Redirect
|
94 |
+
wp_redirect(add_query_arg(array('message' => 'acfe_taxonomy_archive')));
|
95 |
+
exit;
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* ACFE Location: Taxonomy Archive Footer
|
103 |
+
*/
|
104 |
+
add_action('admin_footer', 'acfe_location_taxonomy_archive_footer');
|
105 |
+
function acfe_location_taxonomy_archive_footer(){
|
106 |
+
|
107 |
+
// Check current screen
|
108 |
+
global $pagenow;
|
109 |
+
if($pagenow !== 'edit-tags.php')
|
110 |
+
return;
|
111 |
+
|
112 |
+
// Get taxonomy
|
113 |
+
global $taxnow;
|
114 |
+
|
115 |
+
// Check taxonomy
|
116 |
+
$taxonomy = $taxnow;
|
117 |
+
if(empty($taxonomy) || !in_array($taxonomy, acf_get_taxonomies()))
|
118 |
+
return;
|
119 |
+
|
120 |
+
// Check location = All archives
|
121 |
+
$field_groups_all = acf_get_field_groups(array(
|
122 |
+
'taxonomy' => 'all_archive',
|
123 |
+
));
|
124 |
+
|
125 |
+
// Check location = Taxonomy archive
|
126 |
+
$field_groups_specific = acf_get_field_groups(array(
|
127 |
+
'taxonomy' => $taxonomy . '_archive'
|
128 |
+
));
|
129 |
+
|
130 |
+
$field_groups = array_merge($field_groups_all, $field_groups_specific);
|
131 |
+
|
132 |
+
// Check field groups
|
133 |
+
if(empty($field_groups))
|
134 |
+
return;
|
135 |
+
|
136 |
+
// Init field groups by position
|
137 |
+
$field_groups_position = array(
|
138 |
+
'acf_after_title' => array(),
|
139 |
+
'normal' => array(),
|
140 |
+
'side' => array()
|
141 |
+
);
|
142 |
+
|
143 |
+
foreach($field_groups as $field_group){
|
144 |
+
|
145 |
+
$field_groups_position[$field_group['position']][] = $field_group;
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
// Reset to $field_groups
|
150 |
+
$field_groups = $field_groups_position;
|
151 |
+
|
152 |
+
// Position: After Title
|
153 |
+
if(!empty($field_groups['acf_after_title'])){
|
154 |
+
|
155 |
+
$total = count($field_groups['acf_after_title']);
|
156 |
+
|
157 |
+
$current = 0; foreach($field_groups['acf_after_title'] as $field_group){ $current++;
|
158 |
+
|
159 |
+
add_meta_box(
|
160 |
+
|
161 |
+
// ID
|
162 |
+
'acf-' . $field_group['ID'],
|
163 |
+
|
164 |
+
// Title
|
165 |
+
$field_group['title'],
|
166 |
+
|
167 |
+
// Render
|
168 |
+
'acfe_taxonomy_archive_render_mb',
|
169 |
+
|
170 |
+
// Screen
|
171 |
+
'edit',
|
172 |
+
|
173 |
+
// Position
|
174 |
+
$field_group['position'],
|
175 |
+
|
176 |
+
// Priority
|
177 |
+
'default',
|
178 |
+
|
179 |
+
// Args
|
180 |
+
array(
|
181 |
+
'total' => $total,
|
182 |
+
'current' => $current,
|
183 |
+
'field_group' => $field_group
|
184 |
+
)
|
185 |
+
|
186 |
+
);
|
187 |
+
|
188 |
+
}
|
189 |
+
|
190 |
+
?>
|
191 |
+
<div id="tmpl-acf-after-title" class="acfe-postbox acfe-postbox-no-handle">
|
192 |
+
<form class="acf-form" action="" method="post">
|
193 |
+
|
194 |
+
<div id="poststuff">
|
195 |
+
|
196 |
+
<?php do_meta_boxes('edit', 'acf_after_title', array()); ?>
|
197 |
+
|
198 |
+
</div>
|
199 |
+
|
200 |
+
</form>
|
201 |
+
</div>
|
202 |
+
<script type="text/javascript">
|
203 |
+
(function($){
|
204 |
+
|
205 |
+
// add after title
|
206 |
+
$('.search-form').before($('#tmpl-acf-after-title'));
|
207 |
+
|
208 |
+
})(jQuery);
|
209 |
+
</script>
|
210 |
+
<?php
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
// Position: Normal
|
215 |
+
if(!empty($field_groups['normal'])){
|
216 |
+
|
217 |
+
$total = count($field_groups['normal']);
|
218 |
+
|
219 |
+
$current = 0; foreach($field_groups['normal'] as $field_group){ $current++;
|
220 |
+
|
221 |
+
add_meta_box(
|
222 |
+
|
223 |
+
// ID
|
224 |
+
'acf-' . $field_group['ID'],
|
225 |
+
|
226 |
+
// Title
|
227 |
+
$field_group['title'],
|
228 |
+
|
229 |
+
// Render
|
230 |
+
'acfe_taxonomy_archive_render_mb',
|
231 |
+
|
232 |
+
// Screen
|
233 |
+
'edit',
|
234 |
+
|
235 |
+
// Position
|
236 |
+
$field_group['position'],
|
237 |
+
|
238 |
+
// Priority
|
239 |
+
'default',
|
240 |
+
|
241 |
+
// Args
|
242 |
+
array(
|
243 |
+
'total' => $total,
|
244 |
+
'current' => $current,
|
245 |
+
'field_group' => $field_group
|
246 |
+
)
|
247 |
+
|
248 |
+
);
|
249 |
+
|
250 |
+
}
|
251 |
+
|
252 |
+
?>
|
253 |
+
<div id="tmpl-acf-normal" class="acfe-postbox acfe-postbox-no-handle">
|
254 |
+
<form class="acf-form" action="" method="post">
|
255 |
+
|
256 |
+
<div id="poststuff">
|
257 |
+
|
258 |
+
<?php do_meta_boxes('edit', 'normal', array()); ?>
|
259 |
+
|
260 |
+
</div>
|
261 |
+
|
262 |
+
</form>
|
263 |
+
</div>
|
264 |
+
<script type="text/javascript">
|
265 |
+
(function($){
|
266 |
+
|
267 |
+
// add normal
|
268 |
+
$('#posts-filter').after($('#tmpl-acf-normal'));
|
269 |
+
|
270 |
+
})(jQuery);
|
271 |
+
</script>
|
272 |
+
<?php
|
273 |
+
|
274 |
+
}
|
275 |
+
|
276 |
+
// Position: Side
|
277 |
+
if(!empty($field_groups['side'])){
|
278 |
+
|
279 |
+
$total = count($field_groups['side']);
|
280 |
+
|
281 |
+
$current = 0; foreach($field_groups['side'] as $field_group){ $current++;
|
282 |
+
|
283 |
+
add_meta_box(
|
284 |
+
|
285 |
+
// ID
|
286 |
+
'acf-' . $field_group['ID'],
|
287 |
+
|
288 |
+
// Title
|
289 |
+
$field_group['title'],
|
290 |
+
|
291 |
+
// Render
|
292 |
+
'acfe_taxonomy_archive_render_mb',
|
293 |
+
|
294 |
+
// Screen
|
295 |
+
'edit',
|
296 |
+
|
297 |
+
// Position
|
298 |
+
$field_group['position'],
|
299 |
+
|
300 |
+
// Priority
|
301 |
+
'default',
|
302 |
+
|
303 |
+
// Args
|
304 |
+
array(
|
305 |
+
'total' => $total,
|
306 |
+
'current' => $current,
|
307 |
+
'field_group' => $field_group
|
308 |
+
)
|
309 |
+
|
310 |
+
);
|
311 |
+
|
312 |
+
}
|
313 |
+
|
314 |
+
?>
|
315 |
+
<div id="tmpl-acf-side" class="acfe-postbox acfe-postbox-no-handle">
|
316 |
+
<div class="acf-column-2">
|
317 |
+
<form class="acf-form" action="" method="post">
|
318 |
+
|
319 |
+
<div id="poststuff" style="padding-top:0; min-width:auto;">
|
320 |
+
|
321 |
+
<?php do_meta_boxes('edit', 'side', array()); ?>
|
322 |
+
|
323 |
+
</div>
|
324 |
+
|
325 |
+
</form>
|
326 |
+
</div>
|
327 |
+
</div>
|
328 |
+
<script type="text/javascript">
|
329 |
+
(function($){
|
330 |
+
|
331 |
+
// Wrap form
|
332 |
+
$('.search-form').next('#col-container').andSelf().wrapAll('<div class="acf-columns-2"><div class="acf-column-1"></div></div>');
|
333 |
+
|
334 |
+
// Move After title field group
|
335 |
+
$('.acf-column-1').prepend($('#tmpl-acf-after-title'));
|
336 |
+
|
337 |
+
// Add column side
|
338 |
+
$('.acf-column-1').after($('#tmpl-acf-side'));
|
339 |
+
|
340 |
+
})(jQuery);
|
341 |
+
</script>
|
342 |
+
<?php
|
343 |
+
|
344 |
+
}
|
345 |
+
|
346 |
+
}
|
347 |
+
|
348 |
+
function acfe_taxonomy_archive_render_mb($array, $args){
|
349 |
+
|
350 |
+
global $taxnow;
|
351 |
+
|
352 |
+
$total = $args['args']['total'];
|
353 |
+
$current = $args['args']['current'];
|
354 |
+
$field_group = $args['args']['field_group'];
|
355 |
+
|
356 |
+
// Set post_id
|
357 |
+
$post_id = 'tax_' . $taxnow . '_options';
|
358 |
+
|
359 |
+
// Languages Support
|
360 |
+
$dl = acf_get_setting('default_language');
|
361 |
+
$cl = acf_get_setting('current_language');
|
362 |
+
|
363 |
+
if($cl && $cl !== $dl)
|
364 |
+
$post_id .= '_' . $cl;
|
365 |
+
|
366 |
+
// Set form data
|
367 |
+
acf_form_data(array(
|
368 |
+
'screen' => 'taxonomy_archive_options',
|
369 |
+
'post_id' => $post_id,
|
370 |
+
));
|
371 |
+
|
372 |
+
// Fix WP media upload conflict with underscore.json_decode
|
373 |
+
// Force basic uploader
|
374 |
+
acf_update_setting('uploader', 'basic');
|
375 |
+
|
376 |
+
// Get fields
|
377 |
+
$fields = acf_get_fields($field_group);
|
378 |
+
|
379 |
+
// Render fields
|
380 |
+
acf_render_fields($fields, $post_id, 'div', $field_group['instruction_placement']);
|
381 |
+
|
382 |
+
if($current === $total){ ?>
|
383 |
+
|
384 |
+
<?php
|
385 |
+
$id = ($field_group['style'] != 'seamless') ? 'major-publishing-actions' : '';
|
386 |
+
$style = ($field_group['style'] === 'seamless') ? 'padding:0 12px;' : '';
|
387 |
+
?>
|
388 |
+
|
389 |
+
<div id="<?php echo $id; ?>" style="<?php echo $style; ?>">
|
390 |
+
|
391 |
+
<div id="publishing-action">
|
392 |
+
|
393 |
+
<div class="acf-form-submit">
|
394 |
+
<input type="submit" class="acf-button button button-primary button-large" value="<?php _e('Update', 'acfe'); ?>" />
|
395 |
+
<span class="acf-spinner"></span>
|
396 |
+
</div>
|
397 |
+
|
398 |
+
</div>
|
399 |
+
<div class="clear"></div>
|
400 |
+
|
401 |
+
</div>
|
402 |
+
|
403 |
+
<?php }
|
404 |
+
|
405 |
+
// Create metabox localized data.
|
406 |
+
$data = array(
|
407 |
+
'id' => 'acf-' . $field_group['ID'],
|
408 |
+
'key' => $field_group['key'],
|
409 |
+
'style' => $field_group['style'],
|
410 |
+
'label' => $field_group['label_placement'],
|
411 |
+
'edit' => acf_get_field_group_edit_link($field_group['ID'])
|
412 |
+
);
|
413 |
+
|
414 |
+
?>
|
415 |
+
<script type="text/javascript">
|
416 |
+
if( typeof acf !== 'undefined' ) {
|
417 |
+
acf.newPostbox(<?php echo wp_json_encode($data); ?>);
|
418 |
+
}
|
419 |
+
</script>
|
420 |
+
|
421 |
+
<?php
|
422 |
+
|
423 |
}
|
includes/modules/author.php
CHANGED
@@ -1,230 +1,234 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
}
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
$
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
'
|
102 |
-
'
|
103 |
-
'
|
104 |
-
'
|
105 |
-
'
|
106 |
-
'
|
107 |
-
'
|
108 |
-
'
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
'
|
115 |
-
'
|
116 |
-
'
|
117 |
-
'
|
118 |
-
'
|
119 |
-
'
|
120 |
-
'
|
121 |
-
'
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
$
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
// Check
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
$
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
|
|
|
|
|
|
|
|
230 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/author', true))
|
8 |
+
return;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Register Field Group
|
12 |
+
*/
|
13 |
+
add_filter('acf/get_field_groups', 'acfe_author_field_group_permissions', 999);
|
14 |
+
function acfe_author_field_group_permissions($field_groups){
|
15 |
+
|
16 |
+
if(!is_admin())
|
17 |
+
return $field_groups;
|
18 |
+
|
19 |
+
$check_current_screen = acf_is_screen(array(
|
20 |
+
'edit-acf-field-group',
|
21 |
+
'acf-field-group',
|
22 |
+
'acf_page_acf-tools'
|
23 |
+
));
|
24 |
+
|
25 |
+
if($check_current_screen)
|
26 |
+
return $field_groups;
|
27 |
+
|
28 |
+
global $post;
|
29 |
+
|
30 |
+
// Get Post ID
|
31 |
+
$post_id = get_the_ID();
|
32 |
+
|
33 |
+
if(empty($post_id) && isset($_REQUEST['post']))
|
34 |
+
$post_id = (int) $_REQUEST['post'];
|
35 |
+
|
36 |
+
if(empty($post_id) && isset($post->ID))
|
37 |
+
$post_id = $post->ID;
|
38 |
+
|
39 |
+
if(empty($post_id))
|
40 |
+
return $field_groups;
|
41 |
+
|
42 |
+
// Get Post Type Object
|
43 |
+
$post_type_object = get_post_type_object(get_post_type($post_id));
|
44 |
+
if(empty($post_type_object))
|
45 |
+
return $field_groups;
|
46 |
+
|
47 |
+
foreach($field_groups as $key => $field_group){
|
48 |
+
|
49 |
+
if($field_group['key'] != 'group_acfe_author')
|
50 |
+
continue;
|
51 |
+
|
52 |
+
if(!current_user_can($post_type_object->cap->edit_others_posts))
|
53 |
+
unset($field_groups[$key]);
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
return $field_groups;
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Register Author Field
|
63 |
+
*/
|
64 |
+
add_action('admin_init', 'acfe_author_field_group');
|
65 |
+
function acfe_author_field_group(){
|
66 |
+
|
67 |
+
// Get Post Types Locations
|
68 |
+
$get_post_types = get_post_types_by_support('author');
|
69 |
+
if(empty($get_post_types))
|
70 |
+
return;
|
71 |
+
|
72 |
+
// Set Locations
|
73 |
+
$locations = array();
|
74 |
+
|
75 |
+
foreach($get_post_types as $post_type){
|
76 |
+
|
77 |
+
$locations[] = array(
|
78 |
+
array(
|
79 |
+
'param' => 'post_type',
|
80 |
+
'operator' => '==',
|
81 |
+
'value' => $post_type,
|
82 |
+
)
|
83 |
+
);
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
// Roles
|
88 |
+
global $wp_roles;
|
89 |
+
|
90 |
+
$authors_roles = array();
|
91 |
+
foreach($wp_roles->roles as $role_name => $role){
|
92 |
+
|
93 |
+
if(!isset($role['capabilities']['level_1']) || empty($role['capabilities']['level_1']))
|
94 |
+
continue;
|
95 |
+
|
96 |
+
$authors_roles[] = $role_name;
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
acf_add_local_field_group(array(
|
101 |
+
'title' => __('Author'),
|
102 |
+
'key' => 'group_acfe_author',
|
103 |
+
'menu_order' => 99999,
|
104 |
+
'position' => 'side',
|
105 |
+
'style' => 'default',
|
106 |
+
'label_placement' => 'top',
|
107 |
+
'instruction_placement' => 'label',
|
108 |
+
'hide_on_screen' => '',
|
109 |
+
'active' => 1,
|
110 |
+
'description' => '',
|
111 |
+
'location' => $locations,
|
112 |
+
'fields' => array(
|
113 |
+
array(
|
114 |
+
'label' => '',
|
115 |
+
'key' => 'acfe_author',
|
116 |
+
'name' => 'acfe_author',
|
117 |
+
'type' => 'user',
|
118 |
+
'instructions' => '',
|
119 |
+
'required' => 0,
|
120 |
+
'conditional_logic' => 0,
|
121 |
+
'allow_null' => 0,
|
122 |
+
'multiple' => 0,
|
123 |
+
'return_format' => 'array',
|
124 |
+
'role' => $authors_roles,
|
125 |
+
'wrapper' => array(
|
126 |
+
'width' => '',
|
127 |
+
'class' => '',
|
128 |
+
'id' => '',
|
129 |
+
)
|
130 |
+
),
|
131 |
+
)
|
132 |
+
));
|
133 |
+
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Remove Native WP Metabox
|
138 |
+
*/
|
139 |
+
add_action('admin_menu','acfe_author_remove_default_metabox');
|
140 |
+
function acfe_author_remove_default_metabox(){
|
141 |
+
|
142 |
+
$get_post_types = get_post_types_by_support('author');
|
143 |
+
if(empty($get_post_types))
|
144 |
+
return;
|
145 |
+
|
146 |
+
foreach($get_post_types as $post_type){
|
147 |
+
|
148 |
+
if(in_array($post_type, array('attachment', 'revision', 'customize_changeset')))
|
149 |
+
continue;
|
150 |
+
|
151 |
+
// Remove Metabox
|
152 |
+
remove_meta_box('authordiv', $post_type, 'normal');
|
153 |
+
|
154 |
+
}
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Prepare Default Value
|
160 |
+
*/
|
161 |
+
add_filter('acf/prepare_field/name=acfe_author', 'acfe_author_prepare');
|
162 |
+
function acfe_author_prepare($field){
|
163 |
+
|
164 |
+
// Get Post ID
|
165 |
+
$post_id = get_the_ID();
|
166 |
+
if(empty($post_id))
|
167 |
+
return false;
|
168 |
+
|
169 |
+
// Check Post Type & Permissions
|
170 |
+
$post_type_object = get_post_type_object(get_post_type($post_id));
|
171 |
+
if(empty($post_type_object) || !current_user_can($post_type_object->cap->edit_others_posts))
|
172 |
+
return false;
|
173 |
+
|
174 |
+
// Set Default
|
175 |
+
$author_id = get_post_field('post_author', $post_id);
|
176 |
+
$field['value'] = $author_id;
|
177 |
+
|
178 |
+
return $field;
|
179 |
+
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Save Post Action
|
184 |
+
*/
|
185 |
+
add_action('acf/save_post', 'acfe_author_post_save', 0);
|
186 |
+
function acfe_author_post_save($post_id){
|
187 |
+
|
188 |
+
// Check Field Exists
|
189 |
+
if(!isset($_POST['acf']['acfe_author']))
|
190 |
+
return;
|
191 |
+
|
192 |
+
// Check Post Type & Permissions
|
193 |
+
$post_type_object = get_post_type_object(get_post_type($post_id));
|
194 |
+
if(empty($post_type_object) || !current_user_can($post_type_object->cap->edit_others_posts))
|
195 |
+
return;
|
196 |
+
|
197 |
+
// Set & Validate Author
|
198 |
+
$author_id = (int) $_POST['acf']['acfe_author'];
|
199 |
+
if(!get_user_by('ID', $author_id))
|
200 |
+
return;
|
201 |
+
|
202 |
+
// Update Post Author
|
203 |
+
wp_update_post(array(
|
204 |
+
'ID' => $post_id,
|
205 |
+
'post_author' => $author_id
|
206 |
+
));
|
207 |
+
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Bypass Metadata Update
|
212 |
+
*/
|
213 |
+
add_filter('acf/pre_update_value', 'acfe_author_meta_update', 10, 4);
|
214 |
+
function acfe_author_meta_update($return, $value, $post_id, $field){
|
215 |
+
|
216 |
+
if($field['name'] === 'acfe_author')
|
217 |
+
return false;
|
218 |
+
|
219 |
+
return $return;
|
220 |
+
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Field Group Hide on Screen
|
225 |
+
*/
|
226 |
+
add_filter('acf/get_field_group_style', 'acfe_author_meta_hide_on_screen', 10, 2);
|
227 |
+
function acfe_author_meta_hide_on_screen($style, $field_group){
|
228 |
+
|
229 |
+
$style = str_replace('authordiv', 'acf-group_acfe_author', $style);
|
230 |
+
$style = str_replace('display: none;', 'display: none !important;', $style);
|
231 |
+
|
232 |
+
return $style;
|
233 |
+
|
234 |
}
|
includes/modules/autosync.php
CHANGED
@@ -1,291 +1,291 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Auto Sync: Includes
|
8 |
-
*/
|
9 |
-
$acfe_php = acf_get_setting('acfe_php');
|
10 |
-
$acfe_php_load = acf_get_setting('acfe_php_load');
|
11 |
-
|
12 |
-
if(!empty($acfe_php) && !empty($acfe_php_load)){
|
13 |
-
foreach($acfe_php_load as $path){
|
14 |
-
if(!is_readable($path))
|
15 |
-
continue;
|
16 |
-
|
17 |
-
acf_update_setting('acfe_php_found', true);
|
18 |
-
|
19 |
-
$files = glob($path . '/*.php');
|
20 |
-
if(empty($files))
|
21 |
-
continue;
|
22 |
-
|
23 |
-
foreach($files as $file){
|
24 |
-
require_once($file);
|
25 |
-
}
|
26 |
-
|
27 |
-
}
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Auto Sync: Disable json
|
32 |
-
*/
|
33 |
-
add_action('acf/update_field_group', 'acfe_autosync_json_update_field_group', 9);
|
34 |
-
function acfe_autosync_json_update_field_group($field_group){
|
35 |
-
|
36 |
-
// Validate
|
37 |
-
if(!acf_get_setting('json'))
|
38 |
-
return;
|
39 |
-
|
40 |
-
// Disable json sync for this field group
|
41 |
-
if(!acfe_has_field_group_autosync($field_group, 'json'))
|
42 |
-
add_filter('acf/settings/json', 'acfe_autosync_temp_disable_json');
|
43 |
-
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Auto Sync: Re-enable json
|
48 |
-
*/
|
49 |
-
add_action('acf/update_field_group', 'acfe_autosync_json_after_update_field_group', 11);
|
50 |
-
function acfe_autosync_json_after_update_field_group($field_group){
|
51 |
-
|
52 |
-
// Validate
|
53 |
-
if(!acf_get_setting('json'))
|
54 |
-
return;
|
55 |
-
|
56 |
-
remove_filter('acf/settings/json', 'acfe_autosync_temp_disable_json');
|
57 |
-
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Auto Sync: Disable json (function)
|
62 |
-
*/
|
63 |
-
function acfe_autosync_temp_disable_json(){
|
64 |
-
return false;
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Auto Sync: PHP
|
69 |
-
*/
|
70 |
-
add_action('acf/update_field_group', 'acfe_autosync_php_update_field_group');
|
71 |
-
function acfe_autosync_php_update_field_group($field_group){
|
72 |
-
|
73 |
-
// Validate
|
74 |
-
if(!acf_get_setting('acfe_php'))
|
75 |
-
return;
|
76 |
-
|
77 |
-
if(!acfe_has_field_group_autosync($field_group, 'php'))
|
78 |
-
return;
|
79 |
-
|
80 |
-
$field_group['fields'] = acf_get_fields($field_group);
|
81 |
-
acfe_autosync_write_php($field_group);
|
82 |
-
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Auto Sync: Write PHP
|
87 |
-
*/
|
88 |
-
function acfe_autosync_write_php($field_group){
|
89 |
-
|
90 |
-
$path = acf_get_setting('acfe_php_save');
|
91 |
-
if(empty($path))
|
92 |
-
return false;
|
93 |
-
|
94 |
-
// vars
|
95 |
-
$path = untrailingslashit($path);
|
96 |
-
$file = $field_group['key'] . '.php';
|
97 |
-
|
98 |
-
// bail early if dir does not exist
|
99 |
-
if(!is_writable($path))
|
100 |
-
return false;
|
101 |
-
|
102 |
-
// prepare for export
|
103 |
-
$id = acf_extract_var($field_group, 'ID');
|
104 |
-
$field_group = acf_prepare_field_group_for_export($field_group);
|
105 |
-
|
106 |
-
// add modified time
|
107 |
-
$field_group['modified'] = get_post_modified_time('U', true, $id, true);
|
108 |
-
|
109 |
-
|
110 |
-
// Prepare
|
111 |
-
$str_replace = array(
|
112 |
-
" " => "\t",
|
113 |
-
"'!!__(!!\'" => "__('",
|
114 |
-
"!!\', !!\'" => "', '",
|
115 |
-
"!!\')!!'" => "')",
|
116 |
-
"array (" => "array("
|
117 |
-
);
|
118 |
-
|
119 |
-
$preg_replace = array(
|
120 |
-
'/([\t\r\n]+?)array/' => 'array',
|
121 |
-
'/[0-9]+ => array/' => 'array'
|
122 |
-
);
|
123 |
-
|
124 |
-
ob_start();
|
125 |
-
|
126 |
-
echo "<?php " . "\r\n" . "\r\n";
|
127 |
-
echo "if( function_exists('acf_add_local_field_group') ):" . "\r\n" . "\r\n";
|
128 |
-
|
129 |
-
// code
|
130 |
-
$code = var_export($field_group, true);
|
131 |
-
|
132 |
-
|
133 |
-
// change double spaces to tabs
|
134 |
-
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
135 |
-
|
136 |
-
|
137 |
-
// correctly formats "=> array("
|
138 |
-
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
139 |
-
|
140 |
-
|
141 |
-
// esc_textarea
|
142 |
-
$code = $code;
|
143 |
-
|
144 |
-
// echo
|
145 |
-
echo "acf_add_local_field_group({$code});" . "\r\n" . "\r\n";
|
146 |
-
|
147 |
-
echo "endif;";
|
148 |
-
|
149 |
-
$output = ob_get_clean();
|
150 |
-
|
151 |
-
// write file
|
152 |
-
$f = fopen("{$path}/{$file}", 'w');
|
153 |
-
fwrite($f, $output);
|
154 |
-
fclose($f);
|
155 |
-
|
156 |
-
// return
|
157 |
-
return true;
|
158 |
-
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Auto Sync: Helper - is field group json desync
|
163 |
-
*/
|
164 |
-
function acfe_is_field_group_json_desync($field_group){
|
165 |
-
|
166 |
-
acf_enable_filter('local');
|
167 |
-
$group = acf_get_local_field_group($field_group['key']);
|
168 |
-
acf_disable_filter('local');
|
169 |
-
|
170 |
-
$private = acf_maybe_get($group, 'private', false);
|
171 |
-
$local = acf_maybe_get($group, 'local', false);
|
172 |
-
$modified = acf_maybe_get($group, 'modified', 0);
|
173 |
-
|
174 |
-
if($private){
|
175 |
-
return false;
|
176 |
-
}
|
177 |
-
|
178 |
-
elseif($local !== 'json'){
|
179 |
-
return false;
|
180 |
-
}
|
181 |
-
|
182 |
-
elseif($modified && $modified > get_post_modified_time('U', true, $field_group['ID'], true)){
|
183 |
-
return true;
|
184 |
-
}
|
185 |
-
|
186 |
-
return false;
|
187 |
-
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Auto Sync: Helper - Has field group autosync
|
192 |
-
*/
|
193 |
-
function acfe_has_field_group_autosync($field_group, $type = false){
|
194 |
-
$acfe_autosync = acf_maybe_get($field_group, 'acfe_autosync', array());
|
195 |
-
|
196 |
-
if(!$type)
|
197 |
-
return acf_is_array($acfe_autosync);
|
198 |
-
|
199 |
-
if($type
|
200 |
-
return is_array($acfe_autosync) && in_array('json', $acfe_autosync);
|
201 |
-
|
202 |
-
elseif($type
|
203 |
-
return is_array($acfe_autosync) && in_array('php', $acfe_autosync);
|
204 |
-
|
205 |
-
return false;
|
206 |
-
}
|
207 |
-
|
208 |
-
/**
|
209 |
-
* Auto Sync: Helper - Has field group autosync found register/file
|
210 |
-
*/
|
211 |
-
function acfe_has_field_group_autosync_file($field_group, $type = 'json'){
|
212 |
-
|
213 |
-
if($type
|
214 |
-
|
215 |
-
// acf_is_local_field_group = true if json file found
|
216 |
-
$found = false;
|
217 |
-
if(acf_is_local_field_group($field_group['key'])){
|
218 |
-
|
219 |
-
$local_field_group = acf_get_local_field_group($field_group['key']);
|
220 |
-
$get_local = acf_maybe_get($local_field_group, 'local', false);
|
221 |
-
|
222 |
-
if($get_local
|
223 |
-
|
224 |
-
$found = true;
|
225 |
-
|
226 |
-
}else{
|
227 |
-
|
228 |
-
$paths = acf_get_setting('load_json');
|
229 |
-
|
230 |
-
if(!empty($paths)){
|
231 |
-
foreach($paths as $path){
|
232 |
-
|
233 |
-
$path = untrailingslashit($path);
|
234 |
-
$file = $field_group['key'] . '.json';
|
235 |
-
|
236 |
-
if(is_readable("{$path}/{$file}")){
|
237 |
-
$found = true;
|
238 |
-
break;
|
239 |
-
}
|
240 |
-
|
241 |
-
}
|
242 |
-
}
|
243 |
-
|
244 |
-
}
|
245 |
-
|
246 |
-
}
|
247 |
-
|
248 |
-
else{
|
249 |
-
|
250 |
-
$paths = acf_get_setting('load_json');
|
251 |
-
|
252 |
-
if(!empty($paths)){
|
253 |
-
foreach($paths as $path){
|
254 |
-
|
255 |
-
$path = untrailingslashit($path);
|
256 |
-
$file = $field_group['key'] . '.json';
|
257 |
-
|
258 |
-
if(is_readable("{$path}/{$file}")){
|
259 |
-
$found = true;
|
260 |
-
break;
|
261 |
-
}
|
262 |
-
|
263 |
-
}
|
264 |
-
}
|
265 |
-
|
266 |
-
}
|
267 |
-
|
268 |
-
return $found;
|
269 |
-
|
270 |
-
}
|
271 |
-
|
272 |
-
elseif($type
|
273 |
-
|
274 |
-
// acf_is_local_field_group = true if php registered
|
275 |
-
$found = false;
|
276 |
-
if(acf_is_local_field_group($field_group['key'])){
|
277 |
-
|
278 |
-
$local_field_group = acf_get_local_field_group($field_group['key']);
|
279 |
-
$get_local = acf_maybe_get($local_field_group, 'local', false);
|
280 |
-
if($get_local
|
281 |
-
$found = true;
|
282 |
-
|
283 |
-
}
|
284 |
-
|
285 |
-
return $found;
|
286 |
-
|
287 |
-
}
|
288 |
-
|
289 |
-
return false;
|
290 |
-
|
291 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Auto Sync: Includes
|
8 |
+
*/
|
9 |
+
$acfe_php = acf_get_setting('acfe_php');
|
10 |
+
$acfe_php_load = acf_get_setting('acfe_php_load');
|
11 |
+
|
12 |
+
if(!empty($acfe_php) && !empty($acfe_php_load)){
|
13 |
+
foreach($acfe_php_load as $path){
|
14 |
+
if(!is_readable($path))
|
15 |
+
continue;
|
16 |
+
|
17 |
+
acf_update_setting('acfe_php_found', true);
|
18 |
+
|
19 |
+
$files = glob($path . '/*.php');
|
20 |
+
if(empty($files))
|
21 |
+
continue;
|
22 |
+
|
23 |
+
foreach($files as $file){
|
24 |
+
require_once($file);
|
25 |
+
}
|
26 |
+
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Auto Sync: Disable json
|
32 |
+
*/
|
33 |
+
add_action('acf/update_field_group', 'acfe_autosync_json_update_field_group', 9);
|
34 |
+
function acfe_autosync_json_update_field_group($field_group){
|
35 |
+
|
36 |
+
// Validate
|
37 |
+
if(!acf_get_setting('json'))
|
38 |
+
return;
|
39 |
+
|
40 |
+
// Disable json sync for this field group
|
41 |
+
if(!acfe_has_field_group_autosync($field_group, 'json'))
|
42 |
+
add_filter('acf/settings/json', 'acfe_autosync_temp_disable_json');
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Auto Sync: Re-enable json
|
48 |
+
*/
|
49 |
+
add_action('acf/update_field_group', 'acfe_autosync_json_after_update_field_group', 11);
|
50 |
+
function acfe_autosync_json_after_update_field_group($field_group){
|
51 |
+
|
52 |
+
// Validate
|
53 |
+
if(!acf_get_setting('json'))
|
54 |
+
return;
|
55 |
+
|
56 |
+
remove_filter('acf/settings/json', 'acfe_autosync_temp_disable_json');
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Auto Sync: Disable json (function)
|
62 |
+
*/
|
63 |
+
function acfe_autosync_temp_disable_json(){
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Auto Sync: PHP
|
69 |
+
*/
|
70 |
+
add_action('acf/update_field_group', 'acfe_autosync_php_update_field_group');
|
71 |
+
function acfe_autosync_php_update_field_group($field_group){
|
72 |
+
|
73 |
+
// Validate
|
74 |
+
if(!acf_get_setting('acfe_php'))
|
75 |
+
return;
|
76 |
+
|
77 |
+
if(!acfe_has_field_group_autosync($field_group, 'php'))
|
78 |
+
return;
|
79 |
+
|
80 |
+
$field_group['fields'] = acf_get_fields($field_group);
|
81 |
+
acfe_autosync_write_php($field_group);
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Auto Sync: Write PHP
|
87 |
+
*/
|
88 |
+
function acfe_autosync_write_php($field_group){
|
89 |
+
|
90 |
+
$path = acf_get_setting('acfe_php_save');
|
91 |
+
if(empty($path))
|
92 |
+
return false;
|
93 |
+
|
94 |
+
// vars
|
95 |
+
$path = untrailingslashit($path);
|
96 |
+
$file = $field_group['key'] . '.php';
|
97 |
+
|
98 |
+
// bail early if dir does not exist
|
99 |
+
if(!is_writable($path))
|
100 |
+
return false;
|
101 |
+
|
102 |
+
// prepare for export
|
103 |
+
$id = acf_extract_var($field_group, 'ID');
|
104 |
+
$field_group = acf_prepare_field_group_for_export($field_group);
|
105 |
+
|
106 |
+
// add modified time
|
107 |
+
$field_group['modified'] = get_post_modified_time('U', true, $id, true);
|
108 |
+
|
109 |
+
|
110 |
+
// Prepare
|
111 |
+
$str_replace = array(
|
112 |
+
" " => "\t",
|
113 |
+
"'!!__(!!\'" => "__('",
|
114 |
+
"!!\', !!\'" => "', '",
|
115 |
+
"!!\')!!'" => "')",
|
116 |
+
"array (" => "array("
|
117 |
+
);
|
118 |
+
|
119 |
+
$preg_replace = array(
|
120 |
+
'/([\t\r\n]+?)array/' => 'array',
|
121 |
+
'/[0-9]+ => array/' => 'array'
|
122 |
+
);
|
123 |
+
|
124 |
+
ob_start();
|
125 |
+
|
126 |
+
echo "<?php " . "\r\n" . "\r\n";
|
127 |
+
echo "if( function_exists('acf_add_local_field_group') ):" . "\r\n" . "\r\n";
|
128 |
+
|
129 |
+
// code
|
130 |
+
$code = var_export($field_group, true);
|
131 |
+
|
132 |
+
|
133 |
+
// change double spaces to tabs
|
134 |
+
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
135 |
+
|
136 |
+
|
137 |
+
// correctly formats "=> array("
|
138 |
+
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
139 |
+
|
140 |
+
|
141 |
+
// esc_textarea
|
142 |
+
$code = $code;
|
143 |
+
|
144 |
+
// echo
|
145 |
+
echo "acf_add_local_field_group({$code});" . "\r\n" . "\r\n";
|
146 |
+
|
147 |
+
echo "endif;";
|
148 |
+
|
149 |
+
$output = ob_get_clean();
|
150 |
+
|
151 |
+
// write file
|
152 |
+
$f = fopen("{$path}/{$file}", 'w');
|
153 |
+
fwrite($f, $output);
|
154 |
+
fclose($f);
|
155 |
+
|
156 |
+
// return
|
157 |
+
return true;
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Auto Sync: Helper - is field group json desync
|
163 |
+
*/
|
164 |
+
function acfe_is_field_group_json_desync($field_group){
|
165 |
+
|
166 |
+
acf_enable_filter('local');
|
167 |
+
$group = acf_get_local_field_group($field_group['key']);
|
168 |
+
acf_disable_filter('local');
|
169 |
+
|
170 |
+
$private = acf_maybe_get($group, 'private', false);
|
171 |
+
$local = acf_maybe_get($group, 'local', false);
|
172 |
+
$modified = acf_maybe_get($group, 'modified', 0);
|
173 |
+
|
174 |
+
if($private){
|
175 |
+
return false;
|
176 |
+
}
|
177 |
+
|
178 |
+
elseif($local !== 'json'){
|
179 |
+
return false;
|
180 |
+
}
|
181 |
+
|
182 |
+
elseif($modified && $modified > get_post_modified_time('U', true, $field_group['ID'], true)){
|
183 |
+
return true;
|
184 |
+
}
|
185 |
+
|
186 |
+
return false;
|
187 |
+
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Auto Sync: Helper - Has field group autosync
|
192 |
+
*/
|
193 |
+
function acfe_has_field_group_autosync($field_group, $type = false){
|
194 |
+
$acfe_autosync = acf_maybe_get($field_group, 'acfe_autosync', array());
|
195 |
+
|
196 |
+
if(!$type)
|
197 |
+
return acf_is_array($acfe_autosync);
|
198 |
+
|
199 |
+
if($type === 'json')
|
200 |
+
return is_array($acfe_autosync) && in_array('json', $acfe_autosync);
|
201 |
+
|
202 |
+
elseif($type === 'php')
|
203 |
+
return is_array($acfe_autosync) && in_array('php', $acfe_autosync);
|
204 |
+
|
205 |
+
return false;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Auto Sync: Helper - Has field group autosync found register/file
|
210 |
+
*/
|
211 |
+
function acfe_has_field_group_autosync_file($field_group, $type = 'json'){
|
212 |
+
|
213 |
+
if($type === 'json'){
|
214 |
+
|
215 |
+
// acf_is_local_field_group = true if json file found
|
216 |
+
$found = false;
|
217 |
+
if(acf_is_local_field_group($field_group['key'])){
|
218 |
+
|
219 |
+
$local_field_group = acf_get_local_field_group($field_group['key']);
|
220 |
+
$get_local = acf_maybe_get($local_field_group, 'local', false);
|
221 |
+
|
222 |
+
if($get_local === 'json'){
|
223 |
+
|
224 |
+
$found = true;
|
225 |
+
|
226 |
+
}else{
|
227 |
+
|
228 |
+
$paths = acf_get_setting('load_json');
|
229 |
+
|
230 |
+
if(!empty($paths)){
|
231 |
+
foreach($paths as $path){
|
232 |
+
|
233 |
+
$path = untrailingslashit($path);
|
234 |
+
$file = $field_group['key'] . '.json';
|
235 |
+
|
236 |
+
if(is_readable("{$path}/{$file}")){
|
237 |
+
$found = true;
|
238 |
+
break;
|
239 |
+
}
|
240 |
+
|
241 |
+
}
|
242 |
+
}
|
243 |
+
|
244 |
+
}
|
245 |
+
|
246 |
+
}
|
247 |
+
|
248 |
+
else{
|
249 |
+
|
250 |
+
$paths = acf_get_setting('load_json');
|
251 |
+
|
252 |
+
if(!empty($paths)){
|
253 |
+
foreach($paths as $path){
|
254 |
+
|
255 |
+
$path = untrailingslashit($path);
|
256 |
+
$file = $field_group['key'] . '.json';
|
257 |
+
|
258 |
+
if(is_readable("{$path}/{$file}")){
|
259 |
+
$found = true;
|
260 |
+
break;
|
261 |
+
}
|
262 |
+
|
263 |
+
}
|
264 |
+
}
|
265 |
+
|
266 |
+
}
|
267 |
+
|
268 |
+
return $found;
|
269 |
+
|
270 |
+
}
|
271 |
+
|
272 |
+
elseif($type === 'php'){
|
273 |
+
|
274 |
+
// acf_is_local_field_group = true if php registered
|
275 |
+
$found = false;
|
276 |
+
if(acf_is_local_field_group($field_group['key'])){
|
277 |
+
|
278 |
+
$local_field_group = acf_get_local_field_group($field_group['key']);
|
279 |
+
$get_local = acf_maybe_get($local_field_group, 'local', false);
|
280 |
+
if($get_local === 'php')
|
281 |
+
$found = true;
|
282 |
+
|
283 |
+
}
|
284 |
+
|
285 |
+
return $found;
|
286 |
+
|
287 |
+
}
|
288 |
+
|
289 |
+
return false;
|
290 |
+
|
291 |
}
|
includes/modules/dynamic-block-type.php
CHANGED
@@ -1,1172 +1,1176 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
'
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
'
|
33 |
-
'
|
34 |
-
'
|
35 |
-
'
|
36 |
-
'
|
37 |
-
'
|
38 |
-
'
|
39 |
-
'
|
40 |
-
'
|
41 |
-
'
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
'
|
47 |
-
'
|
48 |
-
'
|
49 |
-
'
|
50 |
-
'
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
$
|
80 |
-
if($
|
81 |
-
return $parent_file;
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
$
|
98 |
-
if($
|
99 |
-
return $submenu_file;
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
}
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
$
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
$
|
171 |
-
$
|
172 |
-
$
|
173 |
-
$
|
174 |
-
$
|
175 |
-
$
|
176 |
-
$
|
177 |
-
$
|
178 |
-
$
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
//
|
185 |
-
if(!empty($
|
186 |
-
$
|
187 |
-
|
188 |
-
// Enqueue
|
189 |
-
if(!empty($
|
190 |
-
$
|
191 |
-
|
192 |
-
//
|
193 |
-
$
|
194 |
-
'
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
'
|
199 |
-
'
|
200 |
-
'
|
201 |
-
'
|
202 |
-
'
|
203 |
-
'
|
204 |
-
'
|
205 |
-
'
|
206 |
-
'
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
//
|
214 |
-
$
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
$
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
$
|
295 |
-
|
296 |
-
|
297 |
-
$
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
//
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
if(
|
332 |
-
return;
|
333 |
-
|
334 |
-
|
335 |
-
if($
|
336 |
-
return;
|
337 |
-
|
338 |
-
$query->
|
339 |
-
$
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
if($
|
354 |
-
return $ppp;
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
$columns['
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
}
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
$
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
$
|
480 |
-
|
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 |
-
'
|
511 |
-
'
|
512 |
-
'
|
513 |
-
|
514 |
-
'
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
'
|
521 |
-
'
|
522 |
-
'
|
523 |
-
'
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
'
|
533 |
-
|
534 |
-
|
535 |
-
'
|
536 |
-
'
|
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 |
-
'
|
564 |
-
'
|
565 |
-
'
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
'
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
'
|
581 |
-
'
|
582 |
-
|
583 |
-
|
584 |
-
'
|
585 |
-
'
|
586 |
-
|
587 |
-
|
588 |
-
'
|
589 |
-
'
|
590 |
-
'
|
591 |
-
'
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
'
|
601 |
-
'
|
602 |
-
'
|
603 |
-
'
|
604 |
-
|
605 |
-
|
606 |
-
'
|
607 |
-
'
|
608 |
-
|
609 |
-
|
610 |
-
'
|
611 |
-
'
|
612 |
-
'
|
613 |
-
'
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
'
|
623 |
-
'
|
624 |
-
'
|
625 |
-
'
|
626 |
-
|
627 |
-
|
628 |
-
'
|
629 |
-
'
|
630 |
-
|
631 |
-
|
632 |
-
'
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
'
|
649 |
-
'
|
650 |
-
'
|
651 |
-
'
|
652 |
-
|
653 |
-
|
654 |
-
'
|
655 |
-
'
|
656 |
-
|
657 |
-
|
658 |
-
'
|
659 |
-
'
|
660 |
-
'
|
661 |
-
'
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
'
|
671 |
-
|
672 |
-
|
673 |
-
'
|
674 |
-
'
|
675 |
-
|
676 |
-
|
677 |
-
'
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
'
|
703 |
-
|
704 |
-
|
705 |
-
'
|
706 |
-
'
|
707 |
-
|
708 |
-
|
709 |
-
'
|
710 |
-
'
|
711 |
-
|
712 |
-
|
713 |
-
'
|
714 |
-
'
|
715 |
-
'
|
716 |
-
'
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
'
|
730 |
-
'
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
'
|
737 |
-
|
738 |
-
'
|
739 |
-
'
|
740 |
-
|
741 |
-
|
742 |
-
'
|
743 |
-
'
|
744 |
-
|
745 |
-
|
746 |
-
'
|
747 |
-
'
|
748 |
-
'
|
749 |
-
'
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
'
|
759 |
-
|
760 |
-
|
761 |
-
'
|
762 |
-
'
|
763 |
-
|
764 |
-
|
765 |
-
'
|
766 |
-
|
767 |
-
'
|
768 |
-
'
|
769 |
-
'
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
'
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
'
|
786 |
-
|
787 |
-
'
|
788 |
-
'
|
789 |
-
|
790 |
-
|
791 |
-
'
|
792 |
-
'
|
793 |
-
|
794 |
-
|
795 |
-
'
|
796 |
-
'
|
797 |
-
'
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
'
|
816 |
-
'
|
817 |
-
'
|
818 |
-
'
|
819 |
-
|
820 |
-
|
821 |
-
'
|
822 |
-
'
|
823 |
-
|
824 |
-
|
825 |
-
'
|
826 |
-
'
|
827 |
-
'
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
'
|
848 |
-
'
|
849 |
-
|
850 |
-
|
851 |
-
'
|
852 |
-
'
|
853 |
-
'
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
'
|
874 |
-
'
|
875 |
-
|
876 |
-
|
877 |
-
'
|
878 |
-
'
|
879 |
-
'
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
'
|
898 |
-
'
|
899 |
-
'
|
900 |
-
'
|
901 |
-
|
902 |
-
|
903 |
-
'
|
904 |
-
'
|
905 |
-
|
906 |
-
|
907 |
-
'
|
908 |
-
'
|
909 |
-
'
|
910 |
-
'
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
'
|
920 |
-
|
921 |
-
|
922 |
-
'
|
923 |
-
'
|
924 |
-
|
925 |
-
|
926 |
-
'
|
927 |
-
'
|
928 |
-
'
|
929 |
-
'
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
'
|
939 |
-
'
|
940 |
-
'
|
941 |
-
'
|
942 |
-
|
943 |
-
|
944 |
-
'
|
945 |
-
'
|
946 |
-
|
947 |
-
|
948 |
-
'
|
949 |
-
'
|
950 |
-
'
|
951 |
-
'
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
'
|
961 |
-
'
|
962 |
-
'
|
963 |
-
'
|
964 |
-
|
965 |
-
|
966 |
-
'
|
967 |
-
'
|
968 |
-
|
969 |
-
|
970 |
-
'
|
971 |
-
'
|
972 |
-
'
|
973 |
-
'
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
'
|
983 |
-
|
984 |
-
|
985 |
-
'
|
986 |
-
'
|
987 |
-
|
988 |
-
|
989 |
-
'
|
990 |
-
'
|
991 |
-
'
|
992 |
-
'
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
'
|
1002 |
-
'
|
1003 |
-
'
|
1004 |
-
'
|
1005 |
-
|
1006 |
-
|
1007 |
-
'
|
1008 |
-
'
|
1009 |
-
|
1010 |
-
|
1011 |
-
'
|
1012 |
-
'
|
1013 |
-
'
|
1014 |
-
'
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
'
|
1024 |
-
'
|
1025 |
-
'
|
1026 |
-
'
|
1027 |
-
|
1028 |
-
|
1029 |
-
'
|
1030 |
-
'
|
1031 |
-
|
1032 |
-
|
1033 |
-
'
|
1034 |
-
'
|
1035 |
-
'
|
1036 |
-
'
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
'
|
1046 |
-
'
|
1047 |
-
'
|
1048 |
-
'
|
1049 |
-
|
1050 |
-
|
1051 |
-
'
|
1052 |
-
'
|
1053 |
-
|
1054 |
-
|
1055 |
-
'
|
1056 |
-
'
|
1057 |
-
'
|
1058 |
-
'
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
'
|
1068 |
-
|
1069 |
-
|
1070 |
-
'
|
1071 |
-
'
|
1072 |
-
|
1073 |
-
|
1074 |
-
'
|
1075 |
-
'
|
1076 |
-
'
|
1077 |
-
'
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
'
|
1087 |
-
'
|
1088 |
-
'
|
1089 |
-
'
|
1090 |
-
|
1091 |
-
|
1092 |
-
'
|
1093 |
-
'
|
1094 |
-
|
1095 |
-
|
1096 |
-
'
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
'
|
1121 |
-
'
|
1122 |
-
'
|
1123 |
-
'
|
1124 |
-
|
1125 |
-
|
1126 |
-
'
|
1127 |
-
'
|
1128 |
-
|
1129 |
-
|
1130 |
-
'
|
1131 |
-
'
|
1132 |
-
'
|
1133 |
-
'
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
'
|
1143 |
-
'
|
1144 |
-
'
|
1145 |
-
'
|
1146 |
-
|
1147 |
-
|
1148 |
-
'
|
1149 |
-
'
|
1150 |
-
|
1151 |
-
|
1152 |
-
'
|
1153 |
-
'
|
1154 |
-
'
|
1155 |
-
'
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
'
|
1165 |
-
'
|
1166 |
-
'
|
1167 |
-
'
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
|
|
|
|
|
|
|
|
1172 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_block_types', true))
|
8 |
+
return;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Require ACF Pro 5.8
|
12 |
+
*/
|
13 |
+
if(version_compare(ACF_VERSION, '5.8', '<'))
|
14 |
+
return;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Register Dynamic Block Type
|
18 |
+
*/
|
19 |
+
add_action('init', 'acfe_dbt_register');
|
20 |
+
function acfe_dbt_register(){
|
21 |
+
|
22 |
+
register_post_type('acfe-dbt', array(
|
23 |
+
'label' => 'Block Type',
|
24 |
+
'description' => 'Block Type',
|
25 |
+
'labels' => array(
|
26 |
+
'name' => 'Block Types',
|
27 |
+
'singular_name' => 'Block Type',
|
28 |
+
'menu_name' => 'Block Types',
|
29 |
+
'edit_item' => 'Edit Block Type',
|
30 |
+
'add_new_item' => 'New Block Type',
|
31 |
+
),
|
32 |
+
'supports' => array('custom-fields'),
|
33 |
+
'hierarchical' => false,
|
34 |
+
'public' => false,
|
35 |
+
'show_ui' => true,
|
36 |
+
'show_in_menu' => false,
|
37 |
+
'menu_icon' => 'dashicons-layout',
|
38 |
+
'show_in_admin_bar' => false,
|
39 |
+
'show_in_nav_menus' => false,
|
40 |
+
'can_export' => false,
|
41 |
+
'has_archive' => false,
|
42 |
+
'rewrite' => false,
|
43 |
+
'exclude_from_search' => true,
|
44 |
+
'publicly_queryable' => false,
|
45 |
+
'capabilities' => array(
|
46 |
+
'publish_posts' => acf_get_setting('capability'),
|
47 |
+
'edit_posts' => acf_get_setting('capability'),
|
48 |
+
'edit_others_posts' => acf_get_setting('capability'),
|
49 |
+
'delete_posts' => acf_get_setting('capability'),
|
50 |
+
'delete_others_posts' => acf_get_setting('capability'),
|
51 |
+
'read_private_posts' => acf_get_setting('capability'),
|
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 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Dynamic Block Type Menu
|
62 |
+
*/
|
63 |
+
add_action('admin_menu', 'acfe_dbt_menu');
|
64 |
+
function acfe_dbt_menu(){
|
65 |
+
|
66 |
+
if(!acf_get_setting('show_admin'))
|
67 |
+
return;
|
68 |
+
|
69 |
+
add_submenu_page('edit.php?post_type=acf-field-group', __('Block Types'), __('Block Types'), acf_get_setting('capability'), 'edit.php?post_type=acfe-dbt');
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Dynamic Block Type Menu: Parent Highlight
|
75 |
+
*/
|
76 |
+
add_filter('parent_file', 'acfe_dbt_menu_parent_highlight');
|
77 |
+
function acfe_dbt_menu_parent_highlight($parent_file){
|
78 |
+
|
79 |
+
global $pagenow;
|
80 |
+
if($pagenow != 'post.php' && $pagenow != 'post-new.php')
|
81 |
+
return $parent_file;
|
82 |
+
|
83 |
+
$post_type = get_post_type();
|
84 |
+
if($post_type != 'acfe-dbt')
|
85 |
+
return $parent_file;
|
86 |
+
|
87 |
+
return 'edit.php?post_type=acf-field-group';
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Dynamic Block Type Menu: Submenu Highlight
|
93 |
+
*/
|
94 |
+
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 != 'post-new.php')
|
99 |
+
return $submenu_file;
|
100 |
+
|
101 |
+
$post_type = get_post_type();
|
102 |
+
if($post_type != 'acfe-dbt')
|
103 |
+
return $submenu_file;
|
104 |
+
|
105 |
+
return 'edit.php?post_type=acfe-dbt';
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* ACF Register Block Types
|
111 |
+
*/
|
112 |
+
add_action('init', 'acfe_dbt_registers');
|
113 |
+
function acfe_dbt_registers(){
|
114 |
+
|
115 |
+
$dynamic_block_types = get_option('acfe_dynamic_block_types', array());
|
116 |
+
if(empty($dynamic_block_types))
|
117 |
+
return;
|
118 |
+
|
119 |
+
foreach($dynamic_block_types as $name => $register_args){
|
120 |
+
|
121 |
+
// Register: Execute
|
122 |
+
acf_register_block_type($register_args);
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* ACF Exclude Dynamic Options Page from available post types
|
130 |
+
*/
|
131 |
+
add_filter('acf/get_post_types', 'acfe_dbt_exclude', 10, 2);
|
132 |
+
function acfe_dbt_exclude($post_types, $args){
|
133 |
+
|
134 |
+
if(empty($post_types))
|
135 |
+
return $post_types;
|
136 |
+
|
137 |
+
foreach($post_types as $k => $post_type){
|
138 |
+
|
139 |
+
if($post_type != 'acfe-dbt')
|
140 |
+
continue;
|
141 |
+
|
142 |
+
unset($post_types[$k]);
|
143 |
+
|
144 |
+
}
|
145 |
+
|
146 |
+
return $post_types;
|
147 |
+
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Dynamic Block Types Save
|
152 |
+
*/
|
153 |
+
add_action('acf/save_post', 'acfe_dbt_filter_save', 20);
|
154 |
+
function acfe_dbt_filter_save($post_id){
|
155 |
+
|
156 |
+
if(get_post_type($post_id) != 'acfe-dbt')
|
157 |
+
return;
|
158 |
+
|
159 |
+
$title = get_field('title', $post_id);
|
160 |
+
$name = get_field('name', $post_id);
|
161 |
+
|
162 |
+
// Update post
|
163 |
+
wp_update_post(array(
|
164 |
+
'ID' => $post_id,
|
165 |
+
'post_title' => $title,
|
166 |
+
'post_name' => $name,
|
167 |
+
));
|
168 |
+
|
169 |
+
// Register Args
|
170 |
+
$name = get_field('name', $post_id);
|
171 |
+
$title = get_field('title', $post_id);
|
172 |
+
$description = get_field('description', $post_id);
|
173 |
+
$category = get_field('category', $post_id);
|
174 |
+
$keywords = acf_decode_choices(get_field('keywords', $post_id), true);
|
175 |
+
$post_types = acf_get_array(get_field('post_types', $post_id));
|
176 |
+
$mode = get_field('mode', $post_id);
|
177 |
+
$align = get_field('align', $post_id);
|
178 |
+
$render_template = get_field('render_template', $post_id);
|
179 |
+
$render_callback = get_field('render_callback', $post_id);
|
180 |
+
$enqueue_style = get_field('enqueue_style', $post_id);
|
181 |
+
$enqueue_script = get_field('enqueue_script', $post_id);
|
182 |
+
$enqueue_assets = get_field('enqueue_assets', $post_id);
|
183 |
+
|
184 |
+
// Render Template
|
185 |
+
if(!empty($render_template))
|
186 |
+
$render_template = ACFE_THEME_PATH . '/' . $render_template;
|
187 |
+
|
188 |
+
// Enqueue Style
|
189 |
+
if(!empty($enqueue_style))
|
190 |
+
$enqueue_style = ACFE_THEME_URL . '/' . $enqueue_style;
|
191 |
+
|
192 |
+
// Enqueue Script
|
193 |
+
if(!empty($enqueue_script))
|
194 |
+
$enqueue_script = ACFE_THEME_URL . '/' . $enqueue_script;
|
195 |
+
|
196 |
+
// Register: Args
|
197 |
+
$register_args = array(
|
198 |
+
'name' => $name,
|
199 |
+
'title' => $title,
|
200 |
+
'description' => $description,
|
201 |
+
'category' => $category,
|
202 |
+
'keywords' => $keywords,
|
203 |
+
'post_types' => $post_types,
|
204 |
+
'mode' => $mode,
|
205 |
+
'align' => $align,
|
206 |
+
'render_template' => $render_template,
|
207 |
+
'render_callback' => $render_callback,
|
208 |
+
'enqueue_style' => $enqueue_style,
|
209 |
+
'enqueue_script' => $enqueue_script,
|
210 |
+
'enqueue_assets' => $enqueue_assets
|
211 |
+
);
|
212 |
+
|
213 |
+
// Align
|
214 |
+
if($align == 'none')
|
215 |
+
$register_args['align'] = '';
|
216 |
+
|
217 |
+
// Icon
|
218 |
+
$icon_type = get_field('icon_type', $post_id);
|
219 |
+
|
220 |
+
// Icon: Simple
|
221 |
+
if($icon_type == 'simple'){
|
222 |
+
|
223 |
+
$icon_text = get_field('icon_text', $post_id);
|
224 |
+
|
225 |
+
$register_args['icon'] = $icon_text;
|
226 |
+
|
227 |
+
}
|
228 |
+
|
229 |
+
// Icon: Colors
|
230 |
+
elseif($icon_type == 'colors'){
|
231 |
+
|
232 |
+
$icon_background = get_field('icon_background', $post_id);
|
233 |
+
$icon_foreground = get_field('icon_foreground', $post_id);
|
234 |
+
$icon_src = get_field('icon_src', $post_id);
|
235 |
+
|
236 |
+
$register_args['icon'] = array(
|
237 |
+
'background' => $icon_background,
|
238 |
+
'foreground' => $icon_foreground,
|
239 |
+
'src' => $icon_src,
|
240 |
+
);
|
241 |
+
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
// Supports: Align
|
246 |
+
$supports_align = get_field('supports_align', $post_id);
|
247 |
+
$supports_align_args = acf_decode_choices(get_field('supports_align_args', $post_id), true);
|
248 |
+
|
249 |
+
$register_args['supports']['align'] = false;
|
250 |
+
if(!empty($supports_align)){
|
251 |
+
|
252 |
+
$register_args['supports']['align'] = true;
|
253 |
+
|
254 |
+
if(!empty($supports_align_args))
|
255 |
+
$register_args['supports']['align'] = $supports_align_args;
|
256 |
+
|
257 |
+
}
|
258 |
+
|
259 |
+
// Supports: Mode
|
260 |
+
$supports_mode = get_field('supports_mode', $post_id);
|
261 |
+
|
262 |
+
$register_args['supports']['mode'] = false;
|
263 |
+
if(!empty($supports_mode))
|
264 |
+
$register_args['supports']['mode'] = true;
|
265 |
+
|
266 |
+
// Supports: Multiple
|
267 |
+
$supports_multiple = get_field('supports_multiple', $post_id);
|
268 |
+
|
269 |
+
$register_args['supports']['multiple'] = false;
|
270 |
+
if(!empty($supports_multiple))
|
271 |
+
$register_args['supports']['multiple'] = true;
|
272 |
+
|
273 |
+
|
274 |
+
// Get ACFE option
|
275 |
+
$option = get_option('acfe_dynamic_block_types', array());
|
276 |
+
|
277 |
+
// Create ACFE option
|
278 |
+
$option[$name] = $register_args;
|
279 |
+
|
280 |
+
// Sort keys ASC
|
281 |
+
ksort($option);
|
282 |
+
|
283 |
+
// Update ACFE option
|
284 |
+
update_option('acfe_dynamic_block_types', $option);
|
285 |
+
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Dynamic Block Type Status Publish > Trash
|
290 |
+
*/
|
291 |
+
add_action('publish_to_trash', 'acfe_dbt_filter_status_trash');
|
292 |
+
function acfe_dbt_filter_status_trash($post){
|
293 |
+
|
294 |
+
if(get_post_type($post->ID) != 'acfe-dbt')
|
295 |
+
return;
|
296 |
+
|
297 |
+
$post_id = $post->ID;
|
298 |
+
$name = get_field('name', $post_id);
|
299 |
+
|
300 |
+
// Get ACFE option
|
301 |
+
$option = get_option('acfe_dynamic_block_types', array());
|
302 |
+
|
303 |
+
// Check ACFE option
|
304 |
+
if(isset($option[$name]))
|
305 |
+
unset($option[$name]);
|
306 |
+
|
307 |
+
// Update ACFE option
|
308 |
+
update_option('acfe_dynamic_block_types', $option);
|
309 |
+
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Dynamic Block Type Status Trash > Publish
|
314 |
+
*/
|
315 |
+
add_action('trash_to_publish', 'acfe_dbt_filter_status_publish');
|
316 |
+
function acfe_dbt_filter_status_publish($post){
|
317 |
+
|
318 |
+
if(get_post_type($post->ID) != 'acfe-dbt')
|
319 |
+
return;
|
320 |
+
|
321 |
+
acfe_dop_filter_save($post->ID);
|
322 |
+
|
323 |
+
}
|
324 |
+
|
325 |
+
/**
|
326 |
+
* Dynamic Block Type Admin: List
|
327 |
+
*/
|
328 |
+
add_action('pre_get_posts', 'acfe_dbt_admin_pre_get_posts');
|
329 |
+
function acfe_dbt_admin_pre_get_posts($query){
|
330 |
+
|
331 |
+
if(!is_admin() || !$query->is_main_query())
|
332 |
+
return;
|
333 |
+
|
334 |
+
global $pagenow;
|
335 |
+
if($pagenow != 'edit.php')
|
336 |
+
return;
|
337 |
+
|
338 |
+
$post_type = $query->get('post_type');
|
339 |
+
if($post_type != 'acfe-dbt')
|
340 |
+
return;
|
341 |
+
|
342 |
+
$query->set('orderby', 'name');
|
343 |
+
$query->set('order', 'ASC');
|
344 |
+
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Dynamic Block Type Admin: Posts Per Page
|
349 |
+
*/
|
350 |
+
add_filter('edit_posts_per_page', 'acfe_dbt_admin_ppp', 10, 2);
|
351 |
+
function acfe_dbt_admin_ppp($ppp, $post_type){
|
352 |
+
|
353 |
+
if($post_type != 'acfe-dbt')
|
354 |
+
return $ppp;
|
355 |
+
|
356 |
+
global $pagenow;
|
357 |
+
if($pagenow != 'edit.php')
|
358 |
+
return $ppp;
|
359 |
+
|
360 |
+
return 999;
|
361 |
+
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* Admin List Columns
|
366 |
+
*/
|
367 |
+
add_filter('manage_edit-acfe-dbt_columns', 'acfe_dbt_admin_columns');
|
368 |
+
function acfe_dbt_admin_columns($columns){
|
369 |
+
|
370 |
+
if(isset($columns['date']))
|
371 |
+
unset($columns['date']);
|
372 |
+
|
373 |
+
$columns['name'] = __('Name');
|
374 |
+
$columns['category'] = __('Category');
|
375 |
+
$columns['post_types'] = __('Post Types');
|
376 |
+
$columns['render'] = __('Render');
|
377 |
+
|
378 |
+
return $columns;
|
379 |
+
|
380 |
+
}
|
381 |
+
|
382 |
+
/**
|
383 |
+
* Admin List Columns HTML
|
384 |
+
*/
|
385 |
+
add_action('manage_acfe-dbt_posts_custom_column', 'acfe_dbt_admin_columns_html', 10, 2);
|
386 |
+
function acfe_dbt_admin_columns_html($column, $post_id){
|
387 |
+
|
388 |
+
// Name
|
389 |
+
if($column == 'name'){
|
390 |
+
|
391 |
+
echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . get_field('name', $post_id) . '</code>';
|
392 |
+
|
393 |
+
}
|
394 |
+
|
395 |
+
// Category
|
396 |
+
elseif($column == 'category'){
|
397 |
+
|
398 |
+
echo ucfirst(get_field('category', $post_id));
|
399 |
+
|
400 |
+
}
|
401 |
+
|
402 |
+
// Post Types
|
403 |
+
elseif($column == 'post_types'){
|
404 |
+
|
405 |
+
$post_types = get_field('post_types', $post_id);
|
406 |
+
|
407 |
+
if(empty($post_types)){
|
408 |
+
echo '—';
|
409 |
+
return;
|
410 |
+
}
|
411 |
+
|
412 |
+
$post_types_names = array();
|
413 |
+
foreach($post_types as $post_type_slug){
|
414 |
+
$post_type_obj = get_post_type_object($post_type_slug);
|
415 |
+
$post_types_names[] = $post_type_obj->label;
|
416 |
+
}
|
417 |
+
|
418 |
+
if(empty($post_types_names)){
|
419 |
+
echo '—';
|
420 |
+
return;
|
421 |
+
}
|
422 |
+
|
423 |
+
echo implode(', ', $post_types_names);
|
424 |
+
|
425 |
+
}
|
426 |
+
|
427 |
+
// Render
|
428 |
+
elseif($column == 'render'){
|
429 |
+
|
430 |
+
$render_template = get_field('render_template', $post_id);
|
431 |
+
$render_callback = get_field('render_callback', $post_id);
|
432 |
+
|
433 |
+
if(!empty($render_template)){
|
434 |
+
|
435 |
+
echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">/' . $render_template . '</code>';
|
436 |
+
|
437 |
+
}
|
438 |
+
|
439 |
+
elseif(!empty($render_callback)){
|
440 |
+
|
441 |
+
echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . $render_callback . '</code>';
|
442 |
+
|
443 |
+
}
|
444 |
+
|
445 |
+
else{
|
446 |
+
|
447 |
+
echo '—';
|
448 |
+
|
449 |
+
}
|
450 |
+
|
451 |
+
}
|
452 |
+
|
453 |
+
}
|
454 |
+
|
455 |
+
/**
|
456 |
+
* Admin List Row Actions
|
457 |
+
*/
|
458 |
+
add_filter('post_row_actions','acfe_dbt_admin_row', 10, 2);
|
459 |
+
function acfe_dbt_admin_row($actions, $post){
|
460 |
+
|
461 |
+
if($post->post_type != 'acfe-dbt' || $post->post_status != 'publish')
|
462 |
+
return $actions;
|
463 |
+
|
464 |
+
$post_id = $post->ID;
|
465 |
+
$name = get_field('name', $post_id);
|
466 |
+
|
467 |
+
$actions['acfe_dpt_export_json'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dbt_export&keys=' . $name) . '">' . __('Json') . '</a>';
|
468 |
+
|
469 |
+
return $actions;
|
470 |
+
|
471 |
+
}
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Admin Disable Name
|
475 |
+
*/
|
476 |
+
add_filter('acf/prepare_field/key=field_acfe_dbt_name', 'acfe_dbt_admin_disable_name');
|
477 |
+
function acfe_dbt_admin_disable_name($field){
|
478 |
+
|
479 |
+
global $pagenow;
|
480 |
+
if($pagenow != 'post.php')
|
481 |
+
return $field;
|
482 |
+
|
483 |
+
$field['disabled'] = true;
|
484 |
+
|
485 |
+
return $field;
|
486 |
+
|
487 |
+
}
|
488 |
+
|
489 |
+
/**
|
490 |
+
* Dynamic Block Type: Local Field Group
|
491 |
+
*/
|
492 |
+
add_action('init', 'acfe_dbt_local_field_group');
|
493 |
+
function acfe_dbt_local_field_group(){
|
494 |
+
|
495 |
+
acf_add_local_field_group(array(
|
496 |
+
'key' => 'group_acfe_dynamic_block_type',
|
497 |
+
'title' => __('Dynamic Block Type', 'acfe'),
|
498 |
+
|
499 |
+
'location' => array(
|
500 |
+
array(
|
501 |
+
array(
|
502 |
+
'param' => 'post_type',
|
503 |
+
'operator' => '==',
|
504 |
+
'value' => 'acfe-dbt',
|
505 |
+
),
|
506 |
+
),
|
507 |
+
),
|
508 |
+
|
509 |
+
'menu_order' => 0,
|
510 |
+
'position' => 'normal',
|
511 |
+
'style' => 'default',
|
512 |
+
'label_placement' => 'left',
|
513 |
+
'instruction_placement' => 'label',
|
514 |
+
'hide_on_screen' => '',
|
515 |
+
'active' => 1,
|
516 |
+
'description' => '',
|
517 |
+
|
518 |
+
'fields' => array(
|
519 |
+
array(
|
520 |
+
'key' => 'field_acfe_dbt_tab_general',
|
521 |
+
'label' => 'General',
|
522 |
+
'name' => '',
|
523 |
+
'type' => 'tab',
|
524 |
+
'instructions' => '',
|
525 |
+
'required' => 0,
|
526 |
+
'conditional_logic' => 0,
|
527 |
+
'wrapper' => array(
|
528 |
+
'width' => '',
|
529 |
+
'class' => '',
|
530 |
+
'id' => '',
|
531 |
+
),
|
532 |
+
'acfe_validate' => '',
|
533 |
+
'acfe_update' => '',
|
534 |
+
'acfe_permissions' => '',
|
535 |
+
'placement' => 'top',
|
536 |
+
'endpoint' => 0,
|
537 |
+
),
|
538 |
+
array(
|
539 |
+
'key' => 'field_acfe_dbt_title',
|
540 |
+
'label' => 'Title',
|
541 |
+
'name' => 'title',
|
542 |
+
'type' => 'text',
|
543 |
+
'instructions' => '(String) The display title for your block.',
|
544 |
+
'required' => 1,
|
545 |
+
'conditional_logic' => 0,
|
546 |
+
'wrapper' => array(
|
547 |
+
'width' => '',
|
548 |
+
'class' => '',
|
549 |
+
'id' => '',
|
550 |
+
),
|
551 |
+
'acfe_validate' => '',
|
552 |
+
'acfe_update' => '',
|
553 |
+
'acfe_permissions' => '',
|
554 |
+
'default_value' => '',
|
555 |
+
'placeholder' => '',
|
556 |
+
'prepend' => '',
|
557 |
+
'append' => '',
|
558 |
+
'maxlength' => '',
|
559 |
+
),
|
560 |
+
array(
|
561 |
+
'key' => 'field_acfe_dbt_name',
|
562 |
+
'label' => 'Name',
|
563 |
+
'name' => 'name',
|
564 |
+
'type' => 'acfe_slug',
|
565 |
+
'instructions' => '(String) A unique name that identifies the block (without namespace).<br />
|
566 |
+
Note: A block name can only contain lowercase alphanumeric characters and dashes, and must begin with a letter.',
|
567 |
+
'required' => 1,
|
568 |
+
'conditional_logic' => 0,
|
569 |
+
'wrapper' => array(
|
570 |
+
'width' => '',
|
571 |
+
'class' => '',
|
572 |
+
'id' => '',
|
573 |
+
),
|
574 |
+
'acfe_validate' => '',
|
575 |
+
'acfe_update' => array(
|
576 |
+
'5cd2ca4caa18b' => array(
|
577 |
+
'acfe_update_function' => 'sanitize_title',
|
578 |
+
),
|
579 |
+
),
|
580 |
+
'acfe_permissions' => '',
|
581 |
+
'default_value' => '',
|
582 |
+
'placeholder' => '',
|
583 |
+
'prepend' => '',
|
584 |
+
'append' => '',
|
585 |
+
'maxlength' => '',
|
586 |
+
),
|
587 |
+
array(
|
588 |
+
'key' => 'field_acfe_dbt_description',
|
589 |
+
'label' => 'Description',
|
590 |
+
'name' => 'description',
|
591 |
+
'type' => 'textarea',
|
592 |
+
'instructions' => '(String) (Optional) This is a short description for your block.',
|
593 |
+
'required' => 0,
|
594 |
+
'conditional_logic' => 0,
|
595 |
+
'wrapper' => array(
|
596 |
+
'width' => '',
|
597 |
+
'class' => '',
|
598 |
+
'id' => '',
|
599 |
+
),
|
600 |
+
'acfe_validate' => '',
|
601 |
+
'acfe_update' => '',
|
602 |
+
'acfe_permissions' => '',
|
603 |
+
'default_value' => '',
|
604 |
+
'placeholder' => '',
|
605 |
+
'maxlength' => '',
|
606 |
+
'rows' => 3,
|
607 |
+
'new_lines' => '',
|
608 |
+
),
|
609 |
+
array(
|
610 |
+
'key' => 'field_acfe_dbt_category',
|
611 |
+
'label' => 'Category',
|
612 |
+
'name' => 'category',
|
613 |
+
'type' => 'text',
|
614 |
+
'instructions' => '(String) Blocks are grouped into categories to help users browse and discover them. The core provided categories are [ common | formatting | layout | widgets | embed ]. Plugins and Themes can also register custom block categories.',
|
615 |
+
'required' => 0,
|
616 |
+
'conditional_logic' => 0,
|
617 |
+
'wrapper' => array(
|
618 |
+
'width' => '',
|
619 |
+
'class' => '',
|
620 |
+
'id' => '',
|
621 |
+
),
|
622 |
+
'acfe_validate' => '',
|
623 |
+
'acfe_update' => '',
|
624 |
+
'acfe_permissions' => '',
|
625 |
+
'default_value' => 'common',
|
626 |
+
'placeholder' => '',
|
627 |
+
'prepend' => '',
|
628 |
+
'append' => '',
|
629 |
+
'maxlength' => '',
|
630 |
+
),
|
631 |
+
array(
|
632 |
+
'key' => 'field_acfe_dbt_keywords',
|
633 |
+
'label' => 'Keywords',
|
634 |
+
'name' => 'keywords',
|
635 |
+
'type' => 'textarea',
|
636 |
+
'instructions' => '(Array) (Optional) An array of search terms to help user discover the block while searching.<br />
|
637 |
+
One line for each keyword. ie:<br /><br />
|
638 |
+
quote<br />
|
639 |
+
mention<br />
|
640 |
+
cite',
|
641 |
+
'required' => 0,
|
642 |
+
'conditional_logic' => 0,
|
643 |
+
'wrapper' => array(
|
644 |
+
'width' => '',
|
645 |
+
'class' => '',
|
646 |
+
'id' => '',
|
647 |
+
),
|
648 |
+
'acfe_validate' => '',
|
649 |
+
'acfe_update' => '',
|
650 |
+
'acfe_permissions' => '',
|
651 |
+
'default_value' => '',
|
652 |
+
'placeholder' => '',
|
653 |
+
'maxlength' => '',
|
654 |
+
'rows' => '',
|
655 |
+
'new_lines' => '',
|
656 |
+
),
|
657 |
+
array(
|
658 |
+
'key' => 'field_acfe_dbt_post_types',
|
659 |
+
'label' => 'Post types',
|
660 |
+
'name' => 'post_types',
|
661 |
+
'type' => 'acfe_post_types',
|
662 |
+
'instructions' => '(Array) (Optional) An array of post types to restrict this block type to.',
|
663 |
+
'required' => 0,
|
664 |
+
'conditional_logic' => 0,
|
665 |
+
'wrapper' => array(
|
666 |
+
'width' => '',
|
667 |
+
'class' => '',
|
668 |
+
'id' => '',
|
669 |
+
),
|
670 |
+
'acfe_validate' => '',
|
671 |
+
'acfe_update' => '',
|
672 |
+
'acfe_permissions' => '',
|
673 |
+
'field_type' => 'checkbox',
|
674 |
+
'return_format' => 'name',
|
675 |
+
),
|
676 |
+
array(
|
677 |
+
'key' => 'field_acfe_dbt_mode',
|
678 |
+
'label' => 'Mode',
|
679 |
+
'name' => 'mode',
|
680 |
+
'type' => 'select',
|
681 |
+
'instructions' => '(String) (Optional) The display mode for your block. Available settings are “auto”, “preview” and “edit”. Defaults to “auto”.<br /><br />
|
682 |
+
auto: Preview is shown by default but changes to edit form when block is selected.<br />
|
683 |
+
preview: Preview is always shown. Edit form appears in sidebar when block is selected.<br />
|
684 |
+
edit: Edit form is always shown.<br /><br />
|
685 |
+
|
686 |
+
Note. When in “preview” or “edit” modes, an icon will appear in the block toolbar to toggle between modes.',
|
687 |
+
'required' => 0,
|
688 |
+
'conditional_logic' => 0,
|
689 |
+
'wrapper' => array(
|
690 |
+
'width' => '',
|
691 |
+
'class' => '',
|
692 |
+
'id' => '',
|
693 |
+
),
|
694 |
+
'acfe_validate' => '',
|
695 |
+
'acfe_update' => '',
|
696 |
+
'acfe_permissions' => '',
|
697 |
+
'choices' => array(
|
698 |
+
'auto' => 'Auto',
|
699 |
+
'preview' => 'Preview',
|
700 |
+
'edit' => 'Edit',
|
701 |
+
),
|
702 |
+
'default_value' => array(
|
703 |
+
0 => 'auto',
|
704 |
+
),
|
705 |
+
'allow_null' => 0,
|
706 |
+
'multiple' => 0,
|
707 |
+
'ui' => 0,
|
708 |
+
'return_format' => 'value',
|
709 |
+
'ajax' => 0,
|
710 |
+
'placeholder' => '',
|
711 |
+
),
|
712 |
+
array(
|
713 |
+
'key' => 'field_acfe_dbt_align',
|
714 |
+
'label' => 'Align',
|
715 |
+
'name' => 'align',
|
716 |
+
'type' => 'select',
|
717 |
+
'instructions' => '(String) (Optional) The default block alignment. Available settings are “left”, “center”, “right”, “wide” and “full”. Defaults to an empty string.',
|
718 |
+
'required' => 0,
|
719 |
+
'conditional_logic' => 0,
|
720 |
+
'wrapper' => array(
|
721 |
+
'width' => '',
|
722 |
+
'class' => '',
|
723 |
+
'id' => '',
|
724 |
+
),
|
725 |
+
'acfe_validate' => '',
|
726 |
+
'acfe_update' => '',
|
727 |
+
'acfe_permissions' => '',
|
728 |
+
'choices' => array(
|
729 |
+
'none' => 'None',
|
730 |
+
'left' => 'Left',
|
731 |
+
'center' => 'Center',
|
732 |
+
'right' => 'Right',
|
733 |
+
'wide' => 'Wide',
|
734 |
+
'full' => 'Full',
|
735 |
+
),
|
736 |
+
'default_value' => array(
|
737 |
+
),
|
738 |
+
'allow_null' => 0,
|
739 |
+
'multiple' => 0,
|
740 |
+
'ui' => 0,
|
741 |
+
'return_format' => 'value',
|
742 |
+
'ajax' => 0,
|
743 |
+
'placeholder' => '',
|
744 |
+
),
|
745 |
+
array(
|
746 |
+
'key' => 'field_acfe_dbt_tab_icon',
|
747 |
+
'label' => 'Icon',
|
748 |
+
'name' => '',
|
749 |
+
'type' => 'tab',
|
750 |
+
'instructions' => '',
|
751 |
+
'required' => 0,
|
752 |
+
'conditional_logic' => 0,
|
753 |
+
'wrapper' => array(
|
754 |
+
'width' => '',
|
755 |
+
'class' => '',
|
756 |
+
'id' => '',
|
757 |
+
),
|
758 |
+
'acfe_validate' => '',
|
759 |
+
'acfe_update' => '',
|
760 |
+
'acfe_permissions' => '',
|
761 |
+
'placement' => 'top',
|
762 |
+
'endpoint' => 0,
|
763 |
+
),
|
764 |
+
array(
|
765 |
+
'key' => 'field_acfe_dbt_icon_type',
|
766 |
+
'label' => 'Icon Type',
|
767 |
+
'name' => 'icon_type',
|
768 |
+
'type' => 'select',
|
769 |
+
'instructions' => 'Simple: Specify a Dashicons class or SVG path<br />
|
770 |
+
Colors: Specify colors & Dashicons class',
|
771 |
+
'required' => 0,
|
772 |
+
'conditional_logic' => 0,
|
773 |
+
'wrapper' => array(
|
774 |
+
'width' => '',
|
775 |
+
'class' => '',
|
776 |
+
'id' => '',
|
777 |
+
),
|
778 |
+
'acfe_validate' => '',
|
779 |
+
'acfe_update' => '',
|
780 |
+
'acfe_permissions' => '',
|
781 |
+
'choices' => array(
|
782 |
+
'simple' => 'Simple',
|
783 |
+
'colors' => 'Colors',
|
784 |
+
),
|
785 |
+
'default_value' => array(
|
786 |
+
),
|
787 |
+
'allow_null' => 0,
|
788 |
+
'multiple' => 0,
|
789 |
+
'ui' => 0,
|
790 |
+
'return_format' => 'value',
|
791 |
+
'ajax' => 0,
|
792 |
+
'placeholder' => '',
|
793 |
+
),
|
794 |
+
array(
|
795 |
+
'key' => 'field_acfe_dbt_icon_text',
|
796 |
+
'label' => 'Icon',
|
797 |
+
'name' => 'icon_text',
|
798 |
+
'type' => 'text',
|
799 |
+
'instructions' => '(String) (Optional) An icon property can be specified to make it easier to identify a block. These can be any of WordPress’ Dashicons, or a custom svg element.',
|
800 |
+
'required' => 0,
|
801 |
+
'conditional_logic' => array(
|
802 |
+
array(
|
803 |
+
array(
|
804 |
+
'field' => 'field_acfe_dbt_icon_type',
|
805 |
+
'operator' => '==',
|
806 |
+
'value' => 'simple',
|
807 |
+
),
|
808 |
+
),
|
809 |
+
),
|
810 |
+
'wrapper' => array(
|
811 |
+
'width' => '',
|
812 |
+
'class' => '',
|
813 |
+
'id' => '',
|
814 |
+
),
|
815 |
+
'acfe_validate' => '',
|
816 |
+
'acfe_update' => '',
|
817 |
+
'acfe_permissions' => '',
|
818 |
+
'default_value' => '',
|
819 |
+
'placeholder' => '',
|
820 |
+
'prepend' => '',
|
821 |
+
'append' => '',
|
822 |
+
'maxlength' => '',
|
823 |
+
),
|
824 |
+
array(
|
825 |
+
'key' => 'field_acfe_dbt_icon_background',
|
826 |
+
'label' => 'Icon background',
|
827 |
+
'name' => 'icon_background',
|
828 |
+
'type' => 'color_picker',
|
829 |
+
'instructions' => 'Specifying a background color to appear with the icon e.g.: in the inserter.',
|
830 |
+
'required' => 0,
|
831 |
+
'conditional_logic' => array(
|
832 |
+
array(
|
833 |
+
array(
|
834 |
+
'field' => 'field_acfe_dbt_icon_type',
|
835 |
+
'operator' => '==',
|
836 |
+
'value' => 'colors',
|
837 |
+
),
|
838 |
+
),
|
839 |
+
),
|
840 |
+
'wrapper' => array(
|
841 |
+
'width' => '',
|
842 |
+
'class' => '',
|
843 |
+
'id' => '',
|
844 |
+
),
|
845 |
+
'acfe_validate' => '',
|
846 |
+
'acfe_update' => '',
|
847 |
+
'acfe_permissions' => '',
|
848 |
+
'default_value' => '',
|
849 |
+
),
|
850 |
+
array(
|
851 |
+
'key' => 'field_acfe_dbt_icon_foreground',
|
852 |
+
'label' => 'Icon foreground',
|
853 |
+
'name' => 'icon_foreground',
|
854 |
+
'type' => 'color_picker',
|
855 |
+
'instructions' => 'Specifying a color for the icon (optional: if not set, a readable color will be automatically defined)',
|
856 |
+
'required' => 0,
|
857 |
+
'conditional_logic' => array(
|
858 |
+
array(
|
859 |
+
array(
|
860 |
+
'field' => 'field_acfe_dbt_icon_type',
|
861 |
+
'operator' => '==',
|
862 |
+
'value' => 'colors',
|
863 |
+
),
|
864 |
+
),
|
865 |
+
),
|
866 |
+
'wrapper' => array(
|
867 |
+
'width' => '',
|
868 |
+
'class' => '',
|
869 |
+
'id' => '',
|
870 |
+
),
|
871 |
+
'acfe_validate' => '',
|
872 |
+
'acfe_update' => '',
|
873 |
+
'acfe_permissions' => '',
|
874 |
+
'default_value' => '',
|
875 |
+
),
|
876 |
+
array(
|
877 |
+
'key' => 'field_acfe_dbt_icon_src',
|
878 |
+
'label' => 'Icon src',
|
879 |
+
'name' => 'icon_src',
|
880 |
+
'type' => 'text',
|
881 |
+
'instructions' => 'Specifying a dashicon for the block',
|
882 |
+
'required' => 0,
|
883 |
+
'conditional_logic' => array(
|
884 |
+
array(
|
885 |
+
array(
|
886 |
+
'field' => 'field_acfe_dbt_icon_type',
|
887 |
+
'operator' => '==',
|
888 |
+
'value' => 'colors',
|
889 |
+
),
|
890 |
+
),
|
891 |
+
),
|
892 |
+
'wrapper' => array(
|
893 |
+
'width' => '',
|
894 |
+
'class' => '',
|
895 |
+
'id' => '',
|
896 |
+
),
|
897 |
+
'acfe_validate' => '',
|
898 |
+
'acfe_update' => '',
|
899 |
+
'acfe_permissions' => '',
|
900 |
+
'default_value' => '',
|
901 |
+
'placeholder' => '',
|
902 |
+
'prepend' => '',
|
903 |
+
'append' => '',
|
904 |
+
'maxlength' => '',
|
905 |
+
),
|
906 |
+
array(
|
907 |
+
'key' => 'field_acfe_dbt_tab_render',
|
908 |
+
'label' => 'Render',
|
909 |
+
'name' => '',
|
910 |
+
'type' => 'tab',
|
911 |
+
'instructions' => '',
|
912 |
+
'required' => 0,
|
913 |
+
'conditional_logic' => 0,
|
914 |
+
'wrapper' => array(
|
915 |
+
'width' => '',
|
916 |
+
'class' => '',
|
917 |
+
'id' => '',
|
918 |
+
),
|
919 |
+
'acfe_validate' => '',
|
920 |
+
'acfe_update' => '',
|
921 |
+
'acfe_permissions' => '',
|
922 |
+
'placement' => 'top',
|
923 |
+
'endpoint' => 0,
|
924 |
+
),
|
925 |
+
array(
|
926 |
+
'key' => 'field_acfe_dbt_render_template',
|
927 |
+
'label' => 'Render template',
|
928 |
+
'name' => 'render_template',
|
929 |
+
'type' => 'text',
|
930 |
+
'instructions' => '(String) The path to a template file used to render the block HTML. This can either be a relative path to a file within the active theme or a full path to any file.',
|
931 |
+
'required' => 0,
|
932 |
+
'conditional_logic' => 0,
|
933 |
+
'wrapper' => array(
|
934 |
+
'width' => '',
|
935 |
+
'class' => '',
|
936 |
+
'id' => '',
|
937 |
+
),
|
938 |
+
'acfe_validate' => '',
|
939 |
+
'acfe_update' => '',
|
940 |
+
'acfe_permissions' => '',
|
941 |
+
'default_value' => '',
|
942 |
+
'placeholder' => '',
|
943 |
+
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
944 |
+
'append' => '',
|
945 |
+
'maxlength' => '',
|
946 |
+
),
|
947 |
+
array(
|
948 |
+
'key' => 'field_acfe_dbt_render_callback',
|
949 |
+
'label' => 'Render callback',
|
950 |
+
'name' => 'render_callback',
|
951 |
+
'type' => 'text',
|
952 |
+
'instructions' => '(Callable) (Optional) Instead of providing a render_template, a callback function name may be specified to output the block’s HTML.',
|
953 |
+
'required' => 0,
|
954 |
+
'conditional_logic' => 0,
|
955 |
+
'wrapper' => array(
|
956 |
+
'width' => '',
|
957 |
+
'class' => '',
|
958 |
+
'id' => '',
|
959 |
+
),
|
960 |
+
'acfe_validate' => '',
|
961 |
+
'acfe_update' => '',
|
962 |
+
'acfe_permissions' => '',
|
963 |
+
'default_value' => '',
|
964 |
+
'placeholder' => '',
|
965 |
+
'prepend' => '',
|
966 |
+
'append' => '',
|
967 |
+
'maxlength' => '',
|
968 |
+
),
|
969 |
+
array(
|
970 |
+
'key' => 'field_acfe_dbt_tab_enqueue',
|
971 |
+
'label' => 'Enqueue',
|
972 |
+
'name' => '',
|
973 |
+
'type' => 'tab',
|
974 |
+
'instructions' => '',
|
975 |
+
'required' => 0,
|
976 |
+
'conditional_logic' => 0,
|
977 |
+
'wrapper' => array(
|
978 |
+
'width' => '',
|
979 |
+
'class' => '',
|
980 |
+
'id' => '',
|
981 |
+
),
|
982 |
+
'acfe_validate' => '',
|
983 |
+
'acfe_update' => '',
|
984 |
+
'acfe_permissions' => '',
|
985 |
+
'placement' => 'top',
|
986 |
+
'endpoint' => 0,
|
987 |
+
),
|
988 |
+
array(
|
989 |
+
'key' => 'field_acfe_dbt_enqueue_style',
|
990 |
+
'label' => 'Enqueue style',
|
991 |
+
'name' => 'enqueue_style',
|
992 |
+
'type' => 'text',
|
993 |
+
'instructions' => '(String) (Optional) The url to a .css file to be enqueued whenever your block is displayed (front-end and back-end).',
|
994 |
+
'required' => 0,
|
995 |
+
'conditional_logic' => 0,
|
996 |
+
'wrapper' => array(
|
997 |
+
'width' => '',
|
998 |
+
'class' => '',
|
999 |
+
'id' => '',
|
1000 |
+
),
|
1001 |
+
'acfe_validate' => '',
|
1002 |
+
'acfe_update' => '',
|
1003 |
+
'acfe_permissions' => '',
|
1004 |
+
'default_value' => '',
|
1005 |
+
'placeholder' => '',
|
1006 |
+
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
1007 |
+
'append' => '',
|
1008 |
+
'maxlength' => '',
|
1009 |
+
),
|
1010 |
+
array(
|
1011 |
+
'key' => 'field_acfe_dbt_enqueue_script',
|
1012 |
+
'label' => 'Enqueue script',
|
1013 |
+
'name' => 'enqueue_script',
|
1014 |
+
'type' => 'text',
|
1015 |
+
'instructions' => '(String) (Optional) The url to a .js file to be enqueued whenever your block is displayed (front-end and back-end).',
|
1016 |
+
'required' => 0,
|
1017 |
+
'conditional_logic' => 0,
|
1018 |
+
'wrapper' => array(
|
1019 |
+
'width' => '',
|
1020 |
+
'class' => '',
|
1021 |
+
'id' => '',
|
1022 |
+
),
|
1023 |
+
'acfe_validate' => '',
|
1024 |
+
'acfe_update' => '',
|
1025 |
+
'acfe_permissions' => '',
|
1026 |
+
'default_value' => '',
|
1027 |
+
'placeholder' => '',
|
1028 |
+
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
1029 |
+
'append' => '',
|
1030 |
+
'maxlength' => '',
|
1031 |
+
),
|
1032 |
+
array(
|
1033 |
+
'key' => 'field_acfe_dbt_enqueue_assets',
|
1034 |
+
'label' => 'Enqueue assets',
|
1035 |
+
'name' => 'enqueue_assets',
|
1036 |
+
'type' => 'text',
|
1037 |
+
'instructions' => '(Callable) (Optional) A callback function that runs whenever your block is displayed (front-end and back-end) and enqueues scripts and/or styles.',
|
1038 |
+
'required' => 0,
|
1039 |
+
'conditional_logic' => 0,
|
1040 |
+
'wrapper' => array(
|
1041 |
+
'width' => '',
|
1042 |
+
'class' => '',
|
1043 |
+
'id' => '',
|
1044 |
+
),
|
1045 |
+
'acfe_validate' => '',
|
1046 |
+
'acfe_update' => '',
|
1047 |
+
'acfe_permissions' => '',
|
1048 |
+
'default_value' => '',
|
1049 |
+
'placeholder' => '',
|
1050 |
+
'prepend' => '',
|
1051 |
+
'append' => '',
|
1052 |
+
'maxlength' => '',
|
1053 |
+
),
|
1054 |
+
array(
|
1055 |
+
'key' => 'field_acfe_dbt_tab_supports',
|
1056 |
+
'label' => 'Supports',
|
1057 |
+
'name' => '',
|
1058 |
+
'type' => 'tab',
|
1059 |
+
'instructions' => '',
|
1060 |
+
'required' => 0,
|
1061 |
+
'conditional_logic' => 0,
|
1062 |
+
'wrapper' => array(
|
1063 |
+
'width' => '',
|
1064 |
+
'class' => '',
|
1065 |
+
'id' => '',
|
1066 |
+
),
|
1067 |
+
'acfe_validate' => '',
|
1068 |
+
'acfe_update' => '',
|
1069 |
+
'acfe_permissions' => '',
|
1070 |
+
'placement' => 'top',
|
1071 |
+
'endpoint' => 0,
|
1072 |
+
),
|
1073 |
+
array(
|
1074 |
+
'key' => 'field_acfe_dbt_supports_align',
|
1075 |
+
'label' => 'Align',
|
1076 |
+
'name' => 'supports_align',
|
1077 |
+
'type' => 'true_false',
|
1078 |
+
'instructions' => 'This property adds block controls which allow the user to change the block’s alignment. Defaults to true. Set to false to hide the alignment toolbar. Set to an array of specific alignment names to customize the toolbar.',
|
1079 |
+
'required' => 0,
|
1080 |
+
'conditional_logic' => 0,
|
1081 |
+
'wrapper' => array(
|
1082 |
+
'width' => '',
|
1083 |
+
'class' => '',
|
1084 |
+
'id' => '',
|
1085 |
+
),
|
1086 |
+
'acfe_validate' => '',
|
1087 |
+
'acfe_update' => '',
|
1088 |
+
'acfe_permissions' => '',
|
1089 |
+
'message' => '',
|
1090 |
+
'default_value' => 1,
|
1091 |
+
'ui' => 1,
|
1092 |
+
'ui_on_text' => 'True',
|
1093 |
+
'ui_off_text' => 'False',
|
1094 |
+
),
|
1095 |
+
array(
|
1096 |
+
'key' => 'field_acfe_dbt_supports_align_args',
|
1097 |
+
'label' => 'Align arguments',
|
1098 |
+
'name' => 'supports_align_args',
|
1099 |
+
'type' => 'textarea',
|
1100 |
+
'instructions' => 'Set to an array of specific alignment names to customize the toolbar.<br />
|
1101 |
+
One line for each name. ie:<br /><br />
|
1102 |
+
left<br />
|
1103 |
+
right<br />
|
1104 |
+
full',
|
1105 |
+
'required' => 0,
|
1106 |
+
'conditional_logic' => array(
|
1107 |
+
array(
|
1108 |
+
array(
|
1109 |
+
'field' => 'field_acfe_dbt_supports_align',
|
1110 |
+
'operator' => '==',
|
1111 |
+
'value' => '1',
|
1112 |
+
),
|
1113 |
+
),
|
1114 |
+
),
|
1115 |
+
'wrapper' => array(
|
1116 |
+
'width' => '',
|
1117 |
+
'class' => '',
|
1118 |
+
'id' => '',
|
1119 |
+
),
|
1120 |
+
'acfe_validate' => '',
|
1121 |
+
'acfe_update' => '',
|
1122 |
+
'acfe_permissions' => '',
|
1123 |
+
'default_value' => '',
|
1124 |
+
'placeholder' => '',
|
1125 |
+
'maxlength' => '',
|
1126 |
+
'rows' => '',
|
1127 |
+
'new_lines' => '',
|
1128 |
+
),
|
1129 |
+
array(
|
1130 |
+
'key' => 'field_acfe_dbt_supports_mode',
|
1131 |
+
'label' => 'Mode',
|
1132 |
+
'name' => 'supports_mode',
|
1133 |
+
'type' => 'true_false',
|
1134 |
+
'instructions' => 'This property allows the user to toggle between edit and preview modes via a button. Defaults to true.',
|
1135 |
+
'required' => 0,
|
1136 |
+
'conditional_logic' => 0,
|
1137 |
+
'wrapper' => array(
|
1138 |
+
'width' => '',
|
1139 |
+
'class' => '',
|
1140 |
+
'id' => '',
|
1141 |
+
),
|
1142 |
+
'acfe_validate' => '',
|
1143 |
+
'acfe_update' => '',
|
1144 |
+
'acfe_permissions' => '',
|
1145 |
+
'message' => '',
|
1146 |
+
'default_value' => 1,
|
1147 |
+
'ui' => 1,
|
1148 |
+
'ui_on_text' => 'True',
|
1149 |
+
'ui_off_text' => 'False',
|
1150 |
+
),
|
1151 |
+
array(
|
1152 |
+
'key' => 'field_acfe_dbt_supports_multiple',
|
1153 |
+
'label' => 'Multiple',
|
1154 |
+
'name' => 'supports_multiple',
|
1155 |
+
'type' => 'true_false',
|
1156 |
+
'instructions' => 'This property allows the block to be added multiple times. Defaults to true.',
|
1157 |
+
'required' => 0,
|
1158 |
+
'conditional_logic' => 0,
|
1159 |
+
'wrapper' => array(
|
1160 |
+
'width' => '',
|
1161 |
+
'class' => '',
|
1162 |
+
'id' => '',
|
1163 |
+
),
|
1164 |
+
'acfe_validate' => '',
|
1165 |
+
'acfe_update' => '',
|
1166 |
+
'acfe_permissions' => '',
|
1167 |
+
'message' => '',
|
1168 |
+
'default_value' => 1,
|
1169 |
+
'ui' => 1,
|
1170 |
+
'ui_on_text' => 'True',
|
1171 |
+
'ui_off_text' => 'False',
|
1172 |
+
),
|
1173 |
+
),
|
1174 |
+
));
|
1175 |
+
|
1176 |
}
|
includes/modules/dynamic-options-page.php
CHANGED
@@ -1,806 +1,810 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
'
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
'
|
27 |
-
'
|
28 |
-
'
|
29 |
-
'
|
30 |
-
'
|
31 |
-
'
|
32 |
-
'
|
33 |
-
'
|
34 |
-
'
|
35 |
-
'
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
'
|
41 |
-
'
|
42 |
-
'
|
43 |
-
'
|
44 |
-
'
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
$
|
74 |
-
if($
|
75 |
-
return $parent_file;
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
$
|
92 |
-
if($
|
93 |
-
return $submenu_file;
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
$
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
}
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
}
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
$
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
if(
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
$
|
214 |
-
$
|
215 |
-
$
|
216 |
-
$
|
217 |
-
$
|
218 |
-
$
|
219 |
-
$
|
220 |
-
|
221 |
-
|
222 |
-
$
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
'
|
228 |
-
'
|
229 |
-
'
|
230 |
-
'
|
231 |
-
'
|
232 |
-
'
|
233 |
-
'
|
234 |
-
'
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
// Menu
|
242 |
-
if(empty($
|
243 |
-
$register_args['
|
244 |
-
|
245 |
-
//
|
246 |
-
$
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
if(empty($
|
252 |
-
$register_args['
|
253 |
-
|
254 |
-
//
|
255 |
-
$
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
$
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
$
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
//
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
if(
|
322 |
-
return;
|
323 |
-
|
324 |
-
|
325 |
-
if($
|
326 |
-
return;
|
327 |
-
|
328 |
-
$query->
|
329 |
-
$
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
if($
|
344 |
-
return $ppp;
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
$columns['
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
$
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
$
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
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 |
-
'
|
511 |
-
'
|
512 |
-
'
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
'
|
522 |
-
'
|
523 |
-
'
|
524 |
-
'
|
525 |
-
|
526 |
-
|
527 |
-
'
|
528 |
-
'
|
529 |
-
|
530 |
-
|
531 |
-
'
|
532 |
-
'
|
533 |
-
'
|
534 |
-
'
|
535 |
-
|
536 |
-
|
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 |
-
|
564 |
-
|
565 |
-
'
|
566 |
-
'
|
567 |
-
'
|
568 |
-
'
|
569 |
-
|
570 |
-
|
571 |
-
'
|
572 |
-
'
|
573 |
-
|
574 |
-
|
575 |
-
'
|
576 |
-
'
|
577 |
-
'
|
578 |
-
'
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
'
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
'
|
594 |
-
'
|
595 |
-
|
596 |
-
|
597 |
-
'
|
598 |
-
'
|
599 |
-
|
600 |
-
|
601 |
-
'
|
602 |
-
|
603 |
-
|
604 |
-
'
|
605 |
-
'
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
'
|
616 |
-
'
|
617 |
-
'
|
618 |
-
'
|
619 |
-
|
620 |
-
|
621 |
-
'
|
622 |
-
'
|
623 |
-
|
624 |
-
|
625 |
-
'
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
'
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
'
|
641 |
-
'
|
642 |
-
'
|
643 |
-
'
|
644 |
-
|
645 |
-
|
646 |
-
'
|
647 |
-
'
|
648 |
-
|
649 |
-
|
650 |
-
'
|
651 |
-
'
|
652 |
-
'
|
653 |
-
'
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
'
|
663 |
-
'
|
664 |
-
'
|
665 |
-
'
|
666 |
-
|
667 |
-
|
668 |
-
'
|
669 |
-
'
|
670 |
-
|
671 |
-
|
672 |
-
'
|
673 |
-
|
674 |
-
'
|
675 |
-
'
|
676 |
-
'
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
'
|
686 |
-
'
|
687 |
-
'
|
688 |
-
'
|
689 |
-
|
690 |
-
|
691 |
-
'
|
692 |
-
'
|
693 |
-
|
694 |
-
|
695 |
-
'
|
696 |
-
|
697 |
-
'
|
698 |
-
'
|
699 |
-
'
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
'
|
709 |
-
'
|
710 |
-
'
|
711 |
-
'
|
712 |
-
|
713 |
-
|
714 |
-
'
|
715 |
-
'
|
716 |
-
|
717 |
-
|
718 |
-
'
|
719 |
-
|
720 |
-
'
|
721 |
-
'
|
722 |
-
'
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
'
|
732 |
-
'
|
733 |
-
'
|
734 |
-
'
|
735 |
-
|
736 |
-
|
737 |
-
'
|
738 |
-
'
|
739 |
-
|
740 |
-
|
741 |
-
'
|
742 |
-
|
743 |
-
'
|
744 |
-
'
|
745 |
-
'
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
'
|
755 |
-
'
|
756 |
-
'
|
757 |
-
'
|
758 |
-
|
759 |
-
|
760 |
-
'
|
761 |
-
'
|
762 |
-
|
763 |
-
|
764 |
-
'
|
765 |
-
'
|
766 |
-
'
|
767 |
-
'
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
'
|
777 |
-
'
|
778 |
-
'
|
779 |
-
'
|
780 |
-
|
781 |
-
|
782 |
-
'
|
783 |
-
'
|
784 |
-
|
785 |
-
|
786 |
-
'
|
787 |
-
'
|
788 |
-
'
|
789 |
-
'
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
'
|
799 |
-
'
|
800 |
-
'
|
801 |
-
'
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
|
|
|
|
|
|
|
|
806 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_options_pages', true))
|
8 |
+
return;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Register Dynamic Options Page
|
12 |
+
*/
|
13 |
+
add_action('init', 'acfe_dop_register');
|
14 |
+
function acfe_dop_register(){
|
15 |
+
|
16 |
+
register_post_type('acfe-dop', array(
|
17 |
+
'label' => 'Options Page',
|
18 |
+
'description' => 'Options Page',
|
19 |
+
'labels' => array(
|
20 |
+
'name' => 'Options Pages',
|
21 |
+
'singular_name' => 'Options Page',
|
22 |
+
'menu_name' => 'Options Pages',
|
23 |
+
'edit_item' => 'Edit Options Page',
|
24 |
+
'add_new_item' => 'New Options Page',
|
25 |
+
),
|
26 |
+
'supports' => array('custom-fields'),
|
27 |
+
'hierarchical' => true,
|
28 |
+
'public' => false,
|
29 |
+
'show_ui' => true,
|
30 |
+
'show_in_menu' => false,
|
31 |
+
'menu_icon' => 'dashicons-layout',
|
32 |
+
'show_in_admin_bar' => false,
|
33 |
+
'show_in_nav_menus' => false,
|
34 |
+
'can_export' => false,
|
35 |
+
'has_archive' => false,
|
36 |
+
'rewrite' => false,
|
37 |
+
'exclude_from_search' => true,
|
38 |
+
'publicly_queryable' => false,
|
39 |
+
'capabilities' => array(
|
40 |
+
'publish_posts' => acf_get_setting('capability'),
|
41 |
+
'edit_posts' => acf_get_setting('capability'),
|
42 |
+
'edit_others_posts' => acf_get_setting('capability'),
|
43 |
+
'delete_posts' => acf_get_setting('capability'),
|
44 |
+
'delete_others_posts' => acf_get_setting('capability'),
|
45 |
+
'read_private_posts' => acf_get_setting('capability'),
|
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 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Dynamic Options Page Menu
|
56 |
+
*/
|
57 |
+
add_action('admin_menu', 'acfe_dop_menu');
|
58 |
+
function acfe_dop_menu(){
|
59 |
+
|
60 |
+
if(!acf_get_setting('show_admin'))
|
61 |
+
return;
|
62 |
+
|
63 |
+
add_submenu_page('edit.php?post_type=acf-field-group', __('Options'), __('Options'), acf_get_setting('capability'), 'edit.php?post_type=acfe-dop');
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Dynamic Options Page Menu: Parent Highlight
|
69 |
+
*/
|
70 |
+
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 != 'post.php' && $pagenow != 'post-new.php')
|
75 |
+
return $parent_file;
|
76 |
+
|
77 |
+
$post_type = get_post_type();
|
78 |
+
if($post_type != 'acfe-dop')
|
79 |
+
return $parent_file;
|
80 |
+
|
81 |
+
return 'edit.php?post_type=acf-field-group';
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Dynamic Options Page Menu: Submenu Highlight
|
87 |
+
*/
|
88 |
+
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 != 'post-new.php')
|
93 |
+
return $submenu_file;
|
94 |
+
|
95 |
+
$post_type = get_post_type();
|
96 |
+
if($post_type != 'acfe-dop')
|
97 |
+
return $submenu_file;
|
98 |
+
|
99 |
+
return 'edit.php?post_type=acfe-dop';
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
/**
|
105 |
+
* ACF Register Options Pages
|
106 |
+
*/
|
107 |
+
add_action('init', 'acfe_dop_registers');
|
108 |
+
function acfe_dop_registers(){
|
109 |
+
|
110 |
+
$dynamic_options_pages = get_option('acfe_dynamic_options_pages', array());
|
111 |
+
if(empty($dynamic_options_pages))
|
112 |
+
return;
|
113 |
+
|
114 |
+
$options_sub_pages = array();
|
115 |
+
|
116 |
+
foreach($dynamic_options_pages as $name => $register_args){
|
117 |
+
|
118 |
+
// Do not register sub pages
|
119 |
+
if(isset($register_args['parent_slug']) && !empty($register_args['parent_slug'])){
|
120 |
+
|
121 |
+
$options_sub_pages[$name] = $register_args;
|
122 |
+
continue;
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
// Register: Execute
|
127 |
+
acf_add_options_page($register_args);
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
// Register sub pages
|
132 |
+
if(!empty($options_sub_pages)){
|
133 |
+
|
134 |
+
foreach($options_sub_pages as $name => $register_args){
|
135 |
+
|
136 |
+
// Register: Execute
|
137 |
+
acf_add_options_page($register_args);
|
138 |
+
|
139 |
+
}
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* ACF Exclude Dynamic Options Page from available post types
|
147 |
+
*/
|
148 |
+
add_filter('acf/get_post_types', 'acfe_dop_exclude', 10, 2);
|
149 |
+
function acfe_dop_exclude($post_types, $args){
|
150 |
+
|
151 |
+
if(empty($post_types))
|
152 |
+
return $post_types;
|
153 |
+
|
154 |
+
foreach($post_types as $k => $post_type){
|
155 |
+
|
156 |
+
if($post_type != 'acfe-dop')
|
157 |
+
continue;
|
158 |
+
|
159 |
+
unset($post_types[$k]);
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
return $post_types;
|
164 |
+
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Dynamic Options Page Save
|
169 |
+
*/
|
170 |
+
add_action('acf/save_post', 'acfe_dop_filter_save', 20);
|
171 |
+
function acfe_dop_filter_save($post_id){
|
172 |
+
|
173 |
+
if(get_post_type($post_id) != 'acfe-dop')
|
174 |
+
return;
|
175 |
+
|
176 |
+
$title = get_field('page_title', $post_id);
|
177 |
+
$name = get_field('acfe_dop_name', $post_id);
|
178 |
+
$parent_slug = get_field('parent_slug', $post_id);
|
179 |
+
|
180 |
+
// Force name
|
181 |
+
if(empty($name))
|
182 |
+
$name = sanitize_title($title);
|
183 |
+
|
184 |
+
$parent = 0;
|
185 |
+
if(!empty($parent_slug)){
|
186 |
+
|
187 |
+
$get_dop_parent = get_posts(array(
|
188 |
+
'post_type' => 'acfe-dop',
|
189 |
+
'posts_per_page' => 1,
|
190 |
+
'fields' => 'ids',
|
191 |
+
'meta_query' => array(
|
192 |
+
array(
|
193 |
+
'key' => 'menu_slug',
|
194 |
+
'value' => $parent_slug
|
195 |
+
)
|
196 |
+
)
|
197 |
+
));
|
198 |
+
|
199 |
+
if(!empty($get_dop_parent))
|
200 |
+
$parent = $get_dop_parent[0];
|
201 |
+
|
202 |
+
}
|
203 |
+
|
204 |
+
// Update post
|
205 |
+
wp_update_post(array(
|
206 |
+
'ID' => $post_id,
|
207 |
+
'post_title' => $title,
|
208 |
+
'post_name' => $name,
|
209 |
+
'post_parent' => $parent,
|
210 |
+
));
|
211 |
+
|
212 |
+
// Register Args
|
213 |
+
$page_title = get_field('page_title', $post_id);
|
214 |
+
$menu_title = get_field('menu_title', $post_id);
|
215 |
+
$menu_slug = get_field('menu_slug', $post_id);
|
216 |
+
$capability = get_field('capability', $post_id);
|
217 |
+
$position = get_field('position', $post_id);
|
218 |
+
$icon_url = get_field('icon_url', $post_id);
|
219 |
+
$redirect = get_field('redirect', $post_id);
|
220 |
+
$p_id = get_field('post_id', $post_id);
|
221 |
+
$autoload = get_field('autoload', $post_id);
|
222 |
+
$update_button = get_field('update_button', $post_id);
|
223 |
+
$updated_message = get_field('updated_message', $post_id);
|
224 |
+
|
225 |
+
// Register: Args
|
226 |
+
$register_args = array(
|
227 |
+
'page_title' => $page_title,
|
228 |
+
'menu_title' => $menu_title,
|
229 |
+
'menu_slug' => $menu_slug,
|
230 |
+
'capability' => $capability,
|
231 |
+
'position' => $position,
|
232 |
+
'parent_slug' => $parent_slug,
|
233 |
+
'icon_url' => $icon_url,
|
234 |
+
'redirect' => $redirect,
|
235 |
+
'post_id' => $p_id,
|
236 |
+
'autoload' => $autoload,
|
237 |
+
'update_button' => $update_button,
|
238 |
+
'updated_message' => $updated_message,
|
239 |
+
);
|
240 |
+
|
241 |
+
// Menu title
|
242 |
+
if(empty($menu_title))
|
243 |
+
$register_args['menu_title'] = $page_title;
|
244 |
+
|
245 |
+
// Menu slug
|
246 |
+
if(empty($menu_slug))
|
247 |
+
$register_args['menu_slug'] = sanitize_title($register_args['menu_title']);
|
248 |
+
|
249 |
+
// Redirect
|
250 |
+
$register_args['redirect'] = true;
|
251 |
+
if(empty($redirect))
|
252 |
+
$register_args['redirect'] = false;
|
253 |
+
|
254 |
+
// Post ID
|
255 |
+
if(empty($p_id))
|
256 |
+
$register_args['post_id'] = 'options';
|
257 |
+
|
258 |
+
// Autoload
|
259 |
+
$register_args['autoload'] = true;
|
260 |
+
if(empty($autoload))
|
261 |
+
$register_args['autoload'] = false;
|
262 |
+
|
263 |
+
// Get ACFE option
|
264 |
+
$option = get_option('acfe_dynamic_options_pages', array());
|
265 |
+
|
266 |
+
// Create ACFE option
|
267 |
+
$option[$name] = $register_args;
|
268 |
+
|
269 |
+
// Sort keys ASC
|
270 |
+
ksort($option);
|
271 |
+
|
272 |
+
// Update ACFE option
|
273 |
+
update_option('acfe_dynamic_options_pages', $option);
|
274 |
+
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Dynamic Options Page Status Publish > Trash
|
279 |
+
*/
|
280 |
+
add_action('publish_to_trash', 'acfe_dop_filter_status_trash');
|
281 |
+
function acfe_dop_filter_status_trash($post){
|
282 |
+
|
283 |
+
if(get_post_type($post->ID) != 'acfe-dop')
|
284 |
+
return;
|
285 |
+
|
286 |
+
$post_id = $post->ID;
|
287 |
+
$title = get_field('page_title', $post_id);
|
288 |
+
$name = get_field('acfe_dop_name', $post_id);
|
289 |
+
|
290 |
+
// Get ACFE option
|
291 |
+
$option = get_option('acfe_dynamic_options_pages', array());
|
292 |
+
|
293 |
+
// Check ACFE option
|
294 |
+
if(isset($option[$name]))
|
295 |
+
unset($option[$name]);
|
296 |
+
|
297 |
+
// Update ACFE option
|
298 |
+
update_option('acfe_dynamic_options_pages', $option);
|
299 |
+
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Dynamic Options Page Status Trash > Publish
|
304 |
+
*/
|
305 |
+
add_action('trash_to_publish', 'acfe_dop_filter_status_publish');
|
306 |
+
function acfe_dop_filter_status_publish($post){
|
307 |
+
|
308 |
+
if(get_post_type($post->ID) != 'acfe-dop')
|
309 |
+
return;
|
310 |
+
|
311 |
+
acfe_dop_filter_save($post->ID);
|
312 |
+
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Dynamic Options Page Admin: List
|
317 |
+
*/
|
318 |
+
add_action('pre_get_posts', 'acfe_dop_admin_pre_get_posts');
|
319 |
+
function acfe_dop_admin_pre_get_posts($query){
|
320 |
+
|
321 |
+
if(!is_admin() || !$query->is_main_query())
|
322 |
+
return;
|
323 |
+
|
324 |
+
global $pagenow;
|
325 |
+
if($pagenow != 'edit.php')
|
326 |
+
return;
|
327 |
+
|
328 |
+
$post_type = $query->get('post_type');
|
329 |
+
if($post_type != 'acfe-dop')
|
330 |
+
return;
|
331 |
+
|
332 |
+
$query->set('orderby', 'name');
|
333 |
+
$query->set('order', 'ASC');
|
334 |
+
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Dynamic Options Page Admin: Posts Per Page
|
339 |
+
*/
|
340 |
+
add_filter('edit_posts_per_page', 'acfe_dop_admin_ppp', 10, 2);
|
341 |
+
function acfe_dop_admin_ppp($ppp, $post_type){
|
342 |
+
|
343 |
+
if($post_type != 'acfe-dop')
|
344 |
+
return $ppp;
|
345 |
+
|
346 |
+
global $pagenow;
|
347 |
+
if($pagenow != 'edit.php')
|
348 |
+
return $ppp;
|
349 |
+
|
350 |
+
return 999;
|
351 |
+
|
352 |
+
}
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Admin List Columns
|
356 |
+
*/
|
357 |
+
add_filter('manage_edit-acfe-dop_columns', 'acfe_dop_admin_columns');
|
358 |
+
function acfe_dop_admin_columns($columns){
|
359 |
+
|
360 |
+
if(isset($columns['date']))
|
361 |
+
unset($columns['date']);
|
362 |
+
|
363 |
+
$columns['name'] = __('Name');
|
364 |
+
$columns['post_id'] = __('Post ID');
|
365 |
+
$columns['autoload'] = __('Autoload');
|
366 |
+
|
367 |
+
return $columns;
|
368 |
+
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Admin List Columns HTML
|
373 |
+
*/
|
374 |
+
add_action('manage_acfe-dop_posts_custom_column', 'acfe_dop_admin_columns_html', 10, 2);
|
375 |
+
function acfe_dop_admin_columns_html($column, $post_id){
|
376 |
+
|
377 |
+
// Name
|
378 |
+
if($column === 'name'){
|
379 |
+
|
380 |
+
$name = get_field('acfe_dop_name', $post_id);
|
381 |
+
|
382 |
+
echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . $name . '</code>';
|
383 |
+
|
384 |
+
}
|
385 |
+
|
386 |
+
// Post ID
|
387 |
+
elseif($column === 'post_id'){
|
388 |
+
|
389 |
+
$p_id = get_field('post_id', $post_id);
|
390 |
+
if(empty($p_id))
|
391 |
+
$p_id = 'options';
|
392 |
+
|
393 |
+
echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . $p_id. '</code>';
|
394 |
+
|
395 |
+
}
|
396 |
+
|
397 |
+
// Autoload
|
398 |
+
elseif($column === 'autoload'){
|
399 |
+
|
400 |
+
$autoload = get_field('autoload', $post_id);
|
401 |
+
|
402 |
+
if(empty($autoload))
|
403 |
+
echo 'No';
|
404 |
+
else
|
405 |
+
echo 'Yes';
|
406 |
+
|
407 |
+
}
|
408 |
+
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Admin List Row Actions
|
413 |
+
*/
|
414 |
+
add_filter('page_row_actions','acfe_dop_admin_row', 10, 2);
|
415 |
+
function acfe_dop_admin_row($actions, $post){
|
416 |
+
|
417 |
+
if($post->post_type != 'acfe-dop' || $post->post_status != 'publish')
|
418 |
+
return $actions;
|
419 |
+
|
420 |
+
$name = get_field('acfe_dop_name', $post->ID);
|
421 |
+
|
422 |
+
$actions['acfe_dpt_export_json'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dop_export&keys=' . $name) . '">' . __('Json') . '</a>';
|
423 |
+
|
424 |
+
return $actions;
|
425 |
+
|
426 |
+
}
|
427 |
+
|
428 |
+
/**
|
429 |
+
* Admin Disable Name
|
430 |
+
*/
|
431 |
+
add_filter('acf/prepare_field/name=acfe_dop_name', 'acfe_dop_admin_disable_name');
|
432 |
+
function acfe_dop_admin_disable_name($field){
|
433 |
+
|
434 |
+
global $pagenow;
|
435 |
+
if($pagenow != 'post.php')
|
436 |
+
return $field;
|
437 |
+
|
438 |
+
$field['disabled'] = true;
|
439 |
+
|
440 |
+
return $field;
|
441 |
+
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
* Admin Force Name
|
446 |
+
*/
|
447 |
+
add_action('load-edit.php', 'acfe_dop_admin_name_value');
|
448 |
+
function acfe_dop_admin_name_value(){
|
449 |
+
|
450 |
+
// Get post type
|
451 |
+
global $typenow;
|
452 |
+
|
453 |
+
// Check post type
|
454 |
+
$post_type = $typenow;
|
455 |
+
if(empty($post_type) || $post_type != 'acfe-dop')
|
456 |
+
return;
|
457 |
+
|
458 |
+
$get_options = get_posts(array(
|
459 |
+
'post_type' => 'acfe-dop',
|
460 |
+
'posts_per_page' => -1,
|
461 |
+
'fields' => 'ids'
|
462 |
+
));
|
463 |
+
|
464 |
+
if(empty($get_options))
|
465 |
+
return;
|
466 |
+
|
467 |
+
foreach($get_options as $post_id){
|
468 |
+
|
469 |
+
if(get_field('acfe_dop_name', $post_id))
|
470 |
+
continue;
|
471 |
+
|
472 |
+
update_field('acfe_dop_name', sanitize_title(get_field('page_title', $post_id)), $post_id);
|
473 |
+
|
474 |
+
}
|
475 |
+
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
* Dynamic Options Page: Local Field Group
|
480 |
+
*/
|
481 |
+
add_action('init', 'acfe_dop_local_field_group');
|
482 |
+
function acfe_dop_local_field_group(){
|
483 |
+
|
484 |
+
acf_add_local_field_group(array(
|
485 |
+
'key' => 'group_acfe_dynamic_options_page',
|
486 |
+
'title' => __('Dynamic Options Page', 'acfe'),
|
487 |
+
|
488 |
+
'location' => array(
|
489 |
+
array(
|
490 |
+
array(
|
491 |
+
'param' => 'post_type',
|
492 |
+
'operator' => '==',
|
493 |
+
'value' => 'acfe-dop',
|
494 |
+
),
|
495 |
+
),
|
496 |
+
),
|
497 |
+
|
498 |
+
'menu_order' => 0,
|
499 |
+
'position' => 'normal',
|
500 |
+
'style' => 'default',
|
501 |
+
'label_placement' => 'left',
|
502 |
+
'instruction_placement' => 'label',
|
503 |
+
'hide_on_screen' => '',
|
504 |
+
'active' => 1,
|
505 |
+
'description' => '',
|
506 |
+
|
507 |
+
'fields' => array(
|
508 |
+
array(
|
509 |
+
'key' => 'field_acfe_dop_page_title',
|
510 |
+
'label' => 'Page title',
|
511 |
+
'name' => 'page_title',
|
512 |
+
'type' => 'text',
|
513 |
+
'instructions' => '(string) The title displayed on the options page. Required.',
|
514 |
+
'required' => 1,
|
515 |
+
'conditional_logic' => 0,
|
516 |
+
'wrapper' => array(
|
517 |
+
'width' => '',
|
518 |
+
'class' => '',
|
519 |
+
'id' => '',
|
520 |
+
),
|
521 |
+
'acfe_validate' => '',
|
522 |
+
'acfe_update' => '',
|
523 |
+
'acfe_permissions' => '',
|
524 |
+
'default_value' => '',
|
525 |
+
'placeholder' => '',
|
526 |
+
'prepend' => '',
|
527 |
+
'append' => '',
|
528 |
+
'maxlength' => '',
|
529 |
+
),
|
530 |
+
array(
|
531 |
+
'key' => 'field_acfe_dop_name',
|
532 |
+
'label' => 'Name',
|
533 |
+
'name' => 'acfe_dop_name',
|
534 |
+
'type' => 'acfe_slug',
|
535 |
+
'instructions' => '(string) Options page slug. Must be unique',
|
536 |
+
'required' => 1,
|
537 |
+
'conditional_logic' => 0,
|
538 |
+
'wrapper' => array(
|
539 |
+
'width' => '',
|
540 |
+
'class' => '',
|
541 |
+
'id' => '',
|
542 |
+
),
|
543 |
+
'acfe_validate' => '',
|
544 |
+
'acfe_update' => '',
|
545 |
+
'acfe_permissions' => '',
|
546 |
+
'default_value' => '',
|
547 |
+
'placeholder' => '',
|
548 |
+
'prepend' => '',
|
549 |
+
'append' => '',
|
550 |
+
'maxlength' => '',
|
551 |
+
),
|
552 |
+
array(
|
553 |
+
'key' => 'field_acfe_dop_menu_title',
|
554 |
+
'label' => 'Menu title',
|
555 |
+
'name' => 'menu_title',
|
556 |
+
'type' => 'text',
|
557 |
+
'instructions' => '(string) The title displayed in the wp-admin sidebar. Defaults to page_title',
|
558 |
+
'required' => 0,
|
559 |
+
'conditional_logic' => 0,
|
560 |
+
'wrapper' => array(
|
561 |
+
'width' => '',
|
562 |
+
'class' => '',
|
563 |
+
'id' => '',
|
564 |
+
),
|
565 |
+
'acfe_validate' => '',
|
566 |
+
'acfe_update' => '',
|
567 |
+
'acfe_permissions' => '',
|
568 |
+
'default_value' => '',
|
569 |
+
'placeholder' => '',
|
570 |
+
'prepend' => '',
|
571 |
+
'append' => '',
|
572 |
+
'maxlength' => '',
|
573 |
+
),
|
574 |
+
array(
|
575 |
+
'key' => 'field_acfe_dop_menu_slug',
|
576 |
+
'label' => 'Menu slug',
|
577 |
+
'name' => 'menu_slug',
|
578 |
+
'type' => 'acfe_slug',
|
579 |
+
'instructions' => '(string) The URL slug used to uniquely identify this options page. Defaults to a url friendly version of menu_title',
|
580 |
+
'required' => 0,
|
581 |
+
'conditional_logic' => 0,
|
582 |
+
'wrapper' => array(
|
583 |
+
'width' => '',
|
584 |
+
'class' => '',
|
585 |
+
'id' => '',
|
586 |
+
),
|
587 |
+
'acfe_validate' => '',
|
588 |
+
'acfe_update' => array(
|
589 |
+
'5cd2a4d60fbf2' => array(
|
590 |
+
'acfe_update_function' => 'sanitize_title',
|
591 |
+
),
|
592 |
+
),
|
593 |
+
'acfe_permissions' => '',
|
594 |
+
'default_value' => '',
|
595 |
+
'placeholder' => '',
|
596 |
+
'prepend' => '',
|
597 |
+
'append' => '',
|
598 |
+
'maxlength' => '',
|
599 |
+
),
|
600 |
+
array(
|
601 |
+
'key' => 'field_acfe_dop_capability',
|
602 |
+
'label' => 'Capability',
|
603 |
+
'name' => 'capability',
|
604 |
+
'type' => 'text',
|
605 |
+
'instructions' => '(string) The capability required for this menu to be displayed to the user. Defaults to edit_posts.<br /><br />
|
606 |
+
|
607 |
+
Read more about capability here: <a href="https://codex.wordpress.org/Roles_and_Capabilities">https://codex.wordpress.org/Roles_and_Capabilities</a>',
|
608 |
+
'required' => 0,
|
609 |
+
'conditional_logic' => 0,
|
610 |
+
'wrapper' => array(
|
611 |
+
'width' => '',
|
612 |
+
'class' => '',
|
613 |
+
'id' => '',
|
614 |
+
),
|
615 |
+
'acfe_validate' => '',
|
616 |
+
'acfe_update' => '',
|
617 |
+
'acfe_permissions' => '',
|
618 |
+
'default_value' => 'edit_posts',
|
619 |
+
'placeholder' => '',
|
620 |
+
'prepend' => '',
|
621 |
+
'append' => '',
|
622 |
+
'maxlength' => '',
|
623 |
+
),
|
624 |
+
array(
|
625 |
+
'key' => 'field_acfe_dop_position',
|
626 |
+
'label' => 'Position',
|
627 |
+
'name' => 'position',
|
628 |
+
'type' => 'text',
|
629 |
+
'instructions' => '(int|string) The position in the menu order this menu should appear. Defaults to bottom of utility menu items.<br /><br />
|
630 |
+
|
631 |
+
WARNING: if two menu items use the same position attribute, one of the items may be overwritten so that only one item displays!<br />
|
632 |
+
Risk of conflict can be reduced by using decimal instead of integer values, e.g. \'63.3\' instead of 63 (must use quotes).',
|
633 |
+
'required' => 0,
|
634 |
+
'conditional_logic' => 0,
|
635 |
+
'wrapper' => array(
|
636 |
+
'width' => '',
|
637 |
+
'class' => '',
|
638 |
+
'id' => '',
|
639 |
+
),
|
640 |
+
'acfe_validate' => '',
|
641 |
+
'acfe_update' => '',
|
642 |
+
'acfe_permissions' => '',
|
643 |
+
'default_value' => '',
|
644 |
+
'placeholder' => '',
|
645 |
+
'prepend' => '',
|
646 |
+
'append' => '',
|
647 |
+
'maxlength' => '',
|
648 |
+
),
|
649 |
+
array(
|
650 |
+
'key' => 'field_acfe_dop_parent_slug',
|
651 |
+
'label' => 'Parent slug',
|
652 |
+
'name' => 'parent_slug',
|
653 |
+
'type' => 'text',
|
654 |
+
'instructions' => '(string) The slug of another WP admin page. if set, this will become a child page.',
|
655 |
+
'required' => 0,
|
656 |
+
'conditional_logic' => 0,
|
657 |
+
'wrapper' => array(
|
658 |
+
'width' => '',
|
659 |
+
'class' => '',
|
660 |
+
'id' => '',
|
661 |
+
),
|
662 |
+
'acfe_validate' => '',
|
663 |
+
'acfe_update' => '',
|
664 |
+
'acfe_permissions' => '',
|
665 |
+
'default_value' => '',
|
666 |
+
'placeholder' => '',
|
667 |
+
'prepend' => '',
|
668 |
+
'append' => '',
|
669 |
+
'maxlength' => '',
|
670 |
+
),
|
671 |
+
array(
|
672 |
+
'key' => 'field_acfe_dop_icon_url',
|
673 |
+
'label' => 'Icon url',
|
674 |
+
'name' => 'icon_url',
|
675 |
+
'type' => 'text',
|
676 |
+
'instructions' => '(string) The icon class for this menu. Defaults to default WordPress gear.<br /><br />
|
677 |
+
Read more about dashicons here: <a href="https://developer.wordpress.org/resource/dashicons/">https://developer.wordpress.org/resource/dashicons/</a>',
|
678 |
+
'required' => 0,
|
679 |
+
'conditional_logic' => 0,
|
680 |
+
'wrapper' => array(
|
681 |
+
'width' => '',
|
682 |
+
'class' => '',
|
683 |
+
'id' => '',
|
684 |
+
),
|
685 |
+
'acfe_validate' => '',
|
686 |
+
'acfe_update' => '',
|
687 |
+
'acfe_permissions' => '',
|
688 |
+
'default_value' => '',
|
689 |
+
'placeholder' => '',
|
690 |
+
'prepend' => '',
|
691 |
+
'append' => '',
|
692 |
+
'maxlength' => '',
|
693 |
+
),
|
694 |
+
array(
|
695 |
+
'key' => 'field_acfe_dop_redirect',
|
696 |
+
'label' => 'Redirect',
|
697 |
+
'name' => 'redirect',
|
698 |
+
'type' => 'true_false',
|
699 |
+
'instructions' => '(boolean) If set to true, this options page will redirect to the first child page (if a child page exists).
|
700 |
+
If set to false, this parent page will appear alongside any child pages. Defaults to true',
|
701 |
+
'required' => 0,
|
702 |
+
'conditional_logic' => 0,
|
703 |
+
'wrapper' => array(
|
704 |
+
'width' => '',
|
705 |
+
'class' => '',
|
706 |
+
'id' => '',
|
707 |
+
),
|
708 |
+
'acfe_validate' => '',
|
709 |
+
'acfe_update' => '',
|
710 |
+
'acfe_permissions' => '',
|
711 |
+
'message' => '',
|
712 |
+
'default_value' => 1,
|
713 |
+
'ui' => 1,
|
714 |
+
'ui_on_text' => 'True',
|
715 |
+
'ui_off_text' => 'False',
|
716 |
+
),
|
717 |
+
array(
|
718 |
+
'key' => 'field_acfe_dop_post_id',
|
719 |
+
'label' => 'Post ID',
|
720 |
+
'name' => 'post_id',
|
721 |
+
'type' => 'text',
|
722 |
+
'instructions' => '(int|string) The \'$post_id\' to save/load data to/from. Can be set to a numeric post ID (123), or a string (\'user_2\').
|
723 |
+
Defaults to \'options\'.',
|
724 |
+
'required' => 0,
|
725 |
+
'conditional_logic' => 0,
|
726 |
+
'wrapper' => array(
|
727 |
+
'width' => '',
|
728 |
+
'class' => '',
|
729 |
+
'id' => '',
|
730 |
+
),
|
731 |
+
'acfe_validate' => '',
|
732 |
+
'acfe_update' => '',
|
733 |
+
'acfe_permissions' => '',
|
734 |
+
'default_value' => 'options',
|
735 |
+
'placeholder' => '',
|
736 |
+
'prepend' => '',
|
737 |
+
'append' => '',
|
738 |
+
'maxlength' => '',
|
739 |
+
),
|
740 |
+
array(
|
741 |
+
'key' => 'field_acfe_dop_autoload',
|
742 |
+
'label' => 'Autoload',
|
743 |
+
'name' => 'autoload',
|
744 |
+
'type' => 'true_false',
|
745 |
+
'instructions' => '(boolean) Whether to load the option (values saved from this options page) when WordPress starts up.
|
746 |
+
Defaults to false.',
|
747 |
+
'required' => 0,
|
748 |
+
'conditional_logic' => 0,
|
749 |
+
'wrapper' => array(
|
750 |
+
'width' => '',
|
751 |
+
'class' => '',
|
752 |
+
'id' => '',
|
753 |
+
),
|
754 |
+
'acfe_validate' => '',
|
755 |
+
'acfe_update' => '',
|
756 |
+
'acfe_permissions' => '',
|
757 |
+
'message' => '',
|
758 |
+
'default_value' => 0,
|
759 |
+
'ui' => 1,
|
760 |
+
'ui_on_text' => 'True',
|
761 |
+
'ui_off_text' => 'False',
|
762 |
+
),
|
763 |
+
array(
|
764 |
+
'key' => 'field_acfe_dop_update_button',
|
765 |
+
'label' => 'Update button',
|
766 |
+
'name' => 'update_button',
|
767 |
+
'type' => 'text',
|
768 |
+
'instructions' => '(string) The update button text.',
|
769 |
+
'required' => 0,
|
770 |
+
'conditional_logic' => 0,
|
771 |
+
'wrapper' => array(
|
772 |
+
'width' => '',
|
773 |
+
'class' => '',
|
774 |
+
'id' => '',
|
775 |
+
),
|
776 |
+
'acfe_validate' => '',
|
777 |
+
'acfe_update' => '',
|
778 |
+
'acfe_permissions' => '',
|
779 |
+
'default_value' => 'Update',
|
780 |
+
'placeholder' => '',
|
781 |
+
'prepend' => '',
|
782 |
+
'append' => '',
|
783 |
+
'maxlength' => '',
|
784 |
+
),
|
785 |
+
array(
|
786 |
+
'key' => 'field_acfe_dop_updated_message',
|
787 |
+
'label' => 'Updated Message',
|
788 |
+
'name' => 'updated_message',
|
789 |
+
'type' => 'text',
|
790 |
+
'instructions' => '(string) The message shown above the form on submit.',
|
791 |
+
'required' => 0,
|
792 |
+
'conditional_logic' => 0,
|
793 |
+
'wrapper' => array(
|
794 |
+
'width' => '',
|
795 |
+
'class' => '',
|
796 |
+
'id' => '',
|
797 |
+
),
|
798 |
+
'acfe_validate' => '',
|
799 |
+
'acfe_update' => '',
|
800 |
+
'acfe_permissions' => '',
|
801 |
+
'default_value' => 'Options Updated',
|
802 |
+
'placeholder' => '',
|
803 |
+
'prepend' => '',
|
804 |
+
'append' => '',
|
805 |
+
'maxlength' => '',
|
806 |
+
),
|
807 |
+
),
|
808 |
+
));
|
809 |
+
|
810 |
}
|
includes/modules/dynamic-post-type.php
CHANGED
@@ -1,2575 +1,2579 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
'
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
'
|
27 |
-
'
|
28 |
-
'
|
29 |
-
'
|
30 |
-
'
|
31 |
-
'
|
32 |
-
'
|
33 |
-
'
|
34 |
-
'
|
35 |
-
'
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
'
|
41 |
-
'
|
42 |
-
'
|
43 |
-
'
|
44 |
-
'
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
$
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
$
|
116 |
-
$
|
117 |
-
$
|
118 |
-
$
|
119 |
-
$
|
120 |
-
$
|
121 |
-
|
122 |
-
|
123 |
-
$
|
124 |
-
$
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
$
|
138 |
-
$
|
139 |
-
$
|
140 |
-
|
141 |
-
|
142 |
-
$
|
143 |
-
$
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
$
|
148 |
-
$
|
149 |
-
|
150 |
-
|
151 |
-
$
|
152 |
-
$
|
153 |
-
|
154 |
-
|
155 |
-
$
|
156 |
-
$
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
$
|
162 |
-
$
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
$
|
167 |
-
$
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
$
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
'
|
177 |
-
'
|
178 |
-
'
|
179 |
-
'
|
180 |
-
'
|
181 |
-
'
|
182 |
-
|
183 |
-
|
184 |
-
'
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
'
|
189 |
-
|
190 |
-
|
191 |
-
'
|
192 |
-
'
|
193 |
-
|
194 |
-
|
195 |
-
'
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
'
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
'
|
207 |
-
'
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
'
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
'
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
//
|
225 |
-
if($
|
226 |
-
$register_args['
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
//
|
239 |
-
$
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
$
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
$
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
$
|
283 |
-
|
284 |
-
|
285 |
-
$
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
//
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
if(
|
323 |
-
return;
|
324 |
-
|
325 |
-
|
326 |
-
if($
|
327 |
-
return;
|
328 |
-
|
329 |
-
$query->
|
330 |
-
$
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
if($
|
345 |
-
return $ppp;
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
$
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
if(
|
387 |
-
return $ppp;
|
388 |
-
|
389 |
-
|
390 |
-
if(!
|
391 |
-
return $ppp;
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
$
|
411 |
-
$
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
//
|
472 |
-
|
473 |
-
return $locate;
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
}
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
$columns['
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
$
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
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 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
$
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
<script type="text/
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
}
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
$
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
$
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
}
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
'
|
706 |
-
'
|
707 |
-
'
|
708 |
-
'
|
709 |
-
|
710 |
-
'
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
'
|
717 |
-
'
|
718 |
-
'
|
719 |
-
'
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
'
|
730 |
-
'
|
731 |
-
|
732 |
-
|
733 |
-
'
|
734 |
-
'
|
735 |
-
'
|
736 |
-
'
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
'
|
748 |
-
'
|
749 |
-
|
750 |
-
|
751 |
-
'
|
752 |
-
|
753 |
-
|
754 |
-
'
|
755 |
-
'
|
756 |
-
|
757 |
-
|
758 |
-
'
|
759 |
-
'
|
760 |
-
'
|
761 |
-
'
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
'
|
771 |
-
'
|
772 |
-
'
|
773 |
-
'
|
774 |
-
|
775 |
-
|
776 |
-
'
|
777 |
-
'
|
778 |
-
|
779 |
-
|
780 |
-
'
|
781 |
-
'
|
782 |
-
'
|
783 |
-
'
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
'
|
793 |
-
'
|
794 |
-
'
|
795 |
-
'
|
796 |
-
|
797 |
-
|
798 |
-
'
|
799 |
-
'
|
800 |
-
|
801 |
-
|
802 |
-
'
|
803 |
-
'
|
804 |
-
'
|
805 |
-
'
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
'
|
815 |
-
'
|
816 |
-
'
|
817 |
-
'
|
818 |
-
|
819 |
-
|
820 |
-
'
|
821 |
-
'
|
822 |
-
|
823 |
-
|
824 |
-
'
|
825 |
-
'
|
826 |
-
'
|
827 |
-
'
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
'
|
841 |
-
'
|
842 |
-
'
|
843 |
-
'
|
844 |
-
'
|
845 |
-
'
|
846 |
-
'
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
'
|
861 |
-
'
|
862 |
-
|
863 |
-
|
864 |
-
'
|
865 |
-
'
|
866 |
-
'
|
867 |
-
'
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
'
|
877 |
-
'
|
878 |
-
'
|
879 |
-
|
880 |
-
|
881 |
-
'
|
882 |
-
'
|
883 |
-
|
884 |
-
|
885 |
-
'
|
886 |
-
'
|
887 |
-
'
|
888 |
-
'
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
'
|
898 |
-
'
|
899 |
-
'
|
900 |
-
'
|
901 |
-
|
902 |
-
|
903 |
-
'
|
904 |
-
'
|
905 |
-
|
906 |
-
|
907 |
-
'
|
908 |
-
'
|
909 |
-
'
|
910 |
-
'
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
'
|
920 |
-
'
|
921 |
-
'
|
922 |
-
'
|
923 |
-
|
924 |
-
|
925 |
-
'
|
926 |
-
'
|
927 |
-
|
928 |
-
|
929 |
-
'
|
930 |
-
'
|
931 |
-
'
|
932 |
-
'
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
'
|
942 |
-
'
|
943 |
-
'
|
944 |
-
'
|
945 |
-
|
946 |
-
|
947 |
-
'
|
948 |
-
'
|
949 |
-
|
950 |
-
|
951 |
-
'
|
952 |
-
'
|
953 |
-
'
|
954 |
-
'
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
'
|
964 |
-
'
|
965 |
-
'
|
966 |
-
'
|
967 |
-
|
968 |
-
|
969 |
-
'
|
970 |
-
'
|
971 |
-
|
972 |
-
|
973 |
-
'
|
974 |
-
'
|
975 |
-
'
|
976 |
-
'
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
'
|
994 |
-
|
995 |
-
'
|
996 |
-
'
|
997 |
-
|
998 |
-
|
999 |
-
'
|
1000 |
-
'
|
1001 |
-
|
1002 |
-
|
1003 |
-
'
|
1004 |
-
'
|
1005 |
-
'
|
1006 |
-
'
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
'
|
1017 |
-
'
|
1018 |
-
|
1019 |
-
|
1020 |
-
'
|
1021 |
-
|
1022 |
-
'
|
1023 |
-
'
|
1024 |
-
'
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
'
|
1038 |
-
'
|
1039 |
-
'
|
1040 |
-
'
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
'
|
1050 |
-
'
|
1051 |
-
'
|
1052 |
-
'
|
1053 |
-
|
1054 |
-
|
1055 |
-
'
|
1056 |
-
'
|
1057 |
-
|
1058 |
-
|
1059 |
-
'
|
1060 |
-
'
|
1061 |
-
'
|
1062 |
-
'
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
'
|
1072 |
-
'
|
1073 |
-
'
|
1074 |
-
'
|
1075 |
-
|
1076 |
-
|
1077 |
-
'
|
1078 |
-
'
|
1079 |
-
|
1080 |
-
|
1081 |
-
'
|
1082 |
-
'
|
1083 |
-
'
|
1084 |
-
'
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
'
|
1094 |
-
'
|
1095 |
-
'
|
1096 |
-
'
|
1097 |
-
|
1098 |
-
|
1099 |
-
'
|
1100 |
-
'
|
1101 |
-
|
1102 |
-
|
1103 |
-
'
|
1104 |
-
'
|
1105 |
-
'
|
1106 |
-
'
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
'
|
1116 |
-
'
|
1117 |
-
'
|
1118 |
-
'
|
1119 |
-
|
1120 |
-
|
1121 |
-
'
|
1122 |
-
'
|
1123 |
-
|
1124 |
-
|
1125 |
-
'
|
1126 |
-
'
|
1127 |
-
'
|
1128 |
-
'
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
'
|
1138 |
-
'
|
1139 |
-
'
|
1140 |
-
'
|
1141 |
-
|
1142 |
-
|
1143 |
-
'
|
1144 |
-
'
|
1145 |
-
|
1146 |
-
|
1147 |
-
'
|
1148 |
-
'
|
1149 |
-
'
|
1150 |
-
'
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
'
|
1160 |
-
'
|
1161 |
-
'
|
1162 |
-
'
|
1163 |
-
|
1164 |
-
|
1165 |
-
'
|
1166 |
-
'
|
1167 |
-
|
1168 |
-
|
1169 |
-
'
|
1170 |
-
'
|
1171 |
-
'
|
1172 |
-
'
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
'
|
1182 |
-
'
|
1183 |
-
'
|
1184 |
-
'
|
1185 |
-
|
1186 |
-
|
1187 |
-
'
|
1188 |
-
'
|
1189 |
-
|
1190 |
-
|
1191 |
-
'
|
1192 |
-
'
|
1193 |
-
'
|
1194 |
-
'
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
'
|
1204 |
-
'
|
1205 |
-
'
|
1206 |
-
'
|
1207 |
-
|
1208 |
-
|
1209 |
-
'
|
1210 |
-
'
|
1211 |
-
|
1212 |
-
|
1213 |
-
'
|
1214 |
-
'
|
1215 |
-
'
|
1216 |
-
'
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
'
|
1226 |
-
'
|
1227 |
-
'
|
1228 |
-
'
|
1229 |
-
|
1230 |
-
|
1231 |
-
'
|
1232 |
-
'
|
1233 |
-
|
1234 |
-
|
1235 |
-
'
|
1236 |
-
'
|
1237 |
-
'
|
1238 |
-
'
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
'
|
1248 |
-
'
|
1249 |
-
'
|
1250 |
-
'
|
1251 |
-
|
1252 |
-
|
1253 |
-
'
|
1254 |
-
'
|
1255 |
-
|
1256 |
-
|
1257 |
-
'
|
1258 |
-
'
|
1259 |
-
'
|
1260 |
-
'
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
'
|
1270 |
-
'
|
1271 |
-
'
|
1272 |
-
'
|
1273 |
-
|
1274 |
-
|
1275 |
-
'
|
1276 |
-
'
|
1277 |
-
|
1278 |
-
|
1279 |
-
'
|
1280 |
-
'
|
1281 |
-
'
|
1282 |
-
'
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
'
|
1292 |
-
'
|
1293 |
-
'
|
1294 |
-
'
|
1295 |
-
|
1296 |
-
|
1297 |
-
'
|
1298 |
-
'
|
1299 |
-
|
1300 |
-
|
1301 |
-
'
|
1302 |
-
'
|
1303 |
-
'
|
1304 |
-
'
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
'
|
1314 |
-
'
|
1315 |
-
'
|
1316 |
-
'
|
1317 |
-
|
1318 |
-
|
1319 |
-
'
|
1320 |
-
'
|
1321 |
-
|
1322 |
-
|
1323 |
-
'
|
1324 |
-
'
|
1325 |
-
'
|
1326 |
-
'
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
'
|
1336 |
-
'
|
1337 |
-
'
|
1338 |
-
'
|
1339 |
-
|
1340 |
-
|
1341 |
-
'
|
1342 |
-
'
|
1343 |
-
|
1344 |
-
|
1345 |
-
'
|
1346 |
-
'
|
1347 |
-
'
|
1348 |
-
'
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
'
|
1358 |
-
'
|
1359 |
-
'
|
1360 |
-
'
|
1361 |
-
|
1362 |
-
|
1363 |
-
'
|
1364 |
-
'
|
1365 |
-
|
1366 |
-
|
1367 |
-
'
|
1368 |
-
'
|
1369 |
-
'
|
1370 |
-
'
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
'
|
1380 |
-
'
|
1381 |
-
'
|
1382 |
-
'
|
1383 |
-
|
1384 |
-
|
1385 |
-
'
|
1386 |
-
'
|
1387 |
-
|
1388 |
-
|
1389 |
-
'
|
1390 |
-
'
|
1391 |
-
'
|
1392 |
-
'
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
'
|
1402 |
-
'
|
1403 |
-
'
|
1404 |
-
'
|
1405 |
-
|
1406 |
-
|
1407 |
-
'
|
1408 |
-
'
|
1409 |
-
|
1410 |
-
|
1411 |
-
'
|
1412 |
-
'
|
1413 |
-
'
|
1414 |
-
'
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
'
|
1424 |
-
'
|
1425 |
-
'
|
1426 |
-
'
|
1427 |
-
|
1428 |
-
|
1429 |
-
'
|
1430 |
-
'
|
1431 |
-
|
1432 |
-
|
1433 |
-
'
|
1434 |
-
'
|
1435 |
-
'
|
1436 |
-
'
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
'
|
1446 |
-
'
|
1447 |
-
'
|
1448 |
-
'
|
1449 |
-
|
1450 |
-
|
1451 |
-
'
|
1452 |
-
'
|
1453 |
-
|
1454 |
-
|
1455 |
-
'
|
1456 |
-
'
|
1457 |
-
'
|
1458 |
-
'
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
'
|
1468 |
-
'
|
1469 |
-
'
|
1470 |
-
'
|
1471 |
-
|
1472 |
-
|
1473 |
-
'
|
1474 |
-
'
|
1475 |
-
|
1476 |
-
|
1477 |
-
'
|
1478 |
-
'
|
1479 |
-
'
|
1480 |
-
'
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
'
|
1490 |
-
'
|
1491 |
-
'
|
1492 |
-
'
|
1493 |
-
|
1494 |
-
|
1495 |
-
'
|
1496 |
-
'
|
1497 |
-
|
1498 |
-
|
1499 |
-
'
|
1500 |
-
'
|
1501 |
-
'
|
1502 |
-
'
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
'
|
1512 |
-
'
|
1513 |
-
'
|
1514 |
-
'
|
1515 |
-
|
1516 |
-
|
1517 |
-
'
|
1518 |
-
'
|
1519 |
-
|
1520 |
-
|
1521 |
-
'
|
1522 |
-
'
|
1523 |
-
'
|
1524 |
-
'
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
'
|
1534 |
-
'
|
1535 |
-
'
|
1536 |
-
'
|
1537 |
-
|
1538 |
-
|
1539 |
-
'
|
1540 |
-
'
|
1541 |
-
|
1542 |
-
|
1543 |
-
'
|
1544 |
-
'
|
1545 |
-
'
|
1546 |
-
'
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
'
|
1556 |
-
'
|
1557 |
-
'
|
1558 |
-
'
|
1559 |
-
|
1560 |
-
|
1561 |
-
'
|
1562 |
-
'
|
1563 |
-
|
1564 |
-
|
1565 |
-
'
|
1566 |
-
'
|
1567 |
-
'
|
1568 |
-
'
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
'
|
1578 |
-
'
|
1579 |
-
'
|
1580 |
-
'
|
1581 |
-
|
1582 |
-
|
1583 |
-
'
|
1584 |
-
'
|
1585 |
-
|
1586 |
-
|
1587 |
-
'
|
1588 |
-
'
|
1589 |
-
'
|
1590 |
-
'
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
'
|
1600 |
-
'
|
1601 |
-
'
|
1602 |
-
'
|
1603 |
-
|
1604 |
-
|
1605 |
-
'
|
1606 |
-
'
|
1607 |
-
|
1608 |
-
|
1609 |
-
'
|
1610 |
-
'
|
1611 |
-
'
|
1612 |
-
'
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
'
|
1622 |
-
'
|
1623 |
-
'
|
1624 |
-
'
|
1625 |
-
|
1626 |
-
|
1627 |
-
'
|
1628 |
-
'
|
1629 |
-
|
1630 |
-
|
1631 |
-
'
|
1632 |
-
'
|
1633 |
-
'
|
1634 |
-
'
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
'
|
1644 |
-
'
|
1645 |
-
'
|
1646 |
-
'
|
1647 |
-
|
1648 |
-
|
1649 |
-
'
|
1650 |
-
'
|
1651 |
-
|
1652 |
-
|
1653 |
-
'
|
1654 |
-
'
|
1655 |
-
'
|
1656 |
-
'
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
'
|
1666 |
-
'
|
1667 |
-
'
|
1668 |
-
'
|
1669 |
-
|
1670 |
-
|
1671 |
-
'
|
1672 |
-
'
|
1673 |
-
|
1674 |
-
|
1675 |
-
'
|
1676 |
-
'
|
1677 |
-
'
|
1678 |
-
'
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
'
|
1688 |
-
'
|
1689 |
-
'
|
1690 |
-
'
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
'
|
1700 |
-
'
|
1701 |
-
'
|
1702 |
-
'
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
'
|
1713 |
-
'
|
1714 |
-
|
1715 |
-
|
1716 |
-
'
|
1717 |
-
'
|
1718 |
-
'
|
1719 |
-
'
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
'
|
1729 |
-
'
|
1730 |
-
'
|
1731 |
-
'
|
1732 |
-
'
|
1733 |
-
'
|
1734 |
-
|
1735 |
-
|
1736 |
-
'
|
1737 |
-
'
|
1738 |
-
|
1739 |
-
|
1740 |
-
'
|
1741 |
-
'
|
1742 |
-
'
|
1743 |
-
'
|
1744 |
-
|
1745 |
-
|
1746 |
-
'id' => '',
|
1747 |
-
),
|
1748 |
-
'acfe_validate' => '',
|
1749 |
-
'acfe_update' => '',
|
1750 |
-
'acfe_permissions' => '',
|
1751 |
-
'default_value' => 'dashicons-admin-post',
|
1752 |
-
'placeholder' => '',
|
1753 |
-
'prepend' => '',
|
1754 |
-
'append' => '',
|
1755 |
-
'maxlength' => '',
|
1756 |
-
),
|
1757 |
-
array(
|
1758 |
-
'key' => 'field_acfe_dpt_show_ui',
|
1759 |
-
'label' => 'Show UI',
|
1760 |
-
'name' => 'show_ui',
|
1761 |
-
'type' => 'true_false',
|
1762 |
-
'instructions' => 'Whether to generate a default UI for managing this post type in the admin',
|
1763 |
-
'required' => 0,
|
1764 |
-
'conditional_logic' => 0,
|
1765 |
-
'wrapper' => array(
|
1766 |
-
'width' => '',
|
1767 |
-
'class' => '',
|
1768 |
-
'id' => '',
|
1769 |
-
),
|
1770 |
-
'acfe_validate' => '',
|
1771 |
-
'acfe_update' => '',
|
1772 |
-
'acfe_permissions' => '',
|
1773 |
-
'message' => '',
|
1774 |
-
'default_value' => 1,
|
1775 |
-
'ui' => 1,
|
1776 |
-
'ui_on_text' => '',
|
1777 |
-
'ui_off_text' => '',
|
1778 |
-
),
|
1779 |
-
array(
|
1780 |
-
'key' => 'field_acfe_dpt_show_in_menu',
|
1781 |
-
'label' => 'Show in menu',
|
1782 |
-
'name' => 'show_in_menu',
|
1783 |
-
'type' => 'true_false',
|
1784 |
-
'instructions' => 'Where to show the post type in the admin menu. show_ui must be true',
|
1785 |
-
'required' => 0,
|
1786 |
-
'conditional_logic' => 0,
|
1787 |
-
'wrapper' => array(
|
1788 |
-
'width' => '',
|
1789 |
-
'class' => '',
|
1790 |
-
'id' => '',
|
1791 |
-
),
|
1792 |
-
'acfe_validate' => '',
|
1793 |
-
'acfe_update' => '',
|
1794 |
-
'acfe_permissions' => '',
|
1795 |
-
'message' => '',
|
1796 |
-
'default_value' => 1,
|
1797 |
-
'ui' => 1,
|
1798 |
-
'ui_on_text' => '',
|
1799 |
-
'ui_off_text' => '',
|
1800 |
-
),
|
1801 |
-
array(
|
1802 |
-
'key' => 'field_acfe_dpt_show_in_menu_text',
|
1803 |
-
'label' => 'Show in menu (text)',
|
1804 |
-
'name' => 'show_in_menu_text',
|
1805 |
-
'type' => 'text',
|
1806 |
-
'instructions' => 'If an existing top level page such as \'tools.php\' or \'edit.php?post_type=page\', the post type will be placed as a sub menu of that',
|
1807 |
-
'required' => 0,
|
1808 |
-
'conditional_logic' => array(
|
1809 |
-
array(
|
1810 |
-
array(
|
1811 |
-
'field' => 'field_5c9f5dd58d5ee',
|
1812 |
-
'operator' => '==',
|
1813 |
-
'value' => '1',
|
1814 |
-
),
|
1815 |
-
),
|
1816 |
-
),
|
1817 |
-
'wrapper' => array(
|
1818 |
-
'width' => '',
|
1819 |
-
'class' => '',
|
1820 |
-
'id' => '',
|
1821 |
-
),
|
1822 |
-
'acfe_validate' => '',
|
1823 |
-
'acfe_update' => '',
|
1824 |
-
'acfe_permissions' => '',
|
1825 |
-
'default_value' => '',
|
1826 |
-
'placeholder' => '',
|
1827 |
-
'prepend' => '',
|
1828 |
-
'append' => '',
|
1829 |
-
'maxlength' => '',
|
1830 |
-
),
|
1831 |
-
array(
|
1832 |
-
'key' => 'field_acfe_dpt_show_in_nav_menus',
|
1833 |
-
'label' => 'Show in nav menus',
|
1834 |
-
'name' => 'show_in_nav_menus',
|
1835 |
-
'type' => 'true_false',
|
1836 |
-
'instructions' => 'Whether post_type is available for selection in navigation menus',
|
1837 |
-
'required' => 0,
|
1838 |
-
'conditional_logic' => 0,
|
1839 |
-
'wrapper' => array(
|
1840 |
-
'width' => '',
|
1841 |
-
'class' => '',
|
1842 |
-
'id' => '',
|
1843 |
-
),
|
1844 |
-
'acfe_validate' => '',
|
1845 |
-
'acfe_update' => '',
|
1846 |
-
'acfe_permissions' => '',
|
1847 |
-
'message' => '',
|
1848 |
-
'default_value' => 1,
|
1849 |
-
'ui' => 1,
|
1850 |
-
'ui_on_text' => '',
|
1851 |
-
'ui_off_text' => '',
|
1852 |
-
),
|
1853 |
-
array(
|
1854 |
-
'key' => 'field_acfe_dpt_show_in_admin_bar',
|
1855 |
-
'label' => 'Show in admin bar',
|
1856 |
-
'name' => 'show_in_admin_bar',
|
1857 |
-
'type' => 'true_false',
|
1858 |
-
'instructions' => 'Where to show the post type in the admin menu. show_ui must be true',
|
1859 |
-
'required' => 0,
|
1860 |
-
'conditional_logic' => 0,
|
1861 |
-
'wrapper' => array(
|
1862 |
-
'width' => '',
|
1863 |
-
'class' => '',
|
1864 |
-
'id' => '',
|
1865 |
-
),
|
1866 |
-
'acfe_validate' => '',
|
1867 |
-
'acfe_update' => '',
|
1868 |
-
'acfe_permissions' => '',
|
1869 |
-
'message' => '',
|
1870 |
-
'default_value' => 1,
|
1871 |
-
'ui' => 1,
|
1872 |
-
'ui_on_text' => '',
|
1873 |
-
'ui_off_text' => '',
|
1874 |
-
),
|
1875 |
-
array(
|
1876 |
-
'key' => 'field_acfe_dpt_tab_capability',
|
1877 |
-
'label' => 'Capability',
|
1878 |
-
'name' => '',
|
1879 |
-
'type' => 'tab',
|
1880 |
-
'instructions' => '',
|
1881 |
-
'required' => 0,
|
1882 |
-
'conditional_logic' => 0,
|
1883 |
-
'wrapper' => array(
|
1884 |
-
'width' => '',
|
1885 |
-
'class' => '',
|
1886 |
-
'id' => '',
|
1887 |
-
),
|
1888 |
-
'acfe_permissions' => '',
|
1889 |
-
'placement' => 'top',
|
1890 |
-
'endpoint' => 0,
|
1891 |
-
),
|
1892 |
-
array(
|
1893 |
-
'key' => 'field_acfe_dpt_capability_type',
|
1894 |
-
'label' => 'Capability type',
|
1895 |
-
'name' => 'capability_type',
|
1896 |
-
'type' => 'textarea',
|
1897 |
-
'instructions' => 'The string to use to build the read, edit, and delete capabilities.<br />
|
1898 |
-
May be passed as an array to allow for alternative plurals when using this argument as a base to construct the capabilities, like this:<br /><br />
|
1899 |
-
|
1900 |
-
story<br />
|
1901 |
-
stories',
|
1902 |
-
'required' => 0,
|
1903 |
-
'conditional_logic' => 0,
|
1904 |
-
'wrapper' => array(
|
1905 |
-
'width' => '',
|
1906 |
-
'class' => '',
|
1907 |
-
'id' => '',
|
1908 |
-
),
|
1909 |
-
'acfe_validate' => '',
|
1910 |
-
'acfe_update' => '',
|
1911 |
-
'acfe_permissions' => '',
|
1912 |
-
'default_value' => 'post',
|
1913 |
-
'placeholder' => '',
|
1914 |
-
'maxlength' => '',
|
1915 |
-
'rows' => '',
|
1916 |
-
'new_lines' => '',
|
1917 |
-
),
|
1918 |
-
array(
|
1919 |
-
'key' => 'field_acfe_dpt_capabilities',
|
1920 |
-
'label' => 'Capabilities',
|
1921 |
-
'name' => 'capabilities',
|
1922 |
-
'type' => 'textarea',
|
1923 |
-
'instructions' => 'An array of the capabilities for this post type. Specify capabilities like this:<br /><br />
|
1924 |
-
|
1925 |
-
edit_post<br />
|
1926 |
-
read_post<br />
|
1927 |
-
delete_post<br />
|
1928 |
-
edit_posts<br />
|
1929 |
-
etc...',
|
1930 |
-
'required' => 0,
|
1931 |
-
'conditional_logic' => 0,
|
1932 |
-
'wrapper' => array(
|
1933 |
-
'width' => '',
|
1934 |
-
'class' => '',
|
1935 |
-
'id' => '',
|
1936 |
-
),
|
1937 |
-
'acfe_validate' => '',
|
1938 |
-
'acfe_update' => '',
|
1939 |
-
'acfe_permissions' => '',
|
1940 |
-
'default_value' => '',
|
1941 |
-
'placeholder' => '',
|
1942 |
-
'maxlength' => '',
|
1943 |
-
'rows' => '',
|
1944 |
-
'new_lines' => '',
|
1945 |
-
),
|
1946 |
-
array(
|
1947 |
-
'key' => 'field_acfe_dpt_map_meta_cap',
|
1948 |
-
'label' => 'Map meta cap',
|
1949 |
-
'name' => 'map_meta_cap',
|
1950 |
-
'type' => 'select',
|
1951 |
-
'instructions' => '',
|
1952 |
-
'required' => 0,
|
1953 |
-
'conditional_logic' => 0,
|
1954 |
-
'wrapper' => array(
|
1955 |
-
'width' => '',
|
1956 |
-
'class' => '',
|
1957 |
-
'id' => '',
|
1958 |
-
),
|
1959 |
-
'acfe_validate' => '',
|
1960 |
-
'acfe_update' => '',
|
1961 |
-
'acfe_permissions' => '',
|
1962 |
-
'choices' => array(
|
1963 |
-
'null' => 'Null (default)',
|
1964 |
-
'false' => 'False',
|
1965 |
-
'true' => 'True',
|
1966 |
-
),
|
1967 |
-
'default_value' => array(
|
1968 |
-
0 => 'null',
|
1969 |
-
),
|
1970 |
-
'allow_null' => 0,
|
1971 |
-
'multiple' => 0,
|
1972 |
-
'ui' => 0,
|
1973 |
-
'return_format' => 'value',
|
1974 |
-
'ajax' => 0,
|
1975 |
-
'placeholder' => '',
|
1976 |
-
),
|
1977 |
-
array(
|
1978 |
-
'key' => 'field_acfe_dpt_tab_archive',
|
1979 |
-
'label' => 'Archive',
|
1980 |
-
'name' => '',
|
1981 |
-
'type' => 'tab',
|
1982 |
-
'instructions' => '',
|
1983 |
-
'required' => 0,
|
1984 |
-
'conditional_logic' => 0,
|
1985 |
-
'wrapper' => array(
|
1986 |
-
'width' => '',
|
1987 |
-
'class' => '',
|
1988 |
-
'id' => '',
|
1989 |
-
),
|
1990 |
-
'acfe_permissions' => '',
|
1991 |
-
'placement' => 'top',
|
1992 |
-
'endpoint' => 0,
|
1993 |
-
),
|
1994 |
-
array(
|
1995 |
-
'key' => 'field_acfe_dpt_archive_template',
|
1996 |
-
'label' => 'Template',
|
1997 |
-
'name' => 'acfe_dpt_archive_template',
|
1998 |
-
'type' => 'text',
|
1999 |
-
'instructions' => 'ACF Extended: Which template file to load for the archive query. More informations on <a href="https://developer.wordpress.org/themes/basics/template-hierarchy/">Template hierarchy</a>',
|
2000 |
-
'required' => 0,
|
2001 |
-
'conditional_logic' => 0,
|
2002 |
-
'wrapper' => array(
|
2003 |
-
'width' => '',
|
2004 |
-
'class' => '',
|
2005 |
-
'id' => '',
|
2006 |
-
),
|
2007 |
-
'acfe_validate' => '',
|
2008 |
-
'acfe_update' => '',
|
2009 |
-
'acfe_permissions' => '',
|
2010 |
-
'default_value' => '',
|
2011 |
-
'placeholder' => 'my-template.php',
|
2012 |
-
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
2013 |
-
'append' => '',
|
2014 |
-
'maxlength' => '',
|
2015 |
-
),
|
2016 |
-
array(
|
2017 |
-
'key' => 'field_acfe_dpt_has_archive',
|
2018 |
-
'label' => 'Has archive',
|
2019 |
-
'name' => 'has_archive',
|
2020 |
-
'type' => 'true_false',
|
2021 |
-
'instructions' => 'Enables post type archives.',
|
2022 |
-
'required' => 0,
|
2023 |
-
'conditional_logic' => 0,
|
2024 |
-
'wrapper' => array(
|
2025 |
-
'width' => '',
|
2026 |
-
'class' => '',
|
2027 |
-
'id' => '',
|
2028 |
-
),
|
2029 |
-
'acfe_validate' => '',
|
2030 |
-
'acfe_update' => '',
|
2031 |
-
'acfe_permissions' => '',
|
2032 |
-
'message' => '',
|
2033 |
-
'default_value' => 1,
|
2034 |
-
'ui' => 1,
|
2035 |
-
'ui_on_text' => '',
|
2036 |
-
'ui_off_text' => '',
|
2037 |
-
),
|
2038 |
-
array(
|
2039 |
-
'key' => 'field_acfe_dpt_has_archive_slug',
|
2040 |
-
'label' => 'Slug',
|
2041 |
-
'name' => 'has_archive_slug',
|
2042 |
-
'type' => 'text',
|
2043 |
-
'instructions' => 'Will use post type name as archive slug by default.',
|
2044 |
-
'required' => 0,
|
2045 |
-
'conditional_logic' => array(
|
2046 |
-
array(
|
2047 |
-
array(
|
2048 |
-
'field' => 'field_acfe_dpt_has_archive',
|
2049 |
-
'operator' => '==',
|
2050 |
-
'value' => '1',
|
2051 |
-
),
|
2052 |
-
),
|
2053 |
-
),
|
2054 |
-
'wrapper' => array(
|
2055 |
-
'width' => '',
|
2056 |
-
'class' => '',
|
2057 |
-
'id' => '',
|
2058 |
-
),
|
2059 |
-
'acfe_validate' => '',
|
2060 |
-
'acfe_update' => '',
|
2061 |
-
'acfe_permissions' => '',
|
2062 |
-
'default_value' => '',
|
2063 |
-
'placeholder' => 'Default',
|
2064 |
-
'prepend' => '',
|
2065 |
-
'append' => '',
|
2066 |
-
'maxlength' => '',
|
2067 |
-
),
|
2068 |
-
array(
|
2069 |
-
'key' => 'field_acfe_dpt_archive_posts_per_page',
|
2070 |
-
'label' => 'Posts per page',
|
2071 |
-
'name' => 'acfe_dpt_archive_posts_per_page',
|
2072 |
-
'type' => 'number',
|
2073 |
-
'instructions' => 'ACF Extended: Number of posts to display in the archive page',
|
2074 |
-
'required' => 0,
|
2075 |
-
'conditional_logic' => 0,
|
2076 |
-
'wrapper' => array(
|
2077 |
-
'width' => '',
|
2078 |
-
'class' => '',
|
2079 |
-
'id' => '',
|
2080 |
-
),
|
2081 |
-
'acfe_validate' => '',
|
2082 |
-
'acfe_update' => '',
|
2083 |
-
'acfe_permissions' => '',
|
2084 |
-
'default_value' => 10,
|
2085 |
-
'placeholder' => '',
|
2086 |
-
'prepend' => '',
|
2087 |
-
'append' => '',
|
2088 |
-
'min' => -1,
|
2089 |
-
'max' => '',
|
2090 |
-
'step' => '',
|
2091 |
-
),
|
2092 |
-
array(
|
2093 |
-
'key' => 'field_acfe_dpt_archive_orderby',
|
2094 |
-
'label' => 'Order by',
|
2095 |
-
'name' => 'acfe_dpt_archive_orderby',
|
2096 |
-
'type' => 'text',
|
2097 |
-
'instructions' => 'ACF Extended: Sort retrieved posts by parameter in the archive page. Defaults to \'date (post_date)\'.',
|
2098 |
-
'required' => 0,
|
2099 |
-
'conditional_logic' => 0,
|
2100 |
-
'wrapper' => array(
|
2101 |
-
'width' => '',
|
2102 |
-
'class' => '',
|
2103 |
-
'id' => '',
|
2104 |
-
),
|
2105 |
-
'acfe_validate' => '',
|
2106 |
-
'acfe_update' => array(
|
2107 |
-
'5c9479dec93c4' => array(
|
2108 |
-
'acfe_update_function' => 'sanitize_title',
|
2109 |
-
),
|
2110 |
-
),
|
2111 |
-
'acfe_permissions' => '',
|
2112 |
-
'default_value' => 'date',
|
2113 |
-
'placeholder' => '',
|
2114 |
-
'prepend' => '',
|
2115 |
-
'append' => '',
|
2116 |
-
'maxlength' => '',
|
2117 |
-
),
|
2118 |
-
array(
|
2119 |
-
'key' => 'field_acfe_dpt_archive_order',
|
2120 |
-
'label' => 'Order',
|
2121 |
-
'name' => 'acfe_dpt_archive_order',
|
2122 |
-
'type' => 'select',
|
2123 |
-
'instructions' => 'ACF Extended: Designates the ascending or descending order of the \'orderby\' parameter in the archive page. Defaults to \'DESC\'.',
|
2124 |
-
'required' => 0,
|
2125 |
-
'conditional_logic' => 0,
|
2126 |
-
'wrapper' => array(
|
2127 |
-
'width' => '',
|
2128 |
-
'class' => '',
|
2129 |
-
'id' => '',
|
2130 |
-
),
|
2131 |
-
'acfe_validate' => '',
|
2132 |
-
'acfe_update' => '',
|
2133 |
-
'acfe_permissions' => '',
|
2134 |
-
'choices' => array(
|
2135 |
-
'ASC' => 'ASC',
|
2136 |
-
'DESC' => 'DESC',
|
2137 |
-
),
|
2138 |
-
'default_value' => array(
|
2139 |
-
0 => 'DESC',
|
2140 |
-
),
|
2141 |
-
'allow_null' => 0,
|
2142 |
-
'multiple' => 0,
|
2143 |
-
'ui' => 0,
|
2144 |
-
'return_format' => 'value',
|
2145 |
-
'ajax' => 0,
|
2146 |
-
'placeholder' => '',
|
2147 |
-
),
|
2148 |
-
array(
|
2149 |
-
'key' => 'field_acfe_dpt_tab_single',
|
2150 |
-
'label' => 'Single',
|
2151 |
-
'name' => '',
|
2152 |
-
'type' => 'tab',
|
2153 |
-
'instructions' => '',
|
2154 |
-
'required' => 0,
|
2155 |
-
'conditional_logic' => 0,
|
2156 |
-
'wrapper' => array(
|
2157 |
-
'width' => '',
|
2158 |
-
'class' => '',
|
2159 |
-
'id' => '',
|
2160 |
-
),
|
2161 |
-
'acfe_permissions' => '',
|
2162 |
-
'placement' => 'top',
|
2163 |
-
'endpoint' => 0,
|
2164 |
-
),
|
2165 |
-
array(
|
2166 |
-
'key' => 'field_acfe_dpt_single_template',
|
2167 |
-
'label' => 'Template',
|
2168 |
-
'name' => 'acfe_dpt_single_template',
|
2169 |
-
'type' => 'text',
|
2170 |
-
'instructions' => 'ACF Extended: Which template file to load for the archive query. More informations on <a href="https://developer.wordpress.org/themes/basics/template-hierarchy/">Template hierarchy</a>',
|
2171 |
-
'required' => 0,
|
2172 |
-
'conditional_logic' => 0,
|
2173 |
-
'wrapper' => array(
|
2174 |
-
'width' => '',
|
2175 |
-
'class' => '',
|
2176 |
-
'id' => '',
|
2177 |
-
),
|
2178 |
-
'acfe_validate' => '',
|
2179 |
-
'acfe_update' => '',
|
2180 |
-
'acfe_permissions' => '',
|
2181 |
-
'default_value' => '',
|
2182 |
-
'placeholder' => 'my-template.php',
|
2183 |
-
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
2184 |
-
'append' => '',
|
2185 |
-
'maxlength' => '',
|
2186 |
-
),
|
2187 |
-
array(
|
2188 |
-
'key' => 'field_acfe_dpt_rewrite',
|
2189 |
-
'label' => 'Rewrite',
|
2190 |
-
'name' => 'rewrite',
|
2191 |
-
'type' => 'true_false',
|
2192 |
-
'instructions' => 'Triggers the handling of rewrites for this post type. To prevent rewrites, set to false.',
|
2193 |
-
'required' => 0,
|
2194 |
-
'conditional_logic' => 0,
|
2195 |
-
'wrapper' => array(
|
2196 |
-
'width' => '',
|
2197 |
-
'class' => '',
|
2198 |
-
'id' => '',
|
2199 |
-
),
|
2200 |
-
'acfe_validate' => '',
|
2201 |
-
'acfe_update' => '',
|
2202 |
-
'acfe_permissions' => '',
|
2203 |
-
'message' => '',
|
2204 |
-
'default_value' => 1,
|
2205 |
-
'ui' => 1,
|
2206 |
-
'ui_on_text' => '',
|
2207 |
-
'ui_off_text' => '',
|
2208 |
-
),
|
2209 |
-
array(
|
2210 |
-
'key' => 'field_acfe_dpt_rewrite_args_select',
|
2211 |
-
'label' => 'Rewrite Arguments',
|
2212 |
-
'name' => 'rewrite_args_select',
|
2213 |
-
'type' => 'true_false',
|
2214 |
-
'instructions' => 'Use additional rewrite arguments',
|
2215 |
-
'required' => 0,
|
2216 |
-
'conditional_logic' => array(
|
2217 |
-
array(
|
2218 |
-
array(
|
2219 |
-
'field' => 'field_acfe_dpt_rewrite',
|
2220 |
-
'operator' => '==',
|
2221 |
-
'value' => '1',
|
2222 |
-
),
|
2223 |
-
),
|
2224 |
-
),
|
2225 |
-
'wrapper' => array(
|
2226 |
-
'width' => '',
|
2227 |
-
'class' => '',
|
2228 |
-
'id' => '',
|
2229 |
-
),
|
2230 |
-
'acfe_validate' => '',
|
2231 |
-
'acfe_update' => '',
|
2232 |
-
'acfe_permissions' => '',
|
2233 |
-
'message' => '',
|
2234 |
-
'default_value' => 0,
|
2235 |
-
'ui' => 1,
|
2236 |
-
'ui_on_text' => '',
|
2237 |
-
'ui_off_text' => '',
|
2238 |
-
),
|
2239 |
-
array(
|
2240 |
-
'key' => 'field_acfe_dpt_rewrite_args',
|
2241 |
-
'label' => 'Rewrite Arguments',
|
2242 |
-
'name' => 'rewrite_args',
|
2243 |
-
'type' => 'group',
|
2244 |
-
'instructions' => 'Additional arguments',
|
2245 |
-
'required' => 0,
|
2246 |
-
'conditional_logic' => array(
|
2247 |
-
array(
|
2248 |
-
array(
|
2249 |
-
'field' => 'field_acfe_dpt_rewrite',
|
2250 |
-
'operator' => '==',
|
2251 |
-
'value' => '1',
|
2252 |
-
),
|
2253 |
-
array(
|
2254 |
-
'field' => 'field_acfe_dpt_rewrite_args_select',
|
2255 |
-
'operator' => '==',
|
2256 |
-
'value' => '1',
|
2257 |
-
),
|
2258 |
-
),
|
2259 |
-
),
|
2260 |
-
'wrapper' => array(
|
2261 |
-
'width' => '',
|
2262 |
-
'class' => '',
|
2263 |
-
'id' => '',
|
2264 |
-
),
|
2265 |
-
'acfe_validate' => '',
|
2266 |
-
'acfe_update' => '',
|
2267 |
-
'acfe_permissions' => '',
|
2268 |
-
'layout' => 'row',
|
2269 |
-
'sub_fields' => array(
|
2270 |
-
array(
|
2271 |
-
'key' => 'field_acfe_dpt_rewrite_slug',
|
2272 |
-
'label' => 'Slug',
|
2273 |
-
'name' => 'acfe_dpt_rewrite_slug',
|
2274 |
-
'type' => 'text',
|
2275 |
-
'instructions' => 'Customize the permalink structure slug. Defaults to the post type name value. Should be translatable.',
|
2276 |
-
'required' => 0,
|
2277 |
-
'conditional_logic' => array(
|
2278 |
-
array(
|
2279 |
-
array(
|
2280 |
-
'field' => 'field_acfe_dpt_rewrite_args_select',
|
2281 |
-
'operator' => '==',
|
2282 |
-
'value' => '1',
|
2283 |
-
),
|
2284 |
-
),
|
2285 |
-
),
|
2286 |
-
'wrapper' => array(
|
2287 |
-
'width' => '',
|
2288 |
-
'class' => '',
|
2289 |
-
'id' => '',
|
2290 |
-
),
|
2291 |
-
'acfe_validate' => '',
|
2292 |
-
'acfe_update' => '',
|
2293 |
-
'acfe_permissions' => '',
|
2294 |
-
'default_value' => '',
|
2295 |
-
'placeholder' => 'Default',
|
2296 |
-
'prepend' => '',
|
2297 |
-
'append' => '',
|
2298 |
-
'maxlength' => '',
|
2299 |
-
),
|
2300 |
-
array(
|
2301 |
-
'key' => 'field_acfe_dpt_rewrite_with_front',
|
2302 |
-
'label' => 'With front',
|
2303 |
-
'name' => 'acfe_dpt_rewrite_with_front',
|
2304 |
-
'type' => 'true_false',
|
2305 |
-
'instructions' => 'Should the permalink structure be prepended with the front base. (example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/). Defaults to true.',
|
2306 |
-
'required' => 0,
|
2307 |
-
'conditional_logic' => array(
|
2308 |
-
array(
|
2309 |
-
array(
|
2310 |
-
'field' => 'field_acfe_dpt_rewrite_args_select',
|
2311 |
-
'operator' => '==',
|
2312 |
-
'value' => '1',
|
2313 |
-
),
|
2314 |
-
),
|
2315 |
-
),
|
2316 |
-
'wrapper' => array(
|
2317 |
-
'width' => '',
|
2318 |
-
'class' => '',
|
2319 |
-
'id' => '',
|
2320 |
-
),
|
2321 |
-
'acfe_validate' => '',
|
2322 |
-
'acfe_update' => '',
|
2323 |
-
'acfe_permissions' => '',
|
2324 |
-
'message' => '',
|
2325 |
-
'default_value' => 1,
|
2326 |
-
'ui' => 1,
|
2327 |
-
'ui_on_text' => '',
|
2328 |
-
'ui_off_text' => '',
|
2329 |
-
),
|
2330 |
-
array(
|
2331 |
-
'key' => 'field_acfe_dpt_rewrite_feeds',
|
2332 |
-
'label' => 'Feeds',
|
2333 |
-
'name' => 'feeds',
|
2334 |
-
'type' => 'true_false',
|
2335 |
-
'instructions' => 'Should a feed permalink structure be built for this post type. Defaults to has_archive value.',
|
2336 |
-
'required' => 0,
|
2337 |
-
'conditional_logic' => array(
|
2338 |
-
array(
|
2339 |
-
array(
|
2340 |
-
'field' => 'field_acfe_dpt_rewrite_args_select',
|
2341 |
-
'operator' => '==',
|
2342 |
-
'value' => '1',
|
2343 |
-
),
|
2344 |
-
),
|
2345 |
-
),
|
2346 |
-
'wrapper' => array(
|
2347 |
-
'width' => '',
|
2348 |
-
'class' => '',
|
2349 |
-
'id' => '',
|
2350 |
-
),
|
2351 |
-
'acfe_validate' => '',
|
2352 |
-
'acfe_update' => '',
|
2353 |
-
'acfe_permissions' => '',
|
2354 |
-
'message' => '',
|
2355 |
-
'default_value' => 1,
|
2356 |
-
'ui' => 1,
|
2357 |
-
'ui_on_text' => '',
|
2358 |
-
'ui_off_text' => '',
|
2359 |
-
),
|
2360 |
-
array(
|
2361 |
-
'key' => 'field_acfe_dpt_rewrite_pages',
|
2362 |
-
'label' => 'Pages',
|
2363 |
-
'name' => 'pages',
|
2364 |
-
'type' => 'true_false',
|
2365 |
-
'instructions' => 'Should the permalink structure provide for pagination. Defaults to true.',
|
2366 |
-
'required' => 0,
|
2367 |
-
'conditional_logic' => array(
|
2368 |
-
array(
|
2369 |
-
array(
|
2370 |
-
'field' => 'field_acfe_dpt_rewrite_args_select',
|
2371 |
-
'operator' => '==',
|
2372 |
-
'value' => '1',
|
2373 |
-
),
|
2374 |
-
),
|
2375 |
-
),
|
2376 |
-
'wrapper' => array(
|
2377 |
-
'width' => '',
|
2378 |
-
'class' => '',
|
2379 |
-
'id' => '',
|
2380 |
-
),
|
2381 |
-
'acfe_validate' => '',
|
2382 |
-
'acfe_update' => '',
|
2383 |
-
'acfe_permissions' => '',
|
2384 |
-
'message' => '',
|
2385 |
-
'default_value' => 1,
|
2386 |
-
'ui' => 1,
|
2387 |
-
'ui_on_text' => '',
|
2388 |
-
'ui_off_text' => '',
|
2389 |
-
),
|
2390 |
-
),
|
2391 |
-
),
|
2392 |
-
array(
|
2393 |
-
'key' => 'field_acfe_dpt_tab_admin',
|
2394 |
-
'label' => 'Admin',
|
2395 |
-
'name' => '',
|
2396 |
-
'type' => 'tab',
|
2397 |
-
'instructions' => '',
|
2398 |
-
'required' => 0,
|
2399 |
-
'conditional_logic' => 0,
|
2400 |
-
'wrapper' => array(
|
2401 |
-
'width' => '',
|
2402 |
-
'class' => '',
|
2403 |
-
'id' => '',
|
2404 |
-
),
|
2405 |
-
'acfe_permissions' => '',
|
2406 |
-
'placement' => 'top',
|
2407 |
-
'endpoint' => 0,
|
2408 |
-
),
|
2409 |
-
array(
|
2410 |
-
'key' => 'field_acfe_dpt_admin_posts_per_page',
|
2411 |
-
'label' => 'Posts per page',
|
2412 |
-
'name' => 'acfe_dpt_admin_posts_per_page',
|
2413 |
-
'type' => 'number',
|
2414 |
-
'instructions' => 'ACF Extended: Number of posts to display on the admin list screen',
|
2415 |
-
'required' => 0,
|
2416 |
-
'conditional_logic' => 0,
|
2417 |
-
'wrapper' => array(
|
2418 |
-
'width' => '',
|
2419 |
-
'class' => '',
|
2420 |
-
'id' => '',
|
2421 |
-
),
|
2422 |
-
'acfe_validate' => '',
|
2423 |
-
'acfe_update' => '',
|
2424 |
-
'acfe_permissions' => '',
|
2425 |
-
'default_value' => 10,
|
2426 |
-
'placeholder' => '',
|
2427 |
-
'prepend' => '',
|
2428 |
-
'append' => '',
|
2429 |
-
'min' => -1,
|
2430 |
-
'max' => '',
|
2431 |
-
'step' => '',
|
2432 |
-
),
|
2433 |
-
array(
|
2434 |
-
'key' => 'field_acfe_dpt_admin_orderby',
|
2435 |
-
'label' => 'Order by',
|
2436 |
-
'name' => 'acfe_dpt_admin_orderby',
|
2437 |
-
'type' => 'text',
|
2438 |
-
'instructions' => 'ACF Extended: Sort retrieved posts by parameter in the admin list screen. Defaults to \'date (post_date)\'.',
|
2439 |
-
'required' => 0,
|
2440 |
-
'conditional_logic' => 0,
|
2441 |
-
'wrapper' => array(
|
2442 |
-
'width' => '',
|
2443 |
-
'class' => '',
|
2444 |
-
'id' => '',
|
2445 |
-
),
|
2446 |
-
'acfe_validate' => '',
|
2447 |
-
'acfe_update' => array(
|
2448 |
-
'5c9479dec93c4' => array(
|
2449 |
-
'acfe_update_function' => 'sanitize_title',
|
2450 |
-
),
|
2451 |
-
),
|
2452 |
-
'acfe_permissions' => '',
|
2453 |
-
'default_value' => 'date',
|
2454 |
-
'placeholder' => '',
|
2455 |
-
'prepend' => '',
|
2456 |
-
'append' => '',
|
2457 |
-
'maxlength' => '',
|
2458 |
-
),
|
2459 |
-
array(
|
2460 |
-
'key' => 'field_acfe_dpt_admin_order',
|
2461 |
-
'label' => 'Order',
|
2462 |
-
'name' => 'acfe_dpt_admin_order',
|
2463 |
-
'type' => 'select',
|
2464 |
-
'instructions' => 'ACF Extended: Designates the ascending or descending order of the \'orderby\' parameter in the admin list screen. Defaults to \'DESC\'.',
|
2465 |
-
'required' => 0,
|
2466 |
-
'conditional_logic' => 0,
|
2467 |
-
'wrapper' => array(
|
2468 |
-
'width' => '',
|
2469 |
-
'class' => '',
|
2470 |
-
'id' => '',
|
2471 |
-
),
|
2472 |
-
'acfe_validate' => '',
|
2473 |
-
'acfe_update' => '',
|
2474 |
-
'acfe_permissions' => '',
|
2475 |
-
'choices' => array(
|
2476 |
-
'ASC' => 'ASC',
|
2477 |
-
'DESC' => 'DESC',
|
2478 |
-
),
|
2479 |
-
'default_value' => array(
|
2480 |
-
0 => 'DESC',
|
2481 |
-
),
|
2482 |
-
'allow_null' => 0,
|
2483 |
-
'multiple' => 0,
|
2484 |
-
'ui' => 0,
|
2485 |
-
'return_format' => 'value',
|
2486 |
-
'ajax' => 0,
|
2487 |
-
'placeholder' => '',
|
2488 |
-
),
|
2489 |
-
array(
|
2490 |
-
'key' => 'field_acfe_dpt_tab_rest',
|
2491 |
-
'label' => 'REST',
|
2492 |
-
'name' => '',
|
2493 |
-
'type' => 'tab',
|
2494 |
-
'instructions' => '',
|
2495 |
-
'required' => 0,
|
2496 |
-
'conditional_logic' => 0,
|
2497 |
-
'wrapper' => array(
|
2498 |
-
'width' => '',
|
2499 |
-
'class' => '',
|
2500 |
-
'id' => '',
|
2501 |
-
),
|
2502 |
-
'acfe_permissions' => '',
|
2503 |
-
'placement' => 'top',
|
2504 |
-
'endpoint' => 0,
|
2505 |
-
),
|
2506 |
-
array(
|
2507 |
-
'key' => 'field_acfe_dpt_show_in_rest',
|
2508 |
-
'label' => 'Show in rest',
|
2509 |
-
'name' => 'show_in_rest',
|
2510 |
-
'type' => 'true_false',
|
2511 |
-
'instructions' => 'Whether to expose this post type in the REST API',
|
2512 |
-
'required' => 0,
|
2513 |
-
'conditional_logic' => 0,
|
2514 |
-
'wrapper' => array(
|
2515 |
-
'width' => '',
|
2516 |
-
'class' => '',
|
2517 |
-
'id' => '',
|
2518 |
-
),
|
2519 |
-
'acfe_validate' => '',
|
2520 |
-
'acfe_update' => '',
|
2521 |
-
'acfe_permissions' => '',
|
2522 |
-
'message' => '',
|
2523 |
-
'default_value' => 0,
|
2524 |
-
'ui' => 1,
|
2525 |
-
'ui_on_text' => '',
|
2526 |
-
'ui_off_text' => '',
|
2527 |
-
),
|
2528 |
-
array(
|
2529 |
-
'key' => 'field_acfe_dpt_rest_base',
|
2530 |
-
'label' => 'Rest base',
|
2531 |
-
'name' => 'rest_base',
|
2532 |
-
'type' => 'text',
|
2533 |
-
'instructions' => 'The base slug that this post type will use when accessed using the REST API',
|
2534 |
-
'required' => 0,
|
2535 |
-
'conditional_logic' => 0,
|
2536 |
-
'wrapper' => array(
|
2537 |
-
'width' => '',
|
2538 |
-
'class' => '',
|
2539 |
-
'id' => '',
|
2540 |
-
),
|
2541 |
-
'acfe_validate' => '',
|
2542 |
-
'acfe_update' => '',
|
2543 |
-
'acfe_permissions' => '',
|
2544 |
-
'default_value' => '',
|
2545 |
-
'placeholder' => '',
|
2546 |
-
'prepend' => '',
|
2547 |
-
'append' => '',
|
2548 |
-
'maxlength' => '',
|
2549 |
-
),
|
2550 |
-
array(
|
2551 |
-
'key' => 'field_acfe_dpt_rest_controller_class',
|
2552 |
-
'label' => 'Rest controller class',
|
2553 |
-
'name' => 'rest_controller_class',
|
2554 |
-
'type' => 'text',
|
2555 |
-
'instructions' => 'An optional custom controller to use instead of WP_REST_Posts_Controller. Must be a subclass of WP_REST_Controller',
|
2556 |
-
'required' => 0,
|
2557 |
-
'conditional_logic' => 0,
|
2558 |
-
'wrapper' => array(
|
2559 |
-
'width' => '',
|
2560 |
-
'class' => '',
|
2561 |
-
'id' => '',
|
2562 |
-
),
|
2563 |
-
'acfe_validate' => '',
|
2564 |
-
'acfe_update' => '',
|
2565 |
-
'acfe_permissions' => '',
|
2566 |
-
'default_value' => 'WP_REST_Posts_Controller',
|
2567 |
-
'placeholder' => '',
|
2568 |
-
'prepend' => '',
|
2569 |
-
'append' => '',
|
2570 |
-
'maxlength' => '',
|
2571 |
-
),
|
2572 |
-
),
|
2573 |
-
));
|
2574 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_post_types', true))
|
8 |
+
return;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Register Dynamic Post Type
|
12 |
+
*/
|
13 |
+
add_action('init', 'acfe_dpt_register');
|
14 |
+
function acfe_dpt_register(){
|
15 |
+
|
16 |
+
register_post_type('acfe-dpt', array(
|
17 |
+
'label' => 'Post Types',
|
18 |
+
'description' => 'Post Types',
|
19 |
+
'labels' => array(
|
20 |
+
'name' => 'Post Types',
|
21 |
+
'singular_name' => 'Post Type',
|
22 |
+
'menu_name' => 'Post Types',
|
23 |
+
'edit_item' => 'Edit Post Type',
|
24 |
+
'add_new_item' => 'New Post Type',
|
25 |
+
),
|
26 |
+
'supports' => array('custom-fields'),
|
27 |
+
'hierarchical' => false,
|
28 |
+
'public' => false,
|
29 |
+
'show_ui' => true,
|
30 |
+
'show_in_menu' => 'tools.php',
|
31 |
+
'menu_icon' => 'dashicons-layout',
|
32 |
+
'show_in_admin_bar' => false,
|
33 |
+
'show_in_nav_menus' => false,
|
34 |
+
'can_export' => false,
|
35 |
+
'has_archive' => false,
|
36 |
+
'rewrite' => false,
|
37 |
+
'exclude_from_search' => true,
|
38 |
+
'publicly_queryable' => false,
|
39 |
+
'capabilities' => array(
|
40 |
+
'publish_posts' => acf_get_setting('capability'),
|
41 |
+
'edit_posts' => acf_get_setting('capability'),
|
42 |
+
'edit_others_posts' => acf_get_setting('capability'),
|
43 |
+
'delete_posts' => acf_get_setting('capability'),
|
44 |
+
'delete_others_posts' => acf_get_setting('capability'),
|
45 |
+
'read_private_posts' => acf_get_setting('capability'),
|
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 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* WP Register Post Types
|
56 |
+
*/
|
57 |
+
add_action('init', 'acfe_dpt_registers');
|
58 |
+
function acfe_dpt_registers(){
|
59 |
+
|
60 |
+
$dynamic_post_types = get_option('acfe_dynamic_post_types', array());
|
61 |
+
if(empty($dynamic_post_types))
|
62 |
+
return;
|
63 |
+
|
64 |
+
foreach($dynamic_post_types as $name => $register_args){
|
65 |
+
|
66 |
+
// Register: Execute
|
67 |
+
register_post_type($name, $register_args);
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* ACF Exclude Dynamic Post Type from available post types
|
75 |
+
*/
|
76 |
+
add_filter('acf/get_post_types', 'acfe_dpt_exclude', 10, 2);
|
77 |
+
function acfe_dpt_exclude($post_types, $args){
|
78 |
+
|
79 |
+
if(empty($post_types))
|
80 |
+
return $post_types;
|
81 |
+
|
82 |
+
foreach($post_types as $k => $post_type){
|
83 |
+
|
84 |
+
if($post_type != 'acfe-dpt')
|
85 |
+
continue;
|
86 |
+
|
87 |
+
unset($post_types[$k]);
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
return $post_types;
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Dynamic Post Type Save
|
97 |
+
*/
|
98 |
+
add_action('acf/save_post', 'acfe_dpt_filter_save', 20);
|
99 |
+
function acfe_dpt_filter_save($post_id){
|
100 |
+
|
101 |
+
if(get_post_type($post_id) != 'acfe-dpt')
|
102 |
+
return;
|
103 |
+
|
104 |
+
$title = get_field('label', $post_id);
|
105 |
+
$name = get_field('acfe_dpt_name', $post_id);
|
106 |
+
|
107 |
+
// Update post
|
108 |
+
wp_update_post(array(
|
109 |
+
'ID' => $post_id,
|
110 |
+
'post_title' => $title,
|
111 |
+
'post_name' => $name,
|
112 |
+
));
|
113 |
+
|
114 |
+
// Register Args
|
115 |
+
$label = get_field('label', $post_id);
|
116 |
+
$description = get_field('description', $post_id);
|
117 |
+
$hierarchical = get_field('hierarchical', $post_id);
|
118 |
+
$supports = get_field('supports', $post_id);
|
119 |
+
$taxonomies = acf_get_array(get_field('taxonomies', $post_id));
|
120 |
+
$public = get_field('public', $post_id);
|
121 |
+
$exclude_from_search = get_field('exclude_from_search', $post_id);
|
122 |
+
$publicly_queryable = get_field('publicly_queryable', $post_id);
|
123 |
+
$can_export = get_field('can_export', $post_id);
|
124 |
+
$delete_with_user = get_field('delete_with_user', $post_id);
|
125 |
+
|
126 |
+
// Labels
|
127 |
+
$labels = get_field('labels', $post_id);
|
128 |
+
$labels_args = array();
|
129 |
+
foreach($labels as $k => $l){
|
130 |
+
if(empty($l))
|
131 |
+
continue;
|
132 |
+
|
133 |
+
$labels_args[$k] = $l;
|
134 |
+
}
|
135 |
+
|
136 |
+
// Menu
|
137 |
+
$menu_position = (int) get_field('menu_position', $post_id);
|
138 |
+
$menu_icon = get_field('menu_icon', $post_id);
|
139 |
+
$show_ui = get_field('show_ui', $post_id);
|
140 |
+
$show_in_menu = get_field('show_in_menu', $post_id);
|
141 |
+
$show_in_menu_text = get_field('show_in_menu_text', $post_id);
|
142 |
+
$show_in_nav_menus = get_field('show_in_nav_menus', $post_id);
|
143 |
+
$show_in_admin_bar = get_field('show_in_admin_bar', $post_id);
|
144 |
+
|
145 |
+
// Capability
|
146 |
+
$capability_type = acf_decode_choices(get_field('capability_type', $post_id), true);
|
147 |
+
$capabilities = acf_decode_choices(get_field('capabilities', $post_id), true);
|
148 |
+
$map_meta_cap = get_field('map_meta_cap', $post_id);
|
149 |
+
|
150 |
+
// Archive
|
151 |
+
$archive_template = get_field('acfe_dpt_archive_template', $post_id);
|
152 |
+
$archive_posts_per_page = (int) get_field('acfe_dpt_archive_posts_per_page', $post_id);
|
153 |
+
$archive_orderby = get_field('acfe_dpt_archive_orderby', $post_id);
|
154 |
+
$archive_order = get_field('acfe_dpt_archive_order', $post_id);
|
155 |
+
$has_archive = get_field('has_archive', $post_id);
|
156 |
+
$has_archive_slug = get_field('has_archive_slug', $post_id);
|
157 |
+
|
158 |
+
// Single
|
159 |
+
$single_template = get_field('acfe_dpt_single_template', $post_id);
|
160 |
+
$rewrite = get_field('rewrite', $post_id);
|
161 |
+
$rewrite_args_select = get_field('rewrite_args_select', $post_id);
|
162 |
+
$rewrite_args = get_field('rewrite_args', $post_id);
|
163 |
+
|
164 |
+
// Admin
|
165 |
+
$admin_posts_per_page = (int) get_field('acfe_dpt_admin_posts_per_page', $post_id);
|
166 |
+
$admin_orderby = get_field('acfe_dpt_admin_orderby', $post_id);
|
167 |
+
$admin_order = get_field('acfe_dpt_admin_order', $post_id);
|
168 |
+
|
169 |
+
// REST
|
170 |
+
$show_in_rest = get_field('show_in_rest', $post_id);
|
171 |
+
$rest_base = get_field('rest_base', $post_id);
|
172 |
+
$rest_controller_class = get_field('rest_controller_class', $post_id);
|
173 |
+
|
174 |
+
// Register: Args
|
175 |
+
$register_args = array(
|
176 |
+
'label' => $label,
|
177 |
+
'description' => $description,
|
178 |
+
'hierarchical' => $hierarchical,
|
179 |
+
'supports' => $supports,
|
180 |
+
'taxonomies' => $taxonomies,
|
181 |
+
'public' => $public,
|
182 |
+
'exclude_from_search' => $exclude_from_search,
|
183 |
+
'publicly_queryable' => $publicly_queryable,
|
184 |
+
'can_export' => $can_export,
|
185 |
+
'delete_with_user' => $delete_with_user,
|
186 |
+
|
187 |
+
// Labels
|
188 |
+
'labels' => $labels_args,
|
189 |
+
|
190 |
+
// Menu
|
191 |
+
'menu_position' => $menu_position,
|
192 |
+
'menu_icon' => $menu_icon,
|
193 |
+
'show_ui' => $show_ui,
|
194 |
+
'show_in_menu' => $show_in_menu,
|
195 |
+
'show_in_nav_menus' => $show_in_nav_menus,
|
196 |
+
'show_in_admin_bar' => $show_in_admin_bar,
|
197 |
+
|
198 |
+
// Single
|
199 |
+
'rewrite' => $rewrite,
|
200 |
+
|
201 |
+
// Archive
|
202 |
+
'has_archive' => $has_archive,
|
203 |
+
|
204 |
+
// REST
|
205 |
+
'show_in_rest' => $show_in_rest,
|
206 |
+
'rest_base' => $rest_base,
|
207 |
+
'rest_controller_class' => $rest_controller_class,
|
208 |
+
|
209 |
+
// ACFE: Archive
|
210 |
+
'acfe_archive_template' => $archive_template,
|
211 |
+
'acfe_archive_ppp' => $archive_posts_per_page,
|
212 |
+
'acfe_archive_orderby' => $archive_orderby,
|
213 |
+
'acfe_archive_order' => $archive_order,
|
214 |
+
|
215 |
+
// ACFE: Single
|
216 |
+
'acfe_single_template' => $single_template,
|
217 |
+
|
218 |
+
// ACFE: Admin
|
219 |
+
'acfe_admin_ppp' => $admin_posts_per_page,
|
220 |
+
'acfe_admin_orderby' => $admin_orderby,
|
221 |
+
'acfe_admin_order' => $admin_order,
|
222 |
+
);
|
223 |
+
|
224 |
+
// Has archive: override
|
225 |
+
if($has_archive && $has_archive_slug)
|
226 |
+
$register_args['has_archive'] = $has_archive_slug;
|
227 |
+
|
228 |
+
// Rewrite: override
|
229 |
+
if($rewrite && $rewrite_args_select){
|
230 |
+
$register_args['rewrite'] = array(
|
231 |
+
'slug' => $rewrite_args['acfe_dpt_rewrite_slug'],
|
232 |
+
'with_front' => $rewrite_args['acfe_dpt_rewrite_with_front'],
|
233 |
+
'feeds' => $rewrite_args['feeds'],
|
234 |
+
'pages' => $rewrite_args['pages'],
|
235 |
+
);
|
236 |
+
}
|
237 |
+
|
238 |
+
// Show in menu (text)
|
239 |
+
if($show_in_menu && !empty($show_in_menu_text))
|
240 |
+
$register_args['show_in_menu'] = $show_in_menu_text;
|
241 |
+
|
242 |
+
// Capability type
|
243 |
+
$register_args['capability_type'] = $capability_type;
|
244 |
+
if(is_array($capability_type) && count($capability_type) == 1)
|
245 |
+
$register_args['capability_type'] = $capability_type[0];
|
246 |
+
|
247 |
+
// Capabilities
|
248 |
+
$register_args['capabilities'] = $capabilities;
|
249 |
+
|
250 |
+
// Map meta cap
|
251 |
+
$register_args['map_meta_cap'] = null;
|
252 |
+
|
253 |
+
if($map_meta_cap === 'false')
|
254 |
+
$register_args['map_meta_cap'] = false;
|
255 |
+
|
256 |
+
elseif($map_meta_cap === 'true')
|
257 |
+
$register_args['map_meta_cap'] = true;
|
258 |
+
|
259 |
+
// Get ACFE option
|
260 |
+
$option = get_option('acfe_dynamic_post_types', array());
|
261 |
+
|
262 |
+
// Create ACFE option
|
263 |
+
$option[$name] = $register_args;
|
264 |
+
|
265 |
+
// Sort keys ASC
|
266 |
+
ksort($option);
|
267 |
+
|
268 |
+
// Update ACFE option
|
269 |
+
update_option('acfe_dynamic_post_types', $option);
|
270 |
+
|
271 |
+
// Flush permalinks
|
272 |
+
flush_rewrite_rules();
|
273 |
+
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Dynamic Post Type Status Publish > Trash
|
278 |
+
*/
|
279 |
+
add_action('publish_to_trash', 'acfe_dpt_filter_status_trash');
|
280 |
+
function acfe_dpt_filter_status_trash($post){
|
281 |
+
|
282 |
+
if(get_post_type($post->ID) != 'acfe-dpt')
|
283 |
+
return;
|
284 |
+
|
285 |
+
$post_id = $post->ID;
|
286 |
+
$name = get_field('acfe_dpt_name', $post_id);
|
287 |
+
|
288 |
+
// Get ACFE option
|
289 |
+
$option = get_option('acfe_dynamic_post_types', array());
|
290 |
+
|
291 |
+
// Check ACFE option
|
292 |
+
if(isset($option[$name]))
|
293 |
+
unset($option[$name]);
|
294 |
+
|
295 |
+
// Update ACFE option
|
296 |
+
update_option('acfe_dynamic_post_types', $option);
|
297 |
+
|
298 |
+
// Flush permalinks
|
299 |
+
flush_rewrite_rules();
|
300 |
+
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Dynamic Post Type Status Trash > Publish
|
305 |
+
*/
|
306 |
+
add_action('trash_to_publish', 'acfe_dpt_filter_status_publish');
|
307 |
+
function acfe_dpt_filter_status_publish($post){
|
308 |
+
|
309 |
+
if(get_post_type($post->ID) != 'acfe-dpt')
|
310 |
+
return;
|
311 |
+
|
312 |
+
acfe_dpt_filter_save($post->ID);
|
313 |
+
|
314 |
+
}
|
315 |
+
|
316 |
+
/**
|
317 |
+
* Dynamic Post Type Admin: List
|
318 |
+
*/
|
319 |
+
add_action('pre_get_posts', 'acfe_dpt_admin_pre_get_posts');
|
320 |
+
function acfe_dpt_admin_pre_get_posts($query){
|
321 |
+
|
322 |
+
if(!is_admin() || !$query->is_main_query())
|
323 |
+
return;
|
324 |
+
|
325 |
+
global $pagenow;
|
326 |
+
if($pagenow != 'edit.php')
|
327 |
+
return;
|
328 |
+
|
329 |
+
$post_type = $query->get('post_type');
|
330 |
+
if($post_type != 'acfe-dpt')
|
331 |
+
return;
|
332 |
+
|
333 |
+
$query->set('orderby', 'name');
|
334 |
+
$query->set('order', 'ASC');
|
335 |
+
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Dynamic Post Type Admin: Posts Per Page
|
340 |
+
*/
|
341 |
+
add_filter('edit_posts_per_page', 'acfe_dpt_admin_ppp', 10, 2);
|
342 |
+
function acfe_dpt_admin_ppp($ppp, $post_type){
|
343 |
+
|
344 |
+
if($post_type != 'acfe-dpt')
|
345 |
+
return $ppp;
|
346 |
+
|
347 |
+
global $pagenow;
|
348 |
+
if($pagenow != 'edit.php')
|
349 |
+
return $ppp;
|
350 |
+
|
351 |
+
return 999;
|
352 |
+
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Filter Admin: List
|
357 |
+
*/
|
358 |
+
add_action('pre_get_posts', 'acfe_dpt_filter_admin_list');
|
359 |
+
function acfe_dpt_filter_admin_list($query){
|
360 |
+
|
361 |
+
if(!is_admin() || !$query->is_main_query() || !is_post_type_archive())
|
362 |
+
return;
|
363 |
+
|
364 |
+
$post_type = $query->get('post_type');
|
365 |
+
$post_type_obj = get_post_type_object($post_type);
|
366 |
+
|
367 |
+
$acfe_admin_orderby = (isset($post_type_obj->acfe_admin_orderby) && !empty($post_type_obj->acfe_admin_orderby));
|
368 |
+
$acfe_admin_order = (isset($post_type_obj->acfe_admin_order) && !empty($post_type_obj->acfe_admin_order));
|
369 |
+
|
370 |
+
if($acfe_admin_orderby && (!isset($_REQUEST['orderby']) || empty($_REQUEST['orderby'])))
|
371 |
+
$query->set('orderby', $post_type_obj->acfe_admin_orderby);
|
372 |
+
|
373 |
+
if($acfe_admin_order && (!isset($_REQUEST['order']) || empty($_REQUEST['order'])))
|
374 |
+
$query->set('order', $post_type_obj->acfe_admin_order);
|
375 |
+
|
376 |
+
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Filter Admin: Posts Per Page
|
381 |
+
*/
|
382 |
+
add_filter('edit_posts_per_page', 'acfe_dpt_filter_admin_ppp', 10, 2);
|
383 |
+
function acfe_dpt_filter_admin_ppp($ppp, $post_type){
|
384 |
+
|
385 |
+
global $pagenow;
|
386 |
+
if($pagenow != 'edit.php')
|
387 |
+
return $ppp;
|
388 |
+
|
389 |
+
$post_type_obj = get_post_type_object($post_type);
|
390 |
+
if(!isset($post_type_obj->acfe_admin_ppp) || empty($post_type_obj->acfe_admin_ppp))
|
391 |
+
return $ppp;
|
392 |
+
|
393 |
+
// Check if user has a screen option
|
394 |
+
if(!empty(get_user_option('edit_' . $post_type . '_per_page')))
|
395 |
+
return $ppp;
|
396 |
+
|
397 |
+
return $post_type_obj->acfe_admin_ppp;
|
398 |
+
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Filter Front: List + Posts Per Page
|
403 |
+
*/
|
404 |
+
add_action('pre_get_posts', 'acfe_dpt_filter_front_list');
|
405 |
+
function acfe_dpt_filter_front_list($query){
|
406 |
+
|
407 |
+
if(is_admin() || !$query->is_main_query() || !is_post_type_archive())
|
408 |
+
return;
|
409 |
+
|
410 |
+
$post_type = $query->get('post_type');
|
411 |
+
$post_type_obj = get_post_type_object($post_type);
|
412 |
+
|
413 |
+
$acfe_archive_ppp = (isset($post_type_obj->acfe_archive_ppp) && !empty($post_type_obj->acfe_archive_ppp));
|
414 |
+
$acfe_archive_orderby = (isset($post_type_obj->acfe_archive_orderby) && !empty($post_type_obj->acfe_archive_orderby));
|
415 |
+
$acfe_archive_order = (isset($post_type_obj->acfe_archive_order) && !empty($post_type_obj->acfe_archive_order));
|
416 |
+
|
417 |
+
if($acfe_archive_ppp)
|
418 |
+
$query->set('posts_per_page', $post_type_obj->acfe_archive_ppp);
|
419 |
+
|
420 |
+
if($acfe_archive_orderby)
|
421 |
+
$query->set('orderby', $post_type_obj->acfe_archive_orderby);
|
422 |
+
|
423 |
+
if($acfe_archive_order)
|
424 |
+
$query->set('order', $post_type_obj->acfe_archive_order);
|
425 |
+
|
426 |
+
}
|
427 |
+
|
428 |
+
/**
|
429 |
+
* Filter Front: Template
|
430 |
+
*/
|
431 |
+
add_filter('template_include', 'acfe_dpt_filter_template', 999);
|
432 |
+
function acfe_dpt_filter_template($template){
|
433 |
+
|
434 |
+
if(!is_single() && !is_post_type_archive() && !is_home())
|
435 |
+
return $template;
|
436 |
+
|
437 |
+
// Get_query_var
|
438 |
+
$query_var = get_query_var('post_type', false);
|
439 |
+
if(is_array($query_var) && !empty($query_var))
|
440 |
+
$query_var = $query_var[0];
|
441 |
+
|
442 |
+
foreach(get_post_types(array(), 'objects') as $post_type){
|
443 |
+
|
444 |
+
// Get_query_var check
|
445 |
+
$is_query_var = ($query_var && $query_var === $post_type->name);
|
446 |
+
|
447 |
+
// Get_post_type check
|
448 |
+
$get_post_type = (get_post_type() === $post_type->name);
|
449 |
+
|
450 |
+
// Acfe_archive_template
|
451 |
+
$acfe_archive_template = (isset($post_type->acfe_archive_template) && !empty($post_type->acfe_archive_template));
|
452 |
+
|
453 |
+
// Acfe_archive_template
|
454 |
+
$acfe_single_template = (isset($post_type->acfe_single_template) && !empty($post_type->acfe_single_template));
|
455 |
+
|
456 |
+
// Global check
|
457 |
+
if(!$get_post_type || !$is_query_var || (!$acfe_archive_template && !$acfe_single_template))
|
458 |
+
continue;
|
459 |
+
|
460 |
+
$rule = array();
|
461 |
+
$rule['is_archive'] = is_post_type_archive($post_type->name);
|
462 |
+
$rule['has_archive'] = $post_type->has_archive;
|
463 |
+
$rule['is_single'] = is_singular($post_type->name);
|
464 |
+
|
465 |
+
// Post Exception
|
466 |
+
if($post_type->name === 'post'){
|
467 |
+
$rule['is_archive'] = is_home();
|
468 |
+
$rule['has_archive'] = true;
|
469 |
+
}
|
470 |
+
|
471 |
+
// Archive
|
472 |
+
if($rule['has_archive'] && $rule['is_archive'] && $acfe_archive_template && ($locate = locate_template(array($post_type->acfe_archive_template))))
|
473 |
+
return $locate;
|
474 |
+
|
475 |
+
// Single
|
476 |
+
elseif($rule['is_single'] && $acfe_single_template && ($locate = locate_template(array($post_type->acfe_single_template))))
|
477 |
+
return $locate;
|
478 |
+
}
|
479 |
+
|
480 |
+
return $template;
|
481 |
+
|
482 |
+
}
|
483 |
+
|
484 |
+
/**
|
485 |
+
* Admin List Columns
|
486 |
+
*/
|
487 |
+
add_filter('manage_edit-acfe-dpt_columns', 'acfe_dpt_admin_columns');
|
488 |
+
function acfe_dpt_admin_columns($columns){
|
489 |
+
|
490 |
+
if(isset($columns['date']))
|
491 |
+
unset($columns['date']);
|
492 |
+
|
493 |
+
$columns['acfe-name'] = __('Name');
|
494 |
+
$columns['acfe-taxonomies'] = __('Taxonomies');
|
495 |
+
$columns['acfe-posts'] = __('Posts');
|
496 |
+
|
497 |
+
return $columns;
|
498 |
+
|
499 |
+
}
|
500 |
+
|
501 |
+
/**
|
502 |
+
* Admin List Columns HTML
|
503 |
+
*/
|
504 |
+
add_action('manage_acfe-dpt_posts_custom_column', 'acfe_dpt_admin_columns_html', 10, 2);
|
505 |
+
function acfe_dpt_admin_columns_html($column, $post_id){
|
506 |
+
|
507 |
+
// Name
|
508 |
+
if($column === 'acfe-name'){
|
509 |
+
|
510 |
+
echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . get_field('acfe_dpt_name', $post_id) . '</code>';
|
511 |
+
|
512 |
+
}
|
513 |
+
|
514 |
+
// Taxonomies
|
515 |
+
elseif($column === 'acfe-taxonomies'){
|
516 |
+
|
517 |
+
$taxonomies = acf_get_array(get_field('taxonomies', $post_id));
|
518 |
+
|
519 |
+
if(empty($taxonomies)){
|
520 |
+
|
521 |
+
echo '—';
|
522 |
+
return;
|
523 |
+
|
524 |
+
}
|
525 |
+
|
526 |
+
$taxonomies_names = array();
|
527 |
+
foreach($taxonomies as $taxonomy_slug){
|
528 |
+
|
529 |
+
$taxonomy_obj = get_taxonomy($taxonomy_slug);
|
530 |
+
if(empty($taxonomy_obj))
|
531 |
+
continue;
|
532 |
+
|
533 |
+
$taxonomies_names[] = $taxonomy_obj->label;
|
534 |
+
|
535 |
+
}
|
536 |
+
|
537 |
+
if(empty($taxonomies_names)){
|
538 |
+
|
539 |
+
echo '—';
|
540 |
+
return;
|
541 |
+
|
542 |
+
}
|
543 |
+
|
544 |
+
echo implode(', ', $taxonomies_names);
|
545 |
+
|
546 |
+
}
|
547 |
+
|
548 |
+
// Posts
|
549 |
+
elseif($column === 'acfe-posts'){
|
550 |
+
|
551 |
+
// Name
|
552 |
+
$name = get_field('acfe_dpt_name', $post_id);
|
553 |
+
|
554 |
+
// Count
|
555 |
+
$count = wp_count_posts($name);
|
556 |
+
if(empty($count)){
|
557 |
+
|
558 |
+
echo '—';
|
559 |
+
return;
|
560 |
+
|
561 |
+
}
|
562 |
+
|
563 |
+
$count_publish = $count->publish;
|
564 |
+
|
565 |
+
echo '<a href="' . admin_url('edit.php?post_type=' . $name) . '">' . $count_publish . '</a>';
|
566 |
+
|
567 |
+
}
|
568 |
+
|
569 |
+
}
|
570 |
+
|
571 |
+
/**
|
572 |
+
* Admin List Row Actions
|
573 |
+
*/
|
574 |
+
add_filter('post_row_actions','acfe_dpt_admin_row', 10, 2);
|
575 |
+
function acfe_dpt_admin_row($actions, $post){
|
576 |
+
|
577 |
+
if($post->post_type != 'acfe-dpt' || $post->post_status != 'publish')
|
578 |
+
return $actions;
|
579 |
+
|
580 |
+
$post_id = $post->ID;
|
581 |
+
$name = get_field('acfe_dpt_name', $post_id);
|
582 |
+
|
583 |
+
$actions['acfe_dpt_export_json'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dpt_export&keys=' . $name) . '">' . __('Json') . '</a>';
|
584 |
+
|
585 |
+
return $actions;
|
586 |
+
|
587 |
+
}
|
588 |
+
|
589 |
+
/**
|
590 |
+
* Admin Add Config Button
|
591 |
+
*/
|
592 |
+
add_action('admin_footer-edit.php', 'acfe_dpt_admin_footer');
|
593 |
+
function acfe_dpt_admin_footer(){
|
594 |
+
|
595 |
+
if(!current_user_can(acf_get_setting('capability')))
|
596 |
+
return;
|
597 |
+
|
598 |
+
// Get post type
|
599 |
+
global $typenow;
|
600 |
+
|
601 |
+
// Check post type
|
602 |
+
$post_type = $typenow;
|
603 |
+
if(empty($post_type))
|
604 |
+
return;
|
605 |
+
|
606 |
+
// Post type object
|
607 |
+
$post_type_obj = get_post_type_object($post_type);
|
608 |
+
if(!isset($post_type_obj->acfe_admin_ppp))
|
609 |
+
return;
|
610 |
+
|
611 |
+
// Get Dynamic Post Type Post
|
612 |
+
$acfe_dpt_post_type = get_page_by_path($post_type, 'OBJECT', 'acfe-dpt');
|
613 |
+
|
614 |
+
if(empty($acfe_dpt_post_type))
|
615 |
+
return;
|
616 |
+
|
617 |
+
?>
|
618 |
+
<script type="text/html" id="tmpl-acfe-dpt-title-config">
|
619 |
+
<a href="<?php echo admin_url('post.php?post=' . $acfe_dpt_post_type->ID . '&action=edit'); ?>" class="page-title-action acfe-dpt-admin-config"><span class="dashicons dashicons-admin-generic"></span></a>
|
620 |
+
</script>
|
621 |
+
|
622 |
+
<script type="text/javascript">
|
623 |
+
(function($){
|
624 |
+
|
625 |
+
// Add button
|
626 |
+
$('.wrap .page-title-action').before($('#tmpl-acfe-dpt-title-config').html());
|
627 |
+
|
628 |
+
})(jQuery);
|
629 |
+
</script>
|
630 |
+
<?php
|
631 |
+
|
632 |
+
}
|
633 |
+
|
634 |
+
/**
|
635 |
+
* Admin Disable Name
|
636 |
+
*/
|
637 |
+
add_filter('acf/prepare_field/name=acfe_dpt_name', 'acfe_dpt_admin_disable_name');
|
638 |
+
function acfe_dpt_admin_disable_name($field){
|
639 |
+
|
640 |
+
global $pagenow;
|
641 |
+
if($pagenow != 'post.php')
|
642 |
+
return $field;
|
643 |
+
|
644 |
+
$field['disabled'] = true;
|
645 |
+
|
646 |
+
return $field;
|
647 |
+
|
648 |
+
}
|
649 |
+
|
650 |
+
/**
|
651 |
+
* Admin Validate Name
|
652 |
+
*/
|
653 |
+
add_filter('acf/validate_value/name=acfe_dpt_name', 'acfe_dpt_admin_validate_name', 10, 4);
|
654 |
+
function acfe_dpt_admin_validate_name($valid, $value, $field, $input){
|
655 |
+
|
656 |
+
if(!$valid)
|
657 |
+
return $valid;
|
658 |
+
|
659 |
+
// Reserved WP post types: https://codex.wordpress.org/Function_Reference/register_post_type
|
660 |
+
$excludes = array('post', 'page', 'attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'user_request', 'action', 'author', 'order', 'theme', 'acfe-dpt');
|
661 |
+
if(in_array($value, $excludes))
|
662 |
+
return __('This post type name is reserved');
|
663 |
+
|
664 |
+
// Editing Current Dynamic Post Type
|
665 |
+
$current_post_id = $_POST['_acf_post_id'];
|
666 |
+
$current_post_type = false;
|
667 |
+
if(!empty($current_post_id))
|
668 |
+
$current_post_type = get_field('acfe_dpt_name', $current_post_id);
|
669 |
+
|
670 |
+
if($value === $current_post_type)
|
671 |
+
return $valid;
|
672 |
+
|
673 |
+
// Listing WP Post Types
|
674 |
+
global $wp_post_types;
|
675 |
+
if(!empty($wp_post_types)){
|
676 |
+
foreach($wp_post_types as $post_type){
|
677 |
+
if($value != $post_type->name)
|
678 |
+
continue;
|
679 |
+
|
680 |
+
$valid = __('This post type name already exists');
|
681 |
+
}
|
682 |
+
}
|
683 |
+
|
684 |
+
return $valid;
|
685 |
+
|
686 |
+
}
|
687 |
+
|
688 |
+
add_action('init', 'acfe_dpt_local_field_group');
|
689 |
+
function acfe_dpt_local_field_group(){
|
690 |
+
|
691 |
+
acf_add_local_field_group(array(
|
692 |
+
'key' => 'group_acfe_dynamic_post_type',
|
693 |
+
'title' => __('Dynamic Post Type', 'acfe'),
|
694 |
+
|
695 |
+
'location' => array(
|
696 |
+
array(
|
697 |
+
array(
|
698 |
+
'param' => 'post_type',
|
699 |
+
'operator' => '==',
|
700 |
+
'value' => 'acfe-dpt',
|
701 |
+
),
|
702 |
+
),
|
703 |
+
),
|
704 |
+
|
705 |
+
'menu_order' => 0,
|
706 |
+
'position' => 'normal',
|
707 |
+
'style' => 'default',
|
708 |
+
'label_placement' => 'left',
|
709 |
+
'instruction_placement' => 'label',
|
710 |
+
'hide_on_screen' => '',
|
711 |
+
'active' => 1,
|
712 |
+
'description' => '',
|
713 |
+
|
714 |
+
'fields' => array(
|
715 |
+
array(
|
716 |
+
'key' => 'field_acfe_dpt_tab_general',
|
717 |
+
'label' => 'General',
|
718 |
+
'name' => '',
|
719 |
+
'type' => 'tab',
|
720 |
+
'instructions' => '',
|
721 |
+
'required' => 0,
|
722 |
+
'conditional_logic' => 0,
|
723 |
+
'wrapper' => array(
|
724 |
+
'width' => '',
|
725 |
+
'class' => '',
|
726 |
+
'id' => '',
|
727 |
+
),
|
728 |
+
'acfe_permissions' => '',
|
729 |
+
'placement' => 'top',
|
730 |
+
'endpoint' => 0,
|
731 |
+
),
|
732 |
+
array(
|
733 |
+
'key' => 'field_acfe_dpt_label',
|
734 |
+
'label' => 'Label',
|
735 |
+
'name' => 'label',
|
736 |
+
'type' => 'text',
|
737 |
+
'instructions' => 'General name for the post type, usually plural. Default is Posts/Pages',
|
738 |
+
'required' => 1,
|
739 |
+
'conditional_logic' => 0,
|
740 |
+
'wrapper' => array(
|
741 |
+
'width' => '',
|
742 |
+
'class' => '',
|
743 |
+
'id' => '',
|
744 |
+
),
|
745 |
+
'acfe_validate' => '',
|
746 |
+
'acfe_update' => '',
|
747 |
+
'acfe_permissions' => '',
|
748 |
+
'user_roles' => array(
|
749 |
+
0 => 'all',
|
750 |
+
),
|
751 |
+
'default_value' => '',
|
752 |
+
'placeholder' => '',
|
753 |
+
'prepend' => '',
|
754 |
+
'append' => '',
|
755 |
+
'maxlength' => '',
|
756 |
+
),
|
757 |
+
array(
|
758 |
+
'key' => 'field_acfe_dpt_name',
|
759 |
+
'label' => 'Name',
|
760 |
+
'name' => 'acfe_dpt_name',
|
761 |
+
'type' => 'acfe_slug',
|
762 |
+
'instructions' => 'Post type name. Max. 20 characters, cannot contain capital letters or spaces',
|
763 |
+
'required' => 1,
|
764 |
+
'conditional_logic' => 0,
|
765 |
+
'wrapper' => array(
|
766 |
+
'width' => '',
|
767 |
+
'class' => '',
|
768 |
+
'id' => '',
|
769 |
+
),
|
770 |
+
'acfe_validate' => '',
|
771 |
+
'acfe_update' => '',
|
772 |
+
'acfe_permissions' => '',
|
773 |
+
'default_value' => '',
|
774 |
+
'placeholder' => '',
|
775 |
+
'prepend' => '',
|
776 |
+
'append' => '',
|
777 |
+
'maxlength' => 20,
|
778 |
+
),
|
779 |
+
array(
|
780 |
+
'key' => 'field_acfe_dpt_description',
|
781 |
+
'label' => 'Description',
|
782 |
+
'name' => 'description',
|
783 |
+
'type' => 'text',
|
784 |
+
'instructions' => 'A short descriptive summary of the post type',
|
785 |
+
'required' => 0,
|
786 |
+
'conditional_logic' => 0,
|
787 |
+
'wrapper' => array(
|
788 |
+
'width' => '',
|
789 |
+
'class' => '',
|
790 |
+
'id' => '',
|
791 |
+
),
|
792 |
+
'acfe_validate' => '',
|
793 |
+
'acfe_update' => '',
|
794 |
+
'acfe_permissions' => '',
|
795 |
+
'default_value' => '',
|
796 |
+
'placeholder' => '',
|
797 |
+
'prepend' => '',
|
798 |
+
'append' => '',
|
799 |
+
'maxlength' => '',
|
800 |
+
),
|
801 |
+
array(
|
802 |
+
'key' => 'field_acfe_dpt_hierarchical',
|
803 |
+
'label' => 'Hierarchical',
|
804 |
+
'name' => 'hierarchical',
|
805 |
+
'type' => 'true_false',
|
806 |
+
'instructions' => 'Whether the post type is hierarchical (e.g. page). Allows Parent to be specified. The \'supports\' parameter should contain \'page-attributes\' to show the parent select box on the editor page.',
|
807 |
+
'required' => 0,
|
808 |
+
'conditional_logic' => 0,
|
809 |
+
'wrapper' => array(
|
810 |
+
'width' => '',
|
811 |
+
'class' => '',
|
812 |
+
'id' => '',
|
813 |
+
),
|
814 |
+
'acfe_validate' => '',
|
815 |
+
'acfe_update' => '',
|
816 |
+
'acfe_permissions' => '',
|
817 |
+
'message' => '',
|
818 |
+
'default_value' => 0,
|
819 |
+
'ui' => 1,
|
820 |
+
'ui_on_text' => '',
|
821 |
+
'ui_off_text' => '',
|
822 |
+
),
|
823 |
+
array(
|
824 |
+
'key' => 'field_acfe_dpt_supports',
|
825 |
+
'label' => 'Supports',
|
826 |
+
'name' => 'supports',
|
827 |
+
'type' => 'checkbox',
|
828 |
+
'instructions' => 'An alias for calling add_post_type_support() directly. As of 3.5, boolean false can be passed as value instead of an array to prevent default (title and editor) behavior.',
|
829 |
+
'required' => 0,
|
830 |
+
'conditional_logic' => 0,
|
831 |
+
'wrapper' => array(
|
832 |
+
'width' => '',
|
833 |
+
'class' => '',
|
834 |
+
'id' => '',
|
835 |
+
),
|
836 |
+
'acfe_validate' => '',
|
837 |
+
'acfe_update' => '',
|
838 |
+
'acfe_permissions' => '',
|
839 |
+
'choices' => array(
|
840 |
+
'title' => 'Title',
|
841 |
+
'editor' => 'Editor',
|
842 |
+
'author' => 'Author',
|
843 |
+
'thumbnail' => 'Thumbnail',
|
844 |
+
'excerpt' => 'Excerpt',
|
845 |
+
'trackbacks' => 'Trackbacks',
|
846 |
+
'custom-fields' => 'Custom fields',
|
847 |
+
'comments' => 'Comments',
|
848 |
+
'revisions' => 'Revisions',
|
849 |
+
'page-attributes' => 'Page attributes',
|
850 |
+
'post-formats' => 'Post formats',
|
851 |
+
),
|
852 |
+
'allow_custom' => 1,
|
853 |
+
'save_custom' => 1,
|
854 |
+
'default_value' => array(
|
855 |
+
0 => 'title',
|
856 |
+
1 => 'thumbnail',
|
857 |
+
2 => 'custom-fields',
|
858 |
+
),
|
859 |
+
'layout' => 'vertical',
|
860 |
+
'toggle' => 0,
|
861 |
+
'return_format' => 'value',
|
862 |
+
),
|
863 |
+
array(
|
864 |
+
'key' => 'field_acfe_dpt_taxonomies',
|
865 |
+
'label' => 'Taxonomies',
|
866 |
+
'name' => 'taxonomies',
|
867 |
+
'type' => 'acfe_taxonomies',
|
868 |
+
'instructions' => 'An array of registered taxonomies like category or post_tag that will be used with this post type. This can be used in lieu of calling register_taxonomy_for_object_type() directly. Custom taxonomies still need to be registered with register_taxonomy()',
|
869 |
+
'required' => 0,
|
870 |
+
'conditional_logic' => 0,
|
871 |
+
'wrapper' => array(
|
872 |
+
'width' => '',
|
873 |
+
'class' => '',
|
874 |
+
'id' => '',
|
875 |
+
),
|
876 |
+
'acfe_validate' => '',
|
877 |
+
'acfe_update' => '',
|
878 |
+
'acfe_permissions' => '',
|
879 |
+
'field_type' => 'checkbox',
|
880 |
+
'return_format' => 'name',
|
881 |
+
'multiple' => 0,
|
882 |
+
'allow_null' => 0,
|
883 |
+
),
|
884 |
+
array(
|
885 |
+
'key' => 'field_acfe_dpt_public',
|
886 |
+
'label' => 'Public',
|
887 |
+
'name' => 'public',
|
888 |
+
'type' => 'true_false',
|
889 |
+
'instructions' => 'Controls how the type is visible to authors (show_in_nav_menus, show_ui) and readers (exclude_from_search, publicly_queryable)',
|
890 |
+
'required' => 0,
|
891 |
+
'conditional_logic' => 0,
|
892 |
+
'wrapper' => array(
|
893 |
+
'width' => '',
|
894 |
+
'class' => '',
|
895 |
+
'id' => '',
|
896 |
+
),
|
897 |
+
'acfe_validate' => '',
|
898 |
+
'acfe_update' => '',
|
899 |
+
'acfe_permissions' => '',
|
900 |
+
'message' => '',
|
901 |
+
'default_value' => 1,
|
902 |
+
'ui' => 1,
|
903 |
+
'ui_on_text' => '',
|
904 |
+
'ui_off_text' => '',
|
905 |
+
),
|
906 |
+
array(
|
907 |
+
'key' => 'field_acfe_dpt_exclude_from_search',
|
908 |
+
'label' => 'Exclude from search',
|
909 |
+
'name' => 'exclude_from_search',
|
910 |
+
'type' => 'true_false',
|
911 |
+
'instructions' => 'Whether to exclude posts with this post type from front end search results',
|
912 |
+
'required' => 0,
|
913 |
+
'conditional_logic' => 0,
|
914 |
+
'wrapper' => array(
|
915 |
+
'width' => '',
|
916 |
+
'class' => '',
|
917 |
+
'id' => '',
|
918 |
+
),
|
919 |
+
'acfe_validate' => '',
|
920 |
+
'acfe_update' => '',
|
921 |
+
'acfe_permissions' => '',
|
922 |
+
'message' => '',
|
923 |
+
'default_value' => 0,
|
924 |
+
'ui' => 1,
|
925 |
+
'ui_on_text' => '',
|
926 |
+
'ui_off_text' => '',
|
927 |
+
),
|
928 |
+
array(
|
929 |
+
'key' => 'field_acfe_dpt_publicly_queryable',
|
930 |
+
'label' => 'Publicly queryable',
|
931 |
+
'name' => 'publicly_queryable',
|
932 |
+
'type' => 'true_false',
|
933 |
+
'instructions' => 'Whether queries can be performed on the front end as part of parse_request()',
|
934 |
+
'required' => 0,
|
935 |
+
'conditional_logic' => 0,
|
936 |
+
'wrapper' => array(
|
937 |
+
'width' => '',
|
938 |
+
'class' => '',
|
939 |
+
'id' => '',
|
940 |
+
),
|
941 |
+
'acfe_validate' => '',
|
942 |
+
'acfe_update' => '',
|
943 |
+
'acfe_permissions' => '',
|
944 |
+
'message' => '',
|
945 |
+
'default_value' => 1,
|
946 |
+
'ui' => 1,
|
947 |
+
'ui_on_text' => '',
|
948 |
+
'ui_off_text' => '',
|
949 |
+
),
|
950 |
+
array(
|
951 |
+
'key' => 'field_acfe_dpt_can_export',
|
952 |
+
'label' => 'Can export',
|
953 |
+
'name' => 'can_export',
|
954 |
+
'type' => 'true_false',
|
955 |
+
'instructions' => 'Can this post type be exported',
|
956 |
+
'required' => 0,
|
957 |
+
'conditional_logic' => 0,
|
958 |
+
'wrapper' => array(
|
959 |
+
'width' => '',
|
960 |
+
'class' => '',
|
961 |
+
'id' => '',
|
962 |
+
),
|
963 |
+
'acfe_validate' => '',
|
964 |
+
'acfe_update' => '',
|
965 |
+
'acfe_permissions' => '',
|
966 |
+
'message' => '',
|
967 |
+
'default_value' => 1,
|
968 |
+
'ui' => 1,
|
969 |
+
'ui_on_text' => '',
|
970 |
+
'ui_off_text' => '',
|
971 |
+
),
|
972 |
+
array(
|
973 |
+
'key' => 'field_acfe_dpt_delete_with_user',
|
974 |
+
'label' => 'Delete with user',
|
975 |
+
'name' => 'delete_with_user',
|
976 |
+
'type' => 'select',
|
977 |
+
'instructions' => 'Whether to delete posts of this type when deleting a user. If true, posts of this type belonging to the user will be moved to trash when then user is deleted.<br /><br />If false, posts of this type belonging to the user will not be trashed or deleted. If not set (the default), posts are trashed if the post type supports author. Otherwise posts are not trashed or deleted',
|
978 |
+
'required' => 0,
|
979 |
+
'conditional_logic' => 0,
|
980 |
+
'wrapper' => array(
|
981 |
+
'width' => '',
|
982 |
+
'class' => '',
|
983 |
+
'id' => '',
|
984 |
+
),
|
985 |
+
'acfe_validate' => '',
|
986 |
+
'acfe_update' => '',
|
987 |
+
'acfe_permissions' => '',
|
988 |
+
'choices' => array(
|
989 |
+
'null' => 'Null (default)',
|
990 |
+
'false' => 'False',
|
991 |
+
'true' => 'True',
|
992 |
+
),
|
993 |
+
'default_value' => array(
|
994 |
+
),
|
995 |
+
'allow_null' => 0,
|
996 |
+
'multiple' => 0,
|
997 |
+
'ui' => 0,
|
998 |
+
'return_format' => 'value',
|
999 |
+
'ajax' => 0,
|
1000 |
+
'placeholder' => '',
|
1001 |
+
),
|
1002 |
+
array(
|
1003 |
+
'key' => 'field_acfe_dpt_tab_labels',
|
1004 |
+
'label' => 'Labels',
|
1005 |
+
'name' => '',
|
1006 |
+
'type' => 'tab',
|
1007 |
+
'instructions' => '',
|
1008 |
+
'required' => 0,
|
1009 |
+
'conditional_logic' => 0,
|
1010 |
+
'wrapper' => array(
|
1011 |
+
'width' => '',
|
1012 |
+
'class' => '',
|
1013 |
+
'id' => '',
|
1014 |
+
),
|
1015 |
+
'acfe_permissions' => '',
|
1016 |
+
'placement' => 'top',
|
1017 |
+
'endpoint' => 0,
|
1018 |
+
),
|
1019 |
+
array(
|
1020 |
+
'key' => 'field_acfe_dpt_labels',
|
1021 |
+
'label' => 'Labels',
|
1022 |
+
'name' => 'labels',
|
1023 |
+
'type' => 'group',
|
1024 |
+
'instructions' => 'An array of labels for this post type. By default, post labels are used for non-hierarchical post types and page labels for hierarchical ones.<br /><br />
|
1025 |
+
Default: if empty, \'name\' is set to value of \'label\', and \'singular_name\' is set to value of \'name\'.',
|
1026 |
+
'required' => 0,
|
1027 |
+
'conditional_logic' => 0,
|
1028 |
+
'wrapper' => array(
|
1029 |
+
'width' => '',
|
1030 |
+
'class' => '',
|
1031 |
+
'id' => '',
|
1032 |
+
),
|
1033 |
+
'acfe_permissions' => '',
|
1034 |
+
'layout' => 'row',
|
1035 |
+
'sub_fields' => array(
|
1036 |
+
array(
|
1037 |
+
'key' => 'field_acfe_dpt_singular_name',
|
1038 |
+
'label' => 'Singular name',
|
1039 |
+
'name' => 'singular_name',
|
1040 |
+
'type' => 'text',
|
1041 |
+
'instructions' => '',
|
1042 |
+
'required' => 0,
|
1043 |
+
'conditional_logic' => 0,
|
1044 |
+
'wrapper' => array(
|
1045 |
+
'width' => '',
|
1046 |
+
'class' => '',
|
1047 |
+
'id' => '',
|
1048 |
+
),
|
1049 |
+
'acfe_validate' => '',
|
1050 |
+
'acfe_update' => '',
|
1051 |
+
'acfe_permissions' => '',
|
1052 |
+
'default_value' => '',
|
1053 |
+
'placeholder' => '',
|
1054 |
+
'prepend' => '',
|
1055 |
+
'append' => '',
|
1056 |
+
'maxlength' => '',
|
1057 |
+
),
|
1058 |
+
array(
|
1059 |
+
'key' => 'field_acfe_dpt_add_new',
|
1060 |
+
'label' => 'Add new',
|
1061 |
+
'name' => 'add_new',
|
1062 |
+
'type' => 'text',
|
1063 |
+
'instructions' => '',
|
1064 |
+
'required' => 0,
|
1065 |
+
'conditional_logic' => 0,
|
1066 |
+
'wrapper' => array(
|
1067 |
+
'width' => '',
|
1068 |
+
'class' => '',
|
1069 |
+
'id' => '',
|
1070 |
+
),
|
1071 |
+
'acfe_validate' => '',
|
1072 |
+
'acfe_update' => '',
|
1073 |
+
'acfe_permissions' => '',
|
1074 |
+
'default_value' => '',
|
1075 |
+
'placeholder' => '',
|
1076 |
+
'prepend' => '',
|
1077 |
+
'append' => '',
|
1078 |
+
'maxlength' => '',
|
1079 |
+
),
|
1080 |
+
array(
|
1081 |
+
'key' => 'field_acfe_dpt_add_new_item',
|
1082 |
+
'label' => 'Add new item',
|
1083 |
+
'name' => 'add_new_item',
|
1084 |
+
'type' => 'text',
|
1085 |
+
'instructions' => '',
|
1086 |
+
'required' => 0,
|
1087 |
+
'conditional_logic' => 0,
|
1088 |
+
'wrapper' => array(
|
1089 |
+
'width' => '',
|
1090 |
+
'class' => '',
|
1091 |
+
'id' => '',
|
1092 |
+
),
|
1093 |
+
'acfe_validate' => '',
|
1094 |
+
'acfe_update' => '',
|
1095 |
+
'acfe_permissions' => '',
|
1096 |
+
'default_value' => '',
|
1097 |
+
'placeholder' => '',
|
1098 |
+
'prepend' => '',
|
1099 |
+
'append' => '',
|
1100 |
+
'maxlength' => '',
|
1101 |
+
),
|
1102 |
+
array(
|
1103 |
+
'key' => 'field_acfe_dpt_edit_item',
|
1104 |
+
'label' => 'Edit item',
|
1105 |
+
'name' => 'edit_item',
|
1106 |
+
'type' => 'text',
|
1107 |
+
'instructions' => '',
|
1108 |
+
'required' => 0,
|
1109 |
+
'conditional_logic' => 0,
|
1110 |
+
'wrapper' => array(
|
1111 |
+
'width' => '',
|
1112 |
+
'class' => '',
|
1113 |
+
'id' => '',
|
1114 |
+
),
|
1115 |
+
'acfe_validate' => '',
|
1116 |
+
'acfe_update' => '',
|
1117 |
+
'acfe_permissions' => '',
|
1118 |
+
'default_value' => '',
|
1119 |
+
'placeholder' => '',
|
1120 |
+
'prepend' => '',
|
1121 |
+
'append' => '',
|
1122 |
+
'maxlength' => '',
|
1123 |
+
),
|
1124 |
+
array(
|
1125 |
+
'key' => 'field_acfe_dpt_new_item',
|
1126 |
+
'label' => 'New item',
|
1127 |
+
'name' => 'new_item',
|
1128 |
+
'type' => 'text',
|
1129 |
+
'instructions' => '',
|
1130 |
+
'required' => 0,
|
1131 |
+
'conditional_logic' => 0,
|
1132 |
+
'wrapper' => array(
|
1133 |
+
'width' => '',
|
1134 |
+
'class' => '',
|
1135 |
+
'id' => '',
|
1136 |
+
),
|
1137 |
+
'acfe_validate' => '',
|
1138 |
+
'acfe_update' => '',
|
1139 |
+
'acfe_permissions' => '',
|
1140 |
+
'default_value' => '',
|
1141 |
+
'placeholder' => '',
|
1142 |
+
'prepend' => '',
|
1143 |
+
'append' => '',
|
1144 |
+
'maxlength' => '',
|
1145 |
+
),
|
1146 |
+
array(
|
1147 |
+
'key' => 'field_acfe_dpt_view_item',
|
1148 |
+
'label' => 'View item',
|
1149 |
+
'name' => 'view_item',
|
1150 |
+
'type' => 'text',
|
1151 |
+
'instructions' => '',
|
1152 |
+
'required' => 0,
|
1153 |
+
'conditional_logic' => 0,
|
1154 |
+
'wrapper' => array(
|
1155 |
+
'width' => '',
|
1156 |
+
'class' => '',
|
1157 |
+
'id' => '',
|
1158 |
+
),
|
1159 |
+
'acfe_validate' => '',
|
1160 |
+
'acfe_update' => '',
|
1161 |
+
'acfe_permissions' => '',
|
1162 |
+
'default_value' => '',
|
1163 |
+
'placeholder' => '',
|
1164 |
+
'prepend' => '',
|
1165 |
+
'append' => '',
|
1166 |
+
'maxlength' => '',
|
1167 |
+
),
|
1168 |
+
array(
|
1169 |
+
'key' => 'field_acfe_dpt_view_items',
|
1170 |
+
'label' => 'View items',
|
1171 |
+
'name' => 'view_items',
|
1172 |
+
'type' => 'text',
|
1173 |
+
'instructions' => '',
|
1174 |
+
'required' => 0,
|
1175 |
+
'conditional_logic' => 0,
|
1176 |
+
'wrapper' => array(
|
1177 |
+
'width' => '',
|
1178 |
+
'class' => '',
|
1179 |
+
'id' => '',
|
1180 |
+
),
|
1181 |
+
'acfe_validate' => '',
|
1182 |
+
'acfe_update' => '',
|
1183 |
+
'acfe_permissions' => '',
|
1184 |
+
'default_value' => '',
|
1185 |
+
'placeholder' => '',
|
1186 |
+
'prepend' => '',
|
1187 |
+
'append' => '',
|
1188 |
+
'maxlength' => '',
|
1189 |
+
),
|
1190 |
+
array(
|
1191 |
+
'key' => 'field_acfe_dpt_search_items',
|
1192 |
+
'label' => 'Search items',
|
1193 |
+
'name' => 'search_items',
|
1194 |
+
'type' => 'text',
|
1195 |
+
'instructions' => '',
|
1196 |
+
'required' => 0,
|
1197 |
+
'conditional_logic' => 0,
|
1198 |
+
'wrapper' => array(
|
1199 |
+
'width' => '',
|
1200 |
+
'class' => '',
|
1201 |
+
'id' => '',
|
1202 |
+
),
|
1203 |
+
'acfe_validate' => '',
|
1204 |
+
'acfe_update' => '',
|
1205 |
+
'acfe_permissions' => '',
|
1206 |
+
'default_value' => '',
|
1207 |
+
'placeholder' => '',
|
1208 |
+
'prepend' => '',
|
1209 |
+
'append' => '',
|
1210 |
+
'maxlength' => '',
|
1211 |
+
),
|
1212 |
+
array(
|
1213 |
+
'key' => 'field_acfe_dpt_not_found',
|
1214 |
+
'label' => 'Not found',
|
1215 |
+
'name' => 'not_found',
|
1216 |
+
'type' => 'text',
|
1217 |
+
'instructions' => '',
|
1218 |
+
'required' => 0,
|
1219 |
+
'conditional_logic' => 0,
|
1220 |
+
'wrapper' => array(
|
1221 |
+
'width' => '',
|
1222 |
+
'class' => '',
|
1223 |
+
'id' => '',
|
1224 |
+
),
|
1225 |
+
'acfe_validate' => '',
|
1226 |
+
'acfe_update' => '',
|
1227 |
+
'acfe_permissions' => '',
|
1228 |
+
'default_value' => '',
|
1229 |
+
'placeholder' => '',
|
1230 |
+
'prepend' => '',
|
1231 |
+
'append' => '',
|
1232 |
+
'maxlength' => '',
|
1233 |
+
),
|
1234 |
+
array(
|
1235 |
+
'key' => 'field_acfe_dpt_not_found_in_trash',
|
1236 |
+
'label' => 'Not found in trash',
|
1237 |
+
'name' => 'not_found_in_trash',
|
1238 |
+
'type' => 'text',
|
1239 |
+
'instructions' => '',
|
1240 |
+
'required' => 0,
|
1241 |
+
'conditional_logic' => 0,
|
1242 |
+
'wrapper' => array(
|
1243 |
+
'width' => '',
|
1244 |
+
'class' => '',
|
1245 |
+
'id' => '',
|
1246 |
+
),
|
1247 |
+
'acfe_validate' => '',
|
1248 |
+
'acfe_update' => '',
|
1249 |
+
'acfe_permissions' => '',
|
1250 |
+
'default_value' => '',
|
1251 |
+
'placeholder' => '',
|
1252 |
+
'prepend' => '',
|
1253 |
+
'append' => '',
|
1254 |
+
'maxlength' => '',
|
1255 |
+
),
|
1256 |
+
array(
|
1257 |
+
'key' => 'field_acfe_dpt_parent_item_colon',
|
1258 |
+
'label' => 'Parent item colon',
|
1259 |
+
'name' => 'parent_item_colon',
|
1260 |
+
'type' => 'text',
|
1261 |
+
'instructions' => '',
|
1262 |
+
'required' => 0,
|
1263 |
+
'conditional_logic' => 0,
|
1264 |
+
'wrapper' => array(
|
1265 |
+
'width' => '',
|
1266 |
+
'class' => '',
|
1267 |
+
'id' => '',
|
1268 |
+
),
|
1269 |
+
'acfe_validate' => '',
|
1270 |
+
'acfe_update' => '',
|
1271 |
+
'acfe_permissions' => '',
|
1272 |
+
'default_value' => '',
|
1273 |
+
'placeholder' => '',
|
1274 |
+
'prepend' => '',
|
1275 |
+
'append' => '',
|
1276 |
+
'maxlength' => '',
|
1277 |
+
),
|
1278 |
+
array(
|
1279 |
+
'key' => 'field_acfe_dpt_all_items',
|
1280 |
+
'label' => 'All items',
|
1281 |
+
'name' => 'all_items',
|
1282 |
+
'type' => 'text',
|
1283 |
+
'instructions' => '',
|
1284 |
+
'required' => 0,
|
1285 |
+
'conditional_logic' => 0,
|
1286 |
+
'wrapper' => array(
|
1287 |
+
'width' => '',
|
1288 |
+
'class' => '',
|
1289 |
+
'id' => '',
|
1290 |
+
),
|
1291 |
+
'acfe_validate' => '',
|
1292 |
+
'acfe_update' => '',
|
1293 |
+
'acfe_permissions' => '',
|
1294 |
+
'default_value' => '',
|
1295 |
+
'placeholder' => '',
|
1296 |
+
'prepend' => '',
|
1297 |
+
'append' => '',
|
1298 |
+
'maxlength' => '',
|
1299 |
+
),
|
1300 |
+
array(
|
1301 |
+
'key' => 'field_acfe_dpt_archives',
|
1302 |
+
'label' => 'Archives',
|
1303 |
+
'name' => 'archives',
|
1304 |
+
'type' => 'text',
|
1305 |
+
'instructions' => '',
|
1306 |
+
'required' => 0,
|
1307 |
+
'conditional_logic' => 0,
|
1308 |
+
'wrapper' => array(
|
1309 |
+
'width' => '',
|
1310 |
+
'class' => '',
|
1311 |
+
'id' => '',
|
1312 |
+
),
|
1313 |
+
'acfe_validate' => '',
|
1314 |
+
'acfe_update' => '',
|
1315 |
+
'acfe_permissions' => '',
|
1316 |
+
'default_value' => '',
|
1317 |
+
'placeholder' => '',
|
1318 |
+
'prepend' => '',
|
1319 |
+
'append' => '',
|
1320 |
+
'maxlength' => '',
|
1321 |
+
),
|
1322 |
+
array(
|
1323 |
+
'key' => 'field_acfe_dpt_attributes',
|
1324 |
+
'label' => 'Attributes',
|
1325 |
+
'name' => 'attributes',
|
1326 |
+
'type' => 'text',
|
1327 |
+
'instructions' => '',
|
1328 |
+
'required' => 0,
|
1329 |
+
'conditional_logic' => 0,
|
1330 |
+
'wrapper' => array(
|
1331 |
+
'width' => '',
|
1332 |
+
'class' => '',
|
1333 |
+
'id' => '',
|
1334 |
+
),
|
1335 |
+
'acfe_validate' => '',
|
1336 |
+
'acfe_update' => '',
|
1337 |
+
'acfe_permissions' => '',
|
1338 |
+
'default_value' => '',
|
1339 |
+
'placeholder' => '',
|
1340 |
+
'prepend' => '',
|
1341 |
+
'append' => '',
|
1342 |
+
'maxlength' => '',
|
1343 |
+
),
|
1344 |
+
array(
|
1345 |
+
'key' => 'field_acfe_dpt_insert_into_item',
|
1346 |
+
'label' => 'Insert into item',
|
1347 |
+
'name' => 'insert_into_item',
|
1348 |
+
'type' => 'text',
|
1349 |
+
'instructions' => '',
|
1350 |
+
'required' => 0,
|
1351 |
+
'conditional_logic' => 0,
|
1352 |
+
'wrapper' => array(
|
1353 |
+
'width' => '',
|
1354 |
+
'class' => '',
|
1355 |
+
'id' => '',
|
1356 |
+
),
|
1357 |
+
'acfe_validate' => '',
|
1358 |
+
'acfe_update' => '',
|
1359 |
+
'acfe_permissions' => '',
|
1360 |
+
'default_value' => '',
|
1361 |
+
'placeholder' => '',
|
1362 |
+
'prepend' => '',
|
1363 |
+
'append' => '',
|
1364 |
+
'maxlength' => '',
|
1365 |
+
),
|
1366 |
+
array(
|
1367 |
+
'key' => 'field_acfe_dpt_uploaded_to_this_item',
|
1368 |
+
'label' => 'Uploaded to this item',
|
1369 |
+
'name' => 'uploaded_to_this_item',
|
1370 |
+
'type' => 'text',
|
1371 |
+
'instructions' => '',
|
1372 |
+
'required' => 0,
|
1373 |
+
'conditional_logic' => 0,
|
1374 |
+
'wrapper' => array(
|
1375 |
+
'width' => '',
|
1376 |
+
'class' => '',
|
1377 |
+
'id' => '',
|
1378 |
+
),
|
1379 |
+
'acfe_validate' => '',
|
1380 |
+
'acfe_update' => '',
|
1381 |
+
'acfe_permissions' => '',
|
1382 |
+
'default_value' => '',
|
1383 |
+
'placeholder' => '',
|
1384 |
+
'prepend' => '',
|
1385 |
+
'append' => '',
|
1386 |
+
'maxlength' => '',
|
1387 |
+
),
|
1388 |
+
array(
|
1389 |
+
'key' => 'field_acfe_dpt_featured_image',
|
1390 |
+
'label' => 'Featured image',
|
1391 |
+
'name' => 'featured_image',
|
1392 |
+
'type' => 'text',
|
1393 |
+
'instructions' => '',
|
1394 |
+
'required' => 0,
|
1395 |
+
'conditional_logic' => 0,
|
1396 |
+
'wrapper' => array(
|
1397 |
+
'width' => '',
|
1398 |
+
'class' => '',
|
1399 |
+
'id' => '',
|
1400 |
+
),
|
1401 |
+
'acfe_validate' => '',
|
1402 |
+
'acfe_update' => '',
|
1403 |
+
'acfe_permissions' => '',
|
1404 |
+
'default_value' => '',
|
1405 |
+
'placeholder' => '',
|
1406 |
+
'prepend' => '',
|
1407 |
+
'append' => '',
|
1408 |
+
'maxlength' => '',
|
1409 |
+
),
|
1410 |
+
array(
|
1411 |
+
'key' => 'field_acfe_dpt_set_featured_image',
|
1412 |
+
'label' => 'Set featured image',
|
1413 |
+
'name' => 'set_featured_image',
|
1414 |
+
'type' => 'text',
|
1415 |
+
'instructions' => '',
|
1416 |
+
'required' => 0,
|
1417 |
+
'conditional_logic' => 0,
|
1418 |
+
'wrapper' => array(
|
1419 |
+
'width' => '',
|
1420 |
+
'class' => '',
|
1421 |
+
'id' => '',
|
1422 |
+
),
|
1423 |
+
'acfe_validate' => '',
|
1424 |
+
'acfe_update' => '',
|
1425 |
+
'acfe_permissions' => '',
|
1426 |
+
'default_value' => '',
|
1427 |
+
'placeholder' => '',
|
1428 |
+
'prepend' => '',
|
1429 |
+
'append' => '',
|
1430 |
+
'maxlength' => '',
|
1431 |
+
),
|
1432 |
+
array(
|
1433 |
+
'key' => 'field_acfe_dpt_remove_featured_image',
|
1434 |
+
'label' => 'Remove featured image',
|
1435 |
+
'name' => 'remove_featured_image',
|
1436 |
+
'type' => 'text',
|
1437 |
+
'instructions' => '',
|
1438 |
+
'required' => 0,
|
1439 |
+
'conditional_logic' => 0,
|
1440 |
+
'wrapper' => array(
|
1441 |
+
'width' => '',
|
1442 |
+
'class' => '',
|
1443 |
+
'id' => '',
|
1444 |
+
),
|
1445 |
+
'acfe_validate' => '',
|
1446 |
+
'acfe_update' => '',
|
1447 |
+
'acfe_permissions' => '',
|
1448 |
+
'default_value' => '',
|
1449 |
+
'placeholder' => '',
|
1450 |
+
'prepend' => '',
|
1451 |
+
'append' => '',
|
1452 |
+
'maxlength' => '',
|
1453 |
+
),
|
1454 |
+
array(
|
1455 |
+
'key' => 'field_acfe_dpt_use_featured_image',
|
1456 |
+
'label' => 'Use featured image',
|
1457 |
+
'name' => 'use_featured_image',
|
1458 |
+
'type' => 'text',
|
1459 |
+
'instructions' => '',
|
1460 |
+
'required' => 0,
|
1461 |
+
'conditional_logic' => 0,
|
1462 |
+
'wrapper' => array(
|
1463 |
+
'width' => '',
|
1464 |
+
'class' => '',
|
1465 |
+
'id' => '',
|
1466 |
+
),
|
1467 |
+
'acfe_validate' => '',
|
1468 |
+
'acfe_update' => '',
|
1469 |
+
'acfe_permissions' => '',
|
1470 |
+
'default_value' => '',
|
1471 |
+
'placeholder' => '',
|
1472 |
+
'prepend' => '',
|
1473 |
+
'append' => '',
|
1474 |
+
'maxlength' => '',
|
1475 |
+
),
|
1476 |
+
array(
|
1477 |
+
'key' => 'field_acfe_dpt_menu_name',
|
1478 |
+
'label' => 'Menu name',
|
1479 |
+
'name' => 'menu_name',
|
1480 |
+
'type' => 'text',
|
1481 |
+
'instructions' => '',
|
1482 |
+
'required' => 0,
|
1483 |
+
'conditional_logic' => 0,
|
1484 |
+
'wrapper' => array(
|
1485 |
+
'width' => '',
|
1486 |
+
'class' => '',
|
1487 |
+
'id' => '',
|
1488 |
+
),
|
1489 |
+
'acfe_validate' => '',
|
1490 |
+
'acfe_update' => '',
|
1491 |
+
'acfe_permissions' => '',
|
1492 |
+
'default_value' => '',
|
1493 |
+
'placeholder' => '',
|
1494 |
+
'prepend' => '',
|
1495 |
+
'append' => '',
|
1496 |
+
'maxlength' => '',
|
1497 |
+
),
|
1498 |
+
array(
|
1499 |
+
'key' => 'field_acfe_dpt_filter_items_list',
|
1500 |
+
'label' => 'Filter items list',
|
1501 |
+
'name' => 'filter_items_list',
|
1502 |
+
'type' => 'text',
|
1503 |
+
'instructions' => '',
|
1504 |
+
'required' => 0,
|
1505 |
+
'conditional_logic' => 0,
|
1506 |
+
'wrapper' => array(
|
1507 |
+
'width' => '',
|
1508 |
+
'class' => '',
|
1509 |
+
'id' => '',
|
1510 |
+
),
|
1511 |
+
'acfe_validate' => '',
|
1512 |
+
'acfe_update' => '',
|
1513 |
+
'acfe_permissions' => '',
|
1514 |
+
'default_value' => '',
|
1515 |
+
'placeholder' => '',
|
1516 |
+
'prepend' => '',
|
1517 |
+
'append' => '',
|
1518 |
+
'maxlength' => '',
|
1519 |
+
),
|
1520 |
+
array(
|
1521 |
+
'key' => 'field_acfe_dpt_items_list_navigation',
|
1522 |
+
'label' => 'Items list navigation',
|
1523 |
+
'name' => 'items_list_navigation',
|
1524 |
+
'type' => 'text',
|
1525 |
+
'instructions' => '',
|
1526 |
+
'required' => 0,
|
1527 |
+
'conditional_logic' => 0,
|
1528 |
+
'wrapper' => array(
|
1529 |
+
'width' => '',
|
1530 |
+
'class' => '',
|
1531 |
+
'id' => '',
|
1532 |
+
),
|
1533 |
+
'acfe_validate' => '',
|
1534 |
+
'acfe_update' => '',
|
1535 |
+
'acfe_permissions' => '',
|
1536 |
+
'default_value' => '',
|
1537 |
+
'placeholder' => '',
|
1538 |
+
'prepend' => '',
|
1539 |
+
'append' => '',
|
1540 |
+
'maxlength' => '',
|
1541 |
+
),
|
1542 |
+
array(
|
1543 |
+
'key' => 'field_acfe_dpt_items_list',
|
1544 |
+
'label' => 'Items list',
|
1545 |
+
'name' => 'items_list',
|
1546 |
+
'type' => 'text',
|
1547 |
+
'instructions' => '',
|
1548 |
+
'required' => 0,
|
1549 |
+
'conditional_logic' => 0,
|
1550 |
+
'wrapper' => array(
|
1551 |
+
'width' => '',
|
1552 |
+
'class' => '',
|
1553 |
+
'id' => '',
|
1554 |
+
),
|
1555 |
+
'acfe_validate' => '',
|
1556 |
+
'acfe_update' => '',
|
1557 |
+
'acfe_permissions' => '',
|
1558 |
+
'default_value' => '',
|
1559 |
+
'placeholder' => '',
|
1560 |
+
'prepend' => '',
|
1561 |
+
'append' => '',
|
1562 |
+
'maxlength' => '',
|
1563 |
+
),
|
1564 |
+
array(
|
1565 |
+
'key' => 'field_acfe_dpt_name_admin_bar',
|
1566 |
+
'label' => 'Name admin bar',
|
1567 |
+
'name' => 'name_admin_bar',
|
1568 |
+
'type' => 'text',
|
1569 |
+
'instructions' => '',
|
1570 |
+
'required' => 0,
|
1571 |
+
'conditional_logic' => 0,
|
1572 |
+
'wrapper' => array(
|
1573 |
+
'width' => '',
|
1574 |
+
'class' => '',
|
1575 |
+
'id' => '',
|
1576 |
+
),
|
1577 |
+
'acfe_validate' => '',
|
1578 |
+
'acfe_update' => '',
|
1579 |
+
'acfe_permissions' => '',
|
1580 |
+
'default_value' => '',
|
1581 |
+
'placeholder' => '',
|
1582 |
+
'prepend' => '',
|
1583 |
+
'append' => '',
|
1584 |
+
'maxlength' => '',
|
1585 |
+
),
|
1586 |
+
array(
|
1587 |
+
'key' => 'field_acfe_dpt_item_published',
|
1588 |
+
'label' => 'Item published',
|
1589 |
+
'name' => 'item_published',
|
1590 |
+
'type' => 'text',
|
1591 |
+
'instructions' => '',
|
1592 |
+
'required' => 0,
|
1593 |
+
'conditional_logic' => 0,
|
1594 |
+
'wrapper' => array(
|
1595 |
+
'width' => '',
|
1596 |
+
'class' => '',
|
1597 |
+
'id' => '',
|
1598 |
+
),
|
1599 |
+
'acfe_validate' => '',
|
1600 |
+
'acfe_update' => '',
|
1601 |
+
'acfe_permissions' => '',
|
1602 |
+
'default_value' => '',
|
1603 |
+
'placeholder' => '',
|
1604 |
+
'prepend' => '',
|
1605 |
+
'append' => '',
|
1606 |
+
'maxlength' => '',
|
1607 |
+
),
|
1608 |
+
array(
|
1609 |
+
'key' => 'field_acfe_dpt_item_published_privately',
|
1610 |
+
'label' => 'Item published privately',
|
1611 |
+
'name' => 'item_published_privately',
|
1612 |
+
'type' => 'text',
|
1613 |
+
'instructions' => '',
|
1614 |
+
'required' => 0,
|
1615 |
+
'conditional_logic' => 0,
|
1616 |
+
'wrapper' => array(
|
1617 |
+
'width' => '',
|
1618 |
+
'class' => '',
|
1619 |
+
'id' => '',
|
1620 |
+
),
|
1621 |
+
'acfe_validate' => '',
|
1622 |
+
'acfe_update' => '',
|
1623 |
+
'acfe_permissions' => '',
|
1624 |
+
'default_value' => '',
|
1625 |
+
'placeholder' => '',
|
1626 |
+
'prepend' => '',
|
1627 |
+
'append' => '',
|
1628 |
+
'maxlength' => '',
|
1629 |
+
),
|
1630 |
+
array(
|
1631 |
+
'key' => 'field_acfe_dpt_item_reverted_to_draft',
|
1632 |
+
'label' => 'Item reverted to draft',
|
1633 |
+
'name' => 'item_reverted_to_draft',
|
1634 |
+
'type' => 'text',
|
1635 |
+
'instructions' => '',
|
1636 |
+
'required' => 0,
|
1637 |
+
'conditional_logic' => 0,
|
1638 |
+
'wrapper' => array(
|
1639 |
+
'width' => '',
|
1640 |
+
'class' => '',
|
1641 |
+
'id' => '',
|
1642 |
+
),
|
1643 |
+
'acfe_validate' => '',
|
1644 |
+
'acfe_update' => '',
|
1645 |
+
'acfe_permissions' => '',
|
1646 |
+
'default_value' => '',
|
1647 |
+
'placeholder' => '',
|
1648 |
+
'prepend' => '',
|
1649 |
+
'append' => '',
|
1650 |
+
'maxlength' => '',
|
1651 |
+
),
|
1652 |
+
array(
|
1653 |
+
'key' => 'field_acfe_dpt_item_scheduled',
|
1654 |
+
'label' => 'Item scheduled',
|
1655 |
+
'name' => 'item_scheduled',
|
1656 |
+
'type' => 'text',
|
1657 |
+
'instructions' => '',
|
1658 |
+
'required' => 0,
|
1659 |
+
'conditional_logic' => 0,
|
1660 |
+
'wrapper' => array(
|
1661 |
+
'width' => '',
|
1662 |
+
'class' => '',
|
1663 |
+
'id' => '',
|
1664 |
+
),
|
1665 |
+
'acfe_validate' => '',
|
1666 |
+
'acfe_update' => '',
|
1667 |
+
'acfe_permissions' => '',
|
1668 |
+
'default_value' => '',
|
1669 |
+
'placeholder' => '',
|
1670 |
+
'prepend' => '',
|
1671 |
+
'append' => '',
|
1672 |
+
'maxlength' => '',
|
1673 |
+
),
|
1674 |
+
array(
|
1675 |
+
'key' => 'field_acfe_dpt_item_updated',
|
1676 |
+
'label' => 'Item updated',
|
1677 |
+
'name' => 'item_updated',
|
1678 |
+
'type' => 'text',
|
1679 |
+
'instructions' => '',
|
1680 |
+
'required' => 0,
|
1681 |
+
'conditional_logic' => 0,
|
1682 |
+
'wrapper' => array(
|
1683 |
+
'width' => '',
|
1684 |
+
'class' => '',
|
1685 |
+
'id' => '',
|
1686 |
+
),
|
1687 |
+
'acfe_validate' => '',
|
1688 |
+
'acfe_update' => '',
|
1689 |
+
'acfe_permissions' => '',
|
1690 |
+
'default_value' => '',
|
1691 |
+
'placeholder' => '',
|
1692 |
+
'prepend' => '',
|
1693 |
+
'append' => '',
|
1694 |
+
'maxlength' => '',
|
1695 |
+
),
|
1696 |
+
),
|
1697 |
+
),
|
1698 |
+
array(
|
1699 |
+
'key' => 'field_acfe_dpt_tab_menu',
|
1700 |
+
'label' => 'Menu',
|
1701 |
+
'name' => '',
|
1702 |
+
'type' => 'tab',
|
1703 |
+
'instructions' => '',
|
1704 |
+
'required' => 0,
|
1705 |
+
'conditional_logic' => 0,
|
1706 |
+
'wrapper' => array(
|
1707 |
+
'width' => '',
|
1708 |
+
'class' => '',
|
1709 |
+
'id' => '',
|
1710 |
+
),
|
1711 |
+
'acfe_permissions' => '',
|
1712 |
+
'placement' => 'top',
|
1713 |
+
'endpoint' => 0,
|
1714 |
+
),
|
1715 |
+
array(
|
1716 |
+
'key' => 'field_acfe_dpt_menu_position',
|
1717 |
+
'label' => 'Menu position',
|
1718 |
+
'name' => 'menu_position',
|
1719 |
+
'type' => 'number',
|
1720 |
+
'instructions' => 'The position in the menu order the post type should appear. show_in_menu must be true',
|
1721 |
+
'required' => 0,
|
1722 |
+
'conditional_logic' => 0,
|
1723 |
+
'wrapper' => array(
|
1724 |
+
'width' => '',
|
1725 |
+
'class' => '',
|
1726 |
+
'id' => '',
|
1727 |
+
),
|
1728 |
+
'acfe_validate' => '',
|
1729 |
+
'acfe_update' => '',
|
1730 |
+
'acfe_permissions' => '',
|
1731 |
+
'default_value' => 20,
|
1732 |
+
'placeholder' => '',
|
1733 |
+
'prepend' => '',
|
1734 |
+
'append' => '',
|
1735 |
+
'min' => 0,
|
1736 |
+
'max' => '',
|
1737 |
+
'step' => '',
|
1738 |
+
),
|
1739 |
+
array(
|
1740 |
+
'key' => 'field_acfe_dpt_menu_icon',
|
1741 |
+
'label' => 'Menu icon',
|
1742 |
+
'name' => 'menu_icon',
|
1743 |
+
'type' => 'text',
|
1744 |
+
'instructions' => 'The url to the icon to be used for this menu or the name of the icon from the iconfont (<a href="https://developer.wordpress.org/resource/dashicons/" target="_blank">Dashicons</a>)',
|
1745 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|