Skip to content

Fix #1956: restrict admin scripts to CB pages only - #29

Open
datengraben wants to merge 3 commits into
masterfrom
claude/cb-wp-inventory-compat-l9yj79
Open

Fix #1956: restrict admin scripts to CB pages only#29
datengraben wants to merge 3 commits into
masterfrom
claude/cb-wp-inventory-compat-l9yj79

Conversation

@datengraben

Copy link
Copy Markdown
Owner

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

claude added 3 commits June 22, 2026 20:29
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
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.

2 participants