Free cookie consent management tool by TermsFeed Generator
All Products & Integrations

jalpi page builder docs

Your First Widget

Step-by-step guide to adding a widget to Jalpi Page Builder β€” the schema-driven path in four files, the bespoke path in seven, and the verification checklist for both.

Jalpi CoreDeveloper
19 min read Β· November 2026

Adding a widget to Jalpi means editing source files in two stacks that share no code. There is no registration hook and no runtime API β€” a widget exists because the TypeScript registry declares it and the PHP side agrees.

There are two routes. The schema-driven route defines a widget entirely through a field list and touches four files; you write no React component and no PHP class. The bespoke route gives you full control of the markup and the inspector, at the cost of seven files that must all agree.

This page walks both, in order, with the exact file and function each step lands in. It ends with the failure modes β€” because almost every mistake here fails silently rather than throwing.

Choosing a Path#

Start with the schema-driven route. It is the default for anything the field vocabulary can express, and the registry's own comment lists what you inherit automatically: style, advanced, animation, responsive, global-styles, copy-paste, undo and import-export all operate on the node tree generically already.

Your widget needs…Route
A handful of text, number, colour, toggle, select, URL or icon fieldsSchema
Markup driven entirely by those field valuesSchema
A repeating list of simple items or objectsSchema β€” repeater / itemsRepeater
To hold other widgets as real childrenBespoke
A server-side query (posts, terms, products)Bespoke
AJAX endpoints of its ownBespoke
A hand-built inspector layout with conditional groups and popupsBespoke
Markup that varies structurally, not just by valueBespoke

The existing split follows exactly this logic. Icon Box is schema-driven despite using the full icon-library picker, because its markup is a direct function of its fields. Products Grid is bespoke because it runs a live WC_Query and paginates over AJAX β€” neither of which a field schema can express.

Path A β€” A Schema-Driven Widget#

Four files, two of them required. The worked example below adds a Notice Bar widget: a dismissible coloured strip with an icon, a message and an optional link.

A custom Notice Bar widget in the Elements palette, rendered on the canvas with its inspector controls
Figure: Custom developer widget registered via jalpi_widgets filter active on the editor canvas.

Step 1 β€” Add the type key#

In admin/editor/src/types/index.ts, add the type to the ElementType union. The registry-driven widgets are grouped together with a comment explaining the generic path; put yours alongside them.

export type ElementType =
  | 'section'
  // …
  | 'shape-divider'
  | 'notice-bar'        // ← new
  | 'social-share'
  // …

Pick the type key carefully. It is written into every stored node, and changing it later orphans existing content β€” the sanitiser drops nodes whose type it does not recognise.

Step 2 β€” Add the registry entry#

In admin/editor/src/widgets/registry.ts, add a WidgetDef to one of the arrays β€” BATCH for effects-style widgets, SOCIAL for social ones, or a new array added to WIDGET_REGISTRY. Do not set bespoke. Its absence is what routes the widget through the generic path.

The entry supplies palette metadata, a seed node and the field list that generates the editor. See the first example below.

What each part controls:

KeyEffect
categoryWhich Elements-panel group and Block-picker tab it appears under
label, icon, color, descriptionHow it presents in the palette
defaultNodeThe node inserted when the widget is added
fieldsThe controls generated in the inspector

A category that is not already a hardcoded panel group automatically gets its own accordion, so a new category needs no edit to ElementsPanel.tsx.

Step 3 β€” Mirror the schema in PHP#

In includes/widgets-schema.php, add an entry to jalpi_widget_schemas(). This is the mirror the file's own docblock calls "the ONE intentional duplication between PHP and the TS editor", and it is not optional β€” without it the type is missing from jalpi_widget_schema_types(), so the sanitiser rejects it and the renderer never registers a handler.

The mirror carries only what the server needs:

  • render β€” which branch of Jalpi_Element_Generic::render_template() handles it
  • needsJs β€” optional; enqueues the shared frontend script
  • fields β€” the field list with each field's control type, used to pick the right escaper

