| 1 |
<?php |
| 2 |
/** |
| 3 |
* The admin-specific functionality of the plugin. |
| 4 |
* |
| 5 |
* @link https://wpsmartpost.com/ |
| 6 |
* @since 3.0.12 |
| 7 |
* |
| 8 |
* @package Smart_Post_Show |
| 9 |
* @subpackage Smart_Post_Show/admin |
| 10 |
* @author ShapedPlugin <[email protected]> |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; // Exit if accessed directly. |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Smart_Post_Show_Cron |
| 19 |
*/ |
| 20 |
class Smart_Post_Show_Cron { |
| 21 |
|
| 22 |
/** |
| 23 |
* Initialize the class and set its properties. |
| 24 |
* |
| 25 |
* @since 3.0.12 |
| 26 |
*/ |
| 27 |
public function __construct() { |
| 28 |
add_filter( 'cron_schedules', array( $this, 'add_schedules' ) ); |
| 29 |
add_action( 'wp', array( $this, 'schedule_events' ) ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Registers new cron schedules |
| 34 |
* |
| 35 |
* @since 3.0.12 |
| 36 |
* |
| 37 |
* @param array $schedules time schedule. |
| 38 |
* @return array |
| 39 |
*/ |
| 40 |
public function add_schedules( $schedules = array() ) { |
| 41 |
// Adds once weekly to the existing schedules. |
| 42 |
$schedules['weekly'] = array( |
| 43 |
'interval' => WEEK_IN_SECONDS, |
| 44 |
'display' => __( 'Once Weekly', 'post-carousel' ), |
| 45 |
); |
| 46 |
|
| 47 |
return $schedules; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Schedules our events |
| 52 |
* |
| 53 |
* @since 3.0.12 |
| 54 |
* @return void |
| 55 |
*/ |
| 56 |
public function schedule_events() { |
| 57 |
$this->weekly_events(); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Schedule weekly events |
| 62 |
* |
| 63 |
* @access private |
| 64 |
* @since 3.0.12 |
| 65 |
* @return void |
| 66 |
*/ |
| 67 |
private function weekly_events() { |
| 68 |
if ( ! wp_next_scheduled( 'smart_post_show_weekly_scheduled_events' ) ) { |
| 69 |
wp_schedule_event( time(), 'weekly', 'smart_post_show_weekly_scheduled_events' ); |
| 70 |
} |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
new Smart_Post_Show_Cron(); |
| 75 |
|