Skip to main content

Snippets — functions

3 public functions. 1 are 🔌 pluggable (function_exists()-guarded, so a theme/child can override them).

FunctionSummary
fw_ext_snippets_editor_noteExplain an empty snippet render — in an editor only.
fw_ext_snippets_renderRender a snippet's page-builder content by ID.
fw_ext_snippets_unwrap_auto_sectionsStrip the [section auto_generated="true"]…[/section] wrappers that the page-builder's items-corrector inserts around root-level rows/columns/simple items when the snippet author didn't explicitly drop a Section item.

fw_ext_snippets_editor_note

🔌 pluggable

fw_ext_snippets_editor_note( $snippet_id )

Explain an empty snippet render — in an editor only.

fw_ext_snippets_render() returns '' for four different reasons: no snippet chosen, the recursion guard, a post that no longer exists, and one that is not published. On the front end that silence is right. In a Gutenberg block every one of them becomes the same "Block rendered as empty", which reads as a bug rather than as a thing to go and fix.

The unpublished case is the one worth naming: a snippet moved back to draft disappears from every page that places it, with nothing anywhere saying why.

ParameterTypeDescription
$snippet_idintThe chosen snippet, 0 when none is chosen.

Returns string HTML, or '' outside an editor.

Source: framework/extensions/snippets/helpers.php:105

fw_ext_snippets_render

fw_ext_snippets_render( $snippet_id )

Render a snippet's page-builder content by ID.

Returns '' for invalid IDs, missing/non-published snippets, or re-entrant calls (a snippet referencing itself directly or through a cycle).

ParameterTypeDescription
$snippet_idint

Returns string

Source: framework/extensions/snippets/helpers.php:14

fw_ext_snippets_unwrap_auto_sections

fw_ext_snippets_unwrap_auto_sections( $shortcodes )

Strip the [section auto_generated="true"]…[/section] wrappers that the page-builder's items-corrector inserts around root-level rows/columns/simple items when the snippet author didn't explicitly drop a Section item.

Without this, embedding a snippet inside a page that already has its own Section produces invalid nested <section><div class="container"> markup. Sections authored explicitly by the user have no auto_generated attribute and are preserved.

ParameterTypeDescription
$shortcodesstring

Returns string

Source: framework/extensions/snippets/helpers.php:75

← Back to Functions overview