Hooks

Hooks: Templates and Rendering

6 min read

These hooks cover Notifal templates (the visual designs notifications use): admin UI, HTML Builder, Elementor widgets, preview routes, import/export, and frontend HTML processing including class placeholders.

Index: Hook Reference Hub. Architecture: Architecture Overview.

Template lifecycle (actions)

HookParametersDescription
notifal/template/createdint $template_idNew template created via admin
notifal/template/duplicatedint $original_id, int $new_idTemplate duplicated
notifal/template/trashedint $template_idTemplate moved to trash
notifal/template/deletedint $template_id, string $statusTemplate permanently deleted
notifal/template/trash_emptiedint[] $deleted_idsTemplate trash emptied
notifal/post/duplicatedint $newPostId, int $originalPostId, string $postTypeGeneric post duplication (templates and notifications)

Template creation UI (actions)

HookParametersDescription
notifal/template/creation/beforebool $is_modalBefore template creation view
notifal/template/creation/afterbool $is_modalAfter template creation view
notifal/admin_page/templates/beforenoneBefore Templates admin page
notifal/admin_page/templates/afternoneAfter Templates admin page

Template preview (actions and filters)

HookTypeParametersDescription
notifal/template/preview/beforeactionWP_Post $postBefore iframe template preview
notifal/template/preview/afteractionWP_Post $postAfter iframe template preview
notifal/template/preview/outputfilterstring $content, WP_Post $postFinal preview HTML

Template queries and AJAX (actions and filters)

HookTypeParametersDescription
notifal/templates/queried_by_builderactionstring $builder, WP_Post[] $templatesAfter templates fetched by builder type
notifal/templates/load_more/beforeactionnoneBefore AJAX load-more
notifal/templates/load_more/afteractionnoneAfter AJAX load-more
notifal/templates/filter/beforeactionnoneBefore AJAX template filter
notifal/templates/filter/afteractionnoneAfter AJAX template filter
notifal/templates/load_more/responsefilterarray $responseLoad-more AJAX response payload
notifal/templates/filter/responsefilterarray $responseFilter AJAX response payload
notifal/templates/builder/countfilterint $count, string $builderCount by builder before return
notifal/templates/total_countfilterint $totalTotal template count
notifal/templates/builder/query_argsfilterarray $args, string $builderQuery args for builder count
notifal/templates/builder/meta_queryfilterarray $metaQuery, string $builderMeta query for builder queries

Template titles (filters)

HookParametersDescription
notifal/template/default_titlestring $titleDefault title for new templates
notifal/template/final_titlestring $title, int $post_idFinal title after creation

Import and export (filters)

HookParametersDescription
notifal/export/template_dataarray $dataExport JSON before download
notifal/template/import/resultarray $result, string $filePathImport result after processing
notifal/template/import/post_statusstring $status, array $template_dataPost status for imported template (default publish)

HTML Builder (actions and filters)

HookTypeParametersDescription
notifal/template/html_builder/assets/beforeactionnoneBefore HTML Builder admin assets
notifal/template/html_builder/assets/afteractionnoneAfter HTML Builder admin assets
notifal/template/html_builder/save/beforeactionint $templateId, string $title, string $htmlBefore AJAX save
notifal/template/html_builder/savedactionint $templateIdAfter successful AJAX save
notifal/template/html/sanitize/beforefilterstring $htmlRaw HTML before sanitization
notifal/template/html/sanitize/afterfilterstring $html, string[] $warningsSanitized HTML and warnings
notifal/template/html/kses/allowedfilterarray $allowedAllowed tags for restricted saves
notifal/template/html_builder/widgetsfilterarray $widgetsHTML Builder widget palette definitions and AI snippets
notifal/template/html_builder/use_casesfilterarray $optionsAI prompt use case options for JS
notifal/template/html_builder/display_layoutsfilterarray $optionsAI prompt layout options for JS
notifal/template/html_builder/ai_prompt_examplesfilterarray $examplesAI field-filling pattern examples
notifal/template/html_builder/primary_colorfilterstring $colorDefault brand color for HTML Builder AI

Use FilterHooks::TEMPLATE_HTML_BUILDER_WIDGETS for widget registration. Each row requires id, label, category, category_label, icon, description, default_html, and ai_snippet.

Complete example: Cookbook: Register a Custom HTML Builder Widget.

Elementor integration (actions and filters)

HookTypeParametersDescription
notifal/elementor/widgets/registeredactionnoneAfter all Notifal Elementor widgets registered
notifal/elementor/widget/{slug}/beforeaction\Elementor\Widget_Base $widgetBefore widget render (dynamic slug)
notifal/elementor/widget/{slug}/afteraction\Elementor\Widget_Base $widgetAfter widget render (dynamic slug)
notifal/elementor/random_product/datafilterarray $dataProduct data before ProductImageWidget render

Use sprintf(ActionHooks::ELEMENTOR_WIDGET_RENDER_BEFORE, $widget_slug) for dynamic hook names.

Frontend rendering (actions and filters)

HookTypeParametersDescription
notifal/template_renderer/shortcode_contextactionWP_Post $templateShortcode/bootstrap context for REST/AJAX render
notifal/onpage/template/class_placeholders/beforefilterstring $html, array $frontendContextHTML before class-placeholder processing
notifal/onpage/template/class_placeholders/afterfilterstring $html, array $frontendContextHTML after class-placeholder processing

Class placeholders power features like analytics click tracking classes on custom elements. See Analytics and Tracking (notifal/onpage/analytics/track_click_class).

Templates admin assets (actions)

HookParametersDescription
notifal/templates/admin/assets/beforenoneBefore templates admin assets enqueue
notifal/templates/admin/assets/afternoneAfter templates admin assets enqueue

WooCommerce product data (filter)

Used when templates resolve random or pool-based product tags.

HookParametersDescription
notifal/woocommerce/product/randomarray $productsRandom WooCommerce product fetch result

Product DTO and tag hooks: Tags and Dynamic Data.

Image size options (filter)

HookParametersDescription
notifal/image_size/dropdown_optionsarray $optionsImage size dropdown in admin

Hooks series

  1. Hook Reference Hub
  2. Hooks: Lifecycle and Bootstrap
  3. Hooks: Notifications and Eligibility
  4. Hooks: Templates and Rendering (you are here)
  5. Hooks: Tags and Dynamic Data
  6. Hooks: Display Rules and Content Source
  7. Hooks: Analytics and Tracking
  8. Hooks: Admin UI Extension
  9. Hooks: Pro Integration Bridge