-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-autoupdate.php
More file actions
59 lines (48 loc) · 1.57 KB
/
git-autoupdate.php
File metadata and controls
59 lines (48 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
56
57
58
59
<?php
/*
Plugin Name: Git Auto Update
Plugin URI: https://example.com/git-autoupdate
Description: A plugin that automatically updates the active theme from a git repository.
Version: 1.0.0
Author: KotoriK
Author URI: https://github.com/KotoriK
Co-author: Bing AI
Co-author URI: https://bing.com/new
License: GPL-2.0-or-later
Text Domain: git-autoupdate
*/
// Prevent direct access to the file
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'GITAU_PLUGIN_NAME', 'Git Auto Update' );
define( 'GITAU_MSG_PREFIX', GITAU_PLUGIN_NAME.': ' );
// 添加额外的cron时间间隔
function gitau_add_cron_schedules( $schedules ) {
// Add a weekly schedule
$schedules['weekly'] = array(
'interval' => 7 * 24 * 60 * 60, // 7 days * 24 hours * 60 minutes * 60 seconds
'display' => __( 'Once a week', 'git-autoupdate' )
);
// Add a monthly schedule
$schedules['monthly'] = array(
'interval' => 30 * 24 * 60 * 60, // 30 days * 24 hours * 60 minutes * 60 seconds
'display' => __( 'Once a month', 'git-autoupdate' )
);
// Return the modified schedules
return $schedules;
}
add_filter( 'cron_schedules', 'gitau_add_cron_schedules' );
require_once __DIR__.'/scheduler.php';
require_once __DIR__.'/settings.php';
// Activation function
function gitau_activate() {
}
// Deactivation function
function gitau_deactivate() {
// Clear the scheduled cron event
gitau_cancel_schedule_cron();
}
// Register activation and deactivation hooks
register_activation_hook( __FILE__, 'gitau_activate' );
register_deactivation_hook( __FILE__, 'gitau_deactivate' );