diff --git a/lib/compat/wordpress-6.1/theme.php b/lib/compat/wordpress-6.1/theme.php index 441fc63071436..4787f1057b474 100644 --- a/lib/compat/wordpress-6.1/theme.php +++ b/lib/compat/wordpress-6.1/theme.php @@ -29,3 +29,19 @@ function gutenberg_create_initial_theme_features() { ); } add_action( 'setup_theme', 'gutenberg_create_initial_theme_features', 0 ); + +if ( ! function_exists( 'wp_theme_element_class_name' ) ) { + /** + * Given an element name, returns a class name. + * Alias from WP_Theme_JSON_Gutenberg::get_element_class_name. + * + * @param string $element The name of the element. + * + * @return string The name of the class. + * + * @since 6.1.0 + */ + function wp_theme_element_class_name( $element ) { + return WP_Theme_JSON_Gutenberg::get_element_class_name( $element ); + } +} diff --git a/packages/block-library/src/comments/index.php b/packages/block-library/src/comments/index.php index 14fe6355a11a7..edc1bedab083f 100644 --- a/packages/block-library/src/comments/index.php +++ b/packages/block-library/src/comments/index.php @@ -109,7 +109,7 @@ function register_block_core_comments() { */ function comments_block_form_defaults( $fields ) { if ( wp_is_block_theme() ) { - $fields['submit_button'] = ''; + $fields['submit_button'] = ''; $fields['submit_field'] = '

%1$s %2$s

'; } diff --git a/packages/block-library/src/post-comments-form/index.php b/packages/block-library/src/post-comments-form/index.php index 40dad1a530495..4bbd24b245411 100644 --- a/packages/block-library/src/post-comments-form/index.php +++ b/packages/block-library/src/post-comments-form/index.php @@ -72,7 +72,7 @@ function register_block_core_post_comments_form() { */ function post_comments_form_block_form_defaults( $fields ) { if ( wp_is_block_theme() ) { - $fields['submit_button'] = ''; + $fields['submit_button'] = ''; $fields['submit_field'] = '

%1$s %2$s

'; } diff --git a/packages/block-library/src/search/index.php b/packages/block-library/src/search/index.php index 8e2a158969acb..40cf5fcf5478f 100644 --- a/packages/block-library/src/search/index.php +++ b/packages/block-library/src/search/index.php @@ -121,7 +121,7 @@ function render_block_core_search( $attributes ) { } // Include the button element class. - $button_classes[] = WP_Theme_JSON_Gutenberg::get_element_class_name( 'button' ); + $button_classes[] = wp_theme_element_class_name( 'button' ); $button_markup = sprintf( '', esc_attr( implode( ' ', $button_classes ) ), diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index 42146c66e6635..35c4bf153ddb2 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -797,14 +797,14 @@ function test_remove_invalid_element_pseudo_selectors() { function test_get_element_class_name_button() { $expected = 'wp-element-button'; - $actual = WP_Theme_JSON_Gutenberg::get_element_class_name( 'button' ); + $actual = wp_theme_element_class_name( 'button' ); $this->assertEquals( $expected, $actual ); } function test_get_element_class_name_invalid() { $expected = ''; - $actual = WP_Theme_JSON_Gutenberg::get_element_class_name( 'unknown-element' ); + $actual = wp_theme_element_class_name( 'unknown-element' ); $this->assertEquals( $expected, $actual ); }