Skip to content

Commit f82284e

Browse files
committed
trim template output.
1 parent b406116 commit f82284e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/blocks/class-renderer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,17 @@ public function get_template_part_dir(): string {
144144
* Loads a template part into a template.
145145
*
146146
* @param string $slug The slug name for the generic template.
147-
* @param string $name The name of the specialised template.
147+
* @param string|null $name The name of the specialised template.
148148
*
149149
* @return string
150150
*/
151-
public function get_template_part( string $slug, $name = null ): string {
151+
public function get_template_part( string $slug, ?string $name = null ): string {
152152
ob_start();
153153
get_template_part( $slug, $name, $this->args );
154154
$output = ob_get_contents();
155155
ob_end_clean();
156156

157-
return $output;
157+
return trim( $output );
158158
}
159159

160160
/**
@@ -169,9 +169,9 @@ public function get_template_part( string $slug, $name = null ): string {
169169
*
170170
* @param array $attributes Block attributes.
171171
*
172-
* @return false|string
172+
* @return string
173173
*/
174-
protected function get_content_from_template( array $attributes ) {
174+
protected function get_content_from_template( array $attributes ): string {
175175
$class_name = join( ' ', $this->get_class_names( $attributes ) );
176176
$this->set_template_args( 'class_name', $class_name );
177177
$path = array(
@@ -250,7 +250,7 @@ protected function get_content_from_default_template( string $name ) {
250250
* @param array $args URL query string or array of vars.
251251
* @param string $query_var query var.
252252
*/
253-
protected function setup_query( array $args, $query_var = 'query' ) {
253+
protected function setup_query( array $args, string $query_var = 'query' ) {
254254
$args = apply_filters( 'advanced_posts_blocks_posts_query', $args, $this->name );
255255
$this->query = new WP_Query( $args );
256256
$this->set_template_args( $query_var, $this->query );
@@ -272,7 +272,7 @@ function ( $class ) {
272272
}
273273
);
274274

275-
if ( ! empty( $styles ) && is_array( $styles ) ) {
275+
if ( ! empty( $styles ) ) {
276276
$style = reset( $styles );
277277

278278
return str_replace( 'is-style-', '', $style );

src/blocks/posts/class-matrix-term-query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Matrix_Term_Query {
3232
*
3333
* @param string $query_var Query var.
3434
*/
35-
public function __construct( $query_var = 'advanced_posts_blocks_preview' ) {
35+
public function __construct( string $query_var = 'advanced_posts_blocks_preview' ) {
3636
if ( $query_var ) {
3737
$this->query_var = $query_var;
3838
}

0 commit comments

Comments
 (0)