Cron.php
8 years ago
Ecommerce.php
7 years ago
Language.php
10 years ago
Logger.php
8 years ago
MobileDetect.php
8 years ago
Options.php
8 years ago
Plugin.php
10 years ago
Properties.php
10 years ago
Tracking.php
8 years ago
Utils.php
8 years ago
Cron.php
37 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 | |
| 4 | class TCMP_Cron { |
| 5 | public function __construct() { |
| 6 | |
| 7 | } |
| 8 | public function init() { |
| 9 | add_filter( 'cron_schedules', array( $this, 'add_schedules' ) ); |
| 10 | add_action( 'wp', array( $this, 'schedule_Events' ) ); |
| 11 | } |
| 12 | public function add_schedules( $schedules = array() ) { |
| 13 | global $tcmp; |
| 14 | // Adds once weekly to the existing schedules. |
| 15 | $schedules['weekly'] = array( |
| 16 | 'interval' => 604800, |
| 17 | 'display' => $tcmp->Lang->L('Once Weekly') |
| 18 | ); |
| 19 | |
| 20 | return $schedules; |
| 21 | } |
| 22 | public function schedule_Events() { |
| 23 | $this->weekly_events(); |
| 24 | $this->daily_events(); |
| 25 | } |
| 26 | private function weekly_events() { |
| 27 | if ( ! wp_next_scheduled( 'tcmp_weekly_scheduled_events' ) ) { |
| 28 | wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'tcmp_weekly_scheduled_events' ); |
| 29 | } |
| 30 | } |
| 31 | private function daily_events() { |
| 32 | if ( ! wp_next_scheduled( 'tcmp_daily_scheduled_events' ) ) { |
| 33 | wp_schedule_event( current_time( 'timestamp' ), 'daily', 'tcmp_daily_scheduled_events' ); |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 |