Fix #1956: restrict admin scripts to CB pages only - #29
Open
datengraben wants to merge 3 commits into
Open
Conversation
CommonsBooking was loading jQuery UI (tooltip, datepicker) and its admin
JS bundle on every WordPress admin page. The global $(document).tooltip()
call in particular interfered with the wp-inventory-manager plugin's
drag-and-drop settings UI, causing items in the right column to disappear
on save.
Fix: add an early return in commonsbooking_admin() when the current screen
is not a CommonsBooking post type, taxonomy, or menu page — mirroring the
existing filterAdminBodyClass() logic in Plugin.php. Also scope the tooltip
initialisation from $(document) to $('body.cb-admin') as defense-in-depth.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CCS1aQ2YcjSuggdLSGk4AR
Cache::addWarmupAjaxToOutput() referenced cb_ajax_cache_warmup which was only localized by commonsbooking_admin(). After restricting that function to CB pages, the warmup AJAX call would fail with a ReferenceError on any non-CB admin page (and silently on frontend pages). Fix by localizing the nonce and URL directly onto the cache_warmup script handle. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CCS1aQ2YcjSuggdLSGk4AR
PostStatus::addOption() was appending canceled/confirmed/unconfirmed options to the post-status dropdown on every post edit screen, and addQuickedit() did the same for the quickedit dropdown on every edit.php list page. Add a $post_types array to PostStatus and guard both callbacks with it. Pass [Booking::$postType] from registerPostStates() so the statuses only appear on cb_booking edit and list screens. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CCS1aQ2YcjSuggdLSGk4AR
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.
CommonsBooking was loading jQuery UI (tooltip, datepicker) and its admin
JS bundle on every WordPress admin page. The global $(document).tooltip()
call in particular interfered with the wp-inventory-manager plugin's
drag-and-drop settings UI, causing items in the right column to disappear
on save.
Fix: add an early return in commonsbooking_admin() when the current screen$(document) to $ ('body.cb-admin') as defense-in-depth.
is not a CommonsBooking post type, taxonomy, or menu page — mirroring the
existing filterAdminBodyClass() logic in Plugin.php. Also scope the tooltip
initialisation from
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01CCS1aQ2YcjSuggdLSGk4AR