Merge branch 'release/5.8.3'
This commit is contained in:
commit
ce74fdd972
24
acf.php
24
acf.php
|
|
@ -3,7 +3,7 @@
|
|||
Plugin Name: Advanced Custom Fields PRO
|
||||
Plugin URI: https://www.advancedcustomfields.com
|
||||
Description: Customize WordPress with powerful, professional and intuitive fields.
|
||||
Version: 5.8.1
|
||||
Version: 5.8.3
|
||||
Author: Elliot Condon
|
||||
Author URI: https://www.advancedcustomfields.com
|
||||
Text Domain: acf
|
||||
|
|
@ -17,7 +17,7 @@ if( ! class_exists('ACF') ) :
|
|||
class ACF {
|
||||
|
||||
/** @var string The plugin version number */
|
||||
var $version = '5.8.1';
|
||||
var $version = '5.8.3';
|
||||
|
||||
/** @var array The plugin settings array */
|
||||
var $settings = array();
|
||||
|
|
@ -118,23 +118,20 @@ class ACF {
|
|||
$this->define( 'ACF_VERSION', $version );
|
||||
$this->define( 'ACF_PATH', $path );
|
||||
|
||||
// Include utility functions.
|
||||
include_once( ACF_PATH . 'includes/acf-utility-functions.php');
|
||||
|
||||
// api
|
||||
include_once( ACF_PATH . 'includes/api/api-helpers.php');
|
||||
acf_include('includes/api/api-input.php');
|
||||
// Include previous API functions.
|
||||
acf_include('includes/api/api-helpers.php');
|
||||
acf_include('includes/api/api-template.php');
|
||||
acf_include('includes/api/api-term.php');
|
||||
|
||||
// Include models.
|
||||
// Include classes.
|
||||
acf_include('includes/class-acf-data.php');
|
||||
|
||||
// Include core functions.
|
||||
acf_include('includes/acf-data-functions.php');
|
||||
// Include functions.
|
||||
acf_include('includes/acf-helper-functions.php');
|
||||
acf_include('includes/acf-hook-functions.php');
|
||||
|
||||
// Include functions.
|
||||
acf_include('includes/acf-deprecated-functions.php');
|
||||
acf_include('includes/acf-field-functions.php');
|
||||
acf_include('includes/acf-field-group-functions.php');
|
||||
acf_include('includes/acf-form-functions.php');
|
||||
|
|
@ -142,6 +139,7 @@ class ACF {
|
|||
acf_include('includes/acf-post-functions.php');
|
||||
acf_include('includes/acf-user-functions.php');
|
||||
acf_include('includes/acf-value-functions.php');
|
||||
acf_include('includes/acf-input-functions.php');
|
||||
|
||||
// fields
|
||||
acf_include('includes/fields.php');
|
||||
|
|
@ -203,7 +201,9 @@ class ACF {
|
|||
acf_include('pro/acf-pro.php');
|
||||
|
||||
// Include tests.
|
||||
//acf_include('tests/tests.php');
|
||||
if( defined('ACF_DEV') && ACF_DEV ) {
|
||||
acf_include('tests/tests.php');
|
||||
}
|
||||
|
||||
// actions
|
||||
add_action('init', array($this, 'init'), 5);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -7171,14 +7171,14 @@
|
|||
},
|
||||
|
||||
setValue: function( val ){
|
||||
|
||||
this.busy = true;
|
||||
|
||||
// update range input (with change)
|
||||
// Update range input (with change).
|
||||
acf.val( this.$input(), val );
|
||||
|
||||
// update alt input (without change)
|
||||
acf.val( this.$inputAlt(), val, true );
|
||||
// Update alt input (without change).
|
||||
// Read in input value to inherit min/max validation.
|
||||
acf.val( this.$inputAlt(), this.$input().val(), true );
|
||||
|
||||
this.busy = false;
|
||||
},
|
||||
|
|
@ -10770,7 +10770,7 @@
|
|||
// convert any string values (tags) into array format
|
||||
for( var tax in terms ) {
|
||||
if( !acf.isArray(terms[tax]) ) {
|
||||
terms[tax] = terms[tax].split(', ');
|
||||
terms[tax] = terms[tax].split(/,[\s]?/);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,116 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* acf_render_field_wrap_label
|
||||
*
|
||||
* Renders the field's label.
|
||||
*
|
||||
* @date 19/9/17
|
||||
* @since 5.6.3
|
||||
* @deprecated 5.6.5
|
||||
*
|
||||
* @param array $field The field array.
|
||||
* @return void
|
||||
*/
|
||||
function acf_render_field_wrap_label( $field ) {
|
||||
|
||||
// Warning.
|
||||
_deprecated_function( __FUNCTION__, '5.7.11', 'acf_render_field_label()' );
|
||||
|
||||
// Render.
|
||||
acf_render_field_label( $field );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_render_field_wrap_description
|
||||
*
|
||||
* Renders the field's instructions.
|
||||
*
|
||||
* @date 19/9/17
|
||||
* @since 5.6.3
|
||||
* @deprecated 5.6.5
|
||||
*
|
||||
* @param array $field The field array.
|
||||
* @return void
|
||||
*/
|
||||
function acf_render_field_wrap_description( $field ) {
|
||||
|
||||
// Warning.
|
||||
_deprecated_function( __FUNCTION__, '5.7.11', 'acf_render_field_instructions()' );
|
||||
|
||||
// Render.
|
||||
acf_render_field_instructions( $field );
|
||||
}
|
||||
|
||||
/*
|
||||
* acf_get_fields_by_id
|
||||
*
|
||||
* Returns and array of fields for the given $parent_id.
|
||||
*
|
||||
* @date 27/02/2014
|
||||
* @since 5.0.0.
|
||||
* @deprecated 5.7.11
|
||||
*
|
||||
* @param int $parent_id The parent ID.
|
||||
* @return array
|
||||
*/
|
||||
function acf_get_fields_by_id( $parent_id = 0 ) {
|
||||
|
||||
// Warning.
|
||||
_deprecated_function( __FUNCTION__, '5.7.11', 'acf_get_fields()' );
|
||||
|
||||
// Return fields.
|
||||
return acf_get_fields(array( 'ID' => $parent_id, 'key' => "group_$parent_id" ));
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_update_option
|
||||
*
|
||||
* A wrapper for the WP update_option but provides logic for a 'no' autoload
|
||||
*
|
||||
* @date 4/01/2014
|
||||
* @since 5.0.0
|
||||
* @deprecated 5.7.11
|
||||
*
|
||||
* @param string $option The option name.
|
||||
* @param string $value The option value.
|
||||
* @param string $autoload An optional autoload value.
|
||||
* @return bool
|
||||
*/
|
||||
function acf_update_option( $option = '', $value = '', $autoload = null ) {
|
||||
|
||||
// Warning.
|
||||
_deprecated_function( __FUNCTION__, '5.7.11', 'update_option()' );
|
||||
|
||||
// Update.
|
||||
if( $autoload === null ) {
|
||||
$autoload = (bool) acf_get_setting('autoload');
|
||||
}
|
||||
return update_option( $option, $value, $autoload );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_field_reference
|
||||
*
|
||||
* Finds the field key for a given field name and post_id.
|
||||
*
|
||||
* @date 26/1/18
|
||||
* @since 5.6.5
|
||||
* @deprecated 5.6.8
|
||||
*
|
||||
* @param string $field_name The name of the field. eg 'sub_heading'
|
||||
* @param mixed $post_id The post_id of which the value is saved against
|
||||
* @return string $reference The field key
|
||||
*/
|
||||
function acf_get_field_reference( $field_name, $post_id ) {
|
||||
|
||||
// Warning.
|
||||
_deprecated_function( __FUNCTION__, '5.6.8', 'acf_get_reference()' );
|
||||
|
||||
// Return reference.
|
||||
return acf_get_reference( $field_name, $post_id );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -369,7 +369,6 @@ function acf_get_fields( $parent ) {
|
|||
* @param array $fields The array of fields.
|
||||
*/
|
||||
$fields = apply_filters( 'acf/load_fields', $fields, $parent );
|
||||
$fields = apply_filters( 'acf/get_fields', $fields, $parent );
|
||||
|
||||
// Return fields
|
||||
return $fields;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ function acf_get_field_group( $id = 0 ) {
|
|||
*
|
||||
* @param array The field_group array.
|
||||
*/
|
||||
$field_group = apply_filters( 'acf/get_field_group', $field_group );
|
||||
$field_group = apply_filters( 'acf/load_field_group', $field_group );
|
||||
|
||||
// Store field group using aliasses to also find via key, ID and name.
|
||||
|
|
@ -319,7 +318,6 @@ function acf_get_field_groups( $filter = array() ) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filters the $field_groups array.
|
||||
*
|
||||
|
|
@ -329,7 +327,6 @@ function acf_get_field_groups( $filter = array() ) {
|
|||
* @param array $field_groups The array of field_groups.
|
||||
*/
|
||||
$field_groups = apply_filters( 'acf/load_field_groups', $field_groups );
|
||||
$field_groups = apply_filters( 'acf/get_field_groups', $field_groups );
|
||||
|
||||
// Filter results.
|
||||
if( $filter ) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,35 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* acf_is_empty
|
||||
*
|
||||
* Returns true if the value provided is considered "empty". Allows numbers such as 0.
|
||||
*
|
||||
* @date 6/7/16
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param mixed $var The value to check.
|
||||
* @return bool
|
||||
*/
|
||||
function acf_is_empty( $var ) {
|
||||
return ( !$var && !is_numeric($var) );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_not_empty
|
||||
*
|
||||
* Returns true if the value provided is considered "not empty". Allows numbers such as 0.
|
||||
*
|
||||
* @date 15/7/19
|
||||
* @since 5.8.1
|
||||
*
|
||||
* @param mixed $var The value to check.
|
||||
* @return bool
|
||||
*/
|
||||
function acf_not_empty( $var ) {
|
||||
return ( $var || is_numeric($var) );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_uniqid
|
||||
*
|
||||
|
|
@ -47,7 +77,7 @@ function acf_merge_attributes( $array1, $array2 ) {
|
|||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
// Return.
|
||||
return $array3;
|
||||
}
|
||||
|
||||
|
|
@ -286,3 +316,50 @@ function acf_maybe_idval( $value ) {
|
|||
function acf_numval( $value ) {
|
||||
return ( intval($value) == floatval($value) ) ? intval($value) : floatval($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_idify
|
||||
*
|
||||
* Returns an id attribute friendly string.
|
||||
*
|
||||
* @date 24/12/17
|
||||
* @since 5.6.5
|
||||
*
|
||||
* @param string $str The string to convert.
|
||||
* @return string
|
||||
*/
|
||||
function acf_idify( $str = '' ) {
|
||||
return str_replace(array('][', '[', ']'), array('-', '-', ''), strtolower($str));
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_slugify
|
||||
*
|
||||
* Returns a slug friendly string.
|
||||
*
|
||||
* @date 24/12/17
|
||||
* @since 5.6.5
|
||||
*
|
||||
* @param string $str The string to convert.
|
||||
* @return string
|
||||
*/
|
||||
function acf_slugify( $str = '' ) {
|
||||
return str_replace(array('_', '/', ' '), '-', strtolower($str));
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_punctify
|
||||
*
|
||||
* Returns a string with correct full stop puctuation.
|
||||
*
|
||||
* @date 12/7/19
|
||||
* @since 5.8.2
|
||||
*
|
||||
* @param string $str The string to format.
|
||||
* @return string
|
||||
*/
|
||||
function acf_punctify( $str = '' ) {
|
||||
return trim($str, '.') . '.';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ function _acf_apply_deprecated_hook() {
|
|||
if( has_filter($deprecated) ) {
|
||||
|
||||
// Log warning.
|
||||
_deprecated_hook( $deprecated, $version, $hook );
|
||||
//_deprecated_hook( $deprecated, $version, $hook );
|
||||
|
||||
// Apply filters.
|
||||
if( $type === 'filter' ) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,472 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* acf_filter_attrs
|
||||
*
|
||||
* Filters out empty attrs from the provided array.
|
||||
*
|
||||
* @date 11/6/19
|
||||
* @since 5.8.1
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return array
|
||||
*/
|
||||
function acf_filter_attrs( $attrs ) {
|
||||
|
||||
// Filter out empty attrs but allow "0" values.
|
||||
$filtered = array_filter( $attrs, 'acf_not_empty' );
|
||||
|
||||
// Correct specific attributes (required="required").
|
||||
foreach( array('required', 'readonly', 'disabled', 'multiple') as $key ) {
|
||||
unset($filtered[ $key ]);
|
||||
if( !empty($attrs[ $key ]) ) {
|
||||
$filtered[ $key ] = $key;
|
||||
}
|
||||
}
|
||||
return $filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_esc_attrs
|
||||
*
|
||||
* Generated valid HTML from an array of attrs.
|
||||
*
|
||||
* @date 11/6/19
|
||||
* @since 5.8.1
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_esc_attrs( $attrs ) {
|
||||
$html = '';
|
||||
|
||||
// Loop over attrs and validate data types.
|
||||
foreach( $attrs as $k => $v ) {
|
||||
|
||||
// String (but don't trim value).
|
||||
if( is_string($v) && ($k !== 'value') ) {
|
||||
$v = trim($v);
|
||||
|
||||
// Boolean
|
||||
} elseif( is_bool($v) ) {
|
||||
$v = $v ? 1 : 0;
|
||||
|
||||
// Object
|
||||
} elseif( is_array($v) || is_object($v) ) {
|
||||
$v = json_encode($v);
|
||||
}
|
||||
|
||||
// Generate HTML.
|
||||
$html .= sprintf( ' %s="%s"', esc_attr($k), esc_attr($v) );
|
||||
}
|
||||
|
||||
// Return trimmed.
|
||||
return trim( $html );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_esc_html
|
||||
*
|
||||
* Encodes <script> tags for safe HTML output.
|
||||
*
|
||||
* @date 12/6/19
|
||||
* @since 5.8.1
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
function acf_esc_html( $string = '' ) {
|
||||
$string = strval($string);
|
||||
|
||||
// Encode "<script" tags to invalidate DOM elements.
|
||||
if( strpos($string, '<script') !== false ) {
|
||||
$string = str_replace('<script', htmlspecialchars('<script'), $string);
|
||||
$string = str_replace('</script', htmlspecialchars('</script'), $string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_html_input
|
||||
*
|
||||
* Returns the HTML of an input.
|
||||
*
|
||||
* @date 13/6/19
|
||||
* @since 5.8.1
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
//function acf_html_input( $attrs = array() ) {
|
||||
// return sprintf( '<input %s/>', acf_esc_attrs($attrs) );
|
||||
//}
|
||||
|
||||
/**
|
||||
* acf_hidden_input
|
||||
*
|
||||
* Renders the HTML of a hidden input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_hidden_input( $attrs = array() ) {
|
||||
echo acf_get_hidden_input( $attrs );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_hidden_input
|
||||
*
|
||||
* Returns the HTML of a hidden input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_get_hidden_input( $attrs = array() ) {
|
||||
return sprintf( '<input type="hidden" %s/>', acf_esc_attrs($attrs) );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_text_input
|
||||
*
|
||||
* Renders the HTML of a text input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_text_input( $attrs = array() ) {
|
||||
echo acf_get_text_input( $attrs );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_text_input
|
||||
*
|
||||
* Returns the HTML of a text input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_get_text_input( $attrs = array() ) {
|
||||
$attrs = wp_parse_args($attrs, array(
|
||||
'type' => 'text'
|
||||
));
|
||||
return sprintf( '<input %s/>', acf_esc_attrs($attrs) );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_file_input
|
||||
*
|
||||
* Renders the HTML of a file input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_file_input( $attrs = array() ) {
|
||||
echo acf_get_file_input( $attrs );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_file_input
|
||||
*
|
||||
* Returns the HTML of a file input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_get_file_input( $attrs = array() ) {
|
||||
return sprintf( '<input type="file" %s/>', acf_esc_attrs($attrs) );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_textarea_input
|
||||
*
|
||||
* Renders the HTML of a textarea input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_textarea_input( $attrs = array() ) {
|
||||
echo acf_get_textarea_input( $attrs );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_textarea_input
|
||||
*
|
||||
* Returns the HTML of a textarea input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_get_textarea_input( $attrs = array() ) {
|
||||
$value = '';
|
||||
if( isset($attrs['value']) ) {
|
||||
$value = $attrs['value'];
|
||||
unset( $attrs['value'] );
|
||||
}
|
||||
return sprintf( '<textarea %s>%s</textarea>', acf_esc_attrs($attrs), esc_textarea($value) );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_checkbox_input
|
||||
*
|
||||
* Renders the HTML of a checkbox input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_checkbox_input( $attrs = array() ) {
|
||||
echo acf_get_checkbox_input( $attrs );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_checkbox_input
|
||||
*
|
||||
* Returns the HTML of a checkbox input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_get_checkbox_input( $attrs = array() ) {
|
||||
|
||||
// Allow radio or checkbox type.
|
||||
$attrs = wp_parse_args($attrs, array(
|
||||
'type' => 'checkbox'
|
||||
));
|
||||
|
||||
// Get label.
|
||||
$label = '';
|
||||
if( isset($attrs['label']) ) {
|
||||
$label= $attrs['label'];
|
||||
unset( $attrs['label'] );
|
||||
}
|
||||
|
||||
// Render.
|
||||
$checked = isset($attrs['checked']);
|
||||
return '<label' . ($checked ? ' class="selected"' : '') . '><input ' . acf_esc_attr($attrs) . '/> ' . acf_esc_html($label) . '</label>';
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_radio_input
|
||||
*
|
||||
* Renders the HTML of a radio input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_radio_input( $attrs = array() ) {
|
||||
echo acf_get_radio_input( $attrs );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_radio_input
|
||||
*
|
||||
* Returns the HTML of a radio input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_get_radio_input( $attrs = array() ) {
|
||||
$attrs['type'] = 'radio';
|
||||
return acf_get_checkbox_input( $attrs );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_select_input
|
||||
*
|
||||
* Renders the HTML of a select input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_select_input( $attrs = array() ) {
|
||||
echo acf_get_select_input( $attrs );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_select_input
|
||||
*
|
||||
* Returns the HTML of a select input.
|
||||
*
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_get_select_input( $attrs = array() ) {
|
||||
$value = (array) acf_extract_var( $attrs, 'value' );
|
||||
$choices = (array) acf_extract_var( $attrs, 'choices' );
|
||||
return sprintf(
|
||||
'<select %s>%s</select>',
|
||||
acf_esc_attrs($attrs),
|
||||
acf_walk_select_input($choices, $value)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_walk_select_input
|
||||
*
|
||||
* Returns the HTML of a select input's choices.
|
||||
*
|
||||
* @date 27/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param array $choices The choices to walk through.
|
||||
* @param array $values The selected choices.
|
||||
* @param array $depth The current walk depth.
|
||||
* @return string
|
||||
*/
|
||||
function acf_walk_select_input( $choices = array(), $values = array(), $depth = 0 ) {
|
||||
$html = '';
|
||||
|
||||
// Sanitize values for 'selected' matching (only once).
|
||||
if( $depth == 0 ) {
|
||||
$values = array_map('esc_attr', $values);
|
||||
}
|
||||
|
||||
// Loop over choices and append to html.
|
||||
if( $choices ) {
|
||||
foreach( $choices as $value => $label ) {
|
||||
|
||||
// Multiple (optgroup)
|
||||
if( is_array($label) ){
|
||||
$html .= sprintf(
|
||||
'<optgroup label="%s">%s</optgroup>',
|
||||
esc_attr($value),
|
||||
acf_walk_select_input( $label, $values, $depth+1 )
|
||||
);
|
||||
|
||||
// single (option)
|
||||
} else {
|
||||
$attrs = array(
|
||||
'value' => $value
|
||||
);
|
||||
|
||||
// If is selected.
|
||||
$pos = array_search( esc_attr($value), $values );
|
||||
if( $pos !== false ) {
|
||||
$attrs['selected'] = 'selected';
|
||||
$attrs['data-i'] = $pos;
|
||||
}
|
||||
$html .= sprintf( '<option %s>%s</option>', acf_esc_attr($attrs), esc_html($label) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_clean_atts
|
||||
*
|
||||
* See acf_filter_attrs().
|
||||
*
|
||||
* @date 3/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_clean_atts( $attrs ) {
|
||||
return acf_filter_attrs( $attrs );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_esc_atts
|
||||
*
|
||||
* See acf_esc_attrs().
|
||||
*
|
||||
* @date 27/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_esc_atts( $attrs ) {
|
||||
return acf_esc_attrs( $attrs );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_esc_attr
|
||||
*
|
||||
* See acf_esc_attrs().
|
||||
*
|
||||
* @date 13/6/19
|
||||
* @since 5.8.1
|
||||
* @deprecated 5.6.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_esc_attr( $attrs ) {
|
||||
return acf_esc_attrs( $attrs );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_esc_attr_e
|
||||
*
|
||||
* See acf_esc_attrs().
|
||||
*
|
||||
* @date 13/6/19
|
||||
* @since 5.8.1
|
||||
* @deprecated 5.6.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_esc_attr_e( $attrs ) {
|
||||
echo acf_esc_attrs( $attrs );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_esc_atts_e
|
||||
*
|
||||
* See acf_esc_attrs().
|
||||
*
|
||||
* @date 13/6/19
|
||||
* @since 5.8.1
|
||||
* @deprecated 5.6.0
|
||||
*
|
||||
* @param array $attrs The array of attrs.
|
||||
* @return string
|
||||
*/
|
||||
function acf_esc_atts_e( $attrs ) {
|
||||
echo acf_esc_attrs( $attrs );
|
||||
}
|
||||
|
|
@ -104,3 +104,55 @@ function acf_switch_stores( $site_id, $prev_site_id ) {
|
|||
}
|
||||
}
|
||||
add_action( 'switch_blog', 'acf_switch_stores', 10, 2 );
|
||||
|
||||
/**
|
||||
* acf_get_path
|
||||
*
|
||||
* Returns the plugin path to a specified file.
|
||||
*
|
||||
* @date 28/9/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param string $filename The specified file.
|
||||
* @return string
|
||||
*/
|
||||
function acf_get_path( $filename = '' ) {
|
||||
return ACF_PATH . ltrim($filename, '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_url
|
||||
*
|
||||
* Returns the plugin url to a specified file.
|
||||
* This function also defines the ACF_URL constant.
|
||||
*
|
||||
* @date 12/12/17
|
||||
* @since 5.6.8
|
||||
*
|
||||
* @param string $filename The specified file.
|
||||
* @return string
|
||||
*/
|
||||
function acf_get_url( $filename = '' ) {
|
||||
if( !defined('ACF_URL') ) {
|
||||
define( 'ACF_URL', acf_get_setting('url') );
|
||||
}
|
||||
return ACF_URL . ltrim($filename, '/');
|
||||
}
|
||||
|
||||
/*
|
||||
* acf_include
|
||||
*
|
||||
* Includes a file within the ACF plugin.
|
||||
*
|
||||
* @date 10/3/14
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param string $filename The specified file.
|
||||
* @return void
|
||||
*/
|
||||
function acf_include( $filename = '' ) {
|
||||
$file_path = acf_get_path($filename);
|
||||
if( file_exists($file_path) ) {
|
||||
include_once($file_path);
|
||||
}
|
||||
}
|
||||
|
|
@ -39,9 +39,6 @@ function acf_get_reference( $field_name, $post_id ) {
|
|||
return apply_filters( "acf/load_reference", $reference, $field_name, $post_id );
|
||||
}
|
||||
|
||||
// Register deprecated.
|
||||
acf_add_deprecated_filter( 'acf/get_field_reference', '5.6.5', 'acf/load_reference' );
|
||||
|
||||
/**
|
||||
* acf_get_value
|
||||
*
|
||||
|
|
@ -117,7 +114,7 @@ acf_add_filter_variations( 'acf/load_value', array('type', 'name', 'key'), 2 );
|
|||
function acf_format_value( $value, $post_id, $field ) {
|
||||
|
||||
// Allow filter to short-circuit load_value logic.
|
||||
$check = apply_filters( "acf/pre_format_value", null, $post_id, $field );
|
||||
$check = apply_filters( "acf/pre_format_value", null, $value, $post_id, $field );
|
||||
if( $check !== null ) {
|
||||
return $check;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,58 +19,6 @@ function acf_is_array( $array ) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_is_empty
|
||||
*
|
||||
* This function will return true for an empty var (allows 0 as true)
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $value (mixed)
|
||||
* @return (boolean)
|
||||
*/
|
||||
|
||||
function acf_is_empty( $value ) {
|
||||
|
||||
return ( empty($value) && !is_numeric($value) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_idify
|
||||
*
|
||||
* Returns an id friendly string
|
||||
*
|
||||
* @date 24/12/17
|
||||
* @since 5.6.5
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
function acf_idify( $str = '' ) {
|
||||
return str_replace(array('][', '[', ']'), array('-', '-', ''), strtolower($str));
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_slugify
|
||||
*
|
||||
* Returns a slug friendly string
|
||||
*
|
||||
* @date 24/12/17
|
||||
* @since 5.6.5
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
function acf_slugify( $str = '' ) {
|
||||
return str_replace(array('_', '/', ' '), '-', strtolower($str));
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_has_setting
|
||||
*
|
||||
|
|
@ -263,26 +211,6 @@ function acf_init() {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_compatibility
|
||||
*
|
||||
* This function will return true or false for a given compatibility setting
|
||||
*
|
||||
* @type function
|
||||
* @date 20/01/2015
|
||||
* @since 5.1.5
|
||||
*
|
||||
* @param $name (string)
|
||||
* @return (boolean)
|
||||
*/
|
||||
|
||||
function acf_get_compatibility( $name ) {
|
||||
|
||||
return apply_filters( "acf/compatibility/{$name}", false );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_has_done
|
||||
*
|
||||
|
|
@ -309,111 +237,7 @@ function acf_has_done( $name ) {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_path
|
||||
*
|
||||
* This function will return the path to a file within the ACF plugin folder
|
||||
*
|
||||
* @type function
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $path (string) the relative path from the root of the ACF plugin folder
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_path( $path = '' ) {
|
||||
|
||||
return ACF_PATH . $path;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* acf_get_url
|
||||
*
|
||||
* This function will return the url to a file within the ACF plugin folder
|
||||
*
|
||||
* @date 12/12/17
|
||||
* @since 5.6.8
|
||||
*
|
||||
* @param string $path The relative path from the root of the ACF plugin folder
|
||||
* @return string
|
||||
*/
|
||||
|
||||
function acf_get_url( $path = '' ) {
|
||||
|
||||
// define ACF_URL to optimise performance
|
||||
if( !defined('ACF_URL') ) {
|
||||
define( 'ACF_URL', acf_get_setting('url') );
|
||||
}
|
||||
|
||||
// return
|
||||
return ACF_URL . $path;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_dir
|
||||
*
|
||||
* Deprecated in 5.6.8. Use acf_get_url() instead.
|
||||
*
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
|
||||
function acf_get_dir( $path = '' ) {
|
||||
return acf_get_url( $path );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_include
|
||||
*
|
||||
* This function will include a file
|
||||
*
|
||||
* @type function
|
||||
* @date 10/03/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_include( $file ) {
|
||||
|
||||
$path = acf_get_path( $file );
|
||||
|
||||
if( file_exists($path) ) {
|
||||
|
||||
include_once( $path );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_include_once
|
||||
*
|
||||
* Includes a file one time only.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param string $file The relative file path.
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function acf_include_once( $file = '' ) {
|
||||
$path = acf_get_path( $file );
|
||||
if( file_exists($path) ) {
|
||||
include_once( $path );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* acf_get_external_path
|
||||
|
|
@ -3442,43 +3266,6 @@ function acf_get_current_url() {
|
|||
return ( is_ssl() ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_str_join
|
||||
*
|
||||
* Joins together 2 strings removing any overlapping characters.
|
||||
* Useful for urls. Eg: 'test.local/foo/' + '/foo/bar/' = 'test.local/foo/bar/'
|
||||
*
|
||||
* @date 19/11/18
|
||||
* @since 5.8.0
|
||||
*
|
||||
* @param string $s1 The first string.
|
||||
* @param string $s2 The seccond string.
|
||||
* @return string
|
||||
*/
|
||||
function acf_str_join( $s1 = '', $s2 = '' ) {
|
||||
|
||||
// Remember number of chars that overlap.
|
||||
$overlap = 0;
|
||||
|
||||
// Find shortest word length.
|
||||
$length = min( strlen($s1), strlen($s2) );
|
||||
|
||||
// Find number of chars that overlap.
|
||||
for( $i = 0; $i < $length; $i++ ) {
|
||||
if( substr($s1, -$i) === substr($s2, 0, $i) ) {
|
||||
$overlap = $i;
|
||||
}
|
||||
}
|
||||
|
||||
// shorten $s2 based on overlap
|
||||
if( $overlap ) {
|
||||
$s2 = substr($s2, $overlap);
|
||||
}
|
||||
|
||||
// Return joined string.
|
||||
return $s1 . $s2;
|
||||
}
|
||||
|
||||
/*
|
||||
* acf_current_user_can_admin
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,615 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* acf_esc_html
|
||||
*
|
||||
* This function will encode <script> tags for safe output
|
||||
*
|
||||
* @type function
|
||||
* @date 25/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param string (string)
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_esc_html( $string = '' ) {
|
||||
|
||||
// cast
|
||||
$string = (string) $string;
|
||||
|
||||
|
||||
// replace
|
||||
$string = str_replace('<script', htmlspecialchars('<script'), $string);
|
||||
$string = str_replace('</script', htmlspecialchars('</script'), $string);
|
||||
|
||||
|
||||
// return
|
||||
return $string;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* acf_clean_atts
|
||||
*
|
||||
* This function will remove empty attributes
|
||||
*
|
||||
* @date 3/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param array $atts
|
||||
* @return array
|
||||
*/
|
||||
|
||||
function acf_clean_atts( $atts = array() ) {
|
||||
|
||||
// loop
|
||||
foreach( $atts as $k => $v ) {
|
||||
if( $v === '' ) unset( $atts[ $k ] );
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $atts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* acf_get_atts
|
||||
*
|
||||
* This function will return an array of HTML attributes
|
||||
*
|
||||
* @date 2/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
/*
|
||||
function acf_get_atts( $array, $keys ) {
|
||||
|
||||
// vars
|
||||
$atts = array();
|
||||
|
||||
|
||||
// append attributes
|
||||
foreach( $keys as $k ) {
|
||||
if( isset($array[ $k ]) ) $atts[ $k ] = $array[ $k ];
|
||||
}
|
||||
|
||||
|
||||
// modify special attributes
|
||||
foreach( array('readonly', 'disabled', 'required') as $k ) {
|
||||
$atts[ $k ] = $atts[ $k ] ? $k : '';
|
||||
}
|
||||
|
||||
|
||||
// clean up blank attributes
|
||||
foreach( $atts as $k => $v ) {
|
||||
if( $v === '' ) unset( $atts[ $k ] );
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $atts;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* acf_esc_atts
|
||||
*
|
||||
* This function will escape an array of attributes and return as HTML
|
||||
*
|
||||
* @type function
|
||||
* @date 27/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $atts (array)
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_esc_atts( $atts = array() ) {
|
||||
|
||||
// vars
|
||||
$html = '';
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $atts as $k => $v ) {
|
||||
|
||||
// string
|
||||
if( is_string($v) ) {
|
||||
|
||||
// don't trim value
|
||||
if( $k !== 'value') $v = trim($v);
|
||||
|
||||
// boolean
|
||||
} elseif( is_bool($v) ) {
|
||||
|
||||
$v = $v ? 1 : 0;
|
||||
|
||||
// object
|
||||
} elseif( is_array($v) || is_object($v) ) {
|
||||
|
||||
$v = json_encode($v);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append
|
||||
$html .= esc_attr( $k ) . '="' . esc_attr( $v ) . '" ';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return trim( $html );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_esc_atts_e
|
||||
*
|
||||
* This function will echo acf_esc_atts
|
||||
*
|
||||
* @type function
|
||||
* @date 27/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $atts (array)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_esc_atts_e( $atts = array() ) {
|
||||
|
||||
echo acf_esc_atts( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_text_input
|
||||
*
|
||||
* This function will return HTML for a text input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_text_input( $atts = array() ) {
|
||||
|
||||
$atts['type'] = isset($atts['type']) ? $atts['type'] : 'text';
|
||||
return '<input ' . acf_esc_atts( $atts ) . ' />';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_text_input
|
||||
*
|
||||
* This function will output HTML for a text input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_text_input( $atts = array() ) {
|
||||
|
||||
echo acf_get_text_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_hidden_input
|
||||
*
|
||||
* This function will return HTML for a hidden input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_hidden_input( $atts = array() ) {
|
||||
|
||||
$atts['type'] = 'hidden';
|
||||
return acf_get_text_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_hidden_input
|
||||
*
|
||||
* This function will output HTML for a generic input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_hidden_input( $atts = array() ) {
|
||||
|
||||
echo acf_get_hidden_input( $atts ) . "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_textarea_input
|
||||
*
|
||||
* This function will return HTML for a textarea input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_textarea_input( $atts = array() ) {
|
||||
|
||||
$value = acf_extract_var( $atts, 'value', '' );
|
||||
return '<textarea ' . acf_esc_atts( $atts ) . '>' . esc_textarea( $value ) . '</textarea>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_textarea_input
|
||||
*
|
||||
* This function will output HTML for a textarea input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_textarea_input( $atts = array() ) {
|
||||
|
||||
echo acf_get_textarea_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_checkbox_input
|
||||
*
|
||||
* This function will return HTML for a checkbox input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_checkbox_input( $atts = array() ) {
|
||||
|
||||
$label = acf_extract_var( $atts, 'label', '' );
|
||||
$checked = acf_maybe_get( $atts, 'checked', '' );
|
||||
$atts['type'] = acf_maybe_get( $atts, 'type', 'checkbox' );
|
||||
return '<label' . ($checked ? ' class="selected"' : '') . '><input ' . acf_esc_attr( $atts ) . '/>' . acf_esc_html( $label ) . '</label>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_checkbox_input
|
||||
*
|
||||
* This function will output HTML for a checkbox input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_checkbox_input( $atts = array() ) {
|
||||
|
||||
echo acf_get_checkbox_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_radio_input
|
||||
*
|
||||
* This function will return HTML for a radio input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_radio_input( $atts = array() ) {
|
||||
|
||||
$atts['type'] = 'radio';
|
||||
return acf_get_checkbox_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_radio_input
|
||||
*
|
||||
* This function will output HTML for a radio input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_radio_input( $atts = array() ) {
|
||||
|
||||
echo acf_get_radio_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_select_input
|
||||
*
|
||||
* This function will return HTML for a select input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_select_input( $atts = array() ) {
|
||||
|
||||
// vars
|
||||
$value = (array) acf_extract_var( $atts, 'value' );
|
||||
$choices = (array) acf_extract_var( $atts, 'choices' );
|
||||
|
||||
|
||||
// html
|
||||
$html = '';
|
||||
$html .= '<select ' . acf_esc_atts( $atts ) . '>';
|
||||
$html .= acf_walk_select_input( $choices, $value );
|
||||
$html .= '</select>' . "\n";
|
||||
|
||||
|
||||
// return
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_walk_select_input
|
||||
*
|
||||
* This function will return the HTML for a select input's choices
|
||||
*
|
||||
* @type function
|
||||
* @date 27/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_walk_select_input( $choices = array(), $values = array(), $depth = 0 ) {
|
||||
|
||||
// bail ealry if no choices
|
||||
if( empty($choices) ) return '';
|
||||
|
||||
|
||||
// vars
|
||||
$html = '';
|
||||
|
||||
|
||||
// sanitize values for 'selected' matching
|
||||
if( $depth == 0 ) {
|
||||
$values = array_map('esc_attr', $values);
|
||||
}
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $choices as $value => $label ) {
|
||||
|
||||
// optgroup
|
||||
if( is_array($label) ){
|
||||
|
||||
$html .= '<optgroup label="' . esc_attr($value) . '">';
|
||||
$html .= acf_walk_select_input( $label, $values, $depth+1 );
|
||||
$html .= '</optgroup>';
|
||||
|
||||
// option
|
||||
} else {
|
||||
|
||||
// vars
|
||||
$atts = array( 'value' => $value );
|
||||
$pos = array_search( esc_attr($value), $values );
|
||||
|
||||
|
||||
// selected
|
||||
if( $pos !== false ) {
|
||||
$atts['selected'] = 'selected';
|
||||
$atts['data-i'] = $pos;
|
||||
}
|
||||
|
||||
|
||||
// append
|
||||
$html .= '<option ' . acf_esc_attr($atts) . '>' . esc_html($label) . '</option>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_select_input
|
||||
*
|
||||
* This function will output HTML for a select input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_select_input( $atts = array() ) {
|
||||
|
||||
echo acf_get_select_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
function acf_test_esc_html( $string = '' ) {
|
||||
|
||||
$s = '';
|
||||
|
||||
|
||||
$time_start = microtime(true);
|
||||
$s .= wp_kses_post( $string );
|
||||
$s .= ' = ('. (microtime(true) - $time_start) .')';
|
||||
|
||||
$s .= '-----';
|
||||
|
||||
|
||||
$time_start = microtime(true);
|
||||
$s .= str_replace(array('<script', '</script'), array(htmlspecialchars('<script'), htmlspecialchars('</script')), $string);
|
||||
$s .= ' = ('. (microtime(true) - $time_start) .')';
|
||||
|
||||
|
||||
$time_start = microtime(true);
|
||||
if( strpos($string, '<script') ) {
|
||||
$s .= str_replace(array('<script', '</script'), array(htmlspecialchars('<script'), htmlspecialchars('</script')), $string);
|
||||
}
|
||||
$s .= ' = ('. (microtime(true) - $time_start) .')';
|
||||
|
||||
return $s;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_file_input
|
||||
*
|
||||
* This function will return HTML for a file input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_file_input( $atts = array() ) {
|
||||
|
||||
$atts['type'] = 'file';
|
||||
return acf_get_text_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_file_input
|
||||
*
|
||||
* This function will output HTML for a file input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_file_input( $atts = array() ) {
|
||||
|
||||
echo acf_get_file_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_esc_attr
|
||||
*
|
||||
* Deprecated since 5.6.0
|
||||
*
|
||||
* @type function
|
||||
* @date 1/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts (array)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_esc_attr( $atts ) {
|
||||
|
||||
return acf_esc_atts( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_esc_attr_e
|
||||
*
|
||||
* Deprecated since 5.6.0
|
||||
*
|
||||
* @type function
|
||||
* @date 1/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts (array)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_esc_attr_e( $atts ) {
|
||||
|
||||
acf_esc_atts_e( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
@ -40,6 +40,28 @@ class ACF_Compatibility {
|
|||
// location
|
||||
add_filter('acf/location/validate_rule/type=post_taxonomy', array($this, 'validate_post_taxonomy_location_rule'), 20, 1);
|
||||
add_filter('acf/location/validate_rule/type=post_category', array($this, 'validate_post_taxonomy_location_rule'), 20, 1);
|
||||
|
||||
// Update settings
|
||||
add_action('acf/init', array($this, 'init'));
|
||||
}
|
||||
|
||||
/**
|
||||
* init
|
||||
*
|
||||
* Adds compatibility for deprecated settings.
|
||||
*
|
||||
* @date 10/6/19
|
||||
* @since 5.8.1
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function init() {
|
||||
|
||||
// Update "show_admin" setting based on defined constant.
|
||||
if( defined('ACF_LITE') && ACF_LITE ) {
|
||||
acf_update_setting( 'show_admin', false );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -446,4 +468,17 @@ acf_new_instance('ACF_Compatibility');
|
|||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
/*
|
||||
* acf_get_compatibility
|
||||
*
|
||||
* Returns true if compatibility is enabled for the given component.
|
||||
*
|
||||
* @date 20/1/15
|
||||
* @since 5.1.5
|
||||
*
|
||||
* @param string $name The name of the component to check.
|
||||
* @return bool
|
||||
*/
|
||||
function acf_get_compatibility( $name ) {
|
||||
return apply_filters( "acf/compatibility/{$name}", false );
|
||||
}
|
||||
|
|
@ -1,232 +1,149 @@
|
|||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
// Register deprecated filters ( $deprecated, $version, $replacement ).
|
||||
acf_add_deprecated_filter( 'acf/settings/export_textdomain', '5.3.3', 'acf/settings/l10n_textdomain' );
|
||||
acf_add_deprecated_filter( 'acf/settings/export_translate', '5.3.3', 'acf/settings/l10n_field' );
|
||||
acf_add_deprecated_filter( 'acf/settings/export_translate', '5.3.3', 'acf/settings/l10n_field_group' );
|
||||
acf_add_deprecated_filter( 'acf/settings/dir', '5.6.8', 'acf/settings/url' );
|
||||
acf_add_deprecated_filter( 'acf/get_valid_field', '5.5.6', 'acf/validate_field' );
|
||||
acf_add_deprecated_filter( 'acf/get_valid_field_group', '5.5.6', 'acf/validate_field_group' );
|
||||
acf_add_deprecated_filter( 'acf/get_valid_post_id', '5.5.6', 'acf/validate_post_id' );
|
||||
acf_add_deprecated_filter( 'acf/get_field_reference', '5.6.5', 'acf/load_reference' );
|
||||
acf_add_deprecated_filter( 'acf/get_field_group', '5.7.11', 'acf/load_field_group' );
|
||||
acf_add_deprecated_filter( 'acf/get_field_groups', '5.7.11', 'acf/load_field_groups' );
|
||||
acf_add_deprecated_filter( 'acf/get_fields', '5.7.11', 'acf/load_fields' );
|
||||
|
||||
if( ! class_exists('acf_deprecated') ) :
|
||||
// Register variations for deprecated filters.
|
||||
acf_add_filter_variations( 'acf/get_valid_field', array('type'), 0 );
|
||||
|
||||
class acf_deprecated {
|
||||
/**
|
||||
* acf_render_field_wrap_label
|
||||
*
|
||||
* Renders the field's label.
|
||||
*
|
||||
* @date 19/9/17
|
||||
* @since 5.6.3
|
||||
* @deprecated 5.6.5
|
||||
*
|
||||
* @param array $field The field array.
|
||||
* @return void
|
||||
*/
|
||||
function acf_render_field_wrap_label( $field ) {
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* This function will setup the class functionality
|
||||
*
|
||||
* @type function
|
||||
* @date 30/1/17
|
||||
* @since 5.5.6
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// settings
|
||||
add_filter('acf/settings/show_admin', array($this, 'acf_settings_show_admin'), 5, 1); // 5.0.0
|
||||
add_filter('acf/settings/l10n_textdomain', array($this, 'acf_settings_l10n_textdomain'), 5, 1); // 5.3.3
|
||||
add_filter('acf/settings/l10n_field', array($this, 'acf_settings_l10n_field'), 5, 1); // 5.3.3
|
||||
add_filter('acf/settings/l10n_field_group', array($this, 'acf_settings_l10n_field'), 5, 1); // 5.3.3
|
||||
add_filter('acf/settings/url', array($this, 'acf_settings_url'), 5, 1); // 5.6.8
|
||||
add_filter('acf/validate_setting', array($this, 'acf_validate_setting'), 5, 1); // 5.6.8
|
||||
|
||||
|
||||
// filters
|
||||
add_filter('acf/validate_field', array($this, 'acf_validate_field'), 10, 1); // 5.5.6
|
||||
add_filter('acf/validate_field_group', array($this, 'acf_validate_field_group'), 10, 1); // 5.5.6
|
||||
add_filter('acf/validate_post_id', array($this, 'acf_validate_post_id'), 10, 2); // 5.5.6
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_settings_show_admin
|
||||
*
|
||||
* This function will add compatibility for previously named hooks
|
||||
*
|
||||
* @type function
|
||||
* @date 19/05/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_settings_show_admin( $setting ) {
|
||||
|
||||
// 5.0.0 - removed ACF_LITE
|
||||
return ( defined('ACF_LITE') && ACF_LITE ) ? false : $setting;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_settings_l10n_textdomain
|
||||
*
|
||||
* This function will add compatibility for previously named hooks
|
||||
*
|
||||
* @type function
|
||||
* @date 19/05/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_settings_l10n_textdomain( $setting ) {
|
||||
|
||||
// 5.3.3 - changed filter name
|
||||
return acf_get_setting( 'export_textdomain', $setting );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_settings_l10n_field
|
||||
*
|
||||
* This function will add compatibility for previously named hooks
|
||||
*
|
||||
* @type function
|
||||
* @date 19/05/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_settings_l10n_field( $setting ) {
|
||||
|
||||
// 5.3.3 - changed filter name
|
||||
return acf_get_setting( 'export_translate', $setting );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* acf_settings_url
|
||||
*
|
||||
* This function will add compatibility for previously named hooks
|
||||
*
|
||||
* @date 12/12/17
|
||||
* @since 5.6.8
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_settings_url( $value ) {
|
||||
return apply_filters( "acf/settings/dir", $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_validate_setting
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 2/2/18
|
||||
* @since 5.6.5
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
function acf_validate_setting( $name ) {
|
||||
|
||||
// vars
|
||||
$changed = array(
|
||||
'dir' => 'url' // 5.6.8
|
||||
);
|
||||
|
||||
// check
|
||||
if( isset($changed[ $name ]) ) {
|
||||
return $changed[ $name ];
|
||||
}
|
||||
|
||||
//return
|
||||
return $name;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_validate_field
|
||||
*
|
||||
* This function will add compatibility for previously named hooks
|
||||
*
|
||||
* @type function
|
||||
* @date 30/1/17
|
||||
* @since 5.5.6
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_validate_field( $field ) {
|
||||
|
||||
// 5.5.6 - changed filter name
|
||||
$field = apply_filters( "acf/get_valid_field/type={$field['type']}", $field );
|
||||
$field = apply_filters( "acf/get_valid_field", $field );
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_validate_field_group
|
||||
*
|
||||
* This function will add compatibility for previously named hooks
|
||||
*
|
||||
* @type function
|
||||
* @date 30/1/17
|
||||
* @since 5.5.6
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_validate_field_group( $field_group ) {
|
||||
|
||||
// 5.5.6 - changed filter name
|
||||
$field_group = apply_filters('acf/get_valid_field_group', $field_group);
|
||||
|
||||
|
||||
// return
|
||||
return $field_group;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_validate_post_id
|
||||
*
|
||||
* This function will add compatibility for previously named hooks
|
||||
*
|
||||
* @type function
|
||||
* @date 6/2/17
|
||||
* @since 5.5.6
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_validate_post_id( $post_id, $_post_id ) {
|
||||
|
||||
// 5.5.6 - changed filter name
|
||||
$post_id = apply_filters('acf/get_valid_post_id', $post_id, $_post_id);
|
||||
|
||||
|
||||
// return
|
||||
return $post_id;
|
||||
|
||||
}
|
||||
// Warning.
|
||||
_deprecated_function( __FUNCTION__, '5.7.11', 'acf_render_field_label()' );
|
||||
|
||||
// Render.
|
||||
acf_render_field_label( $field );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_render_field_wrap_description
|
||||
*
|
||||
* Renders the field's instructions.
|
||||
*
|
||||
* @date 19/9/17
|
||||
* @since 5.6.3
|
||||
* @deprecated 5.6.5
|
||||
*
|
||||
* @param array $field The field array.
|
||||
* @return void
|
||||
*/
|
||||
function acf_render_field_wrap_description( $field ) {
|
||||
|
||||
// initialize
|
||||
acf()->deprecated = new acf_deprecated();
|
||||
// Warning.
|
||||
_deprecated_function( __FUNCTION__, '5.7.11', 'acf_render_field_instructions()' );
|
||||
|
||||
endif; // class_exists check
|
||||
// Render.
|
||||
acf_render_field_instructions( $field );
|
||||
}
|
||||
|
||||
?>
|
||||
/*
|
||||
* acf_get_fields_by_id
|
||||
*
|
||||
* Returns and array of fields for the given $parent_id.
|
||||
*
|
||||
* @date 27/02/2014
|
||||
* @since 5.0.0.
|
||||
* @deprecated 5.7.11
|
||||
*
|
||||
* @param int $parent_id The parent ID.
|
||||
* @return array
|
||||
*/
|
||||
function acf_get_fields_by_id( $parent_id = 0 ) {
|
||||
|
||||
// Warning.
|
||||
_deprecated_function( __FUNCTION__, '5.7.11', 'acf_get_fields()' );
|
||||
|
||||
// Return fields.
|
||||
return acf_get_fields(array( 'ID' => $parent_id, 'key' => "group_$parent_id" ));
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_update_option
|
||||
*
|
||||
* A wrapper for the WP update_option but provides logic for a 'no' autoload
|
||||
*
|
||||
* @date 4/01/2014
|
||||
* @since 5.0.0
|
||||
* @deprecated 5.7.11
|
||||
*
|
||||
* @param string $option The option name.
|
||||
* @param string $value The option value.
|
||||
* @param string $autoload An optional autoload value.
|
||||
* @return bool
|
||||
*/
|
||||
function acf_update_option( $option = '', $value = '', $autoload = null ) {
|
||||
|
||||
// Warning.
|
||||
_deprecated_function( __FUNCTION__, '5.7.11', 'update_option()' );
|
||||
|
||||
// Update.
|
||||
if( $autoload === null ) {
|
||||
$autoload = (bool) acf_get_setting('autoload');
|
||||
}
|
||||
return update_option( $option, $value, $autoload );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_field_reference
|
||||
*
|
||||
* Finds the field key for a given field name and post_id.
|
||||
*
|
||||
* @date 26/1/18
|
||||
* @since 5.6.5
|
||||
* @deprecated 5.6.8
|
||||
*
|
||||
* @param string $field_name The name of the field. eg 'sub_heading'
|
||||
* @param mixed $post_id The post_id of which the value is saved against
|
||||
* @return string $reference The field key
|
||||
*/
|
||||
function acf_get_field_reference( $field_name, $post_id ) {
|
||||
|
||||
// Warning.
|
||||
_deprecated_function( __FUNCTION__, '5.6.8', 'acf_get_reference()' );
|
||||
|
||||
// Return reference.
|
||||
return acf_get_reference( $field_name, $post_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_dir
|
||||
*
|
||||
* Returns the plugin url to a specified file.
|
||||
*
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
* @deprecated 5.6.8
|
||||
*
|
||||
* @param string $filename The specified file.
|
||||
* @return string
|
||||
*/
|
||||
function acf_get_dir( $filename = '' ) {
|
||||
|
||||
// Warning.
|
||||
_deprecated_function( __FUNCTION__, '5.6.8', 'acf_get_url()' );
|
||||
|
||||
// Return.
|
||||
return acf_get_url( $filename );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ class acf_field_image extends acf_field {
|
|||
|
||||
// filters
|
||||
add_filter('get_media_item_args', array($this, 'get_media_item_args'));
|
||||
add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -377,65 +376,6 @@ class acf_field_image extends acf_field {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* wp_prepare_attachment_for_js
|
||||
*
|
||||
* this filter allows ACF to add in extra data to an attachment JS object
|
||||
* This sneaky hook adds the missing sizes to each attachment in the 3.5 uploader.
|
||||
* It would be a lot easier to add all the sizes to the 'image_size_names_choose' filter but
|
||||
* then it will show up on the normal the_content editor
|
||||
*
|
||||
* @type function
|
||||
* @since: 3.5.7
|
||||
* @date 13/01/13
|
||||
*
|
||||
* @param {int} $post_id
|
||||
* @return {int} $post_id
|
||||
*/
|
||||
|
||||
function wp_prepare_attachment_for_js( $response, $attachment, $meta ) {
|
||||
|
||||
// only for image
|
||||
if( $response['type'] != 'image' ) {
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// make sure sizes exist. Perhaps they dont?
|
||||
if( !isset($meta['sizes']) ) {
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$attachment_url = $response['url'];
|
||||
$base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url );
|
||||
|
||||
if( isset($meta['sizes']) && is_array($meta['sizes']) ) {
|
||||
|
||||
foreach( $meta['sizes'] as $k => $v ) {
|
||||
|
||||
if( !isset($response['sizes'][ $k ]) ) {
|
||||
|
||||
$response['sizes'][ $k ] = array(
|
||||
'height' => $v['height'],
|
||||
'width' => $v['width'],
|
||||
'url' => $base_url . $v['file'],
|
||||
'orientation' => $v['height'] > $v['width'] ? 'portrait' : 'landscape',
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* update_value()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ class acf_field_post_object extends acf_field {
|
|||
|
||||
|
||||
// convert back from array if neccessary
|
||||
if( !$field['multiple'] && acf_is_array($value) ) {
|
||||
if( !$field['multiple'] && is_array($value) ) {
|
||||
|
||||
$value = current($value);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,55 +47,31 @@ class acf_field_text extends acf_field {
|
|||
*/
|
||||
|
||||
function render_field( $field ) {
|
||||
|
||||
// vars
|
||||
$atts = array();
|
||||
$keys = array( 'type', 'id', 'class', 'name', 'value', 'placeholder', 'maxlength', 'pattern' );
|
||||
$keys2 = array( 'readonly', 'disabled', 'required' );
|
||||
$html = '';
|
||||
|
||||
|
||||
// prepend
|
||||
// Prepend text.
|
||||
if( $field['prepend'] !== '' ) {
|
||||
|
||||
$field['class'] .= ' acf-is-prepended';
|
||||
$html .= '<div class="acf-input-prepend">' . acf_esc_html($field['prepend']) . '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append
|
||||
// Append text.
|
||||
if( $field['append'] !== '' ) {
|
||||
|
||||
$field['class'] .= ' acf-is-appended';
|
||||
$html .= '<div class="acf-input-append">' . acf_esc_html($field['append']) . '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// atts (value="123")
|
||||
foreach( $keys as $k ) {
|
||||
if( isset($field[ $k ]) ) $atts[ $k ] = $field[ $k ];
|
||||
// Input.
|
||||
$input_attrs = array();
|
||||
foreach( array( 'type', 'id', 'class', 'name', 'value', 'placeholder', 'maxlength', 'pattern', 'readonly', 'disabled', 'required' ) as $k ) {
|
||||
if( isset($field[ $k ]) ) {
|
||||
$input_attrs[ $k ] = $field[ $k ];
|
||||
}
|
||||
}
|
||||
$html .= '<div class="acf-input-wrap">' . acf_get_text_input( acf_filter_attrs($input_attrs) ) . '</div>';
|
||||
|
||||
|
||||
// atts2 (disabled="disabled")
|
||||
foreach( $keys2 as $k ) {
|
||||
if( !empty($field[ $k ]) ) $atts[ $k ] = $k;
|
||||
}
|
||||
|
||||
|
||||
// remove empty atts
|
||||
$atts = acf_clean_atts( $atts );
|
||||
|
||||
|
||||
// render
|
||||
$html .= '<div class="acf-input-wrap">' . acf_get_text_input( $atts ) . '</div>';
|
||||
|
||||
|
||||
// return
|
||||
// Display.
|
||||
echo $html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -208,8 +208,10 @@ class acf_field_textarea extends acf_field {
|
|||
*/
|
||||
function validate_value( $valid, $value, $field, $input ){
|
||||
|
||||
// Check maxlength
|
||||
if( $field['maxlength'] && mb_strlen(wp_unslash($value)) > $field['maxlength'] ) {
|
||||
// Check maxlength.
|
||||
// Note: Due to the way strlen (and mb_strlen) work, line breaks count as two characters in PHP, but not in Javascript (or HTML).
|
||||
// To avoid incorrectly calculating the length, replace double line breaks.
|
||||
if( $field['maxlength'] && mb_strlen(str_replace("\r\n", "\n", wp_unslash($value))) > $field['maxlength'] ) {
|
||||
return sprintf( __('Value must not exceed %d characters', 'acf'), $field['maxlength'] );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,12 +118,39 @@ class ACF_Form_Gutenberg {
|
|||
// Update original data.
|
||||
$wp_meta_boxes[ $current_screen->id ] = $locations;
|
||||
unset( $wp_meta_boxes[ $current_screen->id ]['acf_after_title'] );
|
||||
|
||||
// Avoid conflicts with saved metabox order.
|
||||
add_filter( 'get_user_option_meta-box-order_' . $current_screen->id, array($this, 'modify_user_option_meta_box_order') );
|
||||
}
|
||||
|
||||
// Return
|
||||
return $wp_meta_boxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* modify_user_option_meta_box_order
|
||||
*
|
||||
* Filters the `meta-box-order_{$post_type}` value by prepending "acf_after_title" data to "normal".
|
||||
* Fixes a bug where metaboxes with position "acf_after_title" do not appear in the block editor.
|
||||
*
|
||||
* @date 11/7/19
|
||||
* @since 5.8.2
|
||||
*
|
||||
* @param array $stored_meta_box_order User's existing meta box order.
|
||||
* @return array Modified array with meta boxes moved around.
|
||||
*/
|
||||
function modify_user_option_meta_box_order( $locations ) {
|
||||
if( !empty($locations['acf_after_title']) ) {
|
||||
if( !empty($locations['normal']) ) {
|
||||
$locations['normal'] = $locations['acf_after_title'] . ',' . $locations['normal'];
|
||||
} else {
|
||||
$locations['normal'] = $locations['acf_after_title'];
|
||||
}
|
||||
unset($locations['acf_after_title']);
|
||||
}
|
||||
return $locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_validate_save_post
|
||||
*
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ class ACF_Form_User {
|
|||
// save
|
||||
add_action('user_register', array($this, 'save_user'));
|
||||
add_action('profile_update', array($this, 'save_user'));
|
||||
|
||||
// Perform validation before new user is registered.
|
||||
add_filter('registration_errors', array($this, 'filter_registration_errors'), 10, 3);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -185,6 +188,11 @@ class ACF_Form_User {
|
|||
|
||||
function render( $args = array() ) {
|
||||
|
||||
// Allow $_POST data to persist across form submission attempts.
|
||||
if( isset($_POST['acf']) ) {
|
||||
add_filter('acf/pre_load_value', array($this, 'filter_pre_load_value'), 10, 3);
|
||||
}
|
||||
|
||||
// defaults
|
||||
$args = wp_parse_args($args, array(
|
||||
'user_id' => 0,
|
||||
|
|
@ -305,6 +313,53 @@ class ACF_Form_User {
|
|||
acf_save_post( "user_$user_id" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* filter_registration_errors
|
||||
*
|
||||
* Validates $_POST data and appends any errors to prevent new user registration.
|
||||
*
|
||||
* @date 12/7/19
|
||||
* @since 5.8.1
|
||||
*
|
||||
* @param WP_Error $errors A WP_Error object containing any errors encountered during registration.
|
||||
* @param string $sanitized_user_login User's username after it has been sanitized.
|
||||
* @param string $user_email User's email.
|
||||
* @return WP_Error
|
||||
*/
|
||||
function filter_registration_errors( $errors, $sanitized_user_login, $user_email ) {
|
||||
if( !acf_validate_save_post() ) {
|
||||
$acf_errors = acf_get_validation_errors();
|
||||
foreach( $acf_errors as $acf_error ) {
|
||||
$errors->add(
|
||||
acf_idify( $acf_error['input'] ),
|
||||
acf_punctify( sprintf( __('<strong>ERROR</strong>: %s', 'acf'), $acf_error['message'] ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* filter_pre_load_value
|
||||
*
|
||||
* Checks if a $_POST value exists for this field to allow persistent values.
|
||||
*
|
||||
* @date 12/7/19
|
||||
* @since 5.8.2
|
||||
*
|
||||
* @param null $null A null placeholder.
|
||||
* @param (int|string) $post_id The post id.
|
||||
* @param array $field The field array.
|
||||
* @return mixed
|
||||
*/
|
||||
function filter_pre_load_value( $null, $post_id, $field ) {
|
||||
$field_key = $field['key'];
|
||||
if( isset( $_POST['acf'][ $field_key ] )) {
|
||||
return $_POST['acf'][ $field_key ];
|
||||
}
|
||||
return $null;
|
||||
}
|
||||
}
|
||||
|
||||
// instantiate
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ function acf_get_locale() {
|
|||
$langs = array(
|
||||
'az_TR' => 'az', // Azerbaijani (Turkey)
|
||||
'zh_HK' => 'zh_CN', // Chinese (Hong Kong)
|
||||
//'zh_TW' => 'zh_CN', // Chinese (Taiwan)
|
||||
'nl_BE' => 'nl_NL', // Dutch (Belgium)
|
||||
'fr_BE' => 'fr_FR', // French (Belgium)
|
||||
'nn_NO' => 'nb_NO', // Norwegian (Nynorsk)
|
||||
|
|
@ -152,6 +151,3 @@ function _acf_apply_language_cache_key( $key ) {
|
|||
|
||||
// Hook into filter.
|
||||
add_filter( 'acf/get_cache_key', '_acf_apply_language_cache_key' );
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
1642
lang/acf-fr_FR.po
1642
lang/acf-fr_FR.po
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
|
@ -3,14 +3,14 @@ msgstr ""
|
|||
"Project-Id-Version: Advanced Custom Fields Pro v5.2.9\n"
|
||||
"Report-Msgid-Bugs-To: http://support.advancedcustomfields.com\n"
|
||||
"POT-Creation-Date: 2018-09-06 12:21+1000\n"
|
||||
"PO-Revision-Date: 2018-10-01 21:47+0200\n"
|
||||
"PO-Revision-Date: 2019-07-29 14:31+1000\n"
|
||||
"Last-Translator: Elliot Condon <e@elliotcondon.com>\n"
|
||||
"Language-Team: Dariusz Zielonka <dariusz@zielonka.pro>\n"
|
||||
"Language: pl_PL\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.0.3\n"
|
||||
"X-Generator: Poedit 1.8.1\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
||||
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
|
||||
|
|
@ -1459,7 +1459,8 @@ msgstr "Relacyjne"
|
|||
msgid "jQuery"
|
||||
msgstr "jQuery"
|
||||
|
||||
#: includes/fields.php:354 includes/fields/class-acf-field-button-group.php:177
|
||||
#: includes/fields.php:354
|
||||
#: includes/fields/class-acf-field-button-group.php:177
|
||||
#: includes/fields/class-acf-field-checkbox.php:389
|
||||
#: includes/fields/class-acf-field-group.php:474
|
||||
#: includes/fields/class-acf-field-radio.php:290
|
||||
|
|
@ -2738,8 +2739,8 @@ msgstr "Edytuj grupę pól"
|
|||
msgid "Validate Email"
|
||||
msgstr "Waliduj E-mail"
|
||||
|
||||
#: includes/forms/form-front.php:103 pro/fields/class-acf-field-gallery.php:588
|
||||
#: pro/options-page.php:81
|
||||
#: includes/forms/form-front.php:103
|
||||
#: pro/fields/class-acf-field-gallery.php:588 pro/options-page.php:81
|
||||
msgid "Update"
|
||||
msgstr "Aktualizuj"
|
||||
|
||||
|
|
@ -3253,7 +3254,7 @@ msgstr "Minimalna liczba wierszy"
|
|||
|
||||
#: pro/fields/class-acf-field-repeater.php:433
|
||||
msgid "Maximum Rows"
|
||||
msgstr "Minimalna liczba wierszy"
|
||||
msgstr "Maksymalna liczba wierszy"
|
||||
|
||||
#: pro/locations/class-acf-location-options-page.php:79
|
||||
msgid "No options pages exist"
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -415,7 +415,7 @@ function acf_enqueue_block_type_assets( $block_type ) {
|
|||
|
||||
// Enqueue assets callback.
|
||||
if( $block_type['enqueue_assets'] && is_callable($block_type['enqueue_assets']) ) {
|
||||
call_user_func( $block_type['enqueue_assets'] );
|
||||
call_user_func( $block_type['enqueue_assets'], $block_type );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -534,7 +534,7 @@ function acf_parse_save_blocks( $text = '' ) {
|
|||
// Search text for dynamic blocks and modify attrs.
|
||||
return addslashes(
|
||||
preg_replace_callback(
|
||||
'/<!--\s+wp:(?P<name>[\S]+)\s+(?P<attrs>{[\S\s]+?})\s+\/-->/',
|
||||
'/<!--\s+wp:(?P<name>[\S]+)\s+(?P<attrs>{[\S\s]+?})\s+(?P<void>\/)?-->/',
|
||||
'acf_parse_save_blocks_callback',
|
||||
stripslashes( $text )
|
||||
)
|
||||
|
|
|
|||
|
|
@ -91,38 +91,34 @@ class acf_field_gallery extends acf_field {
|
|||
|
||||
function ajax_get_attachment() {
|
||||
|
||||
// options
|
||||
$options = acf_parse_args( $_POST, array(
|
||||
'post_id' => 0,
|
||||
'attachment' => 0,
|
||||
'id' => 0,
|
||||
'field_key' => '',
|
||||
'nonce' => '',
|
||||
));
|
||||
|
||||
|
||||
// validate
|
||||
// Validate requrest.
|
||||
if( !acf_verify_ajax() ) {
|
||||
die();
|
||||
}
|
||||
|
||||
// Get args.
|
||||
$args = acf_request_args(array(
|
||||
'id' => 0,
|
||||
'field_key' => '',
|
||||
));
|
||||
|
||||
// bail early if no id
|
||||
if( !$options['id'] ) die();
|
||||
// Cast args.
|
||||
$args['id'] = (int) $args['id'];
|
||||
|
||||
// Bail early if no id.
|
||||
if( !$args['id'] ) {
|
||||
die();
|
||||
}
|
||||
|
||||
// load field
|
||||
$field = acf_get_field( $options['field_key'] );
|
||||
// Load field.
|
||||
$field = acf_get_field( $args['field_key'] );
|
||||
if( !$field ) {
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
// bali early if no field
|
||||
if( !$field ) die();
|
||||
|
||||
|
||||
// render
|
||||
$this->render_attachment( $options['id'], $field );
|
||||
// Render.
|
||||
$this->render_attachment( $args['id'], $field );
|
||||
die;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -285,87 +281,69 @@ class acf_field_gallery extends acf_field {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_attachment
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 13/12/2013
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
/**
|
||||
* render_attachment
|
||||
*
|
||||
* Renders the sidebar HTML shown when selecting an attachmemnt.
|
||||
*
|
||||
* @date 13/12/2013
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param int $id The attachment ID.
|
||||
* @param array $field The field array.
|
||||
* @return void
|
||||
*/
|
||||
function render_attachment( $id = 0, $field ) {
|
||||
|
||||
// vars
|
||||
// Load attachmenet data.
|
||||
$attachment = wp_prepare_attachment_for_js( $id );
|
||||
$compat = get_compat_media_markup( $id );
|
||||
$compat = $compat['item'];
|
||||
$prefix = 'attachments[' . $id . ']';
|
||||
$thumb = '';
|
||||
$dimentions = '';
|
||||
|
||||
|
||||
// thumb
|
||||
// Get attachment thumbnail (video).
|
||||
if( isset($attachment['thumb']['src']) ) {
|
||||
|
||||
// video
|
||||
$thumb = $attachment['thumb']['src'];
|
||||
|
||||
// Look for thumbnail size (image).
|
||||
} elseif( isset($attachment['sizes']['thumbnail']['url']) ) {
|
||||
|
||||
// image
|
||||
$thumb = $attachment['sizes']['thumbnail']['url'];
|
||||
|
||||
// Use url for svg.
|
||||
} elseif( $attachment['type'] === 'image' ) {
|
||||
|
||||
// svg
|
||||
$thumb = $attachment['url'];
|
||||
|
||||
// Default to icon.
|
||||
} else {
|
||||
|
||||
// fallback (perhaps attachment does not exist)
|
||||
$thumb = wp_mime_type_icon();
|
||||
|
||||
$thumb = wp_mime_type_icon( $id );
|
||||
}
|
||||
|
||||
|
||||
// dimentions
|
||||
// Get attachment dimentions / time / size.
|
||||
if( $attachment['type'] === 'audio' ) {
|
||||
|
||||
$dimentions = __('Length', 'acf') . ': ' . $attachment['fileLength'];
|
||||
|
||||
} elseif( !empty($attachment['width']) ) {
|
||||
|
||||
$dimentions = $attachment['width'] . ' x ' . $attachment['height'];
|
||||
|
||||
}
|
||||
|
||||
if( !empty($attachment['filesizeHumanReadable']) ) {
|
||||
|
||||
$dimentions .= ' (' . $attachment['filesizeHumanReadable'] . ')';
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="acf-gallery-side-info">
|
||||
<img src="<?php echo $thumb; ?>" alt="<?php echo $attachment['alt']; ?>" />
|
||||
<p class="filename"><strong><?php echo $attachment['filename']; ?></strong></p>
|
||||
<p class="uploaded"><?php echo $attachment['dateFormatted']; ?></p>
|
||||
<p class="dimensions"><?php echo $dimentions; ?></p>
|
||||
<img src="<?php echo esc_attr($thumb); ?>" alt="<?php echo esc_attr($attachment['alt']); ?>" />
|
||||
<p class="filename"><strong><?php echo esc_html($attachment['filename']); ?></strong></p>
|
||||
<p class="uploaded"><?php echo esc_html($attachment['dateFormatted']); ?></p>
|
||||
<p class="dimensions"><?php echo esc_html($dimentions); ?></p>
|
||||
<p class="actions">
|
||||
<a href="#" class="acf-gallery-edit" data-id="<?php echo $id; ?>"><?php _e('Edit', 'acf'); ?></a>
|
||||
<a href="#" class="acf-gallery-remove" data-id="<?php echo $id; ?>"><?php _e('Remove', 'acf'); ?></a>
|
||||
<a href="#" class="acf-gallery-edit" data-id="<?php echo esc_attr($id); ?>"><?php _e('Edit', 'acf'); ?></a>
|
||||
<a href="#" class="acf-gallery-remove" data-id="<?php echo esc_attr($id); ?>"><?php _e('Remove', 'acf'); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
// Render fields.
|
||||
$prefix = 'attachments[' . $id . ']';
|
||||
|
||||
acf_render_field_wrap(array(
|
||||
//'key' => "{$field['key']}-title",
|
||||
'name' => 'title',
|
||||
|
|
@ -407,8 +385,8 @@ class acf_field_gallery extends acf_field {
|
|||
</table>
|
||||
<?php
|
||||
|
||||
echo $compat;
|
||||
|
||||
// Display compat fields.
|
||||
echo $compat['item'];
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class acf_location_options_page extends acf_location {
|
|||
// populate
|
||||
if( !empty($pages) ) {
|
||||
foreach( $pages as $page ) {
|
||||
$choices[ $page['menu_slug'] ] = $page['menu_title'];
|
||||
$choices[ $page['menu_slug'] ] = $page['page_title'];
|
||||
}
|
||||
} else {
|
||||
$choices[''] = __('No options pages exist', 'acf');
|
||||
|
|
|
|||
20
readme.txt
20
readme.txt
|
|
@ -67,6 +67,26 @@ From your WordPress dashboard
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 5.8.3 =
|
||||
*Release Date - 7 August 2019*
|
||||
|
||||
* Tweak - Changed Options Page location rules to show "page_title" instead of "menu_title".
|
||||
* Fix - Fixed bug causing Textarea field to incorrectly validate maxlength.
|
||||
* Fix - Fixed bug allowing Range field values outside of the min and max settings.
|
||||
* Fix - Fixed bug in block RegExp causing some blocks to miss the "acf/pre_save_block" filter.
|
||||
* Dev - Added `$block_type` parameter to block settings "enqueue_assets" callback.
|
||||
* i18n - Added French Canadian language thanks to Bérenger Zyla.
|
||||
* i18n - Updated French language thanks to Bérenger Zyla.
|
||||
|
||||
= 5.8.2 =
|
||||
*Release Date - 15 July 2019*
|
||||
|
||||
* Fix - Fixed bug where validation did not prevent new user registration.
|
||||
* Fix - Fixed bug causing some "reordered" metaboxes to not appear in the Gutenberg editor.
|
||||
* Fix - Fixed bug causing WYSIWYG field with delayed initialization to appear blank.
|
||||
* Fix - Fixed bug when editing a post and adding a new tag did not refresh metaboxes.
|
||||
* Dev - Added missing `$value` parameter in "acf/pre_format_value" filter.
|
||||
|
||||
= 5.8.1 =
|
||||
*Release Date - 3 June 2019*
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue