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

jalpi page builder docs

Global Classes

The Jalpi Page Builder Class-Based Styling System provides reusable, site-wide CSS classes that can be attached to unlimited elements across every page. Modifying a Global Class instantly updates every element linked to it, establishing unified design consistency, minimizing stylesheet bloat, and eliminating repetitive inline styling.

Active Core Feature Site-Wide Styling CSS System Intermediate
4 min read Β· November 2026

Global Classes Overview#

Traditional WordPress page builders store styles directly inside each element's JSON data (inline/element-level styling). While convenient for quick edits, styling ten cards or twenty CTA buttons independently requires twenty repetitive style operations. When brand specifications change, every element must be manually hunted down and re-edited.

The Global Classes panel with class creation, applied-element counts and the Normal, Hover, Focus and Active state selector
Figure: Global Classes panel displaying active class rules and pseudo-class state editor.

Jalpi solves this with Global Classes. Stored in a dedicated database table ({prefix}jalpi_classes), Global Classes act as centralized styling templates. Elements reference classes by an immutable internal key (e.g. cls_9f3a1b2c), and Jalpi's server-side compiler dynamically generates clean, shared CSS classes (e.g. .card-shadow) rendered only when in use.

Core Benefits

Single Source of Truth

Define design properties once. If a card's border radius or shadow changes, editing the class updates all elements across the entire website instantly.

Zero CSS Bloat

Instead of generating 50 duplicate CSS rules for 50 identical widgets, Jalpi outputs a single shared CSS rule (.card-elevated) and enqueues it once.

Strict Brand Consistency

Prevent style fragmentation across teams. Team members can simply assign approved classes (e.g. .btn-primary, .feature-box) without guessing margins or colors.

Instant Cache Invalidation

Editing a class bumps an atomic version token (jalpi_classes_version), invalidating frontend page transients across the entire site with zero database resaves.

Architecture & Headless Node Pattern

In Jalpi's internal architecture, a Global Class is structured as a headless node. It possesses the exact same styling containers as a real canvas widget: styles (desktop), tabletStyles, mobileStyles, and a settings bucket containing background (bgNormal, bgHover) and border (borderNormal, borderHover) definitions.

Because the data structures are identical, Jalpi_Renderer compiles Global Classes using the same battle-tested engine helpers (styles_to_css, bg_data_to_css, border_data_to_css) used for elements, ensuring 100% visual fidelity between the editor and frontend output.

Creating a Global Class#

Jalpi provides two streamlined workflows for creating Global Classes: Inline Creation while designing on canvas, and Centralized Creation inside the dedicated Classes Panel.

1. Inline Creation via Properties Panel

The fastest way to convert an element's styles or start a new reusable class is directly from the element inspector:

  1. Select an Element: Click any widget, container, or column on the canvas.
  2. Open Advanced Controls: In the right-hand inspector panel, ensure the Style (Properties) tab is selected and scroll down to the CSS accordion group.
  3. Focus the Classes Field: Under Classes, you will find the ClassPicker chip input showing "Search or create a class…" (or "Add class…" if other classes are already attached).
  4. Enter Desired Name: Type the desired CSS class name (e.g. card-shadow or badge-pill). Jalpi automatically sanitizes the input via sanitize_html_class().
  5. Create & Attach: If no existing class matches, click the dropdown item + Create ".card-shadow" or press Enter.
  6. Automatic Attachment: Jalpi calls POST /wp-json/jalpi-page-builder/v1/classes, returns the server-generated record, and automatically attaches the new class chip to your element.
  7. Open Style Editor: Click directly on the newly created chip .card-shadow to open the Class Style Editor Modal and configure its typography, background, borders, and margins.
Pro Tip: You do not need to manually prefix class names with a dot (.). The editor displays the dot for clarity, but stores clean CSS identifier tokens.

2. Site-Wide Creation via Classes Panel

