Skip to content

Actions and filters

History: 5 hooks.

Every hook here has a description in the source.

2 actions3 filters

filter

davo_history_can_view

Filters whether a viewer may see the history timeline of an object. Defaults to false, so a domain must allow it.

Parameters of davo_history_can_view
ParameterTypeDescription
$can_viewboolWhether the viewer may see it.
$object_typestringKind of object the history belongs to.
$object_idintObject ID.
$viewer_idintViewing user ID, or 0 for a guest.

Returns bool

add_filter
add_filter( 'davo_history_can_view', 'my_filter_callback', 10, 4 );

/**
 * @param bool $can_view
 * @param string $object_type
 * @param int $object_id
 * @param int $viewer_id
 */
function my_filter_callback( $can_view, $object_type, $object_id, $viewer_id ) {
	// Change $can_view as needed, then return it.
	return $can_view;
}

src/domains/history/routes.php:228

filter

davo_history_mask_author

Filters whether an author is hidden in the history timeline of an object. Defaults to false.

Parameters of davo_history_mask_author
ParameterTypeDescription
$maskboolWhether to hide the author.
$object_typestringKind of object the history belongs to.
$object_idintObject ID.
$user_idintThe author's user ID.

Returns bool

add_filter
add_filter( 'davo_history_mask_author', 'my_filter_callback', 10, 4 );

/**
 * @param bool $mask
 * @param string $object_type
 * @param int $object_id
 * @param int $user_id
 */
function my_filter_callback( $mask, $object_type, $object_id, $user_id ) {
	// Change $mask as needed, then return it.
	return $mask;
}

src/domains/history/routes.php:152

filter

davo_history_migration_object_namespace

Filter the reference namespace a history object_type resolves against during migration, for an object_type this provider doesn't specifically recognize ('question'/'answer' are handled directly).

Parameters of davo_history_migration_object_namespace
ParameterTypeDescription
$namespacestringDefault namespace (wp_post).
$object_typestringThe unrecognized object_type value.
add_filter
add_filter( 'davo_history_migration_object_namespace', 'my_filter_callback', 10, 2 );

/**
 * @param string $namespace
 * @param string $object_type
 */
function my_filter_callback( $namespace, $object_type ) {
	// Change $namespace as needed, then return it.
	return $namespace;
}

src/domains/history/migration-provider.php:573

action

davo_history_recorded

Fires after a new history revision has been fully recorded.

Parameters of davo_history_recorded
ParameterTypeDescription
$revision_idintNew revision ID.
$object_typestringRegistered object type slug.
$object_idintObject's post/entity ID.
$user_idintActing user ID.
$diffsarrayfield_key => { change_type, payload } for every field that changed.
add_action
add_action( 'davo_history_recorded', 'my_action_callback', 10, 5 );

/**
 * @param int $revision_id
 * @param string $object_type
 * @param int $object_id
 * @param int $user_id
 * @param array $diffs
 */
function my_action_callback( $revision_id, $object_type, $object_id, $user_id, $diffs ) {
	// Your code here.
}

src/domains/history/services/recorder.php:118

action

davo_register_history_fields

Fires once at init (priority 5) so every domain can register its trackable object types and fields before anything reads the registry. See History_Registry::register_object_type()/register_field().

Parameters of davo_register_history_fields
ParameterTypeDescription
$registryHistory_RegistryShared registry instance.
add_action
add_action( 'davo_register_history_fields', 'my_action_callback', 10, 1 );

/**
 * @param History_Registry $registry
 */
function my_action_callback( $registry ) {
	// Your code here.
}

src/domains/history/initializer.php:108

Note. Generated from the plugin source. Descriptions and parameters are the ones written in the code. The starter code uses the parameter names from those comments, or generic names where there are none, so check them against your use.

See it on your own site.

Davo is a WordPress theme and plugin by Exorex.

  • Runs on your own WordPress
  • Guided setup wizard
  • AI is off until you switch it on
  • Read the licence on the marketplace first