plugin install
This commit is contained in:
@@ -667,3 +667,45 @@ function acf_maybe_unserialize( $data ) {
|
||||
function acf_is_pro() {
|
||||
return defined( 'ACF_PRO' ) && ACF_PRO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if ACF is a beta-like release.
|
||||
*
|
||||
* @since 6.3
|
||||
*
|
||||
* @return boolean True if the current install version contains a dash, indicating a alpha, beta or RC release.
|
||||
*/
|
||||
function acf_is_beta() {
|
||||
return defined( 'ACF_VERSION' ) && strpos( ACF_VERSION, '-' ) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of ACF when it was first activated.
|
||||
* However, if ACF was first activated prior to the introduction of the acf_first_activated_version option,
|
||||
* this function returns false (boolean) to indicate that the version could not be determined.
|
||||
*
|
||||
* @since 6.3
|
||||
*
|
||||
* @return string|boolean The (string) version of ACF when it was first activated, or false (boolean) if the version could not be determined.
|
||||
*/
|
||||
function acf_get_version_when_first_activated() {
|
||||
// Check if ACF is network-activated on a multisite.
|
||||
if ( is_multisite() ) {
|
||||
$acf_dir_and_filename = basename( ACF_PATH ) . '/acf.php';
|
||||
$plugins = get_site_option( 'active_sitewide_plugins' );
|
||||
|
||||
if ( isset( $plugins[ $acf_dir_and_filename ] ) ) {
|
||||
$main_site_id = get_main_site_id();
|
||||
|
||||
if ( empty( $main_site_id ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ACF is network activated, so get the version from main site's options.
|
||||
return get_blog_option( $main_site_id, 'acf_first_activated_version', false );
|
||||
}
|
||||
}
|
||||
|
||||
// Check if ACF is activated on this single site.
|
||||
return get_option( 'acf_first_activated_version', false );
|
||||
}
|
||||
|
||||
@@ -453,6 +453,8 @@ if ( ! class_exists( 'ACF_Admin_Internal_Post_Type_List' ) ) :
|
||||
$duplicate_action_url = wp_nonce_url( admin_url( 'post-new.php?post_type=acf-post-type&use_post_type=' . $post->ID ), 'acfduplicate-' . $post->ID );
|
||||
} elseif ( 'acf-taxonomy' === $this->post_type ) {
|
||||
$duplicate_action_url = wp_nonce_url( admin_url( 'post-new.php?post_type=acf-taxonomy&use_taxonomy=' . $post->ID ), 'acfduplicate-' . $post->ID );
|
||||
} elseif ( 'acf-ui-options-page' === $this->post_type ) {
|
||||
$duplicate_action_url = wp_nonce_url( admin_url( 'post-new.php?post_type=acf-ui-options-page&use_options_page=' . $post->ID ), 'acfduplicate-' . $post->ID );
|
||||
}
|
||||
|
||||
$actions['acfduplicate'] = '<a href="' . esc_url( $duplicate_action_url ) . '" aria-label="' . esc_attr__( 'Duplicate this item', 'acf' ) . '">' . __( 'Duplicate', 'acf' ) . '</a>';
|
||||
|
||||
@@ -28,7 +28,6 @@ if ( ! class_exists( 'acf_admin_tools' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
@@ -46,7 +45,6 @@ if ( ! class_exists( 'acf_admin_tools' ) ) :
|
||||
* @param string $class
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function register_tool( $class ) {
|
||||
|
||||
$instance = new $class();
|
||||
@@ -65,7 +63,6 @@ if ( ! class_exists( 'acf_admin_tools' ) ) :
|
||||
* @param string $name
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function get_tool( $name ) {
|
||||
|
||||
return isset( $this->tools[ $name ] ) ? $this->tools[ $name ] : null;
|
||||
@@ -83,7 +80,6 @@ if ( ! class_exists( 'acf_admin_tools' ) ) :
|
||||
* @param n/a
|
||||
* @return array
|
||||
*/
|
||||
|
||||
function get_tools() {
|
||||
|
||||
return $this->tools;
|
||||
@@ -100,7 +96,6 @@ if ( ! class_exists( 'acf_admin_tools' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_menu() {
|
||||
|
||||
// bail early if no show_admin
|
||||
@@ -127,7 +122,6 @@ if ( ! class_exists( 'acf_admin_tools' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function load() {
|
||||
|
||||
add_action( 'admin_body_class', array( $this, 'admin_body_class' ) );
|
||||
@@ -169,7 +163,6 @@ if ( ! class_exists( 'acf_admin_tools' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function include_tools() {
|
||||
|
||||
// include
|
||||
@@ -193,7 +186,6 @@ if ( ! class_exists( 'acf_admin_tools' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function check_submit() {
|
||||
|
||||
// loop
|
||||
@@ -221,7 +213,6 @@ if ( ! class_exists( 'acf_admin_tools' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function html() {
|
||||
|
||||
// vars
|
||||
|
||||
@@ -19,7 +19,8 @@ if ( ! class_exists( 'ACF_Admin' ) ) :
|
||||
add_action( 'admin_body_class', array( $this, 'admin_body_class' ) );
|
||||
add_action( 'current_screen', array( $this, 'current_screen' ) );
|
||||
add_action( 'admin_notices', array( $this, 'maybe_show_escaped_html_notice' ) );
|
||||
add_action( 'wp_ajax_acf/dismiss_escaped_html_notice', array( $this, 'dismiss_escaped_html_notice' ) );
|
||||
add_action( 'admin_init', array( $this, 'dismiss_escaped_html_notice' ) );
|
||||
add_action( 'admin_init', array( $this, 'clear_escaped_html_log' ) );
|
||||
add_filter( 'parent_file', array( $this, 'ensure_menu_selection' ) );
|
||||
add_filter( 'submenu_file', array( $this, 'ensure_submenu_selection' ) );
|
||||
}
|
||||
@@ -58,7 +59,6 @@ if ( ! class_exists( 'ACF_Admin' ) ) :
|
||||
'acf-escaped-html-notice',
|
||||
'acf_escaped_html_notice',
|
||||
array(
|
||||
'nonce' => wp_create_nonce( 'acf/dismiss_escaped_html_notice' ),
|
||||
'show_details' => __( 'Show details', 'acf' ),
|
||||
'hide_details' => __( 'Hide details', 'acf' ),
|
||||
)
|
||||
@@ -220,6 +220,10 @@ if ( ! class_exists( 'ACF_Admin' ) ) :
|
||||
return;
|
||||
}
|
||||
|
||||
if ( get_option( 'acf_escaped_html_notice_dismissed' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$escaped = _acf_get_escaped_html_log();
|
||||
|
||||
// Notice for when HTML has already been escaped.
|
||||
@@ -229,18 +233,55 @@ if ( ! class_exists( 'ACF_Admin' ) ) :
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismisses the escaped unsafe HTML notice by clearing the stored log.
|
||||
* Dismisses the escaped unsafe HTML notice.
|
||||
*
|
||||
* @since 6.2.5
|
||||
*/
|
||||
public function dismiss_escaped_html_notice() {
|
||||
if ( empty( $_GET['acf-dismiss-esc-html-notice'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$nonce = sanitize_text_field( wp_unslash( $_GET['acf-dismiss-esc-html-notice'] ) );
|
||||
|
||||
if (
|
||||
! check_admin_referer( 'acf/dismiss_escaped_html_notice', 'nonce' ) ||
|
||||
! current_user_can( acf_get_setting( 'capability' ) ) ) {
|
||||
! wp_verify_nonce( $nonce, 'acf/dismiss_escaped_html_notice' ) ||
|
||||
! current_user_can( acf_get_setting( 'capability' ) )
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
update_option( 'acf_escaped_html_notice_dismissed', true );
|
||||
|
||||
_acf_delete_escaped_html_log();
|
||||
|
||||
wp_safe_redirect( remove_query_arg( 'acf-dismiss-esc-html-notice' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the escaped unsafe HTML log.
|
||||
*
|
||||
* @since 6.2.5
|
||||
*/
|
||||
public function clear_escaped_html_log() {
|
||||
if ( empty( $_GET['acf-clear-esc-html-log'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$nonce = sanitize_text_field( wp_unslash( $_GET['acf-clear-esc-html-log'] ) );
|
||||
|
||||
if (
|
||||
! wp_verify_nonce( $nonce, 'acf/clear_escaped_html_log' ) ||
|
||||
! current_user_can( acf_get_setting( 'capability' ) )
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
_acf_delete_escaped_html_log();
|
||||
|
||||
wp_safe_redirect( remove_query_arg( 'acf-clear-esc-html-log' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -111,6 +111,36 @@ if ( ! class_exists( 'acf_admin_field_group' ) ) :
|
||||
'Value is less than' => esc_html__( 'Value is less than', 'acf' ),
|
||||
'Selection is greater than' => esc_html__( 'Selection is greater than', 'acf' ),
|
||||
'Selection is less than' => esc_html__( 'Selection is less than', 'acf' ),
|
||||
'Relationship is equal to' => esc_html__( 'Relationship is equal to', 'acf' ),
|
||||
'Relationship is not equal to' => esc_html__( 'Relationship is not equal to', 'acf' ),
|
||||
'Relationships contain' => esc_html__( 'Relationships contain', 'acf' ),
|
||||
'Relationships do not contain' => esc_html__( 'Relationships do not contain', 'acf' ),
|
||||
'Post is equal to' => esc_html__( 'Post is equal to', 'acf' ),
|
||||
'Post is not equal to' => esc_html__( 'Post is not equal to', 'acf' ),
|
||||
'Posts contain' => esc_html__( 'Posts contain', 'acf' ),
|
||||
'Posts do not contain' => esc_html__( 'Posts do not contain', 'acf' ),
|
||||
'Has any post selected' => esc_html__( 'Has any post selected', 'acf' ),
|
||||
'Has no post selected' => esc_html__( 'Has no post selected', 'acf' ),
|
||||
'Has any relationship selected' => esc_html__( 'Has any relationship selected', 'acf' ),
|
||||
'Has no relationship selected' => esc_html__( 'Has no relationship selected', 'acf' ),
|
||||
'Page is equal to' => esc_html__( 'Page is equal to', 'acf' ),
|
||||
'Page is not equal to' => esc_html__( 'Page is not equal to', 'acf' ),
|
||||
'Pages contain' => esc_html__( 'Pages contain', 'acf' ),
|
||||
'Pages do not contain' => esc_html__( 'Pages do not contain', 'acf' ),
|
||||
'Has any page selected' => esc_html__( 'Has any page selected', 'acf' ),
|
||||
'Has no page selected' => esc_html__( 'Has no page selected', 'acf' ),
|
||||
'User is equal to' => esc_html__( 'User is equal to', 'acf' ),
|
||||
'User is not equal to' => esc_html__( 'User is not equal to', 'acf' ),
|
||||
'Users contain' => esc_html__( 'Users contain', 'acf' ),
|
||||
'Users do not contain' => esc_html__( 'Users do not contain', 'acf' ),
|
||||
'Has any user selected' => esc_html__( 'Has any user selected', 'acf' ),
|
||||
'Has no user selected' => esc_html__( 'Has no user selected', 'acf' ),
|
||||
'Term is equal to' => esc_html__( 'Term is equal to', 'acf' ),
|
||||
'Term is not equal to' => esc_html__( 'Term is not equal to', 'acf' ),
|
||||
'Terms contain' => esc_html__( 'Terms contain', 'acf' ),
|
||||
'Terms do not contain' => esc_html__( 'Terms do not contain', 'acf' ),
|
||||
'Has any term selected' => esc_html__( 'Has any term selected', 'acf' ),
|
||||
'Has no term selected' => esc_html__( 'Has no term selected', 'acf' ),
|
||||
|
||||
// Custom Select2 templates.
|
||||
'Type to search...' => esc_html__( 'Type to search...', 'acf' ),
|
||||
@@ -479,12 +509,14 @@ if ( ! class_exists( 'acf_admin_field_group' ) ) :
|
||||
}
|
||||
|
||||
/**
|
||||
* Move field AJAX function
|
||||
* Moves fields between field groups via AJAX.
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function ajax_move_field() {
|
||||
// disable filters to ensure ACF loads raw data from DB.
|
||||
// Disable filters to ensure ACF loads raw data from DB.
|
||||
acf_disable_filters();
|
||||
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Missing
|
||||
@@ -499,34 +531,35 @@ if ( ! class_exists( 'acf_admin_field_group' ) ) :
|
||||
);
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Missing
|
||||
|
||||
// verify nonce.
|
||||
// Verify nonce.
|
||||
if ( ! wp_verify_nonce( $args['nonce'], 'acf_nonce' ) ) {
|
||||
die();
|
||||
}
|
||||
|
||||
// verify user capability.
|
||||
// Verify user capability.
|
||||
if ( ! acf_current_user_can_admin() ) {
|
||||
die();
|
||||
}
|
||||
|
||||
// confirm?
|
||||
// Move the field if the user has confirmed.
|
||||
if ( $args['field_id'] && $args['field_group_id'] ) {
|
||||
$field = acf_get_field( $args['field_id'] );
|
||||
$old_field_group = acf_get_field_group( $args['post_id'] );
|
||||
$new_field_group = acf_get_field_group( $args['field_group_id'] );
|
||||
|
||||
// vars.
|
||||
$field = acf_get_field( $args['field_id'] );
|
||||
$field_group = acf_get_field_group( $args['field_group_id'] );
|
||||
|
||||
// update parent.
|
||||
$field['parent'] = $field_group['ID'];
|
||||
|
||||
// remove conditional logic.
|
||||
// Update the field parent and remove conditional logic.
|
||||
$field['parent'] = $new_field_group['ID'];
|
||||
$field['conditional_logic'] = 0;
|
||||
|
||||
// update field.
|
||||
// Update the field in the database.
|
||||
acf_update_field( $field );
|
||||
|
||||
// Fire `acf/update_field_group` action hook so JSON can sync if necessary.
|
||||
do_action( 'acf/update_field_group', $old_field_group );
|
||||
do_action( 'acf/update_field_group', $new_field_group );
|
||||
|
||||
// Output HTML.
|
||||
$link = '<a href="' . admin_url( 'post.php?post=' . $field_group['ID'] . '&action=edit' ) . '" target="_blank">' . esc_html( $field_group['title'] ) . '</a>';
|
||||
$link = '<a href="' . admin_url( 'post.php?post=' . $new_field_group['ID'] . '&action=edit' ) . '" target="_blank">' . esc_html( $new_field_group['title'] ) . '</a>';
|
||||
|
||||
echo '' .
|
||||
'<p><strong>' . esc_html__( 'Move Complete.', 'acf' ) . '</strong></p>' .
|
||||
@@ -540,22 +573,18 @@ if ( ! class_exists( 'acf_admin_field_group' ) ) :
|
||||
die();
|
||||
}
|
||||
|
||||
// get all field groups.
|
||||
// Get all field groups.
|
||||
$field_groups = acf_get_field_groups();
|
||||
$choices = array();
|
||||
|
||||
// check.
|
||||
if ( ! empty( $field_groups ) ) {
|
||||
|
||||
// loop.
|
||||
foreach ( $field_groups as $field_group ) {
|
||||
|
||||
// bail early if no ID.
|
||||
// Bail early if no ID.
|
||||
if ( ! $field_group['ID'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// bail early if is current.
|
||||
// Bail early if is current.
|
||||
if ( $field_group['ID'] == $args['post_id'] ) {
|
||||
continue;
|
||||
}
|
||||
@@ -564,7 +593,7 @@ if ( ! class_exists( 'acf_admin_field_group' ) ) :
|
||||
}
|
||||
}
|
||||
|
||||
// render options.
|
||||
// Render options.
|
||||
$field = acf_get_valid_field(
|
||||
array(
|
||||
'type' => 'select',
|
||||
@@ -575,14 +604,9 @@ if ( ! class_exists( 'acf_admin_field_group' ) ) :
|
||||
);
|
||||
|
||||
echo '<p>' . esc_html__( 'Please select the destination for this field', 'acf' ) . '</p>';
|
||||
|
||||
echo '<form id="acf-move-field-form">';
|
||||
|
||||
// render.
|
||||
acf_render_field_wrap( $field );
|
||||
|
||||
echo '<button type="submit" class="acf-btn">' . esc_html__( 'Move Field', 'acf' ) . '</button>';
|
||||
|
||||
echo '</form>';
|
||||
|
||||
die();
|
||||
|
||||
@@ -121,7 +121,7 @@ if ( ! class_exists( 'ACF_Admin_Field_Groups' ) ) :
|
||||
|
||||
// Description.
|
||||
case 'acf-description':
|
||||
if ( is_string( $post['description'] ) && ! empty( $post['description'] ) ) {
|
||||
if ( ( is_string( $post['description'] ) || is_numeric( $post['description'] ) ) && ! empty( $post['description'] ) ) {
|
||||
echo '<span class="acf-description">' . acf_esc_html( $post['description'] ) . '</span>';
|
||||
} else {
|
||||
echo '<span class="acf-emdash" aria-hidden="true">—</span>';
|
||||
|
||||
@@ -140,7 +140,7 @@ if ( ! class_exists( 'ACF_Admin_Post_Types' ) ) :
|
||||
|
||||
// Description.
|
||||
case 'acf-description':
|
||||
if ( is_string( $post['description'] ) && ! empty( $post['description'] ) ) {
|
||||
if ( ( is_string( $post['description'] ) || is_numeric( $post['description'] ) ) && ! empty( $post['description'] ) ) {
|
||||
echo '<span class="acf-description">' . acf_esc_html( $post['description'] ) . '</span>';
|
||||
} else {
|
||||
echo '<span class="acf-emdash" aria-hidden="true">—</span>';
|
||||
|
||||
@@ -139,7 +139,7 @@ if ( ! class_exists( 'ACF_Admin_Taxonomies' ) ) :
|
||||
|
||||
// Description.
|
||||
case 'acf-description':
|
||||
if ( is_string( $post['description'] ) && ! empty( $post['description'] ) ) {
|
||||
if ( ( is_string( $post['description'] ) || is_numeric( $post['description'] ) ) && ! empty( $post['description'] ) ) {
|
||||
echo '<span class="acf-description">' . acf_esc_html( $post['description'] ) . '</span>';
|
||||
} else {
|
||||
echo '<span class="acf-emdash" aria-hidden="true">—</span>';
|
||||
|
||||
@@ -19,7 +19,6 @@ if ( ! class_exists( 'ACF_Admin_Tool_Import' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
@@ -40,7 +39,6 @@ if ( ! class_exists( 'ACF_Admin_Tool_Import' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function html() {
|
||||
|
||||
?>
|
||||
|
||||
@@ -36,7 +36,6 @@ if ( ! class_exists( 'ACF_Admin_Tool' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function get_name() {
|
||||
return $this->name;
|
||||
}
|
||||
@@ -53,7 +52,6 @@ if ( ! class_exists( 'ACF_Admin_Tool' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function get_title() {
|
||||
return $this->title;
|
||||
}
|
||||
@@ -70,7 +68,6 @@ if ( ! class_exists( 'ACF_Admin_Tool' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function get_url() {
|
||||
return acf_get_admin_tool_url( $this->name );
|
||||
}
|
||||
@@ -87,7 +84,6 @@ if ( ! class_exists( 'ACF_Admin_Tool' ) ) :
|
||||
* @param n/a
|
||||
* @return boolean
|
||||
*/
|
||||
|
||||
function is_active() {
|
||||
return acf_maybe_get_GET( 'tool' ) === $this->name;
|
||||
}
|
||||
@@ -103,7 +99,6 @@ if ( ! class_exists( 'ACF_Admin_Tool' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// initialize
|
||||
@@ -122,7 +117,6 @@ if ( ! class_exists( 'ACF_Admin_Tool' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function initialize() {
|
||||
|
||||
/* do nothing */
|
||||
@@ -141,7 +135,6 @@ if ( ! class_exists( 'ACF_Admin_Tool' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function load() {
|
||||
|
||||
/* do nothing */
|
||||
@@ -159,7 +152,6 @@ if ( ! class_exists( 'ACF_Admin_Tool' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function html() {
|
||||
}
|
||||
|
||||
@@ -175,7 +167,6 @@ if ( ! class_exists( 'ACF_Admin_Tool' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function submit() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,8 +139,19 @@ if ( empty( $field['conditional_logic'] ) ) {
|
||||
</td>
|
||||
<td class="value">
|
||||
<?php
|
||||
$conditional_field = get_field_object( $rule['field'] );
|
||||
|
||||
/**
|
||||
* Filters the choices available for a conditional logic rule.
|
||||
*
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @param array $choices The available choices.
|
||||
* @param array $conditional_field The field object for the conditional field.
|
||||
* @param mixed $value The value of the rule.
|
||||
*/
|
||||
$choices = apply_filters( 'acf/conditional_logic/choices', array( $rule['value'] => $rule['value'] ), $conditional_field, $rule['value'] );
|
||||
|
||||
// create field
|
||||
acf_render_field(
|
||||
array(
|
||||
'type' => 'select',
|
||||
@@ -149,12 +160,9 @@ if ( empty( $field['conditional_logic'] ) ) {
|
||||
'class' => 'condition-rule-value',
|
||||
'disabled' => $disabled,
|
||||
'value' => $rule['value'],
|
||||
'choices' => array(
|
||||
$rule['value'] => $rule['value'],
|
||||
),
|
||||
'choices' => $choices,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td class="add">
|
||||
|
||||
@@ -34,7 +34,7 @@ if ( acf_is_pro() && acf_get_field_type_prop( $field['type'], 'pro' ) ) {
|
||||
}
|
||||
|
||||
if ( acf_is_pro() && acf_get_field_type_prop( $field['type'], 'pro' ) && ! acf_pro_is_license_active() ) {
|
||||
$field_type_label .= '<span class="acf-pro-label acf-pro-label-field-type">PRO</span>';
|
||||
$field_type_label .= '<span class="acf-pro-label-field-type"><img src="' . esc_url( acf_get_url( 'assets/images/pro-chip.svg' ) ) . '" alt="' . esc_attr__( 'ACF PRO Logo', 'acf' ) . '"></span>';
|
||||
|
||||
if ( ! acf_pro_is_license_expired() ) {
|
||||
$inactive_field_class = ' acf-js-tooltip';
|
||||
@@ -217,7 +217,7 @@ if ( isset( $field['conditional_logic'] ) && is_array( $field['conditional_logic
|
||||
$field,
|
||||
array(
|
||||
'label' => __( 'Instructions', 'acf' ),
|
||||
'instructions' => __( 'Instructions for authors. Shown when submitting data', 'acf' ),
|
||||
'instructions' => __( 'Instructions for content editors. Shown when submitting data.', 'acf' ),
|
||||
'type' => 'textarea',
|
||||
'name' => 'instructions',
|
||||
'rows' => 5,
|
||||
|
||||
@@ -22,9 +22,9 @@ if ( acf_is_pro() ) {
|
||||
?>
|
||||
<div id="tmpl-acf-field-group-pro-features">
|
||||
<div class="acf-field-group-pro-features-wrapper">
|
||||
<h1 class="acf-field-group-pro-features-title-sm"><?php echo esc_html( $acf_field_group_pro_features_title ); ?> <div class="acf-pro-label">PRO</div></h1>
|
||||
<h1 class="acf-field-group-pro-features-title-sm"><?php echo esc_html( $acf_field_group_pro_features_title ); ?> <div class="acf-pro-label"><img src="<?php echo esc_url( acf_get_url( 'assets/images/pro-chip.svg' ) ); ?>" alt="<?php esc_attr_e( 'ACF PRO logo', 'acf' ); ?>"></div></h1>
|
||||
<div class="acf-field-group-pro-features-content">
|
||||
<h1 class="acf-field-group-pro-features-title"><?php echo esc_html( $acf_field_group_pro_features_title ); ?> <div class="acf-pro-label">PRO</div></h1>
|
||||
<h1 class="acf-field-group-pro-features-title"><?php echo esc_html( $acf_field_group_pro_features_title ); ?> <div class="acf-pro-label"><img src="<?php echo esc_url( acf_get_url( 'assets/images/pro-chip.svg' ) ); ?>" alt="<?php esc_attr_e( 'ACF PRO logo', 'acf' ); ?>"></div></h1>
|
||||
<p class="acf-field-group-pro-features-desc"><?php esc_html_e( 'Speed up your workflow and develop better websites with features like ACF Blocks and Options Pages, and sophisticated field types like Repeater, Flexible Content, Clone, and Gallery.', 'acf' ); ?></p>
|
||||
<div class="acf-field-group-pro-features-actions">
|
||||
<a target="<?php echo esc_attr( $acf_learn_more_target ); ?>" href="<?php echo $acf_learn_more_link; ?>" class="acf-btn acf-btn-muted acf-pro-features-learn-more"><?php //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped on generation. ?>
|
||||
|
||||
@@ -747,15 +747,6 @@ foreach ( acf_get_combined_post_type_settings_tabs() as $tab_key => $tab_label )
|
||||
)
|
||||
);
|
||||
|
||||
$acf_dashicon_class_name = __( 'Dashicon class name', 'acf' );
|
||||
$acf_dashicon_link = '<a href="https://developer.wordpress.org/resource/dashicons/" target="_blank">' . $acf_dashicon_class_name . '</a>';
|
||||
|
||||
$acf_menu_icon_instructions = sprintf(
|
||||
/* translators: %s = "dashicon class name", link to the WordPress dashicon documentation. */
|
||||
__( 'The icon used for the post type menu item in the admin dashboard. Can be a URL or %s to use for the icon.', 'acf' ),
|
||||
$acf_dashicon_link
|
||||
);
|
||||
|
||||
acf_render_field_wrap(
|
||||
array(
|
||||
'type' => 'text',
|
||||
@@ -795,20 +786,52 @@ foreach ( acf_get_combined_post_type_settings_tabs() as $tab_key => $tab_label )
|
||||
'field'
|
||||
);
|
||||
|
||||
// Set the default value for the icon field.
|
||||
$acf_default_icon_value = array(
|
||||
'type' => 'dashicons',
|
||||
'value' => 'dashicons-admin-post',
|
||||
);
|
||||
|
||||
if ( empty( $acf_post_type['menu_icon'] ) ) {
|
||||
$acf_post_type['menu_icon'] = $acf_default_icon_value;
|
||||
}
|
||||
|
||||
// Backwards compatibility for before the icon picker was introduced.
|
||||
if ( is_string( $acf_post_type['menu_icon'] ) ) {
|
||||
// If the old value was a string that starts with dashicons-, assume it's a dashicon.
|
||||
if ( false !== strpos( $acf_post_type['menu_icon'], 'dashicons-' ) ) {
|
||||
$acf_post_type['menu_icon'] = array(
|
||||
'type' => 'dashicons',
|
||||
'value' => $acf_post_type['menu_icon'],
|
||||
);
|
||||
} else {
|
||||
$acf_post_type['menu_icon'] = array(
|
||||
'type' => 'url',
|
||||
'value' => $acf_post_type['menu_icon'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
acf_render_field_wrap(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'menu_icon',
|
||||
'key' => 'menu_icon',
|
||||
'prefix' => 'acf_post_type',
|
||||
'value' => $acf_post_type['menu_icon'],
|
||||
'label' => __( 'Menu Icon', 'acf' ),
|
||||
'placeholder' => 'dashicons-admin-post',
|
||||
'instructions' => $acf_menu_icon_instructions,
|
||||
'conditions' => array(
|
||||
'field' => 'show_in_menu',
|
||||
'operator' => '==',
|
||||
'value' => 1,
|
||||
'type' => 'icon_picker',
|
||||
'name' => 'menu_icon',
|
||||
'key' => 'menu_icon',
|
||||
'prefix' => 'acf_post_type',
|
||||
'value' => $acf_post_type['menu_icon'],
|
||||
'label' => __( 'Menu Icon', 'acf' ),
|
||||
'placeholder' => 'dashicons-admin-post',
|
||||
'conditions' => array(
|
||||
array(
|
||||
'field' => 'show_in_menu',
|
||||
'operator' => '==',
|
||||
'value' => '1',
|
||||
),
|
||||
array(
|
||||
'field' => 'admin_menu_parent',
|
||||
'operator' => '==',
|
||||
'value' => '',
|
||||
),
|
||||
),
|
||||
),
|
||||
'div',
|
||||
|
||||
@@ -2,44 +2,67 @@
|
||||
|
||||
$acf_plugin_name = acf_is_pro() ? 'ACF PRO' : 'ACF';
|
||||
$acf_plugin_name = '<strong>' . $acf_plugin_name . ' —</strong>';
|
||||
$acf_learn_how_to_fix = '<a href="' . acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/escaping-the-field/', 'docs', '6-2-5-security-changes' ) . '" target="_blank">' . __( 'Learn how to fix this', 'acf' ) . '</a>';
|
||||
$acf_learn_how_to_fix = '<a href="' . acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/escaping-the-field/', 'docs', '6-2-5-security-changes' ) . '" target="_blank">' . __( 'Learn more', 'acf' ) . '</a>';
|
||||
$acf_class = 'notice-error';
|
||||
$acf_user_can_acf = false;
|
||||
|
||||
if ( current_user_can( acf_get_setting( 'capability' ) ) ) {
|
||||
$acf_user_can_acf = true;
|
||||
$acf_show_details = ' <a class="acf-show-more-details" href="#">' . __( 'Show details', 'acf' ) . '</a>';
|
||||
$acf_class .= ' is-dismissible';
|
||||
$acf_dismiss_url = add_query_arg( array( 'acf-dismiss-esc-html-notice' => wp_create_nonce( 'acf/dismiss_escaped_html_notice' ) ) );
|
||||
|
||||
// "Show/Hide Details" is a button for accessibility purposes, because it isn't a link. But since the design shows a link, we need to make it look like a link.
|
||||
$acf_style_button_as_link = trim(
|
||||
'display: inline;
|
||||
padding: 0;
|
||||
background: none;
|
||||
border: none;
|
||||
color: #0073aa;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;'
|
||||
);
|
||||
|
||||
$acf_show_details = '<button style="' . esc_attr( $acf_style_button_as_link ) . '" class="acf-show-more-details">' . __( 'Show details', 'acf' ) . '</button>';
|
||||
$acf_show_details .= ' | <a class="acf-dismiss-permanently-button" href="' . esc_url( $acf_dismiss_url ) . '">' . __( 'Dismiss permanently', 'acf' ) . '</a>';
|
||||
} else {
|
||||
$acf_show_details = __( 'Please contact your site administrator or developer for more details.', 'acf' );
|
||||
}
|
||||
|
||||
$acf_error_msg = sprintf(
|
||||
/* translators: %1$s - name of the ACF plugin. %2$s - Link to documentation. %3$s - Link to show more details about the error */
|
||||
__( '%1$s ACF now automatically escapes unsafe HTML when rendered by <code>the_field</code> or the ACF shortcode. We\'ve detected the output of some of your fields has been modified by this change, but this may not be a breaking change. %2$s. %3$s.', 'acf' ),
|
||||
__( '%1$s ACF now automatically escapes unsafe HTML when rendered by <code>the_field</code> or the ACF shortcode. We\'ve detected the output of some of your fields has been modified by this change, but this may not be a breaking change. %2$s.', 'acf' ),
|
||||
$acf_plugin_name,
|
||||
$acf_learn_how_to_fix,
|
||||
$acf_show_details
|
||||
$acf_learn_how_to_fix
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
<div class="acf-admin-notice notice acf-escaped-html-notice <?php echo esc_attr( $acf_class ); ?>">
|
||||
<p><?php echo acf_esc_html( $acf_error_msg ); ?></p>
|
||||
<p style="margin-bottom: 0.5em; padding-bottom: 2px;"><?php echo acf_esc_html( $acf_error_msg ); ?></p>
|
||||
<p style="margin: 0.5em 0; padding: 2px;"><?php echo acf_esc_html( $acf_show_details ); ?></p>
|
||||
<?php if ( $acf_user_can_acf && ! empty( $acf_escaped ) ) : ?>
|
||||
<ul class="acf-error-details" style="display: none; list-style: disc; margin-left: 14px;">
|
||||
<?php
|
||||
foreach ( $acf_escaped as $acf_field_key => $acf_data ) {
|
||||
$acf_error = sprintf(
|
||||
/* translators: %1$s - The selector used %2$s The field name 3%$s The parent function name */
|
||||
__( '%1$s (%2$s) - rendered via %3$s', 'acf' ),
|
||||
$acf_data['selector'],
|
||||
$acf_data['field'],
|
||||
$acf_data['function']
|
||||
);
|
||||
<div class="acf-error-details" style="display: none; list-style: disc; margin-left: 14px;">
|
||||
<ul class="acf-error-details" style="display: none; list-style: disc; margin-left: 14px;">
|
||||
<?php
|
||||
foreach ( $acf_escaped as $acf_field_key => $acf_data ) {
|
||||
$acf_error = sprintf(
|
||||
/* translators: %1$s - The selector used %2$s The field name 3%$s The parent function name */
|
||||
__( '%1$s (%2$s) - rendered via %3$s', 'acf' ),
|
||||
$acf_data['selector'],
|
||||
$acf_data['field'],
|
||||
$acf_data['function']
|
||||
);
|
||||
|
||||
echo '<li>' . esc_html( $acf_error ) . '</li>';
|
||||
}
|
||||
echo '<li>' . esc_html( $acf_error ) . '</li>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<p style="margin: 0.5em 0; padding: 2px;">
|
||||
<?php
|
||||
$acf_clear_logs_url = add_query_arg( array( 'acf-clear-esc-html-log' => wp_create_nonce( 'acf/clear_escaped_html_log' ) ) );
|
||||
// translators: %s - The clear log button opening HTML tag. %s - The closing HTML tag.
|
||||
echo acf_esc_html( '<i>' . sprintf( __( 'This data is logged as we detect values that have been changed during output. %1$sClear log and dismiss%2$s after escaping the values in your code. The notice will reappear if we detect changed values again.', 'acf' ), '<a class="acf-clear-log-button" href="' . esc_url( $acf_clear_logs_url ) . '">', '</a>' ) . '</i>' );
|
||||
?>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
@@ -40,15 +40,18 @@ if ( 'acf-field-group' === $acf_post_type ) {
|
||||
if ( empty( $acf_title ) && $acf_prefilled_title ) {
|
||||
$acf_title = $acf_prefilled_title;
|
||||
}
|
||||
} elseif ( in_array( $acf_post_type, array( 'acf-post-type', 'acf-taxonomy' ) ) ) {
|
||||
$acf_duplicate_post_type = acf_get_post_type_from_request_args( 'acfduplicate' );
|
||||
$acf_duplicate_taxonomy = acf_get_taxonomy_from_request_args( 'acfduplicate' );
|
||||
$acf_duplicated_from_label = '';
|
||||
} elseif ( in_array( $acf_post_type, array( 'acf-post-type', 'acf-taxonomy', 'acf-ui-options-page' ), true ) ) {
|
||||
$acf_duplicate_post_type = acf_get_post_type_from_request_args( 'acfduplicate' );
|
||||
$acf_duplicate_taxonomy = acf_get_taxonomy_from_request_args( 'acfduplicate' );
|
||||
$acf_duplicate_ui_options_page = acf_get_ui_options_page_from_request_args( 'acfduplicate' );
|
||||
$acf_duplicated_from_label = '';
|
||||
|
||||
if ( $acf_duplicate_post_type && ! empty( $acf_duplicate_post_type['labels']['singular_name'] ) ) {
|
||||
$acf_duplicated_from_label = $acf_duplicate_post_type['labels']['singular_name'];
|
||||
} elseif ( $acf_duplicate_taxonomy && ! empty( $acf_duplicate_taxonomy['labels']['singular_name'] ) ) {
|
||||
$acf_duplicated_from_label = $acf_duplicate_taxonomy['labels']['singular_name'];
|
||||
} elseif ( $acf_duplicate_ui_options_page && ! empty( $acf_duplicate_ui_options_page['page_title'] ) ) {
|
||||
$acf_duplicated_from_label = $acf_duplicate_ui_options_page['page_title'];
|
||||
}
|
||||
|
||||
if ( ! empty( $acf_duplicated_from_label ) ) {
|
||||
|
||||
@@ -24,7 +24,7 @@ if ( $page_title ) {
|
||||
echo esc_html( $page_title );
|
||||
?>
|
||||
<?php if ( $acf_is_options_page_preview ) { ?>
|
||||
<div class="acf-pro-label">PRO</div>
|
||||
<div class="acf-pro-label"><img src="<?php echo esc_url( acf_get_url( 'assets/images/pro-chip.svg' ) ); ?>" alt="<?php esc_attr_e( 'ACF PRO logo', 'acf' ); ?>"></div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -172,12 +172,15 @@ function acf_print_menu_section( $menu_items, $section = '' ) {
|
||||
<div class="acf-admin-toolbar">
|
||||
<div class="acf-admin-toolbar-inner">
|
||||
<div class="acf-nav-wrap">
|
||||
<a href="<?php echo esc_url( admin_url( 'edit.php?post_type=acf-field-group' ) ); ?>" class="acf-logo">
|
||||
<img src="<?php echo esc_url( acf_get_url( 'assets/images/acf-logo.svg' ) ); ?>" alt="<?php esc_attr_e( 'Advanced Custom Fields logo', 'acf' ); ?>">
|
||||
<?php if ( acf_is_pro() && acf_pro_is_license_active() ) { ?>
|
||||
<div class="acf-pro-label">PRO</div>
|
||||
<?php } ?>
|
||||
</a>
|
||||
<?php if ( acf_is_pro() && acf_pro_is_license_active() ) { ?>
|
||||
<a href="<?php echo esc_url( admin_url( 'edit.php?post_type=acf-field-group' ) ); ?>" class="acf-logo pro">
|
||||
<img src="<?php echo esc_url( acf_get_url( 'assets/images/acf-pro-logo.svg' ) ); ?>" alt="<?php esc_attr_e( 'Advanced Custom Fields logo', 'acf' ); ?>">
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
<a href="<?php echo esc_url( admin_url( 'edit.php?post_type=acf-field-group' ) ); ?>" class="acf-logo">
|
||||
<img src="<?php echo esc_url( acf_get_url( 'assets/images/acf-logo.svg' ) ); ?>" alt="<?php esc_attr_e( 'Advanced Custom Fields logo', 'acf' ); ?>">
|
||||
</a>
|
||||
<?php } ?>
|
||||
|
||||
<h2><?php echo esc_html( acf_get_setting( 'name' ) ); ?></h2>
|
||||
<?php acf_print_menu_section( $core_tabs, 'core' ); ?>
|
||||
|
||||
@@ -22,7 +22,7 @@ if ( ! acf_get_setting( 'pro' ) ) {
|
||||
<div id="acf-upgrade-notice" class="notice">
|
||||
<div class="notice-container">
|
||||
<div class="col-content">
|
||||
<img src="<?php echo esc_url( acf_get_url( 'assets/images/acf-logo.png' ) ); ?>" />
|
||||
<img src="<?php echo esc_url( acf_get_url( 'assets/images/acf-logo.svg' ) ); ?>" />
|
||||
<h2><?php esc_html_e( 'Database Upgrade Required', 'acf' ); ?></h2>
|
||||
<?php // translators: %1 plugin name, %2 version number ?>
|
||||
<p><?php echo acf_esc_html( sprintf( __( 'Thank you for updating to %1$s v%2$s!', 'acf' ), acf_get_setting( 'name' ), acf_get_setting( 'version' ) ) ); ?><br />
|
||||
|
||||
@@ -141,13 +141,14 @@ if ( ! class_exists( 'ACF_Ajax_Query_Users' ) ) :
|
||||
// Determine if more results exist.
|
||||
// As this query does not return grouped results, the calculation can be exact (">").
|
||||
$this->more = ( $total_users > count( $users ) + $args['offset'] );
|
||||
|
||||
// Otherwise, group results via role.
|
||||
} else {
|
||||
|
||||
// Unset args that will interfer with query results.
|
||||
unset( $args['role__in'], $args['role__not_in'] );
|
||||
|
||||
$args['search'] = $this->search ? $this->search : '';
|
||||
|
||||
// Loop over each role.
|
||||
foreach ( $roles as $role => $role_label ) {
|
||||
|
||||
|
||||
@@ -93,6 +93,12 @@ if ( ! class_exists( 'ACF_Ajax_Query' ) ) :
|
||||
$this->search = sanitize_text_field( $request['search'] );
|
||||
$this->is_search = true;
|
||||
}
|
||||
|
||||
if ( isset( $request['s'] ) && acf_not_empty( $request['s'] ) ) {
|
||||
$this->search = sanitize_text_field( $request['s'] );
|
||||
$this->is_search = true;
|
||||
}
|
||||
|
||||
if ( isset( $request['post_id'] ) ) {
|
||||
$this->post_id = $request['post_id'];
|
||||
}
|
||||
@@ -115,18 +121,19 @@ if ( ! class_exists( 'ACF_Ajax_Query' ) ) :
|
||||
if ( isset( $request['query'] ) ) {
|
||||
return (array) $request['query'];
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* get_items
|
||||
* get_results
|
||||
*
|
||||
* Returns an array of results for the given args.
|
||||
*
|
||||
* @date 31/7/18
|
||||
* @since 5.7.2
|
||||
*
|
||||
* @param array args The query args.
|
||||
* @param array $args The query args.
|
||||
* @return array
|
||||
*/
|
||||
function get_results( $args ) {
|
||||
@@ -134,7 +141,7 @@ if ( ! class_exists( 'ACF_Ajax_Query' ) ) :
|
||||
}
|
||||
|
||||
/**
|
||||
* get_item
|
||||
* get_result
|
||||
*
|
||||
* Returns a single result for the given item object.
|
||||
*
|
||||
|
||||
@@ -1153,7 +1153,7 @@ function acf_get_posts( $args = array() ) {
|
||||
$args['post_status'] = acf_get_post_stati();
|
||||
}
|
||||
|
||||
// Check if specifc post ID's have been provided.
|
||||
// Check if specific post IDs have been provided.
|
||||
if ( $args['post__in'] ) {
|
||||
|
||||
// Clean value into an array of IDs.
|
||||
|
||||
@@ -142,6 +142,11 @@ function _acf_log_escaped_html( $function, $selector, $field, $post_id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the notice has been dismissed, don't log further errors.
|
||||
if ( get_option( 'acf_escaped_html_notice_dismissed' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the field isn't set, we've output a non-ACF field, so don't log anything.
|
||||
if ( ! is_array( $field ) ) {
|
||||
return;
|
||||
@@ -191,7 +196,7 @@ function _acf_get_escaped_html_log() {
|
||||
* @return boolean True on success, or false on failure.
|
||||
*/
|
||||
function _acf_update_escaped_html_log( $escaped = array() ) {
|
||||
return update_option( 'acf_escaped_html_log', (array) $escaped, true );
|
||||
return update_option( 'acf_escaped_html_log', (array) $escaped, false );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,7 +112,7 @@ if ( ! class_exists( 'ACF_Assets' ) ) :
|
||||
|
||||
// Register scripts.
|
||||
wp_register_script( 'acf', acf_get_url( 'assets/build/js/acf' . $suffix . '.js' ), array( 'jquery' ), $version );
|
||||
wp_register_script( 'acf-input', acf_get_url( 'assets/build/js/acf-input' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-resizable', 'acf' ), $version );
|
||||
wp_register_script( 'acf-input', acf_get_url( 'assets/build/js/acf-input' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-resizable', 'acf', 'wp-a11y' ), $version );
|
||||
wp_register_script( 'acf-field-group', acf_get_url( 'assets/build/js/acf-field-group' . $suffix . '.js' ), array( 'acf-input' ), $version );
|
||||
wp_register_script( 'acf-internal-post-type', acf_get_url( 'assets/build/js/acf-internal-post-type' . $suffix . '.js' ), array( 'acf-input' ), $version );
|
||||
wp_register_script( 'acf-escaped-html-notice', acf_get_url( 'assets/build/js/acf-escaped-html-notice' . $suffix . '.js' ), array( 'jquery' ), $version, true );
|
||||
@@ -369,6 +369,9 @@ if ( ! class_exists( 'ACF_Assets' ) ) :
|
||||
'1 field requires attention' => __( '1 field requires attention', 'acf' ),
|
||||
'%d fields require attention' => __( '%d fields require attention', 'acf' ),
|
||||
|
||||
// Block Validation
|
||||
'An ACF Block on this page requires attention before you can save.' => __( 'An ACF Block on this page requires attention before you can save.', 'acf' ),
|
||||
|
||||
// Other
|
||||
'Edit field group' => __( 'Edit field group', 'acf' ),
|
||||
)
|
||||
@@ -472,6 +475,7 @@ if ( ! class_exists( 'ACF_Assets' ) ) :
|
||||
'validation' => acf_get_form_data( 'validation' ),
|
||||
'editor' => acf_is_block_editor() ? 'block' : 'classic',
|
||||
'is_pro' => acf_is_pro(),
|
||||
'debug' => acf_is_beta() || defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG,
|
||||
);
|
||||
|
||||
acf_localize_data( $data_to_localize );
|
||||
|
||||
@@ -0,0 +1,714 @@
|
||||
<?php
|
||||
/**
|
||||
* Adds helpful debugging information to a new "Advanced Custom Fields"
|
||||
* panel in the WordPress Site Health screen.
|
||||
*
|
||||
* @package ACF
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'ACF_Site_Health' ) ) {
|
||||
|
||||
/**
|
||||
* The ACF Site Health class responsible for populating ACF debug information in WordPress Site Health.
|
||||
*/
|
||||
class ACF_Site_Health {
|
||||
/**
|
||||
* The option name used to store site health data.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public string $option_name = 'acf_site_health';
|
||||
|
||||
/**
|
||||
* Constructs the ACF_Site_Health class.
|
||||
*
|
||||
* @since 6.3
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'debug_information', array( $this, 'render_tab_content' ) );
|
||||
add_action( 'acf_update_site_health_data', array( $this, 'update_site_health_data' ) );
|
||||
|
||||
if ( ! wp_next_scheduled( 'acf_update_site_health_data' ) ) {
|
||||
wp_schedule_event( time(), 'weekly', 'acf_update_site_health_data' );
|
||||
}
|
||||
|
||||
// ACF events.
|
||||
add_action( 'acf/first_activated', array( $this, 'add_activation_event' ) );
|
||||
add_action( 'acf/activated_pro', array( $this, 'add_activation_event' ) );
|
||||
add_filter( 'acf/pre_update_field_group', array( $this, 'pre_update_acf_internal_cpt' ) );
|
||||
add_filter( 'acf/pre_update_post_type', array( $this, 'pre_update_acf_internal_cpt' ) );
|
||||
add_filter( 'acf/pre_update_taxonomy', array( $this, 'pre_update_acf_internal_cpt' ) );
|
||||
add_filter( 'acf/pre_update_ui_options_page', array( $this, 'pre_update_acf_internal_cpt' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the stored site health information.
|
||||
*
|
||||
* @since 6.3
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_site_health(): array {
|
||||
$site_health = get_option( $this->option_name, '' );
|
||||
|
||||
if ( is_string( $site_health ) ) {
|
||||
$site_health = json_decode( $site_health, true );
|
||||
}
|
||||
|
||||
return is_array( $site_health ) ? $site_health : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the site health information.
|
||||
*
|
||||
* @since 6.3
|
||||
*
|
||||
* @param array $data An array of site health information to update.
|
||||
* @return boolean
|
||||
*/
|
||||
public function update_site_health( array $data = array() ): bool {
|
||||
return update_option( $this->option_name, wp_json_encode( $data ), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores debug data in the ACF site health option.
|
||||
*
|
||||
* @since 6.3
|
||||
*
|
||||
* @param array $data Data to update with (optional).
|
||||
* @return boolean
|
||||
*/
|
||||
public function update_site_health_data( array $data = array() ): bool {
|
||||
if ( wp_doing_cron() ) {
|
||||
// Bootstrap wp-admin, as WP_Cron doesn't do this for us.
|
||||
require_once trailingslashit( ABSPATH ) . 'wp-admin/includes/admin.php';
|
||||
}
|
||||
|
||||
$site_health = $this->get_site_health();
|
||||
$values = ! empty( $data ) ? $data : $this->get_site_health_values();
|
||||
$updated = array();
|
||||
|
||||
if ( ! empty( $values ) ) {
|
||||
foreach ( $values as $key => $value ) {
|
||||
$updated[ $key ] = $value['debug'] ?? $value['value'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $site_health as $key => $value ) {
|
||||
if ( 'event_' === substr( $key, 0, 6 ) ) {
|
||||
$updated[ $key ] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$updated['last_updated'] = time();
|
||||
|
||||
return $this->update_site_health( $updated );
|
||||
}
|
||||
|
||||
/**
|
||||
* Pushes an event to the ACF site health option.
|
||||
*
|
||||
* @since 6.3
|
||||
*
|
||||
* @param string $event_name The name of the event to push.
|
||||
* @return boolean
|
||||
*/
|
||||
public function add_site_health_event( string $event_name = '' ): bool {
|
||||
$site_health = $this->get_site_health();
|
||||
|
||||
// Allow using action/filter hooks to set events.
|
||||
if ( empty( $event_name ) ) {
|
||||
$current_filter = current_filter();
|
||||
|
||||
if ( strpos( $current_filter, 'acf/' ) !== false ) {
|
||||
$event_name = str_replace( 'acf/', '', $current_filter );
|
||||
}
|
||||
}
|
||||
|
||||
// Bail if this event was already stored.
|
||||
if ( empty( $event_name ) || ! empty( $site_health[ 'event_' . $event_name ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$time = time();
|
||||
|
||||
$site_health[ 'event_' . $event_name ] = $time;
|
||||
$site_health['last_updated'] = $time;
|
||||
|
||||
return $this->update_site_health( $site_health );
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs activation events for free/pro.
|
||||
*
|
||||
* @since 6.3
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function add_activation_event() {
|
||||
$event_name = 'first_activated';
|
||||
|
||||
if ( acf_is_pro() ) {
|
||||
$event_name = 'first_activated_pro';
|
||||
|
||||
if ( 'acf/first_activated' !== current_filter() ) {
|
||||
$site_health = $this->get_site_health();
|
||||
|
||||
/**
|
||||
* We already have an event for when pro was first activated,
|
||||
* so we don't need to log an additional event here.
|
||||
*/
|
||||
if ( ! empty( $site_health[ 'event_' . $event_name ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$event_name = 'activated_pro';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->add_site_health_event( $event_name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds events when ACF internal post types are created.
|
||||
*
|
||||
* @since 6.3
|
||||
*
|
||||
* @param array $post The post about to be updated.
|
||||
* @return array
|
||||
*/
|
||||
public function pre_update_acf_internal_cpt( array $post = array() ): array {
|
||||
if ( empty( $post['key'] ) ) {
|
||||
return $post;
|
||||
}
|
||||
|
||||
$post_type = acf_determine_internal_post_type( $post['key'] );
|
||||
|
||||
if ( $post_type ) {
|
||||
$posts = acf_get_internal_post_type_posts( $post_type );
|
||||
|
||||
if ( empty( $posts ) ) {
|
||||
$post_type = str_replace(
|
||||
array(
|
||||
'acf-',
|
||||
'-',
|
||||
),
|
||||
array(
|
||||
'',
|
||||
'_',
|
||||
),
|
||||
$post_type
|
||||
);
|
||||
$this->add_site_health_event( 'first_created_' . $post_type );
|
||||
}
|
||||
}
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the ACF section to the "Info" tab of the WordPress Site Health screen.
|
||||
*
|
||||
* @since 6.3
|
||||
*
|
||||
* @param array $debug_info The current debug info for site health.
|
||||
* @return array The debug info appended with the ACF section.
|
||||
*/
|
||||
public function render_tab_content( array $debug_info ): array {
|
||||
$data = $this->get_site_health_values();
|
||||
|
||||
$this->update_site_health_data( $data );
|
||||
|
||||
// Unset values we don't want to display yet.
|
||||
$fields_to_unset = array(
|
||||
'wp_version',
|
||||
'mysql_version',
|
||||
'is_multisite',
|
||||
'active_theme',
|
||||
'parent_theme',
|
||||
'active_plugins',
|
||||
'number_of_fields_by_type',
|
||||
'number_of_third_party_fields_by_type',
|
||||
);
|
||||
|
||||
foreach ( $fields_to_unset as $field ) {
|
||||
if ( isset( $data[ $field ] ) ) {
|
||||
unset( $data[ $field ] );
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $data as $key => $value ) {
|
||||
if ( 'event_' === substr( $key, 0, 6 ) ) {
|
||||
unset( $data[ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
$debug_info['acf'] = array(
|
||||
'label' => __( 'ACF', 'acf' ),
|
||||
'description' => __( 'This section contains debug information about your ACF configuration which can be useful to provide to support.', 'acf' ),
|
||||
'fields' => $data,
|
||||
);
|
||||
|
||||
return $debug_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the values for all data in the ACF site health section.
|
||||
*
|
||||
* @since 6.3
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_site_health_values(): array {
|
||||
global $wpdb;
|
||||
|
||||
$fields = array();
|
||||
$is_pro = acf_is_pro();
|
||||
$license = $is_pro ? acf_pro_get_license() : array();
|
||||
$license_status = $is_pro ? acf_pro_get_license_status() : array();
|
||||
$field_groups = acf_get_field_groups();
|
||||
$post_types = acf_get_post_types();
|
||||
$taxonomies = acf_get_taxonomies();
|
||||
|
||||
$yes = __( 'Yes', 'acf' );
|
||||
$no = __( 'No', 'acf' );
|
||||
|
||||
$fields['version'] = array(
|
||||
'label' => __( 'Plugin Version', 'acf' ),
|
||||
'value' => defined( 'ACF_VERSION' ) ? ACF_VERSION : '',
|
||||
);
|
||||
|
||||
$fields['plugin_type'] = array(
|
||||
'label' => __( 'Plugin Type', 'acf' ),
|
||||
'value' => $is_pro ? __( 'PRO', 'acf' ) : __( 'Free', 'acf' ),
|
||||
'debug' => $is_pro ? 'PRO' : 'Free',
|
||||
);
|
||||
|
||||
if ( $is_pro ) {
|
||||
$fields['activated'] = array(
|
||||
'label' => __( 'License Activated', 'acf' ),
|
||||
'value' => ! empty( $license ) ? $yes : $no,
|
||||
'debug' => ! empty( $license ),
|
||||
);
|
||||
|
||||
$fields['activated_url'] = array(
|
||||
'label' => __( 'Licensed URL', 'acf' ),
|
||||
'value' => ! empty( $license['url'] ) ? $license['url'] : '',
|
||||
);
|
||||
|
||||
$fields['license_type'] = array(
|
||||
'label' => __( 'License Type', 'acf' ),
|
||||
'value' => $license_status['name'],
|
||||
);
|
||||
|
||||
$fields['license_status'] = array(
|
||||
'label' => __( 'License Status', 'acf' ),
|
||||
'value' => $license_status['status'],
|
||||
);
|
||||
|
||||
$expiry = ! empty( $license_status['expiry'] ) ? $license_status['expiry'] : '';
|
||||
$format = get_option( 'date_format', 'F j, Y' );
|
||||
|
||||
$fields['subscription_expires'] = array(
|
||||
'label' => __( 'Subscription Expiry Date', 'acf' ),
|
||||
'value' => is_numeric( $expiry ) ? date_i18n( $format, $expiry ) : '',
|
||||
'debug' => $expiry,
|
||||
);
|
||||
}
|
||||
|
||||
$fields['wp_version'] = array(
|
||||
'label' => __( 'WordPress Version', 'acf' ),
|
||||
'value' => get_bloginfo( 'version' ),
|
||||
);
|
||||
|
||||
$fields['mysql_version'] = array(
|
||||
'label' => __( 'MySQL Version', 'acf' ),
|
||||
'value' => $wpdb->db_server_info(),
|
||||
);
|
||||
|
||||
$fields['is_multisite'] = array(
|
||||
'label' => __( 'Is Multisite', 'acf' ),
|
||||
'value' => is_multisite() ? __( 'Yes', 'acf' ) : __( 'No', 'acf' ),
|
||||
'debug' => is_multisite(),
|
||||
);
|
||||
|
||||
$active_theme = wp_get_theme();
|
||||
$parent_theme = $active_theme->parent();
|
||||
|
||||
$fields['active_theme'] = array(
|
||||
'label' => __( 'Active Theme', 'acf' ),
|
||||
'value' => array(
|
||||
'name' => $active_theme->get( 'Name' ),
|
||||
'version' => $active_theme->get( 'Version' ),
|
||||
'theme_uri' => $active_theme->get( 'ThemeURI' ),
|
||||
'stylesheet' => $active_theme->get( 'Stylesheet' ),
|
||||
),
|
||||
);
|
||||
|
||||
if ( $parent_theme ) {
|
||||
$fields['parent_theme'] = array(
|
||||
'label' => __( 'Parent Theme', 'acf' ),
|
||||
'value' => array(
|
||||
'name' => $parent_theme->get( 'Name' ),
|
||||
'version' => $parent_theme->get( 'Version' ),
|
||||
'theme_uri' => $parent_theme->get( 'ThemeURI' ),
|
||||
'stylesheet' => $parent_theme->get( 'Stylesheet' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$active_plugins = array();
|
||||
$plugins = get_plugins();
|
||||
|
||||
foreach ( $plugins as $plugin_path => $plugin ) {
|
||||
if ( ! is_plugin_active( $plugin_path ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$active_plugins[ $plugin_path ] = array(
|
||||
'name' => $plugin['Name'],
|
||||
'version' => $plugin['Version'],
|
||||
'plugin_uri' => empty( $plugin['PluginURI'] ) ? '' : $plugin['PluginURI'],
|
||||
);
|
||||
}
|
||||
|
||||
$fields['active_plugins'] = array(
|
||||
'label' => __( 'Active Plugins', 'acf' ),
|
||||
'value' => $active_plugins,
|
||||
);
|
||||
|
||||
$ui_field_groups = array_filter(
|
||||
$field_groups,
|
||||
function ( $field_group ) {
|
||||
return empty( $field_group['local'] );
|
||||
}
|
||||
);
|
||||
|
||||
$fields['ui_field_groups'] = array(
|
||||
'label' => __( 'Registered Field Groups (UI)', 'acf' ),
|
||||
'value' => number_format_i18n( count( $ui_field_groups ) ),
|
||||
);
|
||||
|
||||
$php_field_groups = array_filter(
|
||||
$field_groups,
|
||||
function ( $field_group ) {
|
||||
return ! empty( $field_group['local'] ) && 'PHP' === $field_group['local'];
|
||||
}
|
||||
);
|
||||
|
||||
$fields['php_field_groups'] = array(
|
||||
'label' => __( 'Registered Field Groups (PHP)', 'acf' ),
|
||||
'value' => number_format_i18n( count( $php_field_groups ) ),
|
||||
);
|
||||
|
||||
$json_field_groups = array_filter(
|
||||
$field_groups,
|
||||
function ( $field_group ) {
|
||||
return ! empty( $field_group['local'] ) && 'json' === $field_group['local'];
|
||||
}
|
||||
);
|
||||
|
||||
$fields['json_field_groups'] = array(
|
||||
'label' => __( 'Registered Field Groups (JSON)', 'acf' ),
|
||||
'value' => number_format_i18n( count( $json_field_groups ) ),
|
||||
);
|
||||
|
||||
$rest_field_groups = array_filter(
|
||||
$field_groups,
|
||||
function ( $field_group ) {
|
||||
return ! empty( $field_group['show_in_rest'] );
|
||||
}
|
||||
);
|
||||
|
||||
$fields['rest_field_groups'] = array(
|
||||
'label' => __( 'Field Groups Enabled for REST API', 'acf' ),
|
||||
'value' => number_format_i18n( count( $rest_field_groups ) ),
|
||||
);
|
||||
|
||||
$graphql_field_groups = array_filter(
|
||||
$field_groups,
|
||||
function ( $field_group ) {
|
||||
return ! empty( $field_group['show_in_graphql'] );
|
||||
}
|
||||
);
|
||||
|
||||
if ( is_plugin_active( 'wpgraphql-acf/wpgraphql-acf.php' ) ) {
|
||||
$fields['graphql_field_groups'] = array(
|
||||
'label' => __( 'Field Groups Enabled for GraphQL', 'acf' ),
|
||||
'value' => number_format_i18n( count( $graphql_field_groups ) ),
|
||||
);
|
||||
}
|
||||
|
||||
$all_fields = array();
|
||||
foreach ( $field_groups as $field_group ) {
|
||||
$all_fields = array_merge( $all_fields, acf_get_fields( $field_group ) );
|
||||
}
|
||||
|
||||
$fields_by_type = array();
|
||||
$third_party_fields_by_type = array();
|
||||
$core_field_types = array_keys( acf_get_field_types() );
|
||||
|
||||
foreach ( $all_fields as $field ) {
|
||||
if ( in_array( $field['type'], $core_field_types, true ) ) {
|
||||
if ( ! isset( $fields_by_type[ $field['type'] ] ) ) {
|
||||
$fields_by_type[ $field['type'] ] = 0;
|
||||
}
|
||||
|
||||
++$fields_by_type[ $field['type'] ];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! isset( $third_party_fields_by_type[ $field['type'] ] ) ) {
|
||||
$third_party_fields_by_type[ $field['type'] ] = 0;
|
||||
}
|
||||
|
||||
++$third_party_fields_by_type[ $field['type'] ];
|
||||
}
|
||||
|
||||
$fields['number_of_fields_by_type'] = array(
|
||||
'label' => __( 'Number of Fields by Field Type', 'acf' ),
|
||||
'value' => $fields_by_type,
|
||||
);
|
||||
|
||||
$fields['number_of_third_party_fields_by_type'] = array(
|
||||
'label' => __( 'Number of Third Party Fields by Field Type', 'acf' ),
|
||||
'value' => $third_party_fields_by_type,
|
||||
);
|
||||
|
||||
$enable_post_types = acf_get_setting( 'enable_post_types' );
|
||||
|
||||
$fields['post_types_enabled'] = array(
|
||||
'label' => __( 'Post Types and Taxonomies Enabled', 'acf' ),
|
||||
'value' => $enable_post_types ? $yes : $no,
|
||||
'debug' => $enable_post_types,
|
||||
);
|
||||
|
||||
$ui_post_types = array_filter(
|
||||
$post_types,
|
||||
function ( $post_type ) {
|
||||
return empty( $post_type['local'] );
|
||||
}
|
||||
);
|
||||
|
||||
$fields['ui_post_types'] = array(
|
||||
'label' => __( 'Registered Post Types (UI)', 'acf' ),
|
||||
'value' => number_format_i18n( count( $ui_post_types ) ),
|
||||
);
|
||||
|
||||
$json_post_types = array_filter(
|
||||
$post_types,
|
||||
function ( $post_type ) {
|
||||
return ! empty( $post_type['local'] ) && 'json' === $post_type['local'];
|
||||
}
|
||||
);
|
||||
|
||||
$fields['json_post_types'] = array(
|
||||
'label' => __( 'Registered Post Types (JSON)', 'acf' ),
|
||||
'value' => number_format_i18n( count( $json_post_types ) ),
|
||||
);
|
||||
|
||||
$ui_taxonomies = array_filter(
|
||||
$taxonomies,
|
||||
function ( $taxonomy ) {
|
||||
return empty( $taxonomy['local'] );
|
||||
}
|
||||
);
|
||||
|
||||
$fields['ui_taxonomies'] = array(
|
||||
'label' => __( 'Registered Taxonomies (UI)', 'acf' ),
|
||||
'value' => number_format_i18n( count( $ui_taxonomies ) ),
|
||||
);
|
||||
|
||||
$json_taxonomies = array_filter(
|
||||
$taxonomies,
|
||||
function ( $taxonomy ) {
|
||||
return ! empty( $taxonomy['local'] ) && 'json' === $taxonomy['local'];
|
||||
}
|
||||
);
|
||||
|
||||
$fields['json_taxonomies'] = array(
|
||||
'label' => __( 'Registered Taxonomies (JSON)', 'acf' ),
|
||||
'value' => number_format_i18n( count( $json_taxonomies ) ),
|
||||
);
|
||||
|
||||
if ( $is_pro ) {
|
||||
$enable_options_pages_ui = acf_get_setting( 'enable_options_pages_ui' );
|
||||
|
||||
$fields['ui_options_pages_enabled'] = array(
|
||||
'label' => __( 'Options Pages UI Enabled', 'acf' ),
|
||||
'value' => $enable_options_pages_ui ? $yes : $no,
|
||||
'debug' => $enable_options_pages_ui,
|
||||
);
|
||||
|
||||
$options_pages = acf_get_options_pages();
|
||||
$ui_options_pages = array();
|
||||
|
||||
if ( empty( $options_pages ) || ! is_array( $options_pages ) ) {
|
||||
$options_pages = array();
|
||||
}
|
||||
|
||||
if ( $enable_options_pages_ui ) {
|
||||
$ui_options_pages = acf_get_ui_options_pages();
|
||||
|
||||
$ui_options_pages_in_ui = array_filter(
|
||||
$ui_options_pages,
|
||||
function ( $ui_options_page ) {
|
||||
return empty( $ui_options_page['local'] );
|
||||
}
|
||||
);
|
||||
|
||||
$json_options_pages = array_filter(
|
||||
$ui_options_pages,
|
||||
function ( $ui_options_page ) {
|
||||
return ! empty( $ui_options_page['local'] );
|
||||
}
|
||||
);
|
||||
|
||||
$fields['ui_options_pages'] = array(
|
||||
'label' => __( 'Registered Options Pages (UI)', 'acf' ),
|
||||
'value' => number_format_i18n( count( $ui_options_pages_in_ui ) ),
|
||||
);
|
||||
|
||||
$fields['json_options_pages'] = array(
|
||||
'label' => __( 'Registered Options Pages (JSON)', 'acf' ),
|
||||
'value' => number_format_i18n( count( $json_options_pages ) ),
|
||||
);
|
||||
}
|
||||
|
||||
$ui_options_page_slugs = array_column( $ui_options_pages, 'menu_slug' );
|
||||
$php_options_pages = array_filter(
|
||||
$options_pages,
|
||||
function ( $options_page ) use ( $ui_options_page_slugs ) {
|
||||
return ! in_array( $options_page['menu_slug'], $ui_options_page_slugs, true );
|
||||
}
|
||||
);
|
||||
|
||||
$fields['php_options_pages'] = array(
|
||||
'label' => __( 'Registered Options Pages (PHP)', 'acf' ),
|
||||
'value' => number_format_i18n( count( $php_options_pages ) ),
|
||||
);
|
||||
}
|
||||
|
||||
$rest_api_format = acf_get_setting( 'rest_api_format' );
|
||||
|
||||
$fields['rest_api_format'] = array(
|
||||
'label' => __( 'REST API Format', 'acf' ),
|
||||
'value' => 'standard' === $rest_api_format ? __( 'Standard', 'acf' ) : __( 'Light', 'acf' ),
|
||||
'debug' => $rest_api_format,
|
||||
);
|
||||
|
||||
if ( $is_pro ) {
|
||||
$fields['registered_acf_blocks'] = array(
|
||||
'label' => __( 'Registered ACF Blocks', 'acf' ),
|
||||
'value' => number_format_i18n( acf_pro_get_registered_block_count() ),
|
||||
);
|
||||
|
||||
$blocks = acf_get_block_types();
|
||||
$block_api_versions = array();
|
||||
$acf_block_versions = array();
|
||||
$blocks_using_post_meta = 0;
|
||||
|
||||
foreach ( $blocks as $block ) {
|
||||
if ( ! isset( $block_api_versions[ 'v' . $block['api_version'] ] ) ) {
|
||||
$block_api_versions[ 'v' . $block['api_version'] ] = 0;
|
||||
}
|
||||
|
||||
if ( ! isset( $acf_block_versions[ 'v' . $block['acf_block_version'] ] ) ) {
|
||||
$acf_block_versions[ 'v' . $block['acf_block_version'] ] = 0;
|
||||
}
|
||||
|
||||
if ( ! empty( $block['use_post_meta'] ) ) {
|
||||
++$blocks_using_post_meta;
|
||||
}
|
||||
|
||||
++$block_api_versions[ 'v' . $block['api_version'] ];
|
||||
++$acf_block_versions[ 'v' . $block['acf_block_version'] ];
|
||||
}
|
||||
|
||||
$fields['blocks_per_api_version'] = array(
|
||||
'label' => __( 'Blocks Per API Version', 'acf' ),
|
||||
'value' => $block_api_versions,
|
||||
);
|
||||
|
||||
$fields['blocks_per_acf_block_version'] = array(
|
||||
'label' => __( 'Blocks Per ACF Block Version', 'acf' ),
|
||||
'value' => $acf_block_versions,
|
||||
);
|
||||
|
||||
$fields['blocks_using_post_meta'] = array(
|
||||
'label' => __( 'Blocks Using Post Meta', 'acf' ),
|
||||
'value' => number_format_i18n( $blocks_using_post_meta ),
|
||||
);
|
||||
|
||||
$preload_blocks = acf_get_setting( 'preload_blocks' );
|
||||
|
||||
$fields['preload_blocks'] = array(
|
||||
'label' => __( 'Block Preloading Enabled', 'acf' ),
|
||||
'value' => ! empty( $preload_blocks ) ? $yes : $no,
|
||||
'debug' => $preload_blocks,
|
||||
);
|
||||
}
|
||||
|
||||
$show_admin = acf_get_setting( 'show_admin' );
|
||||
|
||||
$fields['admin_ui_enabled'] = array(
|
||||
'label' => __( 'Admin UI Enabled', 'acf' ),
|
||||
'value' => $show_admin ? $yes : $no,
|
||||
'debug' => $show_admin,
|
||||
);
|
||||
|
||||
$field_type_modal_enabled = apply_filters( 'acf/field_group/enable_field_browser', true );
|
||||
|
||||
$fields['field_type-modal_enabled'] = array(
|
||||
'label' => __( 'Field Type Modal Enabled', 'acf' ),
|
||||
'value' => ! empty( $field_type_modal_enabled ) ? $yes : $no,
|
||||
'debug' => $field_type_modal_enabled,
|
||||
);
|
||||
|
||||
$field_settings_tabs_enabled = apply_filters( 'acf/field_group/disable_field_settings_tabs', false );
|
||||
|
||||
$fields['field_settings_tabs_enabled'] = array(
|
||||
'label' => __( 'Field Settings Tabs Enabled', 'acf' ),
|
||||
'value' => empty( $field_settings_tabs_enabled ) ? $yes : $no,
|
||||
'debug' => $field_settings_tabs_enabled,
|
||||
);
|
||||
|
||||
$shortcode_enabled = acf_get_setting( 'enable_shortcode' );
|
||||
|
||||
$fields['shortcode_enabled'] = array(
|
||||
'label' => __( 'Shortcode Enabled', 'acf' ),
|
||||
'value' => ! empty( $shortcode_enabled ) ? $yes : $no,
|
||||
'debug' => $shortcode_enabled,
|
||||
);
|
||||
|
||||
$fields['registered_acf_forms'] = array(
|
||||
'label' => __( 'Registered ACF Forms', 'acf' ),
|
||||
'value' => number_format_i18n( count( acf_get_forms() ) ),
|
||||
);
|
||||
|
||||
$local_json = acf_get_instance( 'ACF_Local_JSON' );
|
||||
$save_paths = $local_json->get_save_paths();
|
||||
$load_paths = $local_json->get_load_paths();
|
||||
|
||||
$fields['json_save_paths'] = array(
|
||||
'label' => __( 'JSON Save Paths', 'acf' ),
|
||||
'value' => number_format_i18n( count( $save_paths ) ),
|
||||
'debug' => count( $save_paths ),
|
||||
);
|
||||
|
||||
$fields['json_load_paths'] = array(
|
||||
'label' => __( 'JSON Load Paths', 'acf' ),
|
||||
'value' => number_format_i18n( count( $load_paths ) ),
|
||||
'debug' => count( $load_paths ),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
}
|
||||
|
||||
acf_new_instance( 'ACF_Site_Health' );
|
||||
}
|
||||
@@ -22,36 +22,31 @@ if ( ! class_exists( 'acf_fields' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function will register a field type instance
|
||||
* This function will register a field type instance based on a class name or instance.
|
||||
* It will return the instance for further use.
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $class (string)
|
||||
* @return n/a
|
||||
* @param mixed $field_class Either a class name (string) or instance of acf_field.
|
||||
* @return acf_field The instance of acf_field.
|
||||
*/
|
||||
|
||||
function register_field_type( $class ) {
|
||||
|
||||
// allow instance
|
||||
if ( $class instanceof acf_field ) {
|
||||
$this->types[ $class->name ] = $class;
|
||||
|
||||
// allow class name
|
||||
} else {
|
||||
$instance = new $class();
|
||||
$this->types[ $instance->name ] = $instance;
|
||||
public function register_field_type( $field_class ) {
|
||||
// Allow registering an instance.
|
||||
if ( $field_class instanceof acf_field ) {
|
||||
$this->types[ $field_class->name ] = $field_class;
|
||||
return $field_class;
|
||||
}
|
||||
}
|
||||
|
||||
// Allow registering a loaded class name.
|
||||
$instance = new $field_class();
|
||||
$this->types[ $instance->name ] = $instance;
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will return a field type instance
|
||||
@@ -63,7 +58,6 @@ if ( ! class_exists( 'acf_fields' ) ) :
|
||||
* @param $name (string)
|
||||
* @return (mixed)
|
||||
*/
|
||||
|
||||
function get_field_type( $name ) {
|
||||
return isset( $this->types[ $name ] ) ? $this->types[ $name ] : null;
|
||||
}
|
||||
@@ -79,7 +73,6 @@ if ( ! class_exists( 'acf_fields' ) ) :
|
||||
* @param $name (string)
|
||||
* @return (mixed)
|
||||
*/
|
||||
|
||||
function is_field_type( $name ) {
|
||||
return isset( $this->types[ $name ] );
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
@@ -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 );
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
/*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 = '';
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -24,7 +24,6 @@ if ( ! class_exists( 'acf_form_attachment' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
@@ -49,7 +48,6 @@ if ( ! class_exists( 'acf_form_attachment' ) ) :
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function admin_enqueue_scripts() {
|
||||
|
||||
// bail early if not valid screen
|
||||
@@ -81,7 +79,6 @@ if ( ! class_exists( 'acf_form_attachment' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_footer() {
|
||||
|
||||
// render post data
|
||||
@@ -113,7 +110,6 @@ acf.unload.active = 0;
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function edit_attachment( $form_fields, $post ) {
|
||||
|
||||
// vars
|
||||
@@ -189,7 +185,6 @@ acf.unload.active = 0;
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function save_attachment( $post, $attachment ) {
|
||||
|
||||
// bail early if not valid nonce
|
||||
|
||||
@@ -24,7 +24,6 @@ if ( ! class_exists( 'acf_form_comment' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
@@ -51,7 +50,6 @@ if ( ! class_exists( 'acf_form_comment' ) ) :
|
||||
* @param n/a
|
||||
* @return (boolean)
|
||||
*/
|
||||
|
||||
function validate_page() {
|
||||
|
||||
// global
|
||||
@@ -78,7 +76,6 @@ if ( ! class_exists( 'acf_form_comment' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_enqueue_scripts() {
|
||||
|
||||
// validate page
|
||||
@@ -105,7 +102,6 @@ if ( ! class_exists( 'acf_form_comment' ) ) :
|
||||
* @param $comment (object)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function edit_comment( $comment ) {
|
||||
|
||||
// vars
|
||||
@@ -177,7 +173,6 @@ if ( ! class_exists( 'acf_form_comment' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function comment_form_field_comment( $html ) {
|
||||
|
||||
// global
|
||||
@@ -241,7 +236,6 @@ if ( ! class_exists( 'acf_form_comment' ) ) :
|
||||
* @param comment_id (int)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function save_comment( $comment_id ) {
|
||||
|
||||
// bail early if not valid nonce
|
||||
@@ -271,7 +265,6 @@ if ( ! class_exists( 'acf_form_comment' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function admin_footer() {
|
||||
|
||||
?>
|
||||
|
||||
@@ -19,7 +19,6 @@ if ( ! class_exists( 'acf_form_customizer' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// vars
|
||||
@@ -48,7 +47,6 @@ if ( ! class_exists( 'acf_form_customizer' ) ) :
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function customize_controls_init() {
|
||||
|
||||
// load acf scripts
|
||||
@@ -76,7 +74,6 @@ if ( ! class_exists( 'acf_form_customizer' ) ) :
|
||||
* @param $widget (object) widget info
|
||||
* @return $instance
|
||||
*/
|
||||
|
||||
function save_widget( $instance, $new_instance, $old_instance, $widget ) {
|
||||
|
||||
// bail early if not valid (customize + acf values + nonce)
|
||||
@@ -128,7 +125,6 @@ if ( ! class_exists( 'acf_form_customizer' ) ) :
|
||||
* @param $customizer (object)
|
||||
* @return $value (mixed)
|
||||
*/
|
||||
|
||||
function settings( $customizer ) {
|
||||
|
||||
// vars
|
||||
@@ -188,7 +184,6 @@ if ( ! class_exists( 'acf_form_customizer' ) ) :
|
||||
* @param $customizer (object)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function customize_preview_init( $customizer ) {
|
||||
|
||||
// get customizer settings (widgets)
|
||||
@@ -231,7 +226,6 @@ if ( ! class_exists( 'acf_form_customizer' ) ) :
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
function pre_load_value( $value, $post_id, $field ) {
|
||||
|
||||
// check
|
||||
@@ -254,7 +248,6 @@ if ( ! class_exists( 'acf_form_customizer' ) ) :
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
function pre_load_reference( $field_key, $field_name, $post_id ) {
|
||||
|
||||
// check
|
||||
@@ -279,7 +272,6 @@ if ( ! class_exists( 'acf_form_customizer' ) ) :
|
||||
* @param $customizer (object)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function customize_save( $customizer ) {
|
||||
|
||||
// get customizer settings (widgets)
|
||||
@@ -316,7 +308,6 @@ if ( ! class_exists( 'acf_form_customizer' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function pre_update_option( $value, $option, $old_value ) {
|
||||
|
||||
// bail early if no value
|
||||
@@ -352,7 +343,6 @@ if ( ! class_exists( 'acf_form_customizer' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_footer() {
|
||||
|
||||
?>
|
||||
|
||||
@@ -25,7 +25,6 @@ if ( ! class_exists( 'acf_form_front' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// vars
|
||||
@@ -78,7 +77,6 @@ if ( ! class_exists( 'acf_form_front' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function validate_form( $args ) {
|
||||
|
||||
// defaults
|
||||
@@ -154,7 +152,6 @@ if ( ! class_exists( 'acf_form_front' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function add_form( $args = array() ) {
|
||||
|
||||
// validate
|
||||
@@ -175,7 +172,6 @@ if ( ! class_exists( 'acf_form_front' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function get_form( $id = '' ) {
|
||||
|
||||
// bail early if not set
|
||||
@@ -187,6 +183,9 @@ if ( ! class_exists( 'acf_form_front' ) ) :
|
||||
return $this->forms[ $id ];
|
||||
}
|
||||
|
||||
function get_forms() {
|
||||
return $this->forms;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will validate fields from the above array
|
||||
@@ -198,7 +197,6 @@ if ( ! class_exists( 'acf_form_front' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function validate_save_post() {
|
||||
|
||||
// register field if isset in $_POST
|
||||
@@ -231,7 +229,6 @@ if ( ! class_exists( 'acf_form_front' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function pre_save_post( $post_id, $form ) {
|
||||
|
||||
// vars
|
||||
@@ -298,7 +295,6 @@ if ( ! class_exists( 'acf_form_front' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function enqueue_form() {
|
||||
|
||||
// check
|
||||
@@ -319,7 +315,6 @@ if ( ! class_exists( 'acf_form_front' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function check_submit_form() {
|
||||
|
||||
// Verify nonce.
|
||||
@@ -367,7 +362,6 @@ if ( ! class_exists( 'acf_form_front' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function submit_form( $form ) {
|
||||
|
||||
// filter
|
||||
@@ -418,7 +412,6 @@ if ( ! class_exists( 'acf_form_front' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function render_form( $args = array() ) {
|
||||
|
||||
// Vars.
|
||||
@@ -581,6 +574,10 @@ function acf_get_form( $id = '' ) {
|
||||
return acf()->form_front->get_form( $id );
|
||||
}
|
||||
|
||||
function acf_get_forms() {
|
||||
return acf()->form_front->get_forms();
|
||||
}
|
||||
|
||||
function acf_register_form( $args ) {
|
||||
|
||||
acf()->form_front->add_form( $args );
|
||||
|
||||
@@ -19,7 +19,6 @@ if ( ! class_exists( 'ACF_Form_Gutenberg' ) ) :
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// Add actions.
|
||||
|
||||
@@ -18,7 +18,6 @@ if ( ! class_exists( 'acf_form_nav_menu' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
@@ -44,7 +43,6 @@ if ( ! class_exists( 'acf_form_nav_menu' ) ) :
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function admin_enqueue_scripts() {
|
||||
|
||||
// validate screen
|
||||
@@ -71,7 +69,6 @@ if ( ! class_exists( 'acf_form_nav_menu' ) ) :
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
function wp_nav_menu_item_custom_fields( $item_id, $item, $depth, $args, $id = '' ) {
|
||||
|
||||
// vars
|
||||
@@ -136,7 +133,6 @@ if ( ! class_exists( 'acf_form_nav_menu' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function update_nav_menu( $menu_id ) {
|
||||
|
||||
// vars
|
||||
@@ -168,7 +164,6 @@ if ( ! class_exists( 'acf_form_nav_menu' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function update_nav_menu_items( $menu_id ) {
|
||||
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified elsewhere.
|
||||
@@ -198,7 +193,6 @@ if ( ! class_exists( 'acf_form_nav_menu' ) ) :
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
function wp_get_nav_menu_items( $items, $menu, $args ) {
|
||||
acf_set_data( 'nav_menu_id', $menu->term_id );
|
||||
return $items;
|
||||
@@ -235,7 +229,6 @@ if ( ! class_exists( 'acf_form_nav_menu' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_validate_save_post() {
|
||||
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified elsewhere.
|
||||
@@ -266,7 +259,6 @@ if ( ! class_exists( 'acf_form_nav_menu' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_footer() {
|
||||
|
||||
// vars
|
||||
|
||||
@@ -26,7 +26,6 @@ if ( ! class_exists( 'acf_form_taxonomy' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
@@ -51,7 +50,6 @@ if ( ! class_exists( 'acf_form_taxonomy' ) ) :
|
||||
* @param n/a
|
||||
* @return (boolean)
|
||||
*/
|
||||
|
||||
function validate_page() {
|
||||
|
||||
// global
|
||||
@@ -78,7 +76,6 @@ if ( ! class_exists( 'acf_form_taxonomy' ) ) :
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function admin_enqueue_scripts() {
|
||||
|
||||
// validate page
|
||||
@@ -110,7 +107,6 @@ if ( ! class_exists( 'acf_form_taxonomy' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function add_term( $taxonomy ) {
|
||||
|
||||
// vars
|
||||
@@ -162,7 +158,6 @@ if ( ! class_exists( 'acf_form_taxonomy' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function edit_term( $term, $taxonomy ) {
|
||||
|
||||
// vars
|
||||
@@ -214,7 +209,6 @@ if ( ! class_exists( 'acf_form_taxonomy' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function admin_footer() {
|
||||
|
||||
?>
|
||||
@@ -309,7 +303,6 @@ if ( ! class_exists( 'acf_form_taxonomy' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function save_term( $term_id, $tt_id, $taxonomy ) {
|
||||
|
||||
// vars
|
||||
@@ -338,7 +331,6 @@ if ( ! class_exists( 'acf_form_taxonomy' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function delete_term( $term, $tt_id, $taxonomy, $deleted_term ) {
|
||||
|
||||
// bail early if termmeta table exists
|
||||
|
||||
@@ -22,7 +22,6 @@ if ( ! class_exists( 'ACF_Form_User' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// enqueue
|
||||
@@ -55,7 +54,6 @@ if ( ! class_exists( 'ACF_Form_User' ) ) :
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function admin_enqueue_scripts() {
|
||||
|
||||
// bail early if not valid screen
|
||||
@@ -79,7 +77,6 @@ if ( ! class_exists( 'ACF_Form_User' ) ) :
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function login_form_register() {
|
||||
|
||||
// customize action prefix so that "admin_head" = "login_head"
|
||||
@@ -101,7 +98,6 @@ if ( ! class_exists( 'ACF_Form_User' ) ) :
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function render_register() {
|
||||
|
||||
// render
|
||||
@@ -125,7 +121,6 @@ if ( ! class_exists( 'ACF_Form_User' ) ) :
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function render_edit( $user ) {
|
||||
|
||||
// add compatibility with front-end user profile edit forms such as bbPress
|
||||
@@ -154,7 +149,6 @@ if ( ! class_exists( 'ACF_Form_User' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function render_new() {
|
||||
|
||||
// Multisite uses a different 'user-new.php' form. Don't render fields here
|
||||
@@ -184,7 +178,6 @@ if ( ! class_exists( 'ACF_Form_User' ) ) :
|
||||
* @param $el (string)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function render( $args = array() ) {
|
||||
|
||||
// Allow $_POST data to persist across form submission attempts.
|
||||
@@ -268,7 +261,6 @@ if ( ! class_exists( 'ACF_Form_User' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function admin_footer() {
|
||||
|
||||
// script
|
||||
@@ -301,7 +293,6 @@ if ( ! class_exists( 'ACF_Form_User' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function save_user( $user_id ) {
|
||||
|
||||
// verify nonce
|
||||
|
||||
@@ -24,7 +24,6 @@ if ( ! class_exists( 'acf_form_widget' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// vars
|
||||
@@ -53,7 +52,6 @@ if ( ! class_exists( 'acf_form_widget' ) ) :
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function admin_enqueue_scripts() {
|
||||
|
||||
// validate screen
|
||||
@@ -109,7 +107,6 @@ if ( ! class_exists( 'acf_form_widget' ) ) :
|
||||
* @param $instance (object)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function edit_widget( $widget, $return, $instance ) {
|
||||
|
||||
// vars
|
||||
@@ -195,7 +192,6 @@ if ( ! class_exists( 'acf_form_widget' ) ) :
|
||||
* @param $widget (object) widget info
|
||||
* @return $instance
|
||||
*/
|
||||
|
||||
function save_widget( $instance, $new_instance, $old_instance, $widget ) {
|
||||
|
||||
// validate nonce if we're not a REST API request.
|
||||
@@ -229,7 +225,6 @@ if ( ! class_exists( 'acf_form_widget' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_footer() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -365,20 +365,16 @@ if ( ! class_exists( 'ACF_Local_JSON' ) ) :
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves an ACF JSON file.
|
||||
* Gets the filename for an ACF JSON file.
|
||||
*
|
||||
* @date 17/4/20
|
||||
* @since 5.9.0
|
||||
* @since 6.3
|
||||
*
|
||||
* @param string $key The ACF post key.
|
||||
* @param array $post The main ACF post array.
|
||||
* @return boolean
|
||||
* @return string|boolean
|
||||
*/
|
||||
public function save_file( $key, $post ) {
|
||||
$paths = $this->get_save_paths( $key, $post );
|
||||
$file = false;
|
||||
$first_writable = false;
|
||||
$load_path = '';
|
||||
public function get_filename( $key, $post ) {
|
||||
$load_path = '';
|
||||
|
||||
if ( is_array( $this->files ) && isset( $this->files[ $key ] ) ) {
|
||||
$load_path = $this->files[ $key ];
|
||||
@@ -406,6 +402,29 @@ if ( ! class_exists( 'ACF_Local_JSON' ) ) :
|
||||
return false;
|
||||
}
|
||||
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves an ACF JSON file.
|
||||
*
|
||||
* @date 17/4/20
|
||||
* @since 5.9.0
|
||||
*
|
||||
* @param string $key The ACF post key.
|
||||
* @param array $post The main ACF post array.
|
||||
* @return boolean
|
||||
*/
|
||||
public function save_file( $key, $post ) {
|
||||
$paths = $this->get_save_paths( $key, $post );
|
||||
$filename = $this->get_filename( $key, $post );
|
||||
$file = false;
|
||||
$first_writable = false;
|
||||
|
||||
if ( ! $filename ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $paths as $path ) {
|
||||
if ( ! is_writable( $path ) ) { //phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_is_writable -- non-compatible function for this purpose.
|
||||
continue;
|
||||
@@ -462,12 +481,17 @@ if ( ! class_exists( 'ACF_Local_JSON' ) ) :
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete_file( $key, $post = array() ) {
|
||||
$paths = $this->get_save_paths( $key, $post );
|
||||
$paths = $this->get_save_paths( $key, $post );
|
||||
$filename = $this->get_filename( $key, $post );
|
||||
|
||||
if ( ! $filename ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $paths as $path_to_check ) {
|
||||
$file = untrailingslashit( $path_to_check ) . '/' . $key . '.json';
|
||||
$file = untrailingslashit( $path_to_check ) . '/' . $filename;
|
||||
|
||||
if ( wp_is_writable( $file ) ) {
|
||||
if ( is_writable( $file ) ) { //phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_is_writable -- non-compatible function for this purpose.
|
||||
wp_delete_file( $file );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ if ( ! class_exists( 'acf_loop' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// vars
|
||||
@@ -37,7 +36,6 @@ if ( ! class_exists( 'acf_loop' ) ) :
|
||||
* @param n/a
|
||||
* @return (boolean)
|
||||
*/
|
||||
|
||||
function is_empty() {
|
||||
|
||||
return empty( $this->loops );
|
||||
@@ -54,7 +52,6 @@ if ( ! class_exists( 'acf_loop' ) ) :
|
||||
* @param $i (int)
|
||||
* @return (boolean)
|
||||
*/
|
||||
|
||||
function is_loop( $i = 0 ) {
|
||||
|
||||
return isset( $this->loops[ $i ] );
|
||||
@@ -71,7 +68,6 @@ if ( ! class_exists( 'acf_loop' ) ) :
|
||||
* @param $i (mixed)
|
||||
* @return (int)
|
||||
*/
|
||||
|
||||
function get_i( $i = 0 ) {
|
||||
|
||||
// 'active'
|
||||
@@ -104,7 +100,6 @@ if ( ! class_exists( 'acf_loop' ) ) :
|
||||
* @param $loop (array)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function add_loop( $loop = array() ) {
|
||||
|
||||
// defaults
|
||||
@@ -150,7 +145,6 @@ if ( ! class_exists( 'acf_loop' ) ) :
|
||||
* @param $value (mixed) the loop setting value
|
||||
* @return (boolean) true on success
|
||||
*/
|
||||
|
||||
function update_loop( $i = 'active', $key = null, $value = null ) {
|
||||
|
||||
// i
|
||||
@@ -180,7 +174,6 @@ if ( ! class_exists( 'acf_loop' ) ) :
|
||||
* @param $key (string) the loop setting name
|
||||
* @return (mixed) false on failure
|
||||
*/
|
||||
|
||||
function get_loop( $i = 'active', $key = null ) {
|
||||
|
||||
// i
|
||||
@@ -211,7 +204,6 @@ if ( ! class_exists( 'acf_loop' ) ) :
|
||||
* @param $i (mixed)
|
||||
* @return (boolean) true on success
|
||||
*/
|
||||
|
||||
function remove_loop( $i = 'active' ) {
|
||||
|
||||
// i
|
||||
|
||||
@@ -233,7 +233,7 @@ if ( ! class_exists( 'ACF_Post_Type' ) ) {
|
||||
'rename_capabilities' => false,
|
||||
'singular_capability_name' => 'post',
|
||||
'plural_capability_name' => 'posts',
|
||||
'supports' => array( 'title', 'editor', 'thumbnail' ),
|
||||
'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ),
|
||||
'taxonomies' => array(),
|
||||
'has_archive' => false,
|
||||
'has_archive_slug' => '',
|
||||
@@ -481,10 +481,21 @@ if ( ! class_exists( 'ACF_Post_Type' ) ) {
|
||||
$args['menu_position'] = $menu_position;
|
||||
}
|
||||
|
||||
// WordPress defaults to the same icon as the posts icon.
|
||||
$menu_icon = (string) $post['menu_icon'];
|
||||
if ( ! empty( $menu_icon ) ) {
|
||||
$args['menu_icon'] = $menu_icon;
|
||||
// Set the default for the icon.
|
||||
$args['menu_icon'] = 'dashicons-admin-post';
|
||||
|
||||
// Override that default if a value is provided.
|
||||
if ( ! empty( $post['menu_icon'] ) ) {
|
||||
if ( is_string( $post['menu_icon'] ) ) {
|
||||
$args['menu_icon'] = $post['menu_icon'];
|
||||
}
|
||||
if ( is_array( $post['menu_icon'] ) ) {
|
||||
if ( $post['menu_icon']['type'] === 'media_library' ) {
|
||||
$args['menu_icon'] = wp_get_attachment_image_url( $post['menu_icon']['value'] );
|
||||
} else {
|
||||
$args['menu_icon'] = $post['menu_icon']['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WordPress defaults to "post" for `$args['capability_type']`, but can also take an array.
|
||||
|
||||
@@ -107,6 +107,11 @@ if ( ! class_exists( 'acf_revisions' ) ) :
|
||||
return;
|
||||
}
|
||||
|
||||
// Bail if this is an autosave in Classic Editor, it already has the field values.
|
||||
if ( acf_maybe_get_POST( '_acf_changed' ) && wp_is_post_autosave( $revision_id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy the saved meta from the main post to the latest revision.
|
||||
acf_save_post_revision( $post_id );
|
||||
}
|
||||
@@ -123,7 +128,6 @@ if ( ! class_exists( 'acf_revisions' ) ) :
|
||||
* @param $fields (array)
|
||||
* @return $fields
|
||||
*/
|
||||
|
||||
function wp_preview_post_fields( $fields ) {
|
||||
|
||||
// bail early if not previewing a post
|
||||
@@ -148,12 +152,11 @@ if ( ! class_exists( 'acf_revisions' ) ) :
|
||||
* @type filter
|
||||
* @date 19/09/13
|
||||
*
|
||||
* @param $return (boolean) defaults to true
|
||||
* @param $last_revision (object) the last revision that WP will compare against
|
||||
* @param $post (object) the $post object that WP will compare against
|
||||
* @return $return (boolean)
|
||||
* @param boolean $return defaults to true
|
||||
* @param object $last_revision the last revision that WP will compare against
|
||||
* @param object $post the $post object that WP will compare against
|
||||
* @return boolean $return
|
||||
*/
|
||||
|
||||
function wp_save_post_revision_check_for_changes( $return, $last_revision, $post ) {
|
||||
|
||||
// if acf has changed, return false and prevent WP from performing 'compare' logic
|
||||
@@ -177,7 +180,6 @@ if ( ! class_exists( 'acf_revisions' ) ) :
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function wp_post_revision_fields( $fields, $post = null ) {
|
||||
|
||||
// validate page
|
||||
@@ -284,22 +286,17 @@ if ( ! class_exists( 'acf_revisions' ) ) :
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This filter will load the value for the given field and return it for rendering
|
||||
* Load the value for the given field and return it for rendering.
|
||||
*
|
||||
* @type filter
|
||||
* @date 11/08/13
|
||||
*
|
||||
* @param $value (mixed) should be false as it has not yet been loaded
|
||||
* @param $field_name (string) The name of the field
|
||||
* @param post (mixed) Holds the $post object to load from - in WP 3.5, this is not passed!
|
||||
* @param $direction (string) to / from - not used
|
||||
* @return $value (string)
|
||||
* @param mixed $value Should be false as it has not yet been loaded.
|
||||
* @param string $field_name The name of the field
|
||||
* @param mixed $post Holds the $post object to load from - in WP 3.5, this is not passed!
|
||||
* @param string $direction To / from - not used.
|
||||
* @return string $value
|
||||
*/
|
||||
function wp_post_revision_field( $value, $field_name, $post = null, $direction = false ) {
|
||||
|
||||
// bail early if is empty.
|
||||
public function wp_post_revision_field( $value, $field_name, $post = null, $direction = false ) {
|
||||
// Bail early if is empty.
|
||||
if ( empty( $value ) ) {
|
||||
return '';
|
||||
}
|
||||
@@ -326,7 +323,6 @@ if ( ! class_exists( 'acf_revisions' ) ) :
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This action will copy and paste the metadata from a revision to the post
|
||||
*
|
||||
@@ -336,7 +332,6 @@ if ( ! class_exists( 'acf_revisions' ) ) :
|
||||
* @param $parent_id (int) the destination post
|
||||
* @return $revision_id (int) the source post
|
||||
*/
|
||||
|
||||
function wp_restore_post_revision( $post_id, $revision_id ) {
|
||||
|
||||
// copy postmeta from revision to post (restore from revision)
|
||||
@@ -366,7 +361,6 @@ if ( ! class_exists( 'acf_revisions' ) ) :
|
||||
* @param $_post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_validate_post_id( $post_id, $_post_id ) {
|
||||
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
@@ -19,7 +19,6 @@ if ( ! class_exists( 'acf_validation' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// vars
|
||||
@@ -43,7 +42,6 @@ if ( ! class_exists( 'acf_validation' ) ) :
|
||||
* @param $message (string) error message
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function add_error( $input, $message ) {
|
||||
|
||||
// add to array
|
||||
@@ -64,7 +62,6 @@ if ( ! class_exists( 'acf_validation' ) ) :
|
||||
* @param $input (string) name attribute of DOM elmenet
|
||||
* @return (mixed)
|
||||
*/
|
||||
|
||||
function get_error( $input ) {
|
||||
|
||||
// bail early if no errors
|
||||
@@ -94,7 +91,6 @@ if ( ! class_exists( 'acf_validation' ) ) :
|
||||
* @param n/a
|
||||
* @return (array|boolean)
|
||||
*/
|
||||
|
||||
function get_errors() {
|
||||
|
||||
// bail early if no errors
|
||||
@@ -117,7 +113,6 @@ if ( ! class_exists( 'acf_validation' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function reset_errors() {
|
||||
|
||||
$this->errors = array();
|
||||
@@ -134,7 +129,6 @@ if ( ! class_exists( 'acf_validation' ) ) :
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function ajax_validate_save_post() {
|
||||
|
||||
// validate
|
||||
|
||||
Reference in New Issue
Block a user