Skip to content
MS Keys Gate
Concept / DemoWordPress plugin

Booking blocks — WordPress plugin

Shows plugin architecture: custom blocks, a settings screen, REST endpoints and capability checks.

A concept by MS Keys Gate, built to demonstrate capability. It is not a client project and was never commissioned.

Screens

booking-blocks.example

Editor. The booking block with inspector controls for service and duration.

What it sets out to prove

  • Add booking to any theme with a block, not a shortcode
  • Keep availability logic on the server, exposed through a typed REST route
  • Gate every write behind a capability and a nonce

Built with

  • PHP
  • WordPress block API
  • REST API
  • @wordpress/scripts

Editor and front-end from one source

The block's render callback and its editor component share the same markup, so what an editor sees is what ships.

Availability as an API

Slots come from a REST endpoint with permission callbacks, so the same data can feed a future mobile app.

A look at the code

Registering the block with a server render callback

register_block_type( __DIR__ . '/build/booking', array(
	'render_callback' => static function ( array $attributes ): string {
		$service = sanitize_key( $attributes['serviceId'] ?? '' );

		return sprintf(
			'<div class="wp-block-bb-booking" data-service="%s">%s</div>',
			esc_attr( $service ),
			render_booking_form( $service )
		);
	},
) );

register_rest_route( 'booking-blocks/v1', '/slots', array(
	'methods'             => 'GET',
	'callback'            => 'bb_get_slots',
	'permission_callback' => static fn (): bool => current_user_can( 'read' ),
) );

Illustrative snippet from the concept (php).

Take this further

The thinking here carries straight into a real project. See the Plugin development service, or tell us what you have in mind.