Hide event sub-club field until burnWorks syncs
All checks were successful
WordPress release / release (push) Successful in 5s

This commit is contained in:
josh
2026-11-12 15:17:32 -05:00
parent 1b5c8a1ff5
commit 6df287d530
3 changed files with 23 additions and 9 deletions

View File

@@ -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'] ) ) );