Replace new lines with empty strings when outputting catgeory list (https://github.com/woocommerce/woocommerce-blocks/pull/4587)

* Replace new lines with empty strings when outputting catgeory list

This is because br tags are being added because of linebreaks in the string. If we replace the linebreaks with empty strings they won't be converted into br elements.

* Add parentheses around product count

* Remove spaces from around title

* Remove parentheses from product count
This commit is contained in:
Thomas Roberts 2021-08-20 12:57:58 +01:00 committed by GitHub
parent 48cf656269
commit b403872300
1 changed files with 2 additions and 4 deletions

View File

@ -304,16 +304,14 @@ class ProductCategories extends AbstractDynamicBlock {
foreach ( $categories as $category ) {
$output .= '
<li class="wc-block-product-categories-list-item">
<a href="' . esc_attr( get_term_link( $category->term_id, 'product_cat' ) ) . '">
' . $this->get_image_html( $category, $attributes ) . esc_html( $category->name ) . '
</a>
<a href="' . esc_attr( get_term_link( $category->term_id, 'product_cat' ) ) . '">' . $this->get_image_html( $category, $attributes ) . esc_html( $category->name ) . '</a>
' . $this->getCount( $category, $attributes ) . '
' . ( ! empty( $category->children ) ? $this->renderList( $category->children, $attributes, $uid, $depth + 1 ) : '' ) . '
</li>
';
}
return $output;
return preg_replace( '/\r|\n/', '', $output );
}
/**