This commit is contained in:
Hanson.xyz Dev
2026-01-04 17:50:08 -06:00
parent 7e45ce0756
commit acc8ac87a0
4131 changed files with 232562 additions and 250244 deletions
+5 -8
View File
@@ -87,16 +87,13 @@ function wp_render_background_support( $block_content, $block ) {
if ( $tags->next_tag() ) {
$existing_style = $tags->get_attribute( 'style' );
$updated_style = '';
if ( ! empty( $existing_style ) ) {
$updated_style = $existing_style;
if ( ! str_ends_with( $existing_style, ';' ) ) {
$updated_style .= ';';
}
if ( is_string( $existing_style ) && '' !== $existing_style ) {
$separator = str_ends_with( $existing_style, ';' ) ? '' : ';';
$updated_style = "{$existing_style}{$separator}{$styles['css']}";
} else {
$updated_style = $styles['css'];
}
$updated_style .= $styles['css'];
$tags->set_attribute( 'style', $updated_style );
$tags->add_class( 'has-background' );
}
+33
View File
@@ -0,0 +1,33 @@
<?php
/**
* Block visibility block support flag.
*
* @package WordPress
* @since 6.9.0
*/
/**
* Render nothing if the block is hidden.
*
* @since 6.9.0
* @access private
*
* @param string $block_content Rendered block content.
* @param array $block Block object.
* @return string Filtered block content.
*/
function wp_render_block_visibility_support( $block_content, $block ) {
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
if ( ! $block_type || ! block_has_support( $block_type, 'visibility', true ) ) {
return $block_content;
}
if ( isset( $block['attrs']['metadata']['blockVisibility'] ) && false === $block['attrs']['metadata']['blockVisibility'] ) {
return '';
}
return $block_content;
}
add_filter( 'render_block', 'wp_render_block_visibility_support', 10, 2 );
+41 -37
View File
@@ -858,8 +858,9 @@ function wp_render_layout_support_flag( $block_content, $block ) {
}
// Add combined layout and block classname for global styles to hook onto.
$block_name = explode( '/', $block['blockName'] );
$class_names[] = 'wp-block-' . end( $block_name ) . '-' . $layout_classname;
$split_block_name = explode( '/', $block['blockName'] );
$full_block_name = 'core' === $split_block_name[0] ? end( $split_block_name ) : implode( '-', $split_block_name );
$class_names[] = 'wp-block-' . $full_block_name . '-' . $layout_classname;
// Add classes to the outermost HTML tag if necessary.
if ( ! empty( $outer_class_names ) ) {
@@ -1073,50 +1074,53 @@ add_filter( 'render_block_core/group', 'wp_restore_group_inner_container', 10, 2
* @return string Filtered block content.
*/
function wp_restore_image_outer_container( $block_content, $block ) {
$image_with_align = "
/# 1) everything up to the class attribute contents
(
^\s*
<figure\b
[^>]*
\bclass=
[\"']
)
# 2) the class attribute contents
(
[^\"']*
\bwp-block-image\b
[^\"']*
\b(?:alignleft|alignright|aligncenter)\b
[^\"']*
)
# 3) everything after the class attribute contents
(
[\"']
[^>]*
>
.*
<\/figure>
)/iUx";
if ( wp_theme_has_theme_json() ) {
return $block_content;
}
$figure_processor = new WP_HTML_Tag_Processor( $block_content );
if (
wp_theme_has_theme_json() ||
0 === preg_match( $image_with_align, $block_content, $matches )
! $figure_processor->next_tag( 'FIGURE' ) ||
! $figure_processor->has_class( 'wp-block-image' ) ||
! (
$figure_processor->has_class( 'alignleft' ) ||
$figure_processor->has_class( 'aligncenter' ) ||
$figure_processor->has_class( 'alignright' )
)
) {
return $block_content;
}
$wrapper_classnames = array( 'wp-block-image' );
/*
* The next section of code wraps the existing figure in a new DIV element.
* While doing it, it needs to transfer the layout and the additional CSS
* class names from the original figure upward to the wrapper.
*
* Example:
*
* // From this…
* <!-- wp:image {"className":"hires"} -->
* <figure class="wp-block-image wide hires">…
*
* // To this…
* <div class="wp-block-image hires"><figure class="wide">…
*/
$wrapper_processor = new WP_HTML_Tag_Processor( '<div>' );
$wrapper_processor->next_token();
$wrapper_processor->set_attribute(
'class',
is_string( $block['attrs']['className'] ?? null )
? "wp-block-image {$block['attrs']['className']}"
: 'wp-block-image'
);
// If the block has a classNames attribute these classnames need to be removed from the content and added back
// to the new wrapper div also.
if ( ! empty( $block['attrs']['className'] ) ) {
$wrapper_classnames = array_merge( $wrapper_classnames, explode( ' ', $block['attrs']['className'] ) );
// And remove them from the existing content; it has been transferred upward.
$figure_processor->remove_class( 'wp-block-image' );
foreach ( $wrapper_processor->class_list() as $class_name ) {
$figure_processor->remove_class( $class_name );
}
$content_classnames = explode( ' ', $matches[2] );
$filtered_content_classnames = array_diff( $content_classnames, $wrapper_classnames );
return '<div class="' . implode( ' ', $wrapper_classnames ) . '">' . $matches[1] . implode( ' ', $filtered_content_classnames ) . $matches[3] . '</div>';
return "{$wrapper_processor->get_updated_html()}{$figure_processor->get_updated_html()}</div>";
}
add_filter( 'render_block_core/image', 'wp_restore_image_outer_container', 10, 2 );
+19
View File
@@ -306,6 +306,25 @@ function wp_typography_get_preset_inline_style_value( $style_value, $css_propert
* @return string Filtered block content.
*/
function wp_render_typography_support( $block_content, $block ) {
if ( ! empty( $block['attrs']['fitText'] ) && $block['attrs']['fitText'] && ! is_admin() ) {
wp_enqueue_script_module( '@wordpress/block-editor/utils/fit-text-frontend' );
// Add Interactivity API directives for fit text to work with client-side navigation.
if ( ! empty( $block_content ) ) {
$processor = new WP_HTML_Tag_Processor( $block_content );
if ( $processor->next_tag() ) {
if ( ! $processor->get_attribute( 'data-wp-interactive' ) ) {
$processor->set_attribute( 'data-wp-interactive', true );
}
$processor->set_attribute( 'data-wp-context---core-fit-text', 'core/fit-text::{"fontSize":""}' );
$processor->set_attribute( 'data-wp-init---core-fit-text', 'core/fit-text::callbacks.init' );
$processor->set_attribute( 'data-wp-style--font-size', 'core/fit-text::context.fontSize' );
$block_content = $processor->get_updated_html();
}
}
// fitText supersedes any other typography features
return $block_content;
}
if ( ! isset( $block['attrs']['style']['typography']['fontSize'] ) ) {
return $block_content;
}