Declare each field as the PHP control matching its stored shape, not its editor control. A slider is declared number; a buttongroup is declared select; image is declared url; dimensions4, repeater and itemsRepeater are declared text.

Step 4 β€” Add the render branch#

In includes/elements/class-jalpi-element-generic.php, add a case to render_template() matching your schema's render key.

The contract for that branch:

  • Return the widget's inner HTML only. The wrapper <div class="jalpi-el jalpi-{id}">, the scoped CSS rule and the id and class attributes are built for you by render().
  • Escape everything. sanitize_text_field() plus esc_html() for text, intval() with clamping for numbers, the private enum() helper for constrained choices, Jalpi_Sanitizer::sanitize_color() for colours, esc_attr() for attributes, esc_url() for links.
  • Pass configuration to the browser as data-* attributes, never inline <script>.
  • Make absent keys reproduce the previous output. Every existing branch does this so a newly added control cannot change how already-saved nodes render.

Step 5 β€” Add a canvas preview (optional)#

In admin/editor/src/widgets/GenericRenderer.tsx, add an entry to the PREVIEWS map keyed by your type.

This is genuinely optional. A widget with no entry falls back to a labelled placeholder that stays fully selectable, movable and stylable β€” the file's comment is explicit that the placeholder is only the visual preview, and the real frontend HTML comes from the PHP generic element either way.

Add one when the widget's appearance is what the author is editing. Skip it for anything whose output is inherently dynamic.

Step 6 β€” Add frontend behaviour (optional)#

If the widget needs JavaScript:

  1. Set 'needsJs' => true in the PHP schema. Jalpi_Element_Generic turns that into $renderer->set_needs_js( 'generic' ), which enqueues the shared script.
  2. Add an initialiser to assets/js/jalpi-frontend.js and call it from init().

Follow the file's established pattern: open with a selector guard so the function costs one failed query when the widget is absent, and read all configuration from data-* attributes.

function initNoticeBars() {
  var els = document.querySelectorAll('.jalpi-notice-bar');
  if (!els.length) return;
  els.forEach(function (el) { /* … */ });
}

Step 7 β€” Build#

cd admin/editor
npm run lint     # tsc --noEmit β€” catches the ElementType union mistakes
npm run build    # or npm run start to watch

PHP changes need no build step.

Files you never touch on this path: CanvasNode.tsx, PropertiesPanel.tsx, ElementsPanel.tsx, BlockPicker.tsx, class-jalpi-sanitizer.php and class-jalpi-renderer.php. Both dispatch switches in the editor already end in a default that routes schema widgets to GenericContent and GenericRenderer, and the renderer registers a Jalpi_Element_Generic instance per schema type automatically.

Path B β€” A Bespoke Widget#

Seven files must agree. Missing one is the usual cause of a widget that half-works, so treat the list as a checklist rather than a sequence.

The Seven Places#

#FileWhat to add
1admin/editor/src/types/index.tsThe type key in the ElementType union
2includes/elements/class-jalpi-element-{type}.phpA class extending Jalpi_Element
3includes/class-jalpi-renderer.phpThe class in register_elements()'s $element_classes array
4includes/class-jalpi-sanitizer.phpThe type in $allowed_types and a case in sanitize_content()
5admin/editor/src/widgets/registry.tsA b(...) entry β€” the helper stamps bespoke: true
6admin/editor/src/components/canvas/CanvasNode.tsxA case in renderContent() plus a renderer component
7admin/editor/src/components/panels/PropertiesPanel.tsxA case in ContentTab plus a *Content component

Optionally an eighth: a *StyleTab component with an early return added to StyleTab's dispatcher, if the shared style panel is not enough.

The file naming in step 2 follows the autoloader convention exactly: Jalpi_Element_Notice_Bar resolves to includes/elements/class-jalpi-element-notice-bar.php. Get it wrong and the class silently fails to load.

Writing the Element Class#

