Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4d329c9
fix: add guards before fatal operations
yashjawale Jul 22, 2026
eaef4d0
fix: use two line form for guards
yashjawale Jul 22, 2026
3f63a54
Merge branch 'trunk' into fix/block-attribute-type-handling-80494
yashjawale Jul 22, 2026
074a9f2
fix: null check for $smallest_font_size before using attribute value
yashjawale Jul 22, 2026
f05192c
Merge branch 'trunk' into fix/block-attribute-type-handling-80494
yashjawale Jul 22, 2026
3bca1df
Merge branch 'trunk' into fix/block-attribute-type-handling-80494
yashjawale Jul 22, 2026
f54f0d6
fix: reset query block index.php
yashjawale Jul 23, 2026
6be2989
fix: nested array check for media-text & cover blocks
yashjawale Jul 23, 2026
cfe7b38
fix: return empty string in navigation-link /
yashjawale Jul 23, 2026
dc215bb
fix: social-link label attribute string check
yashjawale Jul 23, 2026
3924711
Merge branch 'trunk' into fix/block-attribute-type-handling-80494
yashjawale Jul 23, 2026
4e2c303
fix: $service string check before concatenating into class name
yashjawale Jul 23, 2026
5b1c656
Merge branch 'trunk' into fix/block-attribute-type-handling-80494
yashjawale Jul 23, 2026
75e73a2
fix: revert guards for wp_string_all_tags cases
yashjawale Jul 24, 2026
ff4246e
fix: revert cases of esc_attr & esc_html
yashjawale Jul 24, 2026
8819d07
Merge branch 'trunk' into fix/block-attribute-type-handling-80494
yashjawale Jul 24, 2026
e96f254
fix: use the local variable $slug instead of repeated accessor
yashjawale Jul 24, 2026
5f949a4
fix: guard for $rel in social-link
yashjawale Jul 24, 2026
e253c3b
Merge branch 'trunk' into fix/block-attribute-type-handling-80494
yashjawale Jul 24, 2026
97758e6
Merge branch 'trunk' into fix/block-attribute-type-handling-80494
yashjawale Jul 24, 2026
204e613
Merge branch 'trunk' into fix/block-attribute-type-handling-80494
yashjawale Jul 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/block-library/src/breadcrumbs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
return '';
}

