plugin updates

This commit is contained in:
Tony Volpe
2024-06-17 14:48:11 -04:00
parent ecc5fbf831
commit 3751a5a1a6
1318 changed files with 91130 additions and 52250 deletions

View File

@@ -17,7 +17,6 @@ if ( ! class_exists( 'acf_field__accordion' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -47,7 +46,6 @@ if ( ! class_exists( 'acf_field__accordion' ) ) :
* @param array $field
* @return n/a
*/
function render_field( $field ) {
// vars
@@ -122,7 +120,6 @@ if ( ! class_exists( 'acf_field__accordion' ) ) :
*
* @return $field - the field array holding all the field options
*/
function load_field( $field ) {
// remove name to avoid caching issue

View File

@@ -16,7 +16,6 @@ if ( ! class_exists( 'acf_field_button_group' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -224,7 +223,6 @@ if ( ! class_exists( 'acf_field_button_group' ) ) :
* @param array $field The field array holding all the field options
* @return $field
*/
function update_field( $field ) {
return acf_get_field_type( 'radio' )->update_field( $field );
@@ -242,7 +240,6 @@ if ( ! class_exists( 'acf_field_button_group' ) ) :
* @param array $field The field array holding all the field options
* @return $value
*/
function load_value( $value, $post_id, $field ) {
return acf_get_field_type( 'radio' )->load_value( $value, $post_id, $field );
@@ -258,7 +255,6 @@ if ( ! class_exists( 'acf_field_button_group' ) ) :
* @param array $field The field array holding all the field options
* @return $field
*/
function translate_field( $field ) {
return acf_get_field_type( 'radio' )->translate_field( $field );
@@ -276,7 +272,6 @@ if ( ! class_exists( 'acf_field_button_group' ) ) :
* @param array $field The field array holding all the field options
* @return $value
*/
function format_value( $value, $post_id, $field ) {
return acf_get_field_type( 'radio' )->format_value( $value, $post_id, $field );

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_checkbox' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -50,7 +49,6 @@ if ( ! class_exists( 'acf_field_checkbox' ) ) :
* @param $field (array) the $field being edited
* @return n/a
*/
function render_field( $field ) {
// reset vars
@@ -109,7 +107,6 @@ if ( ! class_exists( 'acf_field_checkbox' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function render_field_choices( $field ) {
// walk
@@ -151,7 +148,6 @@ if ( ! class_exists( 'acf_field_checkbox' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function render_field_toggle( $field ) {
// vars
@@ -186,7 +182,6 @@ if ( ! class_exists( 'acf_field_checkbox' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function render_field_custom( $field ) {
// vars
@@ -443,7 +438,6 @@ if ( ! class_exists( 'acf_field_checkbox' ) ) :
*
* @return $field - the modified field
*/
function update_field( $field ) {
// Decode choices (convert to array).
@@ -466,7 +460,6 @@ if ( ! class_exists( 'acf_field_checkbox' ) ) :
*
* @return $value - the modified value
*/
function update_value( $value, $post_id, $field ) {
// bail early if is empty
@@ -530,7 +523,6 @@ if ( ! class_exists( 'acf_field_checkbox' ) ) :
* @param $field (array)
* @return $field
*/
function translate_field( $field ) {
return acf_get_field_type( 'select' )->translate_field( $field );
@@ -550,7 +542,6 @@ if ( ! class_exists( 'acf_field_checkbox' ) ) :
*
* @return $value (mixed) the modified value
*/
function format_value( $value, $post_id, $field ) {
// Bail early if is empty.

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_color_picker' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -43,7 +42,6 @@ if ( ! class_exists( 'acf_field_color_picker' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function input_admin_enqueue_scripts() {
// Register scripts for non-admin.
@@ -107,7 +105,6 @@ if ( ! class_exists( 'acf_field_color_picker' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
$text_input = acf_get_sub_array( $field, array( 'id', 'class', 'name', 'value' ) );
$hidden_input = acf_get_sub_array( $field, array( 'name', 'value' ) );
@@ -138,7 +135,6 @@ if ( ! class_exists( 'acf_field_color_picker' ) ) :
*
* @param $field - an array holding all the field's data
*/
function render_field_settings( $field ) {
// display_format

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_date_picker' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -43,7 +42,6 @@ if ( ! class_exists( 'acf_field_date_picker' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function input_admin_enqueue_scripts() {
// bail early if no enqueue
@@ -87,7 +85,6 @@ if ( ! class_exists( 'acf_field_date_picker' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// vars
@@ -243,7 +240,6 @@ if ( ! class_exists( 'acf_field_date_picker' ) ) :
*
* @return $value (mixed) the modified value
*/
function format_value( $value, $post_id, $field ) {
// save_format - compatibility with ACF < 5.0.0

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_date_and_time_picker' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -43,7 +42,6 @@ if ( ! class_exists( 'acf_field_date_and_time_picker' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function input_admin_enqueue_scripts() {
// bail early if no enqueue
@@ -98,7 +96,6 @@ if ( ! class_exists( 'acf_field_date_and_time_picker' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// Set value.

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_email' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -42,7 +41,6 @@ if ( ! class_exists( 'acf_field_email' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// vars

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_file' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -48,7 +47,6 @@ if ( ! class_exists( 'acf_field_file' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function input_admin_enqueue_scripts() {
// localize
@@ -71,7 +69,6 @@ if ( ! class_exists( 'acf_field_file' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// vars
@@ -297,7 +294,6 @@ if ( ! class_exists( 'acf_field_file' ) ) :
*
* @return $value (mixed) the modified value
*/
function format_value( $value, $post_id, $field ) {
// bail early if no value
@@ -335,7 +331,6 @@ if ( ! class_exists( 'acf_field_file' ) ) :
* @param $vars (array)
* @return $vars
*/
function get_media_item_args( $vars ) {
$vars['send'] = true;
@@ -356,7 +351,6 @@ if ( ! class_exists( 'acf_field_file' ) ) :
*
* @return $value - the modified value
*/
function update_value( $value, $post_id, $field ) {
// Bail early if no value.

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_google_map' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -50,7 +49,6 @@ if ( ! class_exists( 'acf_field_google_map' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function input_admin_enqueue_scripts() {
// localize
@@ -107,7 +105,6 @@ if ( ! class_exists( 'acf_field_google_map' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// Apply defaults.
@@ -176,7 +173,6 @@ if ( ! class_exists( 'acf_field_google_map' ) ) :
*
* @param $field - an array holding all the field's data
*/
function render_field_settings( $field ) {
// center_lat

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field__group' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -48,7 +47,6 @@ if ( ! class_exists( 'acf_field__group' ) ) :
*
* @return $field - the field array holding all the field options
*/
function load_field( $field ) {
// vars
@@ -76,7 +74,6 @@ if ( ! class_exists( 'acf_field__group' ) ) :
* @param $field (array) the field array holding all the field options
* @return $value
*/
function load_value( $value, $post_id, $field ) {
// bail early if no sub fields
@@ -154,7 +151,6 @@ if ( ! class_exists( 'acf_field__group' ) ) :
*
* @return $value - the modified value
*/
function update_value( $value, $post_id, $field ) {
// bail early if no value
@@ -210,7 +206,6 @@ if ( ! class_exists( 'acf_field__group' ) ) :
* @param $field (array)
* @return $field
*/
function prepare_field_for_db( $field ) {
// bail early if no sub fields
@@ -239,7 +234,6 @@ if ( ! class_exists( 'acf_field__group' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// bail early if no sub fields
@@ -289,7 +283,6 @@ if ( ! class_exists( 'acf_field__group' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function render_field_block( $field ) {
// vars
@@ -316,7 +309,6 @@ if ( ! class_exists( 'acf_field__group' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function render_field_table( $field ) {
?>
@@ -381,7 +373,6 @@ if ( ! class_exists( 'acf_field__group' ) ) :
*
* @param $field - an array holding all the field's data
*/
function render_field_settings( $field ) {
// vars
@@ -435,7 +426,6 @@ if ( ! class_exists( 'acf_field__group' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function validate_value( $valid, $value, $field, $input ) {
// bail early if no $value
@@ -484,7 +474,6 @@ if ( ! class_exists( 'acf_field__group' ) ) :
*
* @return $field - the modified field
*/
function duplicate_field( $field ) {
// get sub fields
@@ -561,7 +550,6 @@ if ( ! class_exists( 'acf_field__group' ) ) :
* @param array $field The field settings
* @return void
*/
function delete_value( $post_id, $meta_key, $field ) {
// bail early if no sub fields

View File

@@ -0,0 +1,686 @@
<?php
/**
* This is a PHP file containing the code for the acf_field_icon_picker class.
*
* @package Advanced_Custom_Fields_Pro
*/
if ( ! class_exists( 'acf_field_icon_picker' ) ) :
/**
* Class acf_field_icon_picker.
*/
class acf_field_icon_picker extends acf_field {
/**
* Initialize icon picker field
*
* @since 6.3
*
* @return void
*/
public function initialize() {
$this->name = 'icon_picker';
$this->label = __( 'Icon Picker', 'acf' );
$this->public = true;
$this->category = 'advanced';
$this->description = __( 'An interactive UI for selecting an icon. Select from Dashicons, the media library, or a standalone URL input.', 'acf' );
$this->preview_image = acf_get_url() . '/assets/images/field-type-previews/field-preview-icon-picker.png';
$this->doc_url = acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/resources/icon-picker/', 'docs', 'field-type-selection' );
$this->defaults = array(
'library' => 'all',
'tabs' => array_keys( $this->get_tabs() ),
'return_format' => 'string',
'default_value' => array(
'type' => null,
'value' => null,
),
);
}
/**
* Gets the available tabs for the icon picker field.
*
* @since 6.3
*
* @return array
*/
public function get_tabs() {
$tabs = array(
'dashicons' => esc_html__( 'Dashicons', 'acf' ),
);
if ( current_user_can( 'upload_files' ) ) {
$tabs['media_library'] = esc_html__( 'Media Library', 'acf' );
}
$tabs['url'] = esc_html__( 'URL', 'acf' );
/**
* Allows filtering the tabs used by the icon picker.
*
* @since 6.3
*
* @param array $tabs An associative array of tabs in key => label format.
* @return array
*/
return apply_filters( 'acf/fields/icon_picker/tabs', $tabs );
}
/**
* Renders icon picker field
*
* @since 6.3
*
* @param object $field The ACF Field
* @return void
*/
public function render_field( $field ) {
$uploader = acf_get_setting( 'uploader' );
// Enqueue uploader scripts
if ( $uploader === 'wp' ) {
acf_enqueue_uploader();
}
$div = array(
'id' => $field['id'],
'class' => $field['class'] . ' acf-icon-picker',
);
echo '<div ' . acf_esc_attrs( $div ) . '>';
acf_hidden_input(
array(
'name' => $field['name'] . '[type]',
'value' => $field['value']['type'],
'data-hidden-type' => 'type',
)
);
acf_hidden_input(
array(
'name' => $field['name'] . '[value]',
'value' => $field['value']['value'],
'data-hidden-type' => 'value',
)
);
if ( ! is_array( $field['tabs'] ) ) {
$field['tabs'] = array();
}
$tabs = $this->get_tabs();
$shown = array_filter(
$tabs,
function ( $tab ) use ( $field ) {
return in_array( $tab, $field['tabs'], true );
},
ARRAY_FILTER_USE_KEY
);
foreach ( $shown as $name => $label ) {
if ( count( $shown ) > 1 ) {
acf_render_field_wrap(
array(
'type' => 'tab',
'label' => $label,
'key' => 'acf_icon_picker_tabs',
'selected' => $name === $field['value']['type'],
'unique_tab_key' => $name,
)
);
}
$wrapper_class = str_replace( '_', '-', $name );
echo '<div class="acf-icon-picker-tabs acf-icon-picker-' . esc_attr( $wrapper_class ) . '-tabs">';
switch ( $name ) {
case 'dashicons':
echo '<div class="acf-dashicons-search-wrap">';
acf_text_input(
array(
'class' => 'acf-dashicons-search-input',
'placeholder' => esc_html__( 'Search icons...', 'acf' ),
'type' => 'search',
)
);
echo '</div>';
echo '<div class="acf-dashicons-list"></div>';
?>
<div class="acf-dashicons-list-empty">
<img src="<?php echo esc_url( acf_get_url( 'assets/images/face-sad.svg' ) ); ?>" />
<p class="acf-no-results-text">
<?php
printf(
/* translators: %s: The invalid search term */
esc_html__( "No search results for '%s'", 'acf' ),
'<span class="acf-invalid-dashicon-search-term"></span>'
);
?>
</p>
</div>
<?php
break;
case 'media_library':
?>
<div class="acf-icon-picker-tab" data-category="<?php echo esc_attr( $name ); ?>">
<div class="acf-icon-picker-media-library">
<button
aria-label="<?php esc_attr_e( 'Click to change the icon in the Media Library', 'acf' ); ?>"
class="acf-icon-picker-media-library-preview"
style="<?php echo esc_attr( 'media_library' === $field['value']['type'] || 'dashicons' === $field['value']['type'] && ! empty( $field['value']['value'] ) ? '' : 'display: none;' ); ?>"
>
<div class="acf-icon-picker-media-library-preview-img" style="<?php echo esc_attr( 'media_library' !== $field['value']['type'] ? 'display: none;' : '' ); ?>">
<?php
$img_url = wp_get_attachment_image_url( $field['value']['value'], 'thumbnail' );
// If the type is media_library, then we need to show the media library preview.
?>
<img src="<?php echo esc_url( $img_url ); ?>" alt="<?php esc_attr_e( 'The currently selected image preview', 'acf' ); ?>" />
</div>
<div class="acf-icon-picker-media-library-preview-dashicon" style="<?php echo esc_attr( 'dashicons' !== $field['value']['type'] ? 'display: none;' : '' ); ?>">
<div class="dashicons <?php echo esc_attr( $field['value']['value'] ); ?>">
</div>
</div>
</button>
<button class="acf-icon-picker-media-library-button">
<div class="acf-icon-picker-media-library-button-icon dashicons dashicons-admin-media"></div>
<span><?php esc_html_e( 'Browse Media Library', 'acf' ); ?></span>
</button>
</div>
</div>
<?php
break;
case 'url':
echo '<div class="acf-icon-picker-url">';
acf_text_input(
array(
'class' => 'acf-icon_url',
'value' => $field['value']['type'] === 'url' ? $field['value']['value'] : '',
)
);
// Helper Text
?>
<p class="description"><?php esc_html_e( 'The URL to the icon you\'d like to use, or svg as Data URI', 'acf' ); ?></p>
<?php
echo '</div>';
break;
default:
do_action( 'acf/fields/icon_picker/tab/' . $name, $field );
}
echo '</div>';
}
echo '</div>';
}
/**
* Renders field settings for the icon picker field.
*
* @since 6.3
*
* @param array $field The icon picker field object.
* @return void
*/
public function render_field_settings( $field ) {
acf_render_field_setting(
$field,
array(
'label' => __( 'Tabs', 'acf' ),
'instructions' => __( 'Select where content editors can choose the icon from.', 'acf' ),
'type' => 'checkbox',
'name' => 'tabs',
'choices' => $this->get_tabs(),
)
);
$return_format_doc = sprintf(
'<a href="%s" target="_blank">%s</a>',
acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/resources/icon-picker/', 'docs', 'icon-picker-return-format' ),
__( 'Learn More', 'acf' )
);
$return_format_instructions = sprintf(
/* translators: %s - link to documentation */
__( 'Specify the return format for the icon. %s', 'acf' ),
$return_format_doc
);
acf_render_field_setting(
$field,
array(
'label' => __( 'Return Format', 'acf' ),
'instructions' => $return_format_instructions,
'type' => 'radio',
'name' => 'return_format',
'choices' => array(
'string' => __( 'String', 'acf' ),
'array' => __( 'Array', 'acf' ),
),
'layout' => 'horizontal',
)
);
}
/**
* Localizes text for Icon Picker
*
* @since 6.3
*
* @return void
*/
public function input_admin_enqueue_scripts() {
acf_localize_data(
array(
'iconPickerA11yStrings' => array(
'noResultsForSearchTerm' => esc_html__( 'No results found for that search term', 'acf' ),
'newResultsFoundForSearchTerm' => esc_html__( 'The available icons matching your search query have been updated in the icon picker below.', 'acf' ),
),
'iconPickeri10n' => $this->get_dashicons(),
)
);
}
/**
* Validates the field value before it is saved into the database.
*
* @since 6.3
*
* @param integer $valid The current validation status.
* @param mixed $value The value of the field.
* @param array $field The field array holding all the field options.
* @param string $input The corresponding input name for $_POST value.
* @return boolean true If the value is valid, false if not.
*/
public function validate_value( $valid, $value, $field, $input ) {
// If the value is empty, return true. You're allowed to save nothing.
if ( empty( $value ) && empty( $field['required'] ) ) {
return true;
}
// If the value is not an array, return $valid status.
if ( ! is_array( $value ) ) {
return $valid;
}
// If the value is an array, but the type is not set, fail validation.
if ( ! isset( $value['type'] ) ) {
return __( 'Icon picker requires an icon type.', 'acf' );
}
// If the value is an array, but the value is not set, fail validation.
if ( ! isset( $value['value'] ) ) {
return __( 'Icon picker requires a value.', 'acf' );
}
return true;
}
/**
* format_value()
*
* This filter is appied to the $value after it is loaded from the db and before it is returned to the template
*
* @since 6.3
*
* @param mixed $value The value which was loaded from the database.
* @param integer $post_id The $post_id from which the value was loaded.
* @param array $field The field array holding all the field options.
* @return mixed $value The modified value.
*/
public function format_value( $value, $post_id, $field ) {
// Handle empty values.
if ( empty( $value ) ) {
// Return the default value if there is one.
if ( isset( $field['default_value'] ) ) {
return $field['default_value'];
} else {
// Otherwise return false.
return false;
}
}
// If media_library, behave the same as an image field.
if ( $value['type'] === 'media_library' ) {
// convert to int
$value['value'] = intval( $value['value'] );
// format
if ( $field['return_format'] === 'string' ) {
return wp_get_attachment_url( $value['value'] );
} elseif ( $field['return_format'] === 'array' ) {
$value['value'] = acf_get_attachment( $value['value'] );
return $value;
}
}
// If the desired return format is a string
if ( $field['return_format'] === 'string' ) {
return $value['value'];
}
// If nothing specific matched the return format, just return the value.
return $value;
}
/**
* get_dashicons()
*
* This function will return an array of dashicons.
*
* @since 6.3
*
* @return array $dashicons an array of dashicons.
*/
public function get_dashicons() {
$dashicons = array(
'dashicons-admin-generic' => esc_html__( 'Generic icon', 'acf' ),
'dashicons-admin-appearance' => esc_html__( 'Appearance icon', 'acf' ),
'dashicons-admin-collapse' => esc_html__( 'Collapse icon', 'acf' ),
'dashicons-admin-comments' => esc_html__( 'Comments icon', 'acf' ),
'dashicons-admin-customizer' => esc_html__( 'Customizer icon', 'acf' ),
'dashicons-admin-home' => esc_html__( 'Home icon', 'acf' ),
'dashicons-admin-links' => esc_html__( 'Links icon', 'acf' ),
'dashicons-admin-media' => esc_html__( 'Media icon', 'acf' ),
'dashicons-admin-multisite' => esc_html__( 'Multisite icon', 'acf' ),
'dashicons-admin-network' => esc_html__( 'Network icon', 'acf' ),
'dashicons-admin-page' => esc_html__( 'Page icon', 'acf' ),
'dashicons-admin-plugins' => esc_html__( 'Plugins icon', 'acf' ),
'dashicons-admin-post' => esc_html__( 'Post icon', 'acf' ),
'dashicons-admin-settings' => esc_html__( 'Settings icon', 'acf' ),
'dashicons-admin-site' => esc_html__( 'Site icon', 'acf' ),
'dashicons-admin-tools' => esc_html__( 'Tools icon', 'acf' ),
'dashicons-admin-users' => esc_html__( 'Users icon', 'acf' ),
'dashicons-album' => esc_html__( 'Album icon', 'acf' ),
'dashicons-align-center' => esc_html__( 'Align-center icon', 'acf' ),
'dashicons-align-left' => esc_html__( 'Align-left icon', 'acf' ),
'dashicons-align-none' => esc_html__( 'Align-none icon', 'acf' ),
'dashicons-align-right' => esc_html__( 'Align-right icon', 'acf' ),
'dashicons-analytics' => esc_html__( 'Analytics icon', 'acf' ),
'dashicons-archive' => esc_html__( 'Archive icon', 'acf' ),
'dashicons-arrow-down' => esc_html__( 'Arrow down icon', 'acf' ),
'dashicons-arrow-down-alt' => esc_html__( 'Arrow down-alt icon', 'acf' ),
'dashicons-arrow-down-alt2' => esc_html__( 'Arrow down-alt2 icon', 'acf' ),
'dashicons-arrow-left' => esc_html__( 'Arrow left icon', 'acf' ),
'dashicons-arrow-left-alt' => esc_html__( 'Arrow left-alt icon', 'acf' ),
'dashicons-arrow-left-alt2' => esc_html__( 'Arrow left-alt2 icon', 'acf' ),
'dashicons-arrow-right' => esc_html__( 'Arrow right icon', 'acf' ),
'dashicons-arrow-right-alt' => esc_html__( 'Arrow right-alt icon', 'acf' ),
'dashicons-arrow-right-alt2' => esc_html__( 'Arrow right-alt2 icon', 'acf' ),
'dashicons-arrow-up' => esc_html__( 'Arrow up icon', 'acf' ),
'dashicons-arrow-up-alt' => esc_html__( 'Arrow up-alt icon', 'acf' ),
'dashicons-arrow-up-alt2' => esc_html__( 'Arrow up-alt2 icon', 'acf' ),
'dashicons-art' => esc_html__( 'Art icon', 'acf' ),
'dashicons-awards' => esc_html__( 'Awards icon', 'acf' ),
'dashicons-backup' => esc_html__( 'Backup icon', 'acf' ),
'dashicons-book' => esc_html__( 'Book icon', 'acf' ),
'dashicons-book-alt' => esc_html__( 'Book alt icon', 'acf' ),
'dashicons-building' => esc_html__( 'Building icon', 'acf' ),
'dashicons-businessman' => esc_html__( 'Businessman icon', 'acf' ),
'dashicons-calendar' => esc_html__( 'Calendar icon', 'acf' ),
'dashicons-calendar-alt' => esc_html__( 'Calendar alt icon', 'acf' ),
'dashicons-camera' => esc_html__( 'Camera icon', 'acf' ),
'dashicons-carrot' => esc_html__( 'Carrot icon', 'acf' ),
'dashicons-cart' => esc_html__( 'Cart icon', 'acf' ),
'dashicons-category' => esc_html__( 'Category icon', 'acf' ),
'dashicons-chart-area' => esc_html__( 'Chart area icon', 'acf' ),
'dashicons-chart-bar' => esc_html__( 'Chart bar icon', 'acf' ),
'dashicons-chart-line' => esc_html__( 'Chart line icon', 'acf' ),
'dashicons-chart-pie' => esc_html__( 'Chart pie icon', 'acf' ),
'dashicons-clipboard' => esc_html__( 'Clipboard icon', 'acf' ),
'dashicons-clock' => esc_html__( 'Clock icon', 'acf' ),
'dashicons-cloud' => esc_html__( 'Cloud icon', 'acf' ),
'dashicons-controls-back' => esc_html__( 'Controls back icon', 'acf' ),
'dashicons-controls-forward' => esc_html__( 'Controls forward icon', 'acf' ),
'dashicons-controls-pause' => esc_html__( 'Controls pause icon', 'acf' ),
'dashicons-controls-play' => esc_html__( 'Controls play icon', 'acf' ),
'dashicons-controls-repeat' => esc_html__( 'Controls repeat icon', 'acf' ),
'dashicons-controls-skipback' => esc_html__( 'Controls skipback icon', 'acf' ),
'dashicons-controls-skipforward' => esc_html__( 'Controls skipforward icon', 'acf' ),
'dashicons-controls-volumeoff' => esc_html__( 'Controls volumeoff icon', 'acf' ),
'dashicons-controls-volumeon' => esc_html__( 'Controls volumeon icon', 'acf' ),
'dashicons-dashboard' => esc_html__( 'Dashboard icon', 'acf' ),
'dashicons-desktop' => esc_html__( 'Desktop icon', 'acf' ),
'dashicons-dismiss' => esc_html__( 'Dismiss icon', 'acf' ),
'dashicons-download' => esc_html__( 'Download icon', 'acf' ),
'dashicons-edit' => esc_html__( 'Edit icon', 'acf' ),
'dashicons-editor-aligncenter' => esc_html__( 'aligncenter icon', 'acf' ),
'dashicons-editor-alignleft' => esc_html__( 'alignleft icon', 'acf' ),
'dashicons-editor-alignright' => esc_html__( 'alignright icon', 'acf' ),
'dashicons-editor-bold' => esc_html__( 'Bold icon', 'acf' ),
'dashicons-editor-break' => esc_html__( 'Break icon', 'acf' ),
'dashicons-editor-code' => esc_html__( 'Code icon', 'acf' ),
'dashicons-editor-contract' => esc_html__( 'Contract icon', 'acf' ),
'dashicons-editor-customchar' => esc_html__( 'Customchar icon', 'acf' ),
'dashicons-editor-expand' => esc_html__( 'Expand icon', 'acf' ),
'dashicons-editor-help' => esc_html__( 'Help icon', 'acf' ),
'dashicons-editor-indent' => esc_html__( 'Indent icon', 'acf' ),
'dashicons-editor-insertmore' => esc_html__( 'Insertmore icon', 'acf' ),
'dashicons-editor-italic' => esc_html__( 'Italic icon', 'acf' ),
'dashicons-editor-justify' => esc_html__( 'Justify icon', 'acf' ),
'dashicons-editor-kitchensink' => esc_html__( 'Kitchensink icon', 'acf' ),
'dashicons-editor-ol' => esc_html__( 'Ol icon', 'acf' ),
'dashicons-editor-outdent' => esc_html__( 'Outdent icon', 'acf' ),
'dashicons-editor-paragraph' => esc_html__( 'Paragraph icon', 'acf' ),
'dashicons-editor-paste-text' => esc_html__( 'Paste text icon', 'acf' ),
'dashicons-editor-paste-word' => esc_html__( 'Paste word icon', 'acf' ),
'dashicons-editor-quote' => esc_html__( 'Quote icon', 'acf' ),
'dashicons-editor-removeformatting' => esc_html__( 'Removeformatting icon', 'acf' ),
'dashicons-editor-rtl' => esc_html__( 'Rtl icon', 'acf' ),
'dashicons-editor-spellcheck' => esc_html__( 'Spellcheck icon', 'acf' ),
'dashicons-editor-strikethrough' => esc_html__( 'Strikethrough icon', 'acf' ),
'dashicons-editor-table' => esc_html__( 'Table icon', 'acf' ),
'dashicons-editor-textcolor' => esc_html__( 'Textcolor icon', 'acf' ),
'dashicons-editor-ul' => esc_html__( 'Ul icon', 'acf' ),
'dashicons-editor-underline' => esc_html__( 'Underline icon', 'acf' ),
'dashicons-editor-unlink' => esc_html__( 'Unlink icon', 'acf' ),
'dashicons-editor-video' => esc_html__( 'Video icon', 'acf' ),
'dashicons-email' => esc_html__( 'Email icon', 'acf' ),
'dashicons-email-alt' => esc_html__( 'Email alt icon', 'acf' ),
'dashicons-exerpt-view' => esc_html__( 'Exerpt-view icon', 'acf' ),
'dashicons-external' => esc_html__( 'External icon', 'acf' ),
'dashicons-facebook' => esc_html__( 'Facebook icon', 'acf' ),
'dashicons-facebook-alt' => esc_html__( 'Facebook alt icon', 'acf' ),
'dashicons-feedback' => esc_html__( 'Feedback icon', 'acf' ),
'dashicons-filter' => esc_html__( 'Filter icon', 'acf' ),
'dashicons-flag' => esc_html__( 'Flag icon', 'acf' ),
'dashicons-format-aside' => esc_html__( 'Format aside icon', 'acf' ),
'dashicons-format-audio' => esc_html__( 'Format audio icon', 'acf' ),
'dashicons-format-chat' => esc_html__( 'Format chat icon', 'acf' ),
'dashicons-format-gallery' => esc_html__( 'Format gallery icon', 'acf' ),
'dashicons-format-image' => esc_html__( 'Format image icon', 'acf' ),
'dashicons-format-quote' => esc_html__( 'Format quote icon', 'acf' ),
'dashicons-format-status' => esc_html__( 'Format status icon', 'acf' ),
'dashicons-format-video' => esc_html__( 'Format video icon', 'acf' ),
'dashicons-forms' => esc_html__( 'Forms icon', 'acf' ),
'dashicons-googleplus' => esc_html__( 'Googleplus icon', 'acf' ),
'dashicons-grid-view' => esc_html__( 'Grid-view icon', 'acf' ),
'dashicons-groups' => esc_html__( 'Groups icon', 'acf' ),
'dashicons-hammer' => esc_html__( 'Hammer icon', 'acf' ),
'dashicons-heart' => esc_html__( 'Heart icon', 'acf' ),
'dashicons-hidden' => esc_html__( 'Hidden icon', 'acf' ),
'dashicons-id' => esc_html__( 'Id icon', 'acf' ),
'dashicons-id-alt' => esc_html__( 'Id-alt icon', 'acf' ),
'dashicons-image-crop' => esc_html__( 'Image crop icon', 'acf' ),
'dashicons-image-filter' => esc_html__( 'Image filter icon', 'acf' ),
'dashicons-image-flip-horizontal' => esc_html__( 'Image flip-horizontal icon', 'acf' ),
'dashicons-image-flip-vertical' => esc_html__( 'Image flip-vertical icon', 'acf' ),
'dashicons-image-rotate' => esc_html__( 'Image rotate icon', 'acf' ),
'dashicons-image-rotate-left' => esc_html__( 'Image rotate-left icon', 'acf' ),
'dashicons-image-rotate-right' => esc_html__( 'Image rotate-right icon', 'acf' ),
'dashicons-images-alt' => esc_html__( 'Images-alt icon', 'acf' ),
'dashicons-images-alt2' => esc_html__( 'Images-alt2 icon', 'acf' ),
'dashicons-index-card' => esc_html__( 'Index-card icon', 'acf' ),
'dashicons-info' => esc_html__( 'Info icon', 'acf' ),
'dashicons-laptop' => esc_html__( 'Laptop icon', 'acf' ),
'dashicons-layout' => esc_html__( 'Layout icon', 'acf' ),
'dashicons-leftright' => esc_html__( 'Leftright icon', 'acf' ),
'dashicons-lightbulb' => esc_html__( 'Lightbulb icon', 'acf' ),
'dashicons-list-view' => esc_html__( 'List-view icon', 'acf' ),
'dashicons-location' => esc_html__( 'Location icon', 'acf' ),
'dashicons-location-alt' => esc_html__( 'Location-alt icon', 'acf' ),
'dashicons-lock' => esc_html__( 'Lock icon', 'acf' ),
'dashicons-marker' => esc_html__( 'Marker icon', 'acf' ),
'dashicons-media-archive' => esc_html__( 'Media archive icon', 'acf' ),
'dashicons-media-audio' => esc_html__( 'Media audio icon', 'acf' ),
'dashicons-media-code' => esc_html__( 'Media code icon', 'acf' ),
'dashicons-media-default' => esc_html__( 'Media default icon', 'acf' ),
'dashicons-media-document' => esc_html__( 'Media document icon', 'acf' ),
'dashicons-media-interactive' => esc_html__( 'Media interactive icon', 'acf' ),
'dashicons-media-spreadsheet' => esc_html__( 'Media spreadsheet icon', 'acf' ),
'dashicons-media-text' => esc_html__( 'Media text icon', 'acf' ),
'dashicons-media-video' => esc_html__( 'Media video icon', 'acf' ),
'dashicons-megaphone' => esc_html__( 'Megaphone icon', 'acf' ),
'dashicons-menu' => esc_html__( 'Menu icon', 'acf' ),
'dashicons-microphone' => esc_html__( 'Microphone icon', 'acf' ),
'dashicons-migrate' => esc_html__( 'Migrate icon', 'acf' ),
'dashicons-minus' => esc_html__( 'Minus icon', 'acf' ),
'dashicons-money' => esc_html__( 'Money icon', 'acf' ),
'dashicons-move' => esc_html__( 'Move icon', 'acf' ),
'dashicons-nametag' => esc_html__( 'Nametag icon', 'acf' ),
'dashicons-networking' => esc_html__( 'Networking icon', 'acf' ),
'dashicons-no' => esc_html__( 'No icon', 'acf' ),
'dashicons-no-alt' => esc_html__( 'No alternative icon', 'acf' ),
'dashicons-palmtree' => esc_html__( 'Palmtree icon', 'acf' ),
'dashicons-paperclip' => esc_html__( 'Paperclip icon', 'acf' ),
'dashicons-performance' => esc_html__( 'Performance icon', 'acf' ),
'dashicons-phone' => esc_html__( 'Phone icon', 'acf' ),
'dashicons-playlist-audio' => esc_html__( 'Playlist-audio icon', 'acf' ),
'dashicons-playlist-video' => esc_html__( 'Playlist-video icon', 'acf' ),
'dashicons-plus' => esc_html__( 'Plus icon', 'acf' ),
'dashicons-plus-alt' => esc_html__( 'Plus-alt icon', 'acf' ),
'dashicons-portfolio' => esc_html__( 'Portfolio icon', 'acf' ),
'dashicons-post-status' => esc_html__( 'Post-status icon', 'acf' ),
'dashicons-pressthis' => esc_html__( 'Pressthis icon', 'acf' ),
'dashicons-products' => esc_html__( 'Products icon', 'acf' ),
'dashicons-randomize' => esc_html__( 'Randomize icon', 'acf' ),
'dashicons-redo' => esc_html__( 'Redo icon', 'acf' ),
'dashicons-rss' => esc_html__( 'Rss icon', 'acf' ),
'dashicons-schedule' => esc_html__( 'Schedule icon', 'acf' ),
'dashicons-screenoptions' => esc_html__( 'Screenoptions icon', 'acf' ),
'dashicons-search' => esc_html__( 'Search icon', 'acf' ),
'dashicons-share' => esc_html__( 'Share icon', 'acf' ),
'dashicons-share-alt' => esc_html__( 'Share-alt icon', 'acf' ),
'dashicons-share-alt2' => esc_html__( 'Share-alt2 icon', 'acf' ),
'dashicons-shield' => esc_html__( 'Shield icon', 'acf' ),
'dashicons-shield-alt' => esc_html__( 'Shield-alt icon', 'acf' ),
'dashicons-slides' => esc_html__( 'Slides icon', 'acf' ),
'dashicons-smartphone' => esc_html__( 'Smartphone icon', 'acf' ),
'dashicons-smiley' => esc_html__( 'Smiley icon', 'acf' ),
'dashicons-sort' => esc_html__( 'Sort icon', 'acf' ),
'dashicons-sos' => esc_html__( 'Sos icon', 'acf' ),
'dashicons-star-empty' => esc_html__( 'Star-empty icon', 'acf' ),
'dashicons-star-filled' => esc_html__( 'Star-filled icon', 'acf' ),
'dashicons-star-half' => esc_html__( 'Star-half icon', 'acf' ),
'dashicons-sticky' => esc_html__( 'Sticky icon', 'acf' ),
'dashicons-store' => esc_html__( 'Store icon', 'acf' ),
'dashicons-tablet' => esc_html__( 'Tablet icon', 'acf' ),
'dashicons-tag' => esc_html__( 'Tag icon', 'acf' ),
'dashicons-tagcloud' => esc_html__( 'Tagcloud icon', 'acf' ),
'dashicons-testimonial' => esc_html__( 'Testimonial icon', 'acf' ),
'dashicons-text' => esc_html__( 'Text icon', 'acf' ),
'dashicons-thumbs-down' => esc_html__( 'Thumbs-down icon', 'acf' ),
'dashicons-thumbs-up' => esc_html__( 'Thumbs-up icon', 'acf' ),
'dashicons-tickets' => esc_html__( 'Tickets icon', 'acf' ),
'dashicons-tickets-alt' => esc_html__( 'Tickets alternative icon', 'acf' ),
'dashicons-translation' => esc_html__( 'Translation icon', 'acf' ),
'dashicons-trash' => esc_html__( 'Trash icon', 'acf' ),
'dashicons-twitter' => esc_html__( 'Twitter icon', 'acf' ),
'dashicons-undo' => esc_html__( 'Undo icon', 'acf' ),
'dashicons-universal-access' => esc_html__( 'Universal access icon', 'acf' ),
'dashicons-universal-access-alt' => esc_html__( 'Universal access alternative icon', 'acf' ),
'dashicons-unlock' => esc_html__( 'Unlock icon', 'acf' ),
'dashicons-update' => esc_html__( 'Update icon', 'acf' ),
'dashicons-upload' => esc_html__( 'Upload icon', 'acf' ),
'dashicons-vault' => esc_html__( 'Vault icon', 'acf' ),
'dashicons-video-alt' => esc_html__( 'Video-alt icon', 'acf' ),
'dashicons-video-alt2' => esc_html__( 'Video-alt2 icon', 'acf' ),
'dashicons-video-alt3' => esc_html__( 'Video-alt3 icon', 'acf' ),
'dashicons-visibility' => esc_html__( 'Visibility icon', 'acf' ),
'dashicons-warning' => esc_html__( 'Warning icon', 'acf' ),
'dashicons-welcome-add-page' => esc_html__( 'Welcome add-page icon', 'acf' ),
'dashicons-welcome-comments' => esc_html__( 'Welcome comments icon', 'acf' ),
'dashicons-welcome-learn-more' => esc_html__( 'Welcome learn-more icon', 'acf' ),
'dashicons-welcome-view-site' => esc_html__( 'Welcome view-site icon', 'acf' ),
'dashicons-welcome-widgets-menus' => esc_html__( 'Welcome widgets-menus icon', 'acf' ),
'dashicons-welcome-write-blog' => esc_html__( 'Welcome write-blog icon', 'acf' ),
'dashicons-wordpress' => esc_html__( 'Wordpress icon', 'acf' ),
'dashicons-wordpress-alt' => esc_html__( 'Wordpress-alt icon', 'acf' ),
'dashicons-yes' => esc_html__( 'Yes icon', 'acf' ),
);
return apply_filters( 'acf/fields/icon_picker/dashicons', $dashicons );
}
/**
* Returns the schema used by the REST API.
*
* @since 6.3
*
* @param array $field The main field array.
* @return array
*/
public function get_rest_schema( array $field ): array {
return array(
'type' => array( 'object', 'null' ),
'required' => ! empty( $field['required'] ),
'properties' => array(
'type' => array(
'description' => esc_html__( 'The type of icon to save.', 'acf' ),
'type' => array( 'string' ),
'required' => true,
'enum' => array_keys( $this->get_tabs() ),
),
'value' => array(
'description' => esc_html__( 'The value of icon to save.', 'acf' ),
'type' => array( 'string', 'int' ),
'required' => true,
),
),
);
}
/**
* Validates a value sent via the REST API.
*
* @since 6.3
*
* @param boolean $valid The current validity boolean.
* @param array|null $value The value of the field.
* @param array $field The main field array.
* @return boolean|WP_Error
*/
public function validate_rest_value( $valid, $value, $field ) {
if ( is_null( $value ) ) {
if ( ! empty( $field['required'] ) ) {
return new WP_Error(
'rest_property_required',
/* translators: %s - field name */
sprintf( __( '%s is a required property of acf.', 'acf' ), $field['name'] )
);
} else {
return $valid;
}
}
if ( ! empty( $value['type'] ) && 'media_library' === $value['type'] ) {
$param = sprintf( '%s[%s][value]', $field['prefix'], $field['name'] );
$data = array(
'param' => $param,
'value' => (int) $value['value'],
);
if ( ! is_int( $value['value'] ) || 'attachment' !== get_post_type( $value['value'] ) ) {
/* translators: %s - field/param name */
$error = sprintf( __( '%s requires a valid attachment ID when type is set to media_library.', 'acf' ), $param );
return new WP_Error( 'rest_invalid_param', $error, $data );
}
}
return $valid;
}
}
acf_register_field_type( 'acf_field_icon_picker' );
endif;

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_image' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -53,7 +52,6 @@ if ( ! class_exists( 'acf_field_image' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function input_admin_enqueue_scripts() {
// localize
@@ -172,7 +170,6 @@ if ( ! class_exists( 'acf_field_image' ) ) :
*
* @param $field - an array holding all the field's data
*/
function render_field_settings( $field ) {
acf_render_field_setting(
$field,
@@ -348,7 +345,6 @@ if ( ! class_exists( 'acf_field_image' ) ) :
*
* @return $value (mixed) the modified value
*/
function format_value( $value, $post_id, $field ) {
// bail early if no value
@@ -386,7 +382,6 @@ if ( ! class_exists( 'acf_field_image' ) ) :
* @param $vars (array)
* @return $vars
*/
function get_media_item_args( $vars ) {
$vars['send'] = true;
@@ -407,7 +402,6 @@ if ( ! class_exists( 'acf_field_image' ) ) :
*
* @return $value - the modified value
*/
function update_value( $value, $post_id, $field ) {
return acf_get_field_type( 'file' )->update_value( $value, $post_id, $field );

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_link' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -41,7 +40,6 @@ if ( ! class_exists( 'acf_field_link' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function get_link( $value = '' ) {
// vars
@@ -171,7 +169,6 @@ if ( ! class_exists( 'acf_field_link' ) ) :
*
* @return $value (mixed) the modified value
*/
function format_value( $value, $post_id, $field ) {
// bail early if no value
@@ -202,7 +199,6 @@ if ( ! class_exists( 'acf_field_link' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function validate_value( $valid, $value, $field, $input ) {
// bail early if not required
@@ -233,7 +229,6 @@ if ( ! class_exists( 'acf_field_link' ) ) :
*
* @return $value - the modified value
*/
function update_value( $value, $post_id, $field ) {
// Check if value is an empty array and convert to empty string.

View File

@@ -16,7 +16,6 @@ if ( ! class_exists( 'acf_field_message' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -43,7 +42,6 @@ if ( ! class_exists( 'acf_field_message' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// vars
@@ -127,7 +125,6 @@ if ( ! class_exists( 'acf_field_message' ) ) :
* @param $field (array)
* @return $field
*/
function translate_field( $field ) {
// translate

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_number' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -45,7 +44,6 @@ if ( ! class_exists( 'acf_field_number' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// vars
@@ -106,7 +104,6 @@ if ( ! class_exists( 'acf_field_number' ) ) :
*
* @param $field - an array holding all the field's data
*/
function render_field_settings( $field ) {
// default_value
@@ -211,7 +208,6 @@ if ( ! class_exists( 'acf_field_number' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function validate_value( $valid, $value, $field, $input ) {
// remove ','
@@ -262,7 +258,6 @@ if ( ! class_exists( 'acf_field_number' ) ) :
*
* @return $value - the modified value
*/
function update_value( $value, $post_id, $field ) {
// no formatting needed for empty value

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_oembed' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -51,7 +50,6 @@ if ( ! class_exists( 'acf_field_oembed' ) ) :
* @param $field (array)
* @return (int)
*/
function prepare_field( $field ) {
// defaults
@@ -107,7 +105,6 @@ if ( ! class_exists( 'acf_field_oembed' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function ajax_query() {
// validate
@@ -133,7 +130,6 @@ if ( ! class_exists( 'acf_field_oembed' ) ) :
* @param $options (array)
* @return (array)
*/
function get_ajax_query( $args = array() ) {
// defaults
@@ -176,7 +172,6 @@ if ( ! class_exists( 'acf_field_oembed' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// atts

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_output' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -40,7 +39,6 @@ if ( ! class_exists( 'acf_field_output' ) ) :
* @param $field (array) the $field being edited
* @return n/a
*/
function render_field( $field ) {
// bail early if no html

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_page_link' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -36,8 +35,29 @@ if ( ! class_exists( 'acf_field_page_link' ) ) :
// extra
add_action( 'wp_ajax_acf/fields/page_link/query', array( $this, 'ajax_query' ) );
add_action( 'wp_ajax_nopriv_acf/fields/page_link/query', array( $this, 'ajax_query' ) );
add_filter( 'acf/conditional_logic/choices', array( $this, 'render_field_page_link_conditional_choices' ), 10, 3 );
}
/**
* Filters choices in page link conditions.
*
* @since 6.3
*
* @param array $choices The selected choice.
* @param array $conditional_field The conditional field settings object.
* @param string $rule_value The rule value.
* @return array
*/
public function render_field_page_link_conditional_choices( $choices, $conditional_field, $rule_value ) {
if ( ! is_array( $conditional_field ) || $conditional_field['type'] !== 'page_link' ) {
return $choices;
}
if ( ! empty( $rule_value ) ) {
$post_title = get_the_title( $rule_value );
$choices = array( $rule_value => $post_title );
}
return $choices;
}
/**
* description
@@ -49,7 +69,6 @@ if ( ! class_exists( 'acf_field_page_link' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function ajax_query() {
// validate
@@ -65,6 +84,7 @@ if ( ! class_exists( 'acf_field_page_link' ) ) :
's' => '',
'field_key' => '',
'paged' => 1,
'include' => '',
)
);
@@ -128,6 +148,10 @@ if ( ! class_exists( 'acf_field_page_link' ) ) :
}
}
if ( ! empty( $options['include'] ) ) {
$args['include'] = $options['include'];
}
// filters
$args = apply_filters( 'acf/fields/page_link/query', $args, $field, $options['post_id'] );
$args = apply_filters( 'acf/fields/page_link/query/name=' . $field['name'], $args, $field, $options['post_id'] );
@@ -166,6 +190,11 @@ if ( ! class_exists( 'acf_field_page_link' ) ) :
}
}
// If there is an include set, we will unset search to avoid attempting to further filter by the search term.
if ( isset( $args['include'] ) ) {
unset( $args['s'] );
}
// get posts grouped by post type
$groups = acf_get_grouped_posts( $args );
@@ -223,7 +252,6 @@ if ( ! class_exists( 'acf_field_page_link' ) ) :
* @param $text (string)
* @return (array)
*/
function get_post_result( $id, $text ) {
// vars
@@ -258,7 +286,6 @@ if ( ! class_exists( 'acf_field_page_link' ) ) :
* @param $post_id (int) the post_id to which this value is saved to
* @return (string)
*/
function get_post_title( $post, $field, $post_id = 0, $is_search = 0 ) {
// get post_id
@@ -289,7 +316,6 @@ if ( ! class_exists( 'acf_field_page_link' ) ) :
* @param $value (array)
* @return $value
*/
function get_posts( $value, $field ) {
// force value to array
@@ -352,7 +378,6 @@ if ( ! class_exists( 'acf_field_page_link' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// Change Field into a select
@@ -505,7 +530,6 @@ if ( ! class_exists( 'acf_field_page_link' ) ) :
*
* @return $value (mixed) the modified value
*/
function format_value( $value, $post_id, $field ) {
// ACF4 null
@@ -559,7 +583,6 @@ if ( ! class_exists( 'acf_field_page_link' ) ) :
*
* @return $value - the modified value
*/
function update_value( $value, $post_id, $field ) {
// Bail early if no value.

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_password' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -41,7 +40,6 @@ if ( ! class_exists( 'acf_field_password' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
acf_get_field_type( 'text' )->render_field( $field );

View File

@@ -8,8 +8,6 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
/**
* This function will setup the field type data
*
* @type function
* @date 5/03/2014
* @since 5.0.0
*/
public function initialize() {
@@ -32,23 +30,36 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
// extra
add_action( 'wp_ajax_acf/fields/post_object/query', array( $this, 'ajax_query' ) );
add_action( 'wp_ajax_nopriv_acf/fields/post_object/query', array( $this, 'ajax_query' ) );
add_filter( 'acf/conditional_logic/choices', array( $this, 'render_field_post_object_conditional_choices' ), 10, 3 );
}
/**
* Filters choices in post object conditions.
*
* @since 6.3
*
* @param array $choices The selected choice.
* @param array $conditional_field The conditional field settings object.
* @param string $rule_value The rule value.
* @return array
*/
public function render_field_post_object_conditional_choices( $choices, $conditional_field, $rule_value ) {
if ( ! is_array( $conditional_field ) || $conditional_field['type'] !== 'post_object' ) {
return $choices;
}
if ( ! empty( $rule_value ) ) {
$post_title = get_the_title( $rule_value );
$choices = array( $rule_value => $post_title );
}
return $choices;
}
/**
* description
* AJAX query handler for post object fields.
*
* @type function
* @date 24/10/13
* @since 5.0.0
*
* @param $post_id (int)
* @return $post_id (int)
*/
function ajax_query() {
// validate
public function ajax_query() {
if ( ! acf_verify_ajax() ) {
die();
}
@@ -64,15 +75,12 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
/**
* This function will return an array of data formatted for use in a select2 AJAX response
*
* @type function
* @date 15/10/2014
* @since 5.0.9
*
* @param $options (array)
* @return (array)
* @param array $options The options being queried for the ajax request.
* @return array The AJAX response array.
*/
function get_ajax_query( $options = array() ) {
public function get_ajax_query( $options = array() ) {
// defaults
$options = acf_parse_args(
@@ -82,6 +90,7 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
's' => '',
'field_key' => '',
'paged' => 1,
'include' => '',
)
);
@@ -112,6 +121,10 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
$is_search = true;
}
if ( ! empty( $options['include'] ) ) {
$args['include'] = $options['include'];
}
// post_type
if ( ! empty( $field['post_type'] ) ) {
$args['post_type'] = acf_get_array( $field['post_type'] );
@@ -126,6 +139,11 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
$args['post_status'] = acf_get_array( $field['post_status'] );
}
// If there is an include set, we will unset search to avoid attempting to further filter by the search term.
if ( isset( $args['include'] ) ) {
unset( $args['s'] );
}
// taxonomy
if ( ! empty( $field['taxonomy'] ) ) {
@@ -172,7 +190,7 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
// convert post objects to post titles
foreach ( array_keys( $posts ) as $post_id ) {
$posts[ $post_id ] = $this->get_post_title( $posts[ $post_id ], $field, $options['post_id'], $is_search );
$posts[ $post_id ] = $this->get_post_title( $posts[ $post_id ], $field, $options['post_id'], $is_search, true );
}
// order posts by search
@@ -209,16 +227,13 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
/**
* This function will return an array containing id, text and maybe description data
*
* @type function
* @date 7/07/2016
* @since 5.4.0
*
* @param $id (mixed)
* @param $text (string)
* @return (array)
* @param mixed $id The ID of the post result.
* @param string $text The text for the response item.
* @return array The combined result array.
*/
function get_post_result( $id, $text ) {
public function get_post_result( $id, $text ) {
// vars
$result = array(
@@ -241,19 +256,18 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
/**
* This function returns the HTML for a result
* This function post object's filtered output post title
*
* @type function
* @date 1/11/2013
* @since 5.0.0
*
* @param $post (object)
* @param $field (array)
* @param $post_id (int) the post_id to which this value is saved to
* @return (string)
* @param WP_Post $post The WordPress post.
* @param array $field The field being output.
* @param integer $post_id The post_id to which this value is saved to.
* @param integer $is_search An int-as-boolean value for whether we're performing a search.
* @param boolean $unescape Should we return an unescaped post title.
* @return string A potentially user filtered post title for the post, which may contain unsafe HTML.
*/
function get_post_title( $post, $field, $post_id = 0, $is_search = 0 ) {
public function get_post_title( $post, $field, $post_id = 0, $is_search = 0, $unescape = false ) {
// get post_id
if ( ! $post_id ) {
@@ -263,27 +277,29 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
// vars
$title = acf_get_post_title( $post, $is_search );
// unescape for select2 output which handles the escaping.
if ( $unescape ) {
$title = html_entity_decode( $title );
}
// filters
$title = apply_filters( 'acf/fields/post_object/result', $title, $post, $field, $post_id );
$title = apply_filters( 'acf/fields/post_object/result/name=' . $field['_name'], $title, $post, $field, $post_id );
$title = apply_filters( 'acf/fields/post_object/result/key=' . $field['key'], $title, $post, $field, $post_id );
// return
// return untrusted output.
return $title;
}
/**
* Create the HTML interface for your field
* Create the HTML interface for the post object field.
*
* @param $field - an array holding all the field's data
* @since 3.6
*
* @type action
* @since 3.6
* @date 23/01/13
* @param array $field An array holding all the field's data.
*/
function render_field( $field ) {
public function render_field( $field ) {
// Change Field into a select
$field['type'] = 'select';
@@ -311,16 +327,14 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
/**
* Create extra options for your field. This is rendered when editing a field.
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
* Create extra options for post object field. This is rendered when editing.
* The value of $field['name'] can be used (like below) to save extra data to the $field.
*
* @type action
* @since 3.6
* @date 23/01/13
* @since 3.6
*
* @param $field - an array holding all the field's data
* @param array $field An array holding all the field's data.
*/
function render_field_settings( $field ) {
public function render_field_settings( $field ) {
acf_render_field_setting(
$field,
array(
@@ -401,7 +415,7 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
* @param array $field The field settings array.
* @return void
*/
function render_field_validation_settings( $field ) {
public function render_field_validation_settings( $field ) {
acf_render_field_setting(
$field,
array(
@@ -429,17 +443,14 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
/**
* This filter is applied to the $value after it is loaded from the db
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $value (mixed) the value found in the database
* @param $post_id (mixed) the post_id from which the value was loaded
* @param $field (array) the field array holding all the field options
* @return $value
* @param mixed $value The value found in the database
* @param mixed $post_id The post_id from which the value was loaded
* @param array $field The field array holding all the field options
* @return mixed $value
*/
function load_value( $value, $post_id, $field ) {
public function load_value( $value, $post_id, $field ) {
// ACF4 null
if ( $value === 'null' ) {
@@ -454,20 +465,14 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
/**
* This filter is appied to the $value after it is loaded from the db and before it is returned to the template
*
* @type filter
* @since 3.6
* @date 23/01/13
* @since 3.6
*
* @param $value (mixed) the value which was loaded from the database
* @param $post_id (mixed) the post_id from which the value was loaded
* @param $field (array) the field array holding all the field options
*
* @return $value (mixed) the modified value
* @param mixed $value The value found in the database
* @param mixed $post_id The post_id from which the value was loaded
* @param array $field The field array holding all the field options
* @return mixed $value
*/
function format_value( $value, $post_id, $field ) {
// numeric
public function format_value( $value, $post_id, $field ) {
$value = acf_get_numeric( $value );
// bail early if no value
@@ -529,15 +534,13 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
/**
* This function will return an array of posts for a given field value
*
* @type function
* @date 13/06/2014
* @since 5.0.0
* @since 5.0
*
* @param $value (array)
* @return $value
* @param mixed $value The value of the field.
* @param array $field The field array holding all the field options.
* @return array $value An array of post objects.
*/
function get_posts( $value, $field ) {
public function get_posts( $value, $field ) {
// numeric
$value = acf_get_numeric( $value );
@@ -562,6 +565,8 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
/**
* Validates post object fields updated via the REST API.
*
* @since 5.11
*
* @param boolean $valid The current validity booleean
* @param integer $value The value of the field
* @param array $field The field array
@@ -662,7 +667,9 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
/**
* Return the schema array for the REST API.
*
* @param array $field
* @since 5.11
*
* @param array $field The field array.
* @return array
*/
public function get_rest_schema( array $field ) {
@@ -686,10 +693,14 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
}
/**
* REST link attributes generator for this field.
*
* @since 5.11
* @see \acf_field::get_rest_links()
*
* @param mixed $value The raw (unformatted) field value.
* @param integer|string $post_id
* @param array $field
* @param integer|string $post_id The post ID being queried.
* @param array $field The field array.
* @return array
*/
public function get_rest_links( $value, $post_id, array $field ) {
@@ -722,9 +733,11 @@ if ( ! class_exists( 'acf_field_post_object' ) ) :
/**
* Apply basic formatting to prepare the value for default REST output.
*
* @param mixed $value
* @param string|integer $post_id
* @param array $field
* @since 5.11
*
* @param mixed $value The raw (unformatted) field value.
* @param integer|string $post_id The post ID being queried.
* @param array $field The field array.
* @return mixed
*/
public function format_value_for_rest( $value, $post_id, array $field ) {

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_radio' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -49,7 +48,6 @@ if ( ! class_exists( 'acf_field_radio' ) ) :
* @param $field (array) the $field being edited
* @return n/a
*/
function render_field( $field ) {
// vars
@@ -174,7 +172,6 @@ if ( ! class_exists( 'acf_field_radio' ) ) :
*
* @param $field - an array holding all the field's data
*/
function render_field_settings( $field ) {
// Encode choices (convert from array).
$field['choices'] = acf_encode_choices( $field['choices'] );
@@ -301,7 +298,6 @@ if ( ! class_exists( 'acf_field_radio' ) ) :
*
* @return $field - the modified field
*/
function update_field( $field ) {
// decode choices (convert to array)
@@ -326,7 +322,6 @@ if ( ! class_exists( 'acf_field_radio' ) ) :
*
* @return $value - the modified value
*/
function update_value( $value, $post_id, $field ) {
// bail early if no value (allow 0 to be saved)
@@ -382,7 +377,6 @@ if ( ! class_exists( 'acf_field_radio' ) ) :
*
* @return $value - the value to be saved in te database
*/
function load_value( $value, $post_id, $field ) {
// must be single value
@@ -405,7 +399,6 @@ if ( ! class_exists( 'acf_field_radio' ) ) :
* @param $field (array)
* @return $field
*/
function translate_field( $field ) {
return acf_get_field_type( 'select' )->translate_field( $field );
@@ -425,7 +418,6 @@ if ( ! class_exists( 'acf_field_radio' ) ) :
*
* @return $value (mixed) the modified value
*/
function format_value( $value, $post_id, $field ) {
return acf_get_field_type( 'select' )->format_value( $value, $post_id, $field );

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_range' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -44,7 +43,6 @@ if ( ! class_exists( 'acf_field_range' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// vars
@@ -148,7 +146,6 @@ if ( ! class_exists( 'acf_field_range' ) ) :
*
* @param $field - an array holding all the field's data
*/
function render_field_settings( $field ) {
acf_render_field_setting(
$field,

View File

@@ -29,12 +29,33 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
'return_format' => 'object',
'bidirectional_target' => array(),
);
add_filter( 'acf/conditional_logic/choices', array( $this, 'render_field_relation_conditional_choices' ), 10, 3 );
// extra
add_action( 'wp_ajax_acf/fields/relationship/query', array( $this, 'ajax_query' ) );
add_action( 'wp_ajax_nopriv_acf/fields/relationship/query', array( $this, 'ajax_query' ) );
}
/**
* Filters choices in relation conditions.
*
* @since 6.3
*
* @param array $choices The selected choice.
* @param array $conditional_field The conditional field settings object.
* @param string $rule_value The rule value.
* @return array
*/
public function render_field_relation_conditional_choices( $choices, $conditional_field, $rule_value ) {
if ( ! is_array( $conditional_field ) || $conditional_field['type'] !== 'relationship' ) {
return $choices;
}
if ( ! empty( $rule_value ) ) {
$post_title = get_the_title( $rule_value );
$choices = array( $rule_value => $post_title );
}
return $choices;
}
/**
* description
@@ -46,7 +67,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function input_admin_enqueue_scripts() {
// localize
@@ -71,7 +91,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function ajax_query() {
// validate
@@ -97,7 +116,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @param $options (array)
* @return (array)
*/
function get_ajax_query( $options = array() ) {
// defaults
@@ -109,6 +127,7 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
'field_key' => '',
'paged' => 1,
'post_type' => '',
'include' => '',
'taxonomy' => '',
)
);
@@ -130,8 +149,7 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
$args['paged'] = intval( $options['paged'] );
// search
if ( $options['s'] !== '' ) {
if ( $options['s'] !== '' && empty( $options['include'] ) ) {
// strip slashes (search may be integer)
$s = wp_unslash( strval( $options['s'] ) );
@@ -191,6 +209,11 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
}
}
if ( ! empty( $options['include'] ) ) {
// If we have an include, we need to return only the selected posts.
$args['post__in'] = array( $options['include'] );
}
// filters
$args = apply_filters( 'acf/fields/relationship/query', $args, $field, $options['post_id'] );
$args = apply_filters( 'acf/fields/relationship/query/name=' . $field['name'], $args, $field, $options['post_id'] );
@@ -262,7 +285,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @param $text (string)
* @return (array)
*/
function get_post_result( $id, $text ) {
// vars
@@ -288,7 +310,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @param $post_id (int) the post_id to which this value is saved to
* @return (string)
*/
function get_post_title( $post, $field, $post_id = 0, $is_search = 0 ) {
// get post_id
@@ -334,7 +355,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// vars
@@ -681,7 +701,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
*
* @return $value (mixed) the modified value
*/
function format_value( $value, $post_id, $field ) {
// bail early if no value
@@ -722,7 +741,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function validate_value( $valid, $value, $field, $input ) {
// default

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_select' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -52,7 +51,6 @@ if ( ! class_exists( 'acf_field_select' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function input_admin_enqueue_scripts() {
// bail early if no enqueue
@@ -125,7 +123,6 @@ if ( ! class_exists( 'acf_field_select' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function ajax_query() {
// validate
@@ -223,7 +220,6 @@ if ( ! class_exists( 'acf_field_select' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// convert
@@ -334,7 +330,6 @@ if ( ! class_exists( 'acf_field_select' ) ) :
*
* @param $field - an array holding all the field's data
*/
function render_field_settings( $field ) {
// encode choices (convert from array)
@@ -490,7 +485,6 @@ if ( ! class_exists( 'acf_field_select' ) ) :
*
* @return $field - the modified field
*/
function update_field( $field ) {
// decode choices (convert to array)
@@ -520,7 +514,6 @@ if ( ! class_exists( 'acf_field_select' ) ) :
*
* @return $value - the modified value
*/
function update_value( $value, $post_id, $field ) {
// Bail early if no value.
@@ -549,7 +542,6 @@ if ( ! class_exists( 'acf_field_select' ) ) :
* @param $field (array)
* @return $field
*/
function translate_field( $field ) {
// translate

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_separator' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -36,7 +35,6 @@ if ( ! class_exists( 'acf_field_separator' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
/* do nothing */
@@ -54,7 +52,6 @@ if ( ! class_exists( 'acf_field_separator' ) ) :
*
* @return $field - the field array holding all the field options
*/
function load_field( $field ) {
// remove name to avoid caching issue

View File

@@ -16,7 +16,6 @@ if ( ! class_exists( 'acf_field_tab' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -30,42 +29,45 @@ if ( ! class_exists( 'acf_field_tab' ) ) :
$this->defaults = array(
'placement' => 'top',
'endpoint' => 0, // added in 5.2.8
'selected' => 0, // added in 6.3
);
}
/**
* Create the HTML interface for your field
* Output the HTML required for a tab.
*
* @param $field - an array holding all the field's data
* @since 3.6
*
* @type action
* @since 3.6
* @date 23/01/13
* @param array $field An array of the field data.
*/
function render_field( $field ) {
// vars
public function render_field( $field ) {
$atts = array(
'href' => '',
'class' => 'acf-tab-button',
'data-placement' => $field['placement'],
'data-endpoint' => $field['endpoint'],
'data-key' => $field['key'],
'data-selected' => $field['selected'],
);
if ( isset( $field['unique_tab_key'] ) && ! empty( $field['unique_tab_key'] ) ) {
$atts['data-unique-tab-key'] = $field['unique_tab_key'];
}
if ( isset( $field['settings-type'] ) ) {
$atts['class'] .= ' acf-settings-type-' . acf_slugify( $field['settings-type'] );
$atts['data-settings-type'] = acf_slugify( $field['settings-type'] );
$atts['class'] .= ' acf-settings-type-' . acf_slugify( $field['settings-type'] );
}
if ( isset( $field['class'] ) && ! empty( $field['class'] ) ) {
$atts['class'] .= ' ' . $field['class'];
}
?>
<a <?php echo acf_esc_attrs( $atts ); ?>><?php echo acf_esc_html( $field['label'] ); ?></a>
<a <?php echo acf_esc_attrs( $atts ); ?>><?php echo acf_esc_html( $field['label'] ); ?></a>
<?php
}
/**
* Create extra options for your field. This is rendered when editing a field.
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
@@ -76,7 +78,6 @@ if ( ! class_exists( 'acf_field_tab' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field_settings( $field ) {
/*

View File

@@ -42,6 +42,7 @@ if ( ! class_exists( 'acf_field_taxonomy' ) ) :
add_action( 'wp_ajax_acf/fields/taxonomy/query', array( $this, 'ajax_query' ) );
add_action( 'wp_ajax_nopriv_acf/fields/taxonomy/query', array( $this, 'ajax_query' ) );
add_action( 'wp_ajax_acf/fields/taxonomy/add_term', array( $this, 'ajax_add_term' ) );
add_filter( 'acf/conditional_logic/choices', array( $this, 'render_field_taxonomy_conditional_choices' ), 10, 3 );
// actions
add_action( 'acf/save_post', array( $this, 'save_post' ), 15, 1 );
@@ -58,7 +59,6 @@ if ( ! class_exists( 'acf_field_taxonomy' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function ajax_query() {
// validate
@@ -84,32 +84,36 @@ if ( ! class_exists( 'acf_field_taxonomy' ) ) :
* @param $options (array)
* @return (array)
*/
function get_ajax_query( $options = array() ) {
// defaults
$options = acf_parse_args(
$options,
array(
'post_id' => 0,
's' => '',
'field_key' => '',
'paged' => 0,
'term_id' => '',
'include' => '',
'paged' => 1,
)
);
// load field
$field = acf_get_field( $options['field_key'] );
if ( ! $field ) {
return false;
}
// bail early if taxonomy does not exist
// if options include isset, then we are loading a specific term.
if ( ! empty( $options['include'] ) ) {
$options['term_id'] = $options['include'];
// paged should be 1.
$options['paged'] = 1;
}
// Bail early if taxonomy does not exist.
if ( ! taxonomy_exists( $field['taxonomy'] ) ) {
return false;
}
// vars
$results = array();
$is_hierarchical = is_taxonomy_hierarchical( $field['taxonomy'] );
$is_pagination = ( $options['paged'] > 0 );
@@ -117,14 +121,12 @@ if ( ! class_exists( 'acf_field_taxonomy' ) ) :
$limit = 20;
$offset = 20 * ( $options['paged'] - 1 );
// args
$args = array(
'taxonomy' => $field['taxonomy'],
'hide_empty' => false,
);
// pagination
// - don't bother for hierarchial terms, we will need to load all terms anyway
// Don't bother for hierarchial terms, we will need to load all terms anyway.
if ( $is_pagination && ! $is_hierarchical ) {
$args['number'] = $limit;
$args['offset'] = $offset;
@@ -136,83 +138,82 @@ if ( ! class_exists( 'acf_field_taxonomy' ) ) :
// strip slashes (search may be integer)
$s = wp_unslash( strval( $options['s'] ) );
// update vars
$args['search'] = $s;
$args['search'] = isset( $options['term_id'] ) && $options['term_id'] ? '' : $s;
$is_search = true;
}
// filters
$args = apply_filters( 'acf/fields/taxonomy/query', $args, $field, $options['post_id'] );
// get terms
if ( ! empty( $options['include'] ) ) {
// Limit search to a specific id if one is provided.
$args['include'] = $options['include'];
}
$terms = acf_get_terms( $args );
// sort into hierachial order!
// Sort hierachial.
if ( $is_hierarchical ) {
// update vars
$limit = acf_maybe_get( $args, 'number', $limit );
$offset = acf_maybe_get( $args, 'offset', $offset );
// get parent
$parent = acf_maybe_get( $args, 'parent', 0 );
$parent = acf_maybe_get( $args, 'child_of', $parent );
// this will fail if a search has taken place because parents wont exist
// This will fail if a search has taken place because parents wont exist.
if ( ! $is_search ) {
// order terms
$ordered_terms = _get_term_children( $parent, $terms, $field['taxonomy'] );
// check for empty array (possible if parent did not exist within original data)
// Check for empty array. Possible if parent did not exist within original data.
if ( ! empty( $ordered_terms ) ) {
$terms = $ordered_terms;
}
}
// fake pagination
if ( $is_pagination ) {
// Fake pagination.
if ( $is_pagination && ! $options['include'] ) {
$terms = array_slice( $terms, $offset, $limit );
}
}
// append to r
// Append to r.
foreach ( $terms as $term ) {
// add to json
// Add to json.
$results[] = array(
'id' => $term->term_id,
'text' => $this->get_term_title( $term, $field, $options['post_id'] ),
'text' => $this->get_term_title( $term, $field, $options['post_id'], true ),
);
}
// vars
$response = array(
'results' => $results,
'limit' => $limit,
);
// return
return $response;
}
/**
* Returns the Term's title displayed in the field UI.
*
* @date 1/11/2013
* @since 5.0.0
*
* @param WP_Term $term The term object.
* @param array $field The field settings.
* @param mixed $post_id The post_id being edited.
* @param WP_Term $term The term object.
* @param array $field The field settings.
* @param mixed $post_id The post_id being edited.
* @param boolean $unescape Should we return an unescaped post title.
* @return string
*/
function get_term_title( $term, $field, $post_id = 0 ) {
function get_term_title( $term, $field, $post_id = 0, $unescape = false ) {
$title = acf_get_term_title( $term );
// Default $post_id to current post being edited.
$post_id = $post_id ? $post_id : acf_get_form_data( 'post_id' );
// unescape for select2 output which handles the escaping.
if ( $unescape ) {
$title = html_entity_decode( $title );
}
/**
* Filters the term title.
*
@@ -238,7 +239,6 @@ if ( ! class_exists( 'acf_field_taxonomy' ) ) :
* @param $value (array)
* @return $value
*/
function get_terms( $value, $taxonomy = 'category' ) {
// load terms in 1 query to save multiple DB calls from following code
@@ -278,7 +278,6 @@ if ( ! class_exists( 'acf_field_taxonomy' ) ) :
*
* @return $value - the value to be saved in te database
*/
function load_value( $value, $post_id, $field ) {
// get valid terms
@@ -430,7 +429,6 @@ if ( ! class_exists( 'acf_field_taxonomy' ) ) :
*
* @return $value (mixed) the modified value
*/
function format_value( $value, $post_id, $field ) {
// bail early if no value
@@ -467,7 +465,6 @@ if ( ! class_exists( 'acf_field_taxonomy' ) ) :
*
* @param $field - an array holding all the field's data
*/
function render_field( $field ) {
// force value to array
@@ -481,7 +478,6 @@ if ( ! class_exists( 'acf_field_taxonomy' ) ) :
'data-taxonomy' => $field['taxonomy'],
'data-allow_null' => $field['allow_null'],
);
// get taxonomy
$taxonomy = get_taxonomy( $field['taxonomy'] );
@@ -528,7 +524,6 @@ if ( ! class_exists( 'acf_field_taxonomy' ) ) :
*
* @param $field - an array holding all the field's data
*/
function render_field_select( $field ) {
// Change Field into a select
@@ -734,16 +729,36 @@ if ( ! class_exists( 'acf_field_taxonomy' ) ) :
}
/**
* description
* Filters choices in taxonomy conditions.
*
* @type function
* @date 17/04/2015
* @since 5.2.3
* @since 6.3
*
* @param $post_id (int)
* @return $post_id (int)
* @param array $choices The selected choice.
* @param array $conditional_field The conditional field settings object.
* @param string $rule_value The rule value.
* @return mixed
*/
public function render_field_taxonomy_conditional_choices( $choices, $conditional_field, $rule_value ) {
if ( is_array( $conditional_field ) && $conditional_field['type'] === 'taxonomy' ) {
if ( ! empty( $rule_value ) ) {
$term = get_term( $rule_value );
$choices = array( $rule_value => $term->name );
}
}
return $choices;
}
/**
* ajax_add_term
*
* @since 5.2.3
*
* @type function
* @date 17/04/2015
*
* @return void
*/
function ajax_add_term() {
// verify nonce

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_text' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -43,7 +42,6 @@ if ( ! class_exists( 'acf_field_text' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
$html = '';

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_textarea' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -43,7 +42,6 @@ if ( ! class_exists( 'acf_field_textarea' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// vars
@@ -180,7 +178,6 @@ if ( ! class_exists( 'acf_field_textarea' ) ) :
*
* @return $value (mixed) the modified value
*/
function format_value( $value, $post_id, $field ) {
// bail early if no value or not for template

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_time_picker' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -41,7 +40,6 @@ if ( ! class_exists( 'acf_field_time_picker' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// Set value.

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_true_false' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -44,7 +43,6 @@ if ( ! class_exists( 'acf_field_true_false' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// vars
@@ -209,7 +207,6 @@ if ( ! class_exists( 'acf_field_true_false' ) ) :
*
* @return $value (mixed) the modified value
*/
function format_value( $value, $post_id, $field ) {
return empty( $value ) ? false : true;
@@ -226,7 +223,6 @@ if ( ! class_exists( 'acf_field_true_false' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function validate_value( $valid, $value, $field, $input ) {
// bail early if not required
@@ -254,7 +250,6 @@ if ( ! class_exists( 'acf_field_true_false' ) ) :
* @param $field (array)
* @return $field
*/
function translate_field( $field ) {
// translate

View File

@@ -29,12 +29,41 @@ if ( ! class_exists( 'ACF_Field_User' ) ) :
acf_add_filter_variations( 'acf/fields/user/query', array( 'name', 'key' ), 1 );
acf_add_filter_variations( 'acf/fields/user/result', array( 'name', 'key' ), 2 );
acf_add_filter_variations( 'acf/fields/user/search_columns', array( 'name', 'key' ), 3 );
add_filter( 'acf/conditional_logic/choices', array( $this, 'render_field_user_conditional_choices' ), 10, 3 );
// Add AJAX query.
add_action( 'wp_ajax_acf/fields/user/query', array( $this, 'ajax_query' ) );
add_action( 'wp_ajax_nopriv_acf/fields/user/query', array( $this, 'ajax_query' ) );
}
/**
* Filters choices in user conditions.
*
* @since 6.3
*
* @param array $choices The selected choice.
* @param array $conditional_field The conditional field settings object.
* @param string $rule_value The rule value.
* @return array
*/
public function render_field_user_conditional_choices( $choices, $conditional_field, $rule_value ) {
if ( ! is_array( $conditional_field ) || $conditional_field['type'] !== 'user' ) {
return $choices;
}
if ( ! empty( $rule_value ) ) {
$user = acf_get_users(
array(
'include' => array( $rule_value ),
)
);
$user_result = acf_get_user_result( $user[0] );
$choices = array( $user_result['id'] => $user_result['text'] );
}
return $choices;
}
/**
* Renders the field settings HTML.
*
@@ -165,7 +194,7 @@ if ( ! class_exists( 'ACF_Field_User' ) ) :
}
/**
* Returns the result text for a fiven WP_User object.
* Returns the result text for a given WP_User object.
*
* @date 1/11/2013
* @since 5.0.0
@@ -353,7 +382,6 @@ if ( ! class_exists( 'ACF_Field_User' ) ) :
add_filter( 'acf/ajax/query_users/args', array( $this, 'ajax_query_args' ), 10, 3 );
add_filter( 'acf/ajax/query_users/result', array( $this, 'ajax_query_result' ), 10, 3 );
add_filter( 'acf/ajax/query_users/search_columns', array( $this, 'ajax_query_search_columns' ), 10, 4 );
// Simulate AJAX request.
acf_get_instance( 'ACF_Ajax_Query_Users' )->request();
}

View File

@@ -15,7 +15,6 @@ if ( ! class_exists( 'acf_field_wysiwyg' ) ) :
* @param n/a
* @return n/a
*/
function initialize() {
// vars
@@ -54,7 +53,6 @@ if ( ! class_exists( 'acf_field_wysiwyg' ) ) :
* @param n/a
* @return n/a
*/
function add_filters() {
// WordPress 5.5 introduced new function for applying image tags.
@@ -89,7 +87,6 @@ if ( ! class_exists( 'acf_field_wysiwyg' ) ) :
* @param n/a
* @return (array)
*/
function get_toolbars() {
// vars
@@ -134,7 +131,6 @@ if ( ! class_exists( 'acf_field_wysiwyg' ) ) :
* @param void
* @return void
*/
function acf_enqueue_uploader() {
// vars