The class implements two methods and follows the standard recipe covered on the Canvas Rendering page:

  1. Pull id, content, styles, settings off the node.
  2. Resolve dynamic tags on any text field via $renderer->tags( $renderer->get_current_post_id() ).
  3. Call $renderer->get_css_attrs( $node ) for the id and class attributes.
  4. Build one scoped rule against .jalpi-el.jalpi-{id} using bg_data_to_css(), border_data_to_css() and styles_to_css(), in that order, with styles_to_css() last.
  5. Add a :hover rule when the hover buckets produce anything.
  6. add_css() once.
  7. Return exactly one root tag carrying jalpi-el jalpi-{id}, extra_cls and id_attr.

That last point is not stylistic. Both the CSS scoping and apply_interactions()'s regex injection depend on a single root tag.

Call $renderer->set_needs_js( '{flag}' ) only when the widget genuinely needs the script, and $renderer->render_children( $node ) if it holds children.

Two Edits in the Sanitiser#

Both are required and they fail differently:

  • Missing from $allowed_types β€” the whole node is dropped on save. The widget vanishes from the page.
  • Missing a sanitize_content() case β€” the node survives but falls through to sanitize_generic_content(), which returns [] for a type with no schema entry. The widget stays on the page with empty content.

Write the case as a rebuild, not a filter: construct a new array containing only the keys you recognise, each through a type-appropriate sanitiser. Follow the existing cases β€” sanitize_text_field() for plain strings, wp_kses_post() for rich text, self::sanitize_url() for links, self::sanitize_color() for colours, self::sanitize_dimension() for measurements, self::sanitize_icon_value() for icons, intval() with min/max for bounded numbers, and in_array() for enumerated values.

The Two Editor Components#

The canvas renderer goes in CanvasNode.tsx as a component receiving node and inlineStyles, with a case added to renderContent(). It receives the fully resolved styles β€” presets, tokens, classes and the node's own literals already merged and breakpoint-aware β€” so apply inlineStyles to the element the frontend would style and add nothing else.

The content panel goes in PropertiesPanel.tsx as a *Content component receiving node and store, with a case added to ContentTab. Build it from the shared primitives β€” PropGroup, PropRow, TextInput, Select, Toggle, SliderPropRow, ColorPropRow, ItemRepeater β€” and write through store.updateNodeContent() or store.updateNode().

If the widget needs style controls beyond the shared panel, add a *StyleTab component and an early return in StyleTab's dispatcher, alongside the twenty that are already there.

Adding a New Style Property#

This applies to both paths and is the single most commonly missed step.

A widget-specific style key β€” the pattern used by iconSize, iconPadding, iconRotate, iconBoxColor and outerPadding* β€” lives in node.styles, and StyleMap's index signature means TypeScript accepts it without any declaration. But Jalpi_Sanitizer::sanitize_styles() is a strict allowlist, and a key it does not recognise is dropped on save with no error anywhere.

To add one, edit sanitize_styles():

Kind of valueWhere to add the key
A colourThe $color_keys array
A measurementThe $dim_keys array
Anything elseA new case in the switch, with its own validation

Then, if the renderer should emit it as a plain CSS declaration, add it to the $map in Jalpi_Renderer::styles_to_css(). If your element class composes it into something else β€” as the icon and text-shadow keys do β€” add it to $composite_keys instead so the generic emitter skips it, and handle it in your own render().

The reverse mistake is just as easy: styles_to_css() already maps over ninety keys, so a property appearing in that map does not mean it can be stored. The sanitiser's allowlist is the authority.

Verification Checklist#

