Add JavaScript to conditionally disable the publish button in the classic Editor
This PR solves : https://core.trac.wordpress.org/ticket/62769
Summary
This PR adds logic to disable the "Publish" button in the Classic Editor interface when both the post title and content fields are empty. The button is automatically re-enabled once either field has valid input.
Key Features
Applies to:
post, page, and any custom post types (CPTs) using the Classic Editor.
Skips block editor (Gutenberg) screens using use_block_editor_for_post_type().
Prevents users from accidentally publishing completely empty content.
Improves UX by disabling the button immediately on page load (avoids flicker).
Listens to title input and content changes (including TinyMCE events).
Technical Details
Hook used: admin_print_footer_scripts
Detects screen type using get_current_screen().
Disables #publish button early and conditionally re-enables it.
TinyMCE support: content changes tracked even within WYSIWYG editor.
How to Test
Open the Classic Editor for any post, page, or CPT.
Ensure both the title and content fields are empty.
Observe that the "Publish" button is disabled on load.
Add either a title or content — the button should become enabled.
Clear both fields — the button should disable again.
Notes
This change is purely front-end (JS in admin), ensuring a better editorial workflow. It does not add server-side validation — users with direct access (e.g., via REST API or browser overrides) can still submit empty posts.