DocumentationDownload

Compiler, runtime, layouts and sections

Nucleo 0.2+Free~31 min readUpdated October 31, 2026

Nucleo compiles every document on save, not on visit, and the frontend reads only the result.

On this page

01Overview

Nucleo compiles every document when you save it, not when a visitor opens the page. Nucleo runs a pipeline: it normalizes, expands sections, resolves links, validates, checks quality, compiles and writes. The compiler produces static HTML with slot markers, instance CSS, a list of slots and a list of scripts. The HTML goes into post_content, the CSS into a file under uploads/nucleo/css/, and the rest into the _nucleo_rt meta. The frontend runtime reads only this data and the artifacts in wp-content/uploads/nucleo/store/. It does not load the compiler or the block registry. Layouts are documents with kind layout or popup in the nucleo_layout type. Their conditions become a map that the runtime checks per area. Reusable sections are documents with kind section in the nucleo_section type, inserted with the nc/section-ref block. When a section, a menu, a link or a site option changes, Nucleo queues the rebuild of the pages that depend on it.

The document schema and the blocks are described in the chapter Document schema and blocks.

02Compilation on save

Save pipeline

What it does: takes a document from the JSON it receives to the written post. Nucleo runs these steps in order.

Menus

Converts the menu slugs of nc/menu ("principale" or "menu:principale") to the menu ID.

Conditions

Normalizes the layout conditions. Numeric IDs sent as strings become integers. Validates only the new or changed conditions.

Normalization

Normalizes the document (migrations, block defaults) and expands the nc/section-ref nodes.

Links

Resolves the reference links (page:<slug>, term:<taxonomy>/<slug>, home) to URLs.

Schema

Validates the schema. Errors inside a section point to the nc/section-ref node of the document.

Quality

Checks the quality of the composed page, with the same areas as the public site, also for new content not saved yet: page choices, layout none, single or product layouts. The CSS weight is the one of the document compiled in this save. Applies the saved and new acknowledgements (acknowledge).

Dry run

With dryRun it stops here and returns the report.

Compilation

Compiles the expanded document.

Write

Writes the CSS file first, then post_content, the meta and the dependencies. The CSS goes into a temporary file renamed at the end; the previous files stay 7 days for cached pages. Emits nucleo/document_saved and empties the page cache. Save, patch and rebuild of the same document do not overlap: a MySQL lock per document (GET_LOCK) queues them, with the maximum wait from the filter nucleo/document_lock_timeout.

How to use it: it has no interface of its own. The write abilities call it (nucleo/doc-create, nucleo/doc-patch, nucleo/doc-publish, nucleo/doc-rollback, nucleo/doc-texts-set, nucleo/doc-translate (Pro), nucleo/layout-conditions-set), as well as the site import and the check of the meta read by bindings. See the chapter Write abilities.

Parameters:

NameTypeAllowed valuesDefaultNotes
publishbooltrue, falsefalseSets post_status to publish.
dryRunbooltrue, falsefalseValidates and checks quality without writing.
acknowledgelist{rule, node, reason}[]Acknowledges quality issues.
baseRevisionint or nullintegernullIf different from the current revision: conflict error.
titlestringtext''Post title. Empty: the current title stays.
postTypestringpost typepageOnly on creation.
slugstringslug''Only on creation. Empty: WordPress takes it from the title.
parentint or null0 or IDnullnull keeps the parent as it is.

Permissions: the save step does not check permissions. The ability or command that calls it does.

Edition: Free

Known limits:

  • Error codes returned: invalid_document, quality_blocking, conflict, not_found, patch_failed, write_failed, exists (only start).
  • The blocking quality check applies with publish. It also applies to every save of a post that is already published.
  • The saved document keeps the nc/section-ref nodes and the symbolic links. The expansion is used only to validate and compile.
  • The rules seo.h1.missing, a11y.landmark.missing and seo.content.thin do not apply to layouts, sections and popups. For sections, content.button.inert and form.action.consequential do not apply either.
  • An acknowledgement expires when the node changes. Nucleo saves a fingerprint of the node, without its children, together with the acknowledgement.
  • When you create a document with bind, it compiles twice. The static bindings read the post, which does not exist yet.
  • The budget rules compare the composed page with default values: CSS 76800 bytes, JS 102400 bytes, DOM 1500 estimated nodes. The filter nucleo/quality/<css|js|dom>_budget changes them for the site.
  • A new content item not saved yet: the quality uses the layouts of its type, but it has no CSS weight. The budgets apply from the first save.

