Skip to content

Developer Reference

Voxel Toolkit exposes hooks for extending or reacting to its behaviour. All hooks are namespaced under voxel_toolkit/.

Filters

Registries

Use these to add your own features to the Voxel Toolkit screens.

FilterModifies
voxel_toolkit/available_functionsThe function registry shown under Functions
voxel_toolkit/available_widgetsThe widget registry shown under Widgets
voxel_toolkit/available_post_fieldsThe post field registry shown under Post Fields
php
add_filter( 'voxel_toolkit/available_functions', function ( $functions ) {
	$functions['my_function'] = array(
		'name'        => __( 'My Function', 'my-plugin' ),
		'description' => __( 'What it does.', 'my-plugin' ),
		'class'       => 'My_Function_Class',
		'file'        => 'functions/class-my-function.php',
	);

	return $functions;
} );

Behaviour

FilterPurpose
voxel_toolkit/sanitize_function_settings/{function_key}Sanitise a function's settings before they're saved
voxel_toolkit/should_redirect_postOverride whether the Redirect Posts function redirects a given post
voxel_toolkit/auto_share/preview_imageChange the preview image used in an auto-shared timeline post
voxel_toolkit/auto_share/fallback_imageChange the fallback image when a post has none
voxel_toolkit/ai_autofill/settingsFilter AI Autofill's settings
voxel_toolkit/ai_autofill/storeFilter the data AI Autofill writes to the draft
voxel_toolkit/ai_autofill/embeddedControl AI Autofill's embedded mode

Actions

ActionFires when
voxel_toolkit/settings_updatedPlugin settings are saved
voxel_toolkit/function_initialized/{function_key}A function is initialised
voxel_toolkit/function_deinitialized/{function_key}A function is torn down
voxel_toolkit/post_auto_verifiedAuto Verify Posts marks a post verified
voxel_toolkit/post_status_changedA post's status changes through a toolkit feature
voxel_toolkit/term_addedAdd Category creates a term from the front end
voxel_toolkit/term_pending_approvalA front-end term is created awaiting approval
voxel_toolkit/term_approvedA pending term is approved
voxel_toolkit/checklist/item_checkedA Checklist (VT) item is ticked
voxel_toolkit/settings_page_footerRendering the footer of a settings screen

Checking state in code

Voxel_Toolkit_Settings is the source of truth for whether a feature is on:

php
if ( Voxel_Toolkit_Settings::instance()->is_function_enabled( 'auto_verify_posts' ) ) {
	// The function is active.
}

Voxel_Toolkit_Functions exposes the registries:

php
$functions = Voxel_Toolkit_Functions::instance();

$functions->get_available_functions();  // everything registered
$functions->get_active_functions();     // only what's enabled
$functions->is_function_active( 'ai_bot' );

Constants

ConstantValue
VOXEL_TOOLKIT_VERSIONCurrent plugin version
VOXEL_TOOLKIT_PLUGIN_DIRAbsolute path to the plugin directory
VOXEL_TOOLKIT_PLUGIN_URLURL to the plugin directory
VOXEL_TOOLKIT_PLUGIN_FILEAbsolute path to the main plugin file

Adding a custom post field

Post field files declare two classes — a manager that handles hooks and AJAX, and the field type itself extending \Voxel\Post_Types\Fields\Base_Post_Field. Register the field type with Voxel early, through the voxel/field-types filter, and gate it on the toolkit setting:

php
add_filter( 'voxel/field-types', function ( $fields ) {
	if ( ! Voxel_Toolkit_Settings::instance()->is_function_enabled( 'post_field_my_field' ) ) {
		return $fields;
	}

	if ( ! class_exists( '\Voxel\Post_Types\Fields\Base_Post_Field' ) ) {
		return $fields;
	}

	$fields['my-field'] = '\My_Field_Type';

	return $fields;
} );

Always load the field file unconditionally and only initialise the manager when the field is enabled — that keeps the class available to Voxel while respecting the toggle.

Built by Code Wattz.