-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Summary
Several legacy code patterns in `index.php` need cleanup:
1. Duplicate enqueue logic (`post_enqueue` / `post_new_enqueue`)
Both methods contain ~30 lines of near-identical script/style enqueue code, differing only in the hook value checked. Should be extracted into a single shared private method.
2. Dead code in `bsf_color_scripts()`
The method checks `if ( 3.5 <= $wp_version )` to decide between `wp-color-picker` and the older `farbtastic`. Since the plugin requires WP 3.7+, the `farbtastic` branch can never execute and should be removed.
3. Bare `die()` in AJAX handlers
`submit_request()` and `submit_color()` both call bare `die()` to terminate. WordPress AJAX handlers should use `wp_die()` for proper interoperability.
4. `esc_html_e()` misused in ternary expressions
`esc_html_e()` echoes and returns `null`, so the ternary condition is always truthy — incorrect output when the operation fails. Should be restructured with `if/else`.
Acceptance Criteria
- `post_enqueue` / `post_new_enqueue` share a single extracted helper
- Dead `farbtastic` branch removed from `bsf_color_scripts()`
- `die()` replaced with `wp_die()` in AJAX handlers
- Ternary `esc_html_e` antipattern fixed in `submit_request()` and `submit_color()`
- PHPCS/PHPStan pass with no new errors