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

jalpi page builder docs

Sanitization & Security

The trust boundary, the escaping strategy, capability gates and every validation mechanism in the plugin.

Jalpi CoreDeveloper
6 min read Β· November 2026

Jalpi sanitizes once, at save time, and escapes again at output. This page documents both passes and the capability model around them. Nothing here should be bypassed β€” the renderer is written to trust stored data precisely because the sanitizer already vetted it.

The trust boundary#

Jalpi_Sanitizer::sanitize_page_data() is the single entry point, called from Jalpi_API::save_page() before any database write. It is an allow-list at every level:

sanitize_page_data()
  β”œ version         sanitize_text_field()
  β”œ globalStyles    sanitize_global_styles()
  β”” sections[]      sanitize_node()  (recursive)
        β”œ type          must be in $allowed_types βˆͺ jalpi_widget_schema_types()
        β”œ id            sanitize_key(); required; must be unique in this pass
        β”œ content       sanitize_content( $type, … )   one branch per type
        β”œ styles        sanitize_styles()              fixed property allow-list
        β”œ tabletStyles  sanitize_styles()
        β”œ mobileStyles  sanitize_styles()
        β”œ settings      sanitize_settings( $type, … )
        β”œ children[]    sanitize_node()  (depth++)
        β”œ hideOn        three booleans
        β”œ locked        boolean
        β”œ globalStyleRef sanitize_global_style_ref_data()
        β”” interactions  sanitize_interactions()

Anything not named above is dropped. An unknown type returns [] and the caller filters the node out entirely.

Structural guards#

GuardMechanismPrevents
Depth limitMAX_DEPTH = 20, tracked in self::$depthStack exhaustion from a deeply nested payload
Circular referenceself::$seen_ids; a repeated id returns []Infinite recursion from a duplicated id
Missing idA node with no id returns []Unscopable CSS and unaddressable nodes
Class-attachment caparray_slice( $keys, 0, 50 )Unbounded class lists
Demo-menu capDepth > 5 or 30 items stops recursionPayload bloat in demoItems
Custom CSS capsubstr( $css, 0, 5000 )Unbounded per-element CSS

Primitive sanitizers#