When planning a design system upfront before building canvas sections:

  1. Open the Classes Tab: In the main inspector tab bar (next to Outline, Style, Page, and Global), click the Classes tab (icon with two brackets / classes symbol).
  2. Enter Class Name: In the toolbar row, locate the text input with placeholder "New class name…".
  3. Click New Class: Enter the name and click the teal + New Class button (or press Enter).
  4. Immediate Availability: The class appears in the site-wide class list and immediately opens in the Style Editor modal, ready to be configured.

Applying a Global Class#

Once a Global Class exists, it can be applied to any number of elements across any page on the WordPress site.

Attaching Classes to Elements

  1. Select the target element on the canvas.
  2. Navigate to Advanced β†’ CSS β†’ Classes in the Properties Panel.
  3. Click into the text input. A dropdown list displays available site classes.
  4. Type any substring to filter classes in real time (e.g. typing "btn" displays .btn-primary, .btn-outline, .btn-ghost).
  5. Click any suggestion or press Enter when highlighted. The class attaches as an interactive chip.

Inherited Style Indicator (from .class)

When an element inherits styles from an attached Global Class, Jalpi prevents confusion by displaying an Inherited Badge in the element's style controls:

Editor UI RepresentationVisual State
[Margin]  from .card-shadow
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Top    β”‚ Right  β”‚ Bottom β”‚ Left   β”‚
β”‚ 16px   β”‚ 16px   β”‚ 16px   β”‚ 16px   β”‚  <-- Inherited value displayed in muted state
β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The badge displays from .{class-name}. Hovering over it shows the tooltip: "Inherited from .{class-name} β€” set a value here to override it locally." If you enter a local value into that control, the local value takes precedence and the badge disappears.

Detaching Classes from Elements

To detach a class from a specific element:

  • Click the small remove icon (Γ—) on the right side of the class chip.
  • The class key is immediately removed from the element's settings.cssClasses array.
  • The element instantly reverts to its local element styles and default widget styling.
  • Crucial: Detaching an element chip never deletes the class from other elements or from the site database.

Class Management#

The Classes Panel (accessible via the Classes tab in the right-hand inspector) serves as the central mission control for your entire site-wide class library.

The Classes Panel Workspace

The panel includes a comprehensive suite of management tools:

  • Search Bar: Filter classes by name in real time using case-insensitive substring matching.
  • Favorite Filter: Click the star icon (β˜…) in the toolbar to isolate only starred/favorite classes.
  • Usage Counters: Each row displays an instant badge showing how many times the class is used on the current page (e.g. 4Γ—).
  • Editing Indicator: Classes currently open in the style editor are highlighted with an active border and background.

Renaming, Favoriting & Reordering

ActionUI TriggerInternal Behavior
Edit StylesSingle-click on class name (.{name})Sets editingClassKey in store and opens ClassStyleEditorModal with live preview.
Rename ClassDouble-click on class name (.{name})Opens an inline text input. Press Enter or blur to commit. Jalpi updates the name, auto-uniquifies collisions, and triggers PATCH /classes/{key}.
Toggle FavoriteClick star icon (β˜…) on class rowToggles boolean favorite flag via POST /classes/{key}/favorite. Favorites pin frequently used utility classes for quick filtering.
Reorder (Up/Down)Click Chevron Up (β–²) or Down (β–Ό)Swaps position in the class list and persists order via POST /classes/reorder. Important: List order directly controls multi-class CSS cascade precedence!

Duplication & Protected Deletion

Duplication: Clicking the duplicate icon (two overlapping rectangles) clones the class, its 4 style buckets, and any design-system token references under the name {original}-copy (e.g. card-shadow-copy). Collisions automatically become -copy-2, -copy-3.

