Skip to content

refactor: clean up legacy code in index.php#236

Open
akshayurankar48 wants to merge 1 commit intomasterfrom
refactor/legacy-code-cleanup
Open

refactor: clean up legacy code in index.php#236
akshayurankar48 wants to merge 1 commit intomasterfrom
refactor/legacy-code-cleanup

Conversation

@akshayurankar48
Copy link
Contributor

Summary

Closes #235

Cleans up four legacy code patterns in index.php:

  • Extracted duplicate enqueue logicpost_enqueue() and post_new_enqueue() shared ~30 lines of identical code. Both now delegate to a new private enqueue_post_editor_scripts() helper, eliminating the duplication.
  • Removed dead farbtastic branchbsf_color_scripts() checked if ( 3.5 <= $wp_version ) to choose between wp-color-picker and the legacy farbtastic. The plugin requires WP 3.7+, so the farbtastic branch was unreachable dead code.
  • Replaced die() with wp_die()submit_request() and submit_color() both used bare die() to terminate AJAX responses. Replaced with wp_die() per WordPress standards.
  • Fixed esc_html_e() in ternaryecho $result ? esc_html_e(...) : esc_html_e(...) was always truthy because esc_html_e() returns null. Restructured as if/else so failure messages are actually shown.

Test plan

  • Edit an existing post — confirm schema meta box scripts/styles load correctly
  • Create a new post — confirm schema meta box scripts/styles load correctly
  • Submit the support request form — confirm "Thank you!" / "Something went wrong!" messages display correctly
  • Save colour settings from the admin dashboard — confirm "Settings saved!" / error message displays correctly
  • Confirm no PHP syntax errors: php -l index.php

🤖 Generated with Claude Code

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: clean up legacy code in index.php

1 participant