Skip to content

Commit

Permalink
ACF Extended: 0.9.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
acf-extended committed Apr 28, 2024
1 parent 4002ff2 commit 18945c1
Show file tree
Hide file tree
Showing 16 changed files with 889 additions and 416 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,27 @@ Manage WordPress Options from the Settings > Options page. Options value (string

## 📋 Changelog

### 0.9.0.2

**ACF Extended Pro 0.9.0.2:**

* Module: Global Field Location - Fixed Field Group Location escaping issues
* Field Groups: Advanced Locations - Fixed Field Group Location escaping issues
* Field: Payment - Fixed `{field:payment}` Template Tag output
* Field: Flexible Content - Grid - Added translatable strings
* Global: Country/Currency/Language - Added PHP filters to allow customization

**ACF Extended Basic 0.9.0.2:**

* Module: Form - Enhanced load/validate/submit/render hooks strategy
* Module: Form - Fixed instruction placement undefined key warning
* Module: Form - "Current Post" Target/Source now correctly use the WP Query loop `post_id`
* Module: Form - Enhanced multiple forms on single page support
* Module: Form - Added missing `wpautop()` on email content when using "Content Editor"
* Module: Form - Fixed Taxonomy "Load Terms" & Image "Featured Thumbnail" compatibility
* Fields Condition - Enhanced `acf.newCondition` closer to native ACF logic
* Global: Updated French translation

### 0.9.0.1

* Module: Forms - Fixed upgrade issues when using distant Auto Update
Expand Down
6 changes: 3 additions & 3 deletions acf-extended.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Advanced Custom Fields: Extended
* Description: All-in-one enhancement suite that improves WordPress & Advanced Custom Fields.
* Version: 0.9.0.1
* Version: 0.9.0.2
* Author: ACF Extended
* Plugin URI: https://www.acf-extended.com
* Author URI: https://www.acf-extended.com
Expand All @@ -19,7 +19,7 @@
class ACFE{

// vars
var $version = '0.9.0.1';
var $version = '0.9.0.2';

/**
* construct
Expand Down Expand Up @@ -190,9 +190,9 @@ function load(){
acfe_include('includes/modules/form/module-form-compatibility.php');
acfe_include('includes/modules/form/module-form-deprecated.php');
acfe_include('includes/modules/form/module-form-fields.php');
acfe_include('includes/modules/form/module-form-format.php');
acfe_include('includes/modules/form/module-form-front.php');
acfe_include('includes/modules/form/module-form-front-render.php');
acfe_include('includes/modules/form/module-form-hooks.php');
acfe_include('includes/modules/form/module-form-shortcode.php');
acfe_include('includes/modules/form/module-form-upgrades.php');

Expand Down
17 changes: 15 additions & 2 deletions assets/js/acfe-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -4488,9 +4488,22 @@
// - this field is used to setup the conditional logic events
var field = target.getField(rule.field);

// ACF Extended: Check in all form if targeted field not found
// acfe
// found target, but not the field to check value against
if (target && !field) {
field = acf.getField(rule.field);

// find the field in the whole page
// we must add this step because acf.getField('do_not_exists') will still instantiate the field
var findField = acf.findField(rule.field);

// find field
if (findField.length) {

//instatiate field once found
field = acf.getField(rule.field);

}

}

// bail ealry if no target or no field (possible if field doesn't exist due to HTML error)
Expand Down
2 changes: 1 addition & 1 deletion assets/js/acfe-input.min.js

Large diffs are not rendered by default.

87 changes: 85 additions & 2 deletions includes/acfe-form-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ function acfe_form_get_action($name = false, $key = false){
function acfe_form_is_admin(){

_deprecated_function('ACF Extended: acfe_form_is_admin()', '0.8.8', "acfe_is_admin()");

return acfe_is_admin();

}
Expand All @@ -246,7 +245,91 @@ function acfe_form_is_admin(){
function acfe_form_is_front(){

_deprecated_function('ACF Extended: acfe_form_is_front()', '0.8.8', "acfe_is_front()");

return acfe_is_front();

}


/**
* acfe_import_form
*
* @param $args
*
* @return array|mixed|WP_Error
*/
function acfe_import_form($args){

// json string
if(is_string($args)){
$args = json_decode($args, true);
}

// validate array
if(!is_array($args) || empty($args)){
return new WP_Error('acfe_import_form_invalid_input', __("Input is invalid: Must be a json string or an array."));
}

// module
$module = acfe_get_module('form');

/**
* single item
*
* array(
* 'title' => 'My Form',
* 'acfe_form_name' => 'my-form',
* 'acfe_form_actions' => array(...)
* )
*/
if(isset($args['title'])){

$args = array(
$args
);

}

// vars
$result = array();

// loop
foreach($args as $key => $item){

// prior 0.9
// old import had name as key
if(!is_numeric($key) && !isset($item['name'])){
$item['name'] = $key;
}

// name still missing
// retrieve from old key acfe_form_name
if(!isset($item['name'])){
$item['name'] = acf_maybe_get($item, 'acfe_form_name');
}

// search database for existing item
$post = $module->get_item_post($item['name']);
if($post){
$item['ID'] = $post->ID;
}

// import item
$item = $module->import_item($item);

$return = array(
'success' => true,
'post_id' => $item['ID'],
'message' => 'Form "' . get_the_title($item['ID']) . '" successfully imported.',
);

$result[] = $return;

}

if(count($result) === 1){
$result = $result[0];
}

return $result;

}
6 changes: 5 additions & 1 deletion includes/modules/form/module-form-action-email.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ function process($form, $action){
acfe_apply_tags($action['email']['subject']);
acfe_apply_tags($action['email']['content']);

if(!$action['email']['html']){
$action['email']['content'] = wpautop($action['email']['content']);
}

// args
$args = $action['email'];

Expand Down Expand Up @@ -717,7 +721,7 @@ function register_layout($layout){
),
'choices' => array(
'editor' => __('Content Editor', 'acfe'),
'html' => __('HTML Editor', 'acfe'),
'html' => __('Raw HTML', 'acfe'),
),
'default_value' => array('custom'),
'allow_null' => 0,
Expand Down
26 changes: 15 additions & 11 deletions includes/modules/form/module-form-action.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,23 +206,27 @@ function load_acf_values($form, $post_id, $acf_fields, $acf_fields_exclude){
continue;
}

// get value
// get field & value
$field = acf_get_field($field_key);
$value = acfe_get_value_from_acf_values_by_key($acf, $field_key);

// value is null
// might be a "taxonomy field" with "load values"
if($field && $value === null){

// we need to retrieve the taxonomy valud via acf_get_value()
// so the load_value() method kicks in and "load values" can inject data
$value = acf_get_value($post_id, $field);

}

// map value
$form['map'][ $field_key ]['value'] = $value;

// seamless clone rule
$field = acf_get_field($field_key);

if($field){
if($field && $field['type'] === 'clone' && $field['display'] === 'seamless'){

if($field['type'] === 'clone' && $field['display'] === 'seamless'){

foreach(acf_get_array($value) as $sub_field_key => $sub_field_value){
$form['map'][ $sub_field_key ]['value'] = $sub_field_value;
}

foreach(acf_get_array($value) as $sub_field_key => $sub_field_value){
$form['map'][ $sub_field_key ]['value'] = $sub_field_value;
}

}
Expand Down
4 changes: 2 additions & 2 deletions includes/modules/form/module-form-deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,8 @@ function make_action($form, $action){
*/
function load_form($form){

// deprecated
$form = apply_filters_deprecated("acfe/form/load", array($form, $form['post_id']), '0.9', "acfe/form/load_form");
// deprecated
if($form){$form = apply_filters_deprecated("acfe/form/load", array($form, $form['post_id']), '0.9', "acfe/form/load_form");}
if($form){$form = apply_filters_deprecated("acfe/form/load/form={$form['name']}", array($form, $form['post_id']), '0.9', "acfe/form/load_form/form={$form['name']}");}

return $form;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
exit;
}

if(!class_exists('acfe_module_form_hooks')):
if(!class_exists('acfe_module_form_format')):

class acfe_module_form_hooks{
class acfe_module_form_format{

/**
* __construct
Expand Down Expand Up @@ -406,7 +406,7 @@ function format_value($unformatted, $field){

}

acf_new_instance('acfe_module_form_hooks');
acf_new_instance('acfe_module_form_format');

endif;

Expand All @@ -428,91 +428,6 @@ function acfe_form_format_value($value, $field, $deprecated = null){
$field = $deprecated; // second argument was $post_id
}

return acf_get_instance('acfe_module_form_hooks')->format_value($value, $field);

}


/**
* acfe_import_form
*
* @param $args
*
* @return array|mixed|WP_Error
*/
function acfe_import_form($args){

// json string
if(is_string($args)){
$args = json_decode($args, true);
}

// validate array
if(!is_array($args) || empty($args)){
return new WP_Error('acfe_import_form_invalid_input', __("Input is invalid: Must be a json string or an array."));
}

// module
$module = acfe_get_module('form');

/**
* single item
*
* array(
* 'title' => 'My Form',
* 'acfe_form_name' => 'my-form',
* 'acfe_form_actions' => array(...)
* )
*/
if(isset($args['title'])){

$args = array(
$args
);

}

// vars
$result = array();

// loop
foreach($args as $key => $item){

// prior 0.9
// old import had name as key
if(!is_numeric($key) && !isset($item['name'])){
$item['name'] = $key;
}

// name still missing
// retrieve from old key acfe_form_name
if(!isset($item['name'])){
$item['name'] = acf_maybe_get($item, 'acfe_form_name');
}

// search database for existing item
$post = $module->get_item_post($item['name']);
if($post){
$item['ID'] = $post->ID;
}

// import item
$item = $module->import_item($item);

$return = array(
'success' => true,
'post_id' => $item['ID'],
'message' => 'Form "' . get_the_title($item['ID']) . '" successfully imported.',
);

$result[] = $return;

}

if(count($result) === 1){
$result = $result[0];
}

return $result;
return acf_get_instance('acfe_module_form_format')->format_value($value, $field);

}
Loading

0 comments on commit 18945c1

Please sign in to comment.