Skip to content

Commit

Permalink
ACF 5.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotcondon committed Nov 5, 2020
1 parent 70b15d5 commit 37fcf72
Show file tree
Hide file tree
Showing 24 changed files with 404 additions and 317 deletions.
4 changes: 2 additions & 2 deletions acf.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Advanced Custom Fields
Plugin URI: https://www.advancedcustomfields.com
Description: Customize WordPress with powerful, professional and intuitive fields.
Version: 5.9.1
Version: 5.9.2
Author: Elliot Condon
Author URI: https://www.advancedcustomfields.com
Text Domain: acf
Expand All @@ -17,7 +17,7 @@
class ACF {

/** @var string The plugin version number. */
var $version = '5.9.1';
var $version = '5.9.2';

/** @var array The plugin settings array. */
var $settings = array();
Expand Down
8 changes: 4 additions & 4 deletions assets/build/css/_fields.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,27 @@
.acf-notice {
margin: 0 0 15px;
background: #edf2ff;
color: #2183b9;
color: #0c6ca0;
border-color: #2183b9;

// error
&.-error {
background: #ffe6e6;
color: #d12626;
color: #cc2727;
border-color: #d12626;
}

// success
&.-success {
background: #eefbe8;
color: #32a23b;
color: #0e7b17;
border-color: #32a23b;
}

// warning
&.-warning {
background: #fff3e6;
color: #d16226;
color: #bd4b0e;
border-color: #d16226;
}
}
Expand Down
10 changes: 9 additions & 1 deletion assets/build/js/_acf-field-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
wait: 'load',

events: {
'removeField': 'onRemove'
'removeField': 'onRemove',
'duplicateField': 'onDuplicate'
},

$input: function(){
Expand Down Expand Up @@ -49,6 +50,13 @@
if( this.select2 ) {
this.select2.destroy();
}
},

onDuplicate: function( e, $el, $duplicate ){
if( this.select2 ) {
$duplicate.find('.select2-container').remove();
$duplicate.find('select').removeClass('select2-hidden-accessible');
}
}
});

Expand Down
14 changes: 11 additions & 3 deletions assets/build/js/_acf-select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,12 @@
});
}

// remove conflicting atts
$select.removeData('ajax');
$select.removeAttr('data-ajax');
// Temporarily remove conflicting attribute.
var attrAjax = $select.attr( 'data-ajax' );
if( attrAjax !== undefined ) {
$select.removeData('ajax');
$select.removeAttr('data-ajax');
}

// ajax
if( this.get('ajax') ) {
Expand Down Expand Up @@ -390,6 +393,11 @@
// add class
$container.addClass('-acf');

// Add back temporarily removed attr.
if( attrAjax !== undefined ) {
$select.attr('data-ajax', attrAjax);
}

// action for 3rd party customization
acf.doAction('select2_init', $select, options, this.data, (field || false), this);
},
Expand Down
2 changes: 1 addition & 1 deletion assets/css/acf-input.css

Large diffs are not rendered by default.

24 changes: 20 additions & 4 deletions assets/js/acf-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -3434,7 +3434,8 @@
wait: 'load',

events: {
'removeField': 'onRemove'
'removeField': 'onRemove',
'duplicateField': 'onDuplicate'
},

$input: function(){
Expand Down Expand Up @@ -3474,6 +3475,13 @@
if( this.select2 ) {
this.select2.destroy();
}
},

onDuplicate: function( e, $el, $duplicate ){
if( this.select2 ) {
$duplicate.find('.select2-container').remove();
$duplicate.find('select').removeClass('select2-hidden-accessible');
}
}
});

Expand Down Expand Up @@ -7768,9 +7776,12 @@
});
}

// remove conflicting atts
$select.removeData('ajax');
$select.removeAttr('data-ajax');
// Temporarily remove conflicting attribute.
var attrAjax = $select.attr( 'data-ajax' );
if( attrAjax !== undefined ) {
$select.removeData('ajax');
$select.removeAttr('data-ajax');
}

// ajax
if( this.get('ajax') ) {
Expand Down Expand Up @@ -7831,6 +7842,11 @@
// add class
$container.addClass('-acf');

// Add back temporarily removed attr.
if( attrAjax !== undefined ) {
$select.attr('data-ajax', attrAjax);
}

// action for 3rd party customization
acf.doAction('select2_init', $select, options, this.data, (field || false), this);
},
Expand Down
6 changes: 3 additions & 3 deletions assets/js/acf-input.min.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions includes/acf-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ function acf_request_args( $args = array() ) {
return $args;
}

