wip
This commit is contained in:
@@ -10,9 +10,7 @@
|
||||
*
|
||||
* @since 6.3.0 Using block.json `viewScript` to register script, and update `view_script_handles()` only when needed.
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
* @param string $content The saved content.
|
||||
* @param WP_Block $block The parsed block.
|
||||
* @param array $attributes The block attributes.
|
||||
*
|
||||
* @return string The search block markup.
|
||||
*/
|
||||
@@ -152,17 +150,22 @@ function render_block_core_search( $attributes ) {
|
||||
}
|
||||
}
|
||||
|
||||
$field_markup_classes = $is_button_inside ? $border_color_classes : '';
|
||||
$field_markup = sprintf(
|
||||
'<div class="wp-block-search__inside-wrapper %s" %s>%s</div>',
|
||||
esc_attr( $field_markup_classes ),
|
||||
$field_markup_classes = array(
|
||||
'wp-block-search__inside-wrapper',
|
||||
);
|
||||
if ( $is_button_inside && ! empty( $border_color_classes ) ) {
|
||||
$field_markup_classes[] = $border_color_classes;
|
||||
}
|
||||
$field_markup = sprintf(
|
||||
'<div class="%s" %s>%s</div>',
|
||||
esc_attr( implode( ' ', $field_markup_classes ) ),
|
||||
$inline_styles['wrapper'],
|
||||
$input . $query_params_markup . $button
|
||||
);
|
||||
$wrapper_attributes = get_block_wrapper_attributes(
|
||||
$wrapper_attributes = get_block_wrapper_attributes(
|
||||
array( 'class' => $classnames )
|
||||
);
|
||||
$form_directives = '';
|
||||
$form_directives = '';
|
||||
|
||||
// If it's interactive, add the directives.
|
||||
if ( $is_expandable_searchfield ) {
|
||||
@@ -180,8 +183,8 @@ function render_block_core_search( $attributes ) {
|
||||
data-wp-interactive="core/search"
|
||||
' . $form_context . '
|
||||
data-wp-class--wp-block-search__searchfield-hidden="!context.isSearchInputVisible"
|
||||
data-wp-on-async--keydown="actions.handleSearchKeydown"
|
||||
data-wp-on-async--focusout="actions.handleSearchFocusout"
|
||||
data-wp-on--keydown="actions.handleSearchKeydown"
|
||||
data-wp-on--focusout="actions.handleSearchFocusout"
|
||||
';
|
||||
}
|
||||
|
||||
@@ -369,6 +372,13 @@ function styles_for_block_core_search( $attributes ) {
|
||||
if ( is_array( $border_radius ) ) {
|
||||
// Apply styles for individual corner border radii.
|
||||
foreach ( $border_radius as $key => $value ) {
|
||||
// Get border-radius CSS variable from preset value if provided.
|
||||
if ( is_string( $value ) && str_contains( $value, 'var:preset|border-radius|' ) ) {
|
||||
$index_to_splice = strrpos( $value, '|' ) + 1;
|
||||
$slug = _wp_to_kebab_case( substr( $value, $index_to_splice ) );
|
||||
$value = "var(--wp--preset--border-radius--$slug)";
|
||||
}
|
||||
|
||||
if ( null !== $value ) {
|
||||
// Convert camelCase key to kebab-case.
|
||||
$name = strtolower( preg_replace( '/(?<!^)[A-Z]/', '-$0', $key ) );
|
||||
@@ -384,7 +394,7 @@ function styles_for_block_core_search( $attributes ) {
|
||||
|
||||
// Add adjusted border radius styles for the wrapper element
|
||||
// if button is positioned inside.
|
||||
if ( $is_button_inside && intval( $value ) !== 0 ) {
|
||||
if ( $is_button_inside && ( intval( $value ) !== 0 || str_contains( $value, 'var(--wp--preset--border-radius--' ) ) ) {
|
||||
$wrapper_styles[] = sprintf(
|
||||
'border-%s-radius: calc(%s + %s);',
|
||||
esc_attr( $name ),
|
||||
@@ -396,7 +406,14 @@ function styles_for_block_core_search( $attributes ) {
|
||||
}
|
||||
} else {
|
||||
// Numeric check is for backwards compatibility purposes.
|
||||
$border_radius = is_numeric( $border_radius ) ? $border_radius . 'px' : $border_radius;
|
||||
$border_radius = is_numeric( $border_radius ) ? $border_radius . 'px' : $border_radius;
|
||||
// Get border-radius CSS variable from preset value if provided.
|
||||
if ( is_string( $border_radius ) && str_contains( $border_radius, 'var:preset|border-radius|' ) ) {
|
||||
$index_to_splice = strrpos( $border_radius, '|' ) + 1;
|
||||
$slug = _wp_to_kebab_case( substr( $border_radius, $index_to_splice ) );
|
||||
$border_radius = "var(--wp--preset--border-radius--$slug)";
|
||||
}
|
||||
|
||||
$border_style = sprintf( 'border-radius: %s;', esc_attr( $border_radius ) );
|
||||
$input_styles[] = $border_style;
|
||||
$button_styles[] = $border_style;
|
||||
|
||||
Reference in New Issue
Block a user