Work through this after either path. Each step catches a different silent failure.

  1. npm run lint passes β€” catches a type key missing from the ElementType union.
  2. The widget appears in the Elements panel under the expected group β€” confirms the registry entry and its category.
  3. It appears in the command palette under Ctrl/⌘ + K β€” confirms it reached BLOCKS.
  4. Inserting it produces a node with the seed content from defaultNode.
  5. The inspector shows every control you declared, in the right tab β€” Content versus Style, per each field's tab.
  6. Editing a field updates the canvas β€” confirms the preview path.
  7. Save, then reload the editor. This is the critical one: it proves the sanitiser kept both the node and its content. Anything dropped at save time reappears as missing here.
  8. View the page on the frontend β€” confirms the element registration and the render branch.
  9. Check the page source for the widget's markup and its .jalpi-{id} rule in the inline stylesheet.
  10. If it needs JavaScript, confirm the script is enqueued and the initialiser runs. Remember the editor canvas never runs jalpi-frontend.js, so interactive behaviour can only be verified on the real frontend.
  11. Duplicate the widget and save β€” confirms nested child ids are being reassigned, if the defaultNode seeds children.
  12. Test at tablet and mobile β€” confirms responsive overrides reach the right style map.

Common Failure Modes#

Almost everything here fails quietly. This table maps symptom to cause.

SymptomLikely cause
Widget missing from the Elements panel and command paletteNo WIDGET_REGISTRY entry, or its category maps to null
Widget inserts, then disappears after save and reloadType missing from the sanitiser's $allowed_types, or from jalpi_widget_schema_types()
Widget survives but its content is empty after reloadNo sanitize_content() case, or fields not declared in widgets-schema.php
One field resets on every saveThat field's key is missing from the PHP schema β€” the loop iterates the schema, not the content
A style control has no effect after reloadIts key is not in sanitize_styles()'s allowlist
Renders in the editor, blank on the frontendElement class not registered in register_elements(), or no render branch matching the schema key
Renders on the frontend, placeholder on the canvasNo PREVIEWS entry β€” expected and harmless for a schema widget
Interactions and split text do nothingThe element returns more than one root tag
Content disappears when the widget is duplicatedNested defaultNode child ids not reassigned β€” duplicate ids are dropped as a circular-reference guard
Class never loads, PHP fatal on the class nameFile name does not match the autoloader convention
JavaScript never runsneedsJs not set, set_needs_js() not called, or the initialiser not added to init()

Examples#

Step 1 β€” the type key#

admin/editor/src/types/index.ts. Add the key alongside the other registry-driven widgets.

export type ElementType =
  | 'section'
  | 'container'
  | 'column'
  // … bespoke types …
  // Registry-driven widgets (rendered via the generic path β€” see
  // src/widgets/registry.ts, GenericRenderer.tsx, GenericContent.tsx and the
  // PHP generic element/sanitizer default branches).
  | 'marquee'
  | 'typewriter-text'
  | 'shape-divider'
  | 'notice-bar'          // ← new
  | 'social-share'
  // …

Step 2 β€” the registry entry#

admin/editor/src/widgets/registry.ts. No bespoke flag β€” its absence routes the widget through the generic path. Note the tab: 'style' fields and the showIf condition.

{
  type: 'notice-bar', label: 'Notice Bar', icon: 'πŸ“’', category: 'Effects',
  description: 'A dismissible banner with an icon, message and optional link.',
  color: '#8b5cf6',
  defaultNode: {
    type: 'notice-bar',
    content: {
      message:     'We are running a limited-time offer.',
      icon:        { type: 'svg', lib: 'builtin', name: 'star' },
      linkText:    'Learn more',
      linkUrl:     '',
      dismissible: true,
      bgColor:     '#eef2ff',
      textColor:   '#1a1a1a',
    },
    styles: { fontSize: '15px' },
  },
  fields: [
    { key: 'message',     label: 'Message',      control: 'text' },
    { key: 'icon',        label: 'Icon',         control: 'icon' },
    { key: 'linkText',    label: 'Link Text',    control: 'text' },
    { key: 'linkUrl',     label: 'Link URL',     control: 'url',
      placeholder: 'https://…', showIf: { key: 'linkText', truthy: true } },
    { key: 'dismissible', label: 'Dismissible',  control: 'toggle' },
    { key: 'bgColor',     label: 'Background',   control: 'color',
      group: 'Notice Style', tab: 'style' },
    { key: 'textColor',   label: 'Text Color',   control: 'color',
      group: 'Notice Style', tab: 'style' },
  ],
}

Step 3 β€” the PHP mirror#