Protected Deletion: Deleting a class that is actively used across a website can disrupt layouts. Jalpi protects against accidental breakage with an asynchronous usage verification workflow:

  1. Click the trash icon on any class row.
  2. Jalpi opens a confirmation modal and immediately queries GET /wp-json/jalpi-page-builder/v1/classes/{key}/usage.
  3. The endpoint executes a SQL scan of the wp_jalpi_pages table to count exact page references site-wide.
  4. If references exist, the modal warns: "This class is referenced on {count} page(s) site-wide. Deleting it removes its styling from every widget it's attached to."
  5. Confirming deletion calls DELETE /classes/{key}. Node references on existing pages simply ignore the missing class during render without crashing or displaying errors.

Export & Import Workflows

In the footer of the Classes Panel, two dedicated buttons enable cross-site class sharing:

  • Export: Clicking Export calls GET /classes/export and downloads jalpi-classes.json containing all class definitions, sort orders, and style maps stamped with the plugin version.
  • Import: Clicking Import opens a native file selector. Uploading a JSON export payload calls POST /classes/import. The server supports three conflict strategies:
    • skip (Default): Leaves existing classes with matching keys unchanged.
    • overwrite: Updates existing class styles in-place with the incoming definitions.
    • duplicate: Re-creates the incoming classes under fresh keys with -copy suffixes.

Global Class Styling#

Clicking any class name in the Classes Panel or chip in the Properties Panel opens the Class Style Editor Modal (ClassStyleEditorModal). Changes made here apply across every element attached to that class.

Class Style Editor Modal Interface

The modal features a clean modal header displaying the class name (e.g. .card-elevated), a live usage notice ("Used on X elements on this page β€” changes apply everywhere this class is attached"), and collapsible accordion groups for all supported styling domains.

Every slider, color picker, or spacing input triggers store.upsertClass() instantly, rendering updates on the canvas in real time. A debounced 500ms timer handles persisting updates to the REST API in the background.

Supported Styling Properties

DomainSupported PropertiesHover State Support
Typography
  • Font Family: System fonts & Google Fonts from jalpiEditorConfig.fonts
  • Font Size & Line Height (px, rem, em, %)
  • Font Weight (100–900 scale)
  • Letter Spacing & Text Transform (uppercase, lowercase, capitalize, none)
  • Font Style (normal, italic) & Text Decoration (none, underline, line-through)
  • Text Color: Native color picker with hex/rgb input
Supported (Normal / Hover tabs for Color)
Background
  • Background Type: Classic (Solid Color) or Gradient
  • Color / Gradient: Angle, color stops, radial/linear
  • Background Image: URL, position, attachment, repeat, size (cover, contain, auto)
Supported (bgNormal vs bgHover buckets)
Border
  • Border Type: none, solid, dashed, dotted, double
  • Border Width: Independent top, right, bottom, left dimensions
  • Border Color: Custom color selection
  • Border Radius: Unified or linked corner radius (px, rem, %)
Supported (borderNormal vs borderHover buckets)
Spacing
  • Margin: Independent top, right, bottom, left box spacing
  • Padding: Independent top, right, bottom, left box spacing
Normal State
Note on Unimplemented Controls: Advanced CSS filters (blur, grayscale), 3D transforms, and custom keyframe animations are not currently exposed in the Global Class editor modal. They remain planned for future releases (see Coming Soon Features).

Multiple Classes#

Jalpi fully supports attaching multiple Global Classes to a single element, enabling utility-first or component-oriented design patterns (e.g. combining .card with .theme-dark and .shadow-lg).

Multi-Class Combination

When an element has multiple classes attached in settings.cssClasses, Jalpi resolves their names and outputs them in the HTML class attribute alongside any custom element classes:

HTML Frontend OutputHTML
<div class="jalpi-node-w8f2a card-base shadow-elevated border-accent custom-user-class">
  <!-- Widget Content -->
</div>

Cascade Precedence & Tie Breaking

