2 Commits

Author SHA1 Message Date
josh
6df287d530 Hide event sub-club field until burnWorks syncs
All checks were successful
WordPress release / release (push) Successful in 5s
2026-11-12 15:17:32 -05:00
josh
1b5c8a1ff5 Add sub-club selection to the WordPress event editor
All checks were successful
WordPress release / release (push) Successful in 6s
2026-11-12 15:10:53 -05:00
4 changed files with 62 additions and 2 deletions

View File

@@ -43,3 +43,5 @@ Use `GET /events` to list records, `POST /events` to create one, and `PATCH /eve
Sync a named club or sub-club with `PUT /burnworks/workspaces/{workspace_id}/clubs/{club_id}`. Send events to `PUT /burnworks/workspaces/{workspace_id}/events/{event_id}` with the burnWorks `club_id`. An event stores its workspace and club identity in a hidden field. In Elementor, use **Club or sub-club** on **Event Calendar** and **Event List** to show a whole workspace or one club. Sync a named club or sub-club with `PUT /burnworks/workspaces/{workspace_id}/clubs/{club_id}`. Send events to `PUT /burnworks/workspaces/{workspace_id}/events/{event_id}` with the burnWorks `club_id`. An event stores its workspace and club identity in a hidden field. In Elementor, use **Club or sub-club** on **Event Calendar** and **Event List** to show a whole workspace or one club.
See the [API reference](docs/API.md) for routes, payloads, and errors, and the [burnWorks handoff](docs/BURNWORKS-INTEGRATION.md) for field mapping and publishing rules. The [feature and settings audit](docs/PARITY-AUDIT.md) records the current coverage against the reference packages. See the [API reference](docs/API.md) for routes, payloads, and errors, and the [burnWorks handoff](docs/BURNWORKS-INTEGRATION.md) for field mapping and publishing rules. The [feature and settings audit](docs/PARITY-AUDIT.md) records the current coverage against the reference packages.
For events created in WordPress, use **Event Details → Sub-club** to select a club from the synced burnWorks directory. Events created in burnWorks keep their assignment from that system.

View File

@@ -3,7 +3,7 @@
* Plugin Name: eventLabs * Plugin Name: eventLabs
* Plugin URI: https://git.labs.casa/josh/eventLabs * Plugin URI: https://git.labs.casa/josh/eventLabs
* Description: Calendars, recurring events, community submissions, and a Single Event template builder for Elementor. * Description: Calendars, recurring events, community submissions, and a Single Event template builder for Elementor.
* Version: 0.5.4 * Version: 0.5.6
* Requires at least: 6.9 * Requires at least: 6.9
* Requires PHP: 8.1 * Requires PHP: 8.1
* Author: hostLabs * Author: hostLabs
@@ -16,7 +16,7 @@ declare(strict_types=1);
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
define( 'BURN_EVENTS_FILE', __FILE__ ); define( 'BURN_EVENTS_FILE', __FILE__ );
define( 'BURN_EVENTS_VERSION', '0.5.4' ); define( 'BURN_EVENTS_VERSION', '0.5.6' );
foreach ( [ 'schedule', 'maps', 'events', 'admin', 'map-view', 'calendar-grid', 'calendar', 'community', 'transfer', 'single-event-templates', 'api', 'burnworks', 'clubs', 'legacy-migration', 'updates', 'platform' ] as $module ) { foreach ( [ 'schedule', 'maps', 'events', 'admin', 'map-view', 'calendar-grid', 'calendar', 'community', 'transfer', 'single-event-templates', 'api', 'burnworks', 'clubs', 'legacy-migration', 'updates', 'platform' ] as $module ) {
require_once __DIR__ . '/includes/class-' . $module . '.php'; require_once __DIR__ . '/includes/class-' . $module . '.php';

View File

@@ -177,6 +177,33 @@ final class Admin {
$data['organizer'] = array_filter( [ $options['organizer'] ] ); $data['organizer'] = array_filter( [ $options['organizer'] ] );
} }
self::event_fields( $data ); self::event_fields( $data );
$options = Clubs::editor_options();
if ( null === $options ) {
return;
}
$scope = (string) get_post_meta( $post->ID, Clubs::EVENT_META, true );
?>
<p><label for="burn-event-sub-club"><strong><?php esc_html_e( 'Sub-club', 'burn-events' ); ?></strong></label><br>
<select id="burn-event-sub-club" name="be_sub_club" aria-describedby="burn-event-sub-club-help" <?php disabled( (bool) BurnWorks::snapshot( $post->ID ) ); ?>>
<option value=""><?php esc_html_e( 'No sub-club (organization calendar)', 'burn-events' ); ?></option>
<?php if ( $scope && ! isset( $options[ $scope ] ) ) : ?>
<option value="<?php echo esc_attr( $scope ); ?>" selected><?php esc_html_e( 'Current assignment (unavailable)', 'burn-events' ); ?></option>
<?php endif; ?>
<?php foreach ( $options as $value => $label ) : ?>
<option value="<?php echo esc_attr( $value ); ?>" <?php selected( $scope, $value ); ?>><?php echo esc_html( $label ); ?></option>
<?php endforeach; ?>
</select></p>
<p class="description" id="burn-event-sub-club-help"><?php
if ( BurnWorks::snapshot( $post->ID ) ) {
esc_html_e( 'This assignment is managed in burnWorks.', 'burn-events' );
} elseif ( ! $options ) {
esc_html_e( 'No active sub-clubs have synced from burnWorks.', 'burn-events' );
} else {
esc_html_e( 'This determines which CRM sub-club receives the event.', 'burn-events' );
}
?></p>
<?php
} }
public static function event_fields( array $data, bool $public = false ): void { public static function event_fields( array $data, bool $public = false ): void {
@@ -424,7 +451,16 @@ final class Admin {
return; return;
} }
try { try {
$current = (string) get_post_meta( $id, Clubs::EVENT_META, true );
$options = ! BurnWorks::snapshot( $id ) && is_string( $_POST['be_sub_club'] ?? null ) ? Clubs::editor_options() : null;
$scope = null !== $options ? wp_unslash( $_POST['be_sub_club'] ) : $current;
if ( $scope !== $current && '' !== $scope && ! isset( $options[ $scope ] ) ) {
throw new \InvalidArgumentException( __( 'Select an available sub-club.', 'burn-events' ) );
}
Events::save( $id, Events::validate_event( wp_unslash( $_POST['be'] ) ) ); Events::save( $id, Events::validate_event( wp_unslash( $_POST['be'] ) ) );
if ( $scope !== $current ) {
Clubs::assign( $id, $scope );
}
} catch ( \Throwable $error ) { } catch ( \Throwable $error ) {
set_transient( 'burn_events_error_' . get_current_user_id(), $error->getMessage(), MINUTE_IN_SECONDS ); set_transient( 'burn_events_error_' . get_current_user_id(), $error->getMessage(), MINUTE_IN_SECONDS );
} }

View File

@@ -151,6 +151,28 @@ final class Clubs {
return [ '' => __( 'All events', 'burn-events' ) ] + $workspaces + $clubs; return [ '' => __( 'All events', 'burn-events' ) ] + $workspaces + $clubs;
} }
public static function editor_options(): ?array {
$directory = self::directory();
$connected = [];
foreach ( $directory as $club ) {
if ( 'organization' === $club['kind'] && 'active' === $club['status'] && $club['club_id'] === $club['workspace_id'] ) {
$connected[ $club['workspace_id'] ] = true;
}
}
if ( ! $connected ) {
return null;
}
$options = [];
foreach ( $directory as $club ) {
if ( isset( $connected[ $club['workspace_id'] ] ) && 'subclub' === $club['kind'] && 'active' === $club['status'] ) {
$prefix = $club['workspace_name'] ?: sprintf( __( 'Workspace %s', 'burn-events' ), substr( $club['workspace_id'], 0, 8 ) );
$options[ $club['scope'] ] = $prefix . ' / ' . $club['name'];
}
}
natcasesort( $options );
return $options;
}
public static function condition( string $scope ): string { public static function condition( string $scope ): string {
global $wpdb; global $wpdb;
$scope = strtolower( $scope ); $scope = strtolower( $scope );