Skip to content

Commit

Permalink
Trim whitespace from rendered widgets (#24789)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel authored Aug 26, 2020
1 parent 33beaf4 commit 9c1f6fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/class-wp-rest-sidebars-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public static function get_widgets( $sidebar_id ) {

call_user_func_array( $widget['callback'], $widget_parameters );

$widget['rendered'] = ob_get_clean();
$widget['rendered'] = trim( ob_get_clean() );
}

if ( is_array( $widget['callback'] ) && isset( $widget['callback'][0] ) ) {
Expand Down
6 changes: 3 additions & 3 deletions phpunit/class-rest-sidebars-controller-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function test_get_items_active_sidebar_with_widgets() {
'name' => 'Text',
'description' => 'Arbitrary text.',
'number' => 1,
'rendered' => ' <div class="textwidget">Custom text test</div>' . "\n ",
'rendered' => '<div class="textwidget">Custom text test</div>',
),
array(
'id' => 'rss-1',
Expand Down Expand Up @@ -356,7 +356,7 @@ public function test_update_item() {
'name' => 'Text',
'description' => 'Arbitrary text.',
'number' => 1,
'rendered' => ' <div class="textwidget">Updated text test</div>' . "\n ",
'rendered' => '<div class="textwidget">Updated text test</div>',
),
array(
'id' => 'text-2',
Expand All @@ -370,7 +370,7 @@ public function test_update_item() {
'name' => 'Text',
'description' => 'Arbitrary text.',
'number' => 2,
'rendered' => ' <div class="textwidget">Another text widget</div>' . "\n ",
'rendered' => '<div class="textwidget">Another text widget</div>',
),
),
),
Expand Down

0 comments on commit 9c1f6fd

Please sign in to comment.