When two attached classes define the same CSS property (for example, .card-base sets background-color: #ffffff while .theme-dark sets background-color: #1e293b), how does Jalpi determine which class wins?

  1. Database Sort Order Drives CSS Output: In Jalpi_Renderer::compile_class_css(), all used classes are sorted by sortOrder ascending before stylesheet rules are printed:
    includes/class-jalpi-renderer.phpPHP
    usort( $classes, static fn( $a, $b ) => $a['sortOrder'] <=> $b['sortOrder'] );
  2. CSS Source Order Rule: In standard CSS, when two class selectors have identical specificity (e.g. .card-base vs .theme-dark, specificity 0-1-0), the rule defined later in the stylesheet wins.
  3. Visual Reordering: In the Classes Panel, clicking Move Down increases a class's sortOrder, placing its CSS rules further down the generated stylesheet. Therefore, classes positioned lower in the manager list have higher cascade priority and override earlier classes.
  4. Editor Inheritance Order: The inspector's inheritedFrom() helper mirrors this exact rule: it scans attached classes in reverse order (for (let i = attachedClasses.length - 1; i >= 0; i--)) to ensure the editor UI always highlights the exact winning class.

Responsive Classes#

Global Classes in Jalpi are natively responsive. A single class can define base styling for Desktop, along with targeted overrides for Tablet and Mobile viewports.

Desktop, Tablet & Mobile Breakpoints

The class data structure maintains three independent style buckets:

  • styles: Desktop baseline styles (applies to all screen widths unless overridden).
  • tabletStyles: Overrides applied at the Tablet breakpoint (default: max-width: 1024px).
  • mobileStyles: Overrides applied at the Mobile breakpoint (default: max-width: 767px).

When editing in the visual editor, toggling the top-bar breakpoint switcher (Desktop / Tablet / Mobile) switches the target bucket automatically. Values left blank at a narrower breakpoint automatically inherit from the wider breakpoint.

Media Query Output & Fallbacks

When rendering frontend pages, Jalpi_Renderer compiles these buckets into organized responsive media query blocks:

Compiled Page StylesheetCSS
/* 1. Desktop Global Class Rules */
.card-shadow { box-shadow: 0 4px 16px rgba(0,0,0,0.12); padding: 32px; }
.card-shadow:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.18); }

/* 2. Tablet Media Query (max-width: 1024px) */
@media (max-width: 1024px) {
  .card-shadow { padding: 24px; }
}

/* 3. Mobile Media Query (max-width: 767px) */
@media (max-width: 767px) {
  .card-shadow { padding: 16px; border-radius: 8px; }
}

Breakpoint widths are read dynamically from Jalpi_Settings::get('breakpoints'), ensuring that custom site breakpoints configured under Editor Settings are respected across all Global Classes.

Class Naming#

Jalpi enforces strict server-side validation and sanitization to ensure that class names always generate valid, crash-free CSS selectors.

Sanitization & Validation Rules

CriterionEnforcement RuleBehavior / Example
Allowed Characters[a-zA-Z0-9_-]Passed through WordPress core sanitize_html_class(). Uppercase letters are preserved.
Spaces & PunctuationStripped or convertedEntering "card shadow & highlight" is sanitized to valid identifier tokens. Spaces are removed or hyphenated.
Leading DotsAutomatically removedEntering .my-class strips the leading dot; the class is saved cleanly as my-class.
Empty / Invalid FallbackFallback to 'class'If input sanitizes to an empty string (e.g. only symbols entered), the server falls back to literal class.

Auto-Uniquification & Server Keys

Class names are guaranteed unique site-wide. When a class name collision occurs:

  • Jalpi_Class_Manager::unique_name() checks existing classes.
  • If card-shadow already exists, saving another class with the same name automatically becomes card-shadow-2. Subsequent collisions become card-shadow-3, card-shadow-4, etc.
  • Internal Server Key: The client never invents the database identifier. The server generates an immutable key matching cls_ followed by 8 random hex characters (e.g. cls_9f3a1b2c) using bin2hex(random_bytes(4)). Even if a class is later renamed from .hero-card to .featured-card, its immutable key ensures existing element references remain intact.

Global Classes vs Element Styles#

Understanding when to use a Global Class versus an Element Style is fundamental to building scalable, high-performance Jalpi websites.

