admin
11 years ago
actions.php
11 years ago
class-TCM-check.php
11 years ago
class-TCM-cron.php
11 years ago
class-TCM-form.php
11 years ago
class-TCM-language.php
11 years ago
class-TCM-logger.php
11 years ago
class-TCM-manager.php
11 years ago
class-TCM-options.php
11 years ago
class-TCM-tracking.php
11 years ago
class-TCM-utils.php
11 years ago
core.php
11 years ago
install.php
11 years ago
uninstall.php
11 years ago
class-TCM-cron.php
84 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Cron |
| 4 | * |
| 5 | * @package EDD |
| 6 | * @subpackage Classes/Cron |
| 7 | * @copyright Copyright (c) 2015, Pippin Williamson |
| 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | * @since 1.6 |
| 10 | */ |
| 11 | |
| 12 | // Exit if accessed directly |
| 13 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 14 | |
| 15 | class TCM_Cron { |
| 16 | /** |
| 17 | * Get things going |
| 18 | * |
| 19 | * @since 1.6 |
| 20 | * @see EDD_Cron::weekly_events() |
| 21 | */ |
| 22 | public function __construct() { |
| 23 | add_filter( 'cron_schedules', array( $this, 'add_schedules' ) ); |
| 24 | add_action( 'wp', array( $this, 'schedule_Events' ) ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Registers new cron schedules |
| 29 | * |
| 30 | * @since 1.6 |
| 31 | * |
| 32 | * @param array $schedules |
| 33 | * @return array |
| 34 | */ |
| 35 | public function add_schedules( $schedules = array() ) { |
| 36 | global $tcm; |
| 37 | // Adds once weekly to the existing schedules. |
| 38 | $schedules['weekly'] = array( |
| 39 | 'interval' => 604800, |
| 40 | 'display' => $tcm->Lang->L('Once Weekly') |
| 41 | ); |
| 42 | |
| 43 | return $schedules; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Schedules our events |
| 48 | * |
| 49 | * @access public |
| 50 | * @since 1.6 |
| 51 | * @return void |
| 52 | */ |
| 53 | public function schedule_Events() { |
| 54 | $this->weekly_events(); |
| 55 | $this->daily_events(); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Schedule weekly events |
| 60 | * |
| 61 | * @access private |
| 62 | * @since 1.6 |
| 63 | * @return void |
| 64 | */ |
| 65 | private function weekly_events() { |
| 66 | if ( ! wp_next_scheduled( 'tcm_weekly_scheduled_events' ) ) { |
| 67 | wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'tcm_weekly_scheduled_events' ); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Schedule daily events |
| 73 | * |
| 74 | * @access private |
| 75 | * @since 1.6 |
| 76 | * @return void |
| 77 | */ |
| 78 | private function daily_events() { |
| 79 | if ( ! wp_next_scheduled( 'tcm_daily_scheduled_events' ) ) { |
| 80 | wp_schedule_event( current_time( 'timestamp' ), 'daily', 'tcm_daily_scheduled_events' ); |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 |