" . __( 'All comments have been deleted.', 'disable-comments' ) . "
"; } else { echo "" . __( 'Internal error occured. Please try again later.', 'disable-comments' ) . "
"; } } else { echo "" . __( 'Internal error occured. Please try again later.', 'disable-comments' ) . "
"; } } else { $delete_post_types = empty( $_POST['delete_types'] ) ? array() : (array) $_POST['delete_types']; $delete_post_types = array_intersect( $delete_post_types, array_keys( $types ) ); // Extra custom post types if( $this->networkactive && !empty( $_POST['delete_extra_post_types'] ) ) { $delete_extra_post_types = array_filter( array_map( 'sanitize_key', explode( ',', $_POST['delete_extra_post_types'] ) ) ); $delete_extra_post_types = array_diff( $delete_extra_post_types, array_keys( $types ) ); // Make sure we don't double up builtins $delete_post_types = array_merge($delete_post_types, $delete_extra_post_types); } if ( ! empty( $delete_post_types ) ) { // Loop through post_types and remove comments/meta and set posts comment_count to 0 foreach ( $delete_post_types as $delete_post_type ) { $wpdb->query( "DELETE cmeta FROM $wpdb->commentmeta cmeta INNER JOIN $wpdb->comments comments ON cmeta.comment_id=comments.comment_ID INNER JOIN $wpdb->posts posts ON comments.comment_post_ID=posts.ID WHERE posts.post_type = '$delete_post_type'" ); $wpdb->query( "DELETE comments FROM $wpdb->comments comments INNER JOIN $wpdb->posts posts ON comments.comment_post_ID=posts.ID WHERE posts.post_type = '$delete_post_type'" ); $wpdb->query( "UPDATE $wpdb->posts SET comment_count = 0 WHERE post_author != 0 AND post_type = '$delete_post_type'" ); echo "" . sprintf( __( 'All comments have been deleted for %ss.', 'disable-comments' ), $delete_post_type ) . "
"; } $wpdb->query( "OPTIMIZE TABLE $wpdb->commentmeta" ); $wpdb->query( "OPTIMIZE TABLE $wpdb->comments" ); echo "