From 89d2e815137c20ec52751342b98b643b608ab8ca Mon Sep 17 00:00:00 2001 From: Ajay D'Souza Date: Fri, 26 Jan 2024 13:26:39 +0530 Subject: [PATCH] New filter `tptn_before_update_count` Use the filter to check if the counts should be updated in the database or ignored. --- includes/class-tracker.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/includes/class-tracker.php b/includes/class-tracker.php index 0b35b96..984489e 100644 --- a/includes/class-tracker.php +++ b/includes/class-tracker.php @@ -273,7 +273,19 @@ public static function update_count( $id, $blog_id, $activate_counter ) { $table_name_daily = Helpers::get_tptn_table( true ); $str = ''; - if ( $id > 0 ) { + /** + * Filter the flag to confirm that counts should be updated in the database. + * + * @since 3.4.0 + * + * @param bool $flag Flag to confirm that counts should be updated in the database. + * @param int $id Post ID. + * @param int $blog_id Blog ID. + * @param int $activate_counter Activate counter flag. + */ + $before_update_count = apply_filters( 'tptn_before_update_count', true, $id, $blog_id, $activate_counter ); + + if ( $id > 0 && $before_update_count ) { if ( ( 1 === $activate_counter ) || ( 11 === $activate_counter ) ) {