FunctionAcceptsRejects
sanitize_url()http, https, mailto; {{tag}} placeholders pass through as textEvery other scheme, including javascript: and data:
sanitize_dimension()number + unit (%, px, em, rem, vw, vh, dvh, svh, lvh, s, ms, deg, fr, ch, ex); unitless numbers; the keywords auto/inherit/initial/unset/none/normal; strict clamp()/min()/max()calc(), var(), arithmetic, anything else
sanitize_dimension_shorthand()1–4 space-separated values, each validated individuallyMore than four parts, or any invalid part
sanitize_color()#rgb–#rrggbbaa, rgb()/rgba(), hsl()/hsla(), 25 named keywords, and var(--name) with an optional validated fallbackEverything else
sanitize_css_value()Compound values after stripping the patterns belowexpression(, -moz-binding:, javascript:, vbscript:, data:, @import, HTML comments
sanitize_custom_css()Raw CSS, capped at 5000 charsexpression(, -moz-binding:, javascript:, vbscript:, @import, </style, <script
sanitize_icon_value(){type,lib,name} with type in svg/font/img; the SVG body passes a strict wp_kses() element and attribute listUnknown types; <script>, event handlers and unknown SVG attributes

HTML handling#

Three different filters apply depending on the field:

  1. Rich text fields (heading text, text HTML, accordion bodies, FAQ answers, testimonial text, CTA subtitle, timeline text…) use wp_kses_post().
  2. The HTML widget branches on capability:
'html' => current_user_can( 'unfiltered_html' )
          ? wp_kses( $content['html'] ?? '', self::kses_html_block() )
          : wp_kses_post( $content['html'] ?? '' ),

kses_html_block() extends the post allow-list with structural tags, tables, <iframe>, <video>, <audio>, <picture>, <source> and inline SVG.

  1. Final output escaping β€” the entire rendered page is passed through wp_kses( $html, Jalpi_Renderer::allowed_html() ) before it is returned from the_content. Cached HTML is escaped before being written to the transient, so a cached value is already safe.

The net effect is defence in depth: even markup that passed kses_html_block() at save time is re-filtered against allowed_html() at output.

allowed_html()#

Built from wp_kses_allowed_html( 'post' ) plus:

  • Global attributes on the common structural tags: id, class, style, role, aria-hidden, aria-label, aria-labelledby, aria-current, data-*, title, tabindex, and the schema.org microdata attributes itemscope, itemtype, itemprop, itemid, itemref.
  • <meta content>, so breadcrumb position data survives.
  • Media attributes on <img> (srcset, sizes, loading), <video>, <source> and <iframe> (allow, allowfullscreen, loading).
  • Form elements: <input>, <select>, <option>, <textarea>, <label>, <form>, <button> with their expected attributes.
  • SVG elements: svg, path, circle, rect, line, polyline, polygon, g.
  • <i> with the global attributes, for font-icon classes.

data-* being allowed globally is what lets the renderer ship data-jalpi-interact, data-jalpi-st and every widget’s configuration through wp_kses() intact.

Capability model#

SurfaceCapabilityNotes
Open the editor / admin menuedit_posts, then edit_post on the targetChecked in both render_editor_page() and enqueue_editor()
GET/POST /page/{id}edit_post on that postJalpi_API::edit_permission()
POST /page/{id}/publishedit_post and the post type’s publish_posts cap; plus edit_others_posts when the author differspublish_permission()
Design System read/writemanage_options, filterable via jalpi_design_system_capabilitySite-wide, so gated harder than page editing
Media uploadupload_filesMIME sniffed with finfo before media_handle_upload()
Website-kit importmanage_optionsCreates pages, menus, templates and possibly installs WooCommerce
Templatesedit_posts to read, edit_posts/publish_posts to writeJalpi_Templates::read_permission() / write_permission()
Reusable classesedit_postsSite-wide but authoring-level
Theme Builderedit_theme_optionsMapped onto the CPT’s own capabilities
Revisionsedit_post on the post
HTML widget extended tagsunfiltered_htmlOtherwise wp_kses_post()
Shortcode widgetedit_posts at save timeOtherwise the shortcode is stored as an empty string
Role Manager permissionsA Jalpi permission and the WordPress capabilityChecked on every editor REST route and on each save by the document guard, which drops or reverts changes the role may not make. Users with manage_options are never restricted. JALPI_PERMISSIONS_DISABLED switches the layer off. See Role Manager.

CSRF and AJAX#

REST routes rely on the WordPress framework: the editor sends X-WP-Nonce, and the framework validates it before any permission_callback runs. admin-ajax.php handlers verify their own nonce explicitly:

ActionNonce actionAdditional gate
jalpi_pg_pagejalpi_pgPost must be published, or the user must pass read_post
jalpi_pg_cartjalpi_pgSelf-guards on WooCommerce being loaded; runs woocommerce_add_to_cart_validation
jalpi_template_previewjalpi_template_previewedit_posts; the id must match /^[A-Za-z0-9:_-]{1,120}$/
jalpi_site_previewjalpi_preview_sitemanage_options
jalpi_support_diagnostics, jalpi_support_submitjalpi_supportRate-limited to 3 requests per user per hour

Note that jalpi_pg_page and jalpi_pg_cart are registered for nopriv as well β€” they must be, since visitors paginate and add to cart. Neither accepts a query: the handler rebuilds it from the saved node, so only post, node and page travel over the wire.

SQL and file access#

  • All direct queries use $wpdb->prepare() with %d/%s placeholders; table names go through esc_sql() before interpolation.
  • Saving is a single atomic UPDATE … SET version = version + 1, so concurrent saves cannot race the version counter.
  • import_website() runs sanitize_key() on the kit id and explicitly rejects / and \ before building a path, blocking directory traversal.
  • Jalpi_Template_Preview::handle() validates its id against a regex rather than sanitize_key(), because kit ids legitimately contain :.
  • Media uploads sniff the real MIME with finfo( FILEINFO_MIME_TYPE ) and accept only image/jpeg, image/png, image/gif, image/webp and image/avif β€” the declared extension is not trusted.

There is no ZIP import path in the plugin. Template import accepts a JSON string over REST; website kits are read from files already inside the plugin directory.

Important

  • Never call Jalpi_Renderer::render_node() on data that has not been through Jalpi_Sanitizer. The renderer interpolates stored values into CSS strings on the assumption that they were validated at save time.
Source

Files

includes/class-jalpi-sanitizer.php includes/class-jalpi-renderer.php includes/class-jalpi-api.php includes/class-jalpi-woo-ajax.php includes/class-jalpi-template-preview.php includes/support/class-jalpi-support-center.php

Classes

Jalpi_Sanitizer Jalpi_Renderer Jalpi_API Jalpi_Woo_Ajax Jalpi_Template_Preview Jalpi_Support_Center

Functions

sanitize_page_data sanitize_node sanitize_content sanitize_styles sanitize_settings sanitize_url sanitize_color sanitize_dimension sanitize_css_value sanitize_custom_css sanitize_icon_value allowed_html kses_html_block