Skip to content

Commit

Permalink
Fix linting errors and failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Sep 9, 2022
1 parent df92b89 commit ba0c848
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
10 changes: 8 additions & 2 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,13 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) {
}
$settings[ $settings_field_name ] = $processed_scripts;
} else {
$settings[ $settings_field_name ] = register_block_script_handle(
$result = register_block_script_handle(
$metadata,
$metadata_field_name
);
if ( $result ) {
$settings[ $settings_field_name ] = $result;
}
}
}
}
Expand All @@ -391,10 +394,13 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) {
}
$settings[ $settings_field_name ] = $processed_styles;
} else {
$settings[ $settings_field_name ] = register_block_style_handle(
$result = register_block_style_handle(
$metadata,
$metadata_field_name
);
if ( $result ) {
$settings[ $settings_field_name ] = $result;
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2503,28 +2503,28 @@ function wp_enqueue_registered_block_scripts_and_styles() {
foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) {
// Front-end styles.
if ( ! empty( $block_type->style ) ) {
foreach ( (array) $block_type->style as $single_style ) {
foreach ( (array) $block_type->style as $single_style ) {
wp_enqueue_style( $single_style );
}
}

// Front-end scripts.
if ( ! empty( $block_type->script ) ) {
foreach ( (array) $block_type->script as $single_script ) {
foreach ( (array) $block_type->script as $single_script ) {
wp_enqueue_script( $single_script );
}
}

// Editor styles.
if ( $load_editor_scripts && ! empty( $block_type->editor_style ) ) {
foreach ( (array) $block_type->editor_style as $single_editor_style ) {
foreach ( (array) $block_type->editor_style as $single_editor_style ) {
wp_enqueue_style( $single_editor_style );
}
}

// Editor scripts.
if ( $load_editor_scripts && ! empty( $block_type->editor_script ) ) {
foreach ( (array) $block_type->editor_script as $single_editor_script ) {
foreach ( (array) $block_type->editor_script as $single_editor_script ) {
wp_enqueue_script( $single_editor_script );
}
}
Expand Down
20 changes: 10 additions & 10 deletions tests/phpunit/tests/rest-api/rest-block-type-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ public function test_get_item_invalid() {
$this->assertSame( '1', $data['title'] );
$this->assertSame( '1', $data['description'] );
$this->assertNull( $data['icon'] );
$this->assertNull( $data['editor_script'] );
$this->assertNull( $data['script'] );
$this->assertNull( $data['view_script'] );
$this->assertNull( $data['editor_style'] );
$this->assertNull( $data['style'] );
$this->assertSameSets( array( '1' ), $data['editor_script'] );
$this->assertSameSets( array( '1' ), $data['script'] );
$this->assertSameSets( array( '1' ), $data['view_script'] );
$this->assertSameSets( array( '1' ), $data['editor_style'] );
$this->assertSameSets( array( '1' ), $data['style'] );
$this->assertSameSets( array(), $data['provides_context'] );
$this->assertSameSetsWithIndex(
array(
Expand Down Expand Up @@ -299,11 +299,11 @@ public function test_get_item_defaults() {
$this->assertSame( '', $data['title'] );
$this->assertSame( '', $data['description'] );
$this->assertNull( $data['icon'] );
$this->assertNull( $data['editor_script'] );
$this->assertNull( $data['script'] );
$this->assertNull( $data['view_script'] );
$this->assertNull( $data['editor_style'] );
$this->assertNull( $data['style'] );
$this->assertSameSets( array(), $data['editor_script'] );
$this->assertSameSets( array(), $data['script'] );
$this->assertSameSets( array(), $data['view_script'] );
$this->assertSameSets( array(), $data['editor_style'] );
$this->assertSameSets( array(), $data['style'] );
$this->assertSameSetsWithIndex(
array(
'lock' => array( 'type' => 'object' ),
Expand Down

0 comments on commit ba0c848

Please sign in to comment.