Merged in feature/81-dev-dev01 (pull request #5)

auto-patch  81-dev-dev01-2023-12-05T22_45_26

* auto-patch  81-dev-dev01-2023-12-05T22_45_26
This commit is contained in:
Tony Volpe
2023-12-05 23:05:59 +00:00
parent ba16964e7a
commit 725d3043d5
1463 changed files with 142461 additions and 89421 deletions

View File

@@ -46,6 +46,9 @@ function render_block_core_search( $attributes, $content, $block ) {
'button-inside' === $attributes['buttonPosition'];
// Border color classes need to be applied to the elements that have a border color.
$border_color_classes = get_border_color_classes_for_block_core_search( $attributes );
// This variable is a constant and its value is always false at this moment.
// It is defined this way because some values depend on it, in case it changes in the future.
$open_by_default = 'false';
$label_inner_html = empty( $attributes['label'] ) ? __( 'Search' ) : wp_kses_post( $attributes['label'] );
$label = new WP_HTML_Tag_Processor( sprintf( '<label %1$s>%2$s</label>', $inline_styles['label'], $label_inner_html ) );
@@ -77,6 +80,9 @@ function render_block_core_search( $attributes, $content, $block ) {
$is_expandable_searchfield = 'button-only' === $button_position && 'expand-searchfield' === $button_behavior;
if ( $is_expandable_searchfield ) {
$input->set_attribute( 'data-wp-bind--aria-hidden', '!context.core.search.isSearchInputVisible' );
$input->set_attribute( 'data-wp-bind--tabindex', 'selectors.core.search.tabindex' );
// Adding these attributes manually is needed until the Interactivity API SSR logic is added to core.
$input->set_attribute( 'aria-hidden', 'true' );
$input->set_attribute( 'tabindex', '-1' );
}
@@ -139,9 +145,16 @@ function render_block_core_search( $attributes, $content, $block ) {
if ( $button->next_tag() ) {
$button->add_class( implode( ' ', $button_classes ) );
if ( 'expand-searchfield' === $attributes['buttonBehavior'] && 'button-only' === $attributes['buttonPosition'] ) {
$button->set_attribute( 'data-wp-bind--aria-label', 'selectors.core.search.ariaLabel' );
$button->set_attribute( 'data-wp-bind--aria-controls', 'selectors.core.search.ariaControls' );
$button->set_attribute( 'data-wp-bind--aria-expanded', 'context.core.search.isSearchInputVisible' );
$button->set_attribute( 'data-wp-bind--type', 'selectors.core.search.type' );
$button->set_attribute( 'data-wp-on--click', 'actions.core.search.openSearchInput' );
// Adding these attributes manually is needed until the Interactivity API SSR logic is added to core.
$button->set_attribute( 'aria-label', __( 'Expand search field' ) );
$button->set_attribute( 'aria-controls', 'wp-block-search__input-' . $input_id );
$button->set_attribute( 'aria-expanded', 'false' );
$button->set_attribute( 'type', 'button' );
} else {
$button->set_attribute( 'aria-label', wp_strip_all_tags( $attributes['buttonText'] ) );
}
@@ -158,11 +171,24 @@ function render_block_core_search( $attributes, $content, $block ) {
$wrapper_attributes = get_block_wrapper_attributes(
array( 'class' => $classnames )
);
$form_directives = '';
if ( $is_expandable_searchfield ) {
$aria_label_expanded = __( 'Submit Search' );
$aria_label_collapsed = __( 'Expand search field' );
$form_directives = '
data-wp-interactive
data-wp-context=\'{ "core": { "search": { "isSearchInputVisible": ' . $open_by_default . ', "inputId": "' . $input_id . '", "ariaLabelExpanded": "' . $aria_label_expanded . '", "ariaLabelCollapsed": "' . $aria_label_collapsed . '" } } }\'
data-wp-class--wp-block-search__searchfield-hidden="!context.core.search.isSearchInputVisible"
data-wp-on--keydown="actions.core.search.handleSearchKeydown"
data-wp-on--focusout="actions.core.search.handleSearchFocusout"
';
}
return sprintf(
'<form role="search" method="get" action="%s" %s>%s</form>',
'<form role="search" method="get" action="%1s" %2s %3s>%4s</form>',
esc_url( home_url( '/' ) ),
$wrapper_attributes,
$form_directives,
$label . $field_markup
);
}
@@ -180,6 +206,25 @@ function register_block_core_search() {
}
add_action( 'init', 'register_block_core_search' );
/**
* Ensure that the view script has the `wp-interactivity` dependency.
*
* @since 6.4.0
*
* @global WP_Scripts $wp_scripts
*/
function block_core_search_ensure_interactivity_dependency() {
global $wp_scripts;
if (
isset( $wp_scripts->registered['wp-block-search-view'] ) &&
! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-search-view']->deps, true )
) {
$wp_scripts->registered['wp-block-search-view']->deps[] = 'wp-interactivity';
}
}
add_action( 'wp_print_scripts', 'block_core_search_ensure_interactivity_dependency' );
/**
* Builds the correct top level classnames for the 'core/search' block.
*
@@ -236,11 +281,9 @@ function classnames_for_block_core_search( $attributes ) {
* @param array $wrapper_styles Current collection of wrapper styles.
* @param array $button_styles Current collection of button styles.
* @param array $input_styles Current collection of input styles.
*
* @return void
*/
function apply_block_core_search_border_style( $attributes, $property, $side, &$wrapper_styles, &$button_styles, &$input_styles ) {
$is_button_inside = 'button-inside' === _wp_array_get( $attributes, array( 'buttonPosition' ), false );
$is_button_inside = isset( $attributes['buttonPosition'] ) && 'button-inside' === $attributes['buttonPosition'];
$path = array( 'style', 'border', $property );
@@ -282,8 +325,6 @@ function apply_block_core_search_border_style( $attributes, $property, $side, &$
* @param array $wrapper_styles Current collection of wrapper styles.
* @param array $button_styles Current collection of button styles.
* @param array $input_styles Current collection of input styles.
*
* @return void
*/
function apply_block_core_search_border_styles( $attributes, $property, &$wrapper_styles, &$button_styles, &$input_styles ) {
apply_block_core_search_border_style( $attributes, $property, null, $wrapper_styles, $button_styles, $input_styles );