Skip to content

Commit

Permalink
Improves purge_plugin_logs
Browse files Browse the repository at this point in the history
Uses wp_delete_post to delete logs, entries, and terms instead of just
entries.
  • Loading branch information
ebinnion committed Jun 9, 2014
1 parent 2f151c1 commit 35ea934
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions wp-logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,22 @@ function set_wp_logger_version( $version ) {
/**
* Callback function for 'wp_logger_purge' that will delete all log entries (comments) for a given plugin.
*
* @global $post Global WP_Post object.
*
* @param string $plugin_name The plugins's slug.
*/
function purge_plugin_logs( $plugin_name ) {
global $wpdb;
global $post;

$wpdb->query(
$wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_approved = %s AND comment_author = %s", self::CPT, $plugin_name )
);
$logs = $this->get_logs( $plugin_name );

if ( $logs->have_posts() ) {
while ( $logs->have_posts() ) {
$logs->the_post();

wp_delete_post( $post->ID, true );
}
}
}

/**
Expand Down

0 comments on commit 35ea934

Please sign in to comment.