-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlearntoronto-events.php
More file actions
55 lines (43 loc) · 1.57 KB
/
learntoronto-events.php
File metadata and controls
55 lines (43 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* @package LearnToronto_Events
* @version 1.0
*/
/*
Plugin Name: LearnToronto Events Listings
Plugin URI: http://learntoronto.org/
Description: This plugin creates a Custom Post type that allows adding new events from the LearnToronto.org API feed (http://learntoronto.org/api/v1/events.json)
Author: Raymond Kao
Version: 1.0
Author URI: http://peopleandcode.com
*/
include_once('custom-post-types.php');
include_once('learntoronto/learntoronto.php');
register_activation_hook( __FILE__, 'learntoronto_event_daily_activation' );
add_action('learntoronto_event_daily_event', 'learntoronto_daily_event');
function learntoronto_event_daily_activation() {
$learntoronto = new LearnToronto;
$learntoronto->check_new_events();
$time_zone = new DateTimeZone('America/Toronto');
$new_zone = new DateTimeZone('UTC');
$date = date('Y-m-d 4:00:00');
$date_time = new DateTime($date, $time_zone);
$date_time->setTimeZone($new_zone);
$year = $date_time->format('Y');
$day = $date_time->format('d');
$month = $date_time->format('m');
$hour = $date_time->format('H');
$min = $date_time->format('i');
$sec = $date_time->format('s');
$time = mktime($hour, $min, $sec, $month, $day, $year);
wp_schedule_event($time, 'daily', 'learntoronto_event_daily_event');
}
function learntoronto_daily_event() {
$learntoronto = new LearnToronto;
$learntoronto->check_new_events();
}
register_deactivation_hook( __FILE__, 'learntoronto_event_daily_deactivation');
function learntoronto_event_daily_deactivation() {
wp_clear_scheduled_hook('learntoronto_event_daily_event');
}
?>