plugin updates
This commit is contained in:
@@ -26,7 +26,10 @@ if ( ! class_exists( 'acf_field__accordion' ) ) :
|
||||
$this->description = __( 'Allows you to group and organize custom fields into collapsable panels that are shown while editing content. Useful for keeping large datasets tidy.', 'acf' );
|
||||
$this->preview_image = acf_get_url() . '/assets/images/field-type-previews/field-preview-accordion.png';
|
||||
$this->doc_url = acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/resources/accordion/', 'docs', 'field-type-selection' );
|
||||
$this->supports = array( 'required' => false );
|
||||
$this->supports = array(
|
||||
'required' => false,
|
||||
'bindings' => false,
|
||||
);
|
||||
$this->defaults = array(
|
||||
'open' => 0,
|
||||
'multi_expand' => 0,
|
||||
|
||||
@@ -24,6 +24,9 @@ if ( ! class_exists( 'acf_field__group' ) ) :
|
||||
$this->description = __( 'Provides a way to structure fields into groups to better organize the data and the edit screen.', 'acf' );
|
||||
$this->preview_image = acf_get_url() . '/assets/images/field-type-previews/field-preview-group.png';
|
||||
$this->doc_url = acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/resources/group/', 'docs', 'field-type-selection' );
|
||||
$this->supports = array(
|
||||
'bindings' => false,
|
||||
);
|
||||
$this->defaults = array(
|
||||
'sub_fields' => array(),
|
||||
'layout' => 'block',
|
||||
|
||||
@@ -24,7 +24,10 @@ if ( ! class_exists( 'acf_field_message' ) ) :
|
||||
$this->category = 'layout';
|
||||
$this->description = __( 'Used to display a message to editors alongside other fields. Useful for providing additional context or instructions around your fields.', 'acf' );
|
||||
$this->preview_image = acf_get_url() . '/assets/images/field-type-previews/field-preview-message.png';
|
||||
$this->supports = array( 'required' => false );
|
||||
$this->supports = array(
|
||||
'required' => false,
|
||||
'bindings' => false,
|
||||
);
|
||||
$this->defaults = array(
|
||||
'message' => '',
|
||||
'esc_html' => 0,
|
||||
|
||||
@@ -42,67 +42,59 @@ if ( ! class_exists( 'acf_field_select' ) ) :
|
||||
|
||||
|
||||
/**
|
||||
* description
|
||||
* Enqueues admin scripts for the Select field.
|
||||
*
|
||||
* @type function
|
||||
* @date 16/12/2015
|
||||
* @since 5.3.2
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
* @return void
|
||||
*/
|
||||
function input_admin_enqueue_scripts() {
|
||||
|
||||
// bail early if no enqueue
|
||||
public function input_admin_enqueue_scripts() {
|
||||
// Bail early if not enqueuing select2.
|
||||
if ( ! acf_get_setting( 'enqueue_select2' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// globals
|
||||
global $wp_scripts, $wp_styles;
|
||||
global $wp_scripts;
|
||||
|
||||
// vars
|
||||
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
$major = acf_get_setting( 'select2_version' );
|
||||
$version = '';
|
||||
$script = '';
|
||||
$style = '';
|
||||
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
$major = acf_get_setting( 'select2_version' );
|
||||
|
||||
// attempt to find 3rd party Select2 version
|
||||
// - avoid including v3 CSS when v4 JS is already enququed
|
||||
// - avoid including v3 CSS when v4 JS is already enqueued.
|
||||
if ( isset( $wp_scripts->registered['select2'] ) ) {
|
||||
$major = (int) $wp_scripts->registered['select2']->ver;
|
||||
}
|
||||
|
||||
// v4
|
||||
if ( $major == 4 ) {
|
||||
$version = '4.0.13';
|
||||
$script = acf_get_url( "assets/inc/select2/4/select2.full{$min}.js" );
|
||||
$style = acf_get_url( "assets/inc/select2/4/select2{$min}.css" );
|
||||
|
||||
// v3
|
||||
} else {
|
||||
if ( $major === 3 ) {
|
||||
// Use v3 if necessary.
|
||||
$version = '3.5.2';
|
||||
$script = acf_get_url( "assets/inc/select2/3/select2{$min}.js" );
|
||||
$style = acf_get_url( 'assets/inc/select2/3/select2.css' );
|
||||
} else {
|
||||
// Default to v4.
|
||||
$version = '4.0.13';
|
||||
$script = acf_get_url( "assets/inc/select2/4/select2.full{$min}.js" );
|
||||
$style = acf_get_url( "assets/inc/select2/4/select2{$min}.css" );
|
||||
}
|
||||
|
||||
// enqueue
|
||||
wp_enqueue_script( 'select2', $script, array( 'jquery' ), $version );
|
||||
wp_enqueue_style( 'select2', $style, '', $version );
|
||||
|
||||
// localize
|
||||
acf_localize_data(
|
||||
array(
|
||||
'select2L10n' => array(
|
||||
'matches_1' => _x( 'One result is available, press enter to select it.', 'Select2 JS matches_1', 'acf' ),
|
||||
/* translators: %d - number of results available in select field */
|
||||
'matches_n' => _x( '%d results are available, use up and down arrow keys to navigate.', 'Select2 JS matches_n', 'acf' ),
|
||||
'matches_0' => _x( 'No matches found', 'Select2 JS matches_0', 'acf' ),
|
||||
'input_too_short_1' => _x( 'Please enter 1 or more characters', 'Select2 JS input_too_short_1', 'acf' ),
|
||||
/* translators: %d - number of characters to enter into select field input */
|
||||
'input_too_short_n' => _x( 'Please enter %d or more characters', 'Select2 JS input_too_short_n', 'acf' ),
|
||||
'input_too_long_1' => _x( 'Please delete 1 character', 'Select2 JS input_too_long_1', 'acf' ),
|
||||
/* translators: %d - number of characters that should be removed from select field */
|
||||
'input_too_long_n' => _x( 'Please delete %d characters', 'Select2 JS input_too_long_n', 'acf' ),
|
||||
'selection_too_long_1' => _x( 'You can only select 1 item', 'Select2 JS selection_too_long_1', 'acf' ),
|
||||
/* translators: %d - maximum number of items that can be selected in the select field */
|
||||
'selection_too_long_n' => _x( 'You can only select %d items', 'Select2 JS selection_too_long_n', 'acf' ),
|
||||
'load_more' => _x( 'Loading more results…', 'Select2 JS load_more', 'acf' ),
|
||||
'searching' => _x( 'Searching…', 'Select2 JS searching', 'acf' ),
|
||||
|
||||
@@ -25,7 +25,10 @@ if ( ! class_exists( 'acf_field_tab' ) ) :
|
||||
$this->description = __( 'Allows you to group fields into tabbed sections in the edit screen. Useful for keeping fields organized and structured.', 'acf' );
|
||||
$this->preview_image = acf_get_url() . '/assets/images/field-type-previews/field-preview-tabs.png';
|
||||
$this->doc_url = acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/resources/tab/', 'docs', 'field-type-selection' );
|
||||
$this->supports = array( 'required' => false );
|
||||
$this->supports = array(
|
||||
'required' => false,
|
||||
'bindings' => false,
|
||||
);
|
||||
$this->defaults = array(
|
||||
'placement' => 'top',
|
||||
'endpoint' => 0, // added in 5.2.8
|
||||
|
||||
@@ -78,8 +78,9 @@ if ( ! class_exists( 'acf_field' ) ) :
|
||||
$this->add_action( 'acf/field_group/admin_head', array( $this, 'field_group_admin_head' ), 10, 0 );
|
||||
$this->add_action( 'acf/field_group/admin_footer', array( $this, 'field_group_admin_footer' ), 10, 0 );
|
||||
|
||||
// Most fields can use the "Required" validation setting as well as most presentation settings.
|
||||
// Add field global settings configurable by supports on specific field types.
|
||||
$this->add_field_action( 'acf/field_group/render_field_settings_tab/validation', array( $this, 'render_required_setting' ), 5 );
|
||||
$this->add_field_action( 'acf/field_group/render_field_settings_tab/presentation', array( $this, 'render_bindings_setting' ), 5 );
|
||||
|
||||
foreach ( acf_get_combined_field_type_settings_tabs() as $tab_key => $tab_label ) {
|
||||
$this->add_field_action( "acf/field_group/render_field_settings_tab/{$tab_key}", array( $this, "render_field_{$tab_key}_settings" ), 9, 1 );
|
||||
@@ -318,6 +319,53 @@ if ( ! class_exists( 'acf_field' ) ) :
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the "Allow in Bindings" setting on the field type "Presentation" settings tab.
|
||||
*
|
||||
* @since 6.3.6
|
||||
*
|
||||
* @param array $field The field type being rendered.
|
||||
* @return void
|
||||
*/
|
||||
public function render_bindings_setting( $field ) {
|
||||
$supports_bindings = acf_field_type_supports( $field['type'], 'bindings', true );
|
||||
|
||||
// Only prevent rendering if explicitly disabled.
|
||||
if ( ! $supports_bindings ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* translators: %s A "Learn More" link to documentation explaining the setting further. */
|
||||
$binding_string = esc_html__( 'Allow content editors to access and display the field value in the editor UI using Block Bindings or the ACF Shortcode. %s', 'acf' );
|
||||
$binding_url = '<a target="_blank" href="' . acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/resources/bindings-security/', 'docs', 'field-settings' ) . '">' . esc_html__( 'Learn more.', 'acf' ) . '</a>';
|
||||
$binding_instructions = sprintf(
|
||||
$binding_string,
|
||||
$binding_url
|
||||
);
|
||||
|
||||
// This field setting has a unique behaviour. If the value isn't defined on the field object, it defaults to true, but for new fields, it defaults to off.
|
||||
if ( ! isset( $field['allow_in_bindings'] ) ) {
|
||||
if ( empty( $field['ID'] ) ) {
|
||||
$field['allow_in_bindings'] = false;
|
||||
} else {
|
||||
$field['allow_in_bindings'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
acf_render_field_setting(
|
||||
$field,
|
||||
array(
|
||||
'label' => __( 'Allow Access to Value in Editor UI', 'acf' ),
|
||||
'instructions' => $binding_instructions,
|
||||
'type' => 'true_false',
|
||||
'name' => 'allow_in_bindings',
|
||||
'ui' => 1,
|
||||
'class' => 'field-show-in-bindings',
|
||||
),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
Reference in New Issue
Block a user