-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpbridge.php
More file actions
73 lines (62 loc) · 1.71 KB
/
wpbridge.php
File metadata and controls
73 lines (62 loc) · 1.71 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* Plugin Name: WPBridge
* Plugin URI: https://wenpai.org/plugins/wpbridge
* Description: 自定义源桥接器 - 让用户完全控制 WordPress 的外部连接
* Version: 1.2.2
* Author: WenPai.org
* Author URI: https://wenpai.org
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wpbridge
* Domain Path: /languages
* Requires at least: 5.9
* Requires PHP: 7.4
* Update URI: https://updates.wenpai.net
*
* @package WPBridge
*/
namespace WPBridge;
// 防止直接访问
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// 插件常量
define( 'WPBRIDGE_VERSION', '1.2.2' );
define( 'WPBRIDGE_FILE', __FILE__ );
define( 'WPBRIDGE_PATH', plugin_dir_path( __FILE__ ) );
define( 'WPBRIDGE_URL', plugin_dir_url( __FILE__ ) );
define( 'WPBRIDGE_BASENAME', plugin_basename( __FILE__ ) );
// 加载自动加载器
require_once WPBRIDGE_PATH . 'includes/Core/Loader.php';
// 初始化插件
function wpbridge_init() {
return Core\Plugin::get_instance();
}
// 激活钩子
register_activation_hook(
__FILE__,
function () {
Core\Plugin::activate();
// 调度后台更新任务
$settings = new Core\Settings();
$updater = new Performance\BackgroundUpdater( $settings );
$updater->schedule_update();
}
);
// 停用钩子
register_deactivation_hook(
__FILE__,
function () {
Core\Plugin::deactivate();
}
);
// WenPai 自更新检查器
require_once WPBRIDGE_PATH . 'includes/class-wenpai-updater.php';
new \WenPai_Updater( WPBRIDGE_BASENAME, WPBRIDGE_VERSION );
// 启动插件
add_action( 'plugins_loaded', __NAMESPACE__ . '\\wpbridge_init' );
// 注册 WP-CLI 命令
if ( defined( 'WP_CLI' ) && WP_CLI ) {
\WP_CLI::add_command( 'bridge', CLI\BridgeCommand::class );
}