Skip to content

Commit

Permalink
Chore: renaming functions to fit 6.1 (#44266)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Sep 19, 2022
1 parent 56c97e8 commit cfc881a
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/compat/wordpress-6.1/theme.php
Expand Up @@ -30,7 +30,7 @@ function gutenberg_create_initial_theme_features() {
}
add_action( 'setup_theme', 'gutenberg_create_initial_theme_features', 0 );

if ( ! function_exists( 'wp_theme_element_class_name' ) ) {
if ( ! function_exists( 'wp_theme_get_element_class_name' ) ) {
/**
* Given an element name, returns a class name.
* Alias from WP_Theme_JSON_Gutenberg::get_element_class_name.
Expand All @@ -41,7 +41,7 @@ function gutenberg_create_initial_theme_features() {
*
* @since 6.1.0
*/
function wp_theme_element_class_name( $element ) {
function wp_theme_get_element_class_name( $element ) {
return WP_Theme_JSON_Gutenberg::get_element_class_name( $element );
}
}
2 changes: 1 addition & 1 deletion packages/block-library/src/comments/index.php
Expand Up @@ -109,7 +109,7 @@ function register_block_core_comments() {
*/
function comments_block_form_defaults( $fields ) {
if ( wp_is_block_theme() ) {
$fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link ' . wp_theme_element_class_name( 'button' ) . '" value="%4$s" />';
$fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link ' . wp_theme_get_element_class_name( 'button' ) . '" value="%4$s" />';
$fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
}

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-comments-form/index.php
Expand Up @@ -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'] = '<input name="%1$s" type="submit" id="%2$s" class="wp-block-button__link ' . wp_theme_element_class_name( 'button' ) . '" value="%4$s" />';
$fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="wp-block-button__link ' . wp_theme_get_element_class_name( 'button' ) . '" value="%4$s" />';
$fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
}

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-featured-image/index.php
Expand Up @@ -175,7 +175,7 @@ function get_block_core_post_featured_image_border_attributes( $attributes ) {
);
}

$styles = gutenberg_style_engine_get_styles( array( 'border' => $border_styles ) );
$styles = wp_style_engine_get_styles( array( 'border' => $border_styles ) );
$attributes = array();
if ( ! empty( $styles['classnames'] ) ) {
$attributes['class'] = $styles['classnames'];
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/search/index.php
Expand Up @@ -121,7 +121,7 @@ function render_block_core_search( $attributes ) {
}

// Include the button element class.
$button_classes[] = wp_theme_element_class_name( 'button' );
$button_classes[] = wp_theme_get_element_class_name( 'button' );
$button_markup = sprintf(
'<button type="submit" class="%s" %s %s>%s</button>',
esc_attr( implode( ' ', $button_classes ) ),
Expand Down
4 changes: 2 additions & 2 deletions phpunit/class-wp-theme-json-test.php
Expand Up @@ -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_element_class_name( 'button' );
$actual = WP_Theme_JSON_Gutenberg::get_element_class_name( 'button' );

$this->assertEquals( $expected, $actual );
}

function test_get_element_class_name_invalid() {
$expected = '';
$actual = wp_theme_element_class_name( 'unknown-element' );
$actual = WP_Theme_JSON_Gutenberg::get_element_class_name( 'unknown-element' );

$this->assertEquals( $expected, $actual );
}
Expand Down
1 change: 1 addition & 0 deletions tools/webpack/blocks.js
Expand Up @@ -30,6 +30,7 @@ const blockViewRegex = new RegExp(
const prefixFunctions = [
'build_query_vars_from_query_block',
'wp_enqueue_block_support_styles',
'wp_style_engine_get_styles',
];

/**
Expand Down

0 comments on commit cfc881a

Please sign in to comment.