Version Description
- Field: Flexible Content - Enhanced Code Base
- Field: Flexible Content - Dynamic Render - Enhanced
get_flexible()
&the_flexible()
functions logic - Field: Flexible Content - Dynamic Render - Enhanced Template, Style & Script files detection. Now detects paths from WP root directory, and from
/wp-content/
directory - Field: Flexible Content - Dynamic Preview - Automatically include the layout
{template}-preview.php
file instead oftemplate.php
, if it is found within the same path - Field: Flexible Content - Dynamic Preview - Automatically enqueue the layout
{style}-preview.css
file in addition ofstyle.css
, if it is found within the same path - Field: Flexible Content - Dynamic Preview - Automatically enqueue the layout
{script}-preview.js
file instead ofscript.js
, if it is found within the same path - Field: Flexible Content - Added
filter('acfe/flexible/prepend/template/name=my_flexible', $path, $flexible, $layout)
and its variations to alter the field's setting prepend (display only) - Field: Flexible Content - Added
filter('acfe/flexible/prepend/style/name=my_flexible', $path, $flexible, $layout)
and its variations to alter the field's setting prepend (display only) - Field: Flexible Content - Added
filter('acfe/flexible/prepend/script/name=my_flexible', $path, $flexible, $layout)
and its variations to alter the field's setting prepend (display only) - Field: Flexible Content - Deprecated
acfe/flexible/layout/thumbnail/layout=my_layout
hooks and its variations. Useacfe/flexible/thumbnail/layout=my_layout
instead - Field: Flexible Content - Deprecated
acfe/flexible/layout/render/template/layout=my_layout
hooks and its variations. Useacfe/flexible/render/template/layout=my_layout
instead - Field: Flexible Content - Deprecated
acfe/flexible/layout/render/before_template/layout=my_layout
hooks and its variations. Useacfe/flexible/render/before_template/layout=my_layout
instead - Field: Flexible Content - Deprecated
acfe/flexible/layout/render/after_template/layout=my_layout
hooks and its variations. Useacfe/flexible/render/after_template/layout=my_layout
instead - Field: Flexible Content - Deprecated
acfe/flexible/layout/render/style/layout=my_layout
hooks and its variations. Useacfe/flexible/render/style/layout=my_layout
instead - Field: Flexible Content - Deprecated
acfe/flexible/layout/render/script/layout=my_layout
hooks and its variations. Useacfe/flexible/render/script/layout=my_layout
instead - Field: Flexible Content - Deprecated
acfe/flexible/layout/enqueue/layout=my_layout
hooks and its variations. Useacfe/flexible/enqueue/layout=my_layout
instead - Field: Flexible Content - Deprecated
acfe/flexible/preview
hooks and its variations - Module: Dynamic Block Types - The "Template Render" setting is now independant from the theme
- Module: Dynamic Block Types - Added
filter('acfe/block_type/prepend/template/name=my-block-type', $path, name)
and its variations to alter the field's setting prepend (display only) - Module: Dynamic Block Types - Added
filter('acfe/block_type/prepend/style/name=my-block-type', $path, name)
and its variations to alter the field's setting prepend (display only) - Module: Dynamic Block Types - Added
filter('acfe/block_type/prepend/script/name=my-block-type', $path, name)
and its variations to alter the field's setting prepend (display only) - Module: Post Type Archive Page -
have_archive()
now allows to pass the post type name. Usage example:while(have_archive('my-post-type')): the_archive()
- Module: Multilang - Enhanced Options Pages Post ID detection
- Module: Multilang - Added "Post Type List" & "Taxonomy List" Locations compatibility
- Module: Multilang - Fixed the "Disable module" setting which wasn't working correctly
- Module: Multilang - Fixed Polylang Ajax language detection
- General: Enhanced
acfe_update_setting()
,acfe_get_setting()
functions andfiler('acfe/settings/{name}')
hook - General: Removed
ACFE_THEME_PATH
&ACFE_THEME_URL
constants - General: Added
acfe/theme_path
,acfe/theme_url
&acfe/theme_folder
settings - General: The default
acfe/php_save
,acfe/php_load
&acfe/theme_folder
settings are now generated based on the newacfe/theme_path
&acfe/theme_url
settings - General: The
acfe/theme_folder
setting is now used to preprend Flexible Content & Block Types render fields settings (Display only)
Download this release
Release Info
Developer | hwk-fr |
Plugin | Advanced Custom Fields: Extended |
Version | 0.8.6.7 |
Comparing to | |
See all releases |
Code changes from version 0.8.6.6 to 0.8.6.7
- acf-extended.php +44 -23
- includes/admin/settings.php +23 -5
- includes/admin/tools/dbt-import.php +11 -20
- includes/core/compatibility.php +44 -9
- includes/core/helpers.php +351 -135
- includes/core/multilang.php +259 -139
- includes/fields/field-advanced-link.php +3 -4
- includes/fields/field-flexible-content.php +91 -115
- includes/modules/autosync.php +2 -0
- includes/modules/dynamic-block-type.php +89 -16
- includes/modules/dynamic-post-type.php +2 -2
- includes/modules/dynamic-taxonomy.php +1 -1
- includes/modules/form/actions/email.php +3 -3
- readme.txt +112 -59
acf-extended.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
* Description: Enhancement Suite which improves Advanced Custom Fields administration
|
5 |
-
* Version: 0.8.6.
|
6 |
* Author: ACF Extended
|
7 |
* Author URI: https://www.acf-extended.com
|
8 |
* Text Domain: acfe
|
@@ -16,7 +16,7 @@ if(!class_exists('ACFE')):
|
|
16 |
class ACFE{
|
17 |
|
18 |
// Version
|
19 |
-
var $version = '0.8.6.
|
20 |
|
21 |
// Settings
|
22 |
var $settings = array();
|
@@ -42,28 +42,29 @@ class ACFE{
|
|
42 |
$this->define('ACFE_PATH', plugin_dir_path(__FILE__));
|
43 |
$this->define('ACFE_VERSION', $this->version);
|
44 |
$this->define('ACFE_BASENAME', plugin_basename(__FILE__));
|
45 |
-
$this->define('ACFE_THEME_PATH', get_stylesheet_directory());
|
46 |
-
$this->define('ACFE_THEME_URL', get_stylesheet_directory_uri());
|
47 |
|
48 |
-
//
|
49 |
$this->settings = array(
|
50 |
-
'
|
51 |
-
'
|
52 |
-
'
|
53 |
-
'
|
54 |
-
'
|
55 |
-
'
|
56 |
-
'
|
57 |
-
'
|
58 |
-
'
|
59 |
-
'
|
60 |
-
'
|
61 |
-
'
|
62 |
-
'
|
63 |
-
'
|
64 |
-
'
|
65 |
-
'
|
66 |
-
'
|
|
|
|
|
|
|
67 |
);
|
68 |
|
69 |
// Init
|
@@ -85,10 +86,30 @@ class ACFE{
|
|
85 |
// Settings
|
86 |
foreach($this->settings as $name => $value){
|
87 |
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
}
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
// Load
|
93 |
add_action('acf/init', array($this, 'includes'), 99);
|
94 |
|
2 |
/**
|
3 |
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
* Description: Enhancement Suite which improves Advanced Custom Fields administration
|
5 |
+
* Version: 0.8.6.7
|
6 |
* Author: ACF Extended
|
7 |
* Author URI: https://www.acf-extended.com
|
8 |
* Text Domain: acfe
|
16 |
class ACFE{
|
17 |
|
18 |
// Version
|
19 |
+
var $version = '0.8.6.7';
|
20 |
|
21 |
// Settings
|
22 |
var $settings = array();
|
42 |
$this->define('ACFE_PATH', plugin_dir_path(__FILE__));
|
43 |
$this->define('ACFE_VERSION', $this->version);
|
44 |
$this->define('ACFE_BASENAME', plugin_basename(__FILE__));
|
|
|
|
|
45 |
|
46 |
+
// Settings
|
47 |
$this->settings = array(
|
48 |
+
'url' => plugin_dir_url(__FILE__),
|
49 |
+
'theme_path' => get_stylesheet_directory(),
|
50 |
+
'theme_url' => get_stylesheet_directory_uri(),
|
51 |
+
'theme_folder' => false,
|
52 |
+
'php' => true,
|
53 |
+
'php_save' => false,
|
54 |
+
'php_load' => false,
|
55 |
+
'php_found' => false,
|
56 |
+
'json_found' => false,
|
57 |
+
'dev' => false,
|
58 |
+
'modules/author' => true,
|
59 |
+
'modules/dynamic_block_types' => true,
|
60 |
+
'modules/dynamic_forms' => true,
|
61 |
+
'modules/dynamic_options_pages' => true,
|
62 |
+
'modules/dynamic_post_types' => true,
|
63 |
+
'modules/dynamic_taxonomies' => true,
|
64 |
+
'modules/multilang' => true,
|
65 |
+
'modules/options' => true,
|
66 |
+
'modules/single_meta' => false,
|
67 |
+
'modules/ui' => true,
|
68 |
);
|
69 |
|
70 |
// Init
|
86 |
// Settings
|
87 |
foreach($this->settings as $name => $value){
|
88 |
|
89 |
+
// update
|
90 |
+
acf_update_setting("acfe/{$name}", $value);
|
91 |
+
|
92 |
+
// filter
|
93 |
+
if(!has_filter("acfe/settings/{$name}"))
|
94 |
+
continue;
|
95 |
+
|
96 |
+
add_filter("acf/settings/acfe/{$name}", function($v) use($name){
|
97 |
+
|
98 |
+
return apply_filters("acfe/settings/{$name}", $v);
|
99 |
+
|
100 |
+
}, 5);
|
101 |
|
102 |
}
|
103 |
|
104 |
+
// Theme
|
105 |
+
$theme_path = acf_get_setting('acfe/theme_path');
|
106 |
+
$theme_url = acf_get_setting('acfe/theme_url');
|
107 |
+
|
108 |
+
// Additional Settings
|
109 |
+
acf_update_setting('acfe/php_save', "{$theme_path}/acfe-php");
|
110 |
+
acf_update_setting('acfe/php_load', array("{$theme_path}/acfe-php"));
|
111 |
+
acf_update_setting('acfe/theme_folder', parse_url($theme_url, PHP_URL_PATH));
|
112 |
+
|
113 |
// Load
|
114 |
add_action('acf/init', array($this, 'includes'), 99);
|
115 |
|
includes/admin/settings.php
CHANGED
@@ -351,31 +351,49 @@ function acfe_admin_settings_html(){
|
|
351 |
'name' => 'acfe/php',
|
352 |
'label' => 'PHP',
|
353 |
'value' => '<code>' . (acf_get_setting('acfe/php') ? __('True'): __('False')) . '</code>',
|
354 |
-
'description' => '
|
355 |
),
|
356 |
array(
|
357 |
'name' => 'acfe/php_found',
|
358 |
'label' => 'PHP: Found',
|
359 |
'value' => '<code>' . (acf_get_setting('acfe/php_found') ? __('True'): __('False')) . '</code>',
|
360 |
-
'description' => '
|
361 |
),
|
362 |
array(
|
363 |
'name' => 'acfe/php_save',
|
364 |
'label' => 'PHP: Save',
|
365 |
'value' => '<code>' . acf_get_setting('acfe/php_save') . '</code>',
|
366 |
-
'description' => '
|
367 |
),
|
368 |
array(
|
369 |
'name' => 'acfe/php_load',
|
370 |
'label' => 'PHP: Load',
|
371 |
'value' => '<code>' . $load_php_text . '</code>',
|
372 |
-
'description' => 'PHP
|
373 |
),
|
374 |
array(
|
375 |
'name' => 'acfe/json_found',
|
376 |
'label' => 'Json: Found',
|
377 |
'value' => '<code>' . (acf_get_setting('acfe/json_found') ? __('True'): __('False')) . '</code>',
|
378 |
-
'description' => '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
),
|
380 |
);
|
381 |
?>
|
351 |
'name' => 'acfe/php',
|
352 |
'label' => 'PHP',
|
353 |
'value' => '<code>' . (acf_get_setting('acfe/php') ? __('True'): __('False')) . '</code>',
|
354 |
+
'description' => 'Whenever PHP AutoSync is enabled'
|
355 |
),
|
356 |
array(
|
357 |
'name' => 'acfe/php_found',
|
358 |
'label' => 'PHP: Found',
|
359 |
'value' => '<code>' . (acf_get_setting('acfe/php_found') ? __('True'): __('False')) . '</code>',
|
360 |
+
'description' => 'Whenever PHP AutoSync folder has been found, based on acfe/php_load setting'
|
361 |
),
|
362 |
array(
|
363 |
'name' => 'acfe/php_save',
|
364 |
'label' => 'PHP: Save',
|
365 |
'value' => '<code>' . acf_get_setting('acfe/php_save') . '</code>',
|
366 |
+
'description' => 'PHP AutoSync saving path'
|
367 |
),
|
368 |
array(
|
369 |
'name' => 'acfe/php_load',
|
370 |
'label' => 'PHP: Load',
|
371 |
'value' => '<code>' . $load_php_text . '</code>',
|
372 |
+
'description' => 'PHP AutoSync loading path'
|
373 |
),
|
374 |
array(
|
375 |
'name' => 'acfe/json_found',
|
376 |
'label' => 'Json: Found',
|
377 |
'value' => '<code>' . (acf_get_setting('acfe/json_found') ? __('True'): __('False')) . '</code>',
|
378 |
+
'description' => 'Whenever Json Sync folder has been found, based on load_json setting'
|
379 |
+
),
|
380 |
+
array(
|
381 |
+
'name' => 'acfe/theme_path',
|
382 |
+
'label' => 'Theme: Path',
|
383 |
+
'value' => '<code>' . acf_get_setting('acfe/theme_path') . '</code>',
|
384 |
+
'description' => 'Detected Theme Path'
|
385 |
+
),
|
386 |
+
array(
|
387 |
+
'name' => 'acfe/theme_url',
|
388 |
+
'label' => 'Theme: URL',
|
389 |
+
'value' => '<code>' . acf_get_setting('acfe/theme_url') . '</code>',
|
390 |
+
'description' => 'Detected Theme URL'
|
391 |
+
),
|
392 |
+
array(
|
393 |
+
'name' => 'acfe/theme_folder',
|
394 |
+
'label' => 'Theme: Folder',
|
395 |
+
'value' => '<code>' . acf_get_setting('acfe/theme_folder') . '</code>',
|
396 |
+
'description' => 'Detected Theme Folder'
|
397 |
),
|
398 |
);
|
399 |
?>
|
includes/admin/tools/dbt-import.php
CHANGED
@@ -107,27 +107,18 @@ class ACFE_Admin_Tool_Import_DBT extends ACF_Admin_Tool{
|
|
107 |
}
|
108 |
|
109 |
// Register Args
|
110 |
-
update_field('name',
|
111 |
-
update_field('description',
|
112 |
-
update_field('category',
|
113 |
-
update_field('keywords',
|
114 |
-
update_field('post_types',
|
115 |
-
update_field('mode',
|
116 |
-
update_field('align',
|
117 |
update_field('render_callback', $args['render_callback'], $post_id);
|
118 |
-
update_field('enqueue_assets',
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
update_field('render_template', str_replace(ACFE_THEME_PATH . '/', '', $args['render_template']), $post_id);
|
123 |
-
|
124 |
-
// Enqueue Style
|
125 |
-
if(!empty($args['enqueue_style']))
|
126 |
-
update_field('enqueue_style', str_replace(ACFE_THEME_URL . '/', '', $args['enqueue_style']), $post_id);
|
127 |
-
|
128 |
-
// Enqueue Script
|
129 |
-
if(!empty($args['enqueue_script']))
|
130 |
-
update_field('enqueue_script', str_replace(ACFE_THEME_URL . '/', '', $args['enqueue_script']), $post_id);
|
131 |
|
132 |
// Align
|
133 |
if(empty($args['align']))
|
107 |
}
|
108 |
|
109 |
// Register Args
|
110 |
+
update_field('name', $name, $post_id);
|
111 |
+
update_field('description', $args['description'], $post_id);
|
112 |
+
update_field('category', $args['category'], $post_id);
|
113 |
+
update_field('keywords', acf_encode_choices($args['keywords'], false), $post_id);
|
114 |
+
update_field('post_types', $args['post_types'], $post_id);
|
115 |
+
update_field('mode', $args['mode'], $post_id);
|
116 |
+
update_field('align', $args['align'], $post_id);
|
117 |
update_field('render_callback', $args['render_callback'], $post_id);
|
118 |
+
update_field('enqueue_assets', $args['enqueue_assets'], $post_id);
|
119 |
+
update_field('render_template', $args['render_template'], $post_id);
|
120 |
+
update_field('enqueue_style', $args['enqueue_style'], $post_id);
|
121 |
+
update_field('enqueue_script', $args['enqueue_script'], $post_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
// Align
|
124 |
if(empty($args['align']))
|
includes/core/compatibility.php
CHANGED
@@ -43,17 +43,19 @@ class acfe_compatibility{
|
|
43 |
acf_update_setting('acfe/php_found', acf_get_setting('php_found'));
|
44 |
}
|
45 |
|
46 |
-
add_filter('acf/validate_field_group',
|
47 |
-
add_filter('acf/validate_field',
|
48 |
|
49 |
-
add_filter('acf/validate_field/type=group',
|
50 |
-
add_filter('acf/validate_field/type=clone',
|
51 |
-
add_filter('acfe/load_fields/type=flexible_content',
|
52 |
|
53 |
-
add_filter('
|
54 |
-
|
55 |
-
add_filter('
|
56 |
-
|
|
|
|
|
57 |
|
58 |
}
|
59 |
|
@@ -171,6 +173,39 @@ class acfe_compatibility{
|
|
171 |
|
172 |
return $fields;
|
173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
}
|
175 |
|
176 |
/**
|
43 |
acf_update_setting('acfe/php_found', acf_get_setting('php_found'));
|
44 |
}
|
45 |
|
46 |
+
add_filter('acf/validate_field_group', array($this, 'field_group_location_list'), 20);
|
47 |
+
add_filter('acf/validate_field', array($this, 'field_acfe_update'), 20);
|
48 |
|
49 |
+
add_filter('acf/validate_field/type=group', array($this, 'field_seamless_style'), 20);
|
50 |
+
add_filter('acf/validate_field/type=clone', array($this, 'field_seamless_style'), 20);
|
51 |
+
add_filter('acfe/load_fields/type=flexible_content', array($this, 'field_flexible_settings_title'), 20, 2);
|
52 |
|
53 |
+
add_filter('acf/prepare_field/name=acfe_flexible_category', array($this, 'field_flexible_layout_categories'), 10, 2);
|
54 |
+
|
55 |
+
add_filter('pto/posts_orderby/ignore', array($this, 'pto_acf_field_group'), 10, 3);
|
56 |
+
add_action('admin_menu', array($this, 'cotto_submenu'), 999);
|
57 |
+
add_filter('rank_math/metabox/priority', array($this, 'rankmath_metaboxes_priority'));
|
58 |
+
add_filter('wpseo_metabox_prio', array($this, 'yoast_metaboxes_priority'));
|
59 |
|
60 |
}
|
61 |
|
173 |
|
174 |
return $fields;
|
175 |
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* ACF Extended: 0.8.6.7
|
180 |
+
* Field Flexible Content: Compatibility for Layout Categories
|
181 |
+
*/
|
182 |
+
function field_flexible_layout_categories($field){
|
183 |
+
|
184 |
+
$value = acf_maybe_get($field, 'value');
|
185 |
+
|
186 |
+
if(empty($value))
|
187 |
+
return $field;
|
188 |
+
|
189 |
+
if(is_string($value)){
|
190 |
+
|
191 |
+
$explode = explode('|', $value);
|
192 |
+
|
193 |
+
$choices = array();
|
194 |
+
|
195 |
+
foreach($explode as $v){
|
196 |
+
|
197 |
+
$v = trim($v);
|
198 |
+
$choices[$v] = $v;
|
199 |
+
|
200 |
+
}
|
201 |
+
|
202 |
+
$field['choices'] = $choices;
|
203 |
+
$field['value'] = $choices;
|
204 |
+
|
205 |
+
}
|
206 |
+
|
207 |
+
return $field;
|
208 |
+
|
209 |
}
|
210 |
|
211 |
/**
|
includes/core/helpers.php
CHANGED
@@ -11,27 +11,43 @@ if(!function_exists('get_flexible')){
|
|
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 |
-
|
20 |
-
global $is_preview;
|
21 |
-
$is_preview = false;
|
22 |
-
|
23 |
-
// Actions
|
24 |
-
do_action('acfe/flexible/enqueue', $field, $is_preview);
|
25 |
-
do_action('acfe/flexible/enqueue/name=' . $field['_name'], $field, $is_preview);
|
26 |
-
do_action('acfe/flexible/enqueue/key=' . $field['key'], $field, $is_preview);
|
27 |
|
28 |
ob_start();
|
29 |
-
|
30 |
while(have_rows($selector, $post_id)): the_row();
|
31 |
-
|
32 |
// Vars
|
33 |
-
$
|
34 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
// Render: HTML Comment
|
37 |
echo "\n" . '<!-- ' . $layout['label'] . ' -->' . "\n";
|
@@ -107,13 +123,37 @@ function the_setting(){
|
|
107 |
*/
|
108 |
if(!function_exists('have_archive')){
|
109 |
|
110 |
-
$
|
111 |
-
function have_archive(){
|
112 |
|
113 |
-
global $acfe_archive_i;
|
114 |
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
return true;
|
|
|
|
|
117 |
|
118 |
remove_filter('acf/pre_load_post_id', 'acfe_the_archive_post_id');
|
119 |
|
@@ -145,14 +185,14 @@ function acfe_the_archive_post_id($null, $post_id){
|
|
145 |
if($post_id !== false)
|
146 |
return $null;
|
147 |
|
148 |
-
$
|
149 |
|
150 |
-
if(empty($
|
151 |
return $null;
|
152 |
|
153 |
-
$
|
154 |
|
155 |
-
return $
|
156 |
|
157 |
}
|
158 |
|
@@ -161,65 +201,97 @@ function acfe_the_archive_post_id($null, $post_id){
|
|
161 |
*/
|
162 |
function acfe_flexible_render_layout_template($layout, $field){
|
163 |
|
164 |
-
//
|
165 |
global $is_preview;
|
166 |
|
167 |
-
//
|
168 |
-
$
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
// Filters
|
171 |
-
$
|
172 |
-
$
|
173 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
$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);
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
}
|
197 |
-
|
198 |
-
// Include
|
199 |
-
if(!empty($acfe_flexible_render_template_path)){
|
200 |
-
|
201 |
-
do_action('acfe/flexible/render/before_template', $field, $layout, $is_preview);
|
202 |
-
do_action('acfe/flexible/render/before_template/name=' . $field['_name'], $field, $layout, $is_preview);
|
203 |
-
do_action('acfe/flexible/render/before_template/key=' . $field['key'], $field, $layout, $is_preview);
|
204 |
-
|
205 |
-
do_action('acfe/flexible/layout/render/before_template/layout=' . $layout['name'], $field, $layout, $is_preview);
|
206 |
-
do_action('acfe/flexible/layout/render/before_template/name=' . $field['_name'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
207 |
-
do_action('acfe/flexible/layout/render/before_template/key=' . $field['key'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
208 |
-
|
209 |
-
include($acfe_flexible_render_template_path);
|
210 |
-
|
211 |
-
do_action('acfe/flexible/render/after_template', $field, $layout, $is_preview);
|
212 |
-
do_action('acfe/flexible/render/after_template/name=' . $field['_name'], $field, $layout, $is_preview);
|
213 |
-
do_action('acfe/flexible/render/after_template/key=' . $field['key'], $field, $layout, $is_preview);
|
214 |
-
|
215 |
-
do_action('acfe/flexible/layout/render/after_template/layout=' . $layout['name'], $field, $layout, $is_preview);
|
216 |
-
do_action('acfe/flexible/layout/render/after_template/name=' . $field['_name'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
217 |
-
do_action('acfe/flexible/layout/render/after_template/key=' . $field['key'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
218 |
|
219 |
}
|
220 |
|
221 |
}
|
222 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
}
|
224 |
|
225 |
/**
|
@@ -227,93 +299,133 @@ function acfe_flexible_render_layout_template($layout, $field){
|
|
227 |
*/
|
228 |
function acfe_flexible_render_layout_enqueue($layout, $field){
|
229 |
|
230 |
-
//
|
231 |
global $is_preview;
|
232 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
|
234 |
/**
|
235 |
* Actions
|
236 |
*/
|
237 |
-
do_action(
|
238 |
-
do_action(
|
239 |
-
do_action(
|
|
|
|
|
|
|
|
|
|
|
240 |
|
241 |
/**
|
242 |
* Style
|
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 |
-
if(!empty($acfe_flexible_render_style_url))
|
276 |
-
wp_enqueue_style($handle, $acfe_flexible_render_style_url, array(), false, 'all');
|
277 |
|
278 |
}
|
279 |
|
280 |
/**
|
281 |
* Script
|
282 |
*/
|
283 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
|
|
|
|
|
|
289 |
|
290 |
-
|
291 |
-
|
292 |
-
$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);
|
293 |
|
294 |
-
|
295 |
-
|
|
|
|
|
296 |
|
297 |
-
|
298 |
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
else{
|
308 |
-
|
309 |
-
$acfe_flexible_render_script_url = acfe_locate_file_url(array($acfe_flexible_render_script));
|
310 |
|
311 |
}
|
312 |
|
313 |
-
// Include
|
314 |
-
if(!empty($acfe_flexible_render_script_url))
|
315 |
-
wp_enqueue_script($handle, $acfe_flexible_render_script_url, array(), false, true);
|
316 |
-
|
317 |
}
|
318 |
|
319 |
}
|
@@ -420,7 +532,7 @@ function acfe_is_json($string){
|
|
420 |
|
421 |
}
|
422 |
|
423 |
-
|
424 |
* Array Keys Recursive
|
425 |
*/
|
426 |
function acfe_array_keys_r($array){
|
@@ -440,7 +552,7 @@ function acfe_array_keys_r($array){
|
|
440 |
|
441 |
}
|
442 |
|
443 |
-
|
444 |
* Locate File URL
|
445 |
* Check if file exists locally and return URL (supports parent/child theme)
|
446 |
*/
|
@@ -453,28 +565,132 @@ function acfe_locate_file_url($filenames){
|
|
453 |
if(!$filename)
|
454 |
continue;
|
455 |
|
456 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
if(file_exists(STYLESHEETPATH . '/' . $filename)){
|
458 |
|
459 |
-
$located =
|
460 |
break;
|
461 |
|
462 |
}
|
463 |
-
|
464 |
-
//
|
465 |
elseif(file_exists(TEMPLATEPATH . '/' . $filename)){
|
466 |
|
467 |
-
$located =
|
468 |
break;
|
469 |
|
470 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
471 |
|
472 |
}
|
473 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
return $located;
|
475 |
|
476 |
}
|
477 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
478 |
/**
|
479 |
* Get Roles
|
480 |
*/
|
11 |
function get_flexible($selector, $post_id = false){
|
12 |
|
13 |
if(!have_rows($selector, $post_id))
|
14 |
+
return false;
|
15 |
|
16 |
// Vars
|
|
|
17 |
$flexible = acf_get_field_type('flexible_content');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
ob_start();
|
20 |
+
|
21 |
while(have_rows($selector, $post_id)): the_row();
|
22 |
+
|
23 |
// Vars
|
24 |
+
$loop = acf_get_loop('active');
|
25 |
+
$field = $loop['field'];
|
26 |
+
|
27 |
+
// Bail early if not Flexible Content
|
28 |
+
if($field['type'] !== 'flexible_content')
|
29 |
+
break;
|
30 |
+
|
31 |
+
$loop_i = acf_get_loop('active', 'i');
|
32 |
+
$layout = $flexible->get_layout(get_row_layout(), $field);
|
33 |
+
|
34 |
+
// First row
|
35 |
+
if($loop_i === 0){
|
36 |
+
|
37 |
+
// Global
|
38 |
+
global $is_preview;
|
39 |
+
|
40 |
+
// Vars
|
41 |
+
$is_preview = false;
|
42 |
+
$name = $field['_name'];
|
43 |
+
$key = $field['key'];
|
44 |
+
|
45 |
+
// Actions
|
46 |
+
do_action("acfe/flexible/enqueue", $field, $is_preview);
|
47 |
+
do_action("acfe/flexible/enqueue/name={$name}", $field, $is_preview);
|
48 |
+
do_action("acfe/flexible/enqueue/key={$key}", $field, $is_preview);
|
49 |
+
|
50 |
+
}
|
51 |
|
52 |
// Render: HTML Comment
|
53 |
echo "\n" . '<!-- ' . $layout['label'] . ' -->' . "\n";
|
123 |
*/
|
124 |
if(!function_exists('have_archive')){
|
125 |
|
126 |
+
function have_archive($_post_type = false){
|
|
|
127 |
|
128 |
+
global $acfe_archive_i, $acfe_archive_post_type;
|
129 |
|
130 |
+
$acfe_archive_post_type = false;
|
131 |
+
|
132 |
+
if(!isset($acfe_archive_i) || $acfe_archive_i === 0){
|
133 |
+
|
134 |
+
$acfe_archive_i = 0;
|
135 |
+
|
136 |
+
$post_type = get_post_type();
|
137 |
+
|
138 |
+
if(!empty($_post_type))
|
139 |
+
$post_type = $_post_type;
|
140 |
+
|
141 |
+
if(!post_type_exists($post_type))
|
142 |
+
return false;
|
143 |
+
|
144 |
+
$post_type_object = get_post_type_object($post_type);
|
145 |
+
|
146 |
+
if(empty($post_type_object))
|
147 |
+
return false;
|
148 |
+
|
149 |
+
if(!isset($post_type_object->acfe_admin_archive) || empty($post_type_object->acfe_admin_archive))
|
150 |
+
return false;
|
151 |
+
|
152 |
+
$acfe_archive_post_type = $post_type;
|
153 |
+
|
154 |
return true;
|
155 |
+
|
156 |
+
}
|
157 |
|
158 |
remove_filter('acf/pre_load_post_id', 'acfe_the_archive_post_id');
|
159 |
|
185 |
if($post_id !== false)
|
186 |
return $null;
|
187 |
|
188 |
+
global $acfe_archive_post_type;
|
189 |
|
190 |
+
if(empty($acfe_archive_post_type))
|
191 |
return $null;
|
192 |
|
193 |
+
$return = acf_get_valid_post_id($acfe_archive_post_type . '_archive');
|
194 |
|
195 |
+
return $return;
|
196 |
|
197 |
}
|
198 |
|
201 |
*/
|
202 |
function acfe_flexible_render_layout_template($layout, $field){
|
203 |
|
204 |
+
// Global
|
205 |
global $is_preview;
|
206 |
|
207 |
+
// Vars
|
208 |
+
$name = $field['_name'];
|
209 |
+
$key = $field['key'];
|
210 |
+
$l_name = $layout['name'];
|
211 |
+
|
212 |
+
// File
|
213 |
+
$file = acf_maybe_get($layout, 'acfe_flexible_render_template');
|
214 |
|
215 |
// Filters
|
216 |
+
$file = apply_filters("acfe/flexible/render/template", $file, $field, $layout, $is_preview);
|
217 |
+
$file = apply_filters("acfe/flexible/render/template/name={$name}", $file, $field, $layout, $is_preview);
|
218 |
+
$file = apply_filters("acfe/flexible/render/template/key={$key}", $file, $field, $layout, $is_preview);
|
219 |
+
$file = apply_filters("acfe/flexible/render/template/layout={$l_name}", $file, $field, $layout, $is_preview);
|
220 |
+
$file = apply_filters("acfe/flexible/render/template/name={$name}&layout={$l_name}", $file, $field, $layout, $is_preview);
|
221 |
+
$file = apply_filters("acfe/flexible/render/template/key={$key}&layout={$l_name}", $file, $field, $layout, $is_preview);
|
222 |
+
|
223 |
+
// Deprecated
|
224 |
+
$file = apply_filters_deprecated("acfe/flexible/layout/render/template/layout={$l_name}", array($file, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/template/layout={$l_name}");
|
225 |
+
$file = apply_filters_deprecated("acfe/flexible/layout/render/template/name={$name}&layout={$l_name}", array($file, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/template/name={$name}&layout={$l_name}");
|
226 |
+
$file = apply_filters_deprecated("acfe/flexible/layout/render/template/key={$key}&layout={$l_name}", array($file, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/template/key={$key}&layout={$l_name}");
|
227 |
+
|
228 |
+
// Before Template
|
229 |
+
do_action("acfe/flexible/render/before_template", $field, $layout, $is_preview);
|
230 |
+
do_action("acfe/flexible/render/before_template/name={$name}", $field, $layout, $is_preview);
|
231 |
+
do_action("acfe/flexible/render/before_template/key={$key}", $field, $layout, $is_preview);
|
232 |
+
do_action("acfe/flexible/render/before_template/layout={$l_name}", $field, $layout, $is_preview);
|
233 |
+
do_action("acfe/flexible/render/before_template/name={$name}&layout={$l_name}", $field, $layout, $is_preview);
|
234 |
+
do_action("acfe/flexible/render/before_template/key={$key}&layout={$l_name}", $field, $layout, $is_preview);
|
235 |
+
|
236 |
+
// Deprecated
|
237 |
+
do_action_deprecated("acfe/flexible/layout/render/before_template/layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/before_template/layout={$l_name}");
|
238 |
+
do_action_deprecated("acfe/flexible/layout/render/before_template/name={$name}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/before_template/name={$name}&layout={$l_name}");
|
239 |
+
do_action_deprecated("acfe/flexible/layout/render/before_template/key={$key}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/before_template/key={$key}&layout={$l_name}");
|
240 |
+
|
241 |
+
// Check file
|
242 |
+
if(!empty($file)){
|
243 |
+
|
244 |
+
$file_found = acfe_locate_file_path($file);
|
245 |
+
|
246 |
+
if(!empty($file_found)){
|
247 |
+
|
248 |
+
// Front-end
|
249 |
+
if(!$is_preview){
|
250 |
+
|
251 |
+
// Include
|
252 |
+
load_template($file_found, false);
|
253 |
+
|
254 |
+
// Preview
|
255 |
+
}else{
|
256 |
|
257 |
+
$path = pathinfo($file);
|
258 |
+
$extension = $path['extension'];
|
|
|
259 |
|
260 |
+
$file_preview = substr($file,0, -strlen($extension)-1);
|
261 |
+
$file_preview .= '-preview.' . $extension;
|
262 |
+
|
263 |
+
$file_preview = acfe_locate_file_path($file_preview);
|
264 |
+
|
265 |
+
// Include
|
266 |
+
if(!empty($file_preview)){
|
267 |
+
|
268 |
+
load_template($file_preview, false);
|
269 |
+
|
270 |
+
}else{
|
271 |
+
|
272 |
+
load_template($file_found, false);
|
273 |
+
|
274 |
+
}
|
275 |
+
|
276 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
|
278 |
}
|
279 |
|
280 |
}
|
281 |
|
282 |
+
// After Template
|
283 |
+
do_action("acfe/flexible/render/after_template", $field, $layout, $is_preview);
|
284 |
+
do_action("acfe/flexible/render/after_template/name={$name}", $field, $layout, $is_preview);
|
285 |
+
do_action("acfe/flexible/render/after_template/key={$key}", $field, $layout, $is_preview);
|
286 |
+
do_action("acfe/flexible/render/after_template/layout={$l_name}", $field, $layout, $is_preview);
|
287 |
+
do_action("acfe/flexible/render/after_template/name={$name}&layout={$l_name}", $field, $layout, $is_preview);
|
288 |
+
do_action("acfe/flexible/render/after_template/key={$key}&layout={$l_name}", $field, $layout, $is_preview);
|
289 |
+
|
290 |
+
// Deprecated
|
291 |
+
do_action_deprecated("acfe/flexible/layout/render/after_template/layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/after_template/layout={$l_name}");
|
292 |
+
do_action_deprecated("acfe/flexible/layout/render/after_template/name={$name}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/after_template/name={$name}&layout={$l_name}");
|
293 |
+
do_action_deprecated("acfe/flexible/layout/render/after_template/key={$key}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/after_template/key={$key}&layout={$l_name}");
|
294 |
+
|
295 |
}
|
296 |
|
297 |
/**
|
299 |
*/
|
300 |
function acfe_flexible_render_layout_enqueue($layout, $field){
|
301 |
|
302 |
+
// Global
|
303 |
global $is_preview;
|
304 |
+
|
305 |
+
// Vars
|
306 |
+
$name = $field['_name'];
|
307 |
+
$key = $field['key'];
|
308 |
+
$l_name = $layout['name'];
|
309 |
+
$handle = acf_slugify($field['name']) . '-layout-' . acf_slugify($l_name);
|
310 |
+
|
311 |
+
// Files
|
312 |
+
$style = acf_maybe_get($layout, 'acfe_flexible_render_style');
|
313 |
+
$script = acf_maybe_get($layout, 'acfe_flexible_render_script');
|
314 |
|
315 |
/**
|
316 |
* Actions
|
317 |
*/
|
318 |
+
do_action("acfe/flexible/enqueue/layout={$l_name}", $field, $layout, $is_preview);
|
319 |
+
do_action("acfe/flexible/enqueue/name={$name}&layout={$l_name}", $field, $layout, $is_preview);
|
320 |
+
do_action("acfe/flexible/enqueue/key={$key}&layout={$l_name}", $field, $layout, $is_preview);
|
321 |
+
|
322 |
+
// Deprecated
|
323 |
+
do_action_deprecated("acfe/flexible/layout/enqueue/layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/enqueue/layout={$l_name}");
|
324 |
+
do_action_deprecated("acfe/flexible/layout/enqueue/name={$name}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/enqueue/name={$name}&layout={$l_name}");
|
325 |
+
do_action_deprecated("acfe/flexible/layout/enqueue/key={$key}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/enqueue/key={$key}&layout={$l_name}");
|
326 |
|
327 |
/**
|
328 |
* Style
|
329 |
*/
|
330 |
+
$style = apply_filters("acfe/flexible/render/style", $style, $field, $layout, $is_preview);
|
331 |
+
$style = apply_filters("acfe/flexible/render/style/name={$name}", $style, $field, $layout, $is_preview);
|
332 |
+
$style = apply_filters("acfe/flexible/render/style/key={$key}", $style, $field, $layout, $is_preview);
|
333 |
+
$style = apply_filters("acfe/flexible/render/style/layout={$l_name}", $style, $field, $layout, $is_preview);
|
334 |
+
$style = apply_filters("acfe/flexible/render/style/name={$name}&layout={$l_name}", $style, $field, $layout, $is_preview);
|
335 |
+
$style = apply_filters("acfe/flexible/render/style/key={$key}&layout={$l_name}", $style, $field, $layout, $is_preview);
|
336 |
+
|
337 |
+
// Deprecated
|
338 |
+
$style = apply_filters_deprecated("acfe/flexible/layout/render/style/layout={$l_name}", array($style, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/style/layout={$l_name}");
|
339 |
+
$style = apply_filters_deprecated("acfe/flexible/layout/render/style/name={$name}&layout={$l_name}", array($style, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/style/name={$name}&layout={$l_name}");
|
340 |
+
$style = apply_filters_deprecated("acfe/flexible/layout/render/style/key={$key}&layout={$l_name}", array($style, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/style/key={$key}&layout={$l_name}");
|
341 |
+
|
342 |
+
// Check
|
343 |
+
if(!empty($style)){
|
344 |
+
|
345 |
+
// Locate
|
346 |
+
$style_file = acfe_locate_file_url($style);
|
347 |
+
|
348 |
+
// Enqueue
|
349 |
+
if(!empty($style_file)){
|
350 |
|
351 |
+
// Front-end
|
352 |
+
wp_enqueue_style($handle, $style_file, array(), false, 'all');
|
353 |
|
354 |
}
|
355 |
+
|
356 |
+
// Preview
|
357 |
+
if($is_preview){
|
358 |
+
|
359 |
+
$path = pathinfo($style);
|
360 |
+
$extension = $path['extension'];
|
361 |
+
|
362 |
+
$style_preview = substr($style,0, -strlen($extension)-1);
|
363 |
+
$style_preview .= '-preview.' . $extension;
|
364 |
+
|
365 |
+
$style_preview = acfe_locate_file_url($style_preview);
|
366 |
|
367 |
+
// Enqueue
|
368 |
+
if(!empty($style_preview)){
|
369 |
|
370 |
+
wp_enqueue_style($handle . '-preview', $style_preview, array(), false, 'all');
|
371 |
|
372 |
+
}
|
373 |
|
374 |
+
}
|
|
|
|
|
375 |
|
376 |
}
|
377 |
|
378 |
/**
|
379 |
* Script
|
380 |
*/
|
381 |
+
$script = apply_filters("acfe/flexible/render/script", $script, $field, $layout, $is_preview);
|
382 |
+
$script = apply_filters("acfe/flexible/render/script/name={$name}", $script, $field, $layout, $is_preview);
|
383 |
+
$script = apply_filters("acfe/flexible/render/script/key={$key}", $script, $field, $layout, $is_preview);
|
384 |
+
$script = apply_filters("acfe/flexible/render/script/layout={$l_name}", $script, $field, $layout, $is_preview);
|
385 |
+
$script = apply_filters("acfe/flexible/render/script/name={$name}&layout={$l_name}", $script, $field, $layout, $is_preview);
|
386 |
+
$script = apply_filters("acfe/flexible/render/script/key={$key}&layout={$l_name}", $script, $field, $layout, $is_preview);
|
387 |
+
|
388 |
+
// Deprecated
|
389 |
+
$script = apply_filters_deprecated("acfe/flexible/layout/render/script/layout={$l_name}", array($script, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/script/layout={$l_name}");
|
390 |
+
$script = apply_filters_deprecated("acfe/flexible/layout/render/script/name={$name}&layout={$l_name}", array($script, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/script/name={$name}&layout={$l_name}");
|
391 |
+
$script = apply_filters_deprecated("acfe/flexible/layout/render/script/key={$key}&layout={$l_name}", array($script, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/script/key={$key}&layout={$l_name}");
|
392 |
+
|
393 |
+
// Check
|
394 |
+
if(!empty($script)){
|
395 |
+
|
396 |
+
if(!$is_preview){
|
397 |
+
|
398 |
+
$script_file = acfe_locate_file_url($script);
|
399 |
|
400 |
+
if(!empty($script_file))
|
401 |
+
wp_enqueue_script($handle, $script_file, array(), false, true);
|
402 |
+
|
403 |
+
}else{
|
404 |
+
|
405 |
+
$path = pathinfo($script);
|
406 |
+
$extension = $path['extension'];
|
407 |
|
408 |
+
$script_preview = substr($script,0, -strlen($extension)-1);
|
409 |
+
$script_preview .= '-preview.' . $extension;
|
|
|
410 |
|
411 |
+
$script_preview = acfe_locate_file_url($script_preview);
|
412 |
+
|
413 |
+
// Enqueue
|
414 |
+
if(!empty($script_preview)){
|
415 |
|
416 |
+
wp_enqueue_script($handle . '-preview', $script_preview, array(), false, true);
|
417 |
|
418 |
+
}else{
|
419 |
+
|
420 |
+
$script_file = acfe_locate_file_url($script);
|
421 |
+
|
422 |
+
if(!empty($script_file))
|
423 |
+
wp_enqueue_script($handle, $script_file, array(), false, true);
|
424 |
+
|
425 |
+
}
|
|
|
|
|
|
|
426 |
|
427 |
}
|
428 |
|
|
|
|
|
|
|
|
|
429 |
}
|
430 |
|
431 |
}
|
532 |
|
533 |
}
|
534 |
|
535 |
+
/*
|
536 |
* Array Keys Recursive
|
537 |
*/
|
538 |
function acfe_array_keys_r($array){
|
552 |
|
553 |
}
|
554 |
|
555 |
+
/*
|
556 |
* Locate File URL
|
557 |
* Check if file exists locally and return URL (supports parent/child theme)
|
558 |
*/
|
565 |
if(!$filename)
|
566 |
continue;
|
567 |
|
568 |
+
// Direct URL: https://www.domain.com/folder/file.js
|
569 |
+
if(stripos($filename, 'http://') === 0 || stripos($filename, 'https://') === 0 || stripos($filename, '//') === 0){
|
570 |
+
|
571 |
+
$located = $filename;
|
572 |
+
break;
|
573 |
+
|
574 |
+
}else{
|
575 |
+
|
576 |
+
$filename = ltrim($filename, '/\\');
|
577 |
+
$abspath = wp_normalize_path(untrailingslashit(ABSPATH));
|
578 |
+
|
579 |
+
// Child Theme
|
580 |
+
if(file_exists(STYLESHEETPATH . '/' . $filename)){
|
581 |
+
|
582 |
+
$located = get_stylesheet_directory_uri() . '/' . $filename;
|
583 |
+
break;
|
584 |
+
|
585 |
+
}
|
586 |
+
|
587 |
+
// Parent Theme
|
588 |
+
elseif(file_exists(TEMPLATEPATH . '/' . $filename)){
|
589 |
+
|
590 |
+
$located = get_template_directory_uri() . '/' . $filename;
|
591 |
+
break;
|
592 |
+
|
593 |
+
}
|
594 |
+
|
595 |
+
// ABSPATH file path
|
596 |
+
elseif(file_exists($abspath . '/' . $filename)){
|
597 |
+
|
598 |
+
$located = acfe_get_abs_path_to_url($abspath . '/' . $filename);
|
599 |
+
break;
|
600 |
+
|
601 |
+
}
|
602 |
+
|
603 |
+
// WP Content Dir
|
604 |
+
elseif(file_exists(WP_CONTENT_DIR . '/' . $filename)){
|
605 |
+
|
606 |
+
$located = WP_CONTENT_URL . '/' . $filename;
|
607 |
+
break;
|
608 |
+
|
609 |
+
}
|
610 |
+
|
611 |
+
}
|
612 |
+
|
613 |
+
}
|
614 |
+
|
615 |
+
return $located;
|
616 |
+
|
617 |
+
}
|
618 |
+
|
619 |
+
/*
|
620 |
+
* Locate File Path
|
621 |
+
* Based on wp-includes\template.php:653
|
622 |
+
*/
|
623 |
+
function acfe_locate_file_path($filenames, $load = false, $require_once = true){
|
624 |
+
|
625 |
+
$located = '';
|
626 |
+
|
627 |
+
foreach((array) $filenames as $filename){
|
628 |
+
|
629 |
+
if(!$filename)
|
630 |
+
continue;
|
631 |
+
|
632 |
+
$filename = ltrim($filename, '/\\');
|
633 |
+
$abspath = untrailingslashit(ABSPATH);
|
634 |
+
|
635 |
+
// Stylesheet file path
|
636 |
if(file_exists(STYLESHEETPATH . '/' . $filename)){
|
637 |
|
638 |
+
$located = STYLESHEETPATH . '/' . $filename;
|
639 |
break;
|
640 |
|
641 |
}
|
642 |
+
|
643 |
+
// Template file path
|
644 |
elseif(file_exists(TEMPLATEPATH . '/' . $filename)){
|
645 |
|
646 |
+
$located = TEMPLATEPATH . '/' . $filename;
|
647 |
break;
|
648 |
|
649 |
}
|
650 |
+
|
651 |
+
// ABSPATH file path
|
652 |
+
elseif(file_exists($abspath . '/' . $filename)){
|
653 |
+
|
654 |
+
$located = $abspath . '/' . $filename;
|
655 |
+
break;
|
656 |
+
|
657 |
+
}
|
658 |
+
|
659 |
+
// WP Content Dir
|
660 |
+
elseif(file_exists(WP_CONTENT_DIR . '/' . $filename)){
|
661 |
+
|
662 |
+
$located = WP_CONTENT_DIR . '/' . $filename;
|
663 |
+
break;
|
664 |
+
|
665 |
+
}
|
666 |
|
667 |
}
|
668 |
+
|
669 |
+
if($load && $located != ''){
|
670 |
+
|
671 |
+
load_template($located, $require_once);
|
672 |
+
|
673 |
+
}
|
674 |
+
|
675 |
return $located;
|
676 |
|
677 |
}
|
678 |
|
679 |
+
/**
|
680 |
+
* Convert ABSPATH . '/url' to https://www.domain.com/url
|
681 |
+
*/
|
682 |
+
function acfe_get_abs_path_to_url($path = ''){
|
683 |
+
|
684 |
+
$url = str_replace(
|
685 |
+
wp_normalize_path(untrailingslashit(ABSPATH)),
|
686 |
+
site_url(),
|
687 |
+
wp_normalize_path($path)
|
688 |
+
);
|
689 |
+
|
690 |
+
return esc_url_raw($url);
|
691 |
+
|
692 |
+
}
|
693 |
+
|
694 |
/**
|
695 |
* Get Roles
|
696 |
*/
|
includes/core/multilang.php
CHANGED
@@ -4,66 +4,126 @@ if(!defined('ABSPATH'))
|
|
4 |
exit;
|
5 |
|
6 |
if(!class_exists('acfe_multilang')):
|
7 |
-
|
8 |
class acfe_multilang{
|
9 |
|
10 |
var $is_wpml = false;
|
11 |
var $is_polylang = false;
|
12 |
var $is_multilang = false;
|
|
|
13 |
|
14 |
-
|
15 |
|
16 |
-
// Check setting
|
17 |
-
if(!acf_get_setting('acfe/modules/multilang'))
|
18 |
-
return;
|
19 |
-
|
20 |
// WPML
|
21 |
if(defined('ICL_SITEPRESS_VERSION')){
|
22 |
-
|
23 |
$this->is_wpml = true;
|
24 |
$this->is_multilang = true;
|
25 |
|
26 |
-
$this->wpml();
|
27 |
-
|
28 |
}
|
29 |
|
30 |
// PolyLang
|
31 |
if(defined('POLYLANG_VERSION') && function_exists('pll_default_language')){
|
32 |
-
|
33 |
$this->is_polylang = true;
|
34 |
$this->is_multilang = true;
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
$this
|
37 |
|
38 |
}
|
39 |
|
40 |
}
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
// ACF Options Post ID
|
49 |
-
add_filter('acf/validate_post_id', array($this, 'set_options_post_id'),
|
50 |
-
|
51 |
}
|
52 |
|
53 |
-
|
|
|
|
|
|
|
|
|
54 |
|
55 |
-
//
|
|
|
|
|
56 |
if($pluck === 'locale')
|
57 |
-
$
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
-
|
62 |
|
63 |
-
|
64 |
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
return $languages;
|
68 |
|
69 |
}
|
@@ -75,78 +135,62 @@ class acfe_multilang{
|
|
75 |
* https://polylang.wordpress.com/documentation/documentation-for-developers/general/
|
76 |
* https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/
|
77 |
*/
|
78 |
-
function
|
79 |
|
80 |
-
//
|
81 |
-
$
|
82 |
-
$cl = pll_current_language('locale');
|
83 |
-
|
84 |
-
// Update settings
|
85 |
-
acf_update_setting('default_language', $dl);
|
86 |
-
acf_update_setting('current_language', $cl);
|
87 |
-
|
88 |
-
// Localize data
|
89 |
-
acf_localize_data(array(
|
90 |
-
'language' => $cl
|
91 |
-
));
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
-
|
101 |
-
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
|
102 |
|
103 |
-
|
104 |
-
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
$translations['en_US'] = '';
|
109 |
-
$languages = array_intersect_key($languages, $translations);
|
110 |
-
|
111 |
-
}
|
112 |
|
113 |
-
|
|
|
114 |
|
115 |
-
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
unset($languages[$k]);
|
120 |
-
|
121 |
-
}
|
122 |
|
123 |
-
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
$languages = wp_list_pluck($languages, $pluck, true);
|
128 |
-
|
129 |
-
}
|
130 |
-
|
131 |
-
return $languages;
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
function get_languages($pluck = 'code', $plugin = false){
|
136 |
-
|
137 |
-
// Polylang
|
138 |
-
if($this->is_polylang || $plugin === 'polylang'){
|
139 |
-
|
140 |
-
return $this->polylang_get_languages($pluck);
|
141 |
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
|
149 |
-
return
|
150 |
|
151 |
}
|
152 |
|
@@ -155,78 +199,145 @@ class acfe_multilang{
|
|
155 |
*/
|
156 |
function set_options_post_id($post_id, $original_post_id){
|
157 |
|
158 |
-
//
|
159 |
-
if($
|
160 |
return $post_id;
|
161 |
|
162 |
$data = acf_get_post_id_info($post_id);
|
163 |
-
|
164 |
-
//
|
165 |
if($data['type'] !== 'option')
|
166 |
return $post_id;
|
167 |
-
|
168 |
-
//
|
169 |
-
if(
|
170 |
return $post_id;
|
171 |
|
|
|
|
|
|
|
|
|
|
|
172 |
$dl = acf_get_setting('default_language');
|
173 |
$cl = acf_get_setting('current_language');
|
174 |
-
|
175 |
// Add Language
|
176 |
if($cl && $cl !== $dl){
|
177 |
-
|
178 |
$post_id .= '_' . $cl;
|
179 |
-
|
180 |
}
|
181 |
-
|
182 |
return $post_id;
|
183 |
|
184 |
}
|
185 |
|
186 |
-
function
|
187 |
-
|
188 |
-
// Check if ends with '-en_US' || '_en_US'
|
189 |
-
preg_match('/[_\-][A-Za-z]{2}_[A-Za-z]{2}$/', $post_id, $found);
|
190 |
-
|
191 |
-
if(!empty($found)){
|
192 |
-
|
193 |
-
// Remove first '_'
|
194 |
-
$found = substr($found[0], 1);
|
195 |
-
$found = strtolower($found);
|
196 |
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
|
|
|
|
204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
-
|
208 |
-
preg_match('/[_\-][A-Za-z]{2}$/', $post_id, $found);
|
209 |
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
|
216 |
-
|
217 |
-
|
218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
|
220 |
-
|
221 |
-
|
222 |
-
|
|
|
|
|
223 |
|
|
|
|
|
|
|
|
|
224 |
}
|
225 |
|
226 |
return false;
|
227 |
|
228 |
}
|
229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
}
|
231 |
|
232 |
acf_new_instance('acfe_multilang');
|
@@ -241,17 +352,26 @@ function acfe_is_multilang(){
|
|
241 |
|
242 |
function acfe_get_multilang(){
|
243 |
|
|
|
|
|
|
|
244 |
$data = array(
|
245 |
'dl' => acf_get_setting('default_language'),
|
246 |
'cl' => acf_get_setting('current_language'),
|
247 |
-
'wpml' =>
|
248 |
-
'polylang' =>
|
249 |
);
|
250 |
|
251 |
return $data;
|
252 |
|
253 |
}
|
254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
function acfe_is_polylang(){
|
256 |
|
257 |
return acf_get_instance('acfe_multilang')->is_polylang;
|
@@ -268,16 +388,16 @@ function acfe_get_post_lang($post_id, $field = false){
|
|
268 |
|
269 |
// Polylang
|
270 |
if(acfe_is_polylang()){
|
271 |
-
|
272 |
// Default field
|
273 |
if(!$field)
|
274 |
$field = 'locale';
|
275 |
-
|
276 |
return pll_get_post_language($post_id, $field);
|
277 |
|
278 |
-
|
279 |
}elseif(acfe_is_wpml()){
|
280 |
-
|
281 |
$post_lang = apply_filters('wpml_post_language_details', NULL, $post_id);
|
282 |
|
283 |
// Default field
|
@@ -287,19 +407,19 @@ function acfe_get_post_lang($post_id, $field = false){
|
|
287 |
if($field === 'locale'){
|
288 |
|
289 |
return $post_lang['locale'];
|
290 |
-
|
291 |
}elseif($field === 'slug'){
|
292 |
-
|
293 |
return $post_lang['language_code'];
|
294 |
-
|
295 |
}elseif($field === 'name'){
|
296 |
-
|
297 |
return $post_lang['display_name'];
|
298 |
-
|
299 |
}
|
300 |
-
|
301 |
return false;
|
302 |
-
|
303 |
}
|
304 |
|
305 |
return false;
|
@@ -320,7 +440,7 @@ function acfe__(&$string, $name = false, $textdomain = 'acfe'){
|
|
320 |
do_action( 'wpml_register_single_string', $textdomain, $name, $string);
|
321 |
|
322 |
$string = __($string, $textdomain);
|
323 |
-
|
324 |
return $string;
|
325 |
|
326 |
}
|
@@ -329,11 +449,11 @@ function acfe__(&$string, $name = false, $textdomain = 'acfe'){
|
|
329 |
if(acfe_is_polylang()){
|
330 |
|
331 |
pll_register_string($name, $string, $textdomain);
|
332 |
-
|
333 |
$string = pll__($string);
|
334 |
|
335 |
return $string;
|
336 |
-
|
337 |
}
|
338 |
|
339 |
$string = __($string, $textdomain);
|
@@ -343,7 +463,7 @@ function acfe__(&$string, $name = false, $textdomain = 'acfe'){
|
|
343 |
}
|
344 |
|
345 |
function acfe__e($string, $name = false, $textdomain = 'acfe'){
|
346 |
-
|
347 |
echo acfe__($string, $name, $textdomain);
|
348 |
|
349 |
}
|
4 |
exit;
|
5 |
|
6 |
if(!class_exists('acfe_multilang')):
|
7 |
+
|
8 |
class acfe_multilang{
|
9 |
|
10 |
var $is_wpml = false;
|
11 |
var $is_polylang = false;
|
12 |
var $is_multilang = false;
|
13 |
+
var $options_pages = false;
|
14 |
|
15 |
+
function __construct(){
|
16 |
|
|
|
|
|
|
|
|
|
17 |
// WPML
|
18 |
if(defined('ICL_SITEPRESS_VERSION')){
|
19 |
+
|
20 |
$this->is_wpml = true;
|
21 |
$this->is_multilang = true;
|
22 |
|
|
|
|
|
23 |
}
|
24 |
|
25 |
// PolyLang
|
26 |
if(defined('POLYLANG_VERSION') && function_exists('pll_default_language')){
|
27 |
+
|
28 |
$this->is_polylang = true;
|
29 |
$this->is_multilang = true;
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
if($this->is_multilang){
|
34 |
|
35 |
+
add_action('acf/init', array($this, 'init'), 99);
|
36 |
|
37 |
}
|
38 |
|
39 |
}
|
40 |
|
41 |
+
function init(){
|
42 |
+
|
43 |
+
// Check setting
|
44 |
+
if(!acf_get_setting('acfe/modules/multilang'))
|
45 |
+
return;
|
46 |
+
|
47 |
+
// Polylang specific
|
48 |
+
if($this->is_polylang){
|
49 |
+
|
50 |
+
// Default/Current Language
|
51 |
+
$dl = pll_default_language('locale');
|
52 |
+
$cl = pll_current_language('locale');
|
53 |
+
|
54 |
+
// Update settings
|
55 |
+
acf_update_setting('default_language', $dl);
|
56 |
+
acf_update_setting('current_language', $cl);
|
57 |
+
|
58 |
+
}
|
59 |
|
60 |
// ACF Options Post ID
|
61 |
+
add_filter('acf/validate_post_id', array($this, 'set_options_post_id'), 99, 2);
|
62 |
+
|
63 |
}
|
64 |
|
65 |
+
/**
|
66 |
+
* WPML
|
67 |
+
* https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/
|
68 |
+
*/
|
69 |
+
function wpml_get_languages($pluck, $type = 'all'){
|
70 |
|
71 |
+
// Pluck
|
72 |
+
$pluck_filter = $pluck;
|
73 |
+
|
74 |
if($pluck === 'locale')
|
75 |
+
$pluck_filter = 'default_locale';
|
76 |
+
|
77 |
+
// Vars
|
78 |
+
$languages = array();
|
79 |
+
|
80 |
+
switch($type){
|
81 |
|
82 |
+
// Active
|
83 |
+
case 'active':
|
84 |
+
|
85 |
+
// Active Languages
|
86 |
+
// https://wpml.org/wpml-hook/wpml_active_languages/
|
87 |
+
$languages = apply_filters('wpml_active_languages', null, array('skip_missing' => 0));
|
88 |
+
|
89 |
+
$languages = wp_list_pluck($languages, $pluck_filter, true);
|
90 |
+
|
91 |
+
return $languages;
|
92 |
+
|
93 |
+
// All
|
94 |
+
case 'all':
|
95 |
+
|
96 |
+
// Active Languages
|
97 |
+
// https://wpml.org/wpml-hook/wpml_active_languages/
|
98 |
+
$languages = apply_filters('wpml_active_languages', null, array('skip_missing' => 0));
|
99 |
+
|
100 |
+
$languages = wp_list_pluck($languages, $pluck_filter, true);
|
101 |
+
|
102 |
+
// Plugin Languages
|
103 |
+
$plugin_languages = icl_get_languages_locales();
|
104 |
+
|
105 |
+
if(!empty($plugin_languages)){
|
106 |
|
107 |
+
if($pluck === 'code'){
|
108 |
|
109 |
+
$plugin_languages = array_keys($plugin_languages);
|
110 |
|
111 |
+
}elseif($pluck === 'locale'){
|
112 |
+
|
113 |
+
$plugin_languages = array_values($plugin_languages);
|
114 |
+
|
115 |
+
}
|
116 |
+
|
117 |
+
// Merge
|
118 |
+
$languages = array_merge($languages, $plugin_languages);
|
119 |
+
$languages = array_unique($languages);
|
120 |
|
121 |
+
}
|
122 |
+
|
123 |
+
return $languages;
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
return $languages;
|
128 |
|
129 |
}
|
135 |
* https://polylang.wordpress.com/documentation/documentation-for-developers/general/
|
136 |
* https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/
|
137 |
*/
|
138 |
+
function polylang_get_languages($pluck, $type = 'all'){
|
139 |
|
140 |
+
// Vars
|
141 |
+
$languages = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
+
switch($type){
|
144 |
+
|
145 |
+
// Active
|
146 |
+
case 'active':
|
147 |
+
|
148 |
+
$pluck_filter = $pluck;
|
149 |
+
if($pluck === 'code')
|
150 |
+
$pluck_filter = 'slug';
|
151 |
+
|
152 |
+
// https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/
|
153 |
+
$languages = pll_languages_list(array(
|
154 |
+
'hide_empty' => false,
|
155 |
+
'fields' => $pluck_filter
|
156 |
+
));
|
157 |
|
158 |
+
return $languages;
|
|
|
159 |
|
160 |
+
// All
|
161 |
+
case 'all':
|
162 |
|
163 |
+
// Copy from wp-content/plugins/polylang-pro/settings/settings.php:363
|
164 |
+
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
|
|
|
|
|
|
|
|
|
165 |
|
166 |
+
$languages = include PLL_SETTINGS_INC . '/languages.php';
|
167 |
+
$translations = wp_get_available_translations();
|
168 |
|
169 |
+
if (!empty($translations)){
|
170 |
|
171 |
+
$translations['en_US'] = '';
|
172 |
+
$languages = array_intersect_key($languages, $translations);
|
|
|
|
|
|
|
173 |
|
174 |
+
}
|
175 |
|
176 |
+
$languages = apply_filters('pll_predefined_languages', $languages);
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
+
foreach($languages as $k => $lang){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
+
if(isset($lang['code'], $lang['locale'], $lang['name'], $lang['dir'], $lang['flag']))
|
181 |
+
continue;
|
182 |
+
|
183 |
+
unset($languages[$k]);
|
184 |
|
185 |
+
}
|
186 |
+
|
187 |
+
$languages = wp_list_pluck($languages, $pluck, true);
|
188 |
+
|
189 |
+
return $languages;
|
190 |
+
|
191 |
}
|
192 |
|
193 |
+
return $languages;
|
194 |
|
195 |
}
|
196 |
|
199 |
*/
|
200 |
function set_options_post_id($post_id, $original_post_id){
|
201 |
|
202 |
+
// Bail early if original post id is 'options' ||'option'
|
203 |
+
if(!is_string($post_id) || in_array($original_post_id, array('options', 'option')))
|
204 |
return $post_id;
|
205 |
|
206 |
$data = acf_get_post_id_info($post_id);
|
207 |
+
|
208 |
+
// Bail early if post id isn't an option type
|
209 |
if($data['type'] !== 'option')
|
210 |
return $post_id;
|
211 |
+
|
212 |
+
// Bail early if no Options Page found with that post id
|
213 |
+
if(!$this->is_options_page($post_id))
|
214 |
return $post_id;
|
215 |
|
216 |
+
// Bail early if already localized: 'my-options_en_US'
|
217 |
+
if($this->is_localized($post_id))
|
218 |
+
return $post_id;
|
219 |
+
|
220 |
+
// Append current language to post id
|
221 |
$dl = acf_get_setting('default_language');
|
222 |
$cl = acf_get_setting('current_language');
|
223 |
+
|
224 |
// Add Language
|
225 |
if($cl && $cl !== $dl){
|
226 |
+
|
227 |
$post_id .= '_' . $cl;
|
228 |
+
|
229 |
}
|
230 |
+
|
231 |
return $post_id;
|
232 |
|
233 |
}
|
234 |
|
235 |
+
function is_localized($post_id){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
|
237 |
+
// Check if post id ends with '-en_US' || '_en_US' || '-en' || '_en'
|
238 |
+
// https://regex101.com/r/oMsyeL/4
|
239 |
+
preg_match('/(?P<locale>[_\-][A-Za-z]{2}_[A-Za-z]{2})$|(?P<code>[_\-][A-Za-z]{2})$/', $post_id, $matches);
|
240 |
|
241 |
+
if(empty($matches))
|
242 |
+
return false;
|
243 |
+
|
244 |
+
// Cleanup matches
|
245 |
+
$lang = array();
|
246 |
|
247 |
+
foreach($matches as $key => $val){
|
248 |
+
|
249 |
+
if(is_int($key) || empty($val))
|
250 |
+
continue;
|
251 |
+
|
252 |
+
$lang = array(
|
253 |
+
'type' => $key,
|
254 |
+
'lang' => strtolower(substr($val, 1)), // Lowercase + Remove the first '_'
|
255 |
+
);
|
256 |
+
|
257 |
}
|
258 |
+
|
259 |
+
if(empty($lang))
|
260 |
+
return false;
|
261 |
+
|
262 |
+
// Get WPML/Polylang Languages List
|
263 |
+
$languages = $this->get_languages($lang['type']);
|
264 |
+
$languages = array_map('strtolower', $languages);
|
265 |
+
|
266 |
+
// Compare Matches vs WPML/Polylang Languages List
|
267 |
+
return in_array($lang['lang'], $languages);
|
268 |
+
|
269 |
+
}
|
270 |
|
271 |
+
function is_options_page($post_id){
|
|
|
272 |
|
273 |
+
// Get Options Pages
|
274 |
+
if($this->options_pages === false){
|
275 |
+
|
276 |
+
// Get ACF Options Pages
|
277 |
+
$options_pages = acf_get_array(acf_get_options_pages());
|
278 |
+
$list = wp_list_pluck($options_pages, 'post_id', true);
|
279 |
+
|
280 |
+
// Add 'Post Types List' location
|
281 |
+
$post_types = acf_get_post_types(array(
|
282 |
+
'show_ui' => 1,
|
283 |
+
'exclude' => array('attachment')
|
284 |
+
));
|
285 |
+
|
286 |
+
if(!empty($post_types)){
|
287 |
+
|
288 |
+
foreach($post_types as $post_type){
|
289 |
+
|
290 |
+
$list[] = $post_type . '_options';
|
291 |
+
|
292 |
+
}
|
293 |
|
294 |
+
}
|
295 |
+
|
296 |
+
// Add 'Taxonomy List' location
|
297 |
+
$taxonomies = acf_get_taxonomies();
|
298 |
+
|
299 |
+
if(!empty($taxonomies)){
|
300 |
+
|
301 |
+
foreach($taxonomies as $taxonomy){
|
302 |
+
|
303 |
+
$list[] = 'tax_' . $taxonomy . '_options';
|
304 |
+
|
305 |
+
}
|
306 |
|
307 |
+
}
|
308 |
+
|
309 |
+
$this->options_pages = $list;
|
310 |
+
|
311 |
+
}
|
312 |
|
313 |
+
if(is_array($this->options_pages) && !empty($this->options_pages)){
|
314 |
+
|
315 |
+
return in_array($post_id, $this->options_pages);
|
316 |
+
|
317 |
}
|
318 |
|
319 |
return false;
|
320 |
|
321 |
}
|
322 |
|
323 |
+
function get_languages($pluck = 'code', $type = 'all', $plugin = false){
|
324 |
+
|
325 |
+
// Polylang
|
326 |
+
if($this->is_polylang || $plugin === 'polylang'){
|
327 |
+
|
328 |
+
return $this->polylang_get_languages($pluck, $type);
|
329 |
+
|
330 |
+
// WPML
|
331 |
+
}elseif($this->is_wpml || $plugin === 'wpml'){
|
332 |
+
|
333 |
+
return $this->wpml_get_languages($pluck, $type);
|
334 |
+
|
335 |
+
}
|
336 |
+
|
337 |
+
return array();
|
338 |
+
|
339 |
+
}
|
340 |
+
|
341 |
}
|
342 |
|
343 |
acf_new_instance('acfe_multilang');
|
352 |
|
353 |
function acfe_get_multilang(){
|
354 |
|
355 |
+
$wpml = acf_get_instance('acfe_multilang')->is_wpml;
|
356 |
+
$polylang = acf_get_instance('acfe_multilang')->is_polylang;
|
357 |
+
|
358 |
$data = array(
|
359 |
'dl' => acf_get_setting('default_language'),
|
360 |
'cl' => acf_get_setting('current_language'),
|
361 |
+
'wpml' => $wpml,
|
362 |
+
'polylang' => $polylang,
|
363 |
);
|
364 |
|
365 |
return $data;
|
366 |
|
367 |
}
|
368 |
|
369 |
+
function acfe_get_languages($pluck = 'code', $type = 'all', $plugin = false){
|
370 |
+
|
371 |
+
return acf_get_instance('acfe_multilang')->get_languages($pluck, $type, $plugin);
|
372 |
+
|
373 |
+
}
|
374 |
+
|
375 |
function acfe_is_polylang(){
|
376 |
|
377 |
return acf_get_instance('acfe_multilang')->is_polylang;
|
388 |
|
389 |
// Polylang
|
390 |
if(acfe_is_polylang()){
|
391 |
+
|
392 |
// Default field
|
393 |
if(!$field)
|
394 |
$field = 'locale';
|
395 |
+
|
396 |
return pll_get_post_language($post_id, $field);
|
397 |
|
398 |
+
// WPML
|
399 |
}elseif(acfe_is_wpml()){
|
400 |
+
|
401 |
$post_lang = apply_filters('wpml_post_language_details', NULL, $post_id);
|
402 |
|
403 |
// Default field
|
407 |
if($field === 'locale'){
|
408 |
|
409 |
return $post_lang['locale'];
|
410 |
+
|
411 |
}elseif($field === 'slug'){
|
412 |
+
|
413 |
return $post_lang['language_code'];
|
414 |
+
|
415 |
}elseif($field === 'name'){
|
416 |
+
|
417 |
return $post_lang['display_name'];
|
418 |
+
|
419 |
}
|
420 |
+
|
421 |
return false;
|
422 |
+
|
423 |
}
|
424 |
|
425 |
return false;
|
440 |
do_action( 'wpml_register_single_string', $textdomain, $name, $string);
|
441 |
|
442 |
$string = __($string, $textdomain);
|
443 |
+
|
444 |
return $string;
|
445 |
|
446 |
}
|
449 |
if(acfe_is_polylang()){
|
450 |
|
451 |
pll_register_string($name, $string, $textdomain);
|
452 |
+
|
453 |
$string = pll__($string);
|
454 |
|
455 |
return $string;
|
456 |
+
|
457 |
}
|
458 |
|
459 |
$string = __($string, $textdomain);
|
463 |
}
|
464 |
|
465 |
function acfe__e($string, $name = false, $textdomain = 'acfe'){
|
466 |
+
|
467 |
echo acfe__($string, $name, $textdomain);
|
468 |
|
469 |
}
|
includes/fields/field-advanced-link.php
CHANGED
@@ -376,7 +376,6 @@ function my_acf_advanced_link_sub_fields($sub_fields, $field, $value){
|
|
376 |
'type' => 'acfe_taxonomy_terms',
|
377 |
'required' => false,
|
378 |
'class' => 'input-term',
|
379 |
-
'allow_null' => 1,
|
380 |
'field_type' => 'select',
|
381 |
'return_format' => 'id',
|
382 |
'ui' => 1,
|
@@ -414,9 +413,9 @@ function my_acf_advanced_link_sub_fields($sub_fields, $field, $value){
|
|
414 |
);
|
415 |
|
416 |
// Deprecated
|
417 |
-
$sub_fields =
|
418 |
-
$sub_fields =
|
419 |
-
$sub_fields =
|
420 |
|
421 |
// Sub Fields Fitlers
|
422 |
$sub_fields = apply_filters('acfe/fields/advanced_link/sub_fields', $sub_fields, $field, $value);
|
376 |
'type' => 'acfe_taxonomy_terms',
|
377 |
'required' => false,
|
378 |
'class' => 'input-term',
|
|
|
379 |
'field_type' => 'select',
|
380 |
'return_format' => 'id',
|
381 |
'ui' => 1,
|
413 |
);
|
414 |
|
415 |
// Deprecated
|
416 |
+
$sub_fields = apply_filters_deprecated('acfe/fields/advanced_link/fields', array($sub_fields, $field, $value), '0.8.1', 'acfe/fields/advanced_link/sub_fields');
|
417 |
+
$sub_fields = apply_filters_deprecated('acfe/fields/advanced_link/fields/name=' . $field['_name'], array($sub_fields, $field, $value), '0.8.1', 'acfe/fields/advanced_link/sub_fields/name=' . $field['_name']);
|
418 |
+
$sub_fields = apply_filters_deprecated('acfe/fields/advanced_link/fields/key=' . $field['key'], array($sub_fields, $field, $value), '0.8.1', 'acfe/fields/advanced_link/sub_fields/key=' . $field['key']);
|
419 |
|
420 |
// Sub Fields Fitlers
|
421 |
$sub_fields = apply_filters('acfe/fields/advanced_link/sub_fields', $sub_fields, $field, $value);
|
includes/fields/field-flexible-content.php
CHANGED
@@ -4,9 +4,7 @@ if(!defined('ABSPATH'))
|
|
4 |
exit;
|
5 |
|
6 |
add_action('wp_ajax_acfe/flexible/layout_preview', 'acfe_flexible_layout_preview');
|
7 |
-
function acfe_flexible_layout_preview($
|
8 |
-
|
9 |
-
$options = $args;
|
10 |
|
11 |
if(empty($options)){
|
12 |
|
@@ -27,27 +25,27 @@ function acfe_flexible_layout_preview($args = array()){
|
|
27 |
if(!$field)
|
28 |
die;
|
29 |
|
30 |
-
//
|
31 |
$flexible = acf_get_field_type('flexible_content');
|
32 |
|
33 |
-
//
|
34 |
$layout = $flexible->get_layout($options['layout'], $field);
|
35 |
if(!$layout)
|
36 |
die;
|
37 |
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
//
|
42 |
-
$
|
43 |
-
$
|
44 |
-
$
|
|
|
45 |
|
46 |
-
//
|
47 |
-
$
|
48 |
-
$layout['acfe_flexible_thumbnail'] = apply_filters('acfe/flexible/layout/thumbnail/name=' . $field['_name'] . '&layout=' . $layout['name'], $layout['acfe_flexible_thumbnail'], $field, $layout);
|
49 |
-
$layout['acfe_flexible_thumbnail'] = apply_filters('acfe/flexible/layout/thumbnail/key=' . $field['key'] . '&layout=' . $layout['name'], $layout['acfe_flexible_thumbnail'], $field, $layout);
|
50 |
|
|
|
51 |
$meta = array($options['field_key'] => array(
|
52 |
wp_unslash($options['value'])
|
53 |
));
|
@@ -60,17 +58,16 @@ function acfe_flexible_layout_preview($args = array()){
|
|
60 |
global $post;
|
61 |
$_post = $post;
|
62 |
|
63 |
-
//
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
do_action('acfe/flexible/layout/preview/key=' . $field['key'] . '&layout=' . $layout['name'], $field, $layout);
|
71 |
|
72 |
-
//
|
73 |
-
|
74 |
|
75 |
$post = $_post;
|
76 |
|
@@ -85,77 +82,6 @@ function acfe_flexible_layout_preview($args = array()){
|
|
85 |
|
86 |
}
|
87 |
|
88 |
-
add_action('acfe/flexible/preview', 'acfe_flexible_layout_preview_render', 99, 2);
|
89 |
-
function acfe_flexible_layout_preview_render($field, $layout){
|
90 |
-
|
91 |
-
global $is_preview;
|
92 |
-
|
93 |
-
$is_preview = true;
|
94 |
-
|
95 |
-
acfe_flexible_render_layout_template($layout, $field);
|
96 |
-
|
97 |
-
}
|
98 |
-
|
99 |
-
add_filter('acfe/flexible/render/template', 'acfe_flexible_layout_render_template_setting', 0, 4);
|
100 |
-
function acfe_flexible_layout_render_template_setting($return, $field, $layout, $is_preview){
|
101 |
-
|
102 |
-
if(acf_maybe_get($layout, 'acfe_flexible_render_template'))
|
103 |
-
$return = $layout['acfe_flexible_render_template'];
|
104 |
-
|
105 |
-
return $return;
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
add_filter('acfe/flexible/render/style', 'acfe_flexible_layout_render_style_setting', 0, 4);
|
110 |
-
function acfe_flexible_layout_render_style_setting($return, $field, $layout, $is_preview){
|
111 |
-
|
112 |
-
if(acf_maybe_get($layout, 'acfe_flexible_render_style'))
|
113 |
-
$return = $layout['acfe_flexible_render_style'];
|
114 |
-
|
115 |
-
return $return;
|
116 |
-
|
117 |
-
}
|
118 |
-
|
119 |
-
add_filter('acfe/flexible/render/script', 'acfe_flexible_layout_render_script_setting', 0, 4);
|
120 |
-
function acfe_flexible_layout_render_script_setting($return, $field, $layout, $is_preview){
|
121 |
-
|
122 |
-
if(acf_maybe_get($layout, 'acfe_flexible_render_script'))
|
123 |
-
$return = $layout['acfe_flexible_render_script'];
|
124 |
-
|
125 |
-
return $return;
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
add_filter('acf/prepare_field/name=acfe_flexible_category', 'acfe_prepare_flexible_layout_categories');
|
130 |
-
function acfe_prepare_flexible_layout_categories($field){
|
131 |
-
|
132 |
-
$value = acf_maybe_get($field, 'value');
|
133 |
-
|
134 |
-
if(empty($value))
|
135 |
-
return $field;
|
136 |
-
|
137 |
-
if(is_string($value)){
|
138 |
-
|
139 |
-
$explode = explode('|', $value);
|
140 |
-
|
141 |
-
$choices = array();
|
142 |
-
|
143 |
-
foreach($explode as $v){
|
144 |
-
|
145 |
-
$v = trim($v);
|
146 |
-
$choices[$v] = $v;
|
147 |
-
|
148 |
-
}
|
149 |
-
|
150 |
-
$field['choices'] = $choices;
|
151 |
-
$field['value'] = $choices;
|
152 |
-
|
153 |
-
}
|
154 |
-
|
155 |
-
return $field;
|
156 |
-
|
157 |
-
}
|
158 |
-
|
159 |
if(!class_exists('acfe_field_flexible_content')):
|
160 |
|
161 |
class acfe_field_flexible_content extends acf_field_flexible_content{
|
@@ -922,6 +848,11 @@ class acfe_field_flexible_content extends acf_field_flexible_content{
|
|
922 |
$flexible = acf_get_field($_field_id);
|
923 |
$layout = $flexible['layouts'][$_layout_key];
|
924 |
|
|
|
|
|
|
|
|
|
|
|
925 |
// Category
|
926 |
if($flexible['acfe_flexible_modal'] && acf_maybe_get($flexible['acfe_flexible_modal'], 'acfe_flexible_modal_categories')){
|
927 |
|
@@ -943,9 +874,20 @@ class acfe_field_flexible_content extends acf_field_flexible_content{
|
|
943 |
// Template
|
944 |
if($flexible['acfe_flexible_layouts_templates']){
|
945 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
946 |
acf_render_field_wrap(array(
|
947 |
'label' => __('Render'),
|
948 |
-
'prepend' =>
|
949 |
'name' => 'acfe_flexible_render_template',
|
950 |
'type' => 'text',
|
951 |
'class' => 'acf-fc-meta-name',
|
@@ -954,8 +896,17 @@ class acfe_field_flexible_content extends acf_field_flexible_content{
|
|
954 |
'placeholder' => 'template.php',
|
955 |
), 'ul');
|
956 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
957 |
acf_render_field_wrap(array(
|
958 |
-
'prepend' =>
|
959 |
'name' => 'acfe_flexible_render_style',
|
960 |
'type' => 'text',
|
961 |
'class' => 'acf-fc-meta-name',
|
@@ -963,9 +914,18 @@ class acfe_field_flexible_content extends acf_field_flexible_content{
|
|
963 |
'value' => $layout['acfe_flexible_render_style'],
|
964 |
'placeholder' => 'style.css',
|
965 |
), 'ul');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
966 |
|
967 |
acf_render_field_wrap(array(
|
968 |
-
'prepend' =>
|
969 |
'name' => 'acfe_flexible_render_script',
|
970 |
'type' => 'text',
|
971 |
'class' => 'acf-fc-meta-name',
|
@@ -1165,7 +1125,7 @@ class acfe_field_flexible_content extends acf_field_flexible_content{
|
|
1165 |
|
1166 |
foreach($defaults as $default => $val){
|
1167 |
|
1168 |
-
if(($default === 'acfe_flexible_modal' && empty($field['acfe_flexible_modal']['acfe_flexible_modal_enabled'])) ||empty($field[$default]))
|
1169 |
continue;
|
1170 |
|
1171 |
$field['acfe_flexible_advanced'] = 1;
|
@@ -1228,16 +1188,7 @@ class acfe_field_flexible_content extends acf_field_flexible_content{
|
|
1228 |
}
|
1229 |
|
1230 |
// Thumbnail
|
1231 |
-
$thumbnail = $
|
1232 |
-
|
1233 |
-
// Filters
|
1234 |
-
$thumbnail = apply_filters('acfe/flexible/thumbnail', $thumbnail, $field, $layout);
|
1235 |
-
$thumbnail = apply_filters('acfe/flexible/thumbnail/name=' . $field['_name'], $thumbnail, $field, $layout);
|
1236 |
-
$thumbnail = apply_filters('acfe/flexible/thumbnail/key=' . $field['key'], $thumbnail, $field, $layout);
|
1237 |
-
|
1238 |
-
$thumbnail = apply_filters('acfe/flexible/layout/thumbnail/layout=' . $layout['name'], $thumbnail, $field, $layout);
|
1239 |
-
$thumbnail = apply_filters('acfe/flexible/layout/thumbnail/name=' . $field['_name'] . '&layout=' . $layout['name'], $thumbnail, $field, $layout);
|
1240 |
-
$thumbnail = apply_filters('acfe/flexible/layout/thumbnail/key=' . $field['key'] . '&layout=' . $layout['name'], $thumbnail, $field, $layout);
|
1241 |
|
1242 |
$has_thumbnail = false;
|
1243 |
|
@@ -1269,11 +1220,11 @@ class acfe_field_flexible_content extends acf_field_flexible_content{
|
|
1269 |
|
1270 |
}
|
1271 |
|
1272 |
-
$div = '<div ' .
|
1273 |
|
1274 |
}
|
1275 |
|
1276 |
-
$layout['label'] = $div . '<span ' .
|
1277 |
|
1278 |
}
|
1279 |
|
@@ -1281,6 +1232,31 @@ class acfe_field_flexible_content extends acf_field_flexible_content{
|
|
1281 |
|
1282 |
}
|
1283 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1284 |
/**
|
1285 |
* Load Fields
|
1286 |
*/
|
@@ -1550,9 +1526,9 @@ class acfe_field_flexible_content extends acf_field_flexible_content{
|
|
1550 |
$is_preview = true;
|
1551 |
|
1552 |
// Actions
|
1553 |
-
do_action('acfe/flexible/enqueue',
|
1554 |
-
do_action('acfe/flexible/enqueue/name=' . $field['_name'],
|
1555 |
-
do_action('acfe/flexible/enqueue/key=' . $field['key'],
|
1556 |
|
1557 |
// Layouts Previews
|
1558 |
foreach($field['layouts'] as $layout_key => $layout){
|
4 |
exit;
|
5 |
|
6 |
add_action('wp_ajax_acfe/flexible/layout_preview', 'acfe_flexible_layout_preview');
|
7 |
+
function acfe_flexible_layout_preview($options = array()){
|
|
|
|
|
8 |
|
9 |
if(empty($options)){
|
10 |
|
25 |
if(!$field)
|
26 |
die;
|
27 |
|
28 |
+
// Flexible
|
29 |
$flexible = acf_get_field_type('flexible_content');
|
30 |
|
31 |
+
// Layout
|
32 |
$layout = $flexible->get_layout($options['layout'], $field);
|
33 |
if(!$layout)
|
34 |
die;
|
35 |
|
36 |
+
// Global
|
37 |
+
global $is_preview;
|
38 |
|
39 |
+
// Vars
|
40 |
+
$is_preview = true;
|
41 |
+
$name = $field['_name'];
|
42 |
+
$key = $field['key'];
|
43 |
+
$l_name = $layout['name'];
|
44 |
|
45 |
+
// Thumbnail
|
46 |
+
$flexible->prepare_layout_thumbnail($field, $layout);
|
|
|
|
|
47 |
|
48 |
+
// Prepare values
|
49 |
$meta = array($options['field_key'] => array(
|
50 |
wp_unslash($options['value'])
|
51 |
));
|
58 |
global $post;
|
59 |
$_post = $post;
|
60 |
|
61 |
+
// Deprecated
|
62 |
+
do_action_deprecated("acfe/flexible/preview/name={$name}", array($field, $layout), '0.8.6.7');
|
63 |
+
do_action_deprecated("acfe/flexible/preview/key={$key}", array($field, $layout), '0.8.6.7');
|
64 |
+
do_action_deprecated("acfe/flexible/layout/preview/layout={$l_name}", array($field, $layout), '0.8.6.7');
|
65 |
+
do_action_deprecated("acfe/flexible/layout/preview/name={$name}&layout={$l_name}", array($field, $layout), '0.8.6.7');
|
66 |
+
do_action_deprecated("acfe/flexible/layout/preview/key={$key}&layout={$l_name}", array($field, $layout), '0.8.6.7');
|
67 |
+
do_action_deprecated("acfe/flexible/preview", array($field, $layout), '0.8.6.7');
|
|
|
68 |
|
69 |
+
// Template
|
70 |
+
acfe_flexible_render_layout_template($layout, $field);
|
71 |
|
72 |
$post = $_post;
|
73 |
|
82 |
|
83 |
}
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
if(!class_exists('acfe_field_flexible_content')):
|
86 |
|
87 |
class acfe_field_flexible_content extends acf_field_flexible_content{
|
848 |
$flexible = acf_get_field($_field_id);
|
849 |
$layout = $flexible['layouts'][$_layout_key];
|
850 |
|
851 |
+
// Vars
|
852 |
+
$name = $flexible['name'];
|
853 |
+
$key = $flexible['key'];
|
854 |
+
$l_name = $layout['name'];
|
855 |
+
|
856 |
// Category
|
857 |
if($flexible['acfe_flexible_modal'] && acf_maybe_get($flexible['acfe_flexible_modal'], 'acfe_flexible_modal_categories')){
|
858 |
|
874 |
// Template
|
875 |
if($flexible['acfe_flexible_layouts_templates']){
|
876 |
|
877 |
+
// Prepend
|
878 |
+
$prepend = acfe_get_setting('theme_folder') ? trailingslashit(acfe_get_setting('theme_folder')) : '';
|
879 |
+
|
880 |
+
// Template
|
881 |
+
$prepend = apply_filters("acfe/flexible/prepend/template", $prepend, $flexible, $layout);
|
882 |
+
$prepend = apply_filters("acfe/flexible/prepend/template/name={$name}", $prepend, $flexible, $layout);
|
883 |
+
$prepend = apply_filters("acfe/flexible/prepend/template/key={$key}", $prepend, $flexible, $layout);
|
884 |
+
$prepend = apply_filters("acfe/flexible/prepend/template/layout={$l_name}", $prepend, $flexible, $layout);
|
885 |
+
$prepend = apply_filters("acfe/flexible/prepend/template/name={$name}&layout={$l_name}", $prepend, $flexible, $layout);
|
886 |
+
$prepend = apply_filters("acfe/flexible/prepend/template/key={$key}&layout={$l_name}", $prepend, $flexible, $layout);
|
887 |
+
|
888 |
acf_render_field_wrap(array(
|
889 |
'label' => __('Render'),
|
890 |
+
'prepend' => $prepend,
|
891 |
'name' => 'acfe_flexible_render_template',
|
892 |
'type' => 'text',
|
893 |
'class' => 'acf-fc-meta-name',
|
896 |
'placeholder' => 'template.php',
|
897 |
), 'ul');
|
898 |
|
899 |
+
|
900 |
+
// Style
|
901 |
+
$prepend = apply_filters("acfe/flexible/prepend/style", $prepend, $flexible, $layout);
|
902 |
+
$prepend = apply_filters("acfe/flexible/prepend/style/name={$name}", $prepend, $flexible, $layout);
|
903 |
+
$prepend = apply_filters("acfe/flexible/prepend/style/key={$key}", $prepend, $flexible, $layout);
|
904 |
+
$prepend = apply_filters("acfe/flexible/prepend/style/layout={$l_name}", $prepend, $flexible, $layout);
|
905 |
+
$prepend = apply_filters("acfe/flexible/prepend/style/name={$name}&layout={$l_name}", $prepend, $flexible, $layout);
|
906 |
+
$prepend = apply_filters("acfe/flexible/prepend/style/key={$key}&layout={$l_name}", $prepend, $flexible, $layout);
|
907 |
+
|
908 |
acf_render_field_wrap(array(
|
909 |
+
'prepend' => $prepend,
|
910 |
'name' => 'acfe_flexible_render_style',
|
911 |
'type' => 'text',
|
912 |
'class' => 'acf-fc-meta-name',
|
914 |
'value' => $layout['acfe_flexible_render_style'],
|
915 |
'placeholder' => 'style.css',
|
916 |
), 'ul');
|
917 |
+
|
918 |
+
|
919 |
+
// Script
|
920 |
+
$prepend = apply_filters("acfe/flexible/prepend/script", $prepend, $flexible, $layout);
|
921 |
+
$prepend = apply_filters("acfe/flexible/prepend/script/name={$name}", $prepend, $flexible, $layout);
|
922 |
+
$prepend = apply_filters("acfe/flexible/prepend/script/key={$key}", $prepend, $flexible, $layout);
|
923 |
+
$prepend = apply_filters("acfe/flexible/prepend/script/layout={$l_name}", $prepend, $flexible, $layout);
|
924 |
+
$prepend = apply_filters("acfe/flexible/prepend/script/name={$name}&layout={$l_name}", $prepend, $flexible, $layout);
|
925 |
+
$prepend = apply_filters("acfe/flexible/prepend/script/key={$key}&layout={$l_name}", $prepend, $flexible, $layout);
|
926 |
|
927 |
acf_render_field_wrap(array(
|
928 |
+
'prepend' => $prepend,
|
929 |
'name' => 'acfe_flexible_render_script',
|
930 |
'type' => 'text',
|
931 |
'class' => 'acf-fc-meta-name',
|
1125 |
|
1126 |
foreach($defaults as $default => $val){
|
1127 |
|
1128 |
+
if(($default === 'acfe_flexible_modal' && empty($field['acfe_flexible_modal']['acfe_flexible_modal_enabled'])) || empty($field[$default]))
|
1129 |
continue;
|
1130 |
|
1131 |
$field['acfe_flexible_advanced'] = 1;
|
1188 |
}
|
1189 |
|
1190 |
// Thumbnail
|
1191 |
+
$thumbnail = $this->prepare_layout_thumbnail($field, $layout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1192 |
|
1193 |
$has_thumbnail = false;
|
1194 |
|
1220 |
|
1221 |
}
|
1222 |
|
1223 |
+
$div = '<div ' . acf_esc_attrs($div) . '></div>';
|
1224 |
|
1225 |
}
|
1226 |
|
1227 |
+
$layout['label'] = $div . '<span ' . acf_esc_attrs($span) . '>' . $layout['label'] . '</span>';
|
1228 |
|
1229 |
}
|
1230 |
|
1232 |
|
1233 |
}
|
1234 |
|
1235 |
+
function prepare_layout_thumbnail($field, $layout){
|
1236 |
+
|
1237 |
+
// Vars
|
1238 |
+
$name = $field['_name'];
|
1239 |
+
$key = $field['key'];
|
1240 |
+
$l_name = $layout['name'];
|
1241 |
+
$thumbnail = &$layout['acfe_flexible_thumbnail'];
|
1242 |
+
|
1243 |
+
// Flexible Thumbnails
|
1244 |
+
$thumbnail = apply_filters("acfe/flexible/thumbnail", $thumbnail, $field, $layout);
|
1245 |
+
$thumbnail = apply_filters("acfe/flexible/thumbnail/name={$name}", $thumbnail, $field, $layout);
|
1246 |
+
$thumbnail = apply_filters("acfe/flexible/thumbnail/key={$key}", $thumbnail, $field, $layout);
|
1247 |
+
$thumbnail = apply_filters("acfe/flexible/thumbnail/layout={$l_name}", $thumbnail, $field, $layout);
|
1248 |
+
$thumbnail = apply_filters("acfe/flexible/thumbnail/name={$name}&layout={$l_name}", $thumbnail, $field, $layout);
|
1249 |
+
$thumbnail = apply_filters("acfe/flexible/thumbnail/key={$key}&layout={$l_name}", $thumbnail, $field, $layout);
|
1250 |
+
|
1251 |
+
// Deprecated
|
1252 |
+
$thumbnail = apply_filters_deprecated("acfe/flexible/layout/thumbnail/layout={$l_name}", array($thumbnail, $field, $layout), '0.8.6.7', "acfe/flexible/thumbnail/layout={$l_name}");
|
1253 |
+
$thumbnail = apply_filters_deprecated("acfe/flexible/layout/thumbnail/name={$name}&layout={$l_name}", array($thumbnail, $field, $layout), '0.8.6.7', "acfe/flexible/thumbnail/name={$name}&layout={$l_name}");
|
1254 |
+
$thumbnail = apply_filters_deprecated("acfe/flexible/layout/thumbnail/key={$key}&layout={$l_name}", array($thumbnail, $field, $layout), '0.8.6.7', "acfe/flexible/thumbnail/key={$key}&layout={$l_name}");
|
1255 |
+
|
1256 |
+
return $thumbnail;
|
1257 |
+
|
1258 |
+
}
|
1259 |
+
|
1260 |
/**
|
1261 |
* Load Fields
|
1262 |
*/
|
1526 |
$is_preview = true;
|
1527 |
|
1528 |
// Actions
|
1529 |
+
do_action('acfe/flexible/enqueue', $field, $is_preview);
|
1530 |
+
do_action('acfe/flexible/enqueue/name=' . $field['_name'], $field, $is_preview);
|
1531 |
+
do_action('acfe/flexible/enqueue/key=' . $field['key'], $field, $is_preview);
|
1532 |
|
1533 |
// Layouts Previews
|
1534 |
foreach($field['layouts'] as $layout_key => $layout){
|
includes/modules/autosync.php
CHANGED
@@ -271,6 +271,7 @@ function acfe_is_field_group_json_desync($field_group){
|
|
271 |
* Auto Sync: Helper - Has field group autosync
|
272 |
*/
|
273 |
function acfe_has_field_group_autosync($field_group, $type = false){
|
|
|
274 |
$acfe_autosync = acf_maybe_get($field_group, 'acfe_autosync', array());
|
275 |
|
276 |
if(!$type)
|
@@ -283,6 +284,7 @@ function acfe_has_field_group_autosync($field_group, $type = false){
|
|
283 |
return is_array($acfe_autosync) && in_array('php', $acfe_autosync);
|
284 |
|
285 |
return false;
|
|
|
286 |
}
|
287 |
|
288 |
/**
|
271 |
* Auto Sync: Helper - Has field group autosync
|
272 |
*/
|
273 |
function acfe_has_field_group_autosync($field_group, $type = false){
|
274 |
+
|
275 |
$acfe_autosync = acf_maybe_get($field_group, 'acfe_autosync', array());
|
276 |
|
277 |
if(!$type)
|
284 |
return is_array($acfe_autosync) && in_array('php', $acfe_autosync);
|
285 |
|
286 |
return false;
|
287 |
+
|
288 |
}
|
289 |
|
290 |
/**
|
includes/modules/dynamic-block-type.php
CHANGED
@@ -183,18 +183,6 @@ function acfe_dbt_filter_save($post_id){
|
|
183 |
$enqueue_script = get_field('enqueue_script', $post_id);
|
184 |
$enqueue_assets = get_field('enqueue_assets', $post_id);
|
185 |
|
186 |
-
// Render Template
|
187 |
-
if(!empty($render_template))
|
188 |
-
$render_template = ACFE_THEME_PATH . '/' . $render_template;
|
189 |
-
|
190 |
-
// Enqueue Style
|
191 |
-
if(!empty($enqueue_style))
|
192 |
-
$enqueue_style = ACFE_THEME_URL . '/' . $enqueue_style;
|
193 |
-
|
194 |
-
// Enqueue Script
|
195 |
-
if(!empty($enqueue_script))
|
196 |
-
$enqueue_script = ACFE_THEME_URL . '/' . $enqueue_script;
|
197 |
-
|
198 |
// Register: Args
|
199 |
$register_args = array(
|
200 |
'name' => $name,
|
@@ -401,7 +389,7 @@ function acfe_dbt_admin_columns_html($column, $post_id){
|
|
401 |
|
402 |
if(!empty($render_template)){
|
403 |
|
404 |
-
echo '<code style="font-size: 12px;"
|
405 |
|
406 |
}
|
407 |
|
@@ -560,6 +548,91 @@ function acfe_dbt_load(){
|
|
560 |
|
561 |
add_action('add_meta_boxes', 'acfe_dbt_load_meta_boxes');
|
562 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
563 |
}
|
564 |
|
565 |
function acfe_dbt_load_meta_boxes(){
|
@@ -1133,7 +1206,7 @@ Colors: Specify colors & Dashicons class',
|
|
1133 |
'acfe_permissions' => '',
|
1134 |
'default_value' => '',
|
1135 |
'placeholder' => '',
|
1136 |
-
'prepend' =>
|
1137 |
'append' => '',
|
1138 |
'maxlength' => '',
|
1139 |
),
|
@@ -1196,7 +1269,7 @@ Colors: Specify colors & Dashicons class',
|
|
1196 |
'acfe_permissions' => '',
|
1197 |
'default_value' => '',
|
1198 |
'placeholder' => '',
|
1199 |
-
'prepend' =>
|
1200 |
'append' => '',
|
1201 |
'maxlength' => '',
|
1202 |
),
|
@@ -1218,7 +1291,7 @@ Colors: Specify colors & Dashicons class',
|
|
1218 |
'acfe_permissions' => '',
|
1219 |
'default_value' => '',
|
1220 |
'placeholder' => '',
|
1221 |
-
'prepend' =>
|
1222 |
'append' => '',
|
1223 |
'maxlength' => '',
|
1224 |
),
|
183 |
$enqueue_script = get_field('enqueue_script', $post_id);
|
184 |
$enqueue_assets = get_field('enqueue_assets', $post_id);
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
// Register: Args
|
187 |
$register_args = array(
|
188 |
'name' => $name,
|
389 |
|
390 |
if(!empty($render_template)){
|
391 |
|
392 |
+
echo '<code style="font-size: 12px;">' . $render_template . '</code>';
|
393 |
|
394 |
}
|
395 |
|
548 |
|
549 |
add_action('add_meta_boxes', 'acfe_dbt_load_meta_boxes');
|
550 |
|
551 |
+
if(!isset($_REQUEST['post']))
|
552 |
+
return;
|
553 |
+
|
554 |
+
$post_id = $_REQUEST['post'];
|
555 |
+
$name = get_field('name', $post_id);
|
556 |
+
|
557 |
+
$prepend = acfe_get_setting('theme_folder') ? trailingslashit(acfe_get_setting('theme_folder')) : '';
|
558 |
+
|
559 |
+
add_filter('acf/prepare_field/name=render_template', function($field) use($name, $prepend){
|
560 |
+
|
561 |
+
$prepend = apply_filters("acfe/block_type/prepend/template", $prepend, $name);
|
562 |
+
$prepend = apply_filters("acfe/block_type/prepend/template/name={$name}", $prepend, $name);
|
563 |
+
|
564 |
+
$field['prepend'] = $prepend;
|
565 |
+
|
566 |
+
return $field;
|
567 |
+
|
568 |
+
});
|
569 |
+
|
570 |
+
add_filter('acf/prepare_field/name=enqueue_style', function($field) use($name, $prepend){
|
571 |
+
|
572 |
+
$prepend = apply_filters("acfe/block_type/prepend/style", $prepend, $name);
|
573 |
+
$prepend = apply_filters("acfe/block_type/prepend/style/name={$name}", $prepend, $name);
|
574 |
+
|
575 |
+
$field['prepend'] = $prepend;
|
576 |
+
|
577 |
+
return $field;
|
578 |
+
|
579 |
+
});
|
580 |
+
|
581 |
+
add_filter('acf/prepare_field/name=enqueue_script', function($field) use($name, $prepend){
|
582 |
+
|
583 |
+
$prepend = apply_filters("acfe/block_type/prepend/script", $prepend, $name);
|
584 |
+
$prepend = apply_filters("acfe/block_type/prepend/script/name={$name}", $prepend, $name);
|
585 |
+
|
586 |
+
$field['prepend'] = $prepend;
|
587 |
+
|
588 |
+
return $field;
|
589 |
+
|
590 |
+
});
|
591 |
+
|
592 |
+
}
|
593 |
+
|
594 |
+
add_action('load-post-new.php', 'acfe_dbt_load_new');
|
595 |
+
function acfe_dbt_load_new(){
|
596 |
+
|
597 |
+
// globals
|
598 |
+
global $typenow;
|
599 |
+
|
600 |
+
// Restrict
|
601 |
+
if($typenow !== 'acfe-dbt')
|
602 |
+
return;
|
603 |
+
|
604 |
+
$prepend = acfe_get_setting('theme_folder') ? trailingslashit(acfe_get_setting('theme_folder')) : '';
|
605 |
+
|
606 |
+
add_filter('acf/prepare_field/name=render_template', function($field) use($prepend){
|
607 |
+
|
608 |
+
$prepend = apply_filters('acfe/block_type/prepend/template', $prepend, '');
|
609 |
+
|
610 |
+
$field['prepend'] = $prepend;
|
611 |
+
|
612 |
+
return $field;
|
613 |
+
|
614 |
+
});
|
615 |
+
|
616 |
+
add_filter('acf/prepare_field/name=enqueue_style', function($field) use($prepend){
|
617 |
+
|
618 |
+
$prepend = apply_filters('acfe/block_type/prepend/style', $prepend, '');
|
619 |
+
|
620 |
+
$field['prepend'] = $prepend;
|
621 |
+
|
622 |
+
return $field;
|
623 |
+
|
624 |
+
});
|
625 |
+
|
626 |
+
add_filter('acf/prepare_field/name=enqueue_script', function($field) use($prepend){
|
627 |
+
|
628 |
+
$prepend = apply_filters('acfe/block_type/prepend/script', $prepend, '');
|
629 |
+
|
630 |
+
$field['prepend'] = $prepend;
|
631 |
+
|
632 |
+
return $field;
|
633 |
+
|
634 |
+
});
|
635 |
+
|
636 |
}
|
637 |
|
638 |
function acfe_dbt_load_meta_boxes(){
|
1206 |
'acfe_permissions' => '',
|
1207 |
'default_value' => '',
|
1208 |
'placeholder' => '',
|
1209 |
+
'prepend' => '',
|
1210 |
'append' => '',
|
1211 |
'maxlength' => '',
|
1212 |
),
|
1269 |
'acfe_permissions' => '',
|
1270 |
'default_value' => '',
|
1271 |
'placeholder' => '',
|
1272 |
+
'prepend' => '',
|
1273 |
'append' => '',
|
1274 |
'maxlength' => '',
|
1275 |
),
|
1291 |
'acfe_permissions' => '',
|
1292 |
'default_value' => '',
|
1293 |
'placeholder' => '',
|
1294 |
+
'prepend' => '',
|
1295 |
'append' => '',
|
1296 |
'maxlength' => '',
|
1297 |
),
|
includes/modules/dynamic-post-type.php
CHANGED
@@ -2103,7 +2103,7 @@ etc...',
|
|
2103 |
'acfe_permissions' => '',
|
2104 |
'default_value' => '',
|
2105 |
'placeholder' => 'my-template.php',
|
2106 |
-
'prepend' =>
|
2107 |
'append' => '',
|
2108 |
'maxlength' => '',
|
2109 |
),
|
@@ -2298,7 +2298,7 @@ etc...',
|
|
2298 |
'acfe_permissions' => '',
|
2299 |
'default_value' => '',
|
2300 |
'placeholder' => 'my-template.php',
|
2301 |
-
'prepend' =>
|
2302 |
'append' => '',
|
2303 |
'maxlength' => '',
|
2304 |
),
|
2103 |
'acfe_permissions' => '',
|
2104 |
'default_value' => '',
|
2105 |
'placeholder' => 'my-template.php',
|
2106 |
+
'prepend' => trailingslashit(acfe_get_setting('theme_folder')),
|
2107 |
'append' => '',
|
2108 |
'maxlength' => '',
|
2109 |
),
|
2298 |
'acfe_permissions' => '',
|
2299 |
'default_value' => '',
|
2300 |
'placeholder' => 'my-template.php',
|
2301 |
+
'prepend' => trailingslashit(acfe_get_setting('theme_folder')),
|
2302 |
'append' => '',
|
2303 |
'maxlength' => '',
|
2304 |
),
|
includes/modules/dynamic-taxonomy.php
CHANGED
@@ -1732,7 +1732,7 @@ assign_terms : edit_posts',
|
|
1732 |
'acfe_permissions' => '',
|
1733 |
'default_value' => '',
|
1734 |
'placeholder' => 'my-template.php',
|
1735 |
-
'prepend' =>
|
1736 |
'append' => '',
|
1737 |
'maxlength' => '',
|
1738 |
),
|
1732 |
'acfe_permissions' => '',
|
1733 |
'default_value' => '',
|
1734 |
'placeholder' => 'my-template.php',
|
1735 |
+
'prepend' => trailingslashit(acfe_get_setting('theme_folder')),
|
1736 |
'append' => '',
|
1737 |
'maxlength' => '',
|
1738 |
),
|
includes/modules/form/actions/email.php
CHANGED
@@ -136,8 +136,8 @@ class acfe_form_email{
|
|
136 |
);
|
137 |
|
138 |
// Deprecated filters
|
139 |
-
$args =
|
140 |
-
$args =
|
141 |
|
142 |
// Filters
|
143 |
$args = apply_filters('acfe/form/submit/email_args', $args, $form, $action);
|
@@ -146,7 +146,7 @@ class acfe_form_email{
|
|
146 |
if(!empty($action)){
|
147 |
|
148 |
// Deprecated filter
|
149 |
-
$args =
|
150 |
|
151 |
// Filter
|
152 |
$args = apply_filters('acfe/form/submit/email_args/action=' . $action, $args, $form, $action);
|
136 |
);
|
137 |
|
138 |
// Deprecated filters
|
139 |
+
$args = apply_filters_deprecated('acfe/form/submit/email/args', array($args, $form, $action), '0.8.1', 'acfe/form/submit/email_args');
|
140 |
+
$args = apply_filters_deprecated('acfe/form/submit/email/args/form=' . $form_name, array($args, $form, $action), '0.8.1', 'acfe/form/submit/email_args/form=' . $form_name);
|
141 |
|
142 |
// Filters
|
143 |
$args = apply_filters('acfe/form/submit/email_args', $args, $form, $action);
|
146 |
if(!empty($action)){
|
147 |
|
148 |
// Deprecated filter
|
149 |
+
$args = apply_filters_deprecated('acfe/form/submit/email/args/action=' . $action, array($args, $form, $action), '0.8.1', 'acfe/form/submit/email_args/action=' . $action);
|
150 |
|
151 |
// Filter
|
152 |
$args = apply_filters('acfe/form/submit/email_args/action=' . $action, $args, $form, $action);
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: acf, custom fields, meta, admin, fields, form, repeater, content
|
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.4
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 0.8.6.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -409,7 +409,7 @@ add_action('acf/init', 'my_acfe_modules');
|
|
409 |
function my_acfe_modules(){
|
410 |
|
411 |
// Enable Single Meta Save
|
412 |
-
|
413 |
|
414 |
}
|
415 |
|
@@ -513,7 +513,33 @@ Note: This feature is available in the Dynamic Post Type UI in the Administratio
|
|
513 |
|
514 |
= How to get fields set in the Post Type Archive location? =
|
515 |
|
516 |
-
Fields are saved in the option: `{post_type}_archive`. Frontend usage example: `get_field('my_field', 'post_archive')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
517 |
|
518 |
= How the bidirectional field setting works? =
|
519 |
|
@@ -603,51 +629,48 @@ When using this function, you have access to the following global variables: `$l
|
|
603 |
You can use the following filters:
|
604 |
|
605 |
`
|
606 |
-
// add_filter('acfe/flexible/thumbnail/name=my_flexible',
|
607 |
-
// add_filter('acfe/flexible/thumbnail/key=field_xxxxxx',
|
608 |
-
|
609 |
-
// add_filter('acfe/flexible/
|
610 |
-
// add_filter('acfe/flexible/layout/thumbnail/key=field_xxxxxx&layout=my_layout', 'acf_flexible_layout_thumbnail', 10, 3);
|
611 |
|
612 |
-
add_filter('acfe/flexible/
|
613 |
function acf_flexible_layout_thumbnail($thumbnail, $field, $layout){
|
614 |
|
615 |
-
|
616 |
// Must return an URL or Attachment ID
|
617 |
return 'https://www.example.com/my-image.jpg';
|
618 |
|
619 |
}
|
620 |
`
|
621 |
|
622 |
-
= How to change the Flexible Content: Dynamic Preview content in PHP? =
|
623 |
|
624 |
You can use the following actions:
|
625 |
|
626 |
`
|
627 |
-
//
|
628 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
629 |
|
630 |
-
add_action('acfe/flexible/preview', 'acf_flexible_preview', 10, 2);
|
631 |
-
function acf_flexible_preview($field, $layout){
|
632 |
-
|
633 |
-
echo 'My Preview';
|
634 |
-
|
635 |
-
// It is important to use 'die', as we are in an Ajax request
|
636 |
-
die;
|
637 |
-
|
638 |
}
|
639 |
|
640 |
-
// add_action('acfe/flexible/
|
641 |
-
// add_action('acfe/flexible/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
642 |
|
643 |
-
add_action('acfe/flexible/layout/preview/layout=my_layout', 'acf_flexible_layout_preview', 10, 2);
|
644 |
-
function acf_flexible_layout_preview($field, $layout){
|
645 |
-
|
646 |
-
echo 'My Preview';
|
647 |
-
|
648 |
-
// It is important to use 'die', as we are in an Ajax request
|
649 |
-
die;
|
650 |
-
|
651 |
}
|
652 |
`
|
653 |
|
@@ -673,11 +696,11 @@ function acf_flexible_enqueue($field, $is_preview){
|
|
673 |
|
674 |
}
|
675 |
|
676 |
-
// add_action('acfe/flexible/
|
677 |
-
// add_action('acfe/flexible/
|
678 |
|
679 |
-
add_action('acfe/flexible/
|
680 |
-
function
|
681 |
|
682 |
// Only in Ajax preview
|
683 |
if($is_preview){
|
@@ -696,14 +719,13 @@ function acf_flexible_layout_enqueue($field, $layout, $is_preview){
|
|
696 |
You can use the following actions:
|
697 |
|
698 |
`
|
699 |
-
// add_filter('acfe/flexible/render/template',
|
700 |
-
// add_filter('acfe/flexible/render/template/name=my_flexible',
|
701 |
-
// add_filter('acfe/flexible/render/template/key=field_xxxxxx',
|
702 |
-
|
703 |
-
// add_filter('acfe/flexible/
|
704 |
-
// add_filter('acfe/flexible/layout/render/template/key=field_xxxxxx&layout=my_layout', 'acf_flexible_layout_render_template', 10, 4);
|
705 |
|
706 |
-
add_filter('acfe/flexible/
|
707 |
function acf_flexible_layout_render_template($template, $field, $layout, $is_preview){
|
708 |
|
709 |
// Only in Ajax preview
|
@@ -720,11 +742,10 @@ function acf_flexible_layout_render_template($template, $field, $layout, $is_pre
|
|
720 |
// add_filter('acfe/flexible/render/style', 'acf_flexible_layout_render_style', 10, 4);
|
721 |
// add_filter('acfe/flexible/render/style/name=my_flexible', 'acf_flexible_layout_render_style', 10, 4);
|
722 |
// add_filter('acfe/flexible/render/style/key=field_xxxxxx', 'acf_flexible_layout_render_style', 10, 4);
|
|
|
|
|
723 |
|
724 |
-
|
725 |
-
// add_filter('acfe/flexible/layout/render/style/key=field_xxxxxx&layout=my_layout', 'acf_flexible_layout_render_style', 10, 4);
|
726 |
-
|
727 |
-
add_filter('acfe/flexible/layout/render/style/layout=my_layout', 'acf_flexible_layout_render_style', 10, 4);
|
728 |
function acf_flexible_layout_render_style($style, $field, $layout, $is_preview){
|
729 |
|
730 |
// Only in Ajax preview
|
@@ -741,11 +762,10 @@ function acf_flexible_layout_render_style($style, $field, $layout, $is_preview){
|
|
741 |
// add_filter('acfe/flexible/render/script', 'acf_flexible_layout_render_script', 10, 4);
|
742 |
// add_filter('acfe/flexible/render/script/name=my_flexible', 'acf_flexible_layout_render_script', 10, 4);
|
743 |
// add_filter('acfe/flexible/render/script/key=field_xxxxxx', 'acf_flexible_layout_render_script', 10, 4);
|
|
|
|
|
744 |
|
745 |
-
|
746 |
-
// add_filter('acfe/flexible/layout/render/script/key=field_xxxxxx&layout=my_layout', 'acf_flexible_layout_render_script', 10, 4);
|
747 |
-
|
748 |
-
add_filter('acfe/flexible/layout/render/script/layout=my_layout', 'acf_flexible_layout_render_script', 10, 4);
|
749 |
function acf_flexible_layout_render_script($script, $field, $layout, $is_preview){
|
750 |
|
751 |
// Only in Ajax preview
|
@@ -802,31 +822,31 @@ add_action('acf/init', 'my_acfe_modules');
|
|
802 |
function my_acfe_modules(){
|
803 |
|
804 |
// Disable Ajax Author box
|
805 |
-
|
806 |
|
807 |
// Disable ACF > Block Types
|
808 |
-
|
809 |
|
810 |
// Disable Forms
|
811 |
-
|
812 |
|
813 |
// Disable Tools > Post Types
|
814 |
-
|
815 |
|
816 |
// Disable Tools > Taxonomies
|
817 |
-
|
818 |
|
819 |
// Disable ACF > Options Pages
|
820 |
-
|
821 |
|
822 |
// Disable Settings > Options
|
823 |
-
|
824 |
|
825 |
// Disable Enhanced UI (Taxonomies, Users, Settings)
|
826 |
-
|
827 |
|
828 |
// Disable Multilangual Compatibility
|
829 |
-
|
830 |
|
831 |
}
|
832 |
`
|
@@ -846,6 +866,39 @@ function my_acfe_modules(){
|
|
846 |
|
847 |
== Changelog ==
|
848 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
849 |
= 0.8.6.6 =
|
850 |
* Module: Multilang - Fixed WPML front-end language detection for custom languages
|
851 |
* Module: Settings - Added "Multilang" & "Single Meta" settings in the UI
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.4
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 0.8.6.7
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
409 |
function my_acfe_modules(){
|
410 |
|
411 |
// Enable Single Meta Save
|
412 |
+
acfe_update_setting('modules/single_meta', true);
|
413 |
|
414 |
}
|
415 |
|
513 |
|
514 |
= How to get fields set in the Post Type Archive location? =
|
515 |
|
516 |
+
Fields are saved in the option: `{post_type}_archive`. Frontend usage example: `get_field('my_field', 'post_archive')`.
|
517 |
+
|
518 |
+
You can also using the following code in any Post Type Archive/Single Template:
|
519 |
+
|
520 |
+
`
|
521 |
+
if(have_archive()):
|
522 |
+
while(have_archive()): the_archive();
|
523 |
+
|
524 |
+
// Retrieve 'my_field' from the current Post Type Archive Page
|
525 |
+
echo get_field('my_field');
|
526 |
+
|
527 |
+
endwhile;
|
528 |
+
endif;
|
529 |
+
`
|
530 |
+
|
531 |
+
Or you can also pass a post type, in order to retrieve fields from specific Post Type Archive Page:
|
532 |
+
|
533 |
+
`
|
534 |
+
if(have_archive('my-post-type')):
|
535 |
+
while(have_archive('my-post-type')): the_archive();
|
536 |
+
|
537 |
+
// Retrieve 'my_field' from "My Post Type" - Archive Page
|
538 |
+
echo get_field('my_field');
|
539 |
+
|
540 |
+
endwhile;
|
541 |
+
endif;
|
542 |
+
`
|
543 |
|
544 |
= How the bidirectional field setting works? =
|
545 |
|
629 |
You can use the following filters:
|
630 |
|
631 |
`
|
632 |
+
// add_filter('acfe/flexible/thumbnail/name=my_flexible', 'acf_flexible_layout_thumbnail', 10, 3);
|
633 |
+
// add_filter('acfe/flexible/thumbnail/key=field_xxxxxx', 'acf_flexible_layout_thumbnail', 10, 3);
|
634 |
+
// add_filter('acfe/flexible/thumbnail/name=my_flexible&layout=my_layout', 'acf_flexible_layout_thumbnail', 10, 3);
|
635 |
+
// add_filter('acfe/flexible/thumbnail/key=field_xxxxxx&layout=my_layout', 'acf_flexible_layout_thumbnail', 10, 3);
|
|
|
636 |
|
637 |
+
add_filter('acfe/flexible/thumbnail/layout=my_layout', 'acf_flexible_layout_thumbnail', 10, 3);
|
638 |
function acf_flexible_layout_thumbnail($thumbnail, $field, $layout){
|
639 |
|
|
|
640 |
// Must return an URL or Attachment ID
|
641 |
return 'https://www.example.com/my-image.jpg';
|
642 |
|
643 |
}
|
644 |
`
|
645 |
|
646 |
+
= How to change the Flexible Content: Dynamic Render/Preview content in PHP? =
|
647 |
|
648 |
You can use the following actions:
|
649 |
|
650 |
`
|
651 |
+
// add_filter('acfe/flexible/render/template/name=my_flexible', 'acf_disable_file_render', 10, 4);
|
652 |
+
// add_filter('acfe/flexible/render/template/key=field_xxxxxx', 'acf_disable_file_render', 10, 4);
|
653 |
+
// add_filter('acfe/flexible/render/template/name=my_flexible&layout=my_layout', 'acf_disable_file_render', 10, 4);
|
654 |
+
// add_filter('acfe/flexible/render/template/key=field_xxxxxx&layout=my_layout', 'acf_disable_file_render', 10, 4);
|
655 |
+
|
656 |
+
add_filter('acfe/flexible/render/template/layout=my_layout', 'acf_disable_file_render', 10, 4);
|
657 |
+
function acf_disable_file_render($file, $field, $layout, $is_preview){
|
658 |
+
|
659 |
+
// Do not include the template file
|
660 |
+
return false;
|
661 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
662 |
}
|
663 |
|
664 |
+
// add_action('acfe/flexible/render/before_template/name=my_flexible', 'acf_custom_layout_render', 10, 3);
|
665 |
+
// add_action('acfe/flexible/render/before_template/key=field_xxxxxx', 'acf_custom_layout_render', 10, 3);
|
666 |
+
// add_action('acfe/flexible/render/before_template/name=my_flexible&layout=my_layout', 'acf_custom_layout_render', 10, 3);
|
667 |
+
// add_action('acfe/flexible/render/before_template/key=field_xxxxxx&layout=my_layout', 'acf_custom_layout_render', 10, 3);
|
668 |
+
|
669 |
+
add_action('acfe/flexible/render/before_template/layout=my_layout', 'acf_custom_layout_render', 10, 3);
|
670 |
+
function acf_custom_layout_render($field, $layout, $is_preview){
|
671 |
+
|
672 |
+
echo get_sub_field('my_field');
|
673 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
674 |
}
|
675 |
`
|
676 |
|
696 |
|
697 |
}
|
698 |
|
699 |
+
// add_action('acfe/flexible/enqueue/name=my_flexible&layout=my_layout', 'acf_flexible_enqueue', 10, 3);
|
700 |
+
// add_action('acfe/flexible/enqueue/key=field_xxxxxx&layout=my_layout', 'acf_flexible_enqueue', 10, 3);
|
701 |
|
702 |
+
add_action('acfe/flexible/enqueue/layout=my_layout', 'acf_flexible_enqueue', 10, 3);
|
703 |
+
function acf_flexible_enqueue($field, $layout, $is_preview){
|
704 |
|
705 |
// Only in Ajax preview
|
706 |
if($is_preview){
|
719 |
You can use the following actions:
|
720 |
|
721 |
`
|
722 |
+
// add_filter('acfe/flexible/render/template', 'acf_flexible_layout_render_template', 10, 4);
|
723 |
+
// add_filter('acfe/flexible/render/template/name=my_flexible', 'acf_flexible_layout_render_template', 10, 4);
|
724 |
+
// add_filter('acfe/flexible/render/template/key=field_xxxxxx', 'acf_flexible_layout_render_template', 10, 4);
|
725 |
+
// add_filter('acfe/flexible/render/template/name=my_flexible&layout=my_layout', 'acf_flexible_layout_render_template', 10, 4);
|
726 |
+
// add_filter('acfe/flexible/render/template/key=field_xxxxxx&layout=my_layout', 'acf_flexible_layout_render_template', 10, 4);
|
|
|
727 |
|
728 |
+
add_filter('acfe/flexible/render/template/layout=my_layout', 'acf_flexible_layout_render_template', 10, 4);
|
729 |
function acf_flexible_layout_render_template($template, $field, $layout, $is_preview){
|
730 |
|
731 |
// Only in Ajax preview
|
742 |
// add_filter('acfe/flexible/render/style', 'acf_flexible_layout_render_style', 10, 4);
|
743 |
// add_filter('acfe/flexible/render/style/name=my_flexible', 'acf_flexible_layout_render_style', 10, 4);
|
744 |
// add_filter('acfe/flexible/render/style/key=field_xxxxxx', 'acf_flexible_layout_render_style', 10, 4);
|
745 |
+
// add_filter('acfe/flexible/render/style/name=my_flexible&layout=my_layout', 'acf_flexible_layout_render_style', 10, 4);
|
746 |
+
// add_filter('acfe/flexible/render/style/key=field_xxxxxx&layout=my_layout', 'acf_flexible_layout_render_style', 10, 4);
|
747 |
|
748 |
+
add_filter('acfe/flexible/render/style/layout=my_layout', 'acf_flexible_layout_render_style', 10, 4);
|
|
|
|
|
|
|
749 |
function acf_flexible_layout_render_style($style, $field, $layout, $is_preview){
|
750 |
|
751 |
// Only in Ajax preview
|
762 |
// add_filter('acfe/flexible/render/script', 'acf_flexible_layout_render_script', 10, 4);
|
763 |
// add_filter('acfe/flexible/render/script/name=my_flexible', 'acf_flexible_layout_render_script', 10, 4);
|
764 |
// add_filter('acfe/flexible/render/script/key=field_xxxxxx', 'acf_flexible_layout_render_script', 10, 4);
|
765 |
+
// add_filter('acfe/flexible/render/script/name=my_flexible&layout=my_layout', 'acf_flexible_layout_render_script', 10, 4);
|
766 |
+
// add_filter('acfe/flexible/render/script/key=field_xxxxxx&layout=my_layout', 'acf_flexible_layout_render_script', 10, 4);
|
767 |
|
768 |
+
add_filter('acfe/flexible/render/script/layout=my_layout', 'acf_flexible_layout_render_script', 10, 4);
|
|
|
|
|
|
|
769 |
function acf_flexible_layout_render_script($script, $field, $layout, $is_preview){
|
770 |
|
771 |
// Only in Ajax preview
|
822 |
function my_acfe_modules(){
|
823 |
|
824 |
// Disable Ajax Author box
|
825 |
+
acfe_update_setting('modules/author', false);
|
826 |
|
827 |
// Disable ACF > Block Types
|
828 |
+
acfe_update_setting('modules/dynamic_block_types', false);
|
829 |
|
830 |
// Disable Forms
|
831 |
+
acfe_update_setting('modules/dynamic_forms', false);
|
832 |
|
833 |
// Disable Tools > Post Types
|
834 |
+
acfe_update_setting('modules/dynamic_post_types', false);
|
835 |
|
836 |
// Disable Tools > Taxonomies
|
837 |
+
acfe_update_setting('modules/dynamic_taxonomies', false);
|
838 |
|
839 |
// Disable ACF > Options Pages
|
840 |
+
acfe_update_setting('modules/dynamic_options_pages', false);
|
841 |
|
842 |
// Disable Settings > Options
|
843 |
+
acfe_update_setting('modules/options', false);
|
844 |
|
845 |
// Disable Enhanced UI (Taxonomies, Users, Settings)
|
846 |
+
acfe_update_setting('modules/ui', false);
|
847 |
|
848 |
// Disable Multilangual Compatibility
|
849 |
+
acfe_update_setting('modules/multilang', false);
|
850 |
|
851 |
}
|
852 |
`
|
866 |
|
867 |
== Changelog ==
|
868 |
|
869 |
+
= 0.8.6.7 =
|
870 |
+
* Field: Flexible Content - Enhanced Code Base
|
871 |
+
* Field: Flexible Content - Dynamic Render - Enhanced `get_flexible()` & `the_flexible()` functions logic
|
872 |
+
* Field: Flexible Content - Dynamic Render - Enhanced Template, Style & Script files detection. Now detects paths from WP root directory, and from `/wp-content/` directory
|
873 |
+
* Field: Flexible Content - Dynamic Preview - Automatically include the layout `{template}-preview.php` file instead of `template.php`, if it is found within the same path
|
874 |
+
* Field: Flexible Content - Dynamic Preview - Automatically enqueue the layout `{style}-preview.css` file in addition of `style.css`, if it is found within the same path
|
875 |
+
* Field: Flexible Content - Dynamic Preview - Automatically enqueue the layout `{script}-preview.js` file instead of `script.js`, if it is found within the same path
|
876 |
+
* Field: Flexible Content - Added `filter('acfe/flexible/prepend/template/name=my_flexible', $path, $flexible, $layout)` and its variations to alter the field's setting prepend (display only)
|
877 |
+
* Field: Flexible Content - Added `filter('acfe/flexible/prepend/style/name=my_flexible', $path, $flexible, $layout)` and its variations to alter the field's setting prepend (display only)
|
878 |
+
* Field: Flexible Content - Added `filter('acfe/flexible/prepend/script/name=my_flexible', $path, $flexible, $layout)` and its variations to alter the field's setting prepend (display only)
|
879 |
+
* Field: Flexible Content - Deprecated `acfe/flexible/layout/thumbnail/layout=my_layout` hooks and its variations. Use `acfe/flexible/thumbnail/layout=my_layout` instead
|
880 |
+
* Field: Flexible Content - Deprecated `acfe/flexible/layout/render/template/layout=my_layout` hooks and its variations. Use `acfe/flexible/render/template/layout=my_layout` instead
|
881 |
+
* Field: Flexible Content - Deprecated `acfe/flexible/layout/render/before_template/layout=my_layout` hooks and its variations. Use `acfe/flexible/render/before_template/layout=my_layout` instead
|
882 |
+
* Field: Flexible Content - Deprecated `acfe/flexible/layout/render/after_template/layout=my_layout` hooks and its variations. Use `acfe/flexible/render/after_template/layout=my_layout` instead
|
883 |
+
* Field: Flexible Content - Deprecated `acfe/flexible/layout/render/style/layout=my_layout` hooks and its variations. Use `acfe/flexible/render/style/layout=my_layout` instead
|
884 |
+
* Field: Flexible Content - Deprecated `acfe/flexible/layout/render/script/layout=my_layout` hooks and its variations. Use `acfe/flexible/render/script/layout=my_layout` instead
|
885 |
+
* Field: Flexible Content - Deprecated `acfe/flexible/layout/enqueue/layout=my_layout` hooks and its variations. Use `acfe/flexible/enqueue/layout=my_layout` instead
|
886 |
+
* Field: Flexible Content - Deprecated `acfe/flexible/preview` hooks and its variations
|
887 |
+
* Module: Dynamic Block Types - The "Template Render" setting is now independant from the theme
|
888 |
+
* Module: Dynamic Block Types - Added `filter('acfe/block_type/prepend/template/name=my-block-type', $path, name)` and its variations to alter the field's setting prepend (display only)
|
889 |
+
* Module: Dynamic Block Types - Added `filter('acfe/block_type/prepend/style/name=my-block-type', $path, name)` and its variations to alter the field's setting prepend (display only)
|
890 |
+
* Module: Dynamic Block Types - Added `filter('acfe/block_type/prepend/script/name=my-block-type', $path, name)` and its variations to alter the field's setting prepend (display only)
|
891 |
+
* Module: Post Type Archive Page - `have_archive()` now allows to pass the post type name. Usage example: `while(have_archive('my-post-type')): the_archive()`
|
892 |
+
* Module: Multilang - Enhanced Options Pages Post ID detection
|
893 |
+
* Module: Multilang - Added "Post Type List" & "Taxonomy List" Locations compatibility
|
894 |
+
* Module: Multilang - Fixed the "Disable module" setting which wasn't working correctly
|
895 |
+
* Module: Multilang - Fixed Polylang Ajax language detection
|
896 |
+
* General: Enhanced `acfe_update_setting()`, `acfe_get_setting()` functions and `filer('acfe/settings/{name}')` hook
|
897 |
+
* General: Removed `ACFE_THEME_PATH` & `ACFE_THEME_URL` constants
|
898 |
+
* General: Added `acfe/theme_path`, `acfe/theme_url` & `acfe/theme_folder` settings
|
899 |
+
* General: The default `acfe/php_save`, `acfe/php_load` & `acfe/theme_folder` settings are now generated based on the new `acfe/theme_path` & `acfe/theme_url` settings
|
900 |
+
* General: The `acfe/theme_folder` setting is now used to preprend Flexible Content & Block Types render fields settings (Display only)
|
901 |
+
|
902 |
= 0.8.6.6 =
|
903 |
* Module: Multilang - Fixed WPML front-end language detection for custom languages
|
904 |
* Module: Settings - Added "Multilang" & "Single Meta" settings in the UI
|