mirror of
https://github.com/WenPai-org/wp-china-yes.git
synced 2025-08-07 14:35:20 +08:00
将插件配置信息提取为公共变量
This commit is contained in:
parent
8db1fb3f6a
commit
9c836f9ea7
1 changed files with 8 additions and 7 deletions
15
index.php
15
index.php
|
@ -15,6 +15,8 @@ define('WP_CHINA_YES_BASE_FILE', __FILE__);
|
||||||
(new WP_CHINA_YES)->init();
|
(new WP_CHINA_YES)->init();
|
||||||
|
|
||||||
class WP_CHINA_YES {
|
class WP_CHINA_YES {
|
||||||
|
private $wp_china_yes_options = array();
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
add_filter('pre_http_request', array($this, 'pre_http_request'), 10, 3);
|
add_filter('pre_http_request', array($this, 'pre_http_request'), 10, 3);
|
||||||
$post_action = isset($_POST['action']) ? sanitize_text_field(trim($_POST['action'])) : ' ';
|
$post_action = isset($_POST['action']) ? sanitize_text_field(trim($_POST['action'])) : ' ';
|
||||||
|
@ -22,7 +24,8 @@ class WP_CHINA_YES {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (is_admin()) {
|
if (is_admin()) {
|
||||||
if (empty(get_option('wp_china_yes_options'))) {
|
$this->wp_china_yes_options = get_option('wp_china_yes_options');
|
||||||
|
if (empty($this->wp_china_yes_options)) {
|
||||||
self::set_wp_option();
|
self::set_wp_option();
|
||||||
}
|
}
|
||||||
register_deactivation_hook(WP_CHINA_YES_BASE_FILE, array($this, 'wp_china_yes_deactivate'));
|
register_deactivation_hook(WP_CHINA_YES_BASE_FILE, array($this, 'wp_china_yes_deactivate'));
|
||||||
|
@ -45,9 +48,7 @@ class WP_CHINA_YES {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = get_option('wp_china_yes_options');
|
if ($this->wp_china_yes_options["community"] == 1) {
|
||||||
|
|
||||||
if ($options["community"] == 1) {
|
|
||||||
$api_server = 'api.w.org.ixmu.net';
|
$api_server = 'api.w.org.ixmu.net';
|
||||||
$download_server = 'd.w.org.ixmu.net';
|
$download_server = 'd.w.org.ixmu.net';
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,8 +56,8 @@ class WP_CHINA_YES {
|
||||||
$download_server = 'd.w.org.ibadboy.net';
|
$download_server = 'd.w.org.ibadboy.net';
|
||||||
}
|
}
|
||||||
|
|
||||||
$api_server = $options["custom_api_server"] ?: $api_server;
|
$api_server = $this->wp_china_yes_options["custom_api_server"] ?: $api_server;
|
||||||
$download_server = $options["custom_download_server"] ?: $download_server;
|
$download_server = $this->wp_china_yes_options["custom_download_server"] ?: $download_server;
|
||||||
$url = str_replace('api.wordpress.org', $api_server, $url);
|
$url = str_replace('api.wordpress.org', $api_server, $url);
|
||||||
$url = str_replace('downloads.wordpress.org', $download_server, $url);
|
$url = str_replace('downloads.wordpress.org', $download_server, $url);
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ EOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_config() {
|
public function get_config() {
|
||||||
self::success('', get_option('wp_china_yes_options'));
|
self::success('', $this->wp_china_yes_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_config() {
|
public function set_config() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue