3, 'editor_script' => 'vimine-blocks', 'attributes' => [ 'label' => [ 'type' => 'string', 'default' => '' ], 'returnTo' => [ 'type' => 'string', 'default' => '' ], 'scope' => [ 'type' => 'string', 'default' => '' ] ], 'render_callback' => static fn( array $a ): string => self::wrap( Vimine_Shortcodes::signin( [ 'label' => $a['label'] ?? '', 'return_to' => $a['returnTo'] ?? '', 'scope' => $a['scope'] ?? '' ] ) ), ] ); register_block_type( 'vimine/card', [ 'api_version' => 3, 'editor_script' => 'vimine-blocks', 'render_callback' => static fn(): string => self::wrap( Vimine_Shortcodes::card( [] ) ), ] ); // The look (`scheme`, `accent`, `background`, `font`): empty is Settings → Vimine's, as for the shortcode. $look = [ 'scheme', 'accent', 'background', 'font' ]; register_block_type( 'vimine/enroll', [ 'api_version' => 3, 'editor_script' => 'vimine-blocks', 'attributes' => [ 'slug' => [ 'type' => 'string', 'default' => '' ], 'height' => [ 'type' => 'string', 'default' => '900' ], 'lang' => [ 'type' => 'string', 'default' => '' ] ] + array_fill_keys( $look, [ 'type' => 'string', 'default' => '' ] ), 'render_callback' => static fn( array $a ): string => self::wrap( Vimine_Shortcodes::enroll( [ 'slug' => $a['slug'] ?? '', 'height' => $a['height'] ?? '900', 'lang' => $a['lang'] ?? '' ] + array_intersect_key( $a, array_flip( $look ) ) ) ), ] ); register_block_type( 'vimine/events', [ 'api_version' => 3, 'editor_script' => 'vimine-blocks', 'attributes' => [ 'slug' => [ 'type' => 'string', 'default' => '' ], 'filter' => [ 'type' => 'string', 'default' => 'upcoming' ], 'limit' => [ 'type' => 'string', 'default' => '10' ] ], 'render_callback' => static fn( array $a ): string => self::wrap( Vimine_Shortcodes::events( [ 'slug' => $a['slug'] ?? '', 'filter' => $a['filter'] ?? 'upcoming', 'limit' => $a['limit'] ?? '10' ] ) ), ] ); } /** * A block's markup inside the block's own wrapper: a block theme's layout places the wrapper in the content column, * and what the shortcode draws keeps its own width inside it. Unwrapped, the sign-in link (an inline element) sat at * the page's left edge, and the card, narrower than the column, was centred in it. Nothing to show stays nothing. */ private static function wrap( string $html ): string { return '' !== $html ? '
' . $html . '
' : ''; } /** @return array> */ private static function strings(): array { return [ 'options' => __( 'Options', 'vimine' ), 'slug' => __( 'Association slug', 'vimine' ), 'signinTitle' => __( 'Vimine — Sign in', 'vimine' ), 'signin' => __( 'Sign in with Vimine', 'vimine' ), 'signinHint' => __( 'Sign-in button, and sign-out once the member is signed in', 'vimine' ), 'label' => __( 'Label', 'vimine' ), 'returnTo' => __( 'Return to (path)', 'vimine' ), 'scope' => __( 'Permissions (scope)', 'vimine' ), 'cardTitle' => __( 'Vimine — Membership card', 'vimine' ), 'card' => __( 'Membership card', 'vimine' ), 'cardHint' => __( 'The signed-in visitor’s card, with the QR code', 'vimine' ), 'eventsTitle' => __( 'Vimine — Events', 'vimine' ), 'events' => __( 'Events', 'vimine' ), 'eventsHint' => __( 'The association’s events with the places left; the registration happens on Vimine', 'vimine' ), 'filter' => __( 'Filter (upcoming, past, cancelled, all)', 'vimine' ), 'limit' => __( 'Maximum number', 'vimine' ), 'enrollTitle' => __( 'Vimine — Enrolment form', 'vimine' ), 'enroll' => __( 'Enrolment form', 'vimine' ), 'enrollHint' => __( 'The association’s enrolment form, in the site’s language', 'vimine' ), 'height' => __( 'Height (px)', 'vimine' ), 'lang' => __( 'Language (it, en, fr, es, de, pt-BR, zh-Hans…; empty = the site’s)', 'vimine' ), 'appearance' => __( 'Appearance', 'vimine' ), 'siteDefault' => __( 'Default', 'vimine' ), 'scheme' => __( 'Colour scheme', 'vimine' ), 'light' => __( 'Light', 'vimine' ), 'dark' => __( 'Dark', 'vimine' ), 'accent' => __( 'Accent colour (#rrggbb)', 'vimine' ), 'background' => __( 'Background (#rrggbb or transparent)', 'vimine' ), 'font' => __( 'Typeface', 'vimine' ), 'vimineFace' => __( 'Vimine’s own', 'vimine' ), 'system' => __( 'System', 'vimine' ), 'faces' => Vimine_Appearance::FACES, ]; } }