| @@ -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 | |
| @@ -20,22 +25,18 @@ | ||
| 20 | 25 | |
| 21 | 26 | <div data-count="<?php echo esc_attr( $counts ); ?>" class="betterdocs-category-items-counts"> |
| 22 | 27 | <span> |
| 23 | 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. | |
| 24 | 33 | echo esc_html( |
| 25 | 34 | sprintf( |
| 26 | - /* translators: %s: Number of items. */ | |
| 27 | - // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment, WordPress.WP.I18n.MismatchedPlaceholders | |
| 28 | - _n( | |
| 29 | - '%1$s %2$s %3$s', | |
| 30 | - '%1$s %2$s %4$s', | |
| 31 | - $counts, | |
| 32 | - 'betterdocs' | |
| 33 | - ), | |
| 35 | + '%1$s %2$s %3$s', | |
| 34 | 36 | esc_html( $prefix ), |
| 35 | 37 | esc_html( $counts ), |
| 36 | - esc_html( $suffix_singular ), | |
| 37 | - esc_html( $suffix ) | |
| 38 | + esc_html( $counts === 1 ? $suffix_singular : $suffix ) | |
| 38 | 39 | ) |
| 39 | 40 | ); |
| 40 | 41 | ?> |
| 41 | 42 | </span> |