PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 6.0.6
Taskbuilder – Project Management & Task Management Tool With Kanban Board v6.0.6
6.0.6 6.0.5 6.0.2 6.0.3 6.0.4 6.0.1 6.0.0 5.0.8 5.0.9 4.0.9 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 All 58 releases
taskbuilder / includes / actions / wppm_check_cron_attachment.php

wppm_check_cron_attachment.php in Taskbuilder – Project Management & Task Management Tool With Kanban Board 6.0.6, at includes/actions/wppm_check_cron_attachment.php

49 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5 global $wpdb;
6 $garbage_collection_time = get_option('wppm_garbage_collection_time' ,'');
7 if ( empty( $garbage_collection_time ) ) {
8 update_option( 'wppm_garbage_collection_time', current_time( 'mysql' ) );
9 return;
10 }
11 $check_flag = false;
12 $now = current_time( 'timestamp' );
13 $ago = strtotime($garbage_collection_time);
14 $diff = $now - $ago;
15 if($diff >= DAY_IN_SECONDS){
16 $check_flag = true;
17 }
18 if(!$check_flag){
19 return;
20 }
21 $attachments=$wpdb->get_results(("select id,name,date_created from {$wpdb->prefix}wppm_attachments where is_active=0"));
22 if($attachments){
23 foreach($attachments as $attachment){
24 $created_time = $attachment->date_created;
25 $upload_dir = wp_upload_dir();
26 $time = strtotime($created_time);
27 $month = wp_date("m",$time);
28 $year = wp_date("Y",$time);
29 $filename = sanitize_file_name( $attachment->name );
30 $filepath = $upload_dir['basedir'] . '/wppm/'.'/'.$year.'/'.$month.'/'. $filename;
31 $attachment_updated_time = strtotime($created_time);
32 $diff = $now - $attachment_updated_time;
33 if($diff > DAY_IN_SECONDS){
34 $attachment_id = absint( $attachment->id );
35 $wpdb->delete(
36 $wpdb->prefix . 'wppm_attachments',
37 array( 'id' => $attachment_id ),
38 array( '%d' )
39 );
40 if(file_exists($filepath)){
41 //unlink($filepath);
42 wp_delete_file($filepath);
43 }
44 }
45 }
46 }
47 update_option('wppm_garbage_collection_time', current_time( 'mysql' ) );
48
49