Add core data structures for Buildings and Rooms (v0.1.0)
All checks were successful
Create Release Package / build-release (push) Successful in 1m6s

Phase 1 implementation includes:
- Custom Post Type: Buildings with address, contact, and details meta
- Custom Post Type: Rooms with building relationship and gallery
- Custom Taxonomy: Room Types (hierarchical)
- Custom Taxonomy: Amenities (non-hierarchical with icons)
- Admin columns, filters, and status badges
- Gallery meta box with media library integration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 13:45:06 +01:00
parent d36b6c3dd9
commit f24a347bb1
11 changed files with 2077 additions and 32 deletions

View File

@@ -91,9 +91,102 @@
}
}
/**
* Initialize room gallery functionality.
*/
function initRoomGallery() {
var $container = $('#bnb-room-gallery');
var $addButton = $('#bnb-add-gallery-images');
var $input = $('#bnb_room_gallery');
var $imagesContainer = $container.find('.bnb-gallery-images');
if (!$addButton.length) {
return;
}
// Media frame for selecting images.
var mediaFrame;
// Add images button click.
$addButton.on('click', function(e) {
e.preventDefault();
// If frame exists, reopen it.
if (mediaFrame) {
mediaFrame.open();
return;
}
// Create media frame.
mediaFrame = wp.media({
title: wpBnbAdmin.i18n.selectImages,
button: {
text: wpBnbAdmin.i18n.addToGallery
},
multiple: true,
library: {
type: 'image'
}
});
// Handle selection.
mediaFrame.on('select', function() {
var selection = mediaFrame.state().get('selection');
selection.each(function(attachment) {
var data = attachment.toJSON();
var thumbnail = data.sizes.thumbnail ? data.sizes.thumbnail.url : data.url;
// Check if already in gallery.
if ($imagesContainer.find('[data-id="' + data.id + '"]').length) {
return;
}
// Add image to gallery.
var $image = $('<div class="bnb-gallery-image" data-id="' + data.id + '">' +
'<img src="' + thumbnail + '" alt="">' +
'<button type="button" class="bnb-remove-image">&times;</button>' +
'</div>');
$imagesContainer.append($image);
});
updateGalleryInput();
});
mediaFrame.open();
});
// Remove image button click.
$imagesContainer.on('click', '.bnb-remove-image', function(e) {
e.preventDefault();
$(this).closest('.bnb-gallery-image').remove();
updateGalleryInput();
});
// Make gallery sortable.
$imagesContainer.sortable({
items: '.bnb-gallery-image',
cursor: 'move',
update: function() {
updateGalleryInput();
}
});
/**
* Update the hidden input with gallery image IDs.
*/
function updateGalleryInput() {
var ids = [];
$imagesContainer.find('.bnb-gallery-image').each(function() {
ids.push($(this).data('id'));
});
$input.val(ids.join(','));
}
}
// Initialize on document ready.
$(document).ready(function() {
initLicenseManagement();
initRoomGallery();
});
})(jQuery);