Re is out: see what's new Lifetime updates on every purchase Support replies within 24 hours Secure checkout via Gumroad 8,500+ sales since 2016

↑↓ Navigate ↵ Open Esc Close

All products
Re:Maily contact form builder is now available on WordPress.org See it live

Hooks

Updated 4 min read 15 views

Every hook Forma has, by area. Hooks are filters unless marked as an action, and the first argument is the value you return. Pass the number of arguments your function takes as the last argument of add_filter():

// forma_item_classes gets $classes, $item, $config
add_filter( 'forma_item_classes', function ( $classes, $item, $config ) {
	$classes[] = 'my-item';

	return $classes;
}, 10, 3 );

Worked examples are in Extend Forma → Recipes.

Layouts and their settings

HookArgumentsUse it to
forma_config_defaults$defaultsAdd an add-on’s own layout settings with their defaults
forma_config$config, $rawChange a layout’s settings after they are checked; read an add-on’s own from $raw
forma_config_upgrades$stepsConvert an add-on’s stored settings for the next Config::VERSION
forma_select_options$optionsAdd options to a built-in select, by config path
forma_controls$sectionsAdd sections and fields to the editor; each skin’s settings.php is in it as skin_{id}
forma_image_controls$fieldsAdd fields to each image of a Media Library source
forma_layouts_styles$typesRegister a theme layout type (layouts/{id}/layout.php)
forma_layouts$layoutsAdd or remove layout type objects (LayoutInterface)
forma_metro_patterns / forma_freeform_patterns$patternsAdd Metro and Freeform patterns
forma_image_ratios$ratiosChange the list of image ratios
forma_animations$presetsAdd entrance animations
forma_breakpoints$breakpointsChange the device widths in code
forma_shortcode_config$config, $attsChange a layout’s settings for one shortcode
forma_preview_config$config, $post_idChange the settings the editor’s preview uses

Content and the query

HookArgumentsUse it to
forma_sources$sourcesRegister a content source (SourceInterface)
forma_include_sources / forma_exclude_sources$idsKeep or hide sources in the editor; * is a wildcard
forma_source_taxonomies$taxonomies, $source_idChange the taxonomies a source can filter by
forma_orderby_options$optionsAdd an Order by choice
forma_query_args$query_args, $query, $args, $source_idChange the WP_Query of a posts or Media source
forma_pre_fetchnull, $query_args, $query, $argsReturn the items yourself and skip the query
forma_terms_args$term_args, $query, $argsChange the get_terms() of a terms source
forma_term_image_id$image_id, $termGive a term its image in a terms grid
forma_filter_terms_args$args, $configChange which terms the filter lists

Items and markup

HookArgumentsUse it to
forma_item_data$item, $config, $sourceAdd to or change the data a skin gets
forma_item_image$html, $item, $configChange an item’s <img>
forma_image_size$size, $configChange the image size of a layout
forma_item_classes$classes, $item, $configAdd classes to an item’s cell
forma_item_click[ $item, $attributes, $lightbox ], $configChange what clicking an item does
forma_item_append$html, $item, $configPrint something at the end of each item
forma_cells$cells, $number, $configPut cells of your own before item $number
forma_container_attributes$attributes, $configAdd attributes or classes to the grid
forma_layout_css$css, $config, $scope, $breakpointsAdd CSS for one layout
forma_empty_message$message, $configChange the text shown when nothing matches
forma_filter_html / forma_search_html / forma_sort_html / forma_pagination_html$html, …, $configChange a control’s finished markup
forma_pagination_types$typesAdd a pagination type
forma_pagination_more$data, $config, $endedChange the data of the Load More button
forma_initial_term / forma_initial_sort / forma_initial_page$value, $configStart a grid on a filter, order or page
forma_filter_url$url, $term, $configChange the address of a filter link

Templates, styles and assets

HookArgumentsUse it to
forma_template$found, $relativeServe a template from your plugin: return [ path, url ] for a path such as skins/my-card/skin.php
forma_template_vars$vars, $relativePass more variables to a template
forma_icon$svg, $name, $classChange an icon
forma_{kind}_styles$stylesRegister a style; kinds are skins, filters, search, sort, pagination, layouts
forma_include_styles / forma_exclude_styles$ids, $kindKeep or hide styles in the editor; * is a wildcard
forma_built_in_styles$styles, $kindChange the built-in styles of a kind
forma_default_styles$load, $kind, $idReturn false to drop Forma’s own CSS, for all or one style
forma_enqueue (action)$configLoad your own files on pages that show a grid
forma_assets$assetsChange Forma’s registered scripts and styles
HookArgumentsUse it to
forma_lightbox_enabled$enabledTurn the lightbox on or off in code
forma_lightbox_meta$lines, $image_idAdd lines under a photo’s caption
forma_lightbox_media$attributes, $group, $url, $kind, $caption, $poster_idPlay a video or audio URL in the lightbox
forma_editor_data$dataPass data to the editor’s scripts (window.formaEditor)
forma_css_classes$classesChange the class list under Custom CSS
forma_preview_classes$classes, $configAdd classes to the preview page
forma_summary_badges$badges, $configAdd badges to a layout’s row on the Forma Layouts screen
forma_duplicate_meta$keysCopy more post meta when a layout is duplicated
forma_settings_sections$sectionsAdd sections and fields to Forma → Settings
forma_docs_url / forma_support_url$urlPoint the help links elsewhere

Editor JavaScript filters

The editor’s JavaScript filters, with wp.hooks.addFilter: forma.field (any built-in field, by config path), forma.panels (the sidebar sections), forma.layouts (layout types’ editor parts), forma.previewData and forma.resetMeta.

Was this article helpful?