includes/widgets-schema.php. Required, not optional β€” without it the sanitiser rejects the type entirely. Declare each field as the PHP control matching its stored shape.

'notice-bar' => [
    'render'  => 'notice-bar',
    'needsJs' => true,          // the dismiss button needs a listener
    'fields'  => [
        'message'     => 'text',
        'icon'        => 'icon',    // sanitized via sanitize_icon_value()
        'linkText'    => 'text',
        'linkUrl'     => 'url',
        'dismissible' => 'toggle',
        'bgColor'     => 'color',
        'textColor'   => 'color',
    ],
],

Step 4 β€” the render branch#

includes/elements/class-jalpi-element-generic.php, inside render_template(). Return inner HTML only; the wrapper and scoped CSS are built by render(). Every value is escaped, and absent keys reproduce the previous output.

case 'notice-bar': {
    $message = sanitize_text_field( $content['message'] ?? '' );
    if ( '' === $message ) {
        return '';
    }

    $bg   = Jalpi_Sanitizer::sanitize_color( $content['bgColor']   ?? '' );
    $fg   = Jalpi_Sanitizer::sanitize_color( $content['textColor'] ?? '' );
    $dism = ! empty( $content['dismissible'] ) ? '1' : '0';

    $style = '';
    if ( $bg ) { $style .= 'background:' . esc_attr( $bg ) . ';'; }
    if ( $fg ) { $style .= 'color:'      . esc_attr( $fg ) . ';'; }

    // Icon β€” reuse the shared helper so CDN icon libraries are tracked.
    $icon_html = ! empty( $content['icon'] )
        ? $renderer->render_icon_value( $content['icon'] )
        : '';

    // Optional link
    $link_html = '';
    $link_text = sanitize_text_field( $content['linkText'] ?? '' );
    $link_url  = esc_url( $content['linkUrl'] ?? '' );
    if ( $link_text && $link_url ) {
        $link_html = '<a class="jalpi-notice-bar__link" href="' . $link_url . '">'
                   . esc_html( $link_text ) . '</a>';
    }

    $close_html = '1' === $dism
        ? '<button type="button" class="jalpi-notice-bar__close" aria-label="'
          . esc_attr__( 'Dismiss', 'jalpi-page-builder' ) . '">&times;</button>'
        : '';

    return '<div class="jalpi-notice-bar" data-dismissible="' . esc_attr( $dism ) . '"'
         . ( $style ? ' style="' . esc_attr( $style ) . '"' : '' ) . '>'
         . $icon_html
         . '<span class="jalpi-notice-bar__msg">' . esc_html( $message ) . '</span>'
         . $link_html
         . $close_html
         . '</div>';
}

Step 5 β€” the canvas preview (optional)#

admin/editor/src/widgets/GenericRenderer.tsx, added to the PREVIEWS map. Omitting this leaves a labelled placeholder that is still fully selectable and stylable.

const PREVIEWS: Record<string, (c: Record<string, unknown>) => React.ReactNode> = {
  // … existing entries …

  'notice-bar': (c) => (
    <div
      style={{
        display: 'flex', alignItems: 'center', gap: 10,
        padding: '10px 14px', borderRadius: 6,
        background: str(c.bgColor, '#eef2ff'),
        color:      str(c.textColor, '#1a1a1a'),
      }}
    >
      {c.icon ? <RenderIconValue value={c.icon as IconValue} /> : null}
      <span style={{ flex: 1 }}>{str(c.message, 'Notice message…')}</span>
      {str(c.linkText) ? <span style={{ textDecoration: 'underline' }}>{str(c.linkText)}</span> : null}
      {c.dismissible ? <span style={{ opacity: 0.5 }}>Γ—</span> : null}
    </div>
  ),
};

Path B β€” a bespoke element class#

includes/elements/class-jalpi-element-notice-bar.php. The standard recipe: resolve tags, get attrs, build one scoped rule, add_css once, return one root tag.

<?php
defined( 'ABSPATH' ) || exit;

class Jalpi_Element_Notice_Bar extends Jalpi_Element {