/**
* Returns a single $_REQUEST arg with fallback.
*
* @date 23/10/20
* @since 5.9.2
*
* @param string $key The property name.
* @param mixed $default The default value to fallback to.
* @return mixed
*/
function acf_request_arg( $name = '', $default = null ) {
return isset( $_REQUEST[ $name ] ) ? $_REQUEST[ $name ] : $default;
}

// Register store.
acf_register_store( 'filters' );

Expand Down
96 changes: 14 additions & 82 deletions includes/acf-meta-functions.php
Original file line number Diff line number Diff line change
@@ -1,64 +1,5 @@
<?php

/**
* acf_decode_post_id
*
* Returns an array containing the object type and id for the given post_id string.
*
* @date 25/1/19
* @since 5.7.11
*
* @param (int|string) $post_id The post id.
* @return array()
*/
function acf_decode_post_id( $post_id = 0 ) {

// Default data
$data = array(
'type' => 'post',
'id' => 0
);

// Check if is numeric.
if( is_numeric($post_id) ) {
$data['id'] = (int) $post_id;

// Check if is string.
} elseif( is_string($post_id) ) {

// Determine "{$type}_{$id}" from string.
$bits = explode( '_', $post_id );
$id = array_pop( $bits );
$type = implode( '_', $bits );

// Check if is meta type.
if( function_exists("get_{$type}_meta") && is_numeric($id) ) {
$data['type'] = $type;
$data['id'] = (int) $id;

// Check if is taxonomy name.
} elseif( taxonomy_exists($type) && is_numeric($id) ) {
$data['type'] = 'term';
$data['id'] = (int) $id;

// Otherwise, default to option.
} else {
$data['type'] = 'option';
$data['id'] = $post_id;
}
}

/**
* Filters the $data array after it has been decoded.
*
* @date 12/02/2014
* @since 5.0.0
*
* @param array $data The type and id array.
*/
return apply_filters( "acf/decode_post_id", $data, $post_id );
}

/**
* acf_get_meta
*
Expand All @@ -81,11 +22,9 @@ function acf_get_meta( $post_id = 0 ) {
// Decode $post_id for $type and $id.
extract( acf_decode_post_id($post_id) );

// Use get_$type_meta() function when possible.
// Determine CRUD function.
if( function_exists("get_{$type}_meta") ) {
$allmeta = call_user_func("get_{$type}_meta", $id, '');

// Default to wp_options.
} else {
$allmeta = acf_get_option_meta( $id );
}
Expand Down Expand Up @@ -196,14 +135,12 @@ function acf_get_metadata( $post_id = 0, $name = '', $hidden = false ) {
return null;
}

// Check option.
if( $type === 'option' ) {
return get_option( "{$prefix}{$id}_{$name}", null );

// Check meta.
} else {
$meta = get_metadata( $type, $id, "{$prefix}{$name}", false );
// Determine CRUD function.
if( function_exists("get_{$type}_meta") ) {
$meta = call_user_func("get_{$type}_meta", $id, "{$prefix}{$name}", false);
return isset($meta[0]) ? $meta[0] : null;
} else {
return get_option( "{$prefix}{$id}_{$name}", null );
}
}

Expand Down Expand Up @@ -240,17 +177,14 @@ function acf_update_metadata( $post_id = 0, $name = '', $value = '', $hidden = f
return false;
}

// Update option.
if( $type === 'option' ) {

// Determine CRUD function.
if( function_exists("update_{$type}_meta") ) {
return call_user_func("update_{$type}_meta", $id, "{$prefix}{$name}", $value);
} else {
// Unslash value to match update_metadata() functionality.
$value = wp_unslash( $value );
$autoload = (bool) acf_get_setting('autoload');
return update_option( "{$prefix}{$id}_{$name}", $value, $autoload );

// Update meta.
} else {
return update_metadata( $type, $id, "{$prefix}{$name}", $value );
}
}

Expand Down Expand Up @@ -286,14 +220,12 @@ function acf_delete_metadata( $post_id = 0, $name = '', $hidden = false ) {
return false;
}

// Update option.
if( $type === 'option' ) {
// Determine CRUD function.
if( function_exists("delete_{$type}_meta") ) {
return call_user_func("delete_{$type}_meta", $id, "{$prefix}{$name}");
} else {
$autoload = (bool) acf_get_setting('autoload');
return delete_option( "{$prefix}{$id}_{$name}" );

// Update meta.
} else {
return delete_metadata( $type, $id, "{$prefix}{$name}" );
}
}

Expand Down
Loading

0 comments on commit 37fcf72

Please sign in to comment.