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

@@ -10,6 +10,10 @@ declare( strict_types=1 );
namespace Magdev\WpBnb;
use Magdev\WpBnb\License\Manager as LicenseManager;
use Magdev\WpBnb\PostTypes\Building;
use Magdev\WpBnb\PostTypes\Room;
use Magdev\WpBnb\Taxonomies\Amenity;
use Magdev\WpBnb\Taxonomies\RoomType;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
@@ -67,6 +71,31 @@ final class Plugin {
// Add plugin action links.
add_filter( 'plugin_action_links_' . WP_BNB_BASENAME, array( $this, 'add_action_links' ) );
// Register custom post types and taxonomies.
$this->register_post_types();
$this->register_taxonomies();
}
/**
* Register custom post types.
*
* @return void
*/
private function register_post_types(): void {
Building::init();
Room::init();
}
/**
* Register custom taxonomies.
*
* @return void
*/
private function register_taxonomies(): void {
// Taxonomies must be registered before post types that use them.
Amenity::init();
RoomType::init();
}
/**
@@ -129,8 +158,14 @@ final class Plugin {
* @return void
*/
public function enqueue_admin_assets( string $hook_suffix ): void {
// Only load on plugin pages.
if ( strpos( $hook_suffix, 'wp-bnb' ) === false ) {
global $post_type;
// Check if we're on plugin pages or editing our custom post types.
$is_plugin_page = strpos( $hook_suffix, 'wp-bnb' ) !== false;
$is_our_post_type = in_array( $post_type, array( Building::POST_TYPE, Room::POST_TYPE ), true );
$is_edit_screen = in_array( $hook_suffix, array( 'post.php', 'post-new.php' ), true );
if ( ! $is_plugin_page && ! ( $is_our_post_type && $is_edit_screen ) ) {
return;
}
@@ -141,10 +176,18 @@ final class Plugin {
WP_BNB_VERSION
);
$script_deps = array( 'jquery' );
// Add media dependencies for room gallery.
if ( Room::POST_TYPE === $post_type && $is_edit_screen ) {
wp_enqueue_media();
$script_deps[] = 'jquery-ui-sortable';
}
wp_enqueue_script(
'wp-bnb-admin',
WP_BNB_URL . 'assets/js/admin.js',
array( 'jquery' ),
$script_deps,
WP_BNB_VERSION,
true
);
@@ -153,12 +196,16 @@ final class Plugin {
'wp-bnb-admin',
'wpBnbAdmin',
array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wp_bnb_admin_nonce' ),
'i18n' => array(
'validating' => __( 'Validating...', 'wp-bnb' ),
'activating' => __( 'Activating...', 'wp-bnb' ),
'error' => __( 'An error occurred. Please try again.', 'wp-bnb' ),
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wp_bnb_admin_nonce' ),
'postType' => $post_type,
'i18n' => array(
'validating' => __( 'Validating...', 'wp-bnb' ),
'activating' => __( 'Activating...', 'wp-bnb' ),
'error' => __( 'An error occurred. Please try again.', 'wp-bnb' ),
'selectImages' => __( 'Select Images', 'wp-bnb' ),
'addToGallery' => __( 'Add to Gallery', 'wp-bnb' ),
'confirmRemove' => __( 'Are you sure you want to remove this image?', 'wp-bnb' ),
),
)
);