    public static function type(): string { return 'notice-bar'; }

    public function render( array $node, Jalpi_Renderer $renderer ): string {
        $id       = sanitize_html_class( $node['id'] ?? '' );
        $content  = $node['content']  ?? [];
        $styles   = $node['styles']   ?? [];
        $settings = $node['settings'] ?? [];

        $message = wp_kses_post(
            $renderer->tags( $renderer->get_current_post_id() )->resolve( $content['message'] ?? '' )
        );

        $a   = $renderer->get_css_attrs( $node );
        $sel = '.jalpi-el.jalpi-' . $id;

        $css  = "{$sel}{display:flex;align-items:center;gap:10px;box-sizing:border-box;";
        $css .= $renderer->bg_data_to_css( $settings['bgNormal'] ?? [] );
        $css .= $renderer->border_data_to_css( $settings['borderNormal'] ?? [] );
        $css .= $renderer->styles_to_css( $styles );
        $css .= '}';

        $hover = $renderer->bg_data_to_css( $settings['bgHover'] ?? [] )
               . $renderer->border_data_to_css( $settings['borderHover'] ?? [] );
        if ( $hover ) {
            $css .= "{$sel}:hover{{$hover}}";
        }

        $renderer->add_css( $css );

        if ( ! empty( $content['dismissible'] ) ) {
            $renderer->set_needs_js( 'generic' );
        }

        // Exactly one root tag β€” required by CSS scoping and apply_interactions().
        return '<div class="jalpi-el jalpi-' . esc_attr( $id ) . $a['extra_cls'] . '"' . $a['id_attr'] . '>'
             . '<span class="jalpi-notice-bar__msg">' . $message . '</span>'
             . '</div>';
    }
}

Path B β€” the two sanitiser edits#

includes/class-jalpi-sanitizer.php. Both are required, and they fail differently β€” see the failure-modes table.

// 1. sanitize_node() β€” add the type to $allowed_types
$allowed_types = [
    'section', 'container', 'column',
    // …
    'countdown', 'flip-box', 'star-rating',
    'notice-bar',                              // ← new
    'products-grid', 'product-categories', 'single-product',
];

// 2. sanitize_content() β€” add a case that REBUILDS the content array
case 'notice-bar':
    return [
        'message'     => sanitize_text_field( $content['message'] ?? '' ),
        'icon'        => self::sanitize_icon_value( $content['icon'] ?? '', '' ),
        'linkText'    => sanitize_text_field( $content['linkText'] ?? '' ),
        'linkUrl'     => self::sanitize_url( $content['linkUrl'] ?? '' ),
        'dismissible' => (bool) ( $content['dismissible'] ?? false ),
        'bgColor'     => self::sanitize_color( $content['bgColor'] ?? '' ),
        'textColor'   => self::sanitize_color( $content['textColor'] ?? '' ),
    ];

Path B β€” registering the element#

includes/class-jalpi-renderer.php, in register_elements(). Add before the generic loop β€” the guard there already refuses to shadow a bespoke type, but the explicit list is where a bespoke widget belongs.

private function register_elements(): void {
    $element_classes = [
        Jalpi_Element_Section::class,
        Jalpi_Element_Container::class,
        // …
        Jalpi_Element_Star_Rating::class,
        Jalpi_Element_Notice_Bar::class,          // ← new
        Jalpi_Element_Products_Grid::class,
        // …
    ];

    foreach ( $element_classes as $class ) {
        $el = new $class();
        $this->elements[ $class::type() ] = $el;
    }

    // … generic registration for schema types follows …
}

