| 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 |
} |
| 7 |
if ( ! $show_count ) { |
| 8 |
return; |
| 9 |
} |
| 10 |
|
| 11 |
$prefix = $suffix = $suffix_singular = ''; |
| 12 |
|
| 13 |
if ( is_array( $counts ) ) { |
| 14 |
$prefix = $counts['prefix']; |
| 15 |
$_count = $counts['counts']; |
| 16 |
$suffix = $counts['suffix']; |
| 17 |
$suffix_singular = $counts['suffix_singular']; |
| 18 |
$counts = $_count; |
| 19 |
} |
| 20 |
|
| 21 |
$prefix = apply_filters( 'betterdocs_category_items_counts_prefix', $prefix, get_defined_vars() ); |
| 22 |
$suffix = apply_filters( 'betterdocs_category_items_counts_suffix', $suffix, get_defined_vars() ); |
| 23 |
$suffix_singular = apply_filters( 'betterdocs_category_items_counts_suffix_singular', $suffix_singular, get_defined_vars() ); |
| 24 |
?> |
| 25 |
|
| 26 |
<div data-count="<?php echo esc_attr( $counts ); ?>" class="betterdocs-category-items-counts"> |
| 27 |
<span> |
| 28 |
<?php |
| 29 |
// Layout-only format string — not wrapped in _n() because it contains |
| 30 |
// nothing but positional placeholders, and translator typos in the |
| 31 |
// placeholder numbers (e.g. %4$s instead of %3$s) crash sprintf() on |
| 32 |
// PHP 8.x with ArgumentCountError. |
| 33 |
echo esc_html( |
| 34 |
sprintf( |
| 35 |
'%1$s %2$s %3$s', |
| 36 |
esc_html( $prefix ), |
| 37 |
esc_html( $counts ), |
| 38 |
esc_html( $counts === 1 ? $suffix_singular : $suffix ) |
| 39 |
) |
| 40 |
); |
| 41 |
?> |
| 42 |
</span> |
| 43 |
</div> |
| 44 |
|