PluginProbe
FileBird – WordPress Media Library Folders & File Manager / 5.6
FileBird – WordPress Media Library Folders & File Manager v5.6
6.5.8 6.5.7 6.5.5 6.5.4 trunk 4.3.1 5.1.6 5.3 5.3.2 5.4.3 5.4.4 5.4.5 5.5 5.5.3 5.5.5 5.5.8 5.5.8.1 5.6 5.6.1 5.6.2 5.6.3 5.6.4 6.2.3 6.2.5 6.3 All 36 releases
filebird / includes / Classes / Schedule.php

Schedule.php in FileBird – WordPress Media Library Folders & File Manager 5.6, at includes/Classes/Schedule.php

38 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace FileBird\Classes;
3
4 defined( 'ABSPATH' ) || exit;
5
6 class Schedule {
7 public function __construct() {
8 add_action( 'filebird_remove_zip_files', array( $this, 'actionRemoveZipFiles' ) );
9 }
10
11 public static function registerSchedule() {
12 if ( ! wp_next_scheduled( 'filebird_remove_zip_files' ) ) {
13 wp_schedule_event( time(), 'daily', 'filebird_remove_zip_files' );
14 }
15 }
16
17 public static function clearSchedule() {
18 wp_clear_scheduled_hook( 'filebird_remove_zip_files' );
19 }
20
21 public function actionRemoveZipFiles() {
22 $saved_downloads = get_option( 'filebird_saved_downloads', array() );
23 if ( ! is_array( $saved_downloads ) ) {
24 $saved_downloads = array();
25 }
26 foreach ( $saved_downloads as $time => $path ) {
27 if ( ( time() - $time ) >= ( 24 * 60 * 60 ) ) {
28 $wp_dir = wp_upload_dir();
29 if ( file_exists( $wp_dir['basedir'] . $path ) ) {
30 unlink( $wp_dir['basedir'] . $path );
31 }
32 unset( $saved_downloads[ $time ] );
33 }
34 }
35 update_option( 'filebird_saved_downloads', $saved_downloads );
36 }
37 }
38