diff --git a/Service/Monitor.php b/Service/Monitor.php
index 1f867f7..bcdecb4 100644
--- a/Service/Monitor.php
+++ b/Service/Monitor.php
@@ -37,7 +37,7 @@ class Monitor {
* 初始化
*/
public function init() {
- if ( $this->settings['monitor'] != 'on' ) {
+ if ( $this->settings['monitor'] ) {
return;
}
// 检查应用市场可用性
@@ -104,51 +104,51 @@ class Monitor {
*/
public function maybe_check_admincdn() {
// 后台加速
- if ( ! empty( $this->settings['admincdn']['admin'] ) ) {
+ if ( in_array( 'admin', $this->settings['admincdn'] ) ) {
$response = wp_remote_get( 'https://wpstatic.admincdn.com/6.4.3/wp-includes/js/wp-sanitize.min.js' );
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- unset( $this->settings['admincdn']['admin'] );
+ $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'admin' ] ) );
$this->update_settings();
}
}
// 前台加速
- if ( ! empty( $this->settings['admincdn']['frontend'] ) ) {
+ if ( in_array( 'frontend', $this->settings['admincdn'] ) ) {
$url = network_site_url( '/wp-includes/js/wp-sanitize.min.js' );
$response = wp_remote_get( 'https://public.admincdn.com/' . $url );
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- unset( $this->settings['admincdn']['frontend'] );
+ $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'frontend' ] ) );
$this->update_settings();
}
}
// Google 字体
- if ( ! empty( $this->settings['admincdn']['googlefonts'] ) ) {
+ if ( in_array( 'googlefonts', $this->settings['admincdn'] ) ) {
$response = wp_remote_get( 'https://googlefonts.admincdn.com/css?family=Roboto:400,700' );
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- unset( $this->settings['admincdn']['googlefonts'] );
+ $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'googlefonts' ] ) );
$this->update_settings();
}
}
// Google 前端公共库
- if ( ! empty( $this->settings['admincdn']['googleajax'] ) ) {
+ if ( in_array( 'googleajax', $this->settings['admincdn'] ) ) {
$response = wp_remote_get( 'https://googleajax.admincdn.com/ajax/libs/jquery/3.7.1/jquery.slim.min.js' );
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- unset( $this->settings['admincdn']['googleajax'] );
+ $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'googleajax' ] ) );
$this->update_settings();
}
}
// CDNJS 前端公共库
- if ( ! empty( $this->settings['admincdn']['cdnjs'] ) ) {
+ if ( in_array( 'cdnjs', $this->settings['admincdn'] ) ) {
$response = wp_remote_get( 'https://cdnjs.admincdn.com/jquery/3.7.1/jquery.slim.min.js' );
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- unset( $this->settings['admincdn']['cdnjs'] );
+ $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'cdnjs' ] ) );
$this->update_settings();
}
}
// jsDelivr 公共库
- if ( ! empty( $this->settings['admincdn']['jsdelivr'] ) ) {
+ if ( in_array( 'jsdelivr', $this->settings['admincdn'] ) ) {
$response = wp_remote_get( 'https://jsd.admincdn.com/npm/jquery@3.7.1/dist/jquery.slim.min.js' );
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
- unset( $this->settings['admincdn']['jsdelivr'] );
+ $this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'jsdelivr' ] ) );
$this->update_settings();
}
}
diff --git a/Service/Setting.php b/Service/Setting.php
index c64c782..f85ecbf 100644
--- a/Service/Setting.php
+++ b/Service/Setting.php
@@ -4,7 +4,8 @@ namespace WenPai\ChinaYes\Service;
defined( 'ABSPATH' ) || exit;
-use TheTNB\Setting\API;
+use WP_CHINA_YES;
+use function WenPai\ChinaYes\get_settings;
/**
* Class Setting
@@ -12,115 +13,375 @@ use TheTNB\Setting\API;
* @package WenPai\ChinaYes\Service
*/
class Setting {
- private $setting_api;
+ private $prefix = 'wp_china_yes';
+ private $settings;
public function __construct() {
- $this->setting_api = new API();
- add_action( 'admin_init', [ $this, 'admin_init' ] );
+ $this->settings = get_settings();
+ add_filter( 'wp_china_yes_enqueue_assets', '__return_true' );
+ add_filter( 'wp_china_yes_fa4', '__return_true' );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_assets' ] );
add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', [ $this, 'admin_menu' ] );
+ self::admin_init();
}
/**
* 挂载设置项
*/
public function admin_init() {
+ WP_CHINA_YES::createOptions( $this->prefix, [
+ 'framework_title' => sprintf( '%s v%s', $this->settings['custom_name'], CHINA_YES_VERSION ),
+ 'menu_hidden' => $this->settings['hide'],
+ 'menu_title' => $this->settings['custom_name'],
+ 'menu_slug' => 'wp-china-yes',
+ 'menu_type' => 'submenu',
+ 'menu_parent' => is_multisite() ? 'settings.php' : 'options-general.php',
+ 'show_bar_menu' => false,
+ 'show_sub_menu' => false,
+ 'show_search' => false,
+ 'show_reset_section' => false,
+ 'footer_text' => sprintf( '%s 设置', $this->settings['custom_name'] ),
+ 'theme' => 'light',
+ 'enqueue_webfont' => false,
+ 'async_webfont' => true,
+ 'database' => is_multisite() ? 'network' : '',
+ ] );
- $sections = [
- [
- 'id' => 'wp_china_yes',
- 'title' => __( '设置', 'wp-china-yes' )
- ]
- ];
-
- $fields = [
- 'wp_china_yes' => [
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '加速设置',
+ 'icon' => 'fa fa-rocket',
+ 'fields' => [
[
- 'name' => 'store',
- 'label' => __( '应用市场', 'wp-china-yes' ),
- 'desc' => __( '官方加速源(WPMirror)直接从 .org 反代至大陆分发;文派开源(WenPai.org)中国境内自建托管仓库,同时集成文派翻译平台。',
- 'wp-china-yes' ),
- 'type' => 'radio',
- 'default' => 'wenpai',
- 'options' => [
+ 'id' => 'store',
+ 'type' => 'radio',
+ 'title' => __( '应用市场', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
'proxy' => '官方镜像',
'wenpai' => '文派开源',
'off' => '不启用'
- ]
+ ],
+ 'default' => 'wenpai',
+ 'subtitle' => '是否启用市场加速',
+ 'desc' => __( '官方加速源(WPMirror)直接从 .org 反代至大陆分发;文派开源(WenPai.org)中国境内自建托管仓库,同时集成文派翻译平台',
+ 'wp-china-yes' ),
],
[
- 'name' => 'admincdn',
- 'label' => __( '萌芽加速', 'wp-china-yes' ),
- 'desc' => __( '萌芽加速(adminCDN)将 WordPress 依赖的静态文件切换为公共资源,加快网站访问速度。您可按需启用需要加速的项目,更多细节控制和功能,请关注 adminCDN 项目。',
- 'wp-china-yes' ),
- 'type' => 'multicheck',
- 'default' => [
- 'admin' => 'admin',
- ],
- 'options' => [
+ 'id' => 'admincdn',
+ 'type' => 'checkbox',
+ 'title' => __( '萌芽加速', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
'admin' => '后台加速',
'frontend' => '前台加速',
'googlefonts' => 'Google 字体',
'googleajax' => 'Google 前端公共库',
'cdnjs' => 'CDNJS 前端公共库',
- 'jsdelivr' => 'jsDelivr 公共库',
- ]
+ 'jsdelivr' => 'jsDelivr 公共库'
+ ],
+ 'default' => [
+ 'admin' => 'admin',
+ ],
+ 'subtitle' => '是否启用萌芽加速',
+ 'desc' => __( '萌芽加速(adminCDN)将 WordPress 依赖的静态文件切换为公共资源,加快网站访问速度。您可按需启用需要加速的项目,更多细节控制和功能,请关注 adminCDN 项目',
+ 'wp-china-yes' ),
],
[
- 'name' => 'cravatar',
- 'label' => __( '初认头像', 'wp-china-yes' ),
- 'desc' => __( '初认头像(Cravatar)Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。(任何开发者均可在自己的产品中集成该服务,不局限于 WordPress)',
- 'wp-china-yes' ),
- 'type' => 'radio',
- 'default' => 'cn',
- 'options' => [
+ 'id' => 'cravatar',
+ 'type' => 'radio',
+ 'title' => __( '初认头像', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
'cn' => '默认线路',
'global' => '国际线路',
- 'weavatar' => '备用源(WeAvatar)',
+ 'weavatar' => '备用源(WeAvatar.com)',
'off' => '不启用'
- ]
+ ],
+ 'default' => 'cn',
+ 'subtitle' => '是否启用头像加速',
+ 'desc' => __( '初认头像(Cravatar)Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。(任何开发者均可在自己的产品中集成该服务,不局限于 WordPress)',
+ 'wp-china-yes' ),
+ ],
+ ],
+ ] );
+
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '文风字体',
+ 'icon' => 'fa fa-font',
+ 'fields' => [
+ [
+ 'id' => 'windfonts',
+ 'type' => 'radio',
+ 'title' => __( '文风字体', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
+ 'on' => '全局启用',
+ 'frontend' => '前台启用',
+ 'optimize' => '本机字体',
+ 'off' => '不启用',
+ ],
+ 'default' => 'off',
+ 'subtitle' => '是否启用文风字体定制',
+ 'desc' => __( '文风字体(Windfonts)为您的网站增添无限活力。专为中文网页设计,旨在提升用户阅读体验和视觉享受',
+ 'wp-china-yes' ),
],
[
- 'name' => 'windfonts',
- 'label' => __( '文风字体', 'wp-china-yes' ),
- 'desc' => __( '文风字体(Windfonts)为您的网页渲染中文字体并对主题、插件内的字体进行加速;优化模式可优化浏览器字体调用。',
- 'wp-china-yes' ),
- 'type' => 'radio',
- 'default' => 'off',
- 'options' => [
- 'optimize' => '优化模式',
- 'off' => '不启用',
- ]
+ 'id' => 'windfonts_list',
+ 'type' => 'group',
+ 'title' => '字体列表',
+ 'subtitle' => '使用的文风字体列表',
+ 'desc' => '支持添加多个文风字体,并配置应用元素、字体权重大小',
+ 'button_title' => '添加字体',
+ 'accordion_title_number' => true,
+ 'dependency' => [
+ 'windfonts',
+ 'any',
+ 'on,frontend',
+ ],
+ 'fields' => [
+ [
+ 'id' => 'family',
+ 'type' => 'text',
+ 'title' => __( '字体家族', 'wp-china-yes' ),
+ 'subtitle' => '字体家族名称',
+ 'desc' => __( '填入从文风字体获取的字体家族名称',
+ 'wp-china-yes' ),
+ 'default' => 'wenfeng-syhtcjk',
+ ],
+ [
+ 'id' => 'css',
+ 'type' => 'text',
+ 'title' => __( '字体链接', 'wp-china-yes' ),
+ 'subtitle' => '字体 CSS 链接',
+ 'desc' => __( '填入从文风字体获取的字体 CSS 链接',
+ 'wp-china-yes' ),
+ 'default' => 'https://cn.windfonts.com/wenfeng/fonts/syhtcjk/regular/web/index.css',
+ 'validate' => 'csf_validate_url',
+ ],
+ [
+ 'id' => 'weight',
+ 'type' => 'number',
+ 'title' => __( '字体字重', 'wp-china-yes' ),
+ 'subtitle' => '字体字重大小',
+ 'desc' => __( '设置字体权重大小(字体粗细)',
+ 'wp-china-yes' ),
+ 'default' => 400,
+ 'attributes' => [
+ 'min' => 100,
+ 'max' => 1000,
+ 'step' => 10,
+ ],
+ 'validate' => 'csf_validate_numeric',
+ ],
+ [
+ 'id' => 'style',
+ 'type' => 'select',
+ 'title' => __( '字体样式', 'wp-china-yes' ),
+ 'subtitle' => '字体样式选择',
+ 'options' => [
+ 'normal' => '正常',
+ 'italic' => '斜体',
+ 'oblique' => '倾斜',
+ ],
+ 'desc' => __( '设置字体样式(正常、斜体、倾斜)',
+ 'wp-china-yes' ),
+ ],
+ [
+ 'id' => 'selector',
+ 'type' => 'textarea',
+ 'title' => __( '字体应用', 'wp-china-yes' ),
+ 'subtitle' => '字体应用元素',
+ 'desc' => __( '设置字体应用的元素(CSS 选择器)',
+ 'wp-china-yes' ),
+ 'default' => 'a,p,h1,h2,h3,h4,h5,h6,ul,ol,li,button,blockquote,pre,code,table,th,td,div:not([class*="star"]),label,b,i:not([class]),em,small,strong,sub,sup,ins,del,mark,abbr,dfn,span:not([class*="icon"])',
+ 'sanitize' => false,
+ ],
+ [
+ 'id' => 'enable',
+ 'type' => 'switcher',
+ 'title' => __( '启用字体', 'wp-china-yes' ),
+ 'subtitle' => '是否启用该字体',
+ 'default' => true,
+ ],
+ ],
],
[
- 'name' => 'adblock',
- 'label' => __( '广告拦截', 'wp-china-yes' ),
- 'desc' => __( '文派叶子🍃(WP-China-Yes)独家特色功能,让您拥有清爽整洁的 WordPress 后台,清除各类常用插件侵入式后台广告、通知及无用信息;启用后若存在异常拦截,请切换为手动模式,查看可优化插件列表。',
- 'wp-china-yes' ),
- 'type' => 'radio',
- 'default' => 'off',
- 'options' => [
- 'off' => '即将上线',
- ]
+ 'type' => 'content',
+ 'content' => '默认适配规则跟随插件更新,插件更新后可删除字体重新添加以获取最新适配规则',
],
+ ],
+ ] );
+
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '广告屏蔽',
+ 'icon' => 'fa fa-ban',
+ 'fields' => [
[
- 'name' => 'monitor',
- 'label' => __( '自动监控', 'wp-china-yes' ),
- 'desc' => __( '文派叶子🍃(WP-China-Yes)支持自动监控各加速节点可用性,当节点不可用时自动切换至可用节点或关闭加速,以保证您的网站正常访问。',
- 'wp-china-yes' ),
- 'type' => 'radio',
- 'default' => 'on',
- 'options' => [
+ 'id' => 'adblock',
+ 'type' => 'radio',
+ 'title' => __( '广告屏蔽', 'wp-china-yes' ),
+ 'inline' => true,
+ 'options' => [
'on' => '启用',
'off' => '不启用',
- ]
+ ],
+ 'default' => 'off',
+ 'subtitle' => '是否启用后台广告屏蔽',
+ 'desc' => __( '文派叶子🍃(WP-China-Yes)独家特色功能,让您拥有清爽整洁的 WordPress 后台,清除各类常用插件侵入式后台广告、通知及无用信息',
+ 'wp-china-yes' ),
],
- ]
- ];
+ [
+ 'id' => 'adblock_rule',
+ 'type' => 'group',
+ 'title' => '规则列表',
+ 'subtitle' => '使用的广告屏蔽规则列表',
+ 'desc' => '支持添加多条广告屏蔽规则',
+ 'button_title' => '添加规则',
+ 'accordion_title_number' => true,
+ 'dependency' => [
+ 'adblock',
+ 'any',
+ 'on',
+ ],
+ 'fields' => [
+ [
+ 'id' => 'name',
+ 'type' => 'text',
+ 'title' => __( '规则名称', 'wp-china-yes' ),
+ 'subtitle' => '自定义规则名称',
+ 'desc' => __( '自定义规则名称,方便识别',
+ 'wp-china-yes' ),
+ 'default' => '默认规则',
+ ],
+ [
+ 'id' => 'selector',
+ 'type' => 'textarea',
+ 'title' => __( '应用元素', 'wp-china-yes' ),
+ 'subtitle' => '规则应用元素',
+ 'desc' => __( '设置规则应用的广告元素(CSS 选择器)',
+ 'wp-china-yes' ),
+ 'default' => '.wpseo_content_wrapper #sidebar-container, .yoast_premium_upsell, #wpseo-local-seo-upsell, .yoast-settings-section-upsell, #rank_math_review_plugin_notice, #bwp-get-social, .bwp-button-paypal, #bwp-sidebar-right, .tjcc-custom-css #postbox-container-1, .settings_page_wpcustomtaxfilterinadmin #postbox-container-1, #duplicate-post-notice #newsletter-subscribe-form, div[id^="dnh-wrm"], .notice-info.dst-notice, #googleanalytics_terms_notice, .fw-brz-dismiss, div.elementor-message[data-notice_id="elementor_dev_promote"], .notice-success.wpcf7r-notice, .dc-text__block.disable__comment__alert, #ws_sidebar_pro_ad, .pa-new-feature-notice, #redux-connect-message, .frash-notice-email, .frash-notice-rate, #smush-box-pro-features, #wp-smush-bulk-smush-upsell-row, #easy-updates-manager-dashnotice, #metaslider-optin-notice, #extendifysdk_announcement, .ml-discount-ad, .mo-admin-notice, .post-smtp-donation, div[data-dismissible="notice-owa-sale-forever"], .neve-notice-upsell, #pagelayer_promo, #simple-custom-post-order-epsilon-review-notice, .sfsi_new_prmium_follw, div.fs-slug-the-events-calendar[data-id="connect_account"], .tribe-notice-event-tickets-install, div.notice[data-notice="webp-converter-for-media"], .webpLoader__popup.webpPopup, .put-dismiss-notice, .wp-mail-smtp-review-notice, #wp-mail-smtp-pro-banner, body div.promotion.fs-notice, .analytify-review-thumbnail, .analytify-review-notice, .jitm-banner.is-upgrade-premium, div[data-name*="wbcr_factory_notice_adverts"], .sui-subscription-notice, #sui-cross-sell-footer, .sui-cross-sell-modules, .forminator-rating-notice, .sui-dashboard-upsell-upsell, .anwp-post-grid__rate, .cff-settings-cta, .cff-header-upgrade-notice, .cff_notice.cff_review_notice_step_1, .cff_get_pro_highlight, .aal-install-elementor, #ws_sidebar_pro_ad, .bold-timeline-lite-feedback-notice-wrapper, #elementskit-lite-go-pro-noti2ce, #elementskit-lite-_plugin_rating_msg_used_in_day, .yarpp-review-notice, #prli_review_notice, #webdados_invoicexpress_nag, #vc_license-activation-notice, .villatheme-dashboard.updated, #njt-FileBird-review, .notice[data-dismissible="pro_release_notice"], #thwvsf_review_request_notice, .wpdeveloper-review-notice, div[data-notice_type="tinvwl-user-review"], div[data-notice_type="tinvwl-user-premium"], #sg-backup-review-wrapper, .notice-wpmet-jhanda-getgenie-cross-promo, .notice-getgenie-go-pro-noti2ce, .notice-wpmet-jhanda-Summer2023, .thwcfd-review-wrapper, .woo-permalink-manager-banner, div.notice.bundle-notice, div.notice[data-dismissible="notice-owa-upgrade-forever"], .wpsm-acc-r-review-notice, .wpsm_ac_h_i, .edac-review-notice, .notice-iworks-rate, #monterinsights-admin-menu-tooltip, .monsterinsights-floating-bar, #monterinsights-admin-menu-tooltip, .exactmetrics-floating-bar, #metform-unsupported-metform-pro-version, .lwptocRate, .wpsm-tabs-b-review-notice, .quadlayers_woocommerce-direct-checkout_notice_delay, .iworks-rate-notice, #metform-_plugin_rating_msg_used_in_day, [id^="wpmet-jhanda-"], #wpmet-stories, #ti-optml-notice-helper, .menu-icon-dashboard-notice, .catch-bells-admin-notice, .wpdt-bundles-notice, .td-admin-web-services, .cf-plugin-popup, .wpzinc-review-media-library-organizer, .oxi-image-notice',
+ 'sanitize' => false,
+ ],
+ [
+ 'id' => 'enable',
+ 'type' => 'switcher',
+ 'title' => __( '启用规则', 'wp-china-yes' ),
+ 'subtitle' => '是否启用该规则',
+ 'default' => true,
+ ],
+ ],
+ ],
+ [
+ 'type' => 'content',
+ 'content' => '默认屏蔽规则跟随插件更新,插件更新后可删除规则重新添加以获取最新屏蔽规则',
+ ],
+ ],
+ ] );
- $this->setting_api->set_sections( $sections );
- $this->setting_api->set_fields( $fields );
- $this->setting_api->admin_init();
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '其他设置',
+ 'icon' => 'fa fa-cogs',
+ 'fields' => [
+ [
+ 'id' => 'monitor',
+ 'type' => 'switcher',
+ 'default' => true,
+ 'title' => '节点监控',
+ 'subtitle' => '自动监控加速节点可用性',
+ 'desc' => __( '文派叶子🍃(WP-China-Yes)支持自动监控各加速节点可用性,当节点不可用时自动切换至可用节点或关闭加速,以保证您的网站正常访问',
+ 'wp-china-yes' ),
+ ],
+ [
+ 'id' => 'hide',
+ 'type' => 'switcher',
+ 'default' => false,
+ 'title' => '隐藏设置',
+ 'subtitle' => '隐藏插件设置入口',
+ 'desc' => __( '如果您不希望让客户知道本站启用了文派叶子🍃(WP-China-Yes)插件及服务,可开启此选项',
+ 'wp-china-yes' ),
+ ],
+ [
+ 'id' => 'custom_name',
+ 'type' => 'text',
+ 'title' => '品牌白标',
+ 'subtitle' => '自定义插件显示品牌名',
+ 'desc' => __( '专为 WordPress 建站服务商和代理机构提供的自定义品牌功能,输入您的品牌词启用后生效',
+ 'wp-china-yes' ),
+ 'default' => "WP-China-Yes",
+ ],
+ [
+ 'type' => 'content',
+ 'content' => '启用隐藏设置前请务必保存当前设置页面 URL,否则您将无法再次进入插件设置页面',
+ ],
+ ],
+ ] );
+
+ WP_CHINA_YES::createSection( $this->prefix, [
+ 'title' => '关于插件',
+ 'icon' => 'fa fa-info-circle',
+ 'fields' => [
+ [
+ 'type' => 'heading',
+ 'content' => '将您的 WordPress 接入本土生态体系,这将为您提供一个更贴近中国人使用习惯的 WordPress',
+ ],
+ [
+ 'type' => 'submessage',
+ 'content' => '100% 开源代码,一起参与文派(WordPress)软件国产化进程,打造属于您自己的开源自助建站程序',
+ ],
+ [
+ 'type' => 'subheading',
+ 'content' => '项目简介',
+ ],
+ [
+ 'type' => 'content',
+ 'content' => '文派叶子 🍃(WP-China-Yes)是一款不可多得的 WordPress 系统底层优化和生态基础设施软件。项目起源于 2019 年,专为解决困扰了中国互联网数十年的特色问题而存在。此为文派开源(WenPai.org)的一部分',
+ ],
+ [
+ 'type' => 'subheading',
+ 'content' => '赞助商',
+ ],
+ [
+ 'type' => 'content',
+ 'content' =>
+ <<
+
+
+
+
+
+
+
+
+
+
+
+HTML,
+ ],
+ [
+ 'type' => 'subheading',
+ 'content' => '开发者 & 贡献者',
+ ],
+ [
+ 'type' => 'content',
+ 'content' =>
+ <<孙锡源 |
+耗子 |
+Yulinn |
+赵丰 |
+jialong Dong |
+TigerKK |
+xianyu125 |
+ElliotHughes |
+诗语 |
+莫蒂奇 |
+薇晓朵
+HTML,
+ ]
+ ],
+ ] );
}
/**
@@ -137,15 +398,6 @@ class Setting {
* 挂载设置页面
*/
public function admin_menu() {
- // 后台设置
- add_submenu_page(
- is_multisite() ? 'settings.php' : 'options-general.php',
- esc_html__( 'WP-China-Yes', 'wp-china-yes' ),
- esc_html__( 'WP-China-Yes', 'wp-china-yes' ),
- is_multisite() ? 'manage_network_options' : 'manage_options',
- 'wp-china-yes',
- [ $this, 'setting_page' ]
- );
// 插件页设置
add_filter( 'plugin_action_links', function ( $links, $file ) {
if ( 'wp-china-yes/wp-china-yes.php' !== $file ) {
@@ -159,76 +411,4 @@ class Setting {
return $links;
}, 10, 2 );
}
-
- /**
- * 设置页面模版
- */
- public function setting_page() {
- echo <<
-
提示:插件会定期检查节点可用性,并在节点不可用时自动切换至可用节点,以保证您的网站正常访问。如您发现设置项被自动切换,可重新设置或关闭自动监控功能。
-帮助:您可以随时在此处调整个性化设置以便适应不同的业务场景,萌新请保持默认即可。此项目的发展离不开您的支持和建议,查看联系方式。
- .wp_china_yes-cloneable-item > .wp_china_yes-cloneable-title",collapsible:!0,active:!1,animate:!1,heightStyle:"content",icons:{header:"wp_china_yes-cloneable-header-icon fas fa-angle-right",activeHeader:"wp_china_yes-cloneable-header-icon fas fa-angle-down"},activate:function(e,t){var i,s,n=t.newPanel,t=t.newHeader;n.length&&!n.data("opened")?(i=t.find(".wp_china_yes-cloneable-value"),s=[],S.each(o,function(e,t){s.push(n.find('[data-depend-id="'+t+'"]'))}),S.each(s,function(e,t){t.on("change keyup wp_china_yes.keyup",function(){var n=[];S.each(s,function(e,t){t=t.val();t&&n.push(t)}),n.length&&i.text(n.join(f))}).trigger("wp_china_yes.keyup")}),n.wp_china_yes_reload_script(),n.data("opened",!0),n.data("retry",!1)):n.data("retry")&&(n.wp_china_yes_reload_script_retry(),n.data("retry",!1))}}),c.sortable({axis:"y",handle:".wp_china_yes-cloneable-title,.wp_china_yes-cloneable-sort",helper:"original",cursor:"move",placeholder:"widget-placeholder",start:function(e,t){c.accordion({active:!1}),c.sortable("refreshPositions"),t.item.children(".wp_china_yes-cloneable-content").data("retry",!0)},update:function(e,t){j.helper.name_nested_replace(c.children(".wp_china_yes-cloneable-item"),l),c.wp_china_yes_customizer_refresh(),d&&u(c)}}),i.children(".wp_china_yes-cloneable-add").on("click",function(e){e.preventDefault();var t=c.children(".wp_china_yes-cloneable-item").length;r.hide(),h&&h '+t+" '. esc_html__( 'Field not found!', 'wp_china_yes' ) .' '. esc_html__( 'Field not found!', 'wp_china_yes' ) .'\n
\n
\n\n
'. $field['title'] .'
';
+ echo ( ! empty( $field['subtitle'] ) ) ? '';
+ echo '';
+ echo esc_html( $accordion['title'] );
+ echo '
';
+
+ echo '
';
+ echo '';
+ echo ''. esc_html__( 'Export & Download', 'wp_china_yes' ) .'';
+ echo '
';
+ echo '';
+
+ echo $this->field_after();
+
+ }
+
+ }
+}
diff --git a/framework/fields/border/border.php b/framework/fields/border/border.php
new file mode 100644
index 0000000..e055449
--- /dev/null
+++ b/framework/fields/border/border.php
@@ -0,0 +1,176 @@
+field, array(
+ 'top_icon' => '',
+ 'left_icon' => '',
+ 'bottom_icon' => '',
+ 'right_icon' => '',
+ 'all_icon' => '',
+ 'top_placeholder' => esc_html__( 'top', 'wp_china_yes' ),
+ 'right_placeholder' => esc_html__( 'right', 'wp_china_yes' ),
+ 'bottom_placeholder' => esc_html__( 'bottom', 'wp_china_yes' ),
+ 'left_placeholder' => esc_html__( 'left', 'wp_china_yes' ),
+ 'all_placeholder' => esc_html__( 'all', 'wp_china_yes' ),
+ 'top' => true,
+ 'left' => true,
+ 'bottom' => true,
+ 'right' => true,
+ 'all' => false,
+ 'color' => true,
+ 'style' => true,
+ 'unit' => 'px',
+ ) );
+
+ $default_value = array(
+ 'top' => '',
+ 'right' => '',
+ 'bottom' => '',
+ 'left' => '',
+ 'color' => '',
+ 'style' => 'solid',
+ 'all' => '',
+ );
+
+ $border_props = array(
+ 'solid' => esc_html__( 'Solid', 'wp_china_yes' ),
+ 'dashed' => esc_html__( 'Dashed', 'wp_china_yes' ),
+ 'dotted' => esc_html__( 'Dotted', 'wp_china_yes' ),
+ 'double' => esc_html__( 'Double', 'wp_china_yes' ),
+ 'inset' => esc_html__( 'Inset', 'wp_china_yes' ),
+ 'outset' => esc_html__( 'Outset', 'wp_china_yes' ),
+ 'groove' => esc_html__( 'Groove', 'wp_china_yes' ),
+ 'ridge' => esc_html__( 'ridge', 'wp_china_yes' ),
+ 'none' => esc_html__( 'None', 'wp_china_yes' )
+ );
+
+ $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
+
+ $value = wp_parse_args( $this->value, $default_value );
+
+ echo $this->field_before();
+
+ echo '';
+
+ foreach ( $options as $option_key => $option_value ) {
+
+ if ( is_array( $option_value ) && ! empty( $option_value ) ) {
+
+ echo '
';
+
+ if ( $args['check_all'] ) {
+ echo '';
+ echo '
';
+ echo '';
+ if ( ! empty( $this->value ) ) {
+
+ $values = explode( ',', $this->value );
+
+ foreach ( $values as $id ) {
+ $attachment = wp_get_attachment_image_src( $id, 'thumbnail' );
+ echo '
';
+
+ echo ''. $args['add_title'] .'';
+ echo ''. $args['edit_title'] .'';
+ echo ''. $args['clear_title'] .'';
+ echo 'field_attributes() .'/>';
+
+ echo $this->field_after();
+
+ }
+
+ }
+}
diff --git a/framework/fields/group/group.php b/framework/fields/group/group.php
new file mode 100644
index 0000000..6d06c34
--- /dev/null
+++ b/framework/fields/group/group.php
@@ -0,0 +1,164 @@
+field, array(
+ 'max' => 0,
+ 'min' => 0,
+ 'fields' => array(),
+ 'button_title' => esc_html__( 'Add New', 'wp_china_yes' ),
+ 'accordion_title_prefix' => '',
+ 'accordion_title_number' => false,
+ 'accordion_title_auto' => true,
+ 'accordion_title_by' => array(),
+ 'accordion_title_by_prefix' => ' ',
+ ) );
+
+ $title_prefix = ( ! empty( $args['accordion_title_prefix'] ) ) ? $args['accordion_title_prefix'] : '';
+ $title_number = ( ! empty( $args['accordion_title_number'] ) ) ? true : false;
+ $title_auto = ( ! empty( $args['accordion_title_auto'] ) ) ? true : false;
+ $title_first = ( isset( $this->field['fields'][0]['id'] ) ) ? $this->field['fields'][0]['id'] : $this->field['fields'][1]['id'];
+ $title_by = ( is_array( $args['accordion_title_by'] ) ) ? $args['accordion_title_by'] : (array) $args['accordion_title_by'];
+ $title_by = ( empty( $title_by ) ) ? array( $title_first ) : $title_by;
+ $title_by_prefix = ( ! empty( $args['accordion_title_by_prefix'] ) ) ? $args['accordion_title_by_prefix'] : '';
+
+ if ( preg_match( '/'. preg_quote( '['. $this->field['id'] .']' ) .'/', $this->unique ) ) {
+
+ echo '';
+ echo '';
+ echo ( $title_number ) ? '' : '';
+ echo ( $title_prefix ) ? ''. esc_attr( $title_prefix ) .'' : '';
+ echo ( $title_auto ) ? '' : '';
+ echo '';
+ echo '
';
+
+ echo '';
+ echo '';
+ echo ( $title_number ) ? ''. esc_attr( $num+1 ) .'.' : '';
+ echo ( $title_prefix ) ? ''. esc_attr( $title_prefix ) .'' : '';
+ echo ( $title_auto ) ? '' . esc_attr( $title ) .'' : '';
+ echo '';
+ echo '
';
+
+ echo '';
+ echo 'field_attributes() . esc_attr( $checked ) .'/>';
+ echo '
';
+ echo '
';
+
+ foreach ( $options as $option_key => $option_value ) {
+
+ if ( is_array( $option_value ) && ! empty( $option_value ) ) {
+
+ echo '
';
+
+ } else {
+
+ echo ( ! empty( $this->field['empty_message'] ) ) ? esc_attr( $this->field['empty_message'] ) : esc_html__( 'No data available.', 'wp_china_yes' );
+
+ }
+
+ } else {
+
+ $label = ( isset( $this->field['label'] ) ) ? $this->field['label'] : '';
+ echo '';
+
+ }
+
+ echo $this->field_after();
+
+ }
+
+ }
+}
diff --git a/framework/fields/repeater/repeater.php b/framework/fields/repeater/repeater.php
new file mode 100644
index 0000000..92f2ec2
--- /dev/null
+++ b/framework/fields/repeater/repeater.php
@@ -0,0 +1,108 @@
+field, array(
+ 'max' => 0,
+ 'min' => 0,
+ 'button_title' => '',
+ ) );
+
+ if ( preg_match( '/'. preg_quote( '['. $this->field['id'] .']' ) .'/', $this->unique ) ) {
+
+ echo '';
+ echo '
';
+ echo '';
+ if ( ! empty( $enabled_options ) ) {
+ foreach ( $enabled_options as $key => $value ) {
+ echo '';
+ }
+ }
+ echo '
';
+
+ // Check for hide/show disabled section
+ if ( $args['disabled'] ) {
+
+ echo '';
+ if ( ! empty( $disabled_options ) ) {
+ foreach ( $disabled_options as $key => $value ) {
+ echo '';
+ }
+ }
+ echo '
';
+ echo '';
+ echo '