Hooks for developers
The temper_* filters and actions, the editor's temper.* JavaScript hooks, and examples.
On this page
Temper's extension points are WordPress filters and actions named temper_*, and temper.* filters in the editor through wp.hooks. Temper Pro is built on the same hooks.
Add-ons should register in the temper_loaded action, and check \Temper\Extend::API (currently 1) before relying on a hook, so an add-on can say so on an older Temper instead of failing.
Tip
Put code that changes Temper in a must-use plugin or a plugin you don't edit with Temper, so a broken working copy can't switch it off.
Actions#
| Action | Arguments | When |
|---|---|---|
temper_loaded | None | Temper has loaded, on plugins_loaded at priority 5. Register add-ons here. |
temper_enqueue | string $view: editor, projects or settings | Temper's editor script is queued on a Temper screen. Queue your scripts with temper as a dependency. |
temper_setting_changed | string $key | A secret setting, such as an API key or token, was saved or removed. |
Filters#
Access#
| Filter | Arguments | Returns |
|---|---|---|
temper_can_use | bool $allowed | Whether the current user may use Temper. Applies to screens, REST routes, previews and MCP keys. See Permissions. |
temper_features | string[] $features | Feature names an add-on provides. Temper Pro adds github, build, composer, mcp, mcp-publish, history, tabs, starters and license. |
temper_feature_allowed | bool $allowed, string $feature | Whether a provided feature may be used right now, for example false while a licence is inactive. Data a feature made stays either way. |
temper_allow_application_passwords | bool $allow | Whether Temper's REST routes accept WordPress application passwords. Default false: connect tools with an MCP key instead, so the review hold and publish permission apply. |
temper_ai_allow_private_hosts | bool $allow, string $host | Whether the built-in AI may call a local, private or reserved address. Default false, or true with TEMPER_AI_ALLOW_PRIVATE. |
temper_pro_url | string $url | Where "About Temper Pro" links go. Default https://temperwp.com/#pricing. |
Settings#
| Filter | Arguments | Returns |
|---|---|---|
temper_settings_defaults | array $defaults | Extra settings, with defaults, stored in Temper's temper_settings option. Temper's own keys always win. |
temper_secret_settings | string[] $keys | Setting keys to encrypt at rest and never send to the browser. ai_key is always one. |
temper_sanitize_setting | string $value (already sanitize_text_field), string $key, mixed $raw | The value to store for an add-on's setting. |
temper_settings_view | array $view | The settings sent to the browser. Secrets appear only as has_<key>. |
temper_settings_page | array $view | The data for the Settings page. |
Editor and projects#
| Filter | Arguments | Returns |
|---|---|---|
temper_state | array $state | The editor's state for the open project: files, changes, snapshots, activity and more. |
temper_projects | array $projects | The data for Themes & Plugins: themes, plugins, selected, open and more. |
temper_import_source | null $handled, string $source, array $ctx | Handles an import source Temper doesn't know. $ctx has in (the request), kind (theme or plugin), tmp (a folder to download into) and spec. Return null to pass, a WP_Error, or an array with root (the folder holding the theme or plugin) and optionally slug, fallback, notes, state and after. |
Publishing#
| Filter | Arguments | Returns |
|---|---|---|
temper_publish_checks | array $checks: changes, errors, previewed | What the publish dialog shows before publishing. |
temper_publish_blocker | null|WP_Error $blocker | A WP_Error to stop the publish with its message, or what you were given. Runs after the save checks, for every publish, from the editor or an AI assistant. |
temper_after_publish | array $extra, string $message, WP_REST_Request $request | Extra data to return from a publish made in the editor. Runs only when the publish went through, so anything you record matches what went live. |
MCP Pro#
| Filter | Arguments | Returns |
|---|---|---|
temper_mcp_tools | array $tools, array $hints (ro, rw, del: annotation sets) | Extra tools, keyed by name. Each has title, description, schema (JSON Schema for its input), annotations and run (a callable that takes the arguments array). A name Temper already uses is ignored. |
temper_mcp_info | array $info | Extra fields for get_theme_info. |
Updates and licence#
| Filter | Arguments | Returns |
|---|---|---|
temper_update_server | string $url | Where Temper checks for updates. Default https://temperwp.com, or TEMPER_UPDATE_SERVER. |
temper_update_public_key | string $key (base64) | The key update answers must be signed with. |
temper_pro_license_server Pro | string $url | The licence server. Default https://temperwp.com, or TEMPER_PRO_LICENSE_SERVER. |
temper_pro_license_public_key Pro | string $key (base64) | The key licence answers must be signed with. |
temper_pro_account_url Pro | string $url | The account link in the Licence tab. |
temper_github_client_id Pro | string $client_id | The GitHub OAuth app used by Connect GitHub. It must have Device Flow turned on. |
Examples#
Hold publishing back#
add_action( 'temper_loaded', function () {
add_filter( 'temper_publish_blocker', function ( $blocker ) {
if ( is_wp_error( $blocker ) ) {
return $blocker;
}
if ( get_option( 'my_code_freeze' ) ) {
return new WP_Error( 'my_code_freeze', 'Publishing is paused during the code freeze.', array( 'status' => 409 ) );
}
return $blocker;
} );
} );Add an MCP tool Pro#
add_filter( 'temper_mcp_tools', function ( $tools, $hints ) {
$tools['count_posts'] = array(
'title' => 'Count posts',
'description' => 'How many published posts the site has.',
'schema' => array( 'type' => 'object', 'properties' => new stdClass() ),
'annotations' => $hints['ro'],
'run' => function ( array $args ) {
return (string) wp_count_posts()->publish;
},
);
return $tools;
}, 10, 2 );run can return a string, an array (sent as JSON) or a WP_Error (sent as an error the assistant can read). Use $hints['ro'] for tools that only read: a tool marked as changing things holds the preview for review after it runs.
Editor hooks (JavaScript)#
The editor exposes shared helpers and components on window.temper.core, and calls these wp.hooks filters. Add-on scripts load after Temper's and before the editor first renders.
| Hook | Arguments | What it adds |
|---|---|---|
temper.toolbarItems | items, ctx | Elements in the toolbar |
temper.sideTabs | tabs, props | Tabs in the side panel: { id, label, after, count, dot, render( props ) } |
temper.statusItems | items, ctx | Elements in the status bar |
temper.settingsTabs | tabs, { settings } | Settings tabs: { name, title, order, render( props ) }. Temper's tabs are at order 10 (Appearance), 30 (AI) and 40 (AI tools). |
temper.publishSections | sections, { theme } | Checks and options in the publish dialog |
temper.publishNotice | { message, type }, response, words | The message after publishing |
temper.modal | element, modal, ctx | A dialog opened with ctx.setModal( { type } ) |
temper.importSource | source, type | Fields for an import source |
temper.saved (action) | path, state, ctx | A file was saved |
ctx holds the editor state (data) and refresh, reloadClean, afterExternalChange, notify, openFile, setModal, hasDirty and bumpPreview.