From bca6fd7649e827f011b4e6befe70d08ab797591c Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Fri, 10 Jan 2025 06:40:04 -0600 Subject: [PATCH] Comments: Update counts when (de)activating the plugin (#1128) --- CHANGELOG.md | 1 + includes/class-activitypub.php | 9 +++++++++ readme.txt | 1 + 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10c67ff83..40f85087e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +* Comment counts get updated when the plugin is activated/deactivated/deleted * Added a filter to make custom comment types manageable in WP.com Calypso ### Changed diff --git a/includes/class-activitypub.php b/includes/class-activitypub.php index bf94e303c..b63c1ae33 100644 --- a/includes/class-activitypub.php +++ b/includes/class-activitypub.php @@ -62,6 +62,9 @@ public static function init() { public static function activate() { self::flush_rewrite_rules(); Scheduler::register_schedules(); + + \add_filter( 'pre_wp_update_comment_count_now', array( Comment::class, 'pre_wp_update_comment_count_now' ), 10, 3 ); + Migration::update_comment_counts(); } /** @@ -70,6 +73,9 @@ public static function activate() { public static function deactivate() { self::flush_rewrite_rules(); Scheduler::deregister_schedules(); + + \remove_filter( 'pre_wp_update_comment_count_now', array( Comment::class, 'pre_wp_update_comment_count_now' ) ); + Migration::update_comment_counts( 2000 ); } /** @@ -77,6 +83,9 @@ public static function deactivate() { */ public static function uninstall() { Scheduler::deregister_schedules(); + + \remove_filter( 'pre_wp_update_comment_count_now', array( Comment::class, 'pre_wp_update_comment_count_now' ) ); + Migration::update_comment_counts( 2000 ); } /** diff --git a/readme.txt b/readme.txt index e47085bc2..f16c10315 100644 --- a/readme.txt +++ b/readme.txt @@ -134,6 +134,7 @@ For reasons of data protection, it is not possible to see the followers of other = Unreleased = +* Added: Comment counts get updated when the plugin is activated/deactivated/deleted * Added: A filter to make custom comment types manageable in WP.com Calypso * Changed: Hide ActivityPub post meta keys from the custom Fields UI * Changed: Bumped minimum required PHP version to 7.2