Attach to existing content

What it does: creates the first Nucleo document of an existing post. The type, title and status stay those of the post. If the document has an empty root.children, Nucleo converts the paragraphs, headings and list items of the WordPress text into nc/text blocks. It saves the original text in the _nucleo_wp_content meta.

How to use it: nucleo/doc-create with postId. It accepts only kind page.

Parameters: postId, document, dryRun, acknowledge.

Permissions: those of nucleo/doc-create. See the chapter Write abilities.

Edition: Free

Known limits:

  • At most 200 nc/text blocks. Bold, italics and links remain.
  • Images and other elements are lost in the document.
  • exists error if the post already has a document.

Compiler

What it does: turns a valid, expanded document into a compile result. It contains:

  • html: static HTML with the slot markers.
  • css: instance CSS of the nodes.
  • blockTypes: block types used, in document order.
  • slots: list of the dynamic slots.
  • assets: styles and scripts of the blocks used, with the loading strategy.
  • lcpNodeId: the first node that claims the LCP priority.
  • deps: node dependencies, from the deps of the manifests and from the static bindings.

How to use it: internal to the save. With markIds true, as in the preview, every node receives data-nc-id on its first tag. The preview uses the REST route POST nucleo/v1/preview (capability edit_posts) and the ability nucleo/doc-preview.

Parameters: document, binding source (optional), markIds (bool, default false).

Permissions: none.

Edition: Free

Known limits:

  • Document without root: exception Document has no root.
  • Block type not registered: exception Block type not registered.
  • A node with the old ref field produces an empty string.
  • For layouts, sections and popups, the per-node classes have a 4-character prefix taken from the document. This way two documents on the same page do not share .nc-n1.
  • A link with an unresolved reference becomes href="#" aria-disabled="true".
  • The cards of the nc/query and nc/collection blocks never claim the LCP priority.

Dynamic slots

What it does: marks in the HTML the parts that the runtime computes on every request. The marker is <!--nc:s N-->fallback<!--/nc:s-->. N is the index in the slots list of _nucleo_rt. The fallback is the HTML that shows if the slot is not filled.

How to use it: the blocks that compute a part on every request register it as a slot. The compiler creates two wrapper slots on its own:

  • nc/visibility for a node with a non-empty visibility.when. Empty fallback.
  • nc/bind for a node with dynamic bindings. The values become __NCB<n>__ tokens to replace at runtime.

Parameters: None

Permissions: none.

Edition: Free

Known limits: the dynamic value of a binding is escaped as a URL if the key ends with src, url, href or poster. It is escaped as HTML for content.html, and as text in the other cases.

What it does: replaces the internal references with the URL before validation. It acts on the href keys of content and settings at every depth, and on the href attributes of the <a> tags in content.html. The saved document keeps the symbol.

How to use it: write one of these values in the link field, with an optional #anchor:

FormExampleTarget
homehome#contattihome_url('/')
<post-type>:<slug>page:chi-siamo, post:novitapublished content of the type
<post-type>:<path>page:servizi/consulenzahierarchical types only
term:<taxonomy>/<slug>term:category/notizieterm; term:category:notizie is also allowed

Parameters: None

Permissions: none.

Edition: Free

Known limits:

  • Reserved prefixes, which are not references: http, https, mailto, tel, sms, ftp, file, data, javascript, vbscript, section, menu, media, author, term (as a post type).
  • Only published content of visible types and terms of visible taxonomies.
  • A reference resolved once follows the content by ID even after a slug change (meta _nucleo_links).
  • Reference without a target: quality notice content.link.missing. An internal path written as /chi-siamo/ produces the notice content.link.path with the suggested reference.

Rich text sanitization

What it does: cleans the inline HTML of the text blocks. It keeps strong, em, b, i, br, p, ul, ol, li, span (only class) and a (href, target, rel). It removes script and style with their content. The other tags disappear and their text stays.

How to use it: the blocks that show rich text apply this cleanup to their HTML.

Parameters: None

Permissions: none.

Edition: Free

