Skip to content

Commit

Permalink
Merge pull request #169 from soup-bowl/168-logserviceprune_logs-remov…
Browse files Browse the repository at this point in the history
…es-old-posts-from-custom-post-type

Verify post type before executing delete
  • Loading branch information
soup-bowl authored Jul 21, 2024
2 parents b6a6573 + 13a0838 commit 4bb86da
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/log/class-logservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ public function delete_all_logs() {
);

foreach ( $all as $log ) {
wp_delete_post( $log->ID );
if ( $log->post_type === $this->post_type ) {
wp_delete_post( $log->ID );
}
}

return true;
Expand All @@ -224,7 +226,9 @@ public function prune_logs( $int_time_diff ) {
);

foreach ( $all as $log ) {
wp_delete_post( $log->ID );
if ( $log->post_type === $this->post_type ) {
wp_delete_post( $log->ID );
}
}

return true;
Expand Down Expand Up @@ -254,7 +258,9 @@ public function delete_all_logs_to_email( $email ) {
// @phpcs:enable

foreach ( $all as $log ) {
wp_delete_post( $log->ID );
if ( $log->post_type === $this->post_type ) {
wp_delete_post( $log->ID );
}
}

return count( $all );
Expand Down

0 comments on commit 4bb86da

Please sign in to comment.