Temper
Menu

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#

ActionArgumentsWhen
temper_loadedNoneTemper has loaded, on plugins_loaded at priority 5. Register add-ons here.
temper_enqueuestring $view: editor, projects or settingsTemper's editor script is queued on a Temper screen. Queue your scripts with temper as a dependency.
temper_setting_changedstring $keyA secret setting, such as an API key or token, was saved or removed.

Filters#

Access#

FilterArgumentsReturns
temper_can_usebool $allowedWhether the current user may use Temper. Applies to screens, REST routes, previews and MCP keys. See Permissions.
temper_featuresstring[] $featuresFeature names an add-on provides. Temper Pro adds github, build, composer, mcp, mcp-publish, history, tabs, starters and license.
temper_feature_allowedbool $allowed, string $featureWhether 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_passwordsbool $allowWhether 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_hostsbool $allow, string $hostWhether the built-in AI may call a local, private or reserved address. Default false, or true with TEMPER_AI_ALLOW_PRIVATE.
temper_pro_urlstring $urlWhere "About Temper Pro" links go. Default https://temperwp.com/#pricing.

Settings#

FilterArgumentsReturns
temper_settings_defaultsarray $defaultsExtra settings, with defaults, stored in Temper's temper_settings option. Temper's own keys always win.
temper_secret_settingsstring[] $keysSetting keys to encrypt at rest and never send to the browser. ai_key is always one.
temper_sanitize_settingstring $value (already sanitize_text_field), string $key, mixed $rawThe value to store for an add-on's setting.
temper_settings_viewarray $viewThe settings sent to the browser. Secrets appear only as has_<key>.
temper_settings_pagearray $viewThe data for the Settings page.

Editor and projects#

FilterArgumentsReturns
temper_statearray $stateThe editor's state for the open project: files, changes, snapshots, activity and more.
temper_projectsarray $projectsThe data for Themes & Plugins: themes, plugins, selected, open and more.
temper_import_sourcenull $handled, string $source, array $ctxHandles 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#

FilterArgumentsReturns
temper_publish_checksarray $checks: changes, errors, previewedWhat the publish dialog shows before publishing.
temper_publish_blockernull|WP_Error $blockerA 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_publisharray $extra, string $message, WP_REST_Request $requestExtra 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#

FilterArgumentsReturns
temper_mcp_toolsarray $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_infoarray $infoExtra fields for get_theme_info.

Updates and licence#

FilterArgumentsReturns
temper_update_serverstring $urlWhere Temper checks for updates. Default https://temperwp.com, or TEMPER_UPDATE_SERVER.
temper_update_public_keystring $key (base64)The key update answers must be signed with.
temper_pro_license_server Prostring $urlThe licence server. Default https://temperwp.com, or TEMPER_PRO_LICENSE_SERVER.
temper_pro_license_public_key Prostring $key (base64)The key licence answers must be signed with.
temper_pro_account_url Prostring $urlThe account link in the Licence tab.
temper_github_client_id Prostring $client_idThe GitHub OAuth app used by Connect GitHub. It must have Device Flow turned on.

Examples#

Hold publishing back#

PHP
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#

PHP
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.

HookArgumentsWhat it adds
temper.toolbarItemsitems, ctxElements in the toolbar
temper.sideTabstabs, propsTabs in the side panel: { id, label, after, count, dot, render( props ) }
temper.statusItemsitems, ctxElements in the status bar
temper.settingsTabstabs, { settings }Settings tabs: { name, title, order, render( props ) }. Temper's tabs are at order 10 (Appearance), 30 (AI) and 40 (AI tools).
temper.publishSectionssections, { theme }Checks and options in the publish dialog
temper.publishNotice{ message, type }, response, wordsThe message after publishing
temper.modalelement, modal, ctxA dialog opened with ctx.setModal( { type } )
temper.importSourcesource, typeFields for an import source
temper.saved (action)path, state, ctxA file was saved

ctx holds the editor state (data) and refresh, reloadClean, afterExternalChange, notify, openFile, setModal, hasDirty and bumpPreview.