Architectural Comparison

DimensionGlobal ClassesElement Styles (Inline)
ScopeSite-wide across unlimited pages and elementsScoped strictly to a single widget node
Storage LocationCentral database table: {prefix}jalpi_classesEmbedded inside page JSON in wp_jalpi_pages
CSS Specificity & PrecedenceClass selector (.card-base, specificity 0-1-0). Emitted first in stylesheet.Node ID selector (.jalpi-node-w8f2a). Emitted after class rules, overriding class declarations.
Updating & MaintenanceSingle edit updates all linked elements site-wide automaticallyRequires editing each element individually
Cache InvalidationIncrements jalpi_classes_version, invalidating render transients site-wideInvalidates only the specific post's render transient
CSS Payload SizeGenerates 1 CSS rule regardless of how many widgets use itGenerates unique CSS declarations for every widget instance

When to Use Each Approach

  • Use Global Classes for:
    • UI components repeated across pages: Cards, Testimonial cards, Service boxes, Pricing tables.
    • Button variations: .btn-primary, .btn-secondary, .btn-pill.
    • Typography patterns: Special pull quotes, section subtitles, badge labels.
    • Standardized padding/margin containers used throughout your design system.
  • Use Element Styles for:
    • One-off layout adjustments unique to a specific page or section.
    • Specific element positioning (e.g. absolute coordinates for a decorative graphic).
    • Overriding a single property of a global class (e.g. setting a unique custom background color on one specific card while keeping the global class's padding and borders).

Updating a Global Class#

When a Global Class is modified, Jalpi utilizes a dual-tier update pipeline to ensure both instantaneous editor feedback and immediate site-wide cache synchronization.

Live In-Editor Propagation

If a page contains 15 cards with the .service-card class attached:

  1. Open the style editor modal for .service-card.
  2. Adjust the border radius from 8px to 24px or change the hover box-shadow.
  3. Immediate Reactivity: The editor store executes store.upsertClass() in memory. All 15 cards on the active canvas update instantly and simultaneously without requiring a canvas reload or page save.
  4. Debounced Persistence: 500 milliseconds after your last adjustment, an asynchronous PATCH /wp-json/jalpi-page-builder/v1/classes/{key} request persists the new definition to the database.

Site-Wide Render Cache Invalidation

How do changes reach pages that are currently cached in production?

Rather than executing an expensive SQL table scan to rebuild every cached post, Jalpi uses a high-performance atomic version bump pattern:

Transient Cache Key Generation (includes/class-jalpi-renderer.php)PHP
public function cache_key( int $post_id ): string {
    return 'jalpi_render_' . $post_id . '_' . JALPI_VERSION . '_c' . Jalpi_Class_Manager::instance()->version();
}
  • Every time any class is created, updated, or deleted, Jalpi_Class_Manager::bump_version() increments the WordPress option jalpi_classes_version.
  • Because the version integer is folded directly into every page's render transient key (e.g. jalpi_render_42_1.0.5_c7), old transients instantly become unreachable.
  • The next time any visitor requests any page on the site, Jalpi generates fresh HTML and CSS reflecting the updated class definition. Unreachable old transients expire naturally within their normal TTL with zero database maintenance required.

Removing a Global Class#

Detaching vs Deleting Safe Behaviors

OperationScopeWhat Happens to ElementsDatabase Impact
Detaching from an ElementSingle widgetElement's settings.cssClasses array removes the key. The element immediately loses the class styling and falls back to local element styles. Other elements on the site are completely unaffected.Saved to post JSON when the page is updated.
Deleting the Class from SiteSite-wideThe class record is removed from {prefix}jalpi_classes. All widgets site-wide that reference the deleted key simply skip it at render time (Jalpi_Renderer::get_css_attrs()). No broken HTML, no missing CSS errors.Row deleted from custom table; jalpi_classes_version bumped; jalpi_class_deleted action fires.

Developer Reference#

Technical architecture, database structures, actions, and REST API routes verified against the current Jalpi Page Builder codebase.

PHP Architecture & Data Layer

ClassFile LocationPrimary Responsibility
Jalpi_Class_Managerincludes/class-jalpi-class-manager.phpSingleton data access layer. Manages table creation, in-request caching, object caching (jalpi_classes_all, 1 hour TTL), CRUD, version bumps, uniquification, export, and import.
Jalpi_Classes_APIincludes/class-jalpi-classes-api.phpRegisters all 10 REST API routes under /wp-json/jalpi-page-builder/v1/classes. Enforces edit_posts capability check.
Jalpi_Rendererincludes/class-jalpi-renderer.phpCompiles class styles via compile_class_css(), resolves classes in get_css_attrs(), and folds version into render transient keys.
Jalpi_Sanitizerincludes/class-jalpi-sanitizer.phpValidates incoming class payloads via sanitize_class_definition() before database insertion.

Database Schema ({prefix}jalpi_classes)

SQL Table DefinitionSQL
CREATE TABLE IF NOT EXISTS {$wpdb->prefix}jalpi_classes (
    id          BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    class_key   VARCHAR(64)     NOT NULL,
    name        VARCHAR(191)    NOT NULL,
    styles      LONGTEXT        NOT NULL,
    favorite    TINYINT(1)      NOT NULL DEFAULT 0,
    sort_order  INT UNSIGNED    NOT NULL DEFAULT 0,
    created_by  BIGINT UNSIGNED NOT NULL DEFAULT 0,
    created_at  DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at  DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (id),
    UNIQUE KEY class_key (class_key),
    KEY sort_order (sort_order)
) {$charset};

Hooks & Action Reference

Hook NameTypeParametersDescription
jalpi_class_savedActionstring $key, array $classFires whenever a class is created, updated, duplicated, or has its favorite flag toggled. Deep-linked to Hooks Documentation.
jalpi_class_deletedActionstring $keyFires when a class row is deleted from the database. Deep-linked to Hooks Documentation.
jalpi_before_compile_class_cssFilterstring $rules_css, array $used_class_keysFilters compiled desktop class CSS string before it is combined with element rules.

REST API Endpoints Reference

All ten endpoints operate under namespace jalpi-page-builder/v1, require WordPress cookie authentication + REST nonce (X-WP-Nonce), and verify capability edit_posts. Cross-referenced to REST API Documentation.

MethodEndpointDescription
GET/classesReturns array of all class records, ordered by sort_order ASC. Supports search and favorite query parameters.
POST/classesCreates a new class. Accepts name, styles, tabletStyles, mobileStyles, settings, globalStyleRef, favorite.
PATCH/classes/{key}Partial update of class properties. Explicit null on globalStyleRef clears design token link.
DELETE/classes/{key}Deletes class record. Returns { deleted: bool } with 200 OK.
POST/classes/{key}/duplicateDuplicates target class under {name}-copy.
POST/classes/{key}/favoriteInverts the boolean favorite status flag.
GET/classes/{key}/usagePerforms on-demand SQL LIKE scan of wp_jalpi_pages to return { count: int }.
POST/classes/reorderPersists updated sort orders (1, 2, 3...) from an array of keys. Drives CSS cascade precedence.
GET/classes/exportReturns { version, classes[] } for cross-site portability.
POST/classes/importImports array of classes with conflict resolution (skip, overwrite, duplicate).

Roadmap & Coming Soon Features

The following advanced class capabilities are planned for upcoming Jalpi Page Builder updates and are currently badged as Coming Soon:

Advanced Pseudo-Classes

πŸ”’ Soon

Styling :focus, :active, :focus-visible, and :visited states directly within class definitions.

Class Folders & Tagging

πŸ”’ Soon

Organize extensive class collections into custom folders (Layout, Typography, Buttons, Effects).

Scoped Custom CSS

πŸ”’ Soon

Write raw CSS blocks directly inside a class definition with automatic selector scoping.