Hide event sub-club field until burnWorks syncs
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Plugin Name: eventLabs
|
||||
* Plugin URI: https://git.labs.casa/josh/eventLabs
|
||||
* Description: Calendars, recurring events, community submissions, and a Single Event template builder for Elementor.
|
||||
* Version: 0.5.5
|
||||
* Version: 0.5.6
|
||||
* Requires at least: 6.9
|
||||
* Requires PHP: 8.1
|
||||
* Author: hostLabs
|
||||
@@ -16,7 +16,7 @@ declare(strict_types=1);
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
define( 'BURN_EVENTS_FILE', __FILE__ );
|
||||
define( 'BURN_EVENTS_VERSION', '0.5.5' );
|
||||
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 ) {
|
||||
require_once __DIR__ . '/includes/class-' . $module . '.php';
|
||||
|
||||
@@ -177,8 +177,11 @@ final class Admin {
|
||||
$data['organizer'] = array_filter( [ $options['organizer'] ] );
|
||||
}
|
||||
self::event_fields( $data );
|
||||
$scope = (string) get_post_meta( $post->ID, Clubs::EVENT_META, true );
|
||||
$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 ) ); ?>>
|
||||
@@ -194,7 +197,7 @@ final class Admin {
|
||||
if ( BurnWorks::snapshot( $post->ID ) ) {
|
||||
esc_html_e( 'This assignment is managed in burnWorks.', 'burn-events' );
|
||||
} elseif ( ! $options ) {
|
||||
esc_html_e( 'Connect burnWorks and sync its club directory to populate this list.', 'burn-events' );
|
||||
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' );
|
||||
}
|
||||
@@ -449,8 +452,9 @@ final class Admin {
|
||||
}
|
||||
try {
|
||||
$current = (string) get_post_meta( $id, Clubs::EVENT_META, true );
|
||||
$scope = ! BurnWorks::snapshot( $id ) && is_string( $_POST['be_sub_club'] ?? null ) ? wp_unslash( $_POST['be_sub_club'] ) : $current;
|
||||
if ( $scope !== $current && '' !== $scope && ! isset( Clubs::editor_options()[ $scope ] ) ) {
|
||||
$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'] ) ) );
|
||||
|
||||
@@ -151,10 +151,20 @@ final class Clubs {
|
||||
return [ '' => __( 'All events', 'burn-events' ) ] + $workspaces + $clubs;
|
||||
}
|
||||
|
||||
public static function editor_options(): array {
|
||||
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 ( self::directory() as $club ) {
|
||||
if ( 'archived' !== $club['status'] ) {
|
||||
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'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user