Compiler, runtime, layouts and sections
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.
Converts the menu slugs of nc/menu ("principale" or "menu:principale") to the menu ID.
Normalizes the layout conditions. Numeric IDs sent as strings become integers. Validates only the new or changed conditions.
Normalizes the document (migrations, block defaults) and expands the nc/section-ref nodes.
Resolves the reference links (page:<slug>, term:<taxonomy>/<slug>, home) to URLs.
Validates the schema. Errors inside a section point to the nc/section-ref node of the document.
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).
With dryRun it stops here and returns the report.
Compiles the expanded document.
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:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
publish | bool | true, false | false | Sets post_status to publish. |
dryRun | bool | true, false | false | Validates and checks quality without writing. |
acknowledge | list | {rule, node, reason} | [] | Acknowledges quality issues. |
baseRevision | int or null | integer | null | If different from the current revision: conflict error. |
title | string | text | '' | Post title. Empty: the current title stays. |
postType | string | post type | page | Only on creation. |
slug | string | slug | '' | Only on creation. Empty: WordPress takes it from the title. |
parent | int or null | 0 or ID | null | null 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(onlystart). - 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-refnodes and the symbolic links. The expansion is used only to validate and compile. - The rules
seo.h1.missing,a11y.landmark.missingandseo.content.thindo not apply to layouts, sections and popups. For sections,content.button.inertandform.action.consequentialdo 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>_budgetchanges 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/textblocks. Bold, italics and links remain. - Images and other elements are lost in the document.
existserror 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 thedepsof 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: exceptionDocument has no root. - Block type not registered: exception
Block type not registered. - A node with the old
reffield 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/queryandnc/collectionblocks 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/visibilityfor a node with a non-emptyvisibility.when. Empty fallback.nc/bindfor 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.
Link references
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:
| Form | Example | Target |
|---|---|---|
home | home#contatti | home_url('/') |
<post-type>:<slug> | page:chi-siamo, post:novita | published content of the type |
<post-type>:<path> | page:servizi/consulenza | hierarchical types only |
term:<taxonomy>/<slug> | term:category/notizie | term; 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 noticecontent.link.pathwith 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_stalemeta. - Blocking problems on a published post: the page keeps the previous version. The problems go to the
_nucleo_stale_qualitymeta. - 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_rebuildcallback 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/statusexposes it infailed. - 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 event | Dependency searched | Execution |
|---|---|---|
nucleo/document_saved on a section | section:<id>, section-slug:<slug> | first 10 right away, the rest queued |
post_updated with a changed section slug | old and new slug | first 10 right away |
| Section moved to the trash or restored | section:<id>, section-slug:<slug> | first 10 right away |
wp_update_nav_menu, wp_update_nav_menu_item | menu:<id> | queued |
Publication or withdrawal of a post; public meta or _thumbnail_id and terms of a published post | query:<type> | queued |
| Change of slug or parent, publication, withdrawal of a content item | link:post:<id>, link-slug:<type>:<slug> (descendants too) | queued; after the save if the write is from Nucleo |
deleted_post | link:post:<id> | queued |
created_term, edited_term, delete_term | link:term:<id> (children too), link-slug:term:<taxonomy>/<slug> | queued |
blogname, blogdescription, site_logo, customize_save_after | site, bind:site:name, bind:site:description, bind:site:logo, bind:site:url | queued |
post_updated with a changed title, excerpt, date or author | the post itself, if it has a bind:post: or bind:author: dependency | immediate rebuild |
profile_update | posts of the user with a bind:author: dependency | queued |
permalink_structure | all documents | queued |
WPLANG, date_format, time_format | all documents; increments nucleo_content_version | queued |
added_post_meta, updated_post_meta, deleted_post_meta read by a binding | every dependency ending with :<key>; _thumbnail_id looks for bind:post:image | immediate 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_formatandtime_formatonly if they still have the default format of the previous language. - Changes to the tokens do not rebuild the pages: Nucleo republishes the
tokensartifact 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.
| Meta | Content | Read by the frontend |
|---|---|---|
_nucleo_doc | raw JSON document, with nc/section-ref and symbolic links | no (only in writing, from the layout publisher) |
_nucleo_rev | revision number, +1 on each save | no |
_nucleo_hist | history of the last 20 versions {rev, doc, time, user} | no |
_nucleo_rt | runtime: cssFile, cssUrl, styles, eager, lazy, slots, lcp, breadcrumbBlock, seo (only with meta.seo) | yes |
_nucleo_dep | dependencies, one row per value | no |
_nucleo_links | targets of the resolved links (link:post:<id>, link:term:<id>) | no |
_nucleo_ack | quality acknowledgements still valid, with the node fingerprint | no |
_nucleo_stale, _nucleo_stale_quality | errors of the last failed rebuild | no |
_nucleo_wp_content | original WordPress text of an attached content | no |
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.
| Data | Location |
|---|---|
| Compiled HTML | post_content of the post (written without kses filters) |
| Instance CSS of pages, layouts and sections | uploads/nucleo/css/p-<id>.<hash8>.css |
| CSS of all the blocks | uploads/nucleo/css/blocks.<hash8>.css |
| Tokens | tokens artifact, printed inline with the handle nucleo-tokens |
| Layout map | layouts artifact (map, exclude, conflicts) |
| Published layout | layout-<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:
- loads the CSS preview only if the
nucleo_cssparameter is present; - stops in emergency mode;
- prepares the layout areas;
- attaches the asset rules to
wp_enqueue_scriptswith priority 9999; - on a single content with
_nucleo_rt: registers the SEO meta and JSON-LD, removeswpautopandwptexturize, 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
Linkheader, only if the headers have not been sent yet. - The runtime does not rebuild a document with a missing
_nucleo_rt: it serves thepost_contentas it is. - The
eagerscripts are enqueued withdeferin 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
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/visibilityandnc/bindare 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_in | the user is logged in |
logged_out | the user is not logged in |
role:<slug> | the user has the given role |
filled | the field of the source has a value; for source nucleo, also a repeater with at least one row |
empty | the 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.
| Strategy | When the script starts |
|---|---|
eager | right away, with defer |
visible | any .nc-<block> element enters the viewport, with a 200 px margin |
interaction | first 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 |
idle | requestIdleCallback, 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
componentsource withoutttl), invalidated bynucleo_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:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
$postId | int | post 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:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
$url | string | permalink | — | 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:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
$language | string or null | language slug | language of Polylang or WPML, or null | Return 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.
| Area | Applies to the requests |
|---|---|
header, footer | all |
before-content, after-content | single content and archives (term, post type, author, posts page) |
single | single content |
archive | archives of term, post type, author and the posts page |
search | search results |
notfound | 404 page |
product | single products, only with WooCommerce active |
product-archive | the shop archive and the product category or tag archives, only with WooCommerce active |
popup | all (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 (
kindother) receive onlyheader,footerandpopup. - 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}.
| Type | Keys | Selects | Key in the map |
|---|---|---|---|
entire_site | — | every request | site |
front | — | the home page | front |
blog | — | the posts page | blog |
search | — | search results | search |
404 | — | the page not found | 404 |
post | value (ID) | a single content item | post:<id> |
parent | value (ID) | the descendant pages of a page, not the page itself | post:<id> for each descendant |
post_type | value (slug) | every single content item of the type | type:<type> |
archive | value (slug) | the archive of a post type or of all the terms of a taxonomy | archive:<slug> |
author | value (user ID) | the single content items of the author | author:<id> |
author_archive | value (user ID) | the archive of the author | author_archive:<id> |
term | taxonomy, value (ID), optional children | the single content items with the term | term:<taxonomy>:<id> |
term_archive | taxonomy, value (ID), optional children | the archive of the term | term_archive:<taxonomy>:<id> |
language | value (language code) | limits the layout to one language; does not select requests by itself | none |
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:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
include | list | conditions | — | Required |
exclude | list | conditions | [] | A layout excluded by any key of the request does not apply |
priority | int | integer | 0 | The higher wins when the keys are equal |
children | bool | true, false | false | Adds the child terms |
Permissions: nucleo/layout-conditions-set: edit_post on the layout, scope nucleo:design.
Edition: Free.
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
languageconditions does not apply to any request. - Without a language context (Free, or no multilingual plugin) a layout limited to one language applies to all.
parentfinds descendants withget_pages()on thepagetype.
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.
| Request | Keys tried in order |
|---|---|
| Single content | front (home page only), post:<id>, term:<taxonomy>:<id> for each term, author:<id>, type:<type>, site |
| Term archive | term_archive:<taxonomy>:<id>, archive:<taxonomy>, site |
| Post type archive | archive:<type>, site |
| Author archive | author_archive:<id>, site |
| Search, 404, posts page | search, 404 or blog, then site |
| Other requests | site |
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 asitelayout 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.
Popup
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:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
meta.trigger.type | string | load, delay, scroll, exit, click | delay | Value not in the list: delay |
meta.trigger.value | scalar | text | 5 | Becomes data-value |
meta.frequency | string | once, session, always | session | Value 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:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
settings.section | string | ^[a-z0-9][a-z0-9_-]{0,199}$ | — | Required. Slug of the section |
settings.params | object | name → 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-refnode. - Missing section or section in the trash: the block prints nothing and the report has the notice
content.section.missing. - The
visibilityof thenc/section-refnode passes to the expandedroot. - 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
visibilitybut 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.
| Type | Allowed value |
|---|---|
text, html, link | string |
color | string that starts with $color. |
boolean | true or false |
image | object with a string src and an optional string alt |
list | list of strings, at most 30 items |
How to use it: inside the section, the values are used in three ways.
bindwith"source": "param":{"content.text": {"source": "param", "field": "titolo"}}. Allowed keys:content.*,settings.*,style.*,visible.fieldaccepts a sub-field (immagine.alt). An image without a sub-field gives thesrc.bind.repeaton a child: one copy of the node for each item of alistparameter. In the copy, the item acts as theitemparameter.$param.<name>in astylevalue, also inside a compound value (1px solid $param.colore). Onlycolorparameters.
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, thennull. - A
requiredparameter with no value and no default: error on the page that uses the section. In the section document alone it is not an error. visibleremoves the node if the value isfalse. Fortext,html,link,imageit 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,
repeaton a parameter that is notlist,repeatorvisibleon therootof the section,parambind 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/sectionand the message starts withinside 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.
Was this page helpful?