| @@ -1,5 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- view template receives variables via extract(); prefixing is impractical. | |
| 3 | + | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; | |
| 6 | +} | |
| 2 | 7 | if ( ! $show_count ) { |
| 3 | 8 | return; |
| 4 | 9 | } |
| 5 | 10 | |
| @@ -17,8 +22,14 @@ | ||
| 17 | 22 | $suffix = apply_filters( 'betterdocs_category_items_counts_suffix', $suffix, get_defined_vars() ); |
| 18 | 23 | $suffix_singular = apply_filters( 'betterdocs_category_items_counts_suffix_singular', $suffix_singular, get_defined_vars() ); |
| 19 | 24 | $subcategory_singular_text = isset( $subcategory_text ) ? $subcategory_text : __( 'Sub Category', 'betterdocs' ); // Default singular subcategory text. |
| 20 | 25 | $subcategory_plural_text = isset( $subcategories_text ) ? $subcategories_text : __( 'Sub Categories', 'betterdocs' ); // Default plural subcategory text. |
| 26 | + | |
| 27 | +// These are not always supplied by the caller (e.g. TemplateTags::sub_category_counts() | |
| 28 | +// only passes show_count + counts). Default them so PHP 8.x does not emit | |
| 29 | +// "Undefined variable" warnings; the defaults preserve the existing branch outcomes. | |
| 30 | +$taxonomy = isset( $taxonomy ) ? $taxonomy : ''; | |
| 31 | +$sub_terms_count = isset( $sub_terms_count ) ? $sub_terms_count : 0; | |
| 21 | 32 | ?> |
| 22 | 33 | |
| 23 | 34 | <div data-count="<?php echo esc_attr( $counts ); ?>" class="betterdocs-sub-category-items-counts"> |
| 24 | 35 | <?php |