fc70cde9d5
CI / No Debug Code (pull_request) Successful in 4s
CI / Tests (PHP 8.2) (pull_request) Successful in 52s
CI / Tests (PHP 8.1) (pull_request) Successful in 54s
CI / Tests (PHP 8.3) (pull_request) Successful in 1m29s
CI / Coding Standards (pull_request) Successful in 1m57s
CI / PHPStan (pull_request) Successful in 2m14s
CI / Build Plugin Zip (pull_request) Has been skipped
Wrap the four shortcodes (us_booking, us_student_login, us_student_register, us_group_classes) in dynamic blocks so pages can be previewed and styled in the block editor. Front-end rendering delegates to the same page objects the shortcodes use; in the editor's block-renderer REST preview a static, script-free BlockPreview is rendered instead (no live REST calls, redirects, or Stripe.js). The editor script (vanilla JS, no build step) registers each block with wp.serverSideRender previews and shortcode transforms; frontend.css is attached as the block style so previews pick up theme styling. Resolves #44 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
66 lines
2.4 KiB
JavaScript
66 lines
2.4 KiB
JavaScript
/* global wp */
|
|
(function () {
|
|
'use strict';
|
|
|
|
const { registerBlockType } = wp.blocks;
|
|
const { createElement: el } = wp.element;
|
|
const { useBlockProps } = wp.blockEditor;
|
|
const ServerSideRender = wp.serverSideRender;
|
|
const { __ } = wp.i18n;
|
|
|
|
const blocks = [
|
|
{
|
|
name: 'us-scheduler/booking',
|
|
title: __('Lesson Booking', 'unsupervised-schedular'),
|
|
description: __('Lets students browse availability and book lessons. Shows a styled preview in the editor.', 'unsupervised-schedular'),
|
|
icon: 'calendar-alt',
|
|
keywords: ['booking', 'lesson', 'schedule'],
|
|
shortcode: 'us_booking',
|
|
},
|
|
{
|
|
name: 'us-scheduler/student-login',
|
|
title: __('Student Login', 'unsupervised-schedular'),
|
|
description: __('The front-end login form for students.', 'unsupervised-schedular'),
|
|
icon: 'admin-users',
|
|
keywords: ['login', 'student', 'sign in'],
|
|
shortcode: 'us_student_login',
|
|
},
|
|
{
|
|
name: 'us-scheduler/student-register',
|
|
title: __('Student Registration', 'unsupervised-schedular'),
|
|
description: __('The invite-only student registration form.', 'unsupervised-schedular'),
|
|
icon: 'welcome-add-page',
|
|
keywords: ['register', 'student', 'invite'],
|
|
shortcode: 'us_student_register',
|
|
},
|
|
{
|
|
name: 'us-scheduler/group-classes',
|
|
title: __('Group Classes', 'unsupervised-schedular'),
|
|
description: __('Lets students browse and enrol in group classes. Shows a styled preview in the editor.', 'unsupervised-schedular'),
|
|
icon: 'groups',
|
|
keywords: ['group', 'class', 'enrol'],
|
|
shortcode: 'us_group_classes',
|
|
},
|
|
];
|
|
|
|
blocks.forEach((def) => {
|
|
registerBlockType(def.name, {
|
|
apiVersion: 3,
|
|
title: def.title,
|
|
description: def.description,
|
|
icon: def.icon,
|
|
category: 'widgets',
|
|
keywords: def.keywords,
|
|
supports: { html: false, multiple: false },
|
|
example: {},
|
|
edit: function Edit() {
|
|
return el('div', useBlockProps(), el(ServerSideRender, { block: def.name }));
|
|
},
|
|
save: () => null,
|
|
transforms: {
|
|
from: [{ type: 'shortcode', tag: def.shortcode }],
|
|
},
|
|
});
|
|
});
|
|
}());
|