Known limits: allowed href values: http:, https:, mailto:, tel:, / (not //) and #. With target="_blank" it adds rel="noopener".

03Rebuild and invalidation

Rebuild of a document

What it does: rebuilds the saved document without creating a new revision or a history entry. It expands the sections again, so the page uses the current version.

How to use it: used by nucleo/cache-rebuild, the rebuild queue and the check of the meta read by a binding.

Parameters: post ID.

Permissions: none in the service. nucleo/cache-rebuild requires manage_options and the scope nucleo:admin.

Edition: Free

Known limits:

  • The document is no longer valid after a section change: the page keeps the previous HTML and CSS. The errors go to the _nucleo_stale meta.
  • Blocking problems on a published post: the page keeps the previous version. The problems go to the _nucleo_stale_quality meta.
  • A successful rebuild deletes both meta.

Rebuild queue

What it does: keeps the IDs of the documents to rebuild in the nucleo_rebuild_queue option and processes them in batches with WP-Cron (hook nucleo_rebuild).

How to use it: automatic. Nucleo queues every post with the _nucleo_doc meta. After a plugin update, at the first admin, REST or WP-CLI request, Nucleo sees that the installed version (nucleo_installed_version) has changed and queues every document. This way the saved HTML, including the versioned store.js URL, follows the renderers of the new version.

Parameters: None

Permissions: none.

Edition: Free

Known limits:

  • Per run: at most 20 documents or 20 seconds. If documents remain, Nucleo schedules another event.
  • The nucleo_rebuild callback is registered only in WP-Cron requests.
  • A rebuild that starts during another rebuild only queues.
  • Nucleo removes from the queue a document that has just been written.
  • A document stays in the queue until the rebuild has an outcome. If it fails, it retries after 30 seconds per attempt, up to 3 attempts. Then it leaves the queue and a record keeps the attempts, the code and the message of the error. nucleo/status exposes it in failed.
  • The queue records for each document the generation of the last enqueue. A document enqueued again during its rebuild stays in the queue for another round.
  • Queue writes go through a MySQL lock; one process at a time works on the queue.
  • After a plugin update, a document with blocking problems keeps the previous HTML and stays stale (see Rebuild of a document).

Invalidation events

What it does: queues the rebuild of the documents that depend on a changed object. The dependencies are in the _nucleo_dep meta of each document, one row per dependency.

How to use it: automatic in admin, REST and WP-CLI. Frontend requests do not register these hooks.

WordPress eventDependency searchedExecution
nucleo/document_saved on a sectionsection:<id>, section-slug:<slug>first 10 right away, the rest queued
post_updated with a changed section slugold and new slugfirst 10 right away
Section moved to the trash or restoredsection:<id>, section-slug:<slug>first 10 right away
wp_update_nav_menu, wp_update_nav_menu_itemmenu:<id>queued
Publication or withdrawal of a post; public meta or _thumbnail_id and terms of a published postquery:<type>queued
Change of slug or parent, publication, withdrawal of a content itemlink:post:<id>, link-slug:<type>:<slug> (descendants too)queued; after the save if the write is from Nucleo
deleted_postlink:post:<id>queued
created_term, edited_term, delete_termlink:term:<id> (children too), link-slug:term:<taxonomy>/<slug>queued
blogname, blogdescription, site_logo, customize_save_aftersite, bind:site:name, bind:site:description, bind:site:logo, bind:site:urlqueued
post_updated with a changed title, excerpt, date or authorthe post itself, if it has a bind:post: or bind:author: dependencyimmediate rebuild
profile_updateposts of the user with a bind:author: dependencyqueued
permalink_structureall documentsqueued
WPLANG, date_format, time_formatall documents; increments nucleo_content_versionqueued
added_post_meta, updated_post_meta, deleted_post_meta read by a bindingevery dependency ending with :<key>; _thumbnail_id looks for bind:post:imageimmediate rebuild

Parameters: None

Permissions: none.

Edition: Free

Known limits:

  • The dependent search reads pages of 500 documents, with no total limit.
  • When the language changes, Nucleo adjusts date_format and time_format only if they still have the default format of the previous language.
  • Changes to the tokens do not rebuild the pages: Nucleo republishes the tokens artifact and, if the token CSS changed, empties the whole page cache.

Rebuild of all documents

What it does: queues every document in these cases:

  • plugin update to a different version;
  • change of the block files (new CSS bundle);
  • change of the permalink structure, the language or the date and time formats;
  • rebuild of the artifact store.

How to use it: automatic. By hand: nucleo/cache-rebuild without postIds, or wp nucleo ability run cache-rebuild (see WP-CLI commands).

Parameters: see the ability.

Permissions: manage_options, scope nucleo:admin.

Edition: Free

Known limits: the ability rebuilds at most 20 documents right away and queues the rest. It accepts at most 200 postIds.

Page cache purge

What it does: after each write, empties the cache of the caching plugins that are present. For a layout it empties the whole cache. For the other documents it empties only the URL of the post. With LiteSpeed Cache it also empties the pages with the tag nucleo-post-<id>, sent in the X-LiteSpeed-Tag header of the document.

How to use it: automatic. Supported plugins, when present: LiteSpeed Cache, WP Rocket, W3 Total Cache, WP Super Cache, SiteGround Optimizer, WP Fastest Cache, Breeze, Kinsta.

Parameters: None

Permissions: none.

Edition: Free

Known limits: with Breeze, purging a single post empties the whole cache. Other cache systems connect with nucleo/purge_url and nucleo/purge_all.

Block CSS bundle

What it does: concatenates and minifies the CSS of all the registered blocks, in alphabetical order, into uploads/nucleo/css/blocks.<hash8>.css. A signature of the manifest paths and modification dates avoids reading the files again on every save.

How to use it: automatic when compiling and in the editor.

Parameters: None

Permissions: none.

Edition: Free

Known limits: when the bundle changes, Nucleo keeps the previous bundle, deletes the older ones and queues all documents. A uploads folder that is not writable, or the CSS of a block that cannot be read: exception.

Token publication

What it does: writes the tokens artifact with the @font-face rules of the local fonts, the CSS variables of the tokens, the version (hash) and the URL of the font to preload. In the font stack it adds a metric fallback font after the first family. The saved option does not change.

How to use it: automatic after nucleo/tokens-set, the site import and the font import. See the chapter Design tokens.

Parameters: None

Permissions: those of the calling ability.

Edition: Free

Known limits: invalid token groups: invalid_tokens error.

04Data produced and where it lives

Post meta

What it does: keeps the source, status and runtime of each document.

MetaContentRead by the frontend
_nucleo_docraw JSON document, with nc/section-ref and symbolic linksno (only in writing, from the layout publisher)
_nucleo_revrevision number, +1 on each saveno
_nucleo_histhistory of the last 20 versions {rev, doc, time, user}no
_nucleo_rtruntime: cssFile, cssUrl, styles, eager, lazy, slots, lcp, breadcrumbBlock, seo (only with meta.seo)yes
_nucleo_depdependencies, one row per valueno
_nucleo_linkstargets of the resolved links (link:post:<id>, link:term:<id>)no
_nucleo_ackquality acknowledgements still valid, with the node fingerprintno
_nucleo_stale, _nucleo_stale_qualityerrors of the last failed rebuildno
_nucleo_wp_contentoriginal WordPress text of an attached contentno

How to use it: read with nucleo/doc-get for the document. The other meta are internal.

Parameters: None

Permissions: none.

Edition: Free

Known limits: meta.seo.noindex set to true also writes the noindex meta read by the sitemap.

Files and artifacts

What it does: separates the data served to the browser from the data read by the PHP runtime.

DataLocation
Compiled HTMLpost_content of the post (written without kses filters)
Instance CSS of pages, layouts and sectionsuploads/nucleo/css/p-<id>.<hash8>.css
CSS of all the blocksuploads/nucleo/css/blocks.<hash8>.css
Tokenstokens artifact, printed inline with the handle nucleo-tokens
Layout maplayouts artifact (map, exclude, conflicts)
Published layoutlayout-<id> artifact (html, rt, popup)

The artifact store writes PHP files <key>.<hash8>.php in wp-content/uploads/nucleo/store/<blog>-<generation>/, under the wp_upload_dir() folder. If the folder is not writable, it uses the database options. Up to 0.4.0 the store was in wp-content/cache/nucleo/: on update Nucleo moves the site generation to the new folder.

How to use it: internal.

Parameters: None

Permissions: none.

Edition: Free

Known limits: an empty CSS file stays on disk, but the runtime does not enqueue it. Each write deletes the previous p-<id>.*.css files.

05Frontend runtime

Runtime start

What it does: registers only two callbacks on public site requests: wp (priority 1) and the_content (priority 9). In wp:

  1. loads the CSS preview only if the nucleo_css parameter is present;
  2. stops in emergency mode;
  3. prepares the layout areas;
  4. attaches the asset rules to wp_enqueue_scripts with priority 9999;
  5. on a single content with _nucleo_rt: registers the SEO meta and JSON-LD, removes wpautop and wptexturize, enqueues tokens, styles and scripts.

How to use it: automatic. The theme checks whether the page is a Nucleo document, so it does not print its own title and main.

Parameters: None

Permissions: none.

Edition: Free

Known limits:

  • The main font is preloaded with the HTTP Link header, only if the headers have not been sent yet.
  • The runtime does not rebuild a document with a missing _nucleo_rt: it serves the post_content as it is.
  • The eager scripts are enqueued with defer in the footer. Handles of styles and scripts: nucleo-<md5 of the URL, 8 characters>.

Slot filling

What it does: in the_content it replaces the slot markers of the requested post with the HTML generated for the request. It uses strpos, without regular expressions. Then it marks the current menu item.

How to use it: automatic. Recognized slot blocks: nc/post-title, nc/post-content, nc/post-image, nc/post-meta, nc/breadcrumbs, nc/search, nc/pagination, nc/archive-title, nc/archive-description, nc/visibility, nc/bind, nc/form, nc/collection, nc/native-form, nc/repeater, nc/query, the woo/* blocks and the legacy names post.title and post.date. With a single layout over a Nucleo page, nc/post-content also fills the slots of the page: forms, collections and bound fields.

Parameters: None

Permissions: none.

Edition: Free

Pro

The woo/* blocks exist only in the Pro package.

Known limits:

  • Slot with an unknown block or a missing index: the fallback stays.
  • Missing closing marker: Nucleo removes only the opening marker.
  • Only nc/visibility and nc/bind are filled again after rendering, up to 8 levels of nesting.
  • The filter acts only on the post of the main query.

Visitor visibility

What it does: evaluates visibility.when on every request. It shows the node only if all the conditions are true.

Condition (is)True when
logged_inthe user is logged in
logged_outthe user is not logged in
role:<slug>the user has the given role
filledthe field of the source has a value; for source nucleo, also a repeater with at least one row
emptythe opposite of filled

How to use it: in the document. See the chapter Document schema and blocks.

Parameters: see the table.

Permissions: none.

Edition: Free

Known limits: unknown condition: false. Page cache and crawlers see the empty fallback.

Loading of block scripts

What it does: loads the block scripts with the strategy of the manifest. eager goes into a <script defer> tag. The visible, interaction and idle strategies go through the scripts loader, using window.ncLazy. Every URL gets ?ver= with the plugin version, like the scripts enqueued by WordPress: after an update the browser does not use the cached copy. If the URL already has a ver parameter, Nucleo does not add ?ver=: a parameter with a different name, such as server, does not count. For the scripts with interaction or idle, the paragraph below the table also applies.

StrategyWhen the script starts
eagerright away, with defer
visibleany .nc-<block> element enters the viewport, with a 200 px margin
interactionfirst pointerdown, focusin or keydown on any .nc-<block> element; after loading it repeats the click on the touched button only if the real click arrived before the script
idlerequestIdleCallback, or after 200 ms

The manifest scripts with strategy interaction or idle are written as type="text/plain" tags with data-nc-src and data-nc-load. The loader activates all of them together, in document order: interaction on the first pointerdown, keydown, scroll or touchstart on the window; idle with requestIdleCallback and a 2 s timeout, or after 2 s without it. The table rows describe the entries registered in window.ncLazy.

How to use it: automatic. Strategies of the included blocks: nc/collection, nc/slider and nc/toc use visible; nc/menu and nc/tabs use idle; nc/native-form and nc/video use interaction.

Parameters: None

Permissions: none.

Edition: Free

Known limits: visible and interaction observe every instance of the block on the page; the script loads once, at the first signal. Without IntersectionObserver, the visible script starts right away. Each src loads only once, even if the page and the layout both list it.

Current menu item

What it does: adds aria-current="page" and the class is-current to the link of the current item of the nc/menu menus, and is-ancestor to the ancestor items. It is needed because the compiled HTML is the same for all pages.

How to use it: automatic on content and areas. It first compares the requested object (post:<id> or term:<id>). If no item matches, it compares the URL.

Parameters: None

Permissions: none.

Edition: Free

Known limits: when comparing by URL it ignores the trailing slash and the utm_* parameters. A # link is never current.

Emergency mode

What it does: turns off the whole runtime: no Nucleo assets, layouts or slots. wpautop and wptexturize stay active.

How to use it: define the constant NUCLEO_SAFE_MODE as true in wp-config.php, or set the option nucleo_safe_mode to a true value.

Parameters: None

Permissions: access to wp-config.php or to the database.

Edition: Free

Known limits: the option is read from alloptions.

Lists and cards

What it does: draws the cards of nc/query and nc/collection for each item. The render loop keeps the stack of the current items: post, term or data row. nc/collection updates filters and pages with the REST route GET nucleo/v1/collection/<doc>/<node>.

How to use it: see the chapter Modules, dynamic data, components, bindings and media.

Parameters: filter query string; append=1 to append the results.

Permissions: public route (__return_true). It serves only published documents without a password.

Edition: Free

Known limits:

  • 60 requests per minute per IP, then a 429 error.
  • Response with Cache-Control: public, max-age=60.
  • Result pages in transients for 12 hours (5 minutes for a component source without ttl), invalidated by nucleo_content_version.
  • An active text search does not use the cache.

Asset rules and optimized CSS

What it does: on wp_enqueue_scripts at priority 9999 it applies the asset rules, the reduced CSS variants and the critical CSS. Administrators (manage_options) see the previews with ?nucleo_css=original|candidate|critical|published.

How to use it: see the chapter Optimizer and assets.

Parameters: see the linked chapter.

Permissions: nucleo_css preview: manage_options.

Edition: see the linked chapter.

Known limits: see the linked chapter.

06Public hooks

nucleo/document_saved

What it does: action emitted after each successful write of a document, including after a rebuild.

How to use it:

add_action('nucleo/document_saved', function (int $postId): void { ... });

Parameters:

NameTypeAllowed valuesDefaultNotes
$postIdintpost ID—Post just written

Permissions: none.

Edition: Free

Known limits: Nucleo itself uses it to publish the layouts and to rebuild the pages of a section. During the callback the internal write flag is true.

nucleo/purge_url

What it does: action emitted after the cache of a non-layout document is emptied. Use it to connect a cache system that Nucleo does not support.

How to use it:

add_action('nucleo/purge_url', function (string $url): void { ... });

Parameters:

NameTypeAllowed valuesDefaultNotes
$urlstringpermalink—Not emitted if the post has no permalink

Permissions: none.

Edition: Free

Known limits: none found.

nucleo/purge_all

What it does: action emitted after the whole cache is emptied, that is after the save of a layout.

How to use it:

add_action('nucleo/purge_all', function (): void { ... });

Parameters: None

Permissions: none.

Edition: Free

Known limits: none found.

nucleo/current_language

What it does: filter that replaces the current language used to choose the layouts with a language condition.

How to use it:

add_filter('nucleo/current_language', fn (?string $lang): ?string => 'it');

Parameters:

NameTypeAllowed valuesDefaultNotes
$languagestring or nulllanguage sluglanguage of Polylang or WPML, or nullReturn an empty string or null for no language

Permissions: none.

Edition: Pro. The filter exists only in the Pro package.

Known limits: see the chapter Integrations.

07Layouts

Layout documents and areas

What it does: a layout is a document with kind layout (or popup) in the nucleo_layout post type. meta.area says where it goes. meta.conditions says on which requests it applies. The runtime uses only the published layouts.

AreaApplies to the requests
header, footerall
before-content, after-contentsingle content and archives (term, post type, author, posts page)
singlesingle content
archivearchives of term, post type, author and the posts page
searchsearch results
notfound404 page
productsingle products, only with WooCommerce active
product-archivethe shop archive and the product category or tag archives, only with WooCommerce active
popupall (Pro only, see Popup)

How to use it: create the layout with nucleo/doc-create and postType nucleo_layout. The theme prints each area with nucleo_canvas_area('<area>'). See the chapter Theme.

Parameters: meta.area (string), meta.conditions (object).

Permissions: the nucleo_layout type requires edit_theme_options to create, edit and delete.

Edition: Free

Known limits:

  • The schema does not validate meta.area. An area not in the list is saved, but the runtime does not print it.
  • A layout without meta.area: excluded from the map.
  • Date archives and other unrecognized requests (kind other) receive only header, footer and popup.
  • Layouts receive tokens and assets also on pages not built with Nucleo.

Layout conditions

What it does: meta.conditions has the form {"include": [...], "exclude": [...], "priority": 0}. Each condition is {"type": "<type>", ...keys of the type}.

TypeKeysSelectsKey in the map
entire_site—every requestsite
front—the home pagefront
blog—the posts pageblog
search—search resultssearch
404—the page not found404
postvalue (ID)a single content itempost:<id>
parentvalue (ID)the descendant pages of a page, not the page itselfpost:<id> for each descendant
post_typevalue (slug)every single content item of the typetype:<type>
archivevalue (slug)the archive of a post type or of all the terms of a taxonomyarchive:<slug>
authorvalue (user ID)the single content items of the authorauthor:<id>
author_archivevalue (user ID)the archive of the authorauthor_archive:<id>
termtaxonomy, value (ID), optional childrenthe single content items with the termterm:<taxonomy>:<id>
term_archivetaxonomy, value (ID), optional childrenthe archive of the termterm_archive:<taxonomy>:<id>
languagevalue (language code)limits the layout to one language; does not select requests by itselfnone

How to use it: in the document of the layout, or with nucleo/layout-conditions-set, which replaces include, exclude and priority. In the site files (layouts/*.json) the IDs are written as symbols (page:<path>, term:<taxonomy>/<slug>, author:<login>). See the chapter Import, export and sync.

Parameters:

NameTypeAllowed valuesDefaultNotes
includelistconditions—Required
excludelistconditions[]A layout excluded by any key of the request does not apply
priorityintinteger0The higher wins when the keys are equal
childrenbooltrue, falsefalseAdds the child terms

Permissions: nucleo/layout-conditions-set: edit_post on the layout, scope nucleo:design.

Edition: Free.

Pro

The language context exists only in the Pro package, with Polylang, WPML or the nucleo/current_language filter.

Known limits:

  • Format errors with code layout_condition: unknown type, unknown key, missing key, wrong value type. Each error carries the example of the expected format.
  • IDs: integers ≥ 1. A numeric string ("12") becomes an integer.
  • The save blocks only new or changed conditions. A layout saved earlier with invalid conditions can still be edited and rebuilt.
  • A layout with only language conditions does not apply to any request.
  • Without a language context (Free, or no multilingual plugin) a layout limited to one language applies to all.
  • parent finds descendants with get_pages() on the page type.

Layout map

What it does: turns the conditions of all the published layouts into the layouts artifact.

  • map: area → key → entries [id, priority, languages], sorted by descending priority, then descending ID.
  • exclude: area → key → excluded IDs.
  • conflicts: keys with two or more layouts at the highest priority, which can apply in the same language.

It also writes the layout-<id> artifact with the HTML, runtime and popup settings of each published layout.

How to use it: automatic when a published layout is saved or rebuilt, when it stops being published and when it is deleted. Conflicts are read with nucleo/layout-list.

Parameters: None

Permissions: none.

Edition: Free

Known limits: the parent and children conditions become explicit keys when the map is rebuilt. A child page or a child term created later enters the map only at the next rebuild. To force it: save the layout again, or use nucleo/cache-rebuild.

Layout choice for the request

What it does: for each area it builds the request keys from the most specific to the most general. It returns the first layout found that is not excluded and that speaks the language of the request.

RequestKeys tried in order
Single contentfront (home page only), post:<id>, term:<taxonomy>:<id> for each term, author:<id>, type:<type>, site
Term archiveterm_archive:<taxonomy>:<id>, archive:<taxonomy>, site
Post type archivearchive:<type>, site
Author archiveauthor_archive:<id>, site
Search, 404, posts pagesearch, 404 or blog, then site
Other requestssite

How to use it: automatic on every request. For a URL, nucleo/layout-explain returns for each area {layout, matched}, and excluded with the discarded layout and the key that excluded it.

Parameters: None

Permissions: nucleo/layout-explain: edit_theme_options, scope nucleo:read.

Edition: Free

Known limits:

  • The specificity of the key counts before the priority. A post:<id> layout with priority 0 wins over a site layout with priority 100.
  • For a content item with several terms, the first term that has a layout wins, in the order of the taxonomies and terms returned by WordPress.
  • The resolution runs no queries of its own: it uses the terms already cached by the main query.
Pro

The popup exists only in the Pro package.

What it does: a layout in the popup area becomes a <dialog class="nc-popup"> with a close button. The first heading of the content labels the dialog. Without a heading, the dialog uses the title of the layout. The popup script handles opening and frequency.

How to use it: a kind popup document with meta.area popup in the nucleo_layout type.

Parameters:

NameTypeAllowed valuesDefaultNotes
meta.trigger.typestringload, delay, scroll, exit, clickdelayValue not in the list: delay
meta.trigger.valuescalartext5Becomes data-value
meta.frequencystringonce, session, alwayssessionValue not in the list: session

Permissions: as for the layouts.

Edition: Pro.

Known limits: in the Free package a published popup is not printed, but the runtime still enqueues its styles and scripts.

08Reusable sections

Block nc/section-ref

What it does: inserts a reusable section (a kind section document, type nucleo_section) by slug. On save and on each rebuild Nucleo replaces the node with the root of the section and applies the parameters.

How to use it:

{ "id": "cta1", "type": "nc/section-ref",
  "settings": { "section": "cta-contatti", "params": { "titolo": "Parliamone" } } }

List of the sections and their parameters: nucleo/section-list.

Parameters:

NameTypeAllowed valuesDefaultNotes
settings.sectionstring^[a-z0-9][a-z0-9_-]{0,199}$—Required. Slug of the section
settings.paramsobjectname → value{}Values of the parameters declared by the section

Permissions: the nucleo_section type requires edit_theme_options to create, edit and delete. Sections in draft, pending, private or scheduled status expand only for users with edit_theme_options, and without a user (WP-Cron, WP-CLI). Other users expand only published sections.

Edition: Free

Known limits:

  • Maximum depth of nested sections: 4.
  • A cycle (A inside B inside A) is an error on the outer nc/section-ref node.
  • Missing section or section in the trash: the block prints nothing and the report has the notice content.section.missing.
  • The visibility of the nc/section-ref node passes to the expanded root.
  • The IDs of the expanded nodes change for each instance: the first 4 letters of the ref node ID plus 8 characters of hash.
  • The block accepts visibility but no style key.
  • A new section receives its slug on creation, even as a draft.

Section parameters

What it does: the section declares in params the values that each nc/section-ref can pass. Each declaration has a type, and optional label, required and default.

TypeAllowed value
text, html, linkstring
colorstring that starts with $color.
booleantrue or false
imageobject with a string src and an optional string alt
listlist of strings, at most 30 items

How to use it: inside the section, the values are used in three ways.

  • bind with "source": "param": {"content.text": {"source": "param", "field": "titolo"}}. Allowed keys: content.*, settings.*, style.*, visible. field accepts a sub-field (immagine.alt). An image without a sub-field gives the src.
  • bind.repeat on a child: one copy of the node for each item of a list parameter. In the copy, the item acts as the item parameter.
  • $param.<name> in a style value, also inside a compound value (1px solid $param.colore). Only color parameters.

Parameters: parameter name: ^[a-z][a-z0-9_]{0,31}$.

Permissions: as for the sections.

Edition: Free

Known limits:

  • Order of the values: passed value, then default, then null.
  • A required parameter with no value and no default: error on the page that uses the section. In the section document alone it is not an error.
  • visible removes the node if the value is false. For text, html, link, image it removes it also if the value is empty or missing.
  • Without a value and without fallback, the bind keeps the value written in the node, which acts as a placeholder.
  • An unresolved $param: the style property stays out.
  • Errors: undeclared parameter, wrong type, repeat on a parameter that is not list, repeat or visible on the root of the section, param bind outside a section.

Error position in sections

What it does: reports the validation and quality errors of the expanded nodes on the nc/section-ref node of the document. This way the agent corrects the document it wrote.

How to use it: automatic.

Parameters: None

Permissions: none.

Edition: Free

Known limits:

  • Value coming from a parameter: the path becomes .../settings/params/<name>.
  • Other errors: the path becomes .../settings/section and the message starts with inside section: .
  • A style error loses the hint with the internal IDs.
  • In the quality report the message ends with (inside a reusable section).
  • Identical errors on the same path appear once.

Update of the pages that use a section

What it does: when a section is saved, changes slug or goes to the trash, Nucleo rebuilds the documents that use it. It finds them with the dependencies section:<id> and section-slug:<slug>. The second one also finds the documents that cited the section when it was still missing.

How to use it: automatic.

Parameters: None

Permissions: none.

Edition: Free

Known limits: the first 10 documents rebuild in the same request. The others go to the WP-Cron queue. If the section makes a document invalid or blocking, the published page keeps the previous version.

Historical ref reference

What it does: a node with the ref field "section:<id>" becomes the root of the indicated document during normalization. The internal IDs receive the prefix g<id>.

How to use it: format prior to nc/section-ref. For new documents use nc/section-ref.

Parameters: ref (string, section:<id>).

Permissions: none.

Edition: Free

Known limits: the referenced document does not follow other ref values. Inside a reusable section, ref is an error. Inside an expanded section the node disappears without an error.

Esc
↑↓ to select↵ to openEsc to closeLocal search, no data sent