| @@ -15,8 +15,23 @@ | ||
| 15 | 15 | // Only WordPress and PHP methods can be used. Plugin classes and methods |
| 16 | 16 | // are not reliably available due to the Plugin being deactivated and going |
| 17 | 17 | // through deletion now. |
| 18 | 18 | |
| 19 | +// Delete the log file from the uploads directory. | |
| 20 | +// The Plugin's own directory is deleted by WordPress once this routine completes, | |
| 21 | +// so any historic log file stored there doesn't need deleting here. | |
| 22 | +// This mirrors ConvertKit_Log::get_log_file_name() in the Kit WordPress Libraries, | |
| 23 | +// which we can't call as the Plugin's classes aren't reliably available. | |
| 24 | +$upload_dir = wp_upload_dir(); | |
| 25 | +if ( empty( $upload_dir['error'] ) && ! empty( $upload_dir['basedir'] ) ) { | |
| 26 | + $log_slug = sanitize_key( basename( __DIR__ ) ); | |
| 27 | + $log_file = trailingslashit( $upload_dir['basedir'] ) . 'kit-logs/' . $log_slug . '-' . wp_hash( $log_slug ) . '.log'; | |
| 28 | + | |
| 29 | + if ( file_exists( $log_file ) ) { | |
| 30 | + wp_delete_file( $log_file ); | |
| 31 | + } | |
| 32 | +} | |
| 33 | + | |
| 19 | 34 | // Get settings. |
| 20 | 35 | $settings = get_option( '_wp_convertkit_settings' ); |
| 21 | 36 | |
| 22 | 37 | // Bail if no settings exist. |