Skip to content

P1/P3: Small correctness fixes (empty translation, dead ??, hardcoded path, redundant echo) #106

Description

@Herm71

Roadmap items 11, 13, 22, 25. Grouped: each is a small, independent, low-risk correction. One PR.

Roadmap item 11 (P1, verified) — esc_html__( '', 'ucsc' )

Translating the empty string returns the PO file's metadata header (Project-Id-Version: …), not ''. Whatever this label is meant to be, it should either be a real string or not call a translation function at all.

📍 src/Blocks/Query_Loop.php:102

Roadmap item 13 (P1) — dead null-coalesce on posts_per_page

(int) get_field( 'posts_per_page' ) ?? self::PER_PAGE

A cast never yields null, so ?? is unreachable. When the field is missing — which is the case for News blocks inserted before the field was added — the expression is 0, which flows into array_slice( …, 0, 0 ) and renders an empty block.

Fix: resolve the field first, then fall back when it is empty/non-numeric, and cast after.

📍 src/Components/News_Block_Controller.php:42

Roadmap item 22 (P3) — hardcoded plugin path

Settings page hardcodes WP_PLUGIN_DIR . '/ucsc-custom-functionality/plugin.php', which breaks if the plugin directory is renamed (it is, on some installs and in some deploy flows).

Fix: derive from plugin_dir_path() / plugin_basename() or a constant defined in plugin.php.

📍 lib/functions/settings.php:42

Roadmap item 25 (P3) — echo _e( … )

_e() already echoes; the surrounding echo prints its void return. Harmless but phpcs-flagged.

📍 src/views/news-block/index.php:37

Acceptance

  • All four corrected
  • News block with no posts_per_page value renders the default count, not zero posts
  • Settings page resolves correctly with the plugin directory renamed
  • phpcs clean on the touched lines

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Correctness & securitybugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions