cron.php
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * WordAds cron tasks |
| 5 | * |
| 6 | * @since 4.5.0 |
| 7 | */ |
| 8 | class WordAds_Cron { |
| 9 | |
| 10 | /** |
| 11 | * Add the actions the cron tasks will use |
| 12 | * |
| 13 | * @since 4.5.0 |
| 14 | */ |
| 15 | function __construct() { |
| 16 | add_action( 'wordads_cron_status', array( $this, 'update_wordads_status' ) ); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Registered scheduled events on activation |
| 21 | * |
| 22 | * @since 4.5.0 |
| 23 | */ |
| 24 | static function activate() { |
| 25 | wp_schedule_event( time(), 'daily', 'wordads_cron_status' ); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Clear scheduled hooks on deactivation |
| 30 | * |
| 31 | * @since 4.5.0 |
| 32 | */ |
| 33 | static function deactivate() { |
| 34 | wp_clear_scheduled_hook( 'wordads_cron_status' ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Grab WordAds status from WP.com API |
| 39 | * |
| 40 | * @since 4.5.0 |
| 41 | */ |
| 42 | static function update_wordads_status() { |
| 43 | WordAds_API::update_wordads_status_from_api(); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | global $wordads_cron; |
| 48 | $wordads_cron = new WordAds_Cron(); |
| 49 |