filter
Filter the analytics data before it is returned.
Parameters of davo_post_view_analytics Parameter Type Description $analytics array<string, mixed> Analytics payload. $post_id int Post ID. $days int Period in days.
add_filter Copyadd_filter ( 'davo_post_view_analytics' , 'my_filter_callback' , 10 , 3 );
/**
* @param array<string, mixed> $analytics
* @param int $post_id
* @param int $days
*/
function my_filter_callback ( $analytics , $post_id , $days ) {
// Change $analytics as needed, then return it.
return $analytics ;
}src/domains/post-views/repository.php:328
filter
Filter the view counts before they are returned.
Parameters of davo_post_view_counts Parameter Type Description $counts array<string, mixed> Normalized counts data. $post_id int Post ID.
add_filter Copyadd_filter ( 'davo_post_view_counts' , 'my_filter_callback' , 10 , 2 );
/**
* @param array<string, mixed> $counts
* @param int $post_id
*/
function my_filter_callback ( $counts , $post_id ) {
// Change $counts as needed, then return it.
return $counts ;
}src/domains/post-views/repository.php:234
action
Fires after a view is successfully recorded.
Parameters of davo_post_view_tracked Parameter Type Description $post_id int Post ID. $user_id int User ID (0 = guest). $visitor_hash string Visitor identity hash. $is_unique bool Whether this is the visitor's first view.
add_action Copyadd_action ( 'davo_post_view_tracked' , 'my_action_callback' , 10 , 4 );
/**
* @param int $post_id
* @param int $user_id
* @param string $visitor_hash
* @param bool $is_unique
*/
function my_action_callback ( $post_id , $user_id , $visitor_hash , $is_unique ) {
// Your code here.
}src/domains/post-views/repository.php:206
action
Fires after the batch aggregation job completes.
Parameters of davo_post_views_aggregated Parameter Type Description $processed int Number of view records processed. $posts int Number of distinct posts updated. $post_ids int[] IDs of the posts whose counts were just recounted in this batch — listeners that mirror total_views elsewhere (e.g. the Questions domain's trending-score meta) use this to resync only what actually changed, instead of a full custom-table scan.
add_action Copyadd_action ( 'davo_post_views_aggregated' , 'my_action_callback' , 10 , 3 );
/**
* @param int $processed
* @param int $posts
* @param int[] $post_ids
*/
function my_action_callback ( $processed , $posts , $post_ids ) {
// Your code here.
}src/domains/post-views/repository.php:411
filter
Filters the window, in seconds, in which repeat views of a post by the same visitor are not counted again. Defaults to 1800 (30 minutes).
Parameters of davo_post_views_dedup_window Parameter Type Description $window int Window in seconds. $post_id int The viewed post's ID. $user_id int The viewer's user ID.
Returns int
add_filter Copyadd_filter ( 'davo_post_views_dedup_window' , 'my_filter_callback' , 10 , 3 );
/**
* @param int $window
* @param int $post_id
* @param int $user_id
*/
function my_filter_callback ( $window , $post_id , $user_id ) {
// Change $window as needed, then return it.
return $window ;
}src/domains/post-views/repository.php:128
action
Fires after all view data for a post has been permanently deleted.
Parameters of davo_post_views_deleted_for_post Parameter Type Description $post_id int Post ID.
add_action Copyadd_action ( 'davo_post_views_deleted_for_post' , 'my_action_callback' , 10 , 1 );
/**
* @param int $post_id
*/
function my_action_callback ( $post_id ) {
// Your code here.
}src/domains/post-views/repository.php:544
action
Fires after a migration import wrote view counts for posts.
Domains that mirror a post's total views elsewhere (post meta, the search index's popularity score) resync from it. Writing the counts directly skips the live view-tracking hooks that normally keep those mirrors current.
Parameters of davo_post_views_imported Parameter Type Description $post_ids int[] Destination post IDs whose counts were just imported.
add_action Copyadd_action ( 'davo_post_views_imported' , 'my_action_callback' , 10 , 1 );
/**
* @param int[] $post_ids
*/
function my_action_callback ( $post_ids ) {
// Your code here.
}src/domains/post-views/migration-provider.php:265
filter
Filter whether a user agent is classified as a bot.
Parameters of davo_post_views_is_bot Parameter Type Description $is_bot bool Current classification result. $user_agent string User-Agent string.
add_filter Copyadd_filter ( 'davo_post_views_is_bot' , 'my_filter_callback' , 10 , 2 );
/**
* @param bool $is_bot
* @param string $user_agent
*/
function my_filter_callback ( $is_bot , $user_agent ) {
// Change $is_bot as needed, then return it.
return $is_bot ;
}src/domains/post-views/repository.php:751
filter
Filter whether the current view should be counted despite deduplication. Return true to force-count, false to force-skip.
Parameters of davo_post_views_is_duplicate Parameter Type Description $is_duplicate bool Whether a duplicate was detected. $post_id int Post being viewed. $user_id int Current user (0 = guest). $visitor_hash string Visitor identity hash.
add_filter Copyadd_filter ( 'davo_post_views_is_duplicate' , 'my_filter_callback' , 10 , 4 );
/**
* @param bool $is_duplicate
* @param int $post_id
* @param int $user_id
* @param string $visitor_hash
*/
function my_filter_callback ( $is_duplicate , $post_id , $user_id , $visitor_hash ) {
// Change $is_duplicate as needed, then return it.
return $is_duplicate ;
}src/domains/post-views/repository.php:146
filter
Filters how many days post view logs are kept before the daily housekeeping removes them. Defaults to 90.
Parameters of davo_post_views_log_retention_days Parameter Type Description $days int Retention in days.
Returns int
add_filter Copyadd_filter ( 'davo_post_views_log_retention_days' , 'my_filter_callback' , 10 , 1 );
/**
* @param int $days
*/
function my_filter_callback ( $days ) {
// Change $days as needed, then return it.
return $days ;
}src/domains/post-views/initializer.php:180
filter
Filter the post types that are tracked for views.
Parameters of davo_post_views_supported_post_types Parameter Type Description $post_types string[] Array of post type slugs.
add_filter Copyadd_filter ( 'davo_post_views_supported_post_types' , 'my_filter_callback' , 10 , 1 );
/**
* @param string[] $post_types
*/
function my_filter_callback ( $post_types ) {
// Change $post_types as needed, then return it.
return $post_types ;
}src/domains/post-views/repository.php:58