Notes#

  • Prefer the schema-driven path. It touches four files instead of seven, and the widget inherits style, advanced, animation, responsive, global-styles, copy-paste, undo and import-export automatically because those all operate on the node tree generically.
  • A schema-driven widget requires no edits to CanvasNode.tsx, PropertiesPanel.tsx, ElementsPanel.tsx, BlockPicker.tsx, the sanitiser or the renderer. Both editor dispatch switches end in a default that routes schema widgets to the generic components, and the renderer registers a Jalpi_Element_Generic instance per schema type.
  • A new palette category needs no code change. The Elements panel auto-groups any registry widget that its hardcoded lists do not place, creating a new accordion for an unrecognised category.
  • Element class file names follow the autoloader convention strictly: Jalpi_Element_Notice_Bar β†’ includes/elements/class-jalpi-element-notice-bar.php. Strip the Jalpi_ prefix, lowercase, replace underscores with hyphens, prefix with class-jalpi-.
  • The canvas renderer receives inlineStyles fully resolved β€” presets, tokens, attached classes and the node's own literals already merged, and already breakpoint-aware. Apply it to the element the frontend would style and add nothing else.
  • In a generic render branch, return the widget's inner HTML only. The <div class="jalpi-el jalpi-{id}"> wrapper, the scoped CSS rule and the id and class attributes are all built by Jalpi_Element_Generic::render().
  • Write every render branch so that absent content keys reproduce the previous output exactly. Every existing branch does this, which is what lets new controls ship without changing how already-saved nodes render.
  • Run npm run lint before building. tsc --noEmit catches a type key missing from the ElementType union, which is otherwise a silent mismatch between the registry and the type system.

Warnings#

  • Skipping the widgets-schema.php mirror is fatal, not cosmetic. Without it the type is absent from jalpi_widget_schema_types(), so the sanitiser's allowed-type list rejects it and the whole node is dropped on the first save β€” the widget disappears from the page entirely.
  • A field declared in registry.ts but not in the PHP mirror is discarded on every save. sanitize_generic_content() iterates the schema, not the incoming content, so an undeclared key is never copied no matter what the editor stored.
  • A new style property must be added to Jalpi_Sanitizer::sanitize_styles() β€” to $color_keys, $dim_keys, or a new case. It is a strict allowlist, and an unrecognised key is dropped on save with no error in the editor, the log or the response.
  • Jalpi_Renderer::styles_to_css() maps over ninety keys, but that map does not govern what can be stored. A property present there and absent from the sanitiser's allowlist will never reach the renderer at all.
  • An element's render() must return exactly one root tag. Returning a fragment breaks the .jalpi-el.jalpi-{id} CSS scoping and silently disables interactions and split text, since apply_interactions() injects its payload into the first opening tag it finds.
  • Do not change a type key after content has been saved with it. The sanitiser drops nodes whose type it does not recognise, so a rename orphans every existing instance on the next save.
  • If a defaultNode seeds children, its placeholder ids are literal in the registry. They must be reassigned at insertion time β€” withFreshChildIds() handles the built-in cases β€” or two instances on one page will share ids and the server will drop the duplicates.
  • The editor canvas does not run jalpi-frontend.js. Any behaviour you add there can only be verified on the real frontend, never on the canvas.
  • Widget labels and descriptions in registry.ts are plain string literals with no translation wrapper, unlike PHP-side strings. Text you emit from an element class should still use __() and esc_html__().

Source Files#

  • admin/editor/src/types/index.ts
  • admin/editor/src/widgets/registry.ts
  • admin/editor/src/widgets/GenericContent.tsx
  • admin/editor/src/widgets/GenericRenderer.tsx
  • admin/editor/src/components/canvas/CanvasNode.tsx
  • admin/editor/src/components/canvas/BlockPicker.tsx
  • admin/editor/src/components/panels/ElementsPanel.tsx
  • admin/editor/src/components/panels/PropertiesPanel.tsx
  • admin/editor/src/components/panels/IconPickerModal.tsx
  • admin/editor/src/store/editorStore.ts
  • admin/editor/package.json
  • includes/widgets-schema.php
  • includes/class-jalpi-element.php
  • includes/elements/class-jalpi-element-generic.php
  • includes/elements/class-jalpi-element-heading.php
  • includes/elements/class-jalpi-element-countdown.php
  • includes/class-jalpi-renderer.php
  • includes/class-jalpi-sanitizer.php
  • assets/js/jalpi-frontend.js