| 1 |
<?php |
| 2 |
/** |
| 3 |
* Statify: Statify_Cron class |
| 4 |
* |
| 5 |
* This file contains the derived class for the plugin's cron features. |
| 6 |
* |
| 7 |
* @package Statify |
| 8 |
* @since 1.4.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
// Quit if accessed outside WP context. |
| 12 |
defined( 'ABSPATH' ) || exit; |
| 13 |
|
| 14 |
/** |
| 15 |
* Statify_Cron |
| 16 |
* |
| 17 |
* @since 1.4.0 |
| 18 |
*/ |
| 19 |
class Statify_Cron extends Statify { |
| 20 |
|
| 21 |
/** |
| 22 |
* Cleanup obsolete DB values |
| 23 |
* |
| 24 |
* @since 0.3.0 |
| 25 |
* @version 1.4.0 |
| 26 |
*/ |
| 27 |
public static function cleanup_data() { |
| 28 |
|
| 29 |
// Global. |
| 30 |
global $wpdb; |
| 31 |
|
| 32 |
// Remove items. |
| 33 |
$wpdb->query( |
| 34 |
$wpdb->prepare( |
| 35 |
"DELETE FROM `$wpdb->statify` WHERE created <= SUBDATE(CURDATE(), %d)", |
| 36 |
(int) self::$_options['days'] |
| 37 |
) |
| 38 |
); |
| 39 |
|
| 40 |
// Optimize DB. |
| 41 |
$wpdb->query( |
| 42 |
"OPTIMIZE TABLE `$wpdb->statify`" |
| 43 |
); |
| 44 |
} |
| 45 |
} |
| 46 |
|