refactor: clean up legacy code in index.php#236
Open
akshayurankar48 wants to merge 1 commit intomasterfrom
Open
refactor: clean up legacy code in index.php#236akshayurankar48 wants to merge 1 commit intomasterfrom
akshayurankar48 wants to merge 1 commit intomasterfrom
Conversation
- Extract duplicate enqueue logic from post_enqueue() and post_new_enqueue() into a shared private enqueue_post_editor_scripts() helper - Remove dead farbtastic fallback in bsf_color_scripts() — plugin requires WP 3.7+ so the WP < 3.5 branch was unreachable - Replace bare die() with wp_die() in submit_request() and submit_color() - Fix esc_html_e() misuse in ternary expressions — esc_html_e() returns null so the ternary was always truthy; restructured as if/else Closes #235
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #235
Cleans up four legacy code patterns in
index.php:post_enqueue()andpost_new_enqueue()shared ~30 lines of identical code. Both now delegate to a new privateenqueue_post_editor_scripts()helper, eliminating the duplication.farbtasticbranch —bsf_color_scripts()checkedif ( 3.5 <= $wp_version )to choose betweenwp-color-pickerand the legacyfarbtastic. The plugin requires WP 3.7+, so thefarbtasticbranch was unreachable dead code.die()withwp_die()—submit_request()andsubmit_color()both used baredie()to terminate AJAX responses. Replaced withwp_die()per WordPress standards.esc_html_e()in ternary —echo $result ? esc_html_e(...) : esc_html_e(...)was always truthy becauseesc_html_e()returnsnull. Restructured asif/elseso failure messages are actually shown.Test plan
php -l index.php🤖 Generated with Claude Code