diff --git a/composer.json b/composer.json index 526f8a5..766d69a 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "project", "license": "GPLv3", "require": { - "convertkit/convertkit-wordpress-libraries": "2.6.0" + "convertkit/convertkit-wordpress-libraries": "dev-move-log-location" }, "require-dev": { "php-webdriver/webdriver": "^1.0", diff --git a/uninstall.php b/uninstall.php index 2dbd918..f983a13 100644 --- a/uninstall.php +++ b/uninstall.php @@ -16,6 +16,21 @@ // are not reliably available due to the Plugin being deactivated and going // through deletion now. +// Delete the log file from the uploads directory. +// The Plugin's own directory is deleted by WordPress once this routine completes, +// so any historic log file stored there doesn't need deleting here. +// This mirrors ConvertKit_Log::get_log_file_name() in the Kit WordPress Libraries, +// which we can't call as the Plugin's classes aren't reliably available. +$upload_dir = wp_upload_dir(); +if ( empty( $upload_dir['error'] ) && ! empty( $upload_dir['basedir'] ) ) { + $log_slug = sanitize_key( basename( __DIR__ ) ); + $log_file = trailingslashit( $upload_dir['basedir'] ) . 'kit-logs/' . $log_slug . '-' . wp_hash( $log_slug ) . '.log'; + + if ( file_exists( $log_file ) ) { + wp_delete_file( $log_file ); + } +} + // Get providers. $providers = get_option( 'wpforms_providers' );