Skip to content

Commit efa4cbc

Browse files
committed
Fix boolean checks for show_empty_sections and clickable_section arguments
1 parent ba11ef3 commit efa4cbc

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

includes/frontend/class-display.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ private static function render_product_sections_only( int $product_id, array $ar
310310
'wzkb_category',
311311
array(
312312
'parent' => 0,
313-
'hide_empty' => ! $args['show_empty_sections'],
313+
'hide_empty' => empty( $args['show_empty_sections'] ),
314314
),
315315
array(
316316
array(
@@ -433,7 +433,7 @@ public static function get_knowledge_base_loop( int $term_id, int $level, bool $
433433
'wzkb_category',
434434
array(
435435
'parent' => 0,
436-
'hide_empty' => ! $local_args['show_empty_sections'],
436+
'hide_empty' => empty( $local_args['show_empty_sections'] ),
437437
)
438438
);
439439

@@ -477,7 +477,7 @@ public static function get_knowledge_base_loop( int $term_id, int $level, bool $
477477
array(
478478
'orderby' => 'slug',
479479
'parent' => $term_id,
480-
'hide_empty' => ! $local_args['show_empty_sections'],
480+
'hide_empty' => empty( $local_args['show_empty_sections'] ),
481481
)
482482
);
483483

@@ -631,13 +631,13 @@ public static function get_article_header( $term, int $level, array $args = arra
631631
$heading_level = min( 2 + $level, 6 ); // Start at h3, max h6.
632632
$output = '<h' . $heading_level . ' class="wzkb-section-name wzkb-section-name-level-' . $level . '">';
633633

634-
if ( $args['clickable_section'] ) {
634+
if ( ! empty( $args['clickable_section'] ) ) {
635635
$output .= '<a href="' . esc_url( get_term_link( $term ) ) . '" title="' . esc_attr( $term->name ) . '">' . esc_html( $term->name ) . '</a>';
636636
} else {
637637
$output .= esc_html( $term->name );
638638
}
639639

640-
if ( $args['show_article_count'] ) {
640+
if ( ! empty( $args['show_article_count'] ) ) {
641641
/* translators: %d: Number of articles within a section. */
642642
$count_text = sprintf( _n( '%d article', '%d articles', $term->count, 'knowledgebase' ), $term->count );
643643
$output .= '<span class="wzkb-section-count" aria-label="' . esc_attr( $count_text ) . '">' . $term->count . '</span>';
@@ -740,7 +740,7 @@ public static function get_categories_list( $term_id, $level = 0, $args = array(
740740
array(
741741
'orderby' => 'slug',
742742
'parent' => $term_id,
743-
'hide_empty' => ! $args['show_empty_sections'],
743+
'hide_empty' => empty( $args['show_empty_sections'] ),
744744
)
745745
);
746746

@@ -997,7 +997,7 @@ private static function render_product_archive( $products, $args ) {
997997

998998
// Display product title as clickable if clickable_section is enabled.
999999
$output .= '<h2 class="wzkb-product-title">';
1000-
if ( $args['clickable_section'] ) {
1000+
if ( ! empty( $args['clickable_section'] ) ) {
10011001
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_term_link is properly escaped below.
10021002
$output .= '<a href="' . esc_url( get_term_link( $product_term ) ) . '" title="' . esc_attr( $product_term->name ) . '">' . esc_html( $product_term->name ) . '</a>';
10031003
} else {

0 commit comments

Comments
 (0)