$separator_attr = $attributes['separator'] ?? null;
$separator = is_string( $separator_attr ) ? addcslashes( $separator_attr, '\\"' ) : '';
$wrapper_attributes = get_block_wrapper_attributes(
array(
'style' => '--separator: "' . addcslashes( $attributes['separator'], '\\"' ) . '";',
'style' => '--separator: "' . $separator . '";',
'aria-label' => __( 'Breadcrumbs' ),
)
);
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/button/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function render_block_core_button( $attributes, $content ) {

$width = $attributes['style']['dimensions']['width'] ?? null;

if ( $width ) {
if ( is_string( $width ) && '' !== $width ) {
// Resolve preset references to their actual values.
$resolved_width = $width;
$is_preset = str_starts_with( $width, 'var:preset|dimension|' );
Expand Down
11 changes: 9 additions & 2 deletions packages/block-library/src/cover/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,15 @@ function render_block_core_cover( $attributes, $content ) {
return $content;
}

$object_position = isset( $attributes['focalPoint'] )
? round( $attributes['focalPoint']['x'] * 100 ) . '% ' . round( $attributes['focalPoint']['y'] * 100 ) . '%'
$cover_focal_point = $attributes['focalPoint'] ?? null;
$focal_point_x = null;
$focal_point_y = null;
if ( is_array( $cover_focal_point ) ) {
$focal_point_x = isset( $cover_focal_point['x'] ) && is_numeric( $cover_focal_point['x'] ) ? $cover_focal_point['x'] : null;
$focal_point_y = isset( $cover_focal_point['y'] ) && is_numeric( $cover_focal_point['y'] ) ? $cover_focal_point['y'] : null;
}
$object_position = null !== $focal_point_x && null !== $focal_point_y
? round( $focal_point_x * 100 ) . '% ' . round( $focal_point_y * 100 ) . '%'
: null;

if ( ! ( $attributes['hasParallax'] || $attributes['isRepeated'] ) ) {
Expand Down
10 changes: 6 additions & 4 deletions packages/block-library/src/form/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ function render_block_core_form( $attributes, $content ) {
$processed_content->next_tag( 'form' );

// Get the action for this form.
$action = '';
if ( isset( $attributes['action'] ) ) {
$action = '';
$form_action = $attributes['action'] ?? null;
if ( is_string( $form_action ) ) {
$action = str_replace(
array( '{SITE_URL}', '{ADMIN_URL}' ),
array( site_url(), admin_url() ),
$attributes['action']
$form_action
);
}
$processed_content->set_attribute( 'action', esc_attr( $action ) );
Expand Down Expand Up @@ -55,7 +56,8 @@ function render_block_core_form( $attributes, $content ) {
* @return string The extra fields.
*/
function block_core_form_extra_fields_comment_form( $extra_fields, $attributes ) {
if ( ! empty( $attributes['action'] ) && str_ends_with( $attributes['action'], '/wp-comments-post.php' ) ) {
$form_action = $attributes['action'] ?? null;
if ( ! empty( $form_action ) && is_string( $form_action ) && str_ends_with( $form_action, '/wp-comments-post.php' ) ) {
$extra_fields .= '<input type="hidden" name="comment_post_ID" value="' . get_the_ID() . '" id="comment_post_ID">';
}
return $extra_fields;
Expand Down
5 changes: 3 additions & 2 deletions packages/block-library/src/latest-posts/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ function render_block_core_latest_posts( $attributes ) {
$block_core_latest_posts_excerpt_length = $attributes['excerptLength'];
add_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );

if ( ! empty( $attributes['categories'] ) ) {
$args['category__in'] = array_column( $attributes['categories'], 'id' );
$categories = $attributes['categories'] ?? null;
if ( ! empty( $categories ) && is_array( $categories ) ) {
$args['category__in'] = array_column( $categories, 'id' );
}
if ( isset( $attributes['selectedAuthor'] ) ) {
$args['author'] = $attributes['selectedAuthor'];
Expand Down
13 changes: 11 additions & 2 deletions packages/block-library/src/media-text/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,17 @@ function render_block_core_media_text( $attributes, $content ) {

$has_media_on_right = 'right' === ( $attributes['mediaPosition'] ?? null );
$image_fill = (bool) ( $attributes['imageFill'] ?? false );
$focal_point = isset( $attributes['focalPoint'] ) ? round( $attributes['focalPoint']['x'] * 100 ) . '% ' . round( $attributes['focalPoint']['y'] * 100 ) . '%' : '50% 50%';
$unique_id = 'wp-block-media-text__media-' . wp_unique_id();
$focal_point_attr = $attributes['focalPoint'] ?? null;
$focal_point_x = null;
$focal_point_y = null;
if ( is_array( $focal_point_attr ) ) {
$focal_point_x = isset( $focal_point_attr['x'] ) && is_numeric( $focal_point_attr['x'] ) ? $focal_point_attr['x'] : null;
$focal_point_y = isset( $focal_point_attr['y'] ) && is_numeric( $focal_point_attr['y'] ) ? $focal_point_attr['y'] : null;
}
$focal_point = null !== $focal_point_x && null !== $focal_point_y
? round( $focal_point_x * 100 ) . '% ' . round( $focal_point_y * 100 ) . '%'
: '50% 50%';
$unique_id = 'wp-block-media-text__media-' . wp_unique_id();

$block_tag_processor = new WP_HTML_Tag_Processor( $content );
$block_query = array(
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/navigation-link/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ function block_core_navigation_link_render_submenu_icon() {
* @return string $url Returns the decoded url.
*/
function block_core_navigation_link_maybe_urldecode( $url ) {
if ( ! is_string( $url ) ) {
return '';
}
Comment thread
ramonjd marked this conversation as resolved.
Resolved

$is_url_encoded = false;
$query = parse_url( $url, PHP_URL_QUERY );
$query_params = wp_parse_args( $query );
Expand Down
9 changes: 5 additions & 4 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,13 @@ private static function get_layout_class( $attributes ) {
'space-between' => 'items-justified-space-between',
);

$layout_class = '';
$layout_class = '';
$nav_justify_content = $attributes['layout']['justifyContent'] ?? null;
if (
isset( $attributes['layout']['justifyContent'] ) &&
isset( $layout_justification[ $attributes['layout']['justifyContent'] ] )
is_string( $nav_justify_content ) &&
isset( $layout_justification[ $nav_justify_content ] )
) {
$layout_class .= $layout_justification[ $attributes['layout']['justifyContent'] ];
$layout_class .= $layout_justification[ $nav_justify_content ];
}
if ( isset( $attributes['layout']['orientation'] ) && 'vertical' === $attributes['layout']['orientation'] ) {
$layout_class .= ' is-vertical';
Expand Down
5 changes: 3 additions & 2 deletions packages/block-library/src/page-list/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ function render_block_core_page_list( $attributes, $content, $block ) {
static $block_id = 0;
++$block_id;

$parent_page_id = $attributes['parentPageID'];
$is_nested = ! empty( $block->context['core/isInsideSubmenu'] );
$parent_page_id_attr = isset( $attributes['parentPageID'] ) ? $attributes['parentPageID'] : null;
$parent_page_id = is_scalar( $parent_page_id_attr ) ? (int) $parent_page_id_attr : 0;
$is_nested = ! empty( $block->context['core/isInsideSubmenu'] );

$all_pages = get_pages(
array(
Expand Down
10 changes: 5 additions & 5 deletions packages/block-library/src/pattern/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ function register_block_core_pattern() {
function render_block_core_pattern( $attributes ) {
static $seen_refs = array();

if ( empty( $attributes['slug'] ) ) {
$slug = $attributes['slug'] ?? null;
if ( empty( $slug ) || ! is_string( $slug ) ) {
return '';
}

$slug = $attributes['slug'];
$registry = WP_Block_Patterns_Registry::get_instance();

if ( ! $registry->is_registered( $slug ) ) {
return '';
}

if ( isset( $seen_refs[ $attributes['slug'] ] ) ) {
if ( isset( $seen_refs[ $slug ] ) ) {
// WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent
// is set in `wp_debug_mode()`.
$is_debug = WP_DEBUG && WP_DEBUG_DISPLAY;
Expand All @@ -58,14 +58,14 @@ function render_block_core_pattern( $attributes ) {
$pattern = $registry->get_registered( $slug );
$content = $pattern['content'];

$seen_refs[ $attributes['slug'] ] = true;
$seen_refs[ $slug ] = true;

$content = do_blocks( $content );

global $wp_embed;
$content = $wp_embed->autoembed( $content );

unset( $seen_refs[ $attributes['slug'] ] );
unset( $seen_refs[ $slug ] );
return $content;
}

Expand Down
11 changes: 6 additions & 5 deletions packages/block-library/src/playlist-track/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ function render_block_core_playlist_track( $attributes, $content = '', $block =
$show_images = $block->context['showImages'];
}

$artist = $attributes['artist'] ?? '';
$image = $attributes['image'] ?? '';
$alt = $attributes['imageAlt'] ?? '';
$length = $attributes['length'] ?? '';
$title = isset( $attributes['title'] ) && ! empty( $attributes['title'] ) ? $attributes['title'] : __( 'Unknown title' );
$track_image = $attributes['image'] ?? null;
$image = is_string( $track_image ) ? $track_image : '';
$artist = $attributes['artist'] ?? '';
$alt = $attributes['imageAlt'] ?? '';
$length = $attributes['length'] ?? '';
$title = isset( $attributes['title'] ) && ! empty( $attributes['title'] ) ? $attributes['title'] : __( 'Unknown title' );

$html = '<li ' . $wrapper_attributes . '>';
$html .= '<button data-wp-on--click="actions.changeTrack" data-wp-bind--aria-current="state.isCurrentTrack" class="wp-block-playlist-track__button">';
Expand Down
19 changes: 12 additions & 7 deletions packages/block-library/src/playlist/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,18 @@ function render_block_core_playlist( $attributes, $content, $block ) {
$playlist_tracks[] = $track_id;

// Extract track metadata from block attributes.
$title = isset( $track_attributes['title'] ) && ! empty( $track_attributes['title'] ) ? $track_attributes['title'] : __( 'Unknown title' );
$artist = $track_attributes['artist'] ?? '';
$album = $track_attributes['album'] ?? '';
$image = $track_attributes['image'] ?? '';
$image_alt = $track_attributes['imageAlt'] ?? '';
$url = $track_attributes['src'] ?? '';
$aria_label = $title;
$track_title_attr = $track_attributes['title'] ?? null;
$track_artist = $track_attributes['artist'] ?? null;
$track_album = $track_attributes['album'] ?? null;
$track_image = $track_attributes['image'] ?? null;
$track_src = $track_attributes['src'] ?? null;
$title = ! empty( $track_title_attr ) && is_string( $track_title_attr ) ? $track_title_attr : __( 'Unknown title' );
$artist = is_string( $track_artist ) ? $track_artist : '';
$album = is_string( $track_album ) ? $track_album : '';
$image = is_string( $track_image ) ? $track_image : '';
$image_alt = $track_attributes['imageAlt'] ?? '';
$url = is_string( $track_src ) ? $track_src : '';
$aria_label = $title;

if ( $title && $artist && $album ) {
$aria_label = sprintf(
Expand Down
12 changes: 9 additions & 3 deletions packages/block-library/src/rss/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@
* @return string Returns the block content with received rss items.
*/
function render_block_core_rss( $attributes ) {
if ( in_array( untrailingslashit( $attributes['feedURL'] ), array( site_url(), home_url() ), true ) ) {
$feed_url = $attributes['feedURL'] ?? null;
if ( ! is_string( $feed_url ) ) {
return '';
}

if ( in_array( untrailingslashit( $feed_url ), array( site_url(), home_url() ), true ) ) {
return '<div class="components-placeholder"><div class="notice notice-error">' . __( 'Adding an RSS feed to this site’s homepage is not supported, as it could lead to a loop that slows down your site. Try using another block, like the <strong>Latest Posts</strong> block, to list posts from the site.' ) . '</div></div>';
}

$rss = fetch_feed( $attributes['feedURL'] );
$rss = fetch_feed( $feed_url );

if ( is_wp_error( $rss ) ) {
return '<div class="components-placeholder"><div class="notice notice-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . esc_html( $rss->get_error_message() ) . '</div></div>';
Expand All @@ -33,7 +38,8 @@ function render_block_core_rss( $attributes ) {
$list_items = '';

$open_in_new_tab = ! empty( $attributes['openInNewTab'] );
$rel = ! empty( $attributes['rel'] ) ? trim( $attributes['rel'] ) : '';
$rel_attr = $attributes['rel'] ?? null;
$rel = is_string( $rel_attr ) && '' !== $rel_attr ? trim( $rel_attr ) : '';

$link_attributes = '';

Expand Down
26 changes: 18 additions & 8 deletions packages/block-library/src/social-link/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,26 @@
function render_block_core_social_link( $attributes, $content, $block ) {
$open_in_new_tab = $block->context['openInNewTab'] ?? false;

$text = ! empty( $attributes['label'] ) ? trim( $attributes['label'] ) : '';
$label_attr = $attributes['label'] ?? null;
$text = is_string( $label_attr ) && '' !== $label_attr ? trim( $label_attr ) : '';

$service = $attributes['service'] ?? 'Icon';
$url = $attributes['url'] ?? false;
$text = $text ? $text : block_core_social_link_get_name( $service );
$rel = $attributes['rel'] ?? '';
$show_labels = array_key_exists( 'showLabels', $block->context ) ? $block->context['showLabels'] : false;
$service_attr = $attributes['service'] ?? null;
$service = is_string( $service_attr ) ? $service_attr : 'Icon';
$url = $attributes['url'] ?? false;
$text = $text ? $text : block_core_social_link_get_name( $service );
$rel_attr = $attributes['rel'] ?? null;
$rel = is_string( $rel_attr ) ? $rel_attr : '';
$show_labels = array_key_exists( 'showLabels', $block->context ) ? $block->context['showLabels'] : false;

// Don't render a link if there is no URL set.
if ( ! $url ) {
return '';
}

if ( ! is_string( $url ) ) {
return '';
}

/**
* Prepend emails with `mailto:` if not set.
* The `is_email` returns false for emails with schema.
Expand Down Expand Up @@ -100,7 +107,7 @@ function register_block_core_social_link() {
*/
function block_core_social_link_get_icon( $service ) {
$services = block_core_social_link_services();
if ( isset( $services[ $service ] ) && isset( $services[ $service ]['icon'] ) ) {
if ( is_string( $service ) && isset( $services[ $service ] ) && isset( $services[ $service ]['icon'] ) ) {
return $services[ $service ]['icon'];
}

Expand All @@ -118,7 +125,7 @@ function block_core_social_link_get_icon( $service ) {
*/
function block_core_social_link_get_name( $service ) {
$services = block_core_social_link_services();
if ( isset( $services[ $service ] ) && isset( $services[ $service ]['name'] ) ) {
if ( is_string( $service ) && isset( $services[ $service ] ) && isset( $services[ $service ]['name'] ) ) {
return $services[ $service ]['name'];
}

Expand All @@ -136,6 +143,9 @@ function block_core_social_link_get_name( $service ) {
* @return array|string
*/
function block_core_social_link_services( $service = '', $field = '' ) {
if ( ! is_string( $service ) || ! is_string( $field ) ) {
return array();
}
$services_data = array(
'fivehundredpx' => array(
'name' => _x( '500px', 'social link block variation name' ),
Expand Down
5 changes: 3 additions & 2 deletions packages/block-library/src/tag-cloud/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
* @return string Returns the tag cloud for selected taxonomy.
*/
function render_block_core_tag_cloud( $attributes ) {
$smallest_font_size = $attributes['smallestFontSize'];
$unit = preg_match( '/^[0-9.]+(?P<unit>[a-z%]+)$/i', $smallest_font_size, $m ) ? $m['unit'] : 'pt';
$smallest_font_size_attr = $attributes['smallestFontSize'] ?? null;
$smallest_font_size = is_string( $smallest_font_size_attr ) ? $smallest_font_size_attr : '';
$unit = preg_match( '/^[0-9.]+(?P<unit>[a-z%]+)$/i', $smallest_font_size, $m ) ? $m['unit'] : 'pt';

$args = array(
'echo' => false,
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/template-part/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ function render_block_core_template_part( $attributes ) {
// Run through the actions that are typically taken on the_content.
$content = _wp_apply_block_content_filters( $content, "template_part_{$area}", $seen_ids, $template_part_id );

if ( empty( $attributes['tagName'] ) || tag_escape( $attributes['tagName'] ) !== $attributes['tagName'] ) {
$tag_name = $attributes['tagName'] ?? null;
if ( empty( $tag_name ) || ! is_string( $tag_name ) || tag_escape( $tag_name ) !== $tag_name ) {
$area_tag = 'div';
if ( $area_definition && isset( $area_definition['area_tag'] ) ) {
$area_tag = $area_definition['area_tag'];
Expand Down
Loading