Changeset 43095 for branches/4.9/src/wp-includes/functions.php
- Timestamp:
- 05/02/2018 02:32:57 AM (7 years ago)
- Location:
- branches/4.9
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
branches/4.9/src/wp-includes/functions.php
r43082 r43095 5935 5935 return apply_filters( 'wp_privacy_anonymize_data', $anonymous, $type, $data ); 5936 5936 } 5937 5938 /** 5939 * Schedule a `WP_Cron` job to delete expired export files. 5940 * 5941 * @since 4.9.6 5942 */ 5943 function wp_schedule_delete_old_privacy_export_files() { 5944 if ( ! wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ) { 5945 wp_schedule_event( time(), 'hourly', 'wp_privacy_delete_old_export_files' ); 5946 } 5947 } 5948 5949 /** 5950 * Cleans up export files older than three days old. 5951 * 5952 * The export files are stored in `wp-content/uploads`, and are therefore publicly 5953 * accessible. A CSPRN is appended to the filename to mitigate the risk of an 5954 * unauthorized person downloading the file, but it is still possible. Deleting 5955 * the file after the data subject has had a chance to delete it adds an additional 5956 * layer of protection. 5957 * 5958 * @since 4.9.6 5959 */ 5960 function wp_privacy_delete_old_export_files() { 5961 $upload_dir = wp_upload_dir(); 5962 $exports_dir = trailingslashit( $upload_dir['basedir'] . '/exports' ); 5963 $export_files = list_files( $exports_dir, 100, array( 'index.html' ) ); 5964 5965 /** 5966 * Filters the lifetime, in seconds, of a personal data export file. 5967 * 5968 * By default, the lifetime is 3 days. Once the file reaches that age, it will automatically 5969 * be deleted by a cron job. 5970 * 5971 * @since 4.9.6 5972 * 5973 * @param int $expiration The expiration age of the export, in seconds. 5974 */ 5975 $expiration = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS ); 5976 5977 foreach ( (array) $export_files as $export_file ) { 5978 $file_age_in_seconds = time() - filemtime( $export_file ); 5979 5980 if ( $expiration < $file_age_in_seconds ) { 5981 unlink( $export_file ); 5982 } 5983 } 5984 }
Note: See TracChangeset
for help on using the changeset viewer.