forked from AdeptLMS/adept-wp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cron.php
95 lines (64 loc) · 2.55 KB
/
cron.php
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
function wpadept_cron() {
set_time_limit(300);
//exit;
global $wpdb;
$post_table = $wpdb->prefix . "posts";
$postmeta_table = $wpdb->prefix . "postmeta";
$table_name = $wpdb->prefix . "api_credential";
$table_name1 = $wpdb->prefix . "term_taxonomy";
$table_name2 = $wpdb->prefix . "terms";
$adept_access_token_value = get_option('adept_access_token');
$adept_api_url_value = get_option('adept_api_url');
$adept_account_id_value = get_option('adept_account_id');
//importing courses categories
$url = $adept_api_url_value . 'course_categories?access_token=' . $adept_access_token_value . '&account_id=' . $adept_account_id_value;
wpadept_cron_check_is_authenticated($url);
$adept = new Wpadept_Lib();
$result = $adept->import_category($url);
if ($result) {
echo $result;
} else {
echo 'Categories category imported successfully (time: '.wpadept_clc().')<br><br>';
}
//importing courses
$url = $adept_api_url_value . 'courses?access_token=' . $adept_access_token_value . '&account_id=' . $adept_account_id_value;
$result = $adept->import_course($url);
echo 'Course imported successfully (time: '.wpadept_clc().')<br><br>';
//importing instructors
$url = $adept_api_url_value . 'team_members?access_token=' . $adept_access_token_value . '&account_id=' . $adept_account_id_value;
$result = $adept->import_instructors($url);
$success = $result;
echo 'instructor updated successfully (time: '.wpadept_clc().')<br><br>';
exit;
}
function wpadept_cron_meetings() {
set_time_limit(300);
global $wpdb;
$adept = new Wpadept_Lib();
$post_table = $wpdb->prefix . "posts";
$postmeta_table = $wpdb->prefix . "postmeta";
$table_name = $wpdb->prefix . "api_credential";
$table_name1 = $wpdb->prefix . "term_taxonomy";
$table_name2 = $wpdb->prefix . "terms";
$adept_access_token_value = get_option('adept_access_token');
$adept_api_url_value = get_option('adept_api_url');
$adept_account_id_value = get_option('adept_account_id');
//importing meetings
$url = $adept_api_url_value . 'meetings?access_token=' . $adept_access_token_value . '&account_id=' . $adept_account_id_value;
wpadept_cron_check_is_authenticated($url);
$result = $adept->import_meeting($url);
$success = $result;
echo 'class meeting imported successfully <br><br>';
exit;
}
add_action( "init" , "wpadept_cron_check");
function wpadept_cron_check() {
if(isset($_GET['wpadept_cron'])) {
wpadept_cron();
}
if(isset($_GET['wpadept_cron_meetings'])) {
wpadept_cron_meetings();
}
}