Skip to content

Commit 637ca1c

Browse files
author
ACF
committed
Updates to 6.3.4
1 parent 21b1716 commit 637ca1c

File tree

140 files changed

+32505
-21246
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+32505
-21246
lines changed

acf.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Plugin Name: Advanced Custom Fields PRO
1010
* Plugin URI: https://www.advancedcustomfields.com
1111
* Description: Customize WordPress with powerful, professional and intuitive fields.
12-
* Version: 6.3.3
12+
* Version: 6.3.4
1313
* Author: WP Engine
1414
* Author URI: https://wpengine.com/?utm_source=wordpress.org&utm_medium=referral&utm_campaign=plugin_directory&utm_content=advanced_custom_fields
1515
* Update URI: https://www.advancedcustomfields.com/pro
@@ -36,7 +36,7 @@ class ACF {
3636
*
3737
* @var string
3838
*/
39-
public $version = '6.3.3';
39+
public $version = '6.3.4';
4040

4141
/**
4242
* The plugin settings array.

assets/build/js/pro/acf-pro-blocks.js

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/build/js/pro/acf-pro-blocks.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/build/js/pro/acf-pro-blocks.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/acf-input-functions.php

+5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ function acf_esc_attrs( $attrs ) {
7777
* @return string
7878
*/
7979
function acf_esc_html( $string = '' ) {
80+
81+
if ( ! is_scalar( $string ) ) {
82+
return false;
83+
}
84+
8085
return wp_kses( (string) $string, 'acf' );
8186
}
8287

includes/ajax/class-acf-ajax-check-screen.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ class ACF_Ajax_Check_Screen extends ACF_Ajax {
2323
* @return array|WP_Error The response data or WP_Error.
2424
*/
2525
public function get_response( $request ) {
26-
if ( ! current_user_can( 'edit_posts' ) ) {
27-
return new WP_Error( 'acf_invalid_permissions', __( 'Sorry, you do not have permission to do that.', 'acf' ) );
28-
}
29-
30-
// vars
3126
$args = wp_parse_args(
3227
$this->request,
3328
array(
@@ -38,7 +33,10 @@ public function get_response( $request ) {
3833
)
3934
);
4035

41-
// vars
36+
if ( ! acf_current_user_can_edit_post( (int) $args['post_id'] ) ) {
37+
return new WP_Error( 'acf_invalid_permissions', __( 'Sorry, you do not have permission to do that.', 'acf' ) );
38+
}
39+
4240
$response = array(
4341
'results' => array(),
4442
'style' => '',

includes/api/api-helpers.php

+25
Original file line numberDiff line numberDiff line change
@@ -2715,6 +2715,31 @@ function acf_current_user_can_admin() {
27152715
return false;
27162716
}
27172717

2718+
/**
2719+
* Wrapper function for current_user_can( 'edit_post', $post_id ).
2720+
*
2721+
* @since 6.3.4
2722+
*
2723+
* @param integer $post_id The post ID to check.
2724+
* @return boolean
2725+
*/
2726+
function acf_current_user_can_edit_post( int $post_id ): bool {
2727+
/**
2728+
* The `edit_post` capability is a meta capability, which
2729+
* gets converted to the correct post type object `edit_post`
2730+
* equivalent.
2731+
*
2732+
* If the post type does not have `map_meta_cap` enabled and the user is
2733+
* not manually mapping the `edit_post` capability, this will fail
2734+
* unless the role has the `edit_post` capability added to a user/role.
2735+
*
2736+
* However, more (core) stuff will likely break in this scenario.
2737+
*/
2738+
$user_can_edit = current_user_can( 'edit_post', $post_id );
2739+
2740+
return (bool) apply_filters( 'acf/current_user_can_edit_post', $user_can_edit, $post_id );
2741+
}
2742+
27182743
/**
27192744
* acf_get_filesize
27202745
*

includes/api/api-template.php

+35-16
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,14 @@ function the_field( $selector, $post_id = false, $format_value = true ) {
115115
$unescaped_value = implode( ', ', $unescaped_value );
116116
}
117117

118+
if ( ! is_scalar( $unescaped_value ) ) {
119+
$unescaped_value = false;
120+
}
121+
118122
$field_type = is_array( $field ) && isset( $field['type'] ) ? $field['type'] : 'text';
119123
if ( apply_filters( 'acf/the_field/allow_unsafe_html', false, $selector, $post_id, $field_type, $field ) ) {
120124
$value = $unescaped_value;
121-
} elseif ( (string) $value !== (string) $unescaped_value ) {
125+
} elseif ( $unescaped_value !== false && (string) $value !== (string) $unescaped_value ) {
122126
do_action( 'acf/removed_unsafe_html', __FUNCTION__, $selector, $field, $post_id );
123127
}
124128

@@ -889,10 +893,14 @@ function the_sub_field( $field_name, $format_value = true ) {
889893
$unescaped_value = implode( ', ', $unescaped_value );
890894
}
891895

896+
if ( ! is_scalar( $unescaped_value ) ) {
897+
$unescaped_value = false;
898+
}
899+
892900
$field_type = is_array( $field ) && isset( $field['type'] ) ? $field['type'] : 'text';
893901
if ( apply_filters( 'acf/the_field/allow_unsafe_html', false, $field_name, 'sub_field', $field_type, $field ) ) {
894902
$value = $unescaped_value;
895-
} elseif ( (string) $value !== (string) $unescaped_value ) {
903+
} elseif ( $unescaped_value !== false && (string) $value !== (string) $unescaped_value ) {
896904
do_action( 'acf/removed_unsafe_html', __FUNCTION__, $field_name, $field, false );
897905
}
898906

@@ -999,7 +1007,11 @@ function get_row_layout() {
9991007
function acf_shortcode( $atts ) {
10001008
// Return if the ACF shortcode is disabled.
10011009
if ( ! acf_get_setting( 'enable_shortcode' ) ) {
1002-
return;
1010+
if ( is_preview() ) {
1011+
return apply_filters( 'acf/shortcode/disabled_message', __( '[The ACF shortcode is disabled on this site]', 'acf' ) );
1012+
} else {
1013+
return;
1014+
}
10031015
}
10041016

10051017
if ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) {
@@ -1031,6 +1043,21 @@ function acf_shortcode( $atts ) {
10311043
'acf'
10321044
);
10331045

1046+
// Decode the post ID for filtering.
1047+
$post_id = acf_get_valid_post_id( $atts['post_id'] );
1048+
$decoded_post_id = acf_decode_post_id( $post_id );
1049+
1050+
// If we've decoded to a post, ensure the post is publicly visible.
1051+
if ( $decoded_post_id['type'] === 'post' ) {
1052+
if ( $atts['post_id'] !== false && ( (int) $atts['post_id'] !== (int) acf_get_valid_post_id() ) && ( ! is_post_publicly_viewable( $decoded_post_id['id'] ) ) && apply_filters( 'acf/shortcode/prevent_access_to_fields_on_non_public_posts', true ) ) {
1053+
if ( is_preview() ) {
1054+
return apply_filters( 'acf/shortcode/post_not_public_message', __( '[The ACF shortcode cannot display fields from non-public posts]', 'acf' ) );
1055+
} else {
1056+
return;
1057+
}
1058+
}
1059+
}
1060+
10341061
$access_already_prevented = apply_filters( 'acf/prevent_access_to_unknown_fields', false );
10351062
$filter_applied = false;
10361063

@@ -1039,10 +1066,6 @@ function acf_shortcode( $atts ) {
10391066
add_filter( 'acf/prevent_access_to_unknown_fields', '__return_true' );
10401067
}
10411068

1042-
// Decode the post ID for filtering.
1043-
$post_id = acf_get_valid_post_id( $atts['post_id'] );
1044-
$decoded_post_id = acf_decode_post_id( $post_id );
1045-
10461069
// Try to get the field value, ensuring any non-safe HTML is stripped from wysiwyg fields via `acf_the_content`
10471070
$field = get_field_object( $atts['field'], $post_id, $atts['format_value'], true, true );
10481071
$value = $field ? $field['value'] : get_field( $atts['field'], $post_id, $atts['format_value'], true );
@@ -1053,17 +1076,9 @@ function acf_shortcode( $atts ) {
10531076
return;
10541077
}
10551078

1056-
if ( is_array( $value ) ) {
1057-
$value = implode( ', ', $value );
1058-
}
1059-
10601079
// Temporarily always get the unescaped version for action comparison.
10611080
$unescaped_value = get_field( $atts['field'], $post_id, $atts['format_value'], false );
10621081

1063-
if ( $filter_applied ) {
1064-
remove_filter( 'acf/prevent_access_to_unknown_fields', '__return_true' );
1065-
}
1066-
10671082
// Remove the filter preventing access to unknown filters now we've got all the values.
10681083
if ( $filter_applied ) {
10691084
remove_filter( 'acf/prevent_access_to_unknown_fields', '__return_true' );
@@ -1073,10 +1088,14 @@ function acf_shortcode( $atts ) {
10731088
$unescaped_value = implode( ', ', $unescaped_value );
10741089
}
10751090

1091+
if ( ! is_scalar( $unescaped_value ) ) {
1092+
$unescaped_value = false;
1093+
}
1094+
10761095
// Handle getting the unescaped version if we're allowed unsafe html.
10771096
if ( apply_filters( 'acf/shortcode/allow_unsafe_html', false, $atts, $field_type, $field ) ) {
10781097
$value = $unescaped_value;
1079-
} elseif ( (string) $value !== (string) $unescaped_value ) {
1098+
} elseif ( $unescaped_value !== false && (string) $value !== (string) $unescaped_value ) {
10801099
do_action( 'acf/removed_unsafe_html', __FUNCTION__, $atts['field'], $field, $post_id );
10811100
}
10821101

lang/acf-ar.l10n.php

+1-1
Large diffs are not rendered by default.

lang/acf-ar.mo

0 Bytes
Binary file not shown.

lang/acf-ar.po

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# This file is distributed under the same license as Advanced Custom Fields.
1313
msgid ""
1414
msgstr ""
15-
"PO-Revision-Date: 2024-06-27T14:24:00+00:00\n"
15+
"PO-Revision-Date: 2024-07-18T08:39:03+00:00\n"
1616
"Report-Msgid-Bugs-To: http://support.advancedcustomfields.com\n"
1717
"Language: ar\n"
1818
"MIME-Version: 1.0\n"

lang/acf-bg_BG.l10n.php

+1-1
Large diffs are not rendered by default.

lang/acf-bg_BG.mo

0 Bytes
Binary file not shown.

lang/acf-bg_BG.po

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# This file is distributed under the same license as Advanced Custom Fields.
1313
msgid ""
1414
msgstr ""
15-
"PO-Revision-Date: 2024-06-27T14:24:00+00:00\n"
15+
"PO-Revision-Date: 2024-07-18T08:39:03+00:00\n"
1616
"Report-Msgid-Bugs-To: http://support.advancedcustomfields.com\n"
1717
"Language: bg_BG\n"
1818
"MIME-Version: 1.0\n"

lang/acf-ca.l10n.php

+1-1
Large diffs are not rendered by default.

lang/acf-ca.mo

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)