Skip to main content

Other Extensions — functions

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

FunctionSummary
fw_tpl_lib__fetch_jsonGET a URL and json_decode it. Returns array|WP_Error.
fw_tpl_lib__read_envelope_jsonRead an export-envelope file and return its inner json string if valid for the given kind, else ''. Used for both bundled and installed templates.
fw_tpl_lib__rrmdirRecursively delete a directory (temp + uninstall).
fw_tpl_lib__validate_envelopeValidate a downloaded/bundled export envelope: it must be an _fw_template_export for the page-builder of the expected kind, whose inner json decodes to a non-empty builder tree.
fw_tpl_lib_allowed_kindsThe template kinds the builder's predefined lists accept.
fw_tpl_lib_builder_payloadThe full data the in-builder panel renders: library items (with the builder tree attached for insertable ones), the user's saved templates, categories, and catalog availability.
fw_tpl_lib_bundled_catalogThe bundled catalog: reads templates/catalog.json shipped in the extension (same shape as the remote catalog's templates map, minus base_url — the thumb path is resolved against the bundled folder URI). Cached per request.
fw_tpl_lib_bundled_dirAbsolute path of the bundled-templates folder shipped in the extension.
fw_tpl_lib_bundled_uriPublic URI of the bundled-templates folder (for thumbnails).
fw_tpl_lib_catalogFetch + decode the remote catalog, cached in a transient (12h). Returns a normalized array, or an empty shape on failure (cached briefly so a flaky network doesn't retry on every page load).
fw_tpl_lib_catalog_urlURL of the catalog.json describing installable templates. Filterable.
fw_tpl_lib_feed_predefinedFilter callback: append this library's templates of $kind to the builder's predefined list.
fw_tpl_lib_installDownload one template envelope from the catalog into the uploads install dir. Atomic: writes into a temp dir, then renames into place.
fw_tpl_lib_install_dirAbsolute path of the uploads install dir (no trailing slash). Filterable.
fw_tpl_lib_installed_metaDecoded meta.json for one installed template, or null.
fw_tpl_lib_installed_slugsSlugs of templates installed under uploads (a dir with template.json + meta.json).
fw_tpl_lib_installer_categoriesDistinct category names across the current item list (sorted).
fw_tpl_lib_installer_itemsFlat list the admin grid renders, one entry per template: { slug, title, category, kind, description, thumb, state: 'bundled'|'installed'|'available' }
fw_tpl_lib_installer_payloadEverything the admin grid JS needs, localized as upwTemplateLibrary.
fw_tpl_lib_registered_templatesAll templates to register, keyed slug => { title, kind, json }. Bundled first, then installed (installed wins on a slug clash). Cached per request.
fw_tpl_lib_uninstallRemove an installed template. Bundled templates have no uploads dir, so this is a no-op error for them.
fw_tpl_lib_user_templatesThe current user's own saved page-builder templates, scanned straight from the wp_options rows the builder writes (one per saved template, keyed by a documented prefix per kind). Predefined/library templates are NOT stored as options, so this returns only user-saved ones — exactly the "My Templates" set. The heavy json body is fetched lazily on insert via the builder's own load endpoint, so this stays light.

fw_tpl_lib__fetch_json

🔌 pluggable

fw_tpl_lib__fetch_json( $url )

GET a URL and json_decode it. Returns array|WP_Error.

Source: framework/extensions/template-library/includes/installer.php:300

fw_tpl_lib__read_envelope_json

🔌 pluggable

fw_tpl_lib__read_envelope_json( $file, $kind )

Read an export-envelope file and return its inner json string if valid for the given kind, else ''. Used for both bundled and installed templates.

Source: framework/extensions/template-library/includes/predefined-templates.php:74

fw_tpl_lib__rrmdir

🔌 pluggable

fw_tpl_lib__rrmdir( $dir )

Recursively delete a directory (temp + uninstall).

Source: framework/extensions/template-library/includes/installer.php:317

fw_tpl_lib__validate_envelope

🔌 pluggable

fw_tpl_lib__validate_envelope( $envelope, $kind )

Validate a downloaded/bundled export envelope: it must be an _fw_template_export for the page-builder of the expected kind, whose inner json decodes to a non-empty builder tree.

ParameterTypeDescription
$envelopearrayDecoded envelope.
$kindstringExpected kind (section|column|full).

Returns true\|WP_Error

Source: framework/extensions/template-library/includes/installer.php:275

fw_tpl_lib_allowed_kinds

🔌 pluggable

fw_tpl_lib_allowed_kinds()

The template kinds the builder's predefined lists accept.

Source: framework/extensions/template-library/includes/installer.php:51

fw_tpl_lib_builder_payload

🔌 pluggable

fw_tpl_lib_builder_payload()

The full data the in-builder panel renders: library items (with the builder tree attached for insertable ones), the user's saved templates, categories, and catalog availability.

Source: framework/extensions/template-library/includes/builder-panel.php:75

fw_tpl_lib_bundled_catalog

🔌 pluggable

fw_tpl_lib_bundled_catalog()

The bundled catalog: reads templates/catalog.json shipped in the extension (same shape as the remote catalog's templates map, minus base_url — the thumb path is resolved against the bundled folder URI). Cached per request.

Returns array slug => { slug, title, category, kind, description, thumb }

Source: framework/extensions/template-library/includes/predefined-templates.php:30

fw_tpl_lib_bundled_dir

🔌 pluggable

fw_tpl_lib_bundled_dir()

Absolute path of the bundled-templates folder shipped in the extension.

Source: framework/extensions/template-library/includes/installer.php:35

fw_tpl_lib_bundled_uri

🔌 pluggable

fw_tpl_lib_bundled_uri()

Public URI of the bundled-templates folder (for thumbnails).

Source: framework/extensions/template-library/includes/installer.php:43

fw_tpl_lib_catalog

🔌 pluggable

fw_tpl_lib_catalog( $force = false )

Fetch + decode the remote catalog, cached in a transient (12h). Returns a normalized array, or an empty shape on failure (cached briefly so a flaky network doesn't retry on every page load).

ParameterTypeDescription
$forceboolBypass the transient (explicit "refresh").

Returns array { version:int, base_url:string, templates:{ slug => {...} } }

Source: framework/extensions/template-library/includes/installer.php:80

fw_tpl_lib_catalog_url

🔌 pluggable

fw_tpl_lib_catalog_url()

URL of the catalog.json describing installable templates. Filterable.

Source: framework/extensions/template-library/includes/installer.php:62

fw_tpl_lib_feed_predefined

🔌 pluggable

fw_tpl_lib_feed_predefined( $templates, $kind )

Filter callback: append this library's templates of $kind to the builder's predefined list.

ParameterTypeDescription
$templatesarrayExisting predefined templates (id => {title, json}).
$kindstringsection|column|full

Returns array

Source: framework/extensions/template-library/includes/predefined-templates.php:128

fw_tpl_lib_install

🔌 pluggable

fw_tpl_lib_install( $slug )

Download one template envelope from the catalog into the uploads install dir. Atomic: writes into a temp dir, then renames into place.

ParameterTypeDescription
$slugstring

Returns true\|WP_Error

Source: framework/extensions/template-library/includes/installer.php:180

fw_tpl_lib_install_dir

🔌 pluggable

fw_tpl_lib_install_dir()

Absolute path of the uploads install dir (no trailing slash). Filterable.

Source: framework/extensions/template-library/includes/installer.php:27

fw_tpl_lib_installed_meta

🔌 pluggable

fw_tpl_lib_installed_meta( $slug )

Decoded meta.json for one installed template, or null.

Source: framework/extensions/template-library/includes/installer.php:159

fw_tpl_lib_installed_slugs

🔌 pluggable

fw_tpl_lib_installed_slugs()

Slugs of templates installed under uploads (a dir with template.json + meta.json).

Source: framework/extensions/template-library/includes/installer.php:141

fw_tpl_lib_installer_categories

🔌 pluggable

fw_tpl_lib_installer_categories( $items = null )

Distinct category names across the current item list (sorted).

Source: framework/extensions/template-library/includes/installer.php:400

fw_tpl_lib_installer_items

🔌 pluggable

fw_tpl_lib_installer_items()

Flat list the admin grid renders, one entry per template: { slug, title, category, kind, description, thumb, state: 'bundled'|'installed'|'available' }

Bundled templates (shipped in the extension) are always present and can't be removed. Installed templates were downloaded and can be removed. Catalog entries not present locally are available to install.

Source: framework/extensions/template-library/includes/installer.php:340

fw_tpl_lib_installer_payload

🔌 pluggable

fw_tpl_lib_installer_payload()

Everything the admin grid JS needs, localized as upwTemplateLibrary.

Source: framework/extensions/template-library/includes/installer.php:414

fw_tpl_lib_registered_templates

🔌 pluggable

fw_tpl_lib_registered_templates()

All templates to register, keyed slug => { title, kind, json }. Bundled first, then installed (installed wins on a slug clash). Cached per request.

Source: framework/extensions/template-library/includes/predefined-templates.php:87

fw_tpl_lib_uninstall

🔌 pluggable

fw_tpl_lib_uninstall( $slug )

Remove an installed template. Bundled templates have no uploads dir, so this is a no-op error for them.

ParameterTypeDescription
$slugstring

Returns true\|WP_Error

Source: framework/extensions/template-library/includes/installer.php:250

fw_tpl_lib_user_templates

🔌 pluggable

fw_tpl_lib_user_templates()

The current user's own saved page-builder templates, scanned straight from the wp_options rows the builder writes (one per saved template, keyed by a documented prefix per kind). Predefined/library templates are NOT stored as options, so this returns only user-saved ones — exactly the "My Templates" set. The heavy json body is fetched lazily on insert via the builder's own load endpoint, so this stays light.

Returns array list of { id, title, kind, created }

Source: framework/extensions/template-library/includes/builder-panel.php:29

← Back to Functions overview