mirror of
https://github.com/WenPai-org/wp-china-yes.git
synced 2025-08-03 11:11:30 +08:00
Compare commits
42 commits
Author | SHA1 | Date | |
---|---|---|---|
|
64748fe6ff | ||
|
70af2db0f5 | ||
|
8beff870f2 | ||
|
bfec4c147e | ||
|
6083aa8057 | ||
|
f9a7968c00 | ||
|
5370b07c36 | ||
|
8d3a71414d | ||
|
7e08f33923 | ||
|
fdce4da05e | ||
|
eda5b77a48 | ||
|
9ea04f6ac4 | ||
|
33e0545965 | ||
|
071d022ccf | ||
|
8c29188c1b | ||
|
f2a89c42da | ||
|
a500ff9b6d | ||
|
25fdf04fcc | ||
|
435ffd6980 | ||
|
adb8efd320 | ||
|
7121b4b7ef | ||
|
789c920032 | ||
|
2b7c57a427 | ||
|
82ca5e5dc4 | ||
|
a87985970d | ||
|
b0a4bc3d42 | ||
|
219631bc7e | ||
|
cb06d1bef4 | ||
|
cb98197084 | ||
|
9c678616f2 | ||
|
ada09d9f8c | ||
|
210e2ffbce | ||
|
529bb10f34 | ||
|
2391c18bae | ||
|
dd912a9e31 | ||
|
7f1b9a5672 | ||
|
73f4d6eba5 | ||
|
a2675c4fc6 | ||
|
8a4d74e997 | ||
|
de8b6ccaa6 | ||
|
4a7c871c5c | ||
|
ce02646463 |
106 changed files with 13145 additions and 564 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
.idea
|
||||
vendor
|
55
CHANGELOG.md
55
CHANGELOG.md
|
@ -2,6 +2,61 @@
|
|||
|
||||
All notable changes to `WP-China-Yes` will be documented in this file.
|
||||
|
||||
## v3.8 - 2025-02-05
|
||||
|
||||
* 文派叶子 v3.8 重大更新!全新UI 设计更接近 WordPress 原生体验。
|
||||
|
||||
1. 替换业务域名 WP-China-Yes.com 为新域名 WPCY.COM ;
|
||||
2. 修复 adminCDN 支持 jsDelivr 加速无效等问题;
|
||||
3. 新增 Bootstrap CDN 转接至 adminCDN 加速支持;
|
||||
4. 新增 Windfonts 中文排版优化:支持段首空格 2em;
|
||||
5. 新增 Windfonts 中文排版优化:支持文本内容对齐;
|
||||
6. 新增 [脉云维护] 菜单并支持WP系统状态监控,可在页脚位置显示内存、CPU用量等信息;
|
||||
7. 新增 [欢迎使用] 用户引导页面,更清晰的功能指导和简介。
|
||||
8. 新增 [建站工具] 文派·寻鹿建站套件展示页面,内容待完善。
|
||||
9. 优化 [萌芽加速] 设置,与 WordPress 程序端加速选项分离便于添加后续项目;
|
||||
10. 优化 [关于插件] 页面更简约的赞助商 Logo 和贡献者名单展示。
|
||||
11. 补充 changelog.txt 文本文件,跟随插件副本分发。
|
||||
12. 补充 copyright.txt 版权文件,跟随插件副本分发。
|
||||
|
||||
## v3.7.1 - 2024-11-19
|
||||
|
||||
1. 性能优化
|
||||
2. 修复监控无法关闭的问题
|
||||
|
||||
**Full Changelog**: https://github.com/WenPai-org/wp-china-yes/compare/v3.6.5...v3.7.1
|
||||
|
||||
## v3.6.5 - 2024-08-23
|
||||
|
||||
1. 优化 CLI 判断
|
||||
2. 回退替换钩子修改
|
||||
|
||||
**Full Changelog**: https://github.com/WenPai-org/wp-china-yes/compare/v3.6.4...v3.6.5
|
||||
|
||||
## v3.6.4 - 2024-08-23
|
||||
|
||||
1. WP-CLI 下不运行 adminCDN 部分,防止影响缓冲区。
|
||||
2. 部分文案调整支持多语言。
|
||||
|
||||
**Full Changelog**: https://github.com/WenPai-org/wp-china-yes/compare/v3.6.3...v3.6.4
|
||||
|
||||
## v3.6.3 - 2024-08-23
|
||||
|
||||
1. 为自动监控功能添加开关
|
||||
2. adminCDN 支持 jsDelivr 加速
|
||||
3. Windfonts 支持优化模式开关
|
||||
|
||||
**adminCDN 的 jsd 加速默认屏蔽 gh 端点,如有主题插件作者需要使用请联系加白。**
|
||||
**Full Changelog**: https://github.com/WenPai-org/wp-china-yes/compare/v3.6.2...v3.6.3
|
||||
|
||||
## v3.6.2 - 2024-03-09
|
||||
|
||||
1. UI 重构
|
||||
2. 修复市场加速导致 Beta 测试插件失效的问题
|
||||
3. 更新接口及测试 URL
|
||||
|
||||
**Full Changelog**: https://github.com/WenPai-org/wp-china-yes/compare/v3.6.1...v3.6.2
|
||||
|
||||
## v3.6.1 - 2024-03-08
|
||||
|
||||
1. 重构全部代码
|
||||
|
|
22
Plugin.php
Normal file → Executable file
22
Plugin.php
Normal file → Executable file
|
@ -5,17 +5,17 @@ namespace WenPai\ChinaYes;
|
|||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use WenPai\ChinaYes\Service\Base;
|
||||
use WenPai\ChinaYes\Service\Setting;
|
||||
|
||||
class Plugin {
|
||||
|
||||
/**
|
||||
* 创建一个插件实例
|
||||
* 创建插件实例
|
||||
*/
|
||||
public function __construct() {
|
||||
new Base();
|
||||
new Setting();
|
||||
add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
|
||||
if ( is_admin() ) {
|
||||
add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,6 +40,15 @@ class Plugin {
|
|||
public function plugins_loaded() {
|
||||
load_plugin_textdomain( 'wp-china-yes', false, CHINA_YES_PLUGIN_PATH . 'languages' );
|
||||
add_action( 'admin_notices', [ $this, 'admin_notices' ] );
|
||||
/**
|
||||
* 插件列表页中所有插件增加「参与翻译」链接
|
||||
*/
|
||||
add_filter( sprintf( '%splugin_action_links', is_multisite() ? 'network_admin_' : '' ), function ( $links, $plugin = '' ) {
|
||||
$links[] = '<a target="_blank" href="https://translate.wenpai.org/projects/plugins/' . substr( $plugin, 0, strpos( $plugin, '/' ) ) . '/">参与翻译</a>';
|
||||
$links[] = '<a target="_blank" href="https://wpcy.com/plugins/' . substr( $plugin, 0, strpos( $plugin, '/' ) ) . '/">去广告</a>';
|
||||
|
||||
return $links;
|
||||
}, 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,9 +56,9 @@ class Plugin {
|
|||
*/
|
||||
public static function check() {
|
||||
$notices = [];
|
||||
if ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) {
|
||||
if ( version_compare( PHP_VERSION, '7.0.0', '<' ) ) {
|
||||
deactivate_plugins( 'wp-china-yes/wp-china-yes.php' );
|
||||
$notices[] = '<div class="notice notice-error"><p>' . sprintf( __( 'WP-China-Yes 插件需要 PHP 5.6.0 或更高版本,当前版本为 %s,插件已自动禁用。',
|
||||
$notices[] = '<div class="notice notice-error"><p>' . sprintf( __( 'WP-China-Yes 插件需要 PHP 7.0.0 或更高版本,当前版本为 %s,插件已自动禁用。',
|
||||
'wp-china-yes' ),
|
||||
PHP_VERSION ) . '</p></div>';
|
||||
}
|
||||
|
@ -70,7 +79,6 @@ class Plugin {
|
|||
$notices[] = '<div class="notice notice-error is-dismissible">
|
||||
<p><strong>' . __( '检测到不兼容的插件 Kill 429,已自动禁用!', 'wp-china-yes' ) . '</strong></p>
|
||||
</div>';
|
||||
|
||||
}
|
||||
// 代理服务器检测
|
||||
if ( defined( 'WP_PROXY_HOST' ) || defined( 'WP_PROXY_PORT' ) ) {
|
||||
|
|
169
Service/123-Maintenance.php
Executable file
169
Service/123-Maintenance.php
Executable file
|
@ -0,0 +1,169 @@
|
|||
<?php
|
||||
namespace WenPai\ChinaYes\Service;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use function WenPai\ChinaYes\get_settings;
|
||||
|
||||
class Maintenance {
|
||||
private $settings;
|
||||
private $allowed_pages = [
|
||||
'wp-login.php',
|
||||
'wp-register.php',
|
||||
'wp-cron.php',
|
||||
'async-upload.php',
|
||||
'admin-ajax.php'
|
||||
];
|
||||
|
||||
public function __construct() {
|
||||
// 使用更早的钩子并设置高优先级
|
||||
add_action('plugins_loaded', [$this, 'init'], 1);
|
||||
}
|
||||
|
||||
public function init() {
|
||||
$this->settings = get_settings();
|
||||
|
||||
// 仅在调试模式下输出调试信息
|
||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
||||
error_log('Maintenance Settings Raw: ' . print_r($this->settings, true));
|
||||
error_log('Maintenance Mode Value: ' . var_export($this->settings['maintenance_mode'], true));
|
||||
}
|
||||
|
||||
// 如果维护模式启用,挂载相关钩子
|
||||
if ($this->settings['maintenance_mode']) {
|
||||
add_action('template_redirect', [$this, 'check_maintenance_mode'], 1);
|
||||
add_action('admin_bar_menu', [$this, 'add_admin_bar_notice'], 100);
|
||||
add_action('init', [$this, 'check_ajax_maintenance'], 1);
|
||||
}
|
||||
}
|
||||
|
||||
public function check_ajax_maintenance() {
|
||||
if (wp_doing_ajax() && !current_user_can('manage_options')) {
|
||||
wp_die('维护模式已启用');
|
||||
}
|
||||
}
|
||||
|
||||
public function check_maintenance_mode() {
|
||||
// 如果是命令行环境,直接返回
|
||||
if (php_sapi_name() === 'cli') {
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果是管理员,直接返回
|
||||
if (current_user_can('manage_options')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否是允许的页面
|
||||
global $pagenow;
|
||||
if (in_array($pagenow, $this->allowed_pages)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否是后台请求
|
||||
if (is_admin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否是 REST API 请求
|
||||
if (defined('REST_REQUEST') && REST_REQUEST) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否是 AJAX 请求
|
||||
if (wp_doing_ajax()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示维护页面
|
||||
$this->show_maintenance_page();
|
||||
}
|
||||
|
||||
private function show_maintenance_page() {
|
||||
$maintenance_settings = $this->settings['maintenance_settings'] ?? [];
|
||||
|
||||
$title = $maintenance_settings['maintenance_title'] ?? '网站维护中';
|
||||
$heading = $maintenance_settings['maintenance_heading'] ?? '网站维护中';
|
||||
$message = $maintenance_settings['maintenance_message'] ?? '网站正在进行例行维护,请稍后访问。感谢您的理解与支持!';
|
||||
|
||||
// 添加基本的样式
|
||||
$style = '
|
||||
<style>
|
||||
body {
|
||||
background: #f1f1f1;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
}
|
||||
.maintenance-wrapper {
|
||||
text-align: center;
|
||||
padding: 50px 20px;
|
||||
max-width: 800px;
|
||||
margin: 100px auto;
|
||||
background: white;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
}
|
||||
.maintenance-wrapper h1 {
|
||||
color: #333;
|
||||
font-size: 36px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.maintenance-wrapper h2 {
|
||||
color: #666;
|
||||
font-size: 24px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.maintenance-message {
|
||||
color: #555;
|
||||
line-height: 1.6;
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
';
|
||||
|
||||
$output = $style . sprintf(
|
||||
'<div class="maintenance-wrapper">
|
||||
<h1>%s</h1>
|
||||
<h2>%s</h2>
|
||||
<div class="maintenance-message">%s</div>
|
||||
</div>',
|
||||
esc_html($heading),
|
||||
esc_html($title),
|
||||
wp_kses_post($message)
|
||||
);
|
||||
|
||||
// 设置维护模式响应头
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 503 Service Temporarily Unavailable');
|
||||
header('Status: 503 Service Temporarily Unavailable');
|
||||
header('Retry-After: 3600');
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
}
|
||||
|
||||
// 确保输出被清空
|
||||
if (ob_get_level()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
wp_die($output, $title, [
|
||||
'response' => 503,
|
||||
'back_link' => false
|
||||
]);
|
||||
}
|
||||
|
||||
public function add_admin_bar_notice($wp_admin_bar) {
|
||||
if (!current_user_can('manage_options')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 添加调试信息
|
||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
||||
error_log('Admin bar notice added for maintenance mode.');
|
||||
}
|
||||
|
||||
$wp_admin_bar->add_node([
|
||||
'id' => 'maintenance-mode-notice',
|
||||
'title' => '<span style="color: #ff0000;">维护模式已启用</span>',
|
||||
'href' => admin_url('admin.php?page=wp-china-yes#tab=脉云维护')
|
||||
]);
|
||||
}
|
||||
}
|
256
Service/Acceleration.php
Executable file
256
Service/Acceleration.php
Executable file
|
@ -0,0 +1,256 @@
|
|||
<?php
|
||||
|
||||
namespace WenPai\ChinaYes\Service;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use function WenPai\ChinaYes\get_settings;
|
||||
|
||||
class Acceleration {
|
||||
private $settings;
|
||||
|
||||
public function __construct() {
|
||||
$this->settings = get_settings();
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化 admincdn 功能
|
||||
*/
|
||||
private function init() {
|
||||
if (!empty($this->settings['admincdn'])) {
|
||||
add_action('wp_head', function () {
|
||||
echo "<!-- 此站点使用的前端静态资源库由萌芽加速(adminCDN)提供,智能加速转接基于文派叶子 WPCY.COM -->\n";
|
||||
}, 1);
|
||||
}
|
||||
|
||||
$this->load_admincdn();
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载 admincdn 功能
|
||||
*/
|
||||
private function load_admincdn() {
|
||||
// 确保 $this->settings 中包含必要的键
|
||||
$this->settings['admincdn_files'] = $this->settings['admincdn_files'] ?? [];
|
||||
$this->settings['admincdn_public'] = $this->settings['admincdn_public'] ?? [];
|
||||
$this->settings['admincdn_dev'] = $this->settings['admincdn_dev'] ?? [];
|
||||
|
||||
// WordPress 核心静态文件链接替换
|
||||
if (is_admin() && !(defined('DOING_AJAX') && DOING_AJAX)) {
|
||||
if (
|
||||
in_array('admin', (array) $this->settings['admincdn']) &&
|
||||
!stristr($GLOBALS['wp_version'], 'alpha') &&
|
||||
!stristr($GLOBALS['wp_version'], 'beta') &&
|
||||
!stristr($GLOBALS['wp_version'], 'RC')
|
||||
) {
|
||||
// 禁用合并加载,以便于使用公共资源节点
|
||||
global $concatenate_scripts;
|
||||
$concatenate_scripts = false;
|
||||
|
||||
$this->page_str_replace('init', 'preg_replace', [
|
||||
'~' . home_url('/') . '(wp-admin|wp-includes)/(css|js)/~',
|
||||
sprintf('https://wpstatic.admincdn.com/%s/$1/$2/', $GLOBALS['wp_version'])
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 前台静态加速
|
||||
if (in_array('frontend', (array) $this->settings['admincdn_files'])) {
|
||||
$this->page_str_replace('template_redirect', 'preg_replace', [
|
||||
'#(?<=[(\"\'])(?:' . quotemeta(home_url()) . ')?/(?:((?:wp-content|wp-includes)[^\"\')]+\.(css|js)[^\"\')]+))(?=[\"\')])#',
|
||||
'https://public.admincdn.com/$0'
|
||||
]);
|
||||
}
|
||||
|
||||
// Google 字体替换
|
||||
if (in_array('googlefonts', (array) $this->settings['admincdn_public'])) {
|
||||
$this->page_str_replace('init', 'str_replace', [
|
||||
'fonts.googleapis.com',
|
||||
'googlefonts.admincdn.com'
|
||||
]);
|
||||
}
|
||||
|
||||
// Google 前端公共库替换
|
||||
if (in_array('googleajax', (array) $this->settings['admincdn_public'])) {
|
||||
$this->page_str_replace('init', 'str_replace', [
|
||||
'ajax.googleapis.com',
|
||||
'googleajax.admincdn.com'
|
||||
]);
|
||||
}
|
||||
|
||||
// CDNJS 前端公共库替换
|
||||
if (in_array('cdnjs', (array) $this->settings['admincdn_public'])) {
|
||||
$this->page_str_replace('init', 'str_replace', [
|
||||
'cdnjs.cloudflare.com/ajax/libs',
|
||||
'cdnjs.admincdn.com'
|
||||
]);
|
||||
}
|
||||
|
||||
// jsDelivr 前端公共库替换
|
||||
if (in_array('jsdelivr', (array) $this->settings['admincdn_public'])) {
|
||||
$this->page_str_replace('init', 'str_replace', [
|
||||
'cdn.jsdelivr.net',
|
||||
'jsd.admincdn.com'
|
||||
]);
|
||||
}
|
||||
|
||||
// BootstrapCDN 前端公共库替换
|
||||
if (in_array('bootstrapcdn', (array) $this->settings['admincdn_public'])) {
|
||||
$this->page_str_replace('init', 'str_replace', [
|
||||
'maxcdn.bootstrapcdn.com',
|
||||
'jsd.admincdn.com'
|
||||
]);
|
||||
}
|
||||
|
||||
// Emoji 资源加速 - 使用 Twitter Emoji
|
||||
if (in_array('emoji', (array) $this->settings['admincdn_files'])) {
|
||||
$this->replace_emoji();
|
||||
}
|
||||
|
||||
// WordPress.org 预览资源加速
|
||||
if (in_array('sworg', (array) $this->settings['admincdn_files'])) {
|
||||
$this->replace_sworg();
|
||||
}
|
||||
|
||||
// React 前端库加速
|
||||
if (in_array('react', (array) $this->settings['admincdn_dev'])) {
|
||||
$this->page_str_replace('init', 'str_replace', [
|
||||
'unpkg.com/react',
|
||||
'jsd.admincdn.com/npm/react'
|
||||
]);
|
||||
}
|
||||
|
||||
// jQuery 前端库加速
|
||||
if (in_array('jquery', (array) $this->settings['admincdn_dev'])) {
|
||||
$this->page_str_replace('init', 'str_replace', [
|
||||
'code.jquery.com',
|
||||
'jsd.admincdn.com/npm/jquery'
|
||||
]);
|
||||
}
|
||||
|
||||
// Vue.js 前端库加速
|
||||
if (in_array('vuejs', (array) $this->settings['admincdn_dev'])) {
|
||||
$this->page_str_replace('init', 'str_replace', [
|
||||
'unpkg.com/vue',
|
||||
'jsd.admincdn.com/npm/vue'
|
||||
]);
|
||||
}
|
||||
|
||||
// DataTables 前端库加速
|
||||
if (in_array('datatables', (array) $this->settings['admincdn_dev'])) {
|
||||
$this->page_str_replace('init', 'str_replace', [
|
||||
'cdn.datatables.net',
|
||||
'jsd.admincdn.com/npm/datatables.net'
|
||||
]);
|
||||
}
|
||||
|
||||
// Tailwind CSS 加速
|
||||
if (in_array('tailwindcss', (array) $this->settings['admincdn_dev'])) {
|
||||
$this->page_str_replace('init', 'str_replace', [
|
||||
'unpkg.com/tailwindcss',
|
||||
'jsd.admincdn.com/npm/tailwindcss'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换 Emoji 资源
|
||||
*/
|
||||
private function replace_emoji() {
|
||||
// 禁用 WordPress 默认的 emoji 处理
|
||||
remove_action('wp_head', 'print_emoji_detection_script', 7);
|
||||
remove_action('admin_print_scripts', 'print_emoji_detection_script');
|
||||
remove_action('wp_print_styles', 'print_emoji_styles');
|
||||
remove_action('admin_print_styles', 'print_emoji_styles');
|
||||
remove_filter('the_content_feed', 'wp_staticize_emoji');
|
||||
remove_filter('comment_text_rss', 'wp_staticize_emoji');
|
||||
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
|
||||
|
||||
// 替换 emoji 图片路径
|
||||
$this->page_str_replace('init', 'str_replace', [
|
||||
's.w.org/images/core/emoji',
|
||||
'jsd.admincdn.com/npm/@twemoji/api/dist'
|
||||
]);
|
||||
|
||||
// 替换 wpemojiSettings 配置
|
||||
add_action('wp_head', function () {
|
||||
?>
|
||||
<script>
|
||||
window._wpemojiSettings = {
|
||||
"baseUrl": "https://jsd.admincdn.com/npm/@twemoji/api@15.0.3/dist/72x72/",
|
||||
"ext": ".png",
|
||||
"svgUrl": "https://jsd.admincdn.com/npm/@twemoji/api@15.0.3/dist/svg/",
|
||||
"svgExt": ".svg",
|
||||
"source": {
|
||||
"concatemoji": "<?php echo includes_url('js/wp-emoji-release.min.js'); ?>"
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<?php
|
||||
}, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换 WordPress.org 预览资源
|
||||
*/
|
||||
private function replace_sworg() {
|
||||
$this->page_str_replace('init', 'str_replace', [
|
||||
'ts.w.org',
|
||||
'ts.wenpai.net'
|
||||
]);
|
||||
|
||||
// 替换主题预览图片 URL
|
||||
add_filter('theme_screenshot_url', function ($url) {
|
||||
if (strpos($url, 'ts.w.org') !== false) {
|
||||
$url = str_replace('ts.w.org', 'ts.wenpai.net', $url);
|
||||
}
|
||||
return $url;
|
||||
});
|
||||
|
||||
// 过滤主题 API 响应
|
||||
add_filter('themes_api_result', function ($res, $action, $args) {
|
||||
if (is_object($res) && !empty($res->screenshots)) {
|
||||
foreach ($res->screenshots as &$screenshot) {
|
||||
if (isset($screenshot->src)) {
|
||||
$screenshot->src = str_replace('ts.w.org', 'ts.wenpai.net', $screenshot->src);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}, 10, 3);
|
||||
|
||||
// 替换页面内容
|
||||
add_action('admin_init', function () {
|
||||
ob_start(function ($content) {
|
||||
return str_replace('ts.w.org', 'ts.wenpai.net', $content);
|
||||
});
|
||||
});
|
||||
|
||||
// 确保前台内容替换
|
||||
add_action('template_redirect', function () {
|
||||
ob_start(function ($content) {
|
||||
return str_replace('ts.w.org', 'ts.wenpai.net', $content);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面字符串替换
|
||||
*
|
||||
* @param string $hook 钩子名称
|
||||
* @param string $replace_func 替换函数
|
||||
* @param array $param 替换参数
|
||||
*/
|
||||
private function page_str_replace($hook, $replace_func, $param) {
|
||||
if (php_sapi_name() == 'cli') {
|
||||
return;
|
||||
}
|
||||
add_action($hook, function () use ($replace_func, $param) {
|
||||
ob_start(function ($buffer) use ($replace_func, $param) {
|
||||
$param[] = $buffer;
|
||||
return call_user_func_array($replace_func, $param);
|
||||
});
|
||||
}, PHP_INT_MAX);
|
||||
}
|
||||
}
|
46
Service/Adblock.php
Executable file
46
Service/Adblock.php
Executable file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace WenPai\ChinaYes\Service;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use function WenPai\ChinaYes\get_settings;
|
||||
|
||||
/**
|
||||
* Class Adblock
|
||||
* 广告拦截服务
|
||||
* @package WenPai\ChinaYes\Service
|
||||
*/
|
||||
class Adblock {
|
||||
|
||||
private $settings;
|
||||
|
||||
public function __construct() {
|
||||
$this->settings = get_settings();
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化广告拦截功能
|
||||
*/
|
||||
private function init() {
|
||||
if (!empty($this->settings['adblock']) && $this->settings['adblock'] == 'on') {
|
||||
add_action('admin_head', [$this, 'load_adblock']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载广告拦截
|
||||
*/
|
||||
public function load_adblock() {
|
||||
// 处理广告拦截规则
|
||||
foreach ((array) $this->settings['adblock_rule'] as $rule) {
|
||||
if (empty($rule['enable']) || empty($rule['selector'])) {
|
||||
continue;
|
||||
}
|
||||
echo sprintf('<style>%s{display:none!important;}</style>',
|
||||
htmlspecialchars_decode($rule['selector'])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
98
Service/Avatar.php
Executable file
98
Service/Avatar.php
Executable file
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
namespace WenPai\ChinaYes\Service;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use function WenPai\ChinaYes\get_settings;
|
||||
|
||||
/**
|
||||
* Class Avatar
|
||||
* 初认头像服务
|
||||
* @package WenPai\ChinaYes\Service
|
||||
*/
|
||||
class Avatar {
|
||||
|
||||
private $settings;
|
||||
|
||||
public function __construct() {
|
||||
$this->settings = get_settings();
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化初认头像功能
|
||||
*/
|
||||
private function init() {
|
||||
if (!empty($this->settings['cravatar'])) {
|
||||
add_filter('user_profile_picture_description', [$this, 'set_user_profile_picture_for_cravatar'], 1);
|
||||
add_filter('avatar_defaults', [$this, 'set_defaults_for_cravatar'], 1);
|
||||
add_filter('um_user_avatar_url_filter', [$this, 'get_cravatar_url'], 1);
|
||||
add_filter('bp_gravatar_url', [$this, 'get_cravatar_url'], 1);
|
||||
add_filter('get_avatar_url', [$this, 'get_cravatar_url'], 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Cravatar URL
|
||||
*/
|
||||
public function get_cravatar_url($url) {
|
||||
switch ($this->settings['cravatar']) {
|
||||
case 'cn':
|
||||
return $this->replace_avatar_url($url, 'cn.cravatar.com');
|
||||
case 'global':
|
||||
return $this->replace_avatar_url($url, 'en.cravatar.com');
|
||||
case 'weavatar':
|
||||
return $this->replace_avatar_url($url, 'weavatar.com');
|
||||
default:
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换头像 URL
|
||||
*/
|
||||
public function replace_avatar_url($url, $domain) {
|
||||
$sources = array(
|
||||
'www.gravatar.com',
|
||||
'0.gravatar.com',
|
||||
'1.gravatar.com',
|
||||
'2.gravatar.com',
|
||||
's.gravatar.com',
|
||||
'secure.gravatar.com',
|
||||
'cn.gravatar.com',
|
||||
'en.gravatar.com',
|
||||
'gravatar.com',
|
||||
'sdn.geekzu.org',
|
||||
'gravatar.duoshuo.com',
|
||||
'gravatar.loli.net',
|
||||
'dn-qiniu-avatar.qbox.me'
|
||||
);
|
||||
|
||||
return str_replace($sources, $domain, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 WordPress 讨论设置中的默认 LOGO 名称
|
||||
*/
|
||||
public function set_defaults_for_cravatar($avatar_defaults) {
|
||||
if ($this->settings['cravatar'] == 'weavatar') {
|
||||
$avatar_defaults['gravatar_default'] = 'WeAvatar';
|
||||
} else {
|
||||
$avatar_defaults['gravatar_default'] = '初认头像';
|
||||
}
|
||||
|
||||
return $avatar_defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置个人资料卡中的头像上传地址
|
||||
*/
|
||||
public function set_user_profile_picture_for_cravatar() {
|
||||
if ($this->settings['cravatar'] == 'weavatar') {
|
||||
return '<a href="https://weavatar.com" target="_blank">您可以在 WeAvatar 修改您的资料图片</a>';
|
||||
} else {
|
||||
return '<a href="https://cravatar.com" target="_blank">您可以在初认头像修改您的资料图片</a>';
|
||||
}
|
||||
}
|
||||
}
|
47
Service/Base.php
Normal file → Executable file
47
Service/Base.php
Normal file → Executable file
|
@ -11,21 +11,38 @@ defined( 'ABSPATH' ) || exit;
|
|||
*/
|
||||
class Base {
|
||||
|
||||
public function __construct() {
|
||||
/**
|
||||
* 插件列表页中所有插件增加「参与翻译」链接
|
||||
*/
|
||||
add_filter( sprintf( '%splugin_action_links', is_multisite() ? 'network_admin_' : '' ), function ( $links, $plugin = '' ) {
|
||||
$links[] = '<a target="_blank" href="https://translate.wenpai.org/projects/plugins/' . substr( $plugin, 0, strpos( $plugin, '/' ) ) . '/">参与翻译</a>';
|
||||
public function __construct() {
|
||||
// 确保所有类文件都存在后再实例化
|
||||
if (class_exists(__NAMESPACE__ . '\Super')) {
|
||||
new Super();
|
||||
}
|
||||
|
||||
if (class_exists(__NAMESPACE__ . '\Monitor')) {
|
||||
new Monitor();
|
||||
}
|
||||
|
||||
if (class_exists(__NAMESPACE__ . '\Memory')) {
|
||||
new Memory();
|
||||
}
|
||||
|
||||
if (class_exists(__NAMESPACE__ . '\Update')) {
|
||||
new Update();
|
||||
}
|
||||
|
||||
if (class_exists(__NAMESPACE__ . '\Database')) {
|
||||
new Database();
|
||||
}
|
||||
|
||||
if (class_exists(__NAMESPACE__ . '\Acceleration')) {
|
||||
new Acceleration();
|
||||
}
|
||||
|
||||
return $links;
|
||||
}, 10, 2 );
|
||||
if (class_exists(__NAMESPACE__ . '\Maintenance')) {
|
||||
new Maintenance();
|
||||
}
|
||||
|
||||
// 加速服务
|
||||
new Super();
|
||||
// 监控服务
|
||||
new Monitor();
|
||||
// 更新服务
|
||||
new Update();
|
||||
}
|
||||
if ( is_admin() && class_exists(__NAMESPACE__ . '\Setting')) {
|
||||
new Setting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
0
Service/Comments.php
Executable file
0
Service/Comments.php
Executable file
92
Service/Database.php
Executable file
92
Service/Database.php
Executable file
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace WenPai\ChinaYes\Service;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use function WenPai\ChinaYes\get_settings;
|
||||
|
||||
/**
|
||||
* Class Database
|
||||
* 数据库工具服务
|
||||
* @package WenPai\ChinaYes\Service
|
||||
*/
|
||||
class Database {
|
||||
|
||||
private $settings;
|
||||
|
||||
public function __construct() {
|
||||
|
||||
$this->settings = get_settings();
|
||||
|
||||
// 如果启用了数据库工具,则允许访问数据库修复工具
|
||||
if ( ! empty( $this->settings['enable_db_tools'] ) && $this->settings['enable_db_tools'] ) {
|
||||
define( 'WP_ALLOW_REPAIR', true );
|
||||
}
|
||||
|
||||
// 处理调试常量
|
||||
$this->handle_debug_constants();
|
||||
|
||||
// 安全相关常量
|
||||
$this->handle_security_constants();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理调试模式相关常量
|
||||
*/
|
||||
private function handle_debug_constants() {
|
||||
if ( ! empty( $this->settings['enable_debug'] ) && $this->settings['enable_debug'] ) {
|
||||
// 只有在常量未定义时才定义
|
||||
if ( ! defined( 'WP_DEBUG' ) ) {
|
||||
define( 'WP_DEBUG', true );
|
||||
}
|
||||
if ( ! empty( $this->settings['debug_options']['wp_debug_log'] ) && ! defined( 'WP_DEBUG_LOG' ) ) {
|
||||
define( 'WP_DEBUG_LOG', true );
|
||||
}
|
||||
if ( ! empty( $this->settings['debug_options']['wp_debug_display'] ) && ! defined( 'WP_DEBUG_DISPLAY' ) ) {
|
||||
define( 'WP_DEBUG_DISPLAY', true );
|
||||
}
|
||||
if ( ! empty( $this->settings['debug_options']['script_debug'] ) && ! defined( 'SCRIPT_DEBUG' ) ) {
|
||||
define( 'SCRIPT_DEBUG', true );
|
||||
}
|
||||
if ( ! empty( $this->settings['debug_options']['save_queries'] ) && ! defined( 'SAVEQUERIES' ) ) {
|
||||
define( 'SAVEQUERIES', true );
|
||||
}
|
||||
} else {
|
||||
// 禁用调试模式时的默认值
|
||||
if ( ! defined( 'WP_DEBUG' ) ) {
|
||||
define( 'WP_DEBUG', false );
|
||||
}
|
||||
if ( ! defined( 'WP_DEBUG_LOG' ) ) {
|
||||
define( 'WP_DEBUG_LOG', false );
|
||||
}
|
||||
if ( ! defined( 'WP_DEBUG_DISPLAY' ) ) {
|
||||
define( 'WP_DEBUG_DISPLAY', false );
|
||||
}
|
||||
if ( ! defined( 'SCRIPT_DEBUG' ) ) {
|
||||
define( 'SCRIPT_DEBUG', false );
|
||||
}
|
||||
if ( ! defined( 'SAVEQUERIES' ) ) {
|
||||
define( 'SAVEQUERIES', false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理安全相关常量
|
||||
*/
|
||||
private function handle_security_constants() {
|
||||
if ( ! empty( $this->settings['disallow_file_edit'] ) && ! defined( 'DISALLOW_FILE_EDIT' ) ) {
|
||||
define( 'DISALLOW_FILE_EDIT', $this->settings['disallow_file_edit'] );
|
||||
}
|
||||
if ( ! empty( $this->settings['disallow_file_mods'] ) && ! defined( 'DISALLOW_FILE_MODS' ) ) {
|
||||
define( 'DISALLOW_FILE_MODS', $this->settings['disallow_file_mods'] );
|
||||
}
|
||||
if ( ! empty( $this->settings['force_ssl_admin'] ) && ! defined( 'FORCE_SSL_ADMIN' ) ) {
|
||||
define( 'FORCE_SSL_ADMIN', $this->settings['force_ssl_admin'] );
|
||||
}
|
||||
if ( ! empty( $this->settings['force_ssl_login'] ) && ! defined( 'FORCE_SSL_LOGIN' ) ) {
|
||||
define( 'FORCE_SSL_LOGIN', $this->settings['force_ssl_login'] );
|
||||
}
|
||||
}
|
||||
}
|
131
Service/Fonts.php
Executable file
131
Service/Fonts.php
Executable file
|
@ -0,0 +1,131 @@
|
|||
<?php
|
||||
|
||||
namespace WenPai\ChinaYes\Service;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use function WenPai\ChinaYes\get_settings;
|
||||
|
||||
/**
|
||||
* Class Fonts
|
||||
* 文风字体服务
|
||||
* @package WenPai\ChinaYes\Service
|
||||
*/
|
||||
class Fonts {
|
||||
|
||||
private $settings;
|
||||
|
||||
public function __construct() {
|
||||
$this->settings = get_settings();
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化文风字体功能
|
||||
*/
|
||||
private function init() {
|
||||
if (!empty($this->settings['windfonts']) && $this->settings['windfonts'] != 'off') {
|
||||
$this->load_typography();
|
||||
}
|
||||
|
||||
if (!empty($this->settings['windfonts']) && $this->settings['windfonts'] == 'optimize') {
|
||||
add_action('init', function () {
|
||||
wp_enqueue_style('windfonts-optimize', CHINA_YES_PLUGIN_URL . 'assets/css/fonts.css', [], CHINA_YES_VERSION);
|
||||
});
|
||||
}
|
||||
|
||||
if (!empty($this->settings['windfonts']) && $this->settings['windfonts'] == 'on') {
|
||||
add_action('wp_head', [$this, 'load_windfonts']);
|
||||
add_action('admin_head', [$this, 'load_windfonts']);
|
||||
}
|
||||
|
||||
if (!empty($this->settings['windfonts']) && $this->settings['windfonts'] == 'frontend') {
|
||||
add_action('wp_head', [$this, 'load_windfonts']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载文风字体
|
||||
*/
|
||||
public function load_windfonts() {
|
||||
echo <<<HTML
|
||||
<link rel="preconnect" href="//cn.windfonts.com">
|
||||
<!-- 此中文网页字体由文风字体(Windfonts)免费提供,您可以自由引用,请务必保留此授权许可标注 https://wenfeng.org/license -->
|
||||
HTML;
|
||||
|
||||
$loaded = [];
|
||||
foreach ((array) $this->settings['windfonts_list'] as $font) {
|
||||
if (empty($font['enable'])) {
|
||||
continue;
|
||||
}
|
||||
if (empty($font['family'])) {
|
||||
continue;
|
||||
}
|
||||
if (in_array($font['css'], $loaded)) {
|
||||
continue;
|
||||
}
|
||||
echo sprintf(<<<HTML
|
||||
<link rel="stylesheet" type="text/css" href="%s">
|
||||
<style>
|
||||
%s {
|
||||
font-style: %s;
|
||||
font-weight: %s;
|
||||
font-family: '%s',sans-serif!important;
|
||||
}
|
||||
</style>
|
||||
HTML
|
||||
,
|
||||
$font['css'],
|
||||
htmlspecialchars_decode($font['selector']),
|
||||
$font['style'],
|
||||
$font['weight'],
|
||||
$font['family']
|
||||
);
|
||||
$loaded[] = $font['css'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载排印优化
|
||||
*/
|
||||
public function load_typography() {
|
||||
// 支持中文排版段首缩进 2em
|
||||
if (in_array('indent', (array) $this->settings['windfonts_typography'])) {
|
||||
add_action('wp_head', function () {
|
||||
echo '<style>
|
||||
.entry-content p {
|
||||
text-indent: 2em;
|
||||
}
|
||||
.entry-content .wp-block-group p,
|
||||
.entry-content .wp-block-columns p,
|
||||
.entry-content .wp-block-media-text p,
|
||||
.entry-content .wp-block-quote p {
|
||||
text-indent: 0;
|
||||
}
|
||||
</style>';
|
||||
});
|
||||
}
|
||||
|
||||
// 支持中文排版两端对齐
|
||||
if (in_array('align', (array) $this->settings['windfonts_typography'])) {
|
||||
add_action('wp_head', function () {
|
||||
if (is_single()) { // 仅在文章页面生效
|
||||
echo '<style>
|
||||
.entry-content p {
|
||||
text-align: justify;
|
||||
}
|
||||
.entry-content .wp-block-group p,
|
||||
.entry-content .wp-block-columns p,
|
||||
.entry-content .wp-block-media-text p,
|
||||
.entry-content .wp-block-quote p {
|
||||
text-align: unset !important;
|
||||
}
|
||||
.entry-content .wp-block-columns .has-text-align-center {
|
||||
text-align: center !important;
|
||||
}
|
||||
</style>';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
0
Service/Mail.php
Executable file
0
Service/Mail.php
Executable file
136
Service/Maintenance.php
Executable file
136
Service/Maintenance.php
Executable file
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
namespace WenPai\ChinaYes\Service;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use function WenPai\ChinaYes\get_settings;
|
||||
|
||||
class Maintenance {
|
||||
private $settings;
|
||||
|
||||
public function __construct() {
|
||||
$this->settings = get_settings();
|
||||
|
||||
// 维护模式检查
|
||||
if (!empty($this->settings['maintenance_mode'])) {
|
||||
add_action('template_redirect', [$this, 'check_maintenance_mode']);
|
||||
add_action('admin_bar_menu', [$this, 'add_admin_bar_notice'], 100);
|
||||
}
|
||||
|
||||
// 仪表盘统计信息
|
||||
if (!empty($this->settings['disk']) && $this->settings['disk']) {
|
||||
add_action('dashboard_glance_items', [$this, 'add_dashboard_stats']);
|
||||
add_action('admin_head', [$this, 'add_admin_css']);
|
||||
}
|
||||
|
||||
// 添加登录记录钩子
|
||||
add_action('wp_login', [$this, 'record_last_login'], 10, 2);
|
||||
}
|
||||
|
||||
// 添加 CSS 样式
|
||||
public function add_admin_css() {
|
||||
$screen = get_current_screen();
|
||||
if ($screen->id === 'dashboard') {
|
||||
echo '<style>
|
||||
#dashboard_right_now .stat-item span.dashicons {
|
||||
margin: 0 3px 0 -25px;
|
||||
background: white;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
</style>';
|
||||
}
|
||||
}
|
||||
|
||||
public function add_dashboard_stats($items) {
|
||||
if (!is_array($items)) {
|
||||
$items = array();
|
||||
}
|
||||
|
||||
// 获取显示选项设置
|
||||
$display_options = $this->settings['disk_display'] ?? [];
|
||||
|
||||
// 媒体文件统计
|
||||
if (in_array('media_num', $display_options)) {
|
||||
$media_count = wp_count_posts('attachment')->inherit;
|
||||
$items['media'] = sprintf(
|
||||
'<a href="%s" class="stat-item"><span class="dashicons dashicons-format-gallery"></span> %s</a>',
|
||||
admin_url('upload.php'),
|
||||
sprintf(_n('%d 个媒体', '%d 个媒体', $media_count), $media_count)
|
||||
);
|
||||
}
|
||||
|
||||
// 管理员统计
|
||||
if (in_array('admin_num', $display_options)) {
|
||||
$admin_count = count(get_users(['role' => 'administrator', 'fields' => 'ID']));
|
||||
$items['admins'] = sprintf(
|
||||
'<a href="%s" class="stat-item"><span class="dashicons dashicons-shield-alt"></span> %s</a>',
|
||||
admin_url('users.php?role=administrator'),
|
||||
sprintf(_n('%d 个管理员', '%d 个管理员', $admin_count), $admin_count)
|
||||
);
|
||||
}
|
||||
|
||||
// 用户总数统计
|
||||
if (in_array('user_num', $display_options)) {
|
||||
$total_users = count(get_users(['fields' => 'ID']));
|
||||
$items['users'] = sprintf(
|
||||
'<a href="%s" class="stat-item"><span class="dashicons dashicons-groups"></span> %s</a>',
|
||||
admin_url('users.php'),
|
||||
sprintf(_n('%d 个用户', '%d 个用户', $total_users), $total_users)
|
||||
);
|
||||
}
|
||||
|
||||
// 磁盘使用统计
|
||||
$disk_info = $this->get_disk_usage_info();
|
||||
if (in_array('disk_usage', $display_options)) {
|
||||
$items['disk_usage'] = sprintf(
|
||||
'<span class="stat-item"><span class="dashicons dashicons-database"></span> 磁盘用量:%s / %s</span>',
|
||||
size_format($disk_info['used']),
|
||||
size_format($disk_info['total'])
|
||||
);
|
||||
}
|
||||
|
||||
if (in_array('disk_limit', $display_options)) {
|
||||
$items['disk_free'] = sprintf(
|
||||
'<span class="stat-item"><span class="dashicons dashicons-chart-area"></span> 剩余空间:%s (%s%%)</span>',
|
||||
size_format($disk_info['free']),
|
||||
round(($disk_info['free'] / $disk_info['total']) * 100, 2)
|
||||
);
|
||||
}
|
||||
|
||||
// 上次登录时间
|
||||
if (in_array('lastlogin', $display_options)) {
|
||||
$current_user_id = get_current_user_id();
|
||||
$last_login = get_user_meta($current_user_id, 'last_login', true);
|
||||
$items['lastlogin'] = sprintf(
|
||||
'<span class="stat-item"><span class="dashicons dashicons-clock"></span> 上次登录:%s</span>',
|
||||
$last_login ? date('Y.m.d H:i:s', $last_login) : '从未登录'
|
||||
);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function get_disk_usage_info() {
|
||||
$disk_info = get_transient('disk_usage_info');
|
||||
if (false === $disk_info) {
|
||||
$upload_dir = wp_upload_dir();
|
||||
$disk_total = disk_total_space($upload_dir['basedir']);
|
||||
$disk_free = disk_free_space($upload_dir['basedir']);
|
||||
$disk_used = $disk_total - $disk_free;
|
||||
|
||||
$disk_info = [
|
||||
'used' => $disk_used,
|
||||
'total' => $disk_total,
|
||||
'free' => $disk_free,
|
||||
];
|
||||
set_transient('disk_usage_info', $disk_info, HOUR_IN_SECONDS);
|
||||
}
|
||||
return $disk_info;
|
||||
}
|
||||
|
||||
public function record_last_login($user_login, $user) {
|
||||
update_user_meta($user->ID, 'last_login', time());
|
||||
}
|
||||
}
|
0
Service/Media.php
Executable file
0
Service/Media.php
Executable file
273
Service/Memory.php
Executable file
273
Service/Memory.php
Executable file
|
@ -0,0 +1,273 @@
|
|||
<?php
|
||||
|
||||
namespace WenPai\ChinaYes\Service;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use function WenPai\ChinaYes\get_settings;
|
||||
|
||||
|
||||
/**
|
||||
* Class Memory
|
||||
* 显示服务器 IP 和内存使用情况
|
||||
* @package WenPai\ChinaYes\Service
|
||||
*/
|
||||
class Memory {
|
||||
private $memory = [];
|
||||
private $server_ip_address = '';
|
||||
private $os_info = '';
|
||||
private $debug_status = '';
|
||||
private $cpu_usage = null;
|
||||
private $mysql_version = '';
|
||||
|
||||
public function __construct() {
|
||||
$settings = get_settings();
|
||||
if (!empty($settings['memory'])) {
|
||||
add_action('plugins_loaded', [$this, 'initialize']);
|
||||
}
|
||||
register_activation_hook(CHINA_YES_PLUGIN_FILE, [$this, 'check_php_version']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化插件
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action('init', [$this, 'check_memory_limit']);
|
||||
add_filter('admin_footer_text', [$this, 'add_footer']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取操作系统信息
|
||||
*/
|
||||
private function get_os_info() {
|
||||
$os = php_uname('s');
|
||||
|
||||
// 转换为更直观的名称
|
||||
switch (strtolower($os)) {
|
||||
case 'linux':
|
||||
return 'Linux';
|
||||
case 'darwin':
|
||||
return 'macOS';
|
||||
case 'windows nt':
|
||||
return 'Windows';
|
||||
default:
|
||||
return $os;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取调试状态
|
||||
*/
|
||||
private function get_debug_status() {
|
||||
if (defined('WP_DEBUG') && true === WP_DEBUG) {
|
||||
return '<strong><font color="#F60">' . __('WP_DEBUG', 'wp-china-yes') . '</font></strong>';
|
||||
}
|
||||
return '<span style="text-decoration: line-through;">' . __('WP_DEBUG', 'wp-china-yes') . '</span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 CPU 使用率
|
||||
*/
|
||||
private function get_cpu_usage() {
|
||||
if (function_exists('sys_getloadavg') && is_callable('sys_getloadavg')) {
|
||||
$load = sys_getloadavg();
|
||||
return round($load[0] * 100 / 4, 2); // 假设是4核CPU
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 MySQL 版本
|
||||
*/
|
||||
private function get_mysql_version() {
|
||||
global $wpdb;
|
||||
return $wpdb->get_var("SELECT VERSION()");
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查 PHP 内存限制
|
||||
*/
|
||||
public function check_memory_limit() {
|
||||
$this->memory['limit'] = (int) ini_get('memory_limit');
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查内存使用情况
|
||||
*/
|
||||
private function check_memory_usage() {
|
||||
$this->memory['usage'] = function_exists('memory_get_peak_usage')
|
||||
? round(memory_get_peak_usage(true) / 1024 / 1024, 2)
|
||||
: 0;
|
||||
|
||||
if (!empty($this->memory['usage']) && !empty($this->memory['limit'])) {
|
||||
$this->memory['percent'] = round($this->memory['usage'] / $this->memory['limit'] * 100, 0);
|
||||
$this->memory['color'] = $this->get_memory_color($this->memory['percent']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内存使用率的颜色
|
||||
*/
|
||||
private function get_memory_color($percent) {
|
||||
if ($percent > 90) {
|
||||
return 'font-weight:bold;color:red';
|
||||
} elseif ($percent > 75) {
|
||||
return 'font-weight:bold;color:#E66F00';
|
||||
}
|
||||
return 'font-weight:normal;';
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化 WordPress 内存限制
|
||||
*/
|
||||
private function format_wp_limit($size) {
|
||||
$unit = strtoupper(substr($size, -1));
|
||||
$value = (int) substr($size, 0, -1);
|
||||
|
||||
switch ($unit) {
|
||||
case 'P': $value *= 1024;
|
||||
case 'T': $value *= 1024;
|
||||
case 'G': $value *= 1024;
|
||||
case 'M': $value *= 1024;
|
||||
case 'K': $value *= 1024;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 WordPress 内存限制
|
||||
*/
|
||||
private function check_wp_limit() {
|
||||
$memory = $this->format_wp_limit(WP_MEMORY_LIMIT);
|
||||
return $memory ? size_format($memory) : __('N/A', 'wp-china-yes');
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加信息到管理界面页脚
|
||||
*/
|
||||
public function add_footer($content) {
|
||||
$settings = get_settings();
|
||||
|
||||
// 设置默认显示选项
|
||||
$default_options = [
|
||||
'memory_usage',
|
||||
'wp_limit',
|
||||
'server_ip',
|
||||
];
|
||||
|
||||
// 如果设置为空或不是数组,使用默认选项
|
||||
$display_options = isset($settings['memory_display']) && is_array($settings['memory_display'])
|
||||
? $settings['memory_display']
|
||||
: $default_options;
|
||||
|
||||
// 如果 memory 设置未启用,直接返回原始内容
|
||||
if (empty($settings['memory'])) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$this->check_memory_usage();
|
||||
$this->server_ip_address = $_SERVER['SERVER_ADDR'] ?? ($_SERVER['LOCAL_ADDR'] ?? '');
|
||||
$this->os_info = $this->get_os_info();
|
||||
|
||||
$footer_parts = [];
|
||||
|
||||
|
||||
// 内存使用量
|
||||
if (in_array('memory_usage', $display_options)) {
|
||||
$footer_parts[] = sprintf('%s: %s %s %s MB (<span style="%s">%s%%</span>)',
|
||||
__('Memory', 'wp-china-yes'),
|
||||
$this->memory['usage'],
|
||||
__('of', 'wp-china-yes'),
|
||||
$this->memory['limit'],
|
||||
$this->memory['color'],
|
||||
$this->memory['percent']
|
||||
);
|
||||
}
|
||||
|
||||
// WP内存限制
|
||||
if (in_array('wp_limit', $display_options)) {
|
||||
$footer_parts[] = sprintf('%s: %s',
|
||||
__('WP LIMIT', 'wp-china-yes'),
|
||||
$this->check_wp_limit()
|
||||
);
|
||||
}
|
||||
|
||||
// 服务器IP和主机名
|
||||
if (in_array('server_ip', $display_options)) {
|
||||
$hostname_part = in_array('hostname', $display_options) ? " (" . gethostname() . ")" : "";
|
||||
$footer_parts[] = sprintf('IP: %s%s',
|
||||
$this->server_ip_address,
|
||||
$hostname_part
|
||||
);
|
||||
}
|
||||
|
||||
// 操作系统信息
|
||||
if (in_array('os_info', $display_options)) {
|
||||
$footer_parts[] = sprintf('OS: %s', $this->os_info);
|
||||
}
|
||||
|
||||
// PHP信息
|
||||
if (in_array('php_info', $display_options)) {
|
||||
$footer_parts[] = sprintf('PHP: %s @%sBitOS',
|
||||
PHP_VERSION,
|
||||
PHP_INT_SIZE * 8
|
||||
);
|
||||
}
|
||||
|
||||
// Debug状态
|
||||
if (in_array('debug_status', $display_options)) {
|
||||
$footer_parts[] = $this->get_debug_status();
|
||||
}
|
||||
|
||||
// CPU使用率
|
||||
if (in_array('cpu_usage', $display_options)) {
|
||||
$cpu_usage = $this->get_cpu_usage();
|
||||
if ($cpu_usage !== false) {
|
||||
$footer_parts[] = sprintf('CPU: %s%%', $cpu_usage);
|
||||
}
|
||||
}
|
||||
|
||||
// MySQL版本
|
||||
if (in_array('mysql_version', $display_options)) {
|
||||
$footer_parts[] = sprintf('MySQL: %s', $this->get_mysql_version());
|
||||
}
|
||||
|
||||
if (!empty($footer_parts)) {
|
||||
$content .= ' | WPCY - ' . implode(' | ', $footer_parts);
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查 PHP 版本
|
||||
*/
|
||||
public function check_php_version() {
|
||||
if (version_compare(PHP_VERSION, '7.0', '<')) {
|
||||
deactivate_plugins(plugin_basename(CHINA_YES_PLUGIN_FILE));
|
||||
wp_die(
|
||||
sprintf(
|
||||
'<h1>%s</h1><p>%s</p>',
|
||||
__('插件无法激活:PHP 版本过低', 'wp-china-yes'),
|
||||
__('请升级 PHP 至 7.0 或更高版本。', 'wp-china-yes')
|
||||
),
|
||||
__('PHP 版本错误', 'wp-china-yes'),
|
||||
['back_link' => true]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新设置
|
||||
*/
|
||||
private function update_settings() {
|
||||
if ( is_multisite() ) {
|
||||
update_site_option( 'wp_china_yes', $this->settings );
|
||||
} else {
|
||||
update_option( 'wp_china_yes', $this->settings, true );
|
||||
}
|
||||
}
|
||||
}
|
88
Service/Monitor.php
Normal file → Executable file
88
Service/Monitor.php
Normal file → Executable file
|
@ -17,37 +17,44 @@ class Monitor {
|
|||
|
||||
public function __construct() {
|
||||
$this->settings = get_settings();
|
||||
|
||||
add_action( 'init', [ $this, 'init' ] );
|
||||
add_action( 'wp_china_yes_maybe_check_store', [
|
||||
$this,
|
||||
'maybe_check_store'
|
||||
] );
|
||||
add_action( 'wp_china_yes_maybe_check_cravatar', [
|
||||
$this,
|
||||
'maybe_check_cravatar'
|
||||
] );
|
||||
add_action( 'wp_china_yes_maybe_check_admincdn', [
|
||||
$this,
|
||||
'maybe_check_admincdn'
|
||||
] );
|
||||
}
|
||||
wp_clear_scheduled_hook( 'wp_china_yes_maybe_check_store' ); // TODO 下个版本移除
|
||||
wp_clear_scheduled_hook( 'wp_china_yes_maybe_check_cravatar' ); // TODO 下个版本移除
|
||||
wp_clear_scheduled_hook( 'wp_china_yes_maybe_check_admincdn' ); // TODO 下个版本移除
|
||||
if ( $this->settings['monitor'] ) {
|
||||
// 站点网络下只在主站运行
|
||||
if ( is_main_site() ) {
|
||||
add_action( 'init', [ $this, 'init' ] );
|
||||
add_action( 'wp_china_yes_monitor', [
|
||||
$this,
|
||||
'run_monitor'
|
||||
] );
|
||||
}
|
||||
} else {
|
||||
wp_clear_scheduled_hook( 'wp_china_yes_monitor' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
public function init() {
|
||||
// 检查应用市场可用性
|
||||
if ( ! wp_next_scheduled( 'wp_china_yes_maybe_check_store' ) && $this->settings['store'] != 'off' ) {
|
||||
wp_schedule_event( time(), 'hourly', 'wp_china_yes_maybe_check_store' );
|
||||
if ( ! wp_next_scheduled( 'wp_china_yes_monitor' ) ) {
|
||||
wp_schedule_event( time(), 'hourly', 'wp_china_yes_monitor' );
|
||||
}
|
||||
// 检查初认头像可用性
|
||||
if ( ! wp_next_scheduled( 'wp_china_yes_maybe_check_cravatar' ) && $this->settings['cravatar'] != 'off' ) {
|
||||
wp_schedule_event( time(), 'hourly', 'wp_china_yes_maybe_check_cravatar' );
|
||||
}
|
||||
|
||||
/**
|
||||
* 运行监控
|
||||
*/
|
||||
public function run_monitor() {
|
||||
if ( $this->settings['store'] != 'off' ) {
|
||||
$this->maybe_check_store();
|
||||
}
|
||||
// 检查萌芽加速可用性
|
||||
if ( ! wp_next_scheduled( 'wp_china_yes_maybe_check_admincdn' ) && ! empty( $this->settings['admincdn'] ) ) {
|
||||
wp_schedule_event( time(), 'hourly', 'wp_china_yes_maybe_check_admincdn' );
|
||||
if ( $this->settings['cravatar'] != 'off' ) {
|
||||
$this->maybe_check_cravatar();
|
||||
}
|
||||
if ( ! empty( $this->settings['admincdn'] ) ) {
|
||||
$this->maybe_check_admincdn();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,47 +108,56 @@ class Monitor {
|
|||
*/
|
||||
public function maybe_check_admincdn() {
|
||||
// 后台加速
|
||||
if ( ! empty( $this->settings['admincdn']['admin'] ) ) {
|
||||
$response = wp_remote_get( 'https://wpstatic.admincdn.com/6.4.3/wp-includes/js/wp-sanitize.min.js' );
|
||||
if ( in_array( 'admin', $this->settings['admincdn'] ) ) {
|
||||
$response = wp_remote_get( 'https://wpstatic.admincdn.com/6.7/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 ( 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 ) {
|
||||
$this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'jsdelivr' ] ) );
|
||||
$this->update_settings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新设置
|
||||
|
@ -150,7 +166,7 @@ class Monitor {
|
|||
if ( is_multisite() ) {
|
||||
update_site_option( 'wp_china_yes', $this->settings );
|
||||
} else {
|
||||
update_option( 'wp_china_yes', $this->settings );
|
||||
update_option( 'wp_china_yes', $this->settings, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
Service/Performance.php
Executable file
2
Service/Performance.php
Executable file
|
@ -0,0 +1,2 @@
|
|||
<?php
|
||||
|
1401
Service/Setting.php
Normal file → Executable file
1401
Service/Setting.php
Normal file → Executable file
File diff suppressed because it is too large
Load diff
701
Service/Super.php
Normal file → Executable file
701
Service/Super.php
Normal file → Executable file
|
@ -4,6 +4,7 @@ namespace WenPai\ChinaYes\Service;
|
|||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use WP_Error;
|
||||
use function WenPai\ChinaYes\get_settings;
|
||||
|
||||
/**
|
||||
|
@ -30,176 +31,152 @@ class Super {
|
|||
/**
|
||||
* 添加「文派茶馆」小组件
|
||||
*/
|
||||
if ( is_admin() ) {
|
||||
add_action( 'wp_dashboard_setup', function () {
|
||||
global $wp_meta_boxes;
|
||||
if ( is_admin() ) {
|
||||
add_action( 'wp_dashboard_setup', function () {
|
||||
global $wp_meta_boxes;
|
||||
|
||||
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] );
|
||||
wp_add_dashboard_widget( 'wenpai_tea', '文派茶馆', function () {
|
||||
echo <<<HTML
|
||||
<div class="wordpress-news hide-if-no-js">
|
||||
<div class="rss-widget">
|
||||
HTML;
|
||||
wp_widget_rss_output( 'https://wptea.com/feed/', [
|
||||
'items' => 5,
|
||||
'show_summary' => 1,
|
||||
] );
|
||||
echo <<<HTML
|
||||
</div>
|
||||
</div>
|
||||
<p class="community-events-footer">
|
||||
<a href="https://wenpai.org/" target="_blank">文派开源</a>
|
||||
|
|
||||
<a href="https://wenpai.org/support" target="_blank">支持论坛</a>
|
||||
|
|
||||
<a href="https://translate.wenpai.org/" target="_blank">翻译平台</a>
|
||||
</p>
|
||||
<style>
|
||||
#wenpai_tea .rss-widget {
|
||||
font-size:13px;
|
||||
padding:0 12px
|
||||
}
|
||||
#wenpai_tea .rss-widget:last-child {
|
||||
border-bottom:none;
|
||||
padding-bottom:8px
|
||||
}
|
||||
#wenpai_tea .rss-widget a {
|
||||
font-weight:400
|
||||
}
|
||||
#wenpai_tea .rss-widget span,
|
||||
#wenpai_tea .rss-widget span.rss-date {
|
||||
color:#646970
|
||||
}
|
||||
#wenpai_tea .rss-widget span.rss-date {
|
||||
margin-left:12px
|
||||
}
|
||||
#wenpai_tea .rss-widget ul li {
|
||||
padding:4px 0;
|
||||
margin:0
|
||||
}
|
||||
</style>
|
||||
HTML;
|
||||
} );
|
||||
} );
|
||||
add_action( 'wp_network_dashboard_setup', function () {
|
||||
global $wp_meta_boxes;
|
||||
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] );
|
||||
wp_add_dashboard_widget( 'wenpai_tea', '文派茶馆', function () {
|
||||
$default_rss_url = 'https://wptea.com/feed/';
|
||||
$custom_rss_url = $this->settings['custom_rss_url'] ?? '';
|
||||
$refresh_interval = $this->settings['custom_rss_refresh'] ?? 3600;
|
||||
|
||||
unset( $wp_meta_boxes['dashboard-network']['side']['core']['dashboard_primary'] );
|
||||
wp_add_dashboard_widget( 'wenpai_tea', '文派茶馆', function () {
|
||||
echo <<<HTML
|
||||
<div class="wordpress-news hide-if-no-js">
|
||||
<div class="rss-widget">
|
||||
HTML;
|
||||
wp_widget_rss_output( 'https://wptea.com/feed/', [
|
||||
'items' => 5,
|
||||
'show_summary' => 1,
|
||||
] );
|
||||
echo <<<HTML
|
||||
</div>
|
||||
</div>
|
||||
<p class="community-events-footer">
|
||||
<a href="https://wenpai.org/" target="_blank">文派开源</a>
|
||||
|
|
||||
<a href="https://wenpai.org/support" target="_blank">支持论坛</a>
|
||||
|
|
||||
<a href="https://translate.wenpai.org/" target="_blank">翻译平台</a>
|
||||
</p>
|
||||
<style>
|
||||
#wenpai_tea .rss-widget {
|
||||
font-size:13px;
|
||||
padding:0 12px
|
||||
}
|
||||
#wenpai_tea .rss-widget:last-child {
|
||||
border-bottom:none;
|
||||
padding-bottom:8px
|
||||
}
|
||||
#wenpai_tea .rss-widget a {
|
||||
font-weight:400
|
||||
}
|
||||
#wenpai_tea .rss-widget span,
|
||||
#wenpai_tea .rss-widget span.rss-date {
|
||||
color:#646970
|
||||
}
|
||||
#wenpai_tea .rss-widget span.rss-date {
|
||||
margin-left:12px
|
||||
}
|
||||
#wenpai_tea .rss-widget ul li {
|
||||
padding:4px 0;
|
||||
margin:0
|
||||
}
|
||||
</style>
|
||||
HTML;
|
||||
} );
|
||||
} );
|
||||
}
|
||||
$rss_display_options = $this->settings['rss_display_options'] ?? ['show_date', 'show_summary', 'show_footer'];
|
||||
if (!is_array($rss_display_options)) {
|
||||
$rss_display_options = explode(',', $rss_display_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* WordPress 核心静态文件链接替换
|
||||
*/
|
||||
if ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
||||
if (
|
||||
! empty( $this->settings['admincdn']['admin'] ) &&
|
||||
! stristr( $GLOBALS['wp_version'], 'alpha' ) &&
|
||||
! stristr( $GLOBALS['wp_version'], 'beta' ) &&
|
||||
! stristr( $GLOBALS['wp_version'], 'RC' )
|
||||
) {
|
||||
// 禁用合并加载,以便于使用公共资源节点
|
||||
global $concatenate_scripts;
|
||||
$concatenate_scripts = false;
|
||||
// 获取默认的 RSS 源内容
|
||||
$default_rss = fetch_feed($default_rss_url);
|
||||
$default_items = [];
|
||||
if (!is_wp_error($default_rss)) {
|
||||
$default_items = $default_rss->get_items(0, 5);
|
||||
}
|
||||
|
||||
$this->page_str_replace( 'preg_replace', [
|
||||
'~' . home_url( '/' ) . '(wp-admin|wp-includes)/(css|js)/~',
|
||||
sprintf( 'https://wpstatic.admincdn.com/%s/$1/$2/', $GLOBALS['wp_version'] )
|
||||
] );
|
||||
}
|
||||
}
|
||||
$custom_items = [];
|
||||
$custom_rss = null;
|
||||
$custom_rss_latest_date = 0;
|
||||
|
||||
if ( ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
||||
/**
|
||||
* 前台静态加速
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['frontend'] ) ) {
|
||||
add_action( 'template_redirect', function () {
|
||||
ob_start( function ( $content ) {
|
||||
$regex = '#(?<=[(\"\'])(?:' . quotemeta( home_url() ) . ')?/(?:((?:wp-content|wp-includes)[^\"\')]+\.(css|js)[^\"\')]+))(?=[\"\')])#';
|
||||
if (!empty($custom_rss_url)) {
|
||||
$transient_key = 'wenpai_tea_custom_rss_' . md5($custom_rss_url);
|
||||
$cached_custom_items = get_transient($transient_key);
|
||||
|
||||
return preg_replace_callback( $regex, function ( $asset ) {
|
||||
return 'https://public.admincdn.com/' . $asset[0];
|
||||
}, $content );
|
||||
} );
|
||||
} );
|
||||
}
|
||||
if (false === $cached_custom_items) {
|
||||
$custom_rss = fetch_feed($custom_rss_url);
|
||||
if (!is_wp_error($custom_rss)) {
|
||||
$custom_items = $custom_rss->get_items(0, 2);
|
||||
if (!empty($custom_items)) {
|
||||
$custom_rss_latest_date = $custom_items[0]->get_date('U');
|
||||
}
|
||||
|
||||
/**
|
||||
* Google 字体替换
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['googlefonts'] ) ) {
|
||||
$this->page_str_replace( 'str_replace', [
|
||||
'fonts.googleapis.com',
|
||||
'googlefonts.admincdn.com'
|
||||
] );
|
||||
}
|
||||
set_transient($transient_key, $custom_items, $refresh_interval);
|
||||
}
|
||||
} else {
|
||||
$custom_items = $cached_custom_items;
|
||||
if (!empty($custom_items)) {
|
||||
$custom_rss_latest_date = $custom_items[0]->get_date('U');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Google 前端公共库替换
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['googleajax'] ) ) {
|
||||
$this->page_str_replace( 'str_replace', [
|
||||
'ajax.googleapis.com',
|
||||
'googleajax.admincdn.com'
|
||||
] );
|
||||
}
|
||||
$three_days_ago = time() - (3 * 24 * 60 * 60);
|
||||
if ($custom_rss_latest_date > $three_days_ago) {
|
||||
$items = array_merge(array_slice($default_items, 0, 3), $custom_items);
|
||||
} else {
|
||||
$items = array_slice($default_items, 0, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* CDNJS 前端公共库替换
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['cdnjs'] ) ) {
|
||||
$this->page_str_replace( 'str_replace', [
|
||||
'cdnjs.cloudflare.com/ajax/libs',
|
||||
'cdnjs.admincdn.com'
|
||||
] );
|
||||
}
|
||||
}
|
||||
if (is_wp_error($custom_rss)) {
|
||||
$items = array_slice($default_items, 0, 5);
|
||||
}
|
||||
|
||||
echo <<<HTML
|
||||
<div class="wordpress-news hide-if-no-js">
|
||||
<div class="rss-widget">
|
||||
HTML;
|
||||
foreach ($items as $item) {
|
||||
echo '<div class="rss-item">';
|
||||
echo '<a href="' . esc_url($item->get_permalink()) . '" target="_blank">' . esc_html($item->get_title()) . '</a>';
|
||||
if (in_array('show_date', $rss_display_options)) {
|
||||
echo '<span class="rss-date">' . esc_html($item->get_date('Y.m.d')) . '</span>';
|
||||
}
|
||||
if (in_array('show_summary', $rss_display_options)) {
|
||||
echo '<div class="rss-summary">' . esc_html(wp_trim_words($item->get_description(), 45, '...')) . '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo <<<HTML
|
||||
</div>
|
||||
</div>
|
||||
HTML;
|
||||
if (in_array('show_footer', $rss_display_options)) {
|
||||
echo <<<HTML
|
||||
<p class="community-events-footer">
|
||||
<a href="https://wenpai.org/" target="_blank">文派开源</a>
|
||||
|
|
||||
<a href="https://wenpai.org/support" target="_blank">支持论坛</a>
|
||||
|
|
||||
<a href="https://translate.wenpai.org/" target="_blank">翻译平台</a>
|
||||
|
|
||||
<a href="https://wptea.com/newsletter/" target="_blank">订阅推送</a>
|
||||
</p>
|
||||
HTML;
|
||||
}
|
||||
echo <<<HTML
|
||||
<style>
|
||||
#wenpai_tea .rss-widget {
|
||||
padding: 0 12px;
|
||||
}
|
||||
#wenpai_tea .rss-widget:last-child {
|
||||
border-bottom: none;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
#wenpai_tea .rss-item {
|
||||
margin-bottom: 10px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
#wenpai_tea .rss-item:last-child {
|
||||
border-bottom: none;
|
||||
margin-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
#wenpai_tea .rss-item a {
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
#wenpai_tea .rss-date {
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
#wenpai_tea .rss-summary {
|
||||
color: #444;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
#wenpai_tea .community-events-footer {
|
||||
margin-top: 15px;
|
||||
padding-top: 15px;
|
||||
padding-bottom: 5px;
|
||||
border-top: 1px solid #eee;
|
||||
text-align: center;
|
||||
}
|
||||
#wenpai_tea .community-events-footer a {
|
||||
text-decoration: none;
|
||||
margin: 0 5px;
|
||||
}
|
||||
#wenpai_tea .community-events-footer a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
HTML;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 初认头像
|
||||
|
@ -211,6 +188,386 @@ class Super {
|
|||
add_filter( 'bp_gravatar_url', [ $this, 'get_cravatar_url' ], 1 );
|
||||
add_filter( 'get_avatar_url', [ $this, 'get_cravatar_url' ], 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* 文风字体
|
||||
*/
|
||||
if ( ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
||||
if ( ! empty( $this->settings['windfonts'] ) && $this->settings['windfonts'] != 'off' ) {
|
||||
$this->load_typography();
|
||||
}
|
||||
if ( ! empty( $this->settings['windfonts'] ) && $this->settings['windfonts'] == 'optimize' ) {
|
||||
add_action( 'init', function () {
|
||||
wp_enqueue_style( 'windfonts-optimize', CHINA_YES_PLUGIN_URL . 'assets/css/fonts.css', [], CHINA_YES_VERSION );
|
||||
} );
|
||||
}
|
||||
if ( ! empty( $this->settings['windfonts'] ) && $this->settings['windfonts'] == 'on' ) {
|
||||
add_action( 'wp_head', [ $this, 'load_windfonts' ] );
|
||||
add_action( 'admin_head', [ $this, 'load_windfonts' ] );
|
||||
}
|
||||
if ( ! empty( $this->settings['windfonts'] ) && $this->settings['windfonts'] == 'frontend' ) {
|
||||
add_action( 'wp_head', [ $this, 'load_windfonts' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告拦截
|
||||
*/
|
||||
if ( ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
||||
if ( ! empty( $this->settings['adblock'] ) && $this->settings['adblock'] == 'on' ) {
|
||||
add_action( 'admin_head', [ $this, 'load_adblock' ] );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 通知管理
|
||||
*/
|
||||
if ( ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
||||
if ( ! empty( $this->settings['notice_block'] ) && $this->settings['notice_block'] == 'on' ) {
|
||||
add_action( 'admin_head', [ $this, 'load_notice_management' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞行模式
|
||||
*/
|
||||
if ( ! empty( $this->settings['plane'] ) && $this->settings['plane'] == 'on' ) {
|
||||
$this->load_plane();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 加载文风字体
|
||||
*/
|
||||
public function load_windfonts() {
|
||||
echo <<<HTML
|
||||
<link rel="preconnect" href="//cn.windfonts.com">
|
||||
<!-- 此中文网页字体由文风字体(Windfonts)免费提供,您可以自由引用,请务必保留此授权许可标注 https://wenfeng.org/license -->
|
||||
HTML;
|
||||
|
||||
$loaded = [];
|
||||
foreach ( (array) $this->settings['windfonts_list'] as $font ) {
|
||||
if ( empty( $font['enable'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( empty( $font['family'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( in_array( $font['css'], $loaded ) ) {
|
||||
continue;
|
||||
}
|
||||
echo sprintf( <<<HTML
|
||||
<link rel="stylesheet" type="text/css" href="%s">
|
||||
<style>
|
||||
%s {
|
||||
font-style: %s;
|
||||
font-weight: %s;
|
||||
font-family: '%s',sans-serif!important;
|
||||
}
|
||||
</style>
|
||||
HTML
|
||||
,
|
||||
$font['css'],
|
||||
htmlspecialchars_decode( $font['selector'] ),
|
||||
$font['style'],
|
||||
$font['weight'],
|
||||
$font['family']
|
||||
);
|
||||
$loaded[] = $font['css'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载排印优化
|
||||
*/
|
||||
public function load_typography() {
|
||||
// code from corner-bracket-lover plugin
|
||||
if ( in_array( 'corner', (array) $this->settings['windfonts_typography'] ) ) {
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'n’t',
|
||||
'n’t'
|
||||
] );
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'’s',
|
||||
'’s'
|
||||
] );
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'’m',
|
||||
'’m'
|
||||
] );
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'’re',
|
||||
'’re'
|
||||
] );
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'’ve',
|
||||
'’ve'
|
||||
] );
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'’d',
|
||||
'’d'
|
||||
] );
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'’ll',
|
||||
'’ll'
|
||||
] );
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'“',
|
||||
'「'
|
||||
] );
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'”',
|
||||
'」'
|
||||
] );
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'‘',
|
||||
'『'
|
||||
] );
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'’',
|
||||
'』'
|
||||
] );
|
||||
}
|
||||
// code from space-lover plugin
|
||||
if ( in_array( 'space', (array) $this->settings['windfonts_typography'] ) ) {
|
||||
$this->page_str_replace( 'template_redirect', 'preg_replace', [
|
||||
'~(\p{Han})([a-zA-Z0-9\p{Ps}\p{Pi}])(?![^<]*>)~u',
|
||||
'\1 \2'
|
||||
] );
|
||||
$this->page_str_replace( 'template_redirect', 'preg_replace', [
|
||||
'~([a-zA-Z0-9\p{Pe}\p{Pf}])(\p{Han})(?![^<]*>)~u',
|
||||
'\1 \2'
|
||||
] );
|
||||
$this->page_str_replace( 'template_redirect', 'preg_replace', [
|
||||
'~([!?‽:;,.%])(\p{Han})~u',
|
||||
'\1 \2'
|
||||
] );
|
||||
$this->page_str_replace( 'template_redirect', 'preg_replace', [
|
||||
'~(\p{Han})([@$#])~u',
|
||||
'\1 \2'
|
||||
] );
|
||||
$this->page_str_replace( 'template_redirect', 'preg_replace', [
|
||||
'~(&?(?:amp)?;) (\p{Han})(?![^<]*>)~u',
|
||||
'\1\2'
|
||||
] );
|
||||
$this->page_str_replace( 'template_redirect', 'preg_replace', [
|
||||
'~(\p{Han})(<(?!ruby)[a-zA-Z]+?[^>]*?>)([a-zA-Z0-9\p{Ps}\p{Pi}@$#])~u',
|
||||
'\1 \2\3'
|
||||
] );
|
||||
$this->page_str_replace( 'template_redirect', 'preg_replace', [
|
||||
'~(\p{Han})(<\/(?!ruby)[a-zA-Z]+>)([a-zA-Z0-9])~u',
|
||||
'\1\2 \3'
|
||||
] );
|
||||
$this->page_str_replace( 'template_redirect', 'preg_replace', [
|
||||
'~([a-zA-Z0-9\p{Pe}\p{Pf}!?‽:;,.%])(<(?!ruby)[a-zA-Z]+?[^>]*?>)(\p{Han})~u',
|
||||
'\1 \2\3'
|
||||
] );
|
||||
$this->page_str_replace( 'template_redirect', 'preg_replace', [
|
||||
'~([a-zA-Z0-9\p{Ps}\p{Pi}!?‽:;,.%])(<\/(?!ruby)[a-zA-Z]+>)(\p{Han})~u',
|
||||
'\1\2 \3'
|
||||
] );
|
||||
$this->page_str_replace( 'template_redirect', 'preg_replace', [
|
||||
'~[ ]*([「」『』()〈〉《》【】〔〕〖〗〘〙〚〛])[ ]*~u',
|
||||
'\1'
|
||||
] );
|
||||
}
|
||||
// code from quotmarks-replacer plugin
|
||||
if ( in_array( 'punctuation', (array) $this->settings['windfonts_typography'] ) ) {
|
||||
$qmr_work_tags = array(
|
||||
'the_title', // http://codex.wordpress.org/Function_Reference/the_title
|
||||
'the_content', // http://codex.wordpress.org/Function_Reference/the_content
|
||||
'the_excerpt', // http://codex.wordpress.org/Function_Reference/the_excerpt
|
||||
// 'list_cats', Deprecated. http://codex.wordpress.org/Function_Reference/list_cats
|
||||
'single_post_title', // http://codex.wordpress.org/Function_Reference/single_post_title
|
||||
'comment_author', // http://codex.wordpress.org/Function_Reference/comment_author
|
||||
'comment_text', // http://codex.wordpress.org/Function_Reference/comment_text
|
||||
// 'link_name', Deprecated.
|
||||
// 'link_notes', Deprecated.
|
||||
'link_description', // Deprecated, but still widely used.
|
||||
'bloginfo', // http://codex.wordpress.org/Function_Reference/bloginfo
|
||||
'wp_title', // http://codex.wordpress.org/Function_Reference/wp_title
|
||||
'term_description', // http://codex.wordpress.org/Function_Reference/term_description
|
||||
'category_description', // http://codex.wordpress.org/Function_Reference/category_description
|
||||
'widget_title', // Used by all widgets in themes
|
||||
'widget_text' // Used by all widgets in themes
|
||||
);
|
||||
|
||||
foreach ( $qmr_work_tags as $qmr_work_tag ) {
|
||||
remove_filter( $qmr_work_tag, 'wptexturize' );
|
||||
}
|
||||
}
|
||||
|
||||
// 支持中文排版段首缩进 2em
|
||||
if ( in_array( 'indent', (array) $this->settings['windfonts_typography'] ) ) {
|
||||
add_action( 'wp_head', function () {
|
||||
echo '<style>
|
||||
.entry-content p {
|
||||
text-indent: 2em;
|
||||
}
|
||||
.entry-content .wp-block-group p,
|
||||
.entry-content .wp-block-columns p,
|
||||
.entry-content .wp-block-media-text p,
|
||||
.entry-content .wp-block-quote p {
|
||||
text-indent: 0;
|
||||
}
|
||||
|
||||
</style>';
|
||||
} );
|
||||
}
|
||||
// 支持中文排版两端对齐
|
||||
if ( in_array( 'align', (array) $this->settings['windfonts_typography'] ) ) {
|
||||
add_action( 'wp_head', function () {
|
||||
if ( is_single() ) { // 仅在文章页面生效
|
||||
echo '<style>
|
||||
.entry-content p {
|
||||
text-align: justify;
|
||||
}
|
||||
.entry-content .wp-block-group p,
|
||||
.entry-content .wp-block-columns p,
|
||||
.entry-content .wp-block-media-text p,
|
||||
.entry-content .wp-block-quote p {
|
||||
text-align: unset !important;
|
||||
}
|
||||
.entry-content .wp-block-columns .has-text-align-center {
|
||||
text-align: center !important;
|
||||
}
|
||||
</style>';
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载广告拦截
|
||||
*/
|
||||
public function load_adblock() {
|
||||
if (empty($this->settings['adblock']) || $this->settings['adblock'] !== 'on') {
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理广告拦截规则
|
||||
foreach ( (array) $this->settings['adblock_rule'] as $rule ) {
|
||||
if ( empty( $rule['enable'] ) || empty( $rule['selector'] ) ) {
|
||||
continue;
|
||||
}
|
||||
echo sprintf( '<style>%s{display:none!important;}</style>',
|
||||
htmlspecialchars_decode( $rule['selector'] )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 加载通知管理
|
||||
*/
|
||||
public function load_notice_management() {
|
||||
// 首先检查是否启用通知管理功能
|
||||
if (empty($this->settings['notice_block']) || $this->settings['notice_block'] !== 'on') {
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否启用全局禁用
|
||||
if (!empty($this->settings['disable_all_notices'])) {
|
||||
$this->disable_all_notices();
|
||||
echo '<style>.notice,.notice-error,.notice-warning,.notice-success,.notice-info,.updated,.error,.update-nag{display:none!important;}</style>';
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理选择性禁用
|
||||
$selected_notices = $this->settings['notice_control'] ?? [];
|
||||
$notice_method = $this->settings['notice_method'] ?? 'hook';
|
||||
|
||||
if (!empty($selected_notices)) {
|
||||
// 处理钩子移除
|
||||
if (in_array($notice_method, ['hook', 'both'])) {
|
||||
$this->disable_selected_notices($selected_notices);
|
||||
}
|
||||
|
||||
// 处理 CSS 隐藏
|
||||
if (in_array($notice_method, ['css', 'both'])) {
|
||||
$this->apply_notice_css($selected_notices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用通知 CSS 隐藏
|
||||
*/
|
||||
private function apply_notice_css($selected_notices) {
|
||||
$selectors = [];
|
||||
foreach ($selected_notices as $type) {
|
||||
switch ($type) {
|
||||
case 'error':
|
||||
$selectors[] = '.notice-error,.error';
|
||||
break;
|
||||
case 'warning':
|
||||
$selectors[] = '.notice-warning';
|
||||
break;
|
||||
case 'success':
|
||||
$selectors[] = '.notice-success,.updated';
|
||||
break;
|
||||
case 'info':
|
||||
$selectors[] = '.notice-info';
|
||||
break;
|
||||
case 'core':
|
||||
$selectors[] = '.update-nag';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($selectors)) {
|
||||
echo '<style>' . implode(',', $selectors) . '{display:none!important;}</style>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除所有管理通知
|
||||
*/
|
||||
private function disable_all_notices() {
|
||||
remove_all_actions('admin_notices');
|
||||
remove_all_actions('all_admin_notices');
|
||||
remove_all_actions('user_admin_notices');
|
||||
remove_all_actions('network_admin_notices');
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用选定的通知类型
|
||||
*/
|
||||
private function disable_selected_notices($types) {
|
||||
if (in_array('core', $types)) {
|
||||
remove_action('admin_notices', 'update_nag', 3);
|
||||
remove_action('admin_notices', 'maintenance_nag', 10);
|
||||
add_filter('pre_site_transient_update_core', '__return_null');
|
||||
add_filter('pre_site_transient_update_plugins', '__return_null');
|
||||
add_filter('pre_site_transient_update_themes', '__return_null');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 加载飞行模式
|
||||
*/
|
||||
public function load_plane() {
|
||||
add_filter( 'pre_http_request', function ( $preempt, $parsed_args, $url ) {
|
||||
foreach ( (array) $this->settings['plane_rule'] as $rule ) {
|
||||
if ( empty( $rule['enable'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( empty( $rule['url'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( strpos( $url, $rule['url'] ) !== false ) {
|
||||
return new WP_Error( 'http_request_not_executed', '无用 URL 已屏蔽访问' );
|
||||
}
|
||||
}
|
||||
|
||||
return $preempt;
|
||||
}, PHP_INT_MAX, 3 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -290,7 +647,11 @@ class Super {
|
|||
* WordPress 讨论设置中的默认 LOGO 名称替换
|
||||
*/
|
||||
public function set_defaults_for_cravatar( $avatar_defaults ) {
|
||||
$avatar_defaults['gravatar_default'] = '初认头像';
|
||||
if ( $this->settings['cravatar'] == 'weavatar' ) {
|
||||
$avatar_defaults['gravatar_default'] = 'WeAvatar';
|
||||
} else {
|
||||
$avatar_defaults['gravatar_default'] = '初认头像';
|
||||
}
|
||||
|
||||
return $avatar_defaults;
|
||||
}
|
||||
|
@ -299,7 +660,11 @@ class Super {
|
|||
* 个人资料卡中的头像上传地址替换
|
||||
*/
|
||||
public function set_user_profile_picture_for_cravatar() {
|
||||
return '<a href="https://cravatar.com" target="_blank">您可以在初认头像修改您的资料图片</a>';
|
||||
if ( $this->settings['cravatar'] == 'weavatar' ) {
|
||||
return '<a href="https://weavatar.com" target="_blank">您可以在 WeAvatar 修改您的资料图片</a>';
|
||||
} else {
|
||||
return '<a href="https://cravatar.com" target="_blank">您可以在初认头像修改您的资料图片</a>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,13 +673,17 @@ class Super {
|
|||
* @param $replace_func string 要调用的字符串关键字替换函数
|
||||
* @param $param array 传递给字符串替换函数的参数
|
||||
*/
|
||||
private function page_str_replace( $replace_func, $param ) {
|
||||
add_action( 'init', function () use ( $replace_func, $param ) {
|
||||
private function page_str_replace( $hook, $replace_func, $param ) {
|
||||
// CLI 下返回,防止影响缓冲区
|
||||
if ( php_sapi_name() == 'cli' ) {
|
||||
return;
|
||||
}
|
||||
add_action( $hook, function () use ( $replace_func, $param ) {
|
||||
ob_start( function ( $buffer ) use ( $replace_func, $param ) {
|
||||
$param[] = $buffer;
|
||||
|
||||
return call_user_func_array( $replace_func, $param );
|
||||
} );
|
||||
}, 999999 );
|
||||
}, PHP_INT_MAX );
|
||||
}
|
||||
}
|
||||
|
|
0
Service/Update.php
Normal file → Executable file
0
Service/Update.php
Normal file → Executable file
7
assets/css/fonts.css
Executable file
7
assets/css/fonts.css
Executable file
|
@ -0,0 +1,7 @@
|
|||
html {
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
|
||||
font-family: -apple-system, "Noto Sans", "Helvetica Neue", Helvetica, "Nimbus Sans L", Arial, "Liberation Sans", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Source Han Sans CN", "Microsoft YaHei", "Wenquanyi Micro Hei", "WenQuanYi Zen Hei", "ST Heiti", SimHei, "WenQuanYi Zen Hei Sharp", sans-serif;
|
||||
}
|
539
assets/css/setting.css
Normal file → Executable file
539
assets/css/setting.css
Normal file → Executable file
|
@ -1,129 +1,454 @@
|
|||
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
|
||||
font-family: "Source Han Sans SC", "Noto Sans CJK SC", "Source Han Sans CN", "Noto Sans SC", "Source Han Sans TC", "Noto Sans CJK TC", sans-serif, -apple-system, "Noto Sans", "Helvetica Neue", Helvetica, "Nimbus Sans L", Arial, "Liberation Sans", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Source Han Sans CN", "Microsoft YaHei", "Wenquanyi Micro Hei", "WenQuanYi Zen Hei", "ST Heiti", SimHei, "WenQuanYi Zen Hei Sharp", sans-serif;
|
||||
#wpcontent {
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
#wpcontent, #wpfooter {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#wpbody-content {
|
||||
padding-bottom: 10%;
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
#wpfooter {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.notice {
|
||||
background-color: #f5f5f5;
|
||||
|
||||
@media only screen and (max-width: 782px) {
|
||||
.wp_china_yes-nav-normal+.wp_china_yes-content {
|
||||
margin-left: 0!important;
|
||||
}
|
||||
.wp_china_yes-header-inner h1 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.auto-fold #wpcontent {
|
||||
padding-left: 0px;
|
||||
}
|
||||
.wp_china_yes-field-text input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.left-column, .right-column {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.right-column {
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.card {
|
||||
background-color: #fff;
|
||||
padding: 10%;
|
||||
border-radius: 10px;
|
||||
text-transform: none;
|
||||
border: 0px solid #c3c4c7;
|
||||
font-size: 14px;
|
||||
line-height: 2;
|
||||
box-shadow: 0 0.375rem 1.5rem 0 rgba(141, 153, 165, 0.13);
|
||||
}
|
||||
|
||||
.card h3 {
|
||||
margin-top: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.card a, .left-column a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.card-body, .card-footer {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.card-footer a.button.button-primary {
|
||||
padding: 1% 5%;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.form-table th {
|
||||
width: 120px;
|
||||
padding: 5% 0;
|
||||
}
|
||||
|
||||
.form-table td {
|
||||
padding: 5% 0;
|
||||
}
|
||||
|
||||
.settings-header {
|
||||
padding-top: 20px;
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.settings-header .update-messages h2, .update-php h2, h4 {
|
||||
font-size: 15px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.settings-title-section {
|
||||
padding: 1% 0;
|
||||
}
|
||||
|
||||
.settings-footer p {
|
||||
font-size: 12px;
|
||||
line-height: 2;
|
||||
.wp-core-ui .button, .wp-core-ui .button-primary, .wp-core-ui .button-secondary {
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
.sponsor-logos {
|
||||
display: flex;
|
||||
display: block;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
margin: 24px 0;
|
||||
grid-gap: 24px;
|
||||
grid-template-columns: repeat(7, minmax(0, 1fr));
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sponsor-logos img {
|
||||
width: 26%;
|
||||
margin-bottom: 30px;
|
||||
flex-basis: calc(20% - 10px);
|
||||
max-width: 80px;
|
||||
margin: 13px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.contributors-name {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
padding: 20px 0;
|
||||
color: #dcdcde;
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
height: fit-content;
|
||||
flex-wrap: wrap;
|
||||
display: flex;
|
||||
grid-gap: 22px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 782px) {
|
||||
.auto-fold #wpcontent {
|
||||
padding: 10px;
|
||||
.wp_china_yes-content {
|
||||
position: relative;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
.wp_china_yes-content a {
|
||||
color: #3858e9;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.wp_china_yes-content a:active, a:focus, a:hover {
|
||||
color: #2c3338;
|
||||
}
|
||||
|
||||
.wp_china_yes-options {
|
||||
background-color: #ffffff;
|
||||
border-radius: 10px;
|
||||
text-transform: none;
|
||||
line-height: 2;
|
||||
}
|
||||
|
||||
.wp_china_yes-options {
|
||||
margin-top: 0px;
|
||||
margin-right: 0px;
|
||||
}
|
||||
|
||||
.wp_china_yes-field {
|
||||
padding: 8%;
|
||||
background-color: #ffffff;
|
||||
margin: 5% 0;
|
||||
border-radius: 1px;
|
||||
box-shadow: 0 0 0 1px #ccd0d4, 0 1px 1px 1px rgba(0, 0, 0, .04);
|
||||
}
|
||||
|
||||
.wp_china_yes-field.wp_china_yes-field-content {
|
||||
padding: 0;
|
||||
background-color: rgba(255, 255, 255, 0);
|
||||
margin: 0;
|
||||
border-radius: 0;
|
||||
box-shadow: unset;
|
||||
}
|
||||
.wp_china_yes-field-checkbox .wp_china_yes--inline-list li, .wp_china_yes-field-radio .wp_china_yes--inline-list li {
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.wp_china_yes-copyright p {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
.wp_china_yes-copyright {
|
||||
float: left;
|
||||
margin-top: 25px;
|
||||
margin-bottom: 35px;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
font-size: 12px;
|
||||
zoom: 90%;
|
||||
|
||||
}
|
||||
|
||||
.wp_china_yes-section {
|
||||
margin: 50px auto;
|
||||
max-width: 1000px;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
.wp_china_yes-field {
|
||||
position: relative;
|
||||
border: 0px solid #ccd0d4;
|
||||
}
|
||||
|
||||
.wp_china_yes-field+.wp_china_yes-field {
|
||||
border-top: 0px solid #eee;
|
||||
}
|
||||
.wp_china_yes-field-fieldset .wp_china_yes-fieldset-content {
|
||||
border: 0px solid #ccd0d4;
|
||||
}
|
||||
|
||||
.wp_china_yes-section-title {
|
||||
padding: 20px 30px;
|
||||
background-color: #fff;
|
||||
border-top: 0 solid #f5f5f5;
|
||||
border-bottom: 0px solid #eee;
|
||||
box-shadow: 0 0 0 1px #ccd0d4, 0 1px 1px 1px rgba(0, 0, 0, .04);
|
||||
}
|
||||
|
||||
.wp_china_yes-section-title h3 {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.wp_china_yes-section-title .wp_china_yes-section-icon {
|
||||
margin-right: 10px;
|
||||
width: 20px;
|
||||
height: 24px;
|
||||
line-height: 20px;
|
||||
font-size: 20px;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.wp_china_yes-field-subheading {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.wp_china_yes-theme-light .wp_china_yes-container {
|
||||
border: 0 solid #ccd0d4;
|
||||
}
|
||||
|
||||
.wp_china_yes-theme-light .wp_china_yes-header-inner {
|
||||
border-bottom: 1px solid #f5f5f5;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
|
||||
.wp_china_yes-theme-light .wp_china_yes-nav-background {
|
||||
background-color: #ffffff;
|
||||
border-right: 1px solid #dddddd;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.wp_china_yes-theme-light .wp_china_yes-footer {
|
||||
border-top: 1px solid #fff;
|
||||
background: #ffffff;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.wp_china_yes-field-heading {
|
||||
font-size: 1.4em;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.wp_china_yes-nav-normal {
|
||||
width: 205px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.wp_china_yes-nav {
|
||||
padding: 20px;
|
||||
}
|
||||
.wp_china_yes-nav-background {
|
||||
width: 250px;
|
||||
}
|
||||
.wp_china_yes-nav ul li a {
|
||||
font-size: 13px;
|
||||
position: relative;
|
||||
display: block;
|
||||
padding: 10px 15px;
|
||||
margin: 5px;
|
||||
text-decoration: none;
|
||||
transition-property: color, background;
|
||||
transition-duration: .2s;
|
||||
transition-timing-function: ease;
|
||||
}
|
||||
|
||||
.wp_china_yes-nav .wp_china_yes-tab-icon {
|
||||
margin-right: 10px;
|
||||
width: 20px;
|
||||
height: 24px;
|
||||
line-height: 20px;
|
||||
font-size: 20px;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.wp_china_yes-theme-light .wp_china_yes-nav ul li a {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.wp_china_yes-theme-light .wp_china_yes-nav ul li a:hover {
|
||||
color: #3858e9;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
.wp_china_yes-submessage-normal {
|
||||
border-color: #ffffff;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
|
||||
.wp_china_yes-nav-normal+.wp_china_yes-content {
|
||||
margin-left: 248px;
|
||||
}
|
||||
|
||||
.wp_china_yes-search-all .wp_china_yes-content, .wp_china_yes-show-all .wp_china_yes-content {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.wp_china_yes-theme-light .wp_china_yes-nav-normal > ul li a {
|
||||
border-bottom: 0px solid #f5f5f5;
|
||||
border-right: 0px solid #f5f5f5;
|
||||
}
|
||||
.wp_china_yes-theme-light .wp_china_yes-nav ul li .wp_china_yes-active {
|
||||
color: #111;
|
||||
background-color: #f5f5f7;
|
||||
background: #f5f5f7;
|
||||
}
|
||||
.wp_china_yes-field-group .wp_china_yes-cloneable-header-icon {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.wp_china_yes-field-group .wp_china_yes-cloneable-title {
|
||||
padding: 10px 65px 10px 10px;
|
||||
}
|
||||
|
||||
.wp_china_yes-field-group .ui-accordion .wp_china_yes-cloneable-item {
|
||||
padding: 2px 0;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.wp_china_yes-field-group .wp_china_yes-cloneable-helper {
|
||||
top: 15px;
|
||||
}
|
||||
|
||||
.wp_china_yes-field-group .wp_china_yes-cloneable-title {
|
||||
border: 1px solid #ccd0d4;
|
||||
background-color: #ffffff;
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
.wp_china_yes-field-group .wp_china_yes-cloneable-content {
|
||||
padding: 0;
|
||||
border-top: 1px solid #ffffff;
|
||||
}
|
||||
|
||||
.wp_china_yes-field-group .wp_china_yes-cloneable-content>.wp_china_yes-field {
|
||||
padding: 15px;
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
.wp_china_yes-sticky .wp_china_yes-header-inner {
|
||||
border-bottom: 1px solid #dddddd;
|
||||
background: #ffffff;
|
||||
}
|
||||
.wp_china_yes-sticky .wp_china_yes-header-inner {
|
||||
position: fixed;
|
||||
box-shadow: unset;
|
||||
}
|
||||
|
||||
.wp_china_yes-warning-primary {
|
||||
color: #5e77ec !important;
|
||||
border-color: #5e77ec !important;
|
||||
background: #ffffff !important;
|
||||
}
|
||||
|
||||
.wp_china_yes-warning-primary:focus, .wp_china_yes-warning-primary:hover {
|
||||
border-color: #3858e9 !important;
|
||||
background: #ffffff !important;
|
||||
}
|
||||
|
||||
.wp_china_yes-field-switcher .wp_china_yes--switcher:not(.wp_china_yes--active) {
|
||||
background-color: #9a9a9a;
|
||||
}
|
||||
|
||||
.wp_china_yes-theme-light .wp_china_yes-nav-normal > ul {
|
||||
margin-right: -2px;
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
|
||||
|
||||
@media screen and (max-width: 600px) {
|
||||
.wpcy-about__grid {
|
||||
grid-template-columns: 1fr!important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.container {
|
||||
flex-wrap: nowrap;
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.left-column {
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.right-column {
|
||||
width: 30%;
|
||||
}
|
||||
span.wpcy-icon-inner {
|
||||
line-height: 1px;
|
||||
font-size: 28px;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
span.wpcy-icon-inner-list {
|
||||
line-height: 0px;
|
||||
font-size: 24px;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.wpcy-about__grid {
|
||||
margin: 24px auto;
|
||||
display: grid;
|
||||
grid-gap: 24px;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.wpcy-kit__grid {
|
||||
margin: 24px auto;
|
||||
display: grid;
|
||||
grid-gap: 24px;
|
||||
grid-template-columns: repeat(1, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.column.wpcy-kit-banner {
|
||||
padding: 6% 6% 3%!important;
|
||||
}
|
||||
|
||||
.wpcy-about__grid .column {
|
||||
padding: 10%;
|
||||
background-color: #ffffff;
|
||||
border-radius: 1px;
|
||||
box-shadow: 0 0 0 1px #ccd0d4, 0 1px 1px 1px rgba(0, 0, 0, .04);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.wpcy-about__grid.columns-1 {
|
||||
grid-template-columns: repeat(1, minmax(0, 1fr));
|
||||
}
|
||||
.wpcy-about__grid.columns-3 {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
.wpcy-about__grid .column > svg {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin-left: -3px;
|
||||
}
|
||||
|
||||
.wpcy-buttons {
|
||||
margin-top: 4px;
|
||||
margin-bottom: 32px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
}
|
||||
.wpcy-banner img {
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
margin-top: auto;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.components-button.has-icon {
|
||||
justify-content: center;
|
||||
min-width: 36px;
|
||||
padding: 6px;
|
||||
}
|
||||
.components-button.has-icon.has-text {
|
||||
gap: 4px;
|
||||
justify-content: start;
|
||||
padding-left: 8px;
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
.wpcy-about__list li a:not(:hover) {
|
||||
text-decoration: none;
|
||||
}
|
||||
.components-button {
|
||||
align-items: center;
|
||||
-webkit-appearance: none;
|
||||
background: none;
|
||||
border: 0;
|
||||
border-radius: 2px;
|
||||
box-sizing: border-box;
|
||||
color: var(--wp-components-color-foreground, #1e1e1e);
|
||||
cursor: pointer;
|
||||
display: inline-flex
|
||||
;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
height: 36px;
|
||||
margin: 0;
|
||||
padding: 6px 12px;
|
||||
text-decoration: none;
|
||||
transition: box-shadow .1s linear;
|
||||
}
|
||||
.components-button.button-link {
|
||||
background: none;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
|
||||
height: auto;
|
||||
margin: 0;
|
||||
outline: none;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
text-decoration: underline;
|
||||
transition-duration: .05s;
|
||||
transition-property: border, background, color;
|
||||
transition-timing-function: ease-in-out;
|
||||
}
|
||||
.components-button.button-primary {
|
||||
display: inline-flex;
|
||||
padding: 6px 12px;
|
||||
}
|
||||
|
||||
.components-button.button-secondary {
|
||||
background: #0000;
|
||||
display: inline-flex;
|
||||
padding: 6px 12px;
|
||||
}
|
||||
|
||||
|
|
BIN
assets/images/qr-banner.jpg
Executable file
BIN
assets/images/qr-banner.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
BIN
assets/images/website-banner.jpg
Executable file
BIN
assets/images/website-banner.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
BIN
assets/images/wpcy-logo.png
Executable file
BIN
assets/images/wpcy-logo.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
33
assets/js/script.js
Executable file
33
assets/js/script.js
Executable file
|
@ -0,0 +1,33 @@
|
|||
jQuery(document).ready(function($) {
|
||||
$("#test-rss-feed").click(function() {
|
||||
var button = $(this);
|
||||
var result = $("#rss-test-result");
|
||||
var feedUrl = $("#custom_rss_url").val();
|
||||
|
||||
if (!feedUrl) {
|
||||
result.html('<span style="color: red;">请先填写 RSS 源地址</span>');
|
||||
return;
|
||||
}
|
||||
|
||||
button.prop("disabled", true);
|
||||
result.html("测试中...");
|
||||
|
||||
$.post(ajaxurl, {
|
||||
action: "test_rss_feed",
|
||||
_ajax_nonce: '<?php echo wp_create_nonce("wp_china_yes_nonce"); ?>',
|
||||
feed_url: feedUrl
|
||||
})
|
||||
.done(function(response) {
|
||||
result.html(response.success ?
|
||||
'<span style="color: green;">' + response.data + '</span>' :
|
||||
'<span style="color: red;">' + response.data + '</span>'
|
||||
);
|
||||
})
|
||||
.fail(function() {
|
||||
result.html('<span style="color: red;">测试失败</span>');
|
||||
})
|
||||
.always(function() {
|
||||
button.prop("disabled", false);
|
||||
});
|
||||
});
|
||||
});
|
325
changelog.txt
Executable file
325
changelog.txt
Executable file
|
@ -0,0 +1,325 @@
|
|||
IMPORTANT:
|
||||
-----------------------------------------------------------------------------------------
|
||||
Please be sure to read the Important Update Notes before you update:
|
||||
https://wpcy.com/document/important-update-information/
|
||||
We are always proactive in preventing security issues, however nobody can assume they will never come up.
|
||||
This is why we highly recommend to stay up to date with each new theme version and plugins.
|
||||
|
||||
重要提示:
|
||||
-----------------------------------------------------------------------------------------
|
||||
在更新之前,请务必阅读重要更新说明:
|
||||
https://wpcy.com/document/important-update-information/
|
||||
|
||||
我们始终致力于积极防范安全问题,但没有人能完全避免潜在风险。
|
||||
因此,我们强烈建议您密切关注每个主题和插件的新版本更新,以确保安全性和功能的最佳状态。
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.8 - 2025-01-01
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
* 文派叶子 v3.8 重大更新!全新UI 设计更接近 WordPress 原生体验。
|
||||
|
||||
1. 替换业务域名 WP-China-Yes.com 为新域名 WPCY.COM ;
|
||||
2. 修复 adminCDN 支持 jsDelivr 加速无效等问题;
|
||||
3. 新增 Bootstrap CDN 转接至 adminCDN 加速支持;
|
||||
4. 新增 Windfonts 中文排版优化:支持段首空格 2em;
|
||||
5. 新增 Windfonts 中文排版优化:支持文本内容对齐;
|
||||
6. 新增 [脉云维护] 菜单并支持WP系统状态监控,可在页脚位置显示内存、CPU用量等信息;
|
||||
7. 新增 [欢迎使用] 用户引导页面,更清晰的功能指导和简介。
|
||||
8. 新增 [建站工具] 文派·寻鹿建站套件展示页面,内容待完善。
|
||||
9. 优化 [萌芽加速] 设置,与 WordPress 程序端加速选项分离便于添加后续项目;
|
||||
10. 优化 [关于插件] 页面更简约的赞助商 Logo 和贡献者名单展示。
|
||||
11. 补充 changelog.txt 文本文件,跟随插件副本分发。
|
||||
12. 补充 copyright.txt 版权文件,跟随插件副本分发。
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.7.1 - 2024-11-19
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 性能优化
|
||||
2. 修复监控无法关闭的问题
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.6.5 - 2024-08-23
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 优化 CLI 判断
|
||||
2. 回退替换钩子修改
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.6.4 - 2024-08-23
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. WP-CLI 下不运行 adminCDN 部分,防止影响缓冲区。
|
||||
2. 部分文案调整支持多语言。
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.6.3 - 2024-08-23
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 为自动监控功能添加开关
|
||||
2. adminCDN 支持 jsDelivr 加速
|
||||
3. Windfonts 支持优化模式开关
|
||||
|
||||
**adminCDN 的 jsd 加速默认屏蔽 gh 端点,如有主题插件作者需要使用请联系加白。**
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.6.2 - 2024-03-09
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. UI 重构
|
||||
2. 修复市场加速导致 Beta 测试插件失效的问题
|
||||
3. 更新接口及测试 URL
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.6.1 - 2024-03-08
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 重构全部代码
|
||||
2. 应用市场调整为[文派开源](https://wenpai.org)
|
||||
3. 加速服务调整为[萌芽加速](https://admincdn.com)
|
||||
4. 头像调整为[初认头像](https://cravatar.com)
|
||||
5. 支持自动检测节点可用性
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
发展历史
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
- 2019 年 2022 年 @薇晓朵 为 WP 中文本地化项目提供各项赞助支持,期间陆续数十万的资金。
|
||||
- 2022 年起至 2023 年 3 月,原有 LitePress 及 WP 中文本土化社区项目进入维护状态,不再活跃;
|
||||
- 2023 年 3 月由 @薇晓朵(Weixiaoduo.com)联系原项目团队咨询相关发展情况,得知已无继续开发此项目的意向。
|
||||
- 此时文派开源(WenPai.org)项目也处于筹备启动基础设施建设阶段。
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
项目重启
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
- 了解到此项目实际情况并商议后,文派(广州)科技有限公司决定收购此项目并启动旗下————文派开源(WenPai.org)。
|
||||
- 2023 年 4 月 10 日文派科技公布收购 LitePress 社区声明 https://wpcy.com/news/acquisition-announcement
|
||||
- 2023 年 4 月 25 日 WP-China-Yes 发布中文品牌词——“文派叶子”,寓意生生不息。
|
||||
- 2023 年 5 月 LitePress 、Cravatar 、WP-China-Yes 等项目重启,进入正式交接重启开发阶段。
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
投资机构:汉中菲比斯网络技术有限公司
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
投资项目:文派(WordPress)中国生态基础设施建设、文派开源中国本土化 WordPress 发行版及社区建设。
|
||||
投资金额:一百万人民币(一期)
|
||||
基础资源:三百个 WP 行业属性稀缺域名资源,以及 “文派” 品牌、商标、软著、专利等知识产权。
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
委托机构:文派(广州)科技有限公司
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
技术支持:薇晓朵团队 - Weixiaoduo.com
|
||||
营销支持:莫蒂奇团队 - Modiqi.com
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooooooooooo&&B&oooooooooooooooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooooo#B&oo&#B#ooooooooooooooooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooooBG&o#BBB&oooooooooooooooooooooooooooooooooooooooooo
|
||||
ooooooooooooooooooooooooooooooooo#BGGBG#&ooooooooooooooooooooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooo#BGGGGGG&ooooooooooooooooooooooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooo&&#GGGGGB&oooooooooooooooooooooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooBGGGGGGGB##&&&&&#####&&oooooooooooooooooooooooooooooo
|
||||
ooooooooooooooooooooooooooooooooo&GGGGGGGGGGGGGGGGGGGGGGBB#ooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooo#GGGGGGGGGGGGGGGGGGGGGG&#ooooooooooooooooooooooooooo
|
||||
ooooooooooooooooooooooooooooooooooo#GGGGGGGGGGGGGGGGGGGG#ooooooooooooooooooooooooooooo
|
||||
ooooooooooooooooooooooooooooooooooooo#BGGGGGGGBB##&BGGGGB&oooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooooooooGGG&ooooooooo#GGBBGB&oooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooooooo#GBGooooooooooo&GBooG#oooooooooooooooooooooooooo
|
||||
ooooooooooooooooooooooooooooooooooooooooG#oooooooooooB#ooo##oooooooooooooooooooooooooo
|
||||
ooooooooooooooooooooooooooooooooooooooo#G#ooooooooooo&G&oo##oooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooooooooB#&&oooooooooB#oooo##oooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooooooooooooooooooooo#&oooooooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooo##———— www.feibisi.com ————##ooooooooooooooooooooooooooooooo
|
||||
ooooooooooooooooooooooooooo####菲比斯 · 品味简单生活####ooooooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
|
||||
ooooooooooo(此项目于 2023 年 4 月重启,由菲比斯公司提供了初始一百万启动投资。)ooooooooooo
|
||||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
|
||||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
2022 年 ~ 2023 年 3 月
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
此项目及 LitePress 社区发展已停滞,前景不明。
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.5.5 - 2022-11-15 此为前团队发布最后一版。
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
修复
|
||||
1. 仓库源替换代码优先级过低被覆盖的问题
|
||||
|
||||
重构
|
||||
1. 去掉 CDNJS 功能;
|
||||
2. 修改 WP China 标志为 LitePress
|
||||
3. 替换各种加速节点链接为 LitePress 维护的地址
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.5.4 - 2024-03-08
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
特性
|
||||
1. CDNJS加速功能
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.5.3 - 2024-03-08
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
修复
|
||||
1. 核心功能无法在 Cron 环境中运行的问题
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.5.2 - 2024-03-08
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
修复
|
||||
1. 留下测试代码
|
||||
2. 当未拦截到 API 请求时直接返回 WordPress 到底是什么响应值,而不是 false,该问题会导致其他插件无法调用 pre_http_request 过滤器
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.5.1 - 2021-10-01
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
修复
|
||||
1. 不为 LitePress 替换后台资源
|
||||
2. 完善Cravatar头像夺取机制
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.5.0 - 2021-09-05
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
特性
|
||||
1. 将“本土应用市场”更改为“LitePress 应用市场”,进而对接 LitePress 翻译平台
|
||||
2. “参与翻译”按钮全局生效
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.4.1 - 2021-08-15
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
修复
|
||||
1. 不为处于RC版本的WordPress替换后台静态资源
|
||||
2. 替换默认头像处的Gravatar字样
|
||||
3. 替换个人资料卡中的头像设置说明
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.4.0 - 2021-07-27
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
特性
|
||||
1. 将 Gravatar 头像替换方案由反代更改为 Cravatar(任何开发者均可在自己的产品中集成 Cravatar 头像服务)
|
||||
修复
|
||||
2. 修复了某些情况下无法替换 Gravatar 头像的问题
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.4.0 - 2021-07-27
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 修复:管理后台加速功能因用户反馈问题较多,故暂时默认关闭
|
||||
2. 修复:后台加速功能误对处于测试状态的WordPress起作用的问题
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.3.1 - 2020-10-28
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 修复:管理后台加速功能因用户反馈问题较多,故暂时默认关闭
|
||||
2. 修复:后台加速功能误对处于测试状态的WordPress起作用的问题
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.3.0 - 2020-10-14
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 特性:当使用“本土应用市场”时为插件列表中的所有插件追加“翻译校准”链接
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.2.0 - 2020-10-07
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 特性:支持谷歌前端公共库加速
|
||||
2. 特性:细化管理界面设置的颗粒度
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.1.3 - 2020-09-18
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 修复:多站点模式下可以在子站点激活插件的BUG
|
||||
2. 修复:多站点模式下无法保存配置的BUG
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.1.2 - 2020-08-30
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 修复:兼容WordPress多站点模式(只在主控上显示设置项)
|
||||
2. 修复:插件更新后设置项被覆盖的问题
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.1.1 - 2020-08-27
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
特性
|
||||
1. 增加管理后台加速功能,原理是将WordPress核心依赖的静态文件切换为公共资源,这将极大的加快管理后台访问速度^_^
|
||||
2. 增加”不接管应用市场“选项
|
||||
|
||||
修复
|
||||
1. 对AJAX加载的场景做了较为详尽的适配,节约每一点服务器资源
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v3.0.0 - 2020-08-15
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 使用WordPress默认组件重写设置页面
|
||||
2. 增加Gravatar加速支持
|
||||
3. 增加谷歌字体加速支持
|
||||
4. 对接本土应用市场,这个应用市场与本土翻译平台深度整合,可以大家进行基于AI翻译+人工辅助调整的全量汉化支持(技术试验)
|
||||
5. “仓库源-主源”更名为“官方应用市场镜像”
|
||||
6. 移除“自定义源”功能
|
||||
7. 移除“资源”
|
||||
8. 删除仪表盘赞助商列表
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v2.1.0 - 2020-04-11
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 取消社区源选择功能,只保留主源和备源
|
||||
2. 禁止设置页的tab
|
||||
3. 在仪表盘上放置了赞助者名单展示小部件(可关闭)
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v2.0.3 - 2020-03-20
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 修复修改仓库源后刷新页面无法正确展示源信息的问题
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v2.0.2 - 2020-03-18
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. RepairAPI接口编写的不规范的问题#7
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v2.0.1 - 2020-03-18
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 修复插件无法在使用子目录部署的 WordPress 上运行的问题#6
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v2.0.0 - 2020-03-12
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
从这个版本开始WP-China-是第一次拥有了图形化设置界面
|
||||
|
||||
1. 社区资源
|
||||
2. 来源支持
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
v1.0.1 - 2020-03-12
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. 核心功能
|
6
composer.json
Normal file → Executable file
6
composer.json
Normal file → Executable file
|
@ -3,16 +3,16 @@
|
|||
"description": "WordPress Optimized Plugin for Mainland China",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"thetnb/wp-setting-api": "^2.0",
|
||||
"yahnis-elsts/plugin-update-checker": "^5.2"
|
||||
},
|
||||
"license": "MIT",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"WenPai\\ChinaYes\\": "./"
|
||||
},
|
||||
"files": [
|
||||
"helpers.php"
|
||||
"helpers.php",
|
||||
"framework/classes/setup.class.php"
|
||||
]
|
||||
},
|
||||
"authors": [
|
||||
|
|
60
composer.lock
generated
Normal file → Executable file
60
composer.lock
generated
Normal file → Executable file
|
@ -4,64 +4,20 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "19512e097932a150b6ccc5f8044c62ed",
|
||||
"content-hash": "46cf14a68ffba471ee1e2f603a301a9c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "thetnb/wp-setting-api",
|
||||
"version": "2.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/TheTNB/wp-setting-api.git",
|
||||
"reference": "0e34224dfe0832fd3bf29e2e3c054a2aad603f84"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/TheTNB/wp-setting-api/zipball/0e34224dfe0832fd3bf29e2e3c054a2aad603f84",
|
||||
"reference": "0e34224dfe0832fd3bf29e2e3c054a2aad603f84",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.6"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"TheTNB\\Setting\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-3.0-or-later"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "耗子",
|
||||
"email": "i@haozi.net"
|
||||
}
|
||||
],
|
||||
"description": "WordPress Setting API for developers",
|
||||
"homepage": "https://github.com/thetnb/wp-setting-api",
|
||||
"keywords": [
|
||||
"wordpress"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/TheTNB/wp-setting-api/issues",
|
||||
"source": "https://github.com/TheTNB/wp-setting-api/tree/2.0.2"
|
||||
},
|
||||
"time": "2024-03-08T07:11:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "yahnis-elsts/plugin-update-checker",
|
||||
"version": "v5.4",
|
||||
"version": "v5.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/YahnisElsts/plugin-update-checker.git",
|
||||
"reference": "e8e53e6d98e37fa7c895c93417f52e3775494715"
|
||||
"reference": "845d65da93bcff31649ede00d9d73b1beadbb7f0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/e8e53e6d98e37fa7c895c93417f52e3775494715",
|
||||
"reference": "e8e53e6d98e37fa7c895c93417f52e3775494715",
|
||||
"url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/845d65da93bcff31649ede00d9d73b1beadbb7f0",
|
||||
"reference": "845d65da93bcff31649ede00d9d73b1beadbb7f0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -71,7 +27,7 @@
|
|||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"load-v5p4.php"
|
||||
"load-v5p5.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
|
@ -96,9 +52,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/YahnisElsts/plugin-update-checker/issues",
|
||||
"source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v5.4"
|
||||
"source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v5.5"
|
||||
},
|
||||
"time": "2024-02-24T09:56:49+00:00"
|
||||
"time": "2024-10-16T14:25:00+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
|
36
copyright.txt
Executable file
36
copyright.txt
Executable file
|
@ -0,0 +1,36 @@
|
|||
-----------------------------------------------------------------------------------------
|
||||
**Copyright © 2025 WenPai.cn (Guangzhou) Technology Co., Ltd.**
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
**Compliance Terms**
|
||||
Everyone is free to use WenPai open-source software.However, in China, when using WenPai software,
|
||||
you must adhere to the GPL open-source license, respect the intellectual property rights of others,
|
||||
and prioritize compliance with Chinese laws in case of any conflicts.
|
||||
|
||||
**Fork Declaration**
|
||||
To ensure the long-term availability of various Wenpai (WordPress) infrastructure components,
|
||||
individuals with the necessary capabilities are welcome to establish their own service sources
|
||||
or fork WenPai Leaf 🍃 WP-China-Yes (WPCY) to create their own versions.
|
||||
|
||||
**The Only Requirement:**
|
||||
While strictly adhering to the GPL license, you must respect all lawful rights of WenPai Technology,
|
||||
including (but not limited to) copyrights, trademarks, patents, intellectual property, goodwill, and more.
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
**版权所有 © 2025 年 文派(广州)科技有限公司**
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
**合规条款**
|
||||
任何人都可以自由使用文派开源软件,但在中国,当您使用文派软件时,您应在遵守 GPL 开源协议的同时,
|
||||
尊重他人的知识产权,同时有违背中国法律的情况时皆以中国法律为准。
|
||||
|
||||
**分叉声明**
|
||||
为保障各项文派 (WordPress) 基础设施的长久可用性,
|
||||
欢迎有能力的人自建各类服务源以及分叉文派叶子🍃(WPCY)来制作您自己的版本;
|
||||
|
||||
**唯一要求:**
|
||||
在严格遵守 GPL 协议的前提下,尊重文派科技的各项合法权益,
|
||||
包括 (不限于) 版权、商标、专利、知识产权、商誉等…
|
||||
|
||||
|
||||
|
1
framework/assets/css/style-rtl.min.css
vendored
Executable file
1
framework/assets/css/style-rtl.min.css
vendored
Executable file
File diff suppressed because one or more lines are too long
1
framework/assets/css/style.min.css
vendored
Executable file
1
framework/assets/css/style.min.css
vendored
Executable file
File diff suppressed because one or more lines are too long
BIN
framework/assets/images/checkerboard.png
Executable file
BIN
framework/assets/images/checkerboard.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
1
framework/assets/images/wp-logo.svg
Executable file
1
framework/assets/images/wp-logo.svg
Executable file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><rect x="0" fill="none" width="20" height="20"/><g><g fill="#fff"><path d="M20 10c0-5.52-4.48-10-10-10S0 4.48 0 10s4.48 10 10 10 10-4.48 10-10zM10 1.01c4.97 0 8.99 4.02 8.99 8.99s-4.02 8.99-8.99 8.99S1.01 14.97 1.01 10 5.03 1.01 10 1.01zM8.01 14.82L4.96 6.61c.49-.03 1.05-.08 1.05-.08.43-.05.38-1.01-.06-.99 0 0-1.29.1-2.13.1-.15 0-.33 0-.52-.01 1.44-2.17 3.9-3.6 6.7-3.6 2.09 0 3.99.79 5.41 2.09-.6-.08-1.45.35-1.45 1.42 0 .66.38 1.22.79 1.88.31.54.5 1.22.5 2.21 0 1.34-1.27 4.48-1.27 4.48l-2.71-7.5c.48-.03.75-.16.75-.16.43-.05.38-1.1-.05-1.08 0 0-1.3.11-2.14.11-.78 0-2.11-.11-2.11-.11-.43-.02-.48 1.06-.05 1.08l.84.08 1.12 3.04zm6.02 2.15L16.64 10s.67-1.69.39-3.81c.63 1.14.94 2.42.94 3.81 0 2.96-1.56 5.58-3.94 6.97zM2.68 6.77L6.5 17.25c-2.67-1.3-4.47-4.08-4.47-7.25 0-1.16.2-2.23.65-3.23zm7.45 4.53l2.29 6.25c-.75.27-1.57.42-2.42.42-.72 0-1.41-.11-2.06-.3z"/></g></g></svg>
|
After Width: | Height: | Size: 940 B |
1
framework/assets/images/wp-plugin-logo.svg
Executable file
1
framework/assets/images/wp-plugin-logo.svg
Executable file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><rect x="0" fill="none" width="20" height="20"/><g><g fill="#fff"><path d="M13.11 4.36L9.87 7.6 8 5.73l3.24-3.24c.35-.34 1.05-.2 1.56.32.52.51.66 1.21.31 1.55zm-8 1.77l.91-1.12 9.01 9.01-1.19.84c-.71.71-2.63 1.16-3.82 1.16H6.14L4.9 17.26c-.59.59-1.54.59-2.12 0-.59-.58-.59-1.53 0-2.12l1.24-1.24v-3.88c0-1.13.4-3.19 1.09-3.89zm7.26 3.97l3.24-3.24c.34-.35 1.04-.21 1.55.31.52.51.66 1.21.31 1.55l-3.24 3.25z"/></g></g></svg>
|
After Width: | Height: | Size: 482 B |
2
framework/assets/js/main.min.js
vendored
Executable file
2
framework/assets/js/main.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
2
framework/assets/js/plugins.min.js
vendored
Executable file
2
framework/assets/js/plugins.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
195
framework/classes/abstract.class.php
Executable file
195
framework/classes/abstract.class.php
Executable file
|
@ -0,0 +1,195 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Abstract Class
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Abstract' ) ) {
|
||||
#[AllowDynamicProperties]
|
||||
abstract class WP_CHINA_YES_Abstract {
|
||||
|
||||
public $abstract = '';
|
||||
public $output_css = '';
|
||||
|
||||
public function __construct() {
|
||||
|
||||
// Collect output css and typography
|
||||
if ( ! empty( $this->args['output_css'] ) || ! empty( $this->args['enqueue_webfont'] ) ) {
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'collect_output_css_and_typography' ), 10 );
|
||||
WP_CHINA_YES::$css = apply_filters( "wp_china_yes_{$this->unique}_output_css", WP_CHINA_YES::$css, $this );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function collect_output_css_and_typography() {
|
||||
$this->recursive_output_css( $this->pre_fields );
|
||||
}
|
||||
|
||||
public function recursive_output_css( $fields = array(), $combine_field = array() ) {
|
||||
|
||||
if ( ! empty( $fields ) ) {
|
||||
|
||||
foreach ( $fields as $field ) {
|
||||
|
||||
$field_id = ( ! empty( $field['id'] ) ) ? $field['id'] : '';
|
||||
$field_type = ( ! empty( $field['type'] ) ) ? $field['type'] : '';
|
||||
$field_output = ( ! empty( $field['output'] ) ) ? $field['output'] : '';
|
||||
$field_check = ( $field_type === 'typography' || $field_output ) ? true : false;
|
||||
$field_class = 'WP_CHINA_YES_Field_' . $field_type;
|
||||
|
||||
if ( $field_type && $field_id ) {
|
||||
|
||||
|
||||
if( $field_type === 'fieldset' ) {
|
||||
if ( ! empty( $field['fields'] ) ) {
|
||||
$this->recursive_output_css( $field['fields'], $field );
|
||||
}
|
||||
}
|
||||
|
||||
if( $field_type === 'accordion' ) {
|
||||
if ( ! empty( $field['accordions'] ) ) {
|
||||
foreach ( $field['accordions'] as $accordion ) {
|
||||
$this->recursive_output_css( $accordion['fields'], $field );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $field_type === 'tabbed' ) {
|
||||
if ( ! empty( $field['tabs'] ) ) {
|
||||
foreach ( $field['tabs'] as $accordion ) {
|
||||
$this->recursive_output_css( $accordion['fields'], $field );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( class_exists( $field_class ) ) {
|
||||
|
||||
if ( method_exists( $field_class, 'output' ) || method_exists( $field_class, 'enqueue_google_fonts' ) ) {
|
||||
|
||||
$field_value = '';
|
||||
|
||||
if ( $field_check && ( $this->abstract === 'options' || $this->abstract === 'customize' ) ) {
|
||||
|
||||
if( ! empty( $combine_field ) ) {
|
||||
|
||||
$field_value = ( isset( $this->options[$combine_field['id']][$field_id] ) ) ? $this->options[$combine_field['id']][$field_id] : '';
|
||||
|
||||
} else {
|
||||
|
||||
$field_value = ( isset( $this->options[$field_id] ) ) ? $this->options[$field_id] : '';
|
||||
|
||||
}
|
||||
|
||||
} else if ( $field_check && ( $this->abstract === 'metabox' && is_singular() || $this->abstract === 'taxonomy' && is_archive() ) ) {
|
||||
|
||||
if( ! empty( $combine_field ) ) {
|
||||
|
||||
$meta_value = $this->get_meta_value( $combine_field );
|
||||
$field_value = ( isset( $meta_value[$field_id] ) ) ? $meta_value[$field_id] : '';
|
||||
|
||||
} else {
|
||||
|
||||
$meta_value = $this->get_meta_value( $field );
|
||||
$field_value = ( isset( $meta_value ) ) ? $meta_value : '';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$instance = new $field_class( $field, $field_value, $this->unique, 'wp/enqueue', $this );
|
||||
|
||||
// typography enqueue and embed google web fonts
|
||||
if ( $field_type === 'typography' && $this->args['enqueue_webfont'] && ! empty( $field_value['font-family'] ) ) {
|
||||
|
||||
$method = ( ! empty( $this->args['async_webfont'] ) ) ? 'async' : 'enqueue';
|
||||
|
||||
$instance->enqueue_google_fonts( $method );
|
||||
|
||||
}
|
||||
|
||||
// output css
|
||||
if ( $field_output && $this->args['output_css'] ) {
|
||||
WP_CHINA_YES::$css .= $instance->output();
|
||||
}
|
||||
|
||||
unset( $instance );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function pre_tabs( $sections ) {
|
||||
|
||||
$count = 100;
|
||||
$result = array();
|
||||
$parents = array();
|
||||
|
||||
foreach ( $sections as $key => $section ) {
|
||||
if ( ! empty( $section['parent'] ) ) {
|
||||
$section['priority'] = ( isset( $section['priority'] ) ) ? $section['priority'] : $count;
|
||||
$parents[$section['parent']][] = $section;
|
||||
unset( $sections[$key] );
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
|
||||
foreach ( $sections as $key => $section ) {
|
||||
$section['priority'] = ( isset( $section['priority'] ) ) ? $section['priority'] : $count;
|
||||
if ( ! empty( $section['id'] ) && ! empty( $parents[$section['id']] ) ) {
|
||||
$section['subs'] = wp_list_sort( $parents[$section['id']], array( 'priority' => 'ASC' ), 'ASC', true );
|
||||
}
|
||||
$result[] = $section;
|
||||
$count++;
|
||||
}
|
||||
|
||||
return wp_list_sort( $result, array( 'priority' => 'ASC' ), 'ASC', true );
|
||||
|
||||
}
|
||||
|
||||
public function pre_sections( $sections ) {
|
||||
|
||||
$result = array();
|
||||
|
||||
foreach ( $this->pre_tabs( $sections ) as $section ) {
|
||||
if ( ! empty( $section['subs'] ) ) {
|
||||
foreach ( $section['subs'] as $sub ) {
|
||||
$sub['ptitle'] = ( ! empty( $section['title'] ) ) ? $section['title'] : '';
|
||||
$result[] = $sub;
|
||||
}
|
||||
}
|
||||
if ( empty( $section['subs'] ) ) {
|
||||
$result[] = $section;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function pre_fields( $sections ) {
|
||||
|
||||
$result = array();
|
||||
|
||||
foreach ( $sections as $key => $section ) {
|
||||
if ( ! empty( $section['fields'] ) ) {
|
||||
foreach ( $section['fields'] as $field ) {
|
||||
$result[] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
688
framework/classes/admin-options.class.php
Executable file
688
framework/classes/admin-options.class.php
Executable file
|
@ -0,0 +1,688 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Options Class
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Options' ) ) {
|
||||
class WP_CHINA_YES_Options extends WP_CHINA_YES_Abstract {
|
||||
|
||||
// constans
|
||||
public $unique = '';
|
||||
public $notice = '';
|
||||
public $abstract = 'options';
|
||||
public $sections = array();
|
||||
public $options = array();
|
||||
public $errors = array();
|
||||
public $pre_tabs = array();
|
||||
public $pre_fields = array();
|
||||
public $pre_sections = array();
|
||||
public $args = array(
|
||||
|
||||
// framework title
|
||||
'framework_title' => 'Wp_china_yes Framework <small>by Wp_china_yes</small>',
|
||||
'framework_class' => '',
|
||||
|
||||
// menu settings
|
||||
'menu_title' => '',
|
||||
'menu_slug' => '',
|
||||
'menu_type' => 'menu',
|
||||
'menu_capability' => 'manage_options',
|
||||
'menu_icon' => null,
|
||||
'menu_position' => null,
|
||||
'menu_hidden' => false,
|
||||
'menu_parent' => '',
|
||||
'sub_menu_title' => '',
|
||||
|
||||
// menu extras
|
||||
'show_bar_menu' => true,
|
||||
'show_sub_menu' => true,
|
||||
'show_in_network' => true,
|
||||
'show_in_customizer' => false,
|
||||
|
||||
'show_search' => true,
|
||||
'show_reset_all' => true,
|
||||
'show_reset_section' => true,
|
||||
'show_footer' => true,
|
||||
'show_all_options' => true,
|
||||
'show_form_warning' => true,
|
||||
'sticky_header' => true,
|
||||
'save_defaults' => true,
|
||||
'ajax_save' => true,
|
||||
'form_action' => '',
|
||||
|
||||
// admin bar menu settings
|
||||
'admin_bar_menu_icon' => '',
|
||||
'admin_bar_menu_priority' => 50,
|
||||
|
||||
// footer
|
||||
'footer_text' => 'Thank you for creating with Wp_china_yes Framework',
|
||||
'footer_after' => '',
|
||||
'footer_credit' => '',
|
||||
|
||||
// database model
|
||||
'database' => '', // options, transient, theme_mod, network
|
||||
'transient_time' => 0,
|
||||
|
||||
// contextual help
|
||||
'contextual_help' => array(),
|
||||
'contextual_help_sidebar' => '',
|
||||
|
||||
// typography options
|
||||
'enqueue_webfont' => true,
|
||||
'async_webfont' => false,
|
||||
|
||||
// others
|
||||
'output_css' => true,
|
||||
|
||||
// theme
|
||||
'nav' => 'normal',
|
||||
'theme' => 'dark',
|
||||
'class' => '',
|
||||
|
||||
// external default values
|
||||
'defaults' => array(),
|
||||
|
||||
);
|
||||
|
||||
// run framework construct
|
||||
public function __construct( $key, $params = array() ) {
|
||||
|
||||
$this->unique = $key;
|
||||
$this->args = apply_filters( "wp_china_yes_{$this->unique}_args", wp_parse_args( $params['args'], $this->args ), $this );
|
||||
$this->sections = apply_filters( "wp_china_yes_{$this->unique}_sections", $params['sections'], $this );
|
||||
|
||||
// run only is admin panel options, avoid performance loss
|
||||
$this->pre_tabs = $this->pre_tabs( $this->sections );
|
||||
$this->pre_fields = $this->pre_fields( $this->sections );
|
||||
$this->pre_sections = $this->pre_sections( $this->sections );
|
||||
|
||||
$this->get_options();
|
||||
$this->set_options();
|
||||
$this->save_defaults();
|
||||
|
||||
add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
|
||||
add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_menu' ), $this->args['admin_bar_menu_priority'] );
|
||||
add_action( 'wp_ajax_wp_china_yes_'. $this->unique .'_ajax_save', array( $this, 'ajax_save' ) );
|
||||
|
||||
if ( $this->args['database'] === 'network' && ! empty( $this->args['show_in_network'] ) ) {
|
||||
add_action( 'network_admin_menu', array( $this, 'add_admin_menu' ) );
|
||||
}
|
||||
|
||||
// wp enqeueu for typography and output css
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
// instance
|
||||
public static function instance( $key, $params = array() ) {
|
||||
return new self( $key, $params );
|
||||
}
|
||||
|
||||
// add admin bar menu
|
||||
public function add_admin_bar_menu( $wp_admin_bar ) {
|
||||
|
||||
if ( ! current_user_can( $this->args['menu_capability'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_network_admin() && ( $this->args['database'] !== 'network' || $this->args['show_in_network'] !== true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! empty( $this->args['show_bar_menu'] ) && empty( $this->args['menu_hidden'] ) ) {
|
||||
|
||||
global $submenu;
|
||||
|
||||
$menu_slug = $this->args['menu_slug'];
|
||||
$menu_icon = ( ! empty( $this->args['admin_bar_menu_icon'] ) ) ? '<span class="wp_china_yes-ab-icon ab-icon '. esc_attr( $this->args['admin_bar_menu_icon'] ) .'"></span>' : '';
|
||||
|
||||
$wp_admin_bar->add_node( array(
|
||||
'id' => $menu_slug,
|
||||
'title' => $menu_icon . esc_attr( $this->args['menu_title'] ),
|
||||
'href' => esc_url( ( is_network_admin() ) ? network_admin_url( 'admin.php?page='. $menu_slug ) : admin_url( 'admin.php?page='. $menu_slug ) ),
|
||||
) );
|
||||
|
||||
if ( ! empty( $submenu[$menu_slug] ) ) {
|
||||
foreach ( $submenu[$menu_slug] as $menu_key => $menu_value ) {
|
||||
$wp_admin_bar->add_node( array(
|
||||
'parent' => $menu_slug,
|
||||
'id' => $menu_slug .'-'. $menu_key,
|
||||
'title' => $menu_value[0],
|
||||
'href' => esc_url( ( is_network_admin() ) ? network_admin_url( 'admin.php?page='. $menu_value[2] ) : admin_url( 'admin.php?page='. $menu_value[2] ) ),
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function ajax_save() {
|
||||
|
||||
$result = $this->set_options( true );
|
||||
|
||||
if ( ! $result ) {
|
||||
wp_send_json_error( array( 'error' => esc_html__( 'Error while saving the changes.', 'wp_china_yes' ) ) );
|
||||
} else {
|
||||
wp_send_json_success( array( 'notice' => $this->notice, 'errors' => $this->errors ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// get default value
|
||||
public function get_default( $field ) {
|
||||
|
||||
$default = ( isset( $field['default'] ) ) ? $field['default'] : '';
|
||||
$default = ( isset( $this->args['defaults'][$field['id']] ) ) ? $this->args['defaults'][$field['id']] : $default;
|
||||
|
||||
return $default;
|
||||
|
||||
}
|
||||
|
||||
// save defaults and set new fields value to main options
|
||||
public function save_defaults() {
|
||||
|
||||
$tmp_options = $this->options;
|
||||
|
||||
foreach ( $this->pre_fields as $field ) {
|
||||
if ( ! empty( $field['id'] ) ) {
|
||||
$this->options[$field['id']] = ( isset( $this->options[$field['id']] ) ) ? $this->options[$field['id']] : $this->get_default( $field );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->args['save_defaults'] && empty( $tmp_options ) ) {
|
||||
$this->save_options( $this->options );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// set options
|
||||
public function set_options( $ajax = false ) {
|
||||
|
||||
// XSS ok.
|
||||
// No worries, This "POST" requests is sanitizing in the below foreach. see #L337 - #L341
|
||||
$response = ( $ajax && ! empty( $_POST['data'] ) ) ? json_decode( wp_unslash( trim( $_POST['data'] ) ), true ) : $_POST;
|
||||
|
||||
// Set variables.
|
||||
$data = array();
|
||||
$noncekey = 'wp_china_yes_options_nonce'. $this->unique;
|
||||
$nonce = ( ! empty( $response[$noncekey] ) ) ? $response[$noncekey] : '';
|
||||
$options = ( ! empty( $response[$this->unique] ) ) ? $response[$this->unique] : array();
|
||||
$transient = ( ! empty( $response['wp_china_yes_transient'] ) ) ? $response['wp_china_yes_transient'] : array();
|
||||
|
||||
if ( wp_verify_nonce( $nonce, 'wp_china_yes_options_nonce' ) ) {
|
||||
|
||||
$importing = false;
|
||||
$section_id = ( ! empty( $transient['section'] ) ) ? $transient['section'] : '';
|
||||
|
||||
if ( ! $ajax && ! empty( $response[ 'wp_china_yes_import_data' ] ) ) {
|
||||
|
||||
// XSS ok.
|
||||
// No worries, This "POST" requests is sanitizing in the below foreach. see #L337 - #L341
|
||||
$import_data = json_decode( wp_unslash( trim( $response[ 'wp_china_yes_import_data' ] ) ), true );
|
||||
$options = ( is_array( $import_data ) && ! empty( $import_data ) ) ? $import_data : array();
|
||||
$importing = true;
|
||||
$this->notice = esc_html__( 'Settings successfully imported.', 'wp_china_yes' );
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty( $transient['reset'] ) ) {
|
||||
|
||||
foreach ( $this->pre_fields as $field ) {
|
||||
if ( ! empty( $field['id'] ) ) {
|
||||
$data[$field['id']] = $this->get_default( $field );
|
||||
}
|
||||
}
|
||||
|
||||
$this->notice = esc_html__( 'Default settings restored.', 'wp_china_yes' );
|
||||
|
||||
} else if ( ! empty( $transient['reset_section'] ) && ! empty( $section_id ) ) {
|
||||
|
||||
if ( ! empty( $this->pre_sections[$section_id-1]['fields'] ) ) {
|
||||
|
||||
foreach ( $this->pre_sections[$section_id-1]['fields'] as $field ) {
|
||||
if ( ! empty( $field['id'] ) ) {
|
||||
$data[$field['id']] = $this->get_default( $field );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$data = wp_parse_args( $data, $this->options );
|
||||
|
||||
$this->notice = esc_html__( 'Default settings restored.', 'wp_china_yes' );
|
||||
|
||||
} else {
|
||||
|
||||
// sanitize and validate
|
||||
foreach ( $this->pre_fields as $field ) {
|
||||
|
||||
if ( ! empty( $field['id'] ) ) {
|
||||
|
||||
$field_id = $field['id'];
|
||||
$field_value = isset( $options[$field_id] ) ? $options[$field_id] : '';
|
||||
|
||||
// Ajax and Importing doing wp_unslash already.
|
||||
if ( ! $ajax && ! $importing ) {
|
||||
$field_value = wp_unslash( $field_value );
|
||||
}
|
||||
|
||||
// Sanitize "post" request of field.
|
||||
if ( ! isset( $field['sanitize'] ) ) {
|
||||
|
||||
if( is_array( $field_value ) ) {
|
||||
|
||||
$data[$field_id] = wp_kses_post_deep( $field_value );
|
||||
|
||||
} else {
|
||||
|
||||
$data[$field_id] = wp_kses_post( $field_value );
|
||||
|
||||
}
|
||||
|
||||
} else if( isset( $field['sanitize'] ) && is_callable( $field['sanitize'] ) ) {
|
||||
|
||||
$data[$field_id] = call_user_func( $field['sanitize'], $field_value );
|
||||
|
||||
} else {
|
||||
|
||||
$data[$field_id] = $field_value;
|
||||
|
||||
}
|
||||
|
||||
// Validate "post" request of field.
|
||||
if ( isset( $field['validate'] ) && is_callable( $field['validate'] ) ) {
|
||||
|
||||
$has_validated = call_user_func( $field['validate'], $field_value );
|
||||
|
||||
if ( ! empty( $has_validated ) ) {
|
||||
|
||||
$data[$field_id] = ( isset( $this->options[$field_id] ) ) ? $this->options[$field_id] : '';
|
||||
$this->errors[$field_id] = $has_validated;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$data = apply_filters( "wp_china_yes_{$this->unique}_save", $data, $this );
|
||||
|
||||
do_action( "wp_china_yes_{$this->unique}_save_before", $data, $this );
|
||||
|
||||
$this->options = $data;
|
||||
|
||||
$this->save_options( $data );
|
||||
|
||||
do_action( "wp_china_yes_{$this->unique}_save_after", $data, $this );
|
||||
|
||||
if ( empty( $this->notice ) ) {
|
||||
$this->notice = esc_html__( 'Settings saved.', 'wp_china_yes' );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// save options database
|
||||
public function save_options( $data ) {
|
||||
|
||||
if ( $this->args['database'] === 'transient' ) {
|
||||
set_transient( $this->unique, $data, $this->args['transient_time'] );
|
||||
} else if ( $this->args['database'] === 'theme_mod' ) {
|
||||
set_theme_mod( $this->unique, $data );
|
||||
} else if ( $this->args['database'] === 'network' ) {
|
||||
update_site_option( $this->unique, $data );
|
||||
} else {
|
||||
update_option( $this->unique, $data, true );
|
||||
}
|
||||
|
||||
do_action( "wp_china_yes_{$this->unique}_saved", $data, $this );
|
||||
|
||||
}
|
||||
|
||||
// get options from database
|
||||
public function get_options() {
|
||||
|
||||
if ( $this->args['database'] === 'transient' ) {
|
||||
$this->options = get_transient( $this->unique );
|
||||
} else if ( $this->args['database'] === 'theme_mod' ) {
|
||||
$this->options = get_theme_mod( $this->unique );
|
||||
} else if ( $this->args['database'] === 'network' ) {
|
||||
$this->options = get_site_option( $this->unique );
|
||||
} else {
|
||||
$this->options = get_option( $this->unique );
|
||||
}
|
||||
|
||||
if ( empty( $this->options ) ) {
|
||||
$this->options = array();
|
||||
}
|
||||
|
||||
return $this->options;
|
||||
|
||||
}
|
||||
|
||||
// admin menu
|
||||
public function add_admin_menu() {
|
||||
|
||||
extract( $this->args );
|
||||
|
||||
if ( $menu_type === 'submenu' ) {
|
||||
|
||||
$menu_page = call_user_func( 'add_submenu_page', $menu_parent, esc_attr( $menu_title ), esc_attr( $menu_title ), $menu_capability, $menu_slug, array( $this, 'add_options_html' ) );
|
||||
|
||||
} else {
|
||||
|
||||
$menu_page = call_user_func( 'add_menu_page', esc_attr( $menu_title ), esc_attr( $menu_title ), $menu_capability, $menu_slug, array( $this, 'add_options_html' ), $menu_icon, $menu_position );
|
||||
|
||||
if ( ! empty( $sub_menu_title ) ) {
|
||||
call_user_func( 'add_submenu_page', $menu_slug, esc_attr( $sub_menu_title ), esc_attr( $sub_menu_title ), $menu_capability, $menu_slug, array( $this, 'add_options_html' ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $this->args['show_sub_menu'] ) && count( $this->pre_tabs ) > 1 ) {
|
||||
|
||||
// create submenus
|
||||
foreach ( $this->pre_tabs as $section ) {
|
||||
call_user_func( 'add_submenu_page', $menu_slug, esc_attr( $section['title'] ), esc_attr( $section['title'] ), $menu_capability, $menu_slug .'#tab='. sanitize_title( $section['title'] ), '__return_null' );
|
||||
}
|
||||
|
||||
remove_submenu_page( $menu_slug, $menu_slug );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO CHINA-YES 支持隐藏子菜单
|
||||
if ( ! empty( $menu_hidden ) ) {
|
||||
remove_menu_page( $menu_slug );
|
||||
remove_submenu_page( $menu_parent, $menu_slug );
|
||||
}
|
||||
|
||||
add_action( 'load-'. $menu_page, array( $this, 'add_page_on_load' ) );
|
||||
|
||||
}
|
||||
|
||||
public function add_page_on_load() {
|
||||
|
||||
if ( ! empty( $this->args['contextual_help'] ) ) {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
foreach ( $this->args['contextual_help'] as $tab ) {
|
||||
$screen->add_help_tab( $tab );
|
||||
}
|
||||
|
||||
if ( ! empty( $this->args['contextual_help_sidebar'] ) ) {
|
||||
$screen->set_help_sidebar( $this->args['contextual_help_sidebar'] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty( $this->args['footer_credit'] ) ) {
|
||||
add_filter( 'admin_footer_text', array( $this, 'add_admin_footer_text' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function add_admin_footer_text() {
|
||||
echo wp_kses_post( $this->args['footer_credit'] );
|
||||
}
|
||||
|
||||
public function error_check( $sections, $err = '' ) {
|
||||
|
||||
if ( ! $this->args['ajax_save'] ) {
|
||||
|
||||
if ( ! empty( $sections['fields'] ) ) {
|
||||
foreach ( $sections['fields'] as $field ) {
|
||||
if ( ! empty( $field['id'] ) ) {
|
||||
if ( array_key_exists( $field['id'], $this->errors ) ) {
|
||||
$err = '<span class="wp_china_yes-label-error">!</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $sections['subs'] ) ) {
|
||||
foreach ( $sections['subs'] as $sub ) {
|
||||
$err = $this->error_check( $sub, $err );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $sections['id'] ) && array_key_exists( $sections['id'], $this->errors ) ) {
|
||||
$err = $this->errors[$sections['id']];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $err;
|
||||
}
|
||||
|
||||
// option page html output
|
||||
public function add_options_html() {
|
||||
|
||||
$has_nav = ( count( $this->pre_tabs ) > 1 ) ? true : false;
|
||||
$show_all = ( ! $has_nav ) ? ' wp_china_yes-show-all' : '';
|
||||
$ajax_class = ( $this->args['ajax_save'] ) ? ' wp_china_yes-save-ajax' : '';
|
||||
$sticky_class = ( $this->args['sticky_header'] ) ? ' wp_china_yes-sticky-header' : '';
|
||||
$wrapper_class = ( $this->args['framework_class'] ) ? ' '. $this->args['framework_class'] : '';
|
||||
$theme = ( $this->args['theme'] ) ? ' wp_china_yes-theme-'. $this->args['theme'] : '';
|
||||
$class = ( $this->args['class'] ) ? ' '. $this->args['class'] : '';
|
||||
$nav_type = ( $this->args['nav'] === 'inline' ) ? 'inline' : 'normal';
|
||||
$form_action = ( $this->args['form_action'] ) ? $this->args['form_action'] : '';
|
||||
|
||||
do_action( 'wp_china_yes_options_before' );
|
||||
|
||||
echo '<div class="wp_china_yes wp_china_yes-options'. esc_attr( $theme . $class . $wrapper_class ) .'" data-slug="'. esc_attr( $this->args['menu_slug'] ) .'" data-unique="'. esc_attr( $this->unique ) .'">';
|
||||
|
||||
echo '<div class="wp_china_yes-container">';
|
||||
|
||||
echo '<form method="post" action="'. esc_attr( $form_action ) .'" enctype="multipart/form-data" id="wp_china_yes-form" autocomplete="off" novalidate="novalidate">';
|
||||
|
||||
echo '<input type="hidden" class="wp_china_yes-section-id" name="wp_china_yes_transient[section]" value="1">';
|
||||
|
||||
wp_nonce_field( 'wp_china_yes_options_nonce', 'wp_china_yes_options_nonce'. $this->unique );
|
||||
|
||||
echo '<div class="wp_china_yes-header'. esc_attr( $sticky_class ) .'">';
|
||||
echo '<div class="wp_china_yes-header-inner">';
|
||||
|
||||
echo '<div class="wp_china_yes-header-left">';
|
||||
$hide_elements = !empty($this->options['hide_elements']) ? $this->options['hide_elements'] : [];
|
||||
if (!in_array('hide_logo', $hide_elements)) {
|
||||
$logo_url = !empty($this->options['header_logo']['url']) ? $this->options['header_logo']['url'] : plugins_url('wp-china-yes/assets/images/wpcy-logo.png');
|
||||
echo '<img src="' . esc_url($logo_url) . '" alt="WPCY Logo" class="wp-china-yes-logo" style="float: left; height: 26px; vertical-align: middle; margin-right: 10px;" />';
|
||||
}
|
||||
if (!in_array('hide_title', $hide_elements)) {
|
||||
echo '<h1>'. $this->args['framework_title'] .'</h1>';
|
||||
}
|
||||
if (!in_array('hide_version', $hide_elements)) {
|
||||
echo '<small> v' . CHINA_YES_VERSION . '</small>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="wp_china_yes-header-right">';
|
||||
|
||||
$notice_class = ( ! empty( $this->notice ) ) ? 'wp_china_yes-form-show' : '';
|
||||
$notice_text = ( ! empty( $this->notice ) ) ? $this->notice : '';
|
||||
|
||||
echo '<div class="wp_china_yes-form-result wp_china_yes-form-success '. esc_attr( $notice_class ) .'">'. $notice_text .'</div>';
|
||||
|
||||
echo ( $this->args['show_form_warning'] ) ? '<div class="wp_china_yes-form-result wp_china_yes-form-warning">'. esc_html__( 'You have unsaved changes, save your changes!', 'wp_china_yes' ) .'</div>' : '';
|
||||
|
||||
echo ( $has_nav && $this->args['show_all_options'] ) ? '<div class="wp_china_yes-expand-all" title="'. esc_html__( 'show all settings', 'wp_china_yes' ) .'"><i class="fas fa-outdent"></i></div>' : '';
|
||||
|
||||
echo ( $this->args['show_search'] ) ? '<div class="wp_china_yes-search"><input type="text" name="wp_china_yes-search" placeholder="'. esc_html__( 'Search...', 'wp_china_yes' ) .'" autocomplete="off" /></div>' : '';
|
||||
|
||||
echo '<div class="wp_china_yes-buttons">';
|
||||
echo '<input type="submit" name="'. esc_attr( $this->unique ) .'[_nonce][save]" class="button button-primary wp_china_yes-top-save wp_china_yes-save'. esc_attr( $ajax_class ) .'" value="'. esc_html__( 'Save', 'wp_china_yes' ) .'" data-save="'. esc_html__( 'Saving...', 'wp_china_yes' ) .'">';
|
||||
echo ( $this->args['show_reset_section'] ) ? '<input type="submit" name="wp_china_yes_transient[reset_section]" class="button button-secondary wp_china_yes-reset-section wp_china_yes-confirm" value="'. esc_html__( 'Reset Section', 'wp_china_yes' ) .'" data-confirm="'. esc_html__( 'Are you sure to reset this section options?', 'wp_china_yes' ) .'">' : '';
|
||||
echo ( $this->args['show_reset_all'] ) ? '<input type="submit" name="wp_china_yes_transient[reset]" class="button wp_china_yes-warning-primary wp_china_yes-reset-all wp_china_yes-confirm" value="'. ( ( $this->args['show_reset_section'] ) ? esc_html__( 'Reset All', 'wp_china_yes' ) : esc_html__( 'Reset', 'wp_china_yes' ) ) .'" data-confirm="'. esc_html__( 'Are you sure you want to reset all settings to default values?', 'wp_china_yes' ) .'">' : '';
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="wp_china_yes-wrapper'. esc_attr( $show_all ) .'">';
|
||||
|
||||
if ( $has_nav ) {
|
||||
|
||||
echo '<div class="wp_china_yes-nav wp_china_yes-nav-'. esc_attr( $nav_type ) .' wp_china_yes-nav-options">';
|
||||
|
||||
echo '<ul>';
|
||||
|
||||
foreach ( $this->pre_tabs as $tab ) {
|
||||
|
||||
$tab_id = sanitize_title( $tab['title'] );
|
||||
$tab_error = $this->error_check( $tab );
|
||||
$tab_icon = ( ! empty( $tab['icon'] ) ) ? '<i class="wp_china_yes-tab-icon '. esc_attr( $tab['icon'] ) .'"></i>' : '';
|
||||
|
||||
if ( ! empty( $tab['subs'] ) ) {
|
||||
|
||||
echo '<li class="wp_china_yes-tab-item">';
|
||||
|
||||
echo '<a href="#tab='. esc_attr( $tab_id ) .'" data-tab-id="'. esc_attr( $tab_id ) .'" class="wp_china_yes-arrow">'. $tab_icon . $tab['title'] . $tab_error .'</a>';
|
||||
|
||||
echo '<ul>';
|
||||
|
||||
foreach ( $tab['subs'] as $sub ) {
|
||||
|
||||
$sub_id = $tab_id .'/'. sanitize_title( $sub['title'] );
|
||||
$sub_error = $this->error_check( $sub );
|
||||
$sub_icon = ( ! empty( $sub['icon'] ) ) ? '<i class="wp_china_yes-tab-icon '. esc_attr( $sub['icon'] ) .'"></i>' : '';
|
||||
|
||||
echo '<li><a href="#tab='. esc_attr( $sub_id ) .'" data-tab-id="'. esc_attr( $sub_id ) .'">'. $sub_icon . $sub['title'] . $sub_error .'</a></li>';
|
||||
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
echo '</li>';
|
||||
|
||||
} else {
|
||||
|
||||
echo '<li class="wp_china_yes-tab-item"><a href="#tab='. esc_attr( $tab_id ) .'" data-tab-id="'. esc_attr( $tab_id ) .'">'. $tab_icon . $tab['title'] . $tab_error .'</a></li>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
echo '<div class="wp_china_yes-copyright">';
|
||||
echo '<p>Copyright © 2025 · WPCY.COM</p>';
|
||||
echo '<p>文派叶子·生生不息</p>';
|
||||
echo '</div>';
|
||||
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo '<div class="wp_china_yes-content">';
|
||||
|
||||
echo '<div class="wp_china_yes-sections">';
|
||||
|
||||
foreach ( $this->pre_sections as $section ) {
|
||||
|
||||
$section_onload = ( ! $has_nav ) ? ' wp_china_yes-onload' : '';
|
||||
$section_class = ( ! empty( $section['class'] ) ) ? ' '. $section['class'] : '';
|
||||
$section_icon = ( ! empty( $section['icon'] ) ) ? '<i class="wp_china_yes-section-icon '. esc_attr( $section['icon'] ) .'"></i>' : '';
|
||||
$section_title = ( ! empty( $section['title'] ) ) ? $section['title'] : '';
|
||||
$section_parent = ( ! empty( $section['ptitle'] ) ) ? sanitize_title( $section['ptitle'] ) .'/' : '';
|
||||
$section_slug = ( ! empty( $section['title'] ) ) ? sanitize_title( $section_title ) : '';
|
||||
|
||||
echo '<div class="wp_china_yes-section hidden'. esc_attr( $section_onload . $section_class ) .'" data-section-id="'. esc_attr( $section_parent . $section_slug ) .'">';
|
||||
echo ( $has_nav ) ? '<div class="wp_china_yes-section-title"><h3>'. $section_icon . $section_title .'</h3></div>' : '';
|
||||
echo ( ! empty( $section['description'] ) ) ? '<div class="wp_china_yes-field wp_china_yes-section-description">'. $section['description'] .'</div>' : '';
|
||||
|
||||
if ( ! empty( $section['fields'] ) ) {
|
||||
|
||||
foreach ( $section['fields'] as $field ) {
|
||||
|
||||
$is_field_error = $this->error_check( $field );
|
||||
|
||||
if ( ! empty( $is_field_error ) ) {
|
||||
$field['_error'] = $is_field_error;
|
||||
}
|
||||
|
||||
if ( ! empty( $field['id'] ) ) {
|
||||
$field['default'] = $this->get_default( $field );
|
||||
}
|
||||
|
||||
$value = ( ! empty( $field['id'] ) && isset( $this->options[$field['id']] ) ) ? $this->options[$field['id']] : '';
|
||||
|
||||
WP_CHINA_YES::field( $field, $value, $this->unique, 'options' );
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
echo '<div class="wp_china_yes-no-option">'. esc_html__( 'No data available.', 'wp_china_yes' ) .'</div>';
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="wp_china_yes-copyright">';
|
||||
echo '<p>此服务由 文派开源(WenPai.org) 提供生态接入。</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo ( $has_nav && $nav_type === 'normal' ) ? '<div class="wp_china_yes-nav-background"></div>' : '';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
if ( ! empty( $this->args['show_footer'] ) ) {
|
||||
|
||||
echo '<div class="wp_china_yes-footer">';
|
||||
|
||||
echo '<div class="wp_china_yes-buttons">';
|
||||
echo '<input type="submit" name="wp_china_yes_transient[save]" class="button button-primary wp_china_yes-save'. esc_attr( $ajax_class ) .'" value="'. esc_html__( 'Save', 'wp_china_yes' ) .'" data-save="'. esc_html__( 'Saving...', 'wp_china_yes' ) .'">';
|
||||
echo ( $this->args['show_reset_section'] ) ? '<input type="submit" name="wp_china_yes_transient[reset_section]" class="button button-secondary wp_china_yes-reset-section wp_china_yes-confirm" value="'. esc_html__( 'Reset Section', 'wp_china_yes' ) .'" data-confirm="'. esc_html__( 'Are you sure to reset this section options?', 'wp_china_yes' ) .'">' : '';
|
||||
echo ( $this->args['show_reset_all'] ) ? '<input type="submit" name="wp_china_yes_transient[reset]" class="button wp_china_yes-warning-primary wp_china_yes-reset-all wp_china_yes-confirm" value="'. ( ( $this->args['show_reset_section'] ) ? esc_html__( 'Reset All', 'wp_china_yes' ) : esc_html__( 'Reset', 'wp_china_yes' ) ) .'" data-confirm="'. esc_html__( 'Are you sure you want to reset all settings to default values?', 'wp_china_yes' ) .'">' : '';
|
||||
echo '</div>';
|
||||
|
||||
echo ( ! empty( $this->args['footer_text'] ) ) ? '<div class="wp_china_yes-copyright">'. $this->args['footer_text'] .'</div>' : '';
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo '</form>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
|
||||
echo ( ! empty( $this->args['footer_after'] ) ) ? $this->args['footer_after'] : '';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
do_action( 'wp_china_yes_options_after' );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
405
framework/classes/fields.class.php
Executable file
405
framework/classes/fields.class.php
Executable file
|
@ -0,0 +1,405 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Fields Class
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Fields' ) ) {
|
||||
abstract class WP_CHINA_YES_Fields extends WP_CHINA_YES_Abstract {
|
||||
|
||||
public function __construct( $field = array(), $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
$this->unique = $unique;
|
||||
$this->where = $where;
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
public function field_name( $nested_name = '' ) {
|
||||
|
||||
$field_id = ( ! empty( $this->field['id'] ) ) ? $this->field['id'] : '';
|
||||
$unique_id = ( ! empty( $this->unique ) ) ? $this->unique .'['. $field_id .']' : $field_id;
|
||||
$field_name = ( ! empty( $this->field['name'] ) ) ? $this->field['name'] : $unique_id;
|
||||
$tag_prefix = ( ! empty( $this->field['tag_prefix'] ) ) ? $this->field['tag_prefix'] : '';
|
||||
|
||||
if ( ! empty( $tag_prefix ) ) {
|
||||
$nested_name = str_replace( '[', '['. $tag_prefix, $nested_name );
|
||||
}
|
||||
|
||||
return $field_name . $nested_name;
|
||||
|
||||
}
|
||||
|
||||
public function field_attributes( $custom_atts = array() ) {
|
||||
|
||||
$field_id = ( ! empty( $this->field['id'] ) ) ? $this->field['id'] : '';
|
||||
$attributes = ( ! empty( $this->field['attributes'] ) ) ? $this->field['attributes'] : array();
|
||||
|
||||
if ( ! empty( $field_id ) && empty( $attributes['data-depend-id'] ) ) {
|
||||
$attributes['data-depend-id'] = $field_id;
|
||||
}
|
||||
|
||||
if ( ! empty( $this->field['placeholder'] ) ) {
|
||||
$attributes['placeholder'] = $this->field['placeholder'];
|
||||
}
|
||||
|
||||
$attributes = wp_parse_args( $attributes, $custom_atts );
|
||||
|
||||
$atts = '';
|
||||
|
||||
if ( ! empty( $attributes ) ) {
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
if ( $value === 'only-key' ) {
|
||||
$atts .= ' '. esc_attr( $key );
|
||||
} else {
|
||||
$atts .= ' '. esc_attr( $key ) . '="'. esc_attr( $value ) .'"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $atts;
|
||||
|
||||
}
|
||||
|
||||
public function field_before() {
|
||||
return ( ! empty( $this->field['before'] ) ) ? '<div class="wp_china_yes-before-text">'. $this->field['before'] .'</div>' : '';
|
||||
}
|
||||
|
||||
public function field_after() {
|
||||
|
||||
$output = ( ! empty( $this->field['after'] ) ) ? '<div class="wp_china_yes-after-text">'. $this->field['after'] .'</div>' : '';
|
||||
$output .= ( ! empty( $this->field['desc'] ) ) ? '<div class="clear"></div><div class="wp_china_yes-desc-text">'. $this->field['desc'] .'</div>' : '';
|
||||
$output .= ( ! empty( $this->field['help'] ) ) ? '<div class="wp_china_yes-help"><span class="wp_china_yes-help-text">'. $this->field['help'] .'</span><i class="fas fa-question-circle"></i></div>' : '';
|
||||
$output .= ( ! empty( $this->field['_error'] ) ) ? '<div class="wp_china_yes-error-text">'. $this->field['_error'] .'</div>' : '';
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
public static function field_data( $type = '', $term = false, $query_args = array() ) {
|
||||
|
||||
$options = array();
|
||||
$array_search = false;
|
||||
|
||||
// sanitize type name
|
||||
if ( in_array( $type, array( 'page', 'pages' ) ) ) {
|
||||
$option = 'page';
|
||||
} else if ( in_array( $type, array( 'post', 'posts' ) ) ) {
|
||||
$option = 'post';
|
||||
} else if ( in_array( $type, array( 'category', 'categories' ) ) ) {
|
||||
$option = 'category';
|
||||
} else if ( in_array( $type, array( 'tag', 'tags' ) ) ) {
|
||||
$option = 'post_tag';
|
||||
} else if ( in_array( $type, array( 'menu', 'menus' ) ) ) {
|
||||
$option = 'nav_menu';
|
||||
} else {
|
||||
$option = '';
|
||||
}
|
||||
|
||||
// switch type
|
||||
switch( $type ) {
|
||||
|
||||
case 'page':
|
||||
case 'pages':
|
||||
case 'post':
|
||||
case 'posts':
|
||||
|
||||
// term query required for ajax select
|
||||
if ( ! empty( $term ) ) {
|
||||
|
||||
$query = new WP_Query( wp_parse_args( $query_args, array(
|
||||
's' => $term,
|
||||
'post_type' => $option,
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 25,
|
||||
) ) );
|
||||
|
||||
} else {
|
||||
|
||||
$query = new WP_Query( wp_parse_args( $query_args, array(
|
||||
'post_type' => $option,
|
||||
'post_status' => 'publish',
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
if ( ! is_wp_error( $query ) && ! empty( $query->posts ) ) {
|
||||
foreach ( $query->posts as $item ) {
|
||||
$options[$item->ID] = $item->post_title;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
case 'categories':
|
||||
case 'tag':
|
||||
case 'tags':
|
||||
case 'menu':
|
||||
case 'menus':
|
||||
|
||||
if ( ! empty( $term ) ) {
|
||||
|
||||
$query = new WP_Term_Query( wp_parse_args( $query_args, array(
|
||||
'search' => $term,
|
||||
'taxonomy' => $option,
|
||||
'hide_empty' => false,
|
||||
'number' => 25,
|
||||
) ) );
|
||||
|
||||
} else {
|
||||
|
||||
$query = new WP_Term_Query( wp_parse_args( $query_args, array(
|
||||
'taxonomy' => $option,
|
||||
'hide_empty' => false,
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
if ( ! is_wp_error( $query ) && ! empty( $query->terms ) ) {
|
||||
foreach ( $query->terms as $item ) {
|
||||
$options[$item->term_id] = $item->name;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
case 'users':
|
||||
|
||||
if ( ! empty( $term ) ) {
|
||||
|
||||
$query = new WP_User_Query( array(
|
||||
'search' => '*'. $term .'*',
|
||||
'number' => 25,
|
||||
'orderby' => 'title',
|
||||
'order' => 'ASC',
|
||||
'fields' => array( 'display_name', 'ID' )
|
||||
) );
|
||||
|
||||
} else {
|
||||
|
||||
$query = new WP_User_Query( array( 'fields' => array( 'display_name', 'ID' ) ) );
|
||||
|
||||
}
|
||||
|
||||
if ( ! is_wp_error( $query ) && ! empty( $query->get_results() ) ) {
|
||||
foreach ( $query->get_results() as $item ) {
|
||||
$options[$item->ID] = $item->display_name;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'sidebar':
|
||||
case 'sidebars':
|
||||
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
if ( ! empty( $wp_registered_sidebars ) ) {
|
||||
foreach ( $wp_registered_sidebars as $sidebar ) {
|
||||
$options[$sidebar['id']] = $sidebar['name'];
|
||||
}
|
||||
}
|
||||
|
||||
$array_search = true;
|
||||
|
||||
break;
|
||||
|
||||
case 'role':
|
||||
case 'roles':
|
||||
|
||||
global $wp_roles;
|
||||
|
||||
if ( ! empty( $wp_roles ) ) {
|
||||
if ( ! empty( $wp_roles->roles ) ) {
|
||||
foreach ( $wp_roles->roles as $role_key => $role_value ) {
|
||||
$options[$role_key] = $role_value['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$array_search = true;
|
||||
|
||||
break;
|
||||
|
||||
case 'post_type':
|
||||
case 'post_types':
|
||||
|
||||
$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' );
|
||||
|
||||
if ( ! is_wp_error( $post_types ) && ! empty( $post_types ) ) {
|
||||
foreach ( $post_types as $post_type ) {
|
||||
$options[$post_type->name] = $post_type->labels->name;
|
||||
}
|
||||
}
|
||||
|
||||
$array_search = true;
|
||||
|
||||
break;
|
||||
|
||||
case 'location':
|
||||
case 'locations':
|
||||
|
||||
$nav_menus = get_registered_nav_menus();
|
||||
|
||||
if ( ! is_wp_error( $nav_menus ) && ! empty( $nav_menus ) ) {
|
||||
foreach ( $nav_menus as $nav_menu_key => $nav_menu_name ) {
|
||||
$options[$nav_menu_key] = $nav_menu_name;
|
||||
}
|
||||
}
|
||||
|
||||
$array_search = true;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
if ( is_callable( $type ) ) {
|
||||
if ( ! empty( $term ) ) {
|
||||
$options = call_user_func( $type, $query_args );
|
||||
} else {
|
||||
$options = call_user_func( $type, $term, $query_args );
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// Array search by "term"
|
||||
if ( ! empty( $term ) && ! empty( $options ) && ! empty( $array_search ) ) {
|
||||
$options = preg_grep( '/'. $term .'/i', $options );
|
||||
}
|
||||
|
||||
// Make multidimensional array for ajax search
|
||||
if ( ! empty( $term ) && ! empty( $options ) ) {
|
||||
$arr = array();
|
||||
foreach ( $options as $option_key => $option_value ) {
|
||||
$arr[] = array( 'value' => $option_key, 'text' => $option_value );
|
||||
}
|
||||
$options = $arr;
|
||||
}
|
||||
|
||||
return $options;
|
||||
|
||||
}
|
||||
|
||||
public function field_wp_query_data_title( $type, $values ) {
|
||||
|
||||
$options = array();
|
||||
|
||||
if ( ! empty( $values ) && is_array( $values ) ) {
|
||||
|
||||
foreach ( $values as $value ) {
|
||||
|
||||
$options[$value] = ucfirst( $value );
|
||||
|
||||
switch( $type ) {
|
||||
|
||||
case 'post':
|
||||
case 'posts':
|
||||
case 'page':
|
||||
case 'pages':
|
||||
|
||||
$title = get_the_title( $value );
|
||||
|
||||
if ( ! is_wp_error( $title ) && ! empty( $title ) ) {
|
||||
$options[$value] = $title;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
case 'categories':
|
||||
case 'tag':
|
||||
case 'tags':
|
||||
case 'menu':
|
||||
case 'menus':
|
||||
|
||||
$term = get_term( $value );
|
||||
|
||||
if ( ! is_wp_error( $term ) && ! empty( $term ) ) {
|
||||
$options[$value] = $term->name;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
case 'users':
|
||||
|
||||
$user = get_user_by( 'id', $value );
|
||||
|
||||
if ( ! is_wp_error( $user ) && ! empty( $user ) ) {
|
||||
$options[$value] = $user->display_name;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'sidebar':
|
||||
case 'sidebars':
|
||||
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
if ( ! empty( $wp_registered_sidebars[$value] ) ) {
|
||||
$options[$value] = $wp_registered_sidebars[$value]['name'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'role':
|
||||
case 'roles':
|
||||
|
||||
global $wp_roles;
|
||||
|
||||
if ( ! empty( $wp_roles ) && ! empty( $wp_roles->roles ) && ! empty( $wp_roles->roles[$value] ) ) {
|
||||
$options[$value] = $wp_roles->roles[$value]['name'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'post_type':
|
||||
case 'post_types':
|
||||
|
||||
$post_types = get_post_types( array( 'show_in_nav_menus' => true ) );
|
||||
|
||||
if ( ! is_wp_error( $post_types ) && ! empty( $post_types ) && ! empty( $post_types[$value] ) ) {
|
||||
$options[$value] = ucfirst( $value );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'location':
|
||||
case 'locations':
|
||||
|
||||
$nav_menus = get_registered_nav_menus();
|
||||
|
||||
if ( ! is_wp_error( $nav_menus ) && ! empty( $nav_menus ) && ! empty( $nav_menus[$value] ) ) {
|
||||
$options[$value] = $nav_menus[$value];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
if ( is_callable( $type .'_title' ) ) {
|
||||
$options[$value] = call_user_func( $type .'_title', $value );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $options;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
804
framework/classes/setup.class.php
Executable file
804
framework/classes/setup.class.php
Executable file
|
@ -0,0 +1,804 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Setup Class
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Setup' ) ) {
|
||||
class WP_CHINA_YES_Setup {
|
||||
|
||||
// Default constants
|
||||
public static $premium = false;
|
||||
public static $version = '2.3.1';
|
||||
public static $dir = '';
|
||||
public static $url = '';
|
||||
public static $css = '';
|
||||
public static $file = '';
|
||||
public static $enqueue = false;
|
||||
public static $webfonts = array();
|
||||
public static $subsets = array();
|
||||
public static $inited = array();
|
||||
public static $fields = array();
|
||||
public static $args = array(
|
||||
'admin_options' => array(),
|
||||
'customize_options' => array(),
|
||||
'metabox_options' => array(),
|
||||
'nav_menu_options' => array(),
|
||||
'profile_options' => array(),
|
||||
'taxonomy_options' => array(),
|
||||
'widget_options' => array(),
|
||||
'comment_options' => array(),
|
||||
'shortcode_options' => array(),
|
||||
);
|
||||
|
||||
// Shortcode instances
|
||||
public static $shortcode_instances = array();
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
public static function init( $file = __FILE__, $premium = false ) {
|
||||
|
||||
// Set file constant
|
||||
self::$file = $file;
|
||||
|
||||
// Set file constant
|
||||
self::$premium = $premium;
|
||||
|
||||
// Set constants
|
||||
self::constants();
|
||||
|
||||
// Include files
|
||||
self::includes();
|
||||
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
|
||||
}
|
||||
|
||||
// Initalize
|
||||
public function __construct() {
|
||||
|
||||
// Init action
|
||||
do_action( 'wp_china_yes_init' );
|
||||
|
||||
// Setup textdomain
|
||||
self::textdomain();
|
||||
|
||||
add_action( 'after_setup_theme', array( 'WP_CHINA_YES', 'setup' ) );
|
||||
add_action( 'init', array( 'WP_CHINA_YES', 'setup' ) );
|
||||
add_action( 'switch_theme', array( 'WP_CHINA_YES', 'setup' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( 'WP_CHINA_YES', 'add_admin_enqueue_scripts' ) );
|
||||
add_action( 'wp_enqueue_scripts', array( 'WP_CHINA_YES', 'add_typography_enqueue_styles' ), 80 );
|
||||
add_action( 'wp_head', array( 'WP_CHINA_YES', 'add_custom_css' ), 80 );
|
||||
add_filter( 'admin_body_class', array( 'WP_CHINA_YES', 'add_admin_body_class' ) );
|
||||
|
||||
}
|
||||
|
||||
// Setup frameworks
|
||||
public static function setup() {
|
||||
|
||||
// Setup admin option framework
|
||||
$params = array();
|
||||
if ( class_exists( 'WP_CHINA_YES_Options' ) && ! empty( self::$args['admin_options'] ) ) {
|
||||
foreach ( self::$args['admin_options'] as $key => $value ) {
|
||||
if ( ! empty( self::$args['sections'][$key] ) && ! isset( self::$inited[$key] ) ) {
|
||||
|
||||
$params['args'] = $value;
|
||||
$params['sections'] = self::$args['sections'][$key];
|
||||
self::$inited[$key] = true;
|
||||
|
||||
WP_CHINA_YES_Options::instance( $key, $params );
|
||||
|
||||
if ( ! empty( $value['show_in_customizer'] ) ) {
|
||||
$value['output_css'] = false;
|
||||
$value['enqueue_webfont'] = false;
|
||||
self::$args['customize_options'][$key] = $value;
|
||||
self::$inited[$key] = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup customize option framework
|
||||
$params = array();
|
||||
if ( class_exists( 'WP_CHINA_YES_Customize_Options' ) && ! empty( self::$args['customize_options'] ) ) {
|
||||
foreach ( self::$args['customize_options'] as $key => $value ) {
|
||||
if ( ! empty( self::$args['sections'][$key] ) && ! isset( self::$inited[$key] ) ) {
|
||||
|
||||
$params['args'] = $value;
|
||||
$params['sections'] = self::$args['sections'][$key];
|
||||
self::$inited[$key] = true;
|
||||
|
||||
WP_CHINA_YES_Customize_Options::instance( $key, $params );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup metabox option framework
|
||||
$params = array();
|
||||
if ( class_exists( 'WP_CHINA_YES_Metabox' ) && ! empty( self::$args['metabox_options'] ) ) {
|
||||
foreach ( self::$args['metabox_options'] as $key => $value ) {
|
||||
if ( ! empty( self::$args['sections'][$key] ) && ! isset( self::$inited[$key] ) ) {
|
||||
|
||||
$params['args'] = $value;
|
||||
$params['sections'] = self::$args['sections'][$key];
|
||||
self::$inited[$key] = true;
|
||||
|
||||
WP_CHINA_YES_Metabox::instance( $key, $params );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup nav menu option framework
|
||||
$params = array();
|
||||
if ( class_exists( 'WP_CHINA_YES_Nav_Menu_Options' ) && ! empty( self::$args['nav_menu_options'] ) ) {
|
||||
foreach ( self::$args['nav_menu_options'] as $key => $value ) {
|
||||
if ( ! empty( self::$args['sections'][$key] ) && ! isset( self::$inited[$key] ) ) {
|
||||
|
||||
$params['args'] = $value;
|
||||
$params['sections'] = self::$args['sections'][$key];
|
||||
self::$inited[$key] = true;
|
||||
|
||||
WP_CHINA_YES_Nav_Menu_Options::instance( $key, $params );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup profile option framework
|
||||
$params = array();
|
||||
if ( class_exists( 'WP_CHINA_YES_Profile_Options' ) && ! empty( self::$args['profile_options'] ) ) {
|
||||
foreach ( self::$args['profile_options'] as $key => $value ) {
|
||||
if ( ! empty( self::$args['sections'][$key] ) && ! isset( self::$inited[$key] ) ) {
|
||||
|
||||
$params['args'] = $value;
|
||||
$params['sections'] = self::$args['sections'][$key];
|
||||
self::$inited[$key] = true;
|
||||
|
||||
WP_CHINA_YES_Profile_Options::instance( $key, $params );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup taxonomy option framework
|
||||
$params = array();
|
||||
if ( class_exists( 'WP_CHINA_YES_Taxonomy_Options' ) && ! empty( self::$args['taxonomy_options'] ) ) {
|
||||
$taxonomy = ( isset( $_GET['taxonomy'] ) ) ? sanitize_text_field( wp_unslash( $_GET['taxonomy'] ) ) : '';
|
||||
foreach ( self::$args['taxonomy_options'] as $key => $value ) {
|
||||
if ( ! empty( self::$args['sections'][$key] ) && ! isset( self::$inited[$key] ) ) {
|
||||
|
||||
$params['args'] = $value;
|
||||
$params['sections'] = self::$args['sections'][$key];
|
||||
self::$inited[$key] = true;
|
||||
|
||||
WP_CHINA_YES_Taxonomy_Options::instance( $key, $params );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup widget option framework
|
||||
if ( class_exists( 'WP_CHINA_YES_Widget' ) && class_exists( 'WP_Widget_Factory' ) && ! empty( self::$args['widget_options'] ) ) {
|
||||
$wp_widget_factory = new WP_Widget_Factory();
|
||||
global $wp_widget_factory;
|
||||
foreach ( self::$args['widget_options'] as $key => $value ) {
|
||||
if ( ! isset( self::$inited[$key] ) ) {
|
||||
|
||||
self::$inited[$key] = true;
|
||||
$wp_widget_factory->register( WP_CHINA_YES_Widget::instance( $key, $value ) );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup comment option framework
|
||||
$params = array();
|
||||
if ( class_exists( 'WP_CHINA_YES_Comment_Metabox' ) && ! empty( self::$args['comment_options'] ) ) {
|
||||
foreach ( self::$args['comment_options'] as $key => $value ) {
|
||||
if ( ! empty( self::$args['sections'][$key] ) && ! isset( self::$inited[$key] ) ) {
|
||||
|
||||
$params['args'] = $value;
|
||||
$params['sections'] = self::$args['sections'][$key];
|
||||
self::$inited[$key] = true;
|
||||
|
||||
WP_CHINA_YES_Comment_Metabox::instance( $key, $params );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup shortcode option framework
|
||||
$params = array();
|
||||
if ( class_exists( 'WP_CHINA_YES_Shortcoder' ) && ! empty( self::$args['shortcode_options'] ) ) {
|
||||
foreach ( self::$args['shortcode_options'] as $key => $value ) {
|
||||
if ( ! empty( self::$args['sections'][$key] ) && ! isset( self::$inited[$key] ) ) {
|
||||
|
||||
$params['args'] = $value;
|
||||
$params['sections'] = self::$args['sections'][$key];
|
||||
self::$inited[$key] = true;
|
||||
|
||||
WP_CHINA_YES_Shortcoder::instance( $key, $params );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Once editor setup for gutenberg and media buttons
|
||||
if ( class_exists( 'WP_CHINA_YES_Shortcoder' ) && ! empty( self::$shortcode_instances ) ) {
|
||||
foreach ( self::$shortcode_instances as $instance ) {
|
||||
if ( ! empty( $instance['show_in_editor'] ) ) {
|
||||
WP_CHINA_YES_Shortcoder::once_editor_setup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
do_action( 'wp_china_yes_loaded' );
|
||||
|
||||
}
|
||||
|
||||
// Create options
|
||||
public static function createOptions( $id, $args = array() ) {
|
||||
self::$args['admin_options'][$id] = $args;
|
||||
}
|
||||
|
||||
// Create customize options
|
||||
public static function createCustomizeOptions( $id, $args = array() ) {
|
||||
self::$args['customize_options'][$id] = $args;
|
||||
}
|
||||
|
||||
// Create metabox options
|
||||
public static function createMetabox( $id, $args = array() ) {
|
||||
self::$args['metabox_options'][$id] = $args;
|
||||
}
|
||||
|
||||
// Create menu options
|
||||
public static function createNavMenuOptions( $id, $args = array() ) {
|
||||
self::$args['nav_menu_options'][$id] = $args;
|
||||
}
|
||||
|
||||
// Create shortcoder options
|
||||
public static function createShortcoder( $id, $args = array() ) {
|
||||
self::$args['shortcode_options'][$id] = $args;
|
||||
}
|
||||
|
||||
// Create taxonomy options
|
||||
public static function createTaxonomyOptions( $id, $args = array() ) {
|
||||
self::$args['taxonomy_options'][$id] = $args;
|
||||
}
|
||||
|
||||
// Create profile options
|
||||
public static function createProfileOptions( $id, $args = array() ) {
|
||||
self::$args['profile_options'][$id] = $args;
|
||||
}
|
||||
|
||||
// Create widget
|
||||
public static function createWidget( $id, $args = array() ) {
|
||||
self::$args['widget_options'][$id] = $args;
|
||||
self::set_used_fields( $args );
|
||||
}
|
||||
|
||||
// Create comment metabox
|
||||
public static function createCommentMetabox( $id, $args = array() ) {
|
||||
self::$args['comment_options'][$id] = $args;
|
||||
}
|
||||
|
||||
// Create section
|
||||
public static function createSection( $id, $sections ) {
|
||||
self::$args['sections'][$id][] = $sections;
|
||||
self::set_used_fields( $sections );
|
||||
}
|
||||
|
||||
// Set directory constants
|
||||
public static function constants() {
|
||||
|
||||
// We need this path-finder code for set URL of framework
|
||||
$dirname = str_replace( '//', '/', wp_normalize_path( dirname( dirname( self::$file ) ) ) );
|
||||
$theme_dir = str_replace( '//', '/', wp_normalize_path( get_parent_theme_file_path() ) );
|
||||
$plugin_dir = str_replace( '//', '/', wp_normalize_path( WP_PLUGIN_DIR ) );
|
||||
$plugin_dir = str_replace( '/opt/bitnami', '/bitnami', $plugin_dir );
|
||||
$located_plugin = ( preg_match( '#'. self::sanitize_dirname( $plugin_dir ) .'#', self::sanitize_dirname( $dirname ) ) ) ? true : false;
|
||||
$directory = ( $located_plugin ) ? $plugin_dir : $theme_dir;
|
||||
$directory_uri = ( $located_plugin ) ? WP_PLUGIN_URL : get_parent_theme_file_uri();
|
||||
$foldername = str_replace( $directory, '', $dirname );
|
||||
$protocol_uri = ( is_ssl() ) ? 'https' : 'http';
|
||||
$directory_uri = set_url_scheme( $directory_uri, $protocol_uri );
|
||||
|
||||
self::$dir = $dirname;
|
||||
self::$url = $directory_uri . $foldername;
|
||||
|
||||
}
|
||||
|
||||
// Include file helper
|
||||
public static function include_plugin_file( $file, $load = true ) {
|
||||
|
||||
$path = '';
|
||||
$file = ltrim( $file, '/' );
|
||||
$override = apply_filters( 'wp_china_yes_override', 'wp_china_yes-override' );
|
||||
|
||||
if ( file_exists( get_parent_theme_file_path( $override .'/'. $file ) ) ) {
|
||||
$path = get_parent_theme_file_path( $override .'/'. $file );
|
||||
} elseif ( file_exists( get_theme_file_path( $override .'/'. $file ) ) ) {
|
||||
$path = get_theme_file_path( $override .'/'. $file );
|
||||
} elseif ( file_exists( self::$dir .'/'. $override .'/'. $file ) ) {
|
||||
$path = self::$dir .'/'. $override .'/'. $file;
|
||||
} elseif ( file_exists( self::$dir .'/'. $file ) ) {
|
||||
$path = self::$dir .'/'. $file;
|
||||
}
|
||||
|
||||
if ( ! empty( $path ) && ! empty( $file ) && $load ) {
|
||||
|
||||
global $wp_query;
|
||||
|
||||
if ( is_object( $wp_query ) && function_exists( 'load_template' ) ) {
|
||||
|
||||
load_template( $path, true );
|
||||
|
||||
} else {
|
||||
|
||||
require_once( $path );
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
return self::$dir .'/'. $file;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Is active plugin helper
|
||||
public static function is_active_plugin( $file = '' ) {
|
||||
return in_array( $file, (array) get_option( 'active_plugins', array() ) );
|
||||
}
|
||||
|
||||
// Sanitize dirname
|
||||
public static function sanitize_dirname( $dirname ) {
|
||||
return preg_replace( '/[^A-Za-z]/', '', $dirname );
|
||||
}
|
||||
|
||||
// Set url constant
|
||||
public static function include_plugin_url( $file ) {
|
||||
return esc_url( self::$url ) .'/'. ltrim( $file, '/' );
|
||||
}
|
||||
|
||||
// Include files
|
||||
public static function includes() {
|
||||
|
||||
// Include common functions
|
||||
self::include_plugin_file( 'functions/actions.php' );
|
||||
self::include_plugin_file( 'functions/helpers.php' );
|
||||
self::include_plugin_file( 'functions/sanitize.php' );
|
||||
self::include_plugin_file( 'functions/validate.php' );
|
||||
|
||||
// Include free version classes
|
||||
self::include_plugin_file( 'classes/abstract.class.php' );
|
||||
self::include_plugin_file( 'classes/fields.class.php' );
|
||||
self::include_plugin_file( 'classes/admin-options.class.php' );
|
||||
|
||||
// Include premium version classes
|
||||
if ( self::$premium ) {
|
||||
self::include_plugin_file( 'classes/customize-options.class.php' );
|
||||
self::include_plugin_file( 'classes/metabox-options.class.php' );
|
||||
self::include_plugin_file( 'classes/nav-menu-options.class.php' );
|
||||
self::include_plugin_file( 'classes/profile-options.class.php' );
|
||||
self::include_plugin_file( 'classes/shortcode-options.class.php' );
|
||||
self::include_plugin_file( 'classes/taxonomy-options.class.php' );
|
||||
self::include_plugin_file( 'classes/widget-options.class.php' );
|
||||
self::include_plugin_file( 'classes/comment-options.class.php' );
|
||||
}
|
||||
|
||||
// Include all framework fields
|
||||
$fields = apply_filters( 'wp_china_yes_fields', array(
|
||||
'accordion',
|
||||
'background',
|
||||
'backup',
|
||||
'border',
|
||||
'button_set',
|
||||
'callback',
|
||||
'checkbox',
|
||||
'code_editor',
|
||||
'color',
|
||||
'color_group',
|
||||
'content',
|
||||
'date',
|
||||
'datetime',
|
||||
'dimensions',
|
||||
'fieldset',
|
||||
'gallery',
|
||||
'group',
|
||||
'heading',
|
||||
'icon',
|
||||
'image_select',
|
||||
'link',
|
||||
'link_color',
|
||||
'map',
|
||||
'media',
|
||||
'notice',
|
||||
'number',
|
||||
'palette',
|
||||
'radio',
|
||||
'repeater',
|
||||
'select',
|
||||
'slider',
|
||||
'sortable',
|
||||
'sorter',
|
||||
'spacing',
|
||||
'spinner',
|
||||
'subheading',
|
||||
'submessage',
|
||||
'switcher',
|
||||
'tabbed',
|
||||
'text',
|
||||
'textarea',
|
||||
'typography',
|
||||
'upload',
|
||||
'wp_editor',
|
||||
) );
|
||||
|
||||
if ( ! empty( $fields ) ) {
|
||||
foreach ( $fields as $field ) {
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_'. $field ) && class_exists( 'WP_CHINA_YES_Fields' ) ) {
|
||||
self::include_plugin_file( 'fields/'. $field .'/'. $field .'.php' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Setup textdomain
|
||||
public static function textdomain() {
|
||||
load_textdomain( 'wp_china_yes', self::$dir .'/languages/'. get_locale() .'.mo' );
|
||||
}
|
||||
|
||||
// Set all of used fields
|
||||
public static function set_used_fields( $sections ) {
|
||||
|
||||
if ( ! empty( $sections['fields'] ) ) {
|
||||
|
||||
foreach ( $sections['fields'] as $field ) {
|
||||
|
||||
if ( ! empty( $field['fields'] ) ) {
|
||||
self::set_used_fields( $field );
|
||||
}
|
||||
|
||||
if ( ! empty( $field['tabs'] ) ) {
|
||||
self::set_used_fields( array( 'fields' => $field['tabs'] ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $field['accordions'] ) ) {
|
||||
self::set_used_fields( array( 'fields' => $field['accordions'] ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $field['elements'] ) ) {
|
||||
self::set_used_fields( array( 'fields' => $field['elements'] ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $field['type'] ) ) {
|
||||
self::$fields[$field['type']] = $field;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Enqueue admin and fields styles and scripts
|
||||
public static function add_admin_enqueue_scripts() {
|
||||
|
||||
if ( ! self::$enqueue ) {
|
||||
|
||||
// Loads scripts and styles only when needed
|
||||
$wpscreen = get_current_screen();
|
||||
|
||||
if ( ! empty( self::$args['admin_options'] ) ) {
|
||||
foreach ( self::$args['admin_options'] as $argument ) {
|
||||
if ( substr( $wpscreen->id, -strlen( $argument['menu_slug'] ) ) === $argument['menu_slug'] ) {
|
||||
self::$enqueue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( self::$args['metabox_options'] ) ) {
|
||||
foreach ( self::$args['metabox_options'] as $argument ) {
|
||||
if ( in_array( $wpscreen->post_type, (array) $argument['post_type'] ) ) {
|
||||
self::$enqueue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( self::$args['taxonomy_options'] ) ) {
|
||||
foreach ( self::$args['taxonomy_options'] as $argument ) {
|
||||
if ( in_array( $wpscreen->taxonomy, (array) $argument['taxonomy'] ) ) {
|
||||
self::$enqueue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( self::$shortcode_instances ) ) {
|
||||
foreach ( self::$shortcode_instances as $argument ) {
|
||||
if ( ( $argument['show_in_editor'] && $wpscreen->base === 'post' ) || $argument['show_in_custom'] ) {
|
||||
self::$enqueue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( self::$args['widget_options'] ) && ( $wpscreen->id === 'widgets' || $wpscreen->id === 'customize' ) ) {
|
||||
self::$enqueue = true;
|
||||
}
|
||||
|
||||
if ( ! empty( self::$args['customize_options'] ) && $wpscreen->id === 'customize' ) {
|
||||
self::$enqueue = true;
|
||||
}
|
||||
|
||||
if ( ! empty( self::$args['nav_menu_options'] ) && $wpscreen->id === 'nav-menus' ) {
|
||||
self::$enqueue = true;
|
||||
}
|
||||
|
||||
if ( ! empty( self::$args['profile_options'] ) && ( $wpscreen->id === 'profile' || $wpscreen->id === 'user-edit' ) ) {
|
||||
self::$enqueue = true;
|
||||
}
|
||||
|
||||
if ( ! empty( self::$args['comment_options'] ) && $wpscreen->id === 'comment' ) {
|
||||
self::$enqueue = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! apply_filters( 'wp_china_yes_enqueue_assets', self::$enqueue ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Admin utilities
|
||||
wp_enqueue_media();
|
||||
|
||||
// Wp color picker
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
wp_enqueue_script( 'wp-color-picker' );
|
||||
|
||||
// Font awesome 4 and 5 loader
|
||||
if ( apply_filters( 'wp_china_yes_fa4', false ) ) {
|
||||
wp_enqueue_style( 'wp_china_yes-fa', 'https://jsd.admincdn.com/npm/font-awesome@4.7.0/css/font-awesome.min.css', array(), '4.7.0', 'all' );
|
||||
} else {
|
||||
wp_enqueue_style( 'wp_china_yes-fa5', 'https://jsd.admincdn.com/npm/@fortawesome/fontawesome-free@5.15.4/css/all.min.css', array(), '5.15.5', 'all' );
|
||||
wp_enqueue_style( 'wp_china_yes-fa5-v4-shims', 'https://jsd.admincdn.com/npm/@fortawesome/fontawesome-free@5.15.4/css/v4-shims.min.css', array(), '5.15.5', 'all' );
|
||||
}
|
||||
|
||||
// Iconsax font icon loader
|
||||
wp_enqueue_style( 'wp_china_yes-iconsax', 'https://jsd.admincdn.com/npm/iconsax-font-icon@1.1.0/dist/icons.min.css', array(), '1.1.0', 'all' );
|
||||
|
||||
|
||||
// Check for developer mode
|
||||
$min = ( self::$premium && SCRIPT_DEBUG ) ? '' : '.min';
|
||||
|
||||
// Main style
|
||||
wp_enqueue_style( 'wp_china_yes', self::include_plugin_url( 'assets/css/style'. $min .'.css' ), array(), self::$version, 'all' );
|
||||
|
||||
// Main RTL styles
|
||||
if ( is_rtl() ) {
|
||||
wp_enqueue_style( 'wp_china_yes-rtl', self::include_plugin_url( 'assets/css/style-rtl'. $min .'.css' ), array(), self::$version, 'all' );
|
||||
}
|
||||
|
||||
// Main scripts
|
||||
wp_enqueue_script( 'wp_china_yes-plugins', self::include_plugin_url( 'assets/js/plugins'. $min .'.js' ), array(), self::$version, true );
|
||||
wp_enqueue_script( 'wp_china_yes', self::include_plugin_url( 'assets/js/main'. $min .'.js' ), array( 'wp_china_yes-plugins' ), self::$version, true );
|
||||
|
||||
// Main variables
|
||||
wp_localize_script( 'wp_china_yes', 'wp_china_yes_vars', array(
|
||||
'color_palette' => apply_filters( 'wp_china_yes_color_palette', array() ),
|
||||
'i18n' => array(
|
||||
'confirm' => esc_html__( 'Are you sure?', 'wp_china_yes' ),
|
||||
'typing_text' => esc_html__( 'Please enter %s or more characters', 'wp_china_yes' ),
|
||||
'searching_text' => esc_html__( 'Searching...', 'wp_china_yes' ),
|
||||
'no_results_text' => esc_html__( 'No results found.', 'wp_china_yes' ),
|
||||
),
|
||||
) );
|
||||
|
||||
// Enqueue fields scripts and styles
|
||||
$enqueued = array();
|
||||
|
||||
if ( ! empty( self::$fields ) ) {
|
||||
foreach ( self::$fields as $field ) {
|
||||
if ( ! empty( $field['type'] ) ) {
|
||||
$classname = 'WP_CHINA_YES_Field_' . $field['type'];
|
||||
if ( class_exists( $classname ) && method_exists( $classname, 'enqueue' ) ) {
|
||||
$instance = new $classname( $field );
|
||||
if ( method_exists( $classname, 'enqueue' ) ) {
|
||||
$instance->enqueue();
|
||||
}
|
||||
unset( $instance );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do_action( 'wp_china_yes_enqueue' );
|
||||
|
||||
}
|
||||
|
||||
// Add typography enqueue styles to front page
|
||||
public static function add_typography_enqueue_styles() {
|
||||
|
||||
if ( ! empty( self::$webfonts ) ) {
|
||||
|
||||
if ( ! empty( self::$webfonts['enqueue'] ) ) {
|
||||
|
||||
$query = array();
|
||||
$fonts = array();
|
||||
|
||||
foreach ( self::$webfonts['enqueue'] as $family => $styles ) {
|
||||
$fonts[] = $family . ( ( ! empty( $styles ) ) ? ':'. implode( ',', $styles ) : '' );
|
||||
}
|
||||
|
||||
if ( ! empty( $fonts ) ) {
|
||||
$query['family'] = implode( '%7C', $fonts );
|
||||
}
|
||||
|
||||
if ( ! empty( self::$subsets ) ) {
|
||||
$query['subset'] = implode( ',', self::$subsets );
|
||||
}
|
||||
|
||||
$query['display'] = 'swap';
|
||||
|
||||
wp_enqueue_style( 'wp_china_yes-google-web-fonts', esc_url( add_query_arg( $query, '//fonts.googleapis.com/css' ) ), array(), null );
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty( self::$webfonts['async'] ) ) {
|
||||
|
||||
$fonts = array();
|
||||
|
||||
foreach ( self::$webfonts['async'] as $family => $styles ) {
|
||||
$fonts[] = $family . ( ( ! empty( $styles ) ) ? ':'. implode( ',', $styles ) : '' );
|
||||
}
|
||||
|
||||
wp_enqueue_script( 'wp_china_yes-google-web-fonts', esc_url( '//ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js' ), array(), null );
|
||||
|
||||
wp_localize_script( 'wp_china_yes-google-web-fonts', 'WebFontConfig', array( 'google' => array( 'families' => $fonts ) ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Add admin body class
|
||||
public static function add_admin_body_class( $classes ) {
|
||||
|
||||
if ( apply_filters( 'wp_china_yes_fa4', false ) ) {
|
||||
$classes .= 'wp_china_yes-fa5-shims';
|
||||
}
|
||||
|
||||
return $classes;
|
||||
|
||||
}
|
||||
|
||||
// Add custom css to front page
|
||||
public static function add_custom_css() {
|
||||
|
||||
if ( ! empty( self::$css ) ) {
|
||||
echo '<style type="text/css">'. wp_strip_all_tags( self::$css ) .'</style>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Add a new framework field
|
||||
public static function field( $field = array(), $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
|
||||
// Check for unallow fields
|
||||
if ( ! empty( $field['_notice'] ) ) {
|
||||
|
||||
$field_type = $field['type'];
|
||||
|
||||
$field = array();
|
||||
$field['content'] = esc_html__( 'Oops! Not allowed.', 'wp_china_yes' ) .' <strong>('. $field_type .')</strong>';
|
||||
$field['type'] = 'notice';
|
||||
$field['style'] = 'danger';
|
||||
|
||||
}
|
||||
|
||||
$depend = '';
|
||||
$visible = '';
|
||||
$unique = ( ! empty( $unique ) ) ? $unique : '';
|
||||
$class = ( ! empty( $field['class'] ) ) ? ' ' . esc_attr( $field['class'] ) : '';
|
||||
$is_pseudo = ( ! empty( $field['pseudo'] ) ) ? ' wp_china_yes-pseudo-field' : '';
|
||||
$field_type = ( ! empty( $field['type'] ) ) ? esc_attr( $field['type'] ) : '';
|
||||
|
||||
if ( ! empty( $field['dependency'] ) ) {
|
||||
|
||||
$dependency = $field['dependency'];
|
||||
$depend_visible = '';
|
||||
$data_controller = '';
|
||||
$data_condition = '';
|
||||
$data_value = '';
|
||||
$data_global = '';
|
||||
|
||||
if ( is_array( $dependency[0] ) ) {
|
||||
$data_controller = implode( '|', array_column( $dependency, 0 ) );
|
||||
$data_condition = implode( '|', array_column( $dependency, 1 ) );
|
||||
$data_value = implode( '|', array_column( $dependency, 2 ) );
|
||||
$data_global = implode( '|', array_column( $dependency, 3 ) );
|
||||
$depend_visible = implode( '|', array_column( $dependency, 4 ) );
|
||||
} else {
|
||||
$data_controller = ( ! empty( $dependency[0] ) ) ? $dependency[0] : '';
|
||||
$data_condition = ( ! empty( $dependency[1] ) ) ? $dependency[1] : '';
|
||||
$data_value = ( ! empty( $dependency[2] ) ) ? $dependency[2] : '';
|
||||
$data_global = ( ! empty( $dependency[3] ) ) ? $dependency[3] : '';
|
||||
$depend_visible = ( ! empty( $dependency[4] ) ) ? $dependency[4] : '';
|
||||
}
|
||||
|
||||
$depend .= ' data-controller="'. esc_attr( $data_controller ) .'"';
|
||||
$depend .= ' data-condition="'. esc_attr( $data_condition ) .'"';
|
||||
$depend .= ' data-value="'. esc_attr( $data_value ) .'"';
|
||||
$depend .= ( ! empty( $data_global ) ) ? ' data-depend-global="true"' : '';
|
||||
|
||||
$visible = ( ! empty( $depend_visible ) ) ? ' wp_china_yes-depend-visible' : ' wp_china_yes-depend-hidden';
|
||||
|
||||
}
|
||||
|
||||
// These attributes has been sanitized above.
|
||||
echo '<div class="wp_china_yes-field wp_china_yes-field-'. $field_type . $is_pseudo . $class . $visible .'"'. $depend .'>';
|
||||
|
||||
if ( ! empty( $field_type ) ) {
|
||||
|
||||
if ( ! empty( $field['title'] ) ) {
|
||||
echo '<div class="wp_china_yes-title">';
|
||||
echo '<h4>'. $field['title'] .'</h4>';
|
||||
echo ( ! empty( $field['subtitle'] ) ) ? '<div class="wp_china_yes-subtitle-text">'. $field['subtitle'] .'</div>' : '';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo ( ! empty( $field['title'] ) ) ? '<div class="wp_china_yes-fieldset">' : '';
|
||||
|
||||
$value = ( ! isset( $value ) && isset( $field['default'] ) ) ? $field['default'] : $value;
|
||||
$value = ( isset( $field['value'] ) ) ? $field['value'] : $value;
|
||||
|
||||
$classname = 'WP_CHINA_YES_Field_'. $field_type;
|
||||
|
||||
if ( class_exists( $classname ) ) {
|
||||
$instance = new $classname( $field, $value, $unique, $where, $parent );
|
||||
$instance->render();
|
||||
} else {
|
||||
echo '<p>'. esc_html__( 'Field not found!', 'wp_china_yes' ) .'</p>';
|
||||
}
|
||||
|
||||
} else {
|
||||
echo '<p>'. esc_html__( 'Field not found!', 'wp_china_yes' ) .'</p>';
|
||||
}
|
||||
|
||||
echo ( ! empty( $field['title'] ) ) ? '</div>' : '';
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WP_CHINA_YES_Setup::init( __FILE__, false );
|
||||
|
||||
/**
|
||||
*
|
||||
* Extended Setup Class for Shortland
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES' ) ) {
|
||||
class WP_CHINA_YES extends WP_CHINA_YES_Setup{}
|
||||
}
|
64
framework/fields/accordion/accordion.php
Executable file
64
framework/fields/accordion/accordion.php
Executable file
|
@ -0,0 +1,64 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: accordion
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_accordion' ) ) {
|
||||
class WP_CHINA_YES_Field_accordion extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$unallows = array( 'accordion' );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<div class="wp_china_yes-accordion-items" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
|
||||
|
||||
foreach ( $this->field['accordions'] as $key => $accordion ) {
|
||||
|
||||
echo '<div class="wp_china_yes-accordion-item">';
|
||||
|
||||
$icon = ( ! empty( $accordion['icon'] ) ) ? 'wp_china_yes--icon '. $accordion['icon'] : 'wp_china_yes-accordion-icon fas fa-angle-right';
|
||||
|
||||
echo '<h4 class="wp_china_yes-accordion-title">';
|
||||
echo '<i class="'. esc_attr( $icon ) .'"></i>';
|
||||
echo esc_html( $accordion['title'] );
|
||||
echo '</h4>';
|
||||
|
||||
echo '<div class="wp_china_yes-accordion-content">';
|
||||
|
||||
foreach ( $accordion['fields'] as $field ) {
|
||||
|
||||
if ( in_array( $field['type'], $unallows ) ) { $field['_notice'] = true; }
|
||||
|
||||
$field_id = ( isset( $field['id'] ) ) ? $field['id'] : '';
|
||||
$field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
|
||||
$field_value = ( isset( $this->value[$field_id] ) ) ? $this->value[$field_id] : $field_default;
|
||||
$unique_id = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']' : $this->field['id'];
|
||||
|
||||
WP_CHINA_YES::field( $field, $field_value, $unique_id, 'field/accordion' );
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
340
framework/fields/background/background.php
Executable file
340
framework/fields/background/background.php
Executable file
|
@ -0,0 +1,340 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: background
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_background' ) ) {
|
||||
class WP_CHINA_YES_Field_background extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'background_color' => true,
|
||||
'background_image' => true,
|
||||
'background_position' => true,
|
||||
'background_repeat' => true,
|
||||
'background_attachment' => true,
|
||||
'background_size' => true,
|
||||
'background_origin' => false,
|
||||
'background_clip' => false,
|
||||
'background_blend_mode' => false,
|
||||
'background_gradient' => false,
|
||||
'background_gradient_color' => true,
|
||||
'background_gradient_direction' => true,
|
||||
'background_image_preview' => true,
|
||||
'background_auto_attributes' => false,
|
||||
'compact' => false,
|
||||
'background_image_library' => 'image',
|
||||
'background_image_placeholder' => esc_html__( 'Not selected', 'wp_china_yes' ),
|
||||
) );
|
||||
|
||||
if ( $args['compact'] ) {
|
||||
$args['background_color'] = false;
|
||||
$args['background_auto_attributes'] = true;
|
||||
}
|
||||
|
||||
$default_value = array(
|
||||
'background-color' => '',
|
||||
'background-image' => '',
|
||||
'background-position' => '',
|
||||
'background-repeat' => '',
|
||||
'background-attachment' => '',
|
||||
'background-size' => '',
|
||||
'background-origin' => '',
|
||||
'background-clip' => '',
|
||||
'background-blend-mode' => '',
|
||||
'background-gradient-color' => '',
|
||||
'background-gradient-direction' => '',
|
||||
);
|
||||
|
||||
$default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
|
||||
|
||||
$this->value = wp_parse_args( $this->value, $default_value );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<div class="wp_china_yes--background-colors">';
|
||||
|
||||
//
|
||||
// Background Color
|
||||
if ( ! empty( $args['background_color'] ) ) {
|
||||
|
||||
echo '<div class="wp_china_yes--color">';
|
||||
|
||||
echo ( ! empty( $args['background_gradient'] ) ) ? '<div class="wp_china_yes--title">'. esc_html__( 'From', 'wp_china_yes' ) .'</div>' : '';
|
||||
|
||||
WP_CHINA_YES::field( array(
|
||||
'id' => 'background-color',
|
||||
'type' => 'color',
|
||||
'default' => $default_value['background-color'],
|
||||
), $this->value['background-color'], $this->field_name(), 'field/background' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Background Gradient Color
|
||||
if ( ! empty( $args['background_gradient_color'] ) && ! empty( $args['background_gradient'] ) ) {
|
||||
|
||||
echo '<div class="wp_china_yes--color">';
|
||||
|
||||
echo ( ! empty( $args['background_gradient'] ) ) ? '<div class="wp_china_yes--title">'. esc_html__( 'To', 'wp_china_yes' ) .'</div>' : '';
|
||||
|
||||
WP_CHINA_YES::field( array(
|
||||
'id' => 'background-gradient-color',
|
||||
'type' => 'color',
|
||||
'default' => $default_value['background-gradient-color'],
|
||||
), $this->value['background-gradient-color'], $this->field_name(), 'field/background' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Background Gradient Direction
|
||||
if ( ! empty( $args['background_gradient_direction'] ) && ! empty( $args['background_gradient'] ) ) {
|
||||
|
||||
echo '<div class="wp_china_yes--color">';
|
||||
|
||||
echo ( ! empty( $args['background_gradient'] ) ) ? '<div class="wp_china_yes---title">'. esc_html__( 'Direction', 'wp_china_yes' ) .'</div>' : '';
|
||||
|
||||
WP_CHINA_YES::field( array(
|
||||
'id' => 'background-gradient-direction',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'' => esc_html__( 'Gradient Direction', 'wp_china_yes' ),
|
||||
'to bottom' => esc_html__( '⇓ top to bottom', 'wp_china_yes' ),
|
||||
'to right' => esc_html__( '⇒ left to right', 'wp_china_yes' ),
|
||||
'135deg' => esc_html__( '⇘ corner top to right', 'wp_china_yes' ),
|
||||
'-135deg' => esc_html__( '⇙ corner top to left', 'wp_china_yes' ),
|
||||
),
|
||||
), $this->value['background-gradient-direction'], $this->field_name(), 'field/background' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
//
|
||||
// Background Image
|
||||
if ( ! empty( $args['background_image'] ) ) {
|
||||
|
||||
echo '<div class="wp_china_yes--background-image">';
|
||||
|
||||
WP_CHINA_YES::field( array(
|
||||
'id' => 'background-image',
|
||||
'type' => 'media',
|
||||
'class' => 'wp_china_yes-assign-field-background',
|
||||
'library' => $args['background_image_library'],
|
||||
'preview' => $args['background_image_preview'],
|
||||
'placeholder' => $args['background_image_placeholder'],
|
||||
'attributes' => array( 'data-depend-id' => $this->field['id'] ),
|
||||
), $this->value['background-image'], $this->field_name(), 'field/background' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
$auto_class = ( ! empty( $args['background_auto_attributes'] ) ) ? ' wp_china_yes--auto-attributes' : '';
|
||||
$hidden_class = ( ! empty( $args['background_auto_attributes'] ) && empty( $this->value['background-image']['url'] ) ) ? ' wp_china_yes--attributes-hidden' : '';
|
||||
|
||||
echo '<div class="wp_china_yes--background-attributes'. esc_attr( $auto_class . $hidden_class ) .'">';
|
||||
|
||||
//
|
||||
// Background Position
|
||||
if ( ! empty( $args['background_position'] ) ) {
|
||||
|
||||
WP_CHINA_YES::field( array(
|
||||
'id' => 'background-position',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'' => esc_html__( 'Background Position', 'wp_china_yes' ),
|
||||
'left top' => esc_html__( 'Left Top', 'wp_china_yes' ),
|
||||
'left center' => esc_html__( 'Left Center', 'wp_china_yes' ),
|
||||
'left bottom' => esc_html__( 'Left Bottom', 'wp_china_yes' ),
|
||||
'center top' => esc_html__( 'Center Top', 'wp_china_yes' ),
|
||||
'center center' => esc_html__( 'Center Center', 'wp_china_yes' ),
|
||||
'center bottom' => esc_html__( 'Center Bottom', 'wp_china_yes' ),
|
||||
'right top' => esc_html__( 'Right Top', 'wp_china_yes' ),
|
||||
'right center' => esc_html__( 'Right Center', 'wp_china_yes' ),
|
||||
'right bottom' => esc_html__( 'Right Bottom', 'wp_china_yes' ),
|
||||
),
|
||||
), $this->value['background-position'], $this->field_name(), 'field/background' );
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Background Repeat
|
||||
if ( ! empty( $args['background_repeat'] ) ) {
|
||||
|
||||
WP_CHINA_YES::field( array(
|
||||
'id' => 'background-repeat',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'' => esc_html__( 'Background Repeat', 'wp_china_yes' ),
|
||||
'repeat' => esc_html__( 'Repeat', 'wp_china_yes' ),
|
||||
'no-repeat' => esc_html__( 'No Repeat', 'wp_china_yes' ),
|
||||
'repeat-x' => esc_html__( 'Repeat Horizontally', 'wp_china_yes' ),
|
||||
'repeat-y' => esc_html__( 'Repeat Vertically', 'wp_china_yes' ),
|
||||
),
|
||||
), $this->value['background-repeat'], $this->field_name(), 'field/background' );
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Background Attachment
|
||||
if ( ! empty( $args['background_attachment'] ) ) {
|
||||
|
||||
WP_CHINA_YES::field( array(
|
||||
'id' => 'background-attachment',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'' => esc_html__( 'Background Attachment', 'wp_china_yes' ),
|
||||
'scroll' => esc_html__( 'Scroll', 'wp_china_yes' ),
|
||||
'fixed' => esc_html__( 'Fixed', 'wp_china_yes' ),
|
||||
),
|
||||
), $this->value['background-attachment'], $this->field_name(), 'field/background' );
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Background Size
|
||||
if ( ! empty( $args['background_size'] ) ) {
|
||||
|
||||
WP_CHINA_YES::field( array(
|
||||
'id' => 'background-size',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'' => esc_html__( 'Background Size', 'wp_china_yes' ),
|
||||
'cover' => esc_html__( 'Cover', 'wp_china_yes' ),
|
||||
'contain' => esc_html__( 'Contain', 'wp_china_yes' ),
|
||||
'auto' => esc_html__( 'Auto', 'wp_china_yes' ),
|
||||
),
|
||||
), $this->value['background-size'], $this->field_name(), 'field/background' );
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Background Origin
|
||||
if ( ! empty( $args['background_origin'] ) ) {
|
||||
|
||||
WP_CHINA_YES::field( array(
|
||||
'id' => 'background-origin',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'' => esc_html__( 'Background Origin', 'wp_china_yes' ),
|
||||
'padding-box' => esc_html__( 'Padding Box', 'wp_china_yes' ),
|
||||
'border-box' => esc_html__( 'Border Box', 'wp_china_yes' ),
|
||||
'content-box' => esc_html__( 'Content Box', 'wp_china_yes' ),
|
||||
),
|
||||
), $this->value['background-origin'], $this->field_name(), 'field/background' );
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Background Clip
|
||||
if ( ! empty( $args['background_clip'] ) ) {
|
||||
|
||||
WP_CHINA_YES::field( array(
|
||||
'id' => 'background-clip',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'' => esc_html__( 'Background Clip', 'wp_china_yes' ),
|
||||
'border-box' => esc_html__( 'Border Box', 'wp_china_yes' ),
|
||||
'padding-box' => esc_html__( 'Padding Box', 'wp_china_yes' ),
|
||||
'content-box' => esc_html__( 'Content Box', 'wp_china_yes' ),
|
||||
),
|
||||
), $this->value['background-clip'], $this->field_name(), 'field/background' );
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Background Blend Mode
|
||||
if ( ! empty( $args['background_blend_mode'] ) ) {
|
||||
|
||||
WP_CHINA_YES::field( array(
|
||||
'id' => 'background-blend-mode',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'' => esc_html__( 'Background Blend Mode', 'wp_china_yes' ),
|
||||
'normal' => esc_html__( 'Normal', 'wp_china_yes' ),
|
||||
'multiply' => esc_html__( 'Multiply', 'wp_china_yes' ),
|
||||
'screen' => esc_html__( 'Screen', 'wp_china_yes' ),
|
||||
'overlay' => esc_html__( 'Overlay', 'wp_china_yes' ),
|
||||
'darken' => esc_html__( 'Darken', 'wp_china_yes' ),
|
||||
'lighten' => esc_html__( 'Lighten', 'wp_china_yes' ),
|
||||
'color-dodge' => esc_html__( 'Color Dodge', 'wp_china_yes' ),
|
||||
'saturation' => esc_html__( 'Saturation', 'wp_china_yes' ),
|
||||
'color' => esc_html__( 'Color', 'wp_china_yes' ),
|
||||
'luminosity' => esc_html__( 'Luminosity', 'wp_china_yes' ),
|
||||
),
|
||||
), $this->value['background-blend-mode'], $this->field_name(), 'field/background' );
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function output() {
|
||||
|
||||
$output = '';
|
||||
$bg_image = array();
|
||||
$important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
|
||||
$element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
|
||||
|
||||
// Background image and gradient
|
||||
$background_color = ( ! empty( $this->value['background-color'] ) ) ? $this->value['background-color'] : '';
|
||||
$background_gd_color = ( ! empty( $this->value['background-gradient-color'] ) ) ? $this->value['background-gradient-color'] : '';
|
||||
$background_gd_direction = ( ! empty( $this->value['background-gradient-direction'] ) ) ? $this->value['background-gradient-direction'] : '';
|
||||
$background_image = ( ! empty( $this->value['background-image']['url'] ) ) ? $this->value['background-image']['url'] : '';
|
||||
|
||||
|
||||
if ( $background_color && $background_gd_color ) {
|
||||
$gd_direction = ( $background_gd_direction ) ? $background_gd_direction .',' : '';
|
||||
$bg_image[] = 'linear-gradient('. $gd_direction . $background_color .','. $background_gd_color .')';
|
||||
unset( $this->value['background-color'] );
|
||||
}
|
||||
|
||||
if ( $background_image ) {
|
||||
$bg_image[] = 'url('. $background_image .')';
|
||||
}
|
||||
|
||||
if ( ! empty( $bg_image ) ) {
|
||||
$output .= 'background-image:'. implode( ',', $bg_image ) . $important .';';
|
||||
}
|
||||
|
||||
// Common background properties
|
||||
$properties = array( 'color', 'position', 'repeat', 'attachment', 'size', 'origin', 'clip', 'blend-mode' );
|
||||
|
||||
foreach ( $properties as $property ) {
|
||||
$property = 'background-'. $property;
|
||||
if ( ! empty( $this->value[$property] ) ) {
|
||||
$output .= $property .':'. $this->value[$property] . $important .';';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $output ) {
|
||||
$output = $element .'{'. $output .'}';
|
||||
}
|
||||
|
||||
$this->parent->output_css .= $output;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
38
framework/fields/backup/backup.php
Executable file
38
framework/fields/backup/backup.php
Executable file
|
@ -0,0 +1,38 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: backup
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_backup' ) ) {
|
||||
class WP_CHINA_YES_Field_backup extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$unique = $this->unique;
|
||||
$nonce = wp_create_nonce( 'wp_china_yes_backup_nonce' );
|
||||
$export = add_query_arg( array( 'action' => 'wp_china_yes-export', 'unique' => $unique, 'nonce' => $nonce ), admin_url( 'admin-ajax.php' ) );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<textarea name="wp_china_yes_import_data" class="wp_china_yes-import-data"></textarea>';
|
||||
echo '<button type="submit" class="button button-primary wp_china_yes-confirm wp_china_yes-import" data-unique="'. esc_attr( $unique ) .'" data-nonce="'. esc_attr( $nonce ) .'">'. esc_html__( 'Import', 'wp_china_yes' ) .'</button>';
|
||||
echo '<hr />';
|
||||
echo '<textarea readonly="readonly" class="wp_china_yes-export-data">'. esc_attr( json_encode( get_option( $unique ) ) ) .'</textarea>';
|
||||
echo '<a href="'. esc_url( $export ) .'" class="button button-primary wp_china_yes-export" target="_blank">'. esc_html__( 'Export & Download', 'wp_china_yes' ) .'</a>';
|
||||
echo '<hr />';
|
||||
echo '<button type="submit" name="wp_china_yes_transient[reset]" value="reset" class="button wp_china_yes-warning-primary wp_china_yes-confirm wp_china_yes-reset" data-unique="'. esc_attr( $unique ) .'" data-nonce="'. esc_attr( $nonce ) .'">'. esc_html__( 'Reset', 'wp_china_yes' ) .'</button>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
176
framework/fields/border/border.php
Executable file
176
framework/fields/border/border.php
Executable file
|
@ -0,0 +1,176 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: border
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_border' ) ) {
|
||||
class WP_CHINA_YES_Field_border extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'top_icon' => '<i class="fas fa-long-arrow-alt-up"></i>',
|
||||
'left_icon' => '<i class="fas fa-long-arrow-alt-left"></i>',
|
||||
'bottom_icon' => '<i class="fas fa-long-arrow-alt-down"></i>',
|
||||
'right_icon' => '<i class="fas fa-long-arrow-alt-right"></i>',
|
||||
'all_icon' => '<i class="fas fa-arrows-alt"></i>',
|
||||
'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 '<div class="wp_china_yes--inputs" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
|
||||
|
||||
if ( ! empty( $args['all'] ) ) {
|
||||
|
||||
$placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args['all_placeholder'] ) .'"' : '';
|
||||
|
||||
echo '<div class="wp_china_yes--input">';
|
||||
echo ( ! empty( $args['all_icon'] ) ) ? '<span class="wp_china_yes--label wp_china_yes--icon">'. $args['all_icon'] .'</span>' : '';
|
||||
echo '<input type="number" name="'. esc_attr( $this->field_name( '[all]' ) ) .'" value="'. esc_attr( $value['all'] ) .'"'. $placeholder .' class="wp_china_yes-input-number wp_china_yes--is-unit" step="any" />';
|
||||
echo ( ! empty( $args['unit'] ) ) ? '<span class="wp_china_yes--label wp_china_yes--unit">'. esc_attr( $args['unit'] ) .'</span>' : '';
|
||||
echo '</div>';
|
||||
|
||||
} else {
|
||||
|
||||
$properties = array();
|
||||
|
||||
foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) {
|
||||
if ( ! empty( $args[$prop] ) ) {
|
||||
$properties[] = $prop;
|
||||
}
|
||||
}
|
||||
|
||||
$properties = ( $properties === array( 'right', 'left' ) ) ? array_reverse( $properties ) : $properties;
|
||||
|
||||
foreach ( $properties as $property ) {
|
||||
|
||||
$placeholder = ( ! empty( $args[$property.'_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args[$property.'_placeholder'] ) .'"' : '';
|
||||
|
||||
echo '<div class="wp_china_yes--input">';
|
||||
echo ( ! empty( $args[$property.'_icon'] ) ) ? '<span class="wp_china_yes--label wp_china_yes--icon">'. $args[$property.'_icon'] .'</span>' : '';
|
||||
echo '<input type="number" name="'. esc_attr( $this->field_name( '['. $property .']' ) ) .'" value="'. esc_attr( $value[$property] ) .'"'. $placeholder .' class="wp_china_yes-input-number wp_china_yes--is-unit" step="any" />';
|
||||
echo ( ! empty( $args['unit'] ) ) ? '<span class="wp_china_yes--label wp_china_yes--unit">'. esc_attr( $args['unit'] ) .'</span>' : '';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty( $args['style'] ) ) {
|
||||
echo '<div class="wp_china_yes--input">';
|
||||
echo '<select name="'. esc_attr( $this->field_name( '[style]' ) ) .'">';
|
||||
foreach ( $border_props as $border_prop_key => $border_prop_value ) {
|
||||
$selected = ( $value['style'] === $border_prop_key ) ? ' selected' : '';
|
||||
echo '<option value="'. esc_attr( $border_prop_key ) .'"'. esc_attr( $selected ) .'>'. esc_attr( $border_prop_value ) .'</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
if ( ! empty( $args['color'] ) ) {
|
||||
$default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="'. esc_attr( $default_value['color'] ) .'"' : '';
|
||||
echo '<div class="wp_china_yes--color">';
|
||||
echo '<div class="wp_china_yes-field-color">';
|
||||
echo '<input type="text" name="'. esc_attr( $this->field_name( '[color]' ) ) .'" value="'. esc_attr( $value['color'] ) .'" class="wp_china_yes-color"'. $default_color_attr .' />';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function output() {
|
||||
|
||||
$output = '';
|
||||
$unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
|
||||
$important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
|
||||
$element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
|
||||
|
||||
// properties
|
||||
$top = ( isset( $this->value['top'] ) && $this->value['top'] !== '' ) ? $this->value['top'] : '';
|
||||
$right = ( isset( $this->value['right'] ) && $this->value['right'] !== '' ) ? $this->value['right'] : '';
|
||||
$bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] !== '' ) ? $this->value['bottom'] : '';
|
||||
$left = ( isset( $this->value['left'] ) && $this->value['left'] !== '' ) ? $this->value['left'] : '';
|
||||
$style = ( isset( $this->value['style'] ) && $this->value['style'] !== '' ) ? $this->value['style'] : '';
|
||||
$color = ( isset( $this->value['color'] ) && $this->value['color'] !== '' ) ? $this->value['color'] : '';
|
||||
$all = ( isset( $this->value['all'] ) && $this->value['all'] !== '' ) ? $this->value['all'] : '';
|
||||
|
||||
if ( ! empty( $this->field['all'] ) && ( $all !== '' || $color !== '' ) ) {
|
||||
|
||||
$output = $element .'{';
|
||||
$output .= ( $all !== '' ) ? 'border-width:'. $all . $unit . $important .';' : '';
|
||||
$output .= ( $color !== '' ) ? 'border-color:'. $color . $important .';' : '';
|
||||
$output .= ( $style !== '' ) ? 'border-style:'. $style . $important .';' : '';
|
||||
$output .= '}';
|
||||
|
||||
} else if ( $top !== '' || $right !== '' || $bottom !== '' || $left !== '' || $color !== '' ) {
|
||||
|
||||
$output = $element .'{';
|
||||
$output .= ( $top !== '' ) ? 'border-top-width:'. $top . $unit . $important .';' : '';
|
||||
$output .= ( $right !== '' ) ? 'border-right-width:'. $right . $unit . $important .';' : '';
|
||||
$output .= ( $bottom !== '' ) ? 'border-bottom-width:'. $bottom . $unit . $important .';' : '';
|
||||
$output .= ( $left !== '' ) ? 'border-left-width:'. $left . $unit . $important .';' : '';
|
||||
$output .= ( $color !== '' ) ? 'border-color:'. $color . $important .';' : '';
|
||||
$output .= ( $style !== '' ) ? 'border-style:'. $style . $important .';' : '';
|
||||
$output .= '}';
|
||||
|
||||
}
|
||||
|
||||
$this->parent->output_css .= $output;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
67
framework/fields/button_set/button_set.php
Executable file
67
framework/fields/button_set/button_set.php
Executable file
|
@ -0,0 +1,67 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: button_set
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_button_set' ) ) {
|
||||
class WP_CHINA_YES_Field_button_set extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'multiple' => false,
|
||||
'options' => array(),
|
||||
'query_args' => array(),
|
||||
) );
|
||||
|
||||
$value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
if ( isset( $this->field['options'] ) ) {
|
||||
|
||||
$options = $this->field['options'];
|
||||
$options = ( is_array( $options ) ) ? $options : array_filter( $this->field_data( $options, false, $args['query_args'] ) );
|
||||
|
||||
if ( is_array( $options ) && ! empty( $options ) ) {
|
||||
|
||||
echo '<div class="wp_china_yes-siblings wp_china_yes--button-group" data-multiple="'. esc_attr( $args['multiple'] ) .'">';
|
||||
|
||||
foreach ( $options as $key => $option ) {
|
||||
|
||||
$type = ( $args['multiple'] ) ? 'checkbox' : 'radio';
|
||||
$extra = ( $args['multiple'] ) ? '[]' : '';
|
||||
$active = ( in_array( $key, $value ) || ( empty( $value ) && empty( $key ) ) ) ? ' wp_china_yes--active' : '';
|
||||
$checked = ( in_array( $key, $value ) || ( empty( $value ) && empty( $key ) ) ) ? ' checked' : '';
|
||||
|
||||
echo '<div class="wp_china_yes--sibling wp_china_yes--button'. esc_attr( $active ) .'">';
|
||||
echo '<input type="'. esc_attr( $type ) .'" name="'. esc_attr( $this->field_name( $extra ) ) .'" value="'. esc_attr( $key ) .'"'. $this->field_attributes() . esc_attr( $checked ) .'/>';
|
||||
echo $option;
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
} else {
|
||||
|
||||
echo ( ! empty( $this->field['empty_message'] ) ) ? esc_attr( $this->field['empty_message'] ) : esc_html__( 'No data available.', 'wp_china_yes' );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
31
framework/fields/callback/callback.php
Executable file
31
framework/fields/callback/callback.php
Executable file
|
@ -0,0 +1,31 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: callback
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_callback' ) ) {
|
||||
class WP_CHINA_YES_Field_callback extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
if ( isset( $this->field['function'] ) && is_callable( $this->field['function'] ) ) {
|
||||
|
||||
$args = ( isset( $this->field['args'] ) ) ? $this->field['args'] : null;
|
||||
|
||||
call_user_func( $this->field['function'], $args );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
101
framework/fields/checkbox/checkbox.php
Executable file
101
framework/fields/checkbox/checkbox.php
Executable file
|
@ -0,0 +1,101 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: checkbox
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_checkbox' ) ) {
|
||||
class WP_CHINA_YES_Field_checkbox extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'inline' => false,
|
||||
'query_args' => array(),
|
||||
'check_all' => false,
|
||||
'check_all_text' => esc_html__( 'Check/Uncheck All' ),
|
||||
) );
|
||||
|
||||
$inline_class = ( $args['inline'] ) ? ' class="wp_china_yes--inline-list"' : '';
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
if ( isset( $this->field['options'] ) ) {
|
||||
|
||||
$value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
|
||||
$options = $this->field['options'];
|
||||
$options = ( is_array( $options ) ) ? $options : array_filter( $this->field_data( $options, false, $args['query_args'] ) );
|
||||
|
||||
if ( is_array( $options ) && ! empty( $options ) ) {
|
||||
|
||||
echo '<ul'. $inline_class .'>';
|
||||
|
||||
foreach ( $options as $option_key => $option_value ) {
|
||||
|
||||
if ( is_array( $option_value ) && ! empty( $option_value ) ) {
|
||||
|
||||
echo '<li>';
|
||||
echo '<ul>';
|
||||
echo '<li><strong>'. esc_attr( $option_key ) .'</strong></li>';
|
||||
foreach ( $option_value as $sub_key => $sub_value ) {
|
||||
$checked = ( in_array( $sub_key, $value ) ) ? ' checked' : '';
|
||||
echo '<li>';
|
||||
echo '<label>';
|
||||
echo '<input type="checkbox" name="'. esc_attr( $this->field_name( '[]' ) ) .'" value="'. esc_attr( $sub_key ) .'"'. $this->field_attributes() . esc_attr( $checked ) .'/>';
|
||||
echo '<span class="wp_china_yes--text">'. esc_attr( $sub_value ) .'</span>';
|
||||
echo '</label>';
|
||||
echo '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
echo '</li>';
|
||||
|
||||
} else {
|
||||
|
||||
$checked = ( in_array( $option_key, $value ) ) ? ' checked' : '';
|
||||
|
||||
echo '<li>';
|
||||
echo '<label>';
|
||||
echo '<input type="checkbox" name="'. esc_attr( $this->field_name( '[]' ) ) .'" value="'. esc_attr( $option_key ) .'"'. $this->field_attributes() . esc_attr( $checked ) .'/>';
|
||||
echo '<span class="wp_china_yes--text">'. esc_attr( $option_value ) .'</span>';
|
||||
echo '</label>';
|
||||
echo '</li>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
if ( $args['check_all'] ) {
|
||||
echo '<div class="wp_china_yes-checkbox-all">'. esc_html( $args['check_all_text'] ) .'</div>';
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
echo ( ! empty( $this->field['empty_message'] ) ) ? esc_attr( $this->field['empty_message'] ) : esc_html__( 'No data available.', 'wp_china_yes' );
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
echo '<label class="wp_china_yes-checkbox">';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name() ) .'" value="'. $this->value .'" class="wp_china_yes--input"'. $this->field_attributes() .'/>';
|
||||
echo '<input type="checkbox" name="_pseudo" class="wp_china_yes--checkbox"'. esc_attr( checked( $this->value, 1, false ) ) . $this->field_attributes() .'/>';
|
||||
echo ( ! empty( $this->field['label'] ) ) ? '<span class="wp_china_yes--text">'. esc_attr( $this->field['label'] ) .'</span>' : '';
|
||||
echo '</label>';
|
||||
|
||||
}
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
58
framework/fields/code_editor/code_editor.php
Executable file
58
framework/fields/code_editor/code_editor.php
Executable file
|
@ -0,0 +1,58 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: code_editor
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_code_editor' ) ) {
|
||||
class WP_CHINA_YES_Field_code_editor extends WP_CHINA_YES_Fields {
|
||||
|
||||
public $version = '6.65.7';
|
||||
public $cdn_url = 'https://jsd.admincdn.com/npm/codemirror@';
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$default_settings = array(
|
||||
'tabSize' => 2,
|
||||
'lineNumbers' => true,
|
||||
'theme' => 'default',
|
||||
'mode' => 'htmlmixed',
|
||||
'cdnURL' => $this->cdn_url . $this->version,
|
||||
);
|
||||
|
||||
$settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
|
||||
$settings = wp_parse_args( $settings, $default_settings );
|
||||
|
||||
echo $this->field_before();
|
||||
echo '<textarea name="'. esc_attr( $this->field_name() ) .'"'. $this->field_attributes() .' data-editor="'. esc_attr( json_encode( $settings ) ) .'">'. $this->value .'</textarea>';
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
$page = ( ! empty( $_GET[ 'page' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'page' ] ) ) : '';
|
||||
|
||||
// Do not loads CodeMirror in revslider page.
|
||||
if ( in_array( $page, array( 'revslider' ) ) ) { return; }
|
||||
|
||||
if ( ! wp_script_is( 'wp_china_yes-codemirror' ) ) {
|
||||
wp_enqueue_script( 'wp_china_yes-codemirror', esc_url( $this->cdn_url . $this->version .'/lib/codemirror.min.js' ), array( 'wp_china_yes' ), $this->version, true );
|
||||
wp_enqueue_script( 'wp_china_yes-codemirror-loadmode', esc_url( $this->cdn_url . $this->version .'/addon/mode/loadmode.min.js' ), array( 'wp_china_yes-codemirror' ), $this->version, true );
|
||||
}
|
||||
|
||||
if ( ! wp_style_is( 'wp_china_yes-codemirror' ) ) {
|
||||
wp_enqueue_style( 'wp_china_yes-codemirror', esc_url( $this->cdn_url . $this->version .'/lib/codemirror.min.css' ), array(), $this->version );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
52
framework/fields/color/color.php
Executable file
52
framework/fields/color/color.php
Executable file
|
@ -0,0 +1,52 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: color
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_color' ) ) {
|
||||
class WP_CHINA_YES_Field_color extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$default_attr = ( ! empty( $this->field['default'] ) ) ? ' data-default-color="'. esc_attr( $this->field['default'] ) .'"' : '';
|
||||
|
||||
echo $this->field_before();
|
||||
echo '<input type="text" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'" class="wp_china_yes-color"'. $default_attr . $this->field_attributes() .'/>';
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function output() {
|
||||
|
||||
$output = '';
|
||||
$elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
|
||||
$important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
|
||||
$mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'color';
|
||||
|
||||
if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
|
||||
foreach ( $elements as $key_property => $element ) {
|
||||
if ( is_numeric( $key_property ) ) {
|
||||
$output = implode( ',', $elements ) .'{'. $mode .':'. $this->value . $important .';}';
|
||||
break;
|
||||
} else {
|
||||
$output .= $element .'{'. $key_property .':'. $this->value . $important .'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->parent->output_css .= $output;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
42
framework/fields/color_group/color_group.php
Executable file
42
framework/fields/color_group/color_group.php
Executable file
|
@ -0,0 +1,42 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: color_group
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_color_group' ) ) {
|
||||
class WP_CHINA_YES_Field_color_group extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$options = ( ! empty( $this->field['options'] ) ) ? $this->field['options'] : array();
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
if ( ! empty( $options ) ) {
|
||||
foreach ( $options as $key => $option ) {
|
||||
|
||||
$color_value = ( ! empty( $this->value[$key] ) ) ? $this->value[$key] : '';
|
||||
$default_attr = ( ! empty( $this->field['default'][$key] ) ) ? ' data-default-color="'. esc_attr( $this->field['default'][$key] ) .'"' : '';
|
||||
|
||||
echo '<div class="wp_china_yes--left wp_china_yes-field-color">';
|
||||
echo '<div class="wp_china_yes--title">'. $option .'</div>';
|
||||
echo '<input type="text" name="'. esc_attr( $this->field_name( '['. $key .']' ) ) .'" value="'. esc_attr( $color_value ) .'" class="wp_china_yes-color"'. $default_attr . $this->field_attributes() .'/>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
28
framework/fields/content/content.php
Executable file
28
framework/fields/content/content.php
Executable file
|
@ -0,0 +1,28 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: content
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_content' ) ) {
|
||||
class WP_CHINA_YES_Field_content extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
if ( ! empty( $this->field['content'] ) ) {
|
||||
|
||||
echo $this->field['content'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
64
framework/fields/date/date.php
Executable file
64
framework/fields/date/date.php
Executable file
|
@ -0,0 +1,64 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: date
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_date' ) ) {
|
||||
class WP_CHINA_YES_Field_date extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$default_settings = array(
|
||||
'dateFormat' => 'mm/dd/yy',
|
||||
);
|
||||
|
||||
$settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
|
||||
$settings = wp_parse_args( $settings, $default_settings );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
if ( ! empty( $this->field['from_to'] ) ) {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'text_from' => esc_html__( 'From', 'wp_china_yes' ),
|
||||
'text_to' => esc_html__( 'To', 'wp_china_yes' ),
|
||||
) );
|
||||
|
||||
$value = wp_parse_args( $this->value, array(
|
||||
'from' => '',
|
||||
'to' => '',
|
||||
) );
|
||||
|
||||
echo '<label class="wp_china_yes--from">'. esc_attr( $args['text_from'] ) .' <input type="text" name="'. esc_attr( $this->field_name( '[from]' ) ) .'" value="'. esc_attr( $value['from'] ) .'"'. $this->field_attributes() .'/></label>';
|
||||
echo '<label class="wp_china_yes--to">'. esc_attr( $args['text_to'] ) .' <input type="text" name="'. esc_attr( $this->field_name( '[to]' ) ) .'" value="'. esc_attr( $value['to'] ) .'"'. $this->field_attributes() .'/></label>';
|
||||
|
||||
} else {
|
||||
|
||||
echo '<input type="text" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes() .'/>';
|
||||
|
||||
}
|
||||
|
||||
echo '<div class="wp_china_yes-date-settings" data-settings="'. esc_attr( json_encode( $settings ) ) .'"></div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
if ( ! wp_script_is( 'jquery-ui-datepicker' ) ) {
|
||||
wp_enqueue_script( 'jquery-ui-datepicker' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
61
framework/fields/datetime/datetime.php
Executable file
61
framework/fields/datetime/datetime.php
Executable file
|
@ -0,0 +1,61 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: datetime
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_datetime' ) ) {
|
||||
class WP_CHINA_YES_Field_datetime extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$defaults = array(
|
||||
'allowInput' => true,
|
||||
);
|
||||
|
||||
$settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
|
||||
|
||||
if ( ! isset( $settings['noCalendar'] ) ) {
|
||||
$defaults['dateFormat'] = 'm/d/Y';
|
||||
}
|
||||
|
||||
$settings = wp_parse_args( $settings, $defaults );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
if ( ! empty( $this->field['from_to'] ) ) {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'text_from' => esc_html__( 'From', 'wp_china_yes' ),
|
||||
'text_to' => esc_html__( 'To', 'wp_china_yes' ),
|
||||
) );
|
||||
|
||||
$value = wp_parse_args( $this->value, array(
|
||||
'from' => '',
|
||||
'to' => '',
|
||||
) );
|
||||
|
||||
echo '<label class="wp_china_yes--from">'. esc_attr( $args['text_from'] ) .' <input type="text" name="'. esc_attr( $this->field_name( '[from]' ) ) .'" value="'. esc_attr( $value['from'] ) .'"'. $this->field_attributes() .' data-type="from" /></label>';
|
||||
echo '<label class="wp_china_yes--to">'. esc_attr( $args['text_to'] ) .' <input type="text" name="'. esc_attr( $this->field_name( '[to]' ) ) .'" value="'. esc_attr( $value['to'] ) .'"'. $this->field_attributes() .' data-type="to" /></label>';
|
||||
|
||||
} else {
|
||||
|
||||
echo '<input type="text" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes() .'/>';
|
||||
|
||||
}
|
||||
|
||||
echo '<div class="wp_china_yes-datetime-settings" data-settings="'. esc_attr( json_encode( $settings ) ) .'"></div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
101
framework/fields/dimensions/dimensions.php
Executable file
101
framework/fields/dimensions/dimensions.php
Executable file
|
@ -0,0 +1,101 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: dimensions
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_dimensions' ) ) {
|
||||
class WP_CHINA_YES_Field_dimensions extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'width_icon' => '<i class="fas fa-arrows-alt-h"></i>',
|
||||
'height_icon' => '<i class="fas fa-arrows-alt-v"></i>',
|
||||
'width_placeholder' => esc_html__( 'width', 'wp_china_yes' ),
|
||||
'height_placeholder' => esc_html__( 'height', 'wp_china_yes' ),
|
||||
'width' => true,
|
||||
'height' => true,
|
||||
'unit' => true,
|
||||
'show_units' => true,
|
||||
'units' => array( 'px', '%', 'em' )
|
||||
) );
|
||||
|
||||
$default_values = array(
|
||||
'width' => '',
|
||||
'height' => '',
|
||||
'unit' => 'px',
|
||||
);
|
||||
|
||||
$value = wp_parse_args( $this->value, $default_values );
|
||||
$unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
|
||||
$is_unit = ( ! empty( $unit ) ) ? ' wp_china_yes--is-unit' : '';
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<div class="wp_china_yes--inputs" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
|
||||
|
||||
if ( ! empty( $args['width'] ) ) {
|
||||
$placeholder = ( ! empty( $args['width_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args['width_placeholder'] ) .'"' : '';
|
||||
echo '<div class="wp_china_yes--input">';
|
||||
echo ( ! empty( $args['width_icon'] ) ) ? '<span class="wp_china_yes--label wp_china_yes--icon">'. $args['width_icon'] .'</span>' : '';
|
||||
echo '<input type="number" name="'. esc_attr( $this->field_name( '[width]' ) ) .'" value="'. esc_attr( $value['width'] ) .'"'. $placeholder .' class="wp_china_yes-input-number'. esc_attr( $is_unit ) .'" step="any" />';
|
||||
echo ( ! empty( $unit ) ) ? '<span class="wp_china_yes--label wp_china_yes--unit">'. esc_attr( $args['units'][0] ) .'</span>' : '';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if ( ! empty( $args['height'] ) ) {
|
||||
$placeholder = ( ! empty( $args['height_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args['height_placeholder'] ) .'"' : '';
|
||||
echo '<div class="wp_china_yes--input">';
|
||||
echo ( ! empty( $args['height_icon'] ) ) ? '<span class="wp_china_yes--label wp_china_yes--icon">'. $args['height_icon'] .'</span>' : '';
|
||||
echo '<input type="number" name="'. esc_attr( $this->field_name( '[height]' ) ) .'" value="'. esc_attr( $value['height'] ) .'"'. $placeholder .' class="wp_china_yes-input-number'. esc_attr( $is_unit ) .'" step="any" />';
|
||||
echo ( ! empty( $unit ) ) ? '<span class="wp_china_yes--label wp_china_yes--unit">'. esc_attr( $args['units'][0] ) .'</span>' : '';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if ( ! empty( $args['unit'] ) && ! empty( $args['show_units'] ) && count( $args['units'] ) > 1 ) {
|
||||
echo '<div class="wp_china_yes--input">';
|
||||
echo '<select name="'. esc_attr( $this->field_name( '[unit]' ) ) .'">';
|
||||
foreach ( $args['units'] as $unit ) {
|
||||
$selected = ( $value['unit'] === $unit ) ? ' selected' : '';
|
||||
echo '<option value="'. esc_attr( $unit ) .'"'. esc_attr( $selected ) .'>'. esc_attr( $unit ) .'</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function output() {
|
||||
|
||||
$output = '';
|
||||
$element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
|
||||
$prefix = ( ! empty( $this->field['output_prefix'] ) ) ? $this->field['output_prefix'] .'-' : '';
|
||||
$important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
|
||||
$unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
|
||||
$width = ( isset( $this->value['width'] ) && $this->value['width'] !== '' ) ? $prefix .'width:'. $this->value['width'] . $unit . $important .';' : '';
|
||||
$height = ( isset( $this->value['height'] ) && $this->value['height'] !== '' ) ? $prefix .'height:'. $this->value['height'] . $unit . $important .';' : '';
|
||||
|
||||
if ( $width !== '' || $height !== '' ) {
|
||||
$output = $element .'{'. $width . $height .'}';
|
||||
}
|
||||
|
||||
$this->parent->output_css .= $output;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
41
framework/fields/fieldset/fieldset.php
Executable file
41
framework/fields/fieldset/fieldset.php
Executable file
|
@ -0,0 +1,41 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: fieldset
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_fieldset' ) ) {
|
||||
class WP_CHINA_YES_Field_fieldset extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<div class="wp_china_yes-fieldset-content" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
|
||||
|
||||
foreach ( $this->field['fields'] as $field ) {
|
||||
|
||||
$field_id = ( isset( $field['id'] ) ) ? $field['id'] : '';
|
||||
$field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
|
||||
$field_value = ( isset( $this->value[$field_id] ) ) ? $this->value[$field_id] : $field_default;
|
||||
$unique_id = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']' : $this->field['id'];
|
||||
|
||||
WP_CHINA_YES::field( $field, $field_value, $unique_id, 'field/fieldset' );
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
52
framework/fields/gallery/gallery.php
Executable file
52
framework/fields/gallery/gallery.php
Executable file
|
@ -0,0 +1,52 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: gallery
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_gallery' ) ) {
|
||||
class WP_CHINA_YES_Field_gallery extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'add_title' => esc_html__( 'Add Gallery', 'wp_china_yes' ),
|
||||
'edit_title' => esc_html__( 'Edit Gallery', 'wp_china_yes' ),
|
||||
'clear_title' => esc_html__( 'Clear', 'wp_china_yes' ),
|
||||
) );
|
||||
|
||||
$hidden = ( empty( $this->value ) ) ? ' hidden' : '';
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<ul>';
|
||||
if ( ! empty( $this->value ) ) {
|
||||
|
||||
$values = explode( ',', $this->value );
|
||||
|
||||
foreach ( $values as $id ) {
|
||||
$attachment = wp_get_attachment_image_src( $id, 'thumbnail' );
|
||||
echo '<li><img src="'. esc_url( $attachment[0] ) .'" /></li>';
|
||||
}
|
||||
|
||||
}
|
||||
echo '</ul>';
|
||||
|
||||
echo '<a href="#" class="button button-primary wp_china_yes-button">'. $args['add_title'] .'</a>';
|
||||
echo '<a href="#" class="button wp_china_yes-edit-gallery'. esc_attr( $hidden ) .'">'. $args['edit_title'] .'</a>';
|
||||
echo '<a href="#" class="button wp_china_yes-warning-primary wp_china_yes-clear-gallery'. esc_attr( $hidden ) .'">'. $args['clear_title'] .'</a>';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes() .'/>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
164
framework/fields/group/group.php
Executable file
164
framework/fields/group/group.php
Executable file
|
@ -0,0 +1,164 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: group
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_group' ) ) {
|
||||
class WP_CHINA_YES_Field_group extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->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 '<div class="wp_china_yes-notice wp_china_yes-notice-danger">'. esc_html__( 'Error: Field ID conflict.', 'wp_china_yes' ) .'</div>';
|
||||
|
||||
} else {
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<div class="wp_china_yes-cloneable-item wp_china_yes-cloneable-hidden" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
|
||||
|
||||
echo '<div class="wp_china_yes-cloneable-helper">';
|
||||
echo '<i class="wp_china_yes-cloneable-sort fas fa-arrows-alt"></i>';
|
||||
echo '<i class="wp_china_yes-cloneable-clone far fa-clone"></i>';
|
||||
echo '<i class="wp_china_yes-cloneable-remove wp_china_yes-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'wp_china_yes' ) .'"></i>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<h4 class="wp_china_yes-cloneable-title">';
|
||||
echo '<span class="wp_china_yes-cloneable-text">';
|
||||
echo ( $title_number ) ? '<span class="wp_china_yes-cloneable-title-number"></span>' : '';
|
||||
echo ( $title_prefix ) ? '<span class="wp_china_yes-cloneable-title-prefix">'. esc_attr( $title_prefix ) .'</span>' : '';
|
||||
echo ( $title_auto ) ? '<span class="wp_china_yes-cloneable-value"><span class="wp_china_yes-cloneable-placeholder"></span></span>' : '';
|
||||
echo '</span>';
|
||||
echo '</h4>';
|
||||
|
||||
echo '<div class="wp_china_yes-cloneable-content">';
|
||||
foreach ( $this->field['fields'] as $field ) {
|
||||
|
||||
$field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
|
||||
$field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .'][0]' : $this->field['id'] .'[0]';
|
||||
|
||||
WP_CHINA_YES::field( $field, $field_default, '___'. $field_unique, 'field/group' );
|
||||
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="wp_china_yes-cloneable-wrapper wp_china_yes-data-wrapper" data-title-by="'. esc_attr( json_encode( $title_by ) ) .'" data-title-by-prefix="'. esc_attr( $title_by_prefix ) .'" data-title-number="'. esc_attr( $title_number ) .'" data-field-id="['. esc_attr( $this->field['id'] ) .']" data-max="'. esc_attr( $args['max'] ) .'" data-min="'. esc_attr( $args['min'] ) .'">';
|
||||
|
||||
if ( ! empty( $this->value ) ) {
|
||||
|
||||
$num = 0;
|
||||
|
||||
foreach ( $this->value as $value ) {
|
||||
|
||||
$title = '';
|
||||
|
||||
if ( ! empty( $title_by ) ) {
|
||||
|
||||
$titles = array();
|
||||
|
||||
foreach ( $title_by as $title_key ) {
|
||||
if ( isset( $value[ $title_key ] ) ) {
|
||||
$titles[] = $value[ $title_key ];
|
||||
}
|
||||
}
|
||||
|
||||
$title = join( $title_by_prefix, $titles );
|
||||
|
||||
}
|
||||
|
||||
$title = ( is_array( $title ) ) ? reset( $title ) : $title;
|
||||
|
||||
echo '<div class="wp_china_yes-cloneable-item">';
|
||||
|
||||
echo '<div class="wp_china_yes-cloneable-helper">';
|
||||
echo '<i class="wp_china_yes-cloneable-sort fas fa-arrows-alt"></i>';
|
||||
echo '<i class="wp_china_yes-cloneable-clone far fa-clone"></i>';
|
||||
echo '<i class="wp_china_yes-cloneable-remove wp_china_yes-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'wp_china_yes' ) .'"></i>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<h4 class="wp_china_yes-cloneable-title">';
|
||||
echo '<span class="wp_china_yes-cloneable-text">';
|
||||
echo ( $title_number ) ? '<span class="wp_china_yes-cloneable-title-number">'. esc_attr( $num+1 ) .'.</span>' : '';
|
||||
echo ( $title_prefix ) ? '<span class="wp_china_yes-cloneable-title-prefix">'. esc_attr( $title_prefix ) .'</span>' : '';
|
||||
echo ( $title_auto ) ? '<span class="wp_china_yes-cloneable-value">' . esc_attr( $title ) .'</span>' : '';
|
||||
echo '</span>';
|
||||
echo '</h4>';
|
||||
|
||||
echo '<div class="wp_china_yes-cloneable-content">';
|
||||
|
||||
foreach ( $this->field['fields'] as $field ) {
|
||||
|
||||
$field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']['. $num .']' : $this->field['id'] .'['. $num .']';
|
||||
$field_value = ( isset( $field['id'] ) && isset( $value[$field['id']] ) ) ? $value[$field['id']] : '';
|
||||
|
||||
WP_CHINA_YES::field( $field, $field_value, $field_unique, 'field/group' );
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
$num++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="wp_china_yes-cloneable-alert wp_china_yes-cloneable-max">'. esc_html__( 'You cannot add more.', 'wp_china_yes' ) .'</div>';
|
||||
echo '<div class="wp_china_yes-cloneable-alert wp_china_yes-cloneable-min">'. esc_html__( 'You cannot remove more.', 'wp_china_yes' ) .'</div>';
|
||||
echo '<a href="#" class="button button-primary wp_china_yes-cloneable-add">'. $args['button_title'] .'</a>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
if ( ! wp_script_is( 'jquery-ui-accordion' ) ) {
|
||||
wp_enqueue_script( 'jquery-ui-accordion' );
|
||||
}
|
||||
|
||||
if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
24
framework/fields/heading/heading.php
Executable file
24
framework/fields/heading/heading.php
Executable file
|
@ -0,0 +1,24 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: heading
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_heading' ) ) {
|
||||
class WP_CHINA_YES_Field_heading extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
echo ( ! empty( $this->field['content'] ) ) ? $this->field['content'] : '';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
12
framework/fields/icon/fa4-icons.php
Executable file
12
framework/fields/icon/fa4-icons.php
Executable file
File diff suppressed because one or more lines are too long
12
framework/fields/icon/fa5-icons.php
Executable file
12
framework/fields/icon/fa5-icons.php
Executable file
File diff suppressed because one or more lines are too long
71
framework/fields/icon/icon.php
Executable file
71
framework/fields/icon/icon.php
Executable file
|
@ -0,0 +1,71 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: icon
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_icon' ) ) {
|
||||
class WP_CHINA_YES_Field_icon extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'button_title' => esc_html__( 'Add Icon', 'wp_china_yes' ),
|
||||
'remove_title' => esc_html__( 'Remove Icon', 'wp_china_yes' ),
|
||||
) );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
$nonce = wp_create_nonce( 'wp_china_yes_icon_nonce' );
|
||||
$hidden = ( empty( $this->value ) ) ? ' hidden' : '';
|
||||
|
||||
echo '<div class="wp_china_yes-icon-select">';
|
||||
echo '<span class="wp_china_yes-icon-preview'. esc_attr( $hidden ) .'"><i class="'. esc_attr( $this->value ) .'"></i></span>';
|
||||
echo '<a href="#" class="button button-primary wp_china_yes-icon-add" data-nonce="'. esc_attr( $nonce ) .'">'. $args['button_title'] .'</a>';
|
||||
echo '<a href="#" class="button wp_china_yes-warning-primary wp_china_yes-icon-remove'. esc_attr( $hidden ) .'">'. $args['remove_title'] .'</a>';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'" class="wp_china_yes-icon-value"'. $this->field_attributes() .' />';
|
||||
echo '</div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
add_action( 'admin_footer', array( 'WP_CHINA_YES_Field_icon', 'add_footer_modal_icon' ) );
|
||||
add_action( 'customize_controls_print_footer_scripts', array( 'WP_CHINA_YES_Field_icon', 'add_footer_modal_icon' ) );
|
||||
}
|
||||
|
||||
public static function add_footer_modal_icon() {
|
||||
?>
|
||||
<div id="wp_china_yes-modal-icon" class="wp_china_yes-modal wp_china_yes-modal-icon hidden">
|
||||
<div class="wp_china_yes-modal-table">
|
||||
<div class="wp_china_yes-modal-table-cell">
|
||||
<div class="wp_china_yes-modal-overlay"></div>
|
||||
<div class="wp_china_yes-modal-inner">
|
||||
<div class="wp_china_yes-modal-title">
|
||||
<?php esc_html_e( 'Add Icon', 'wp_china_yes' ); ?>
|
||||
<div class="wp_china_yes-modal-close wp_china_yes-icon-close"></div>
|
||||
</div>
|
||||
<div class="wp_china_yes-modal-header">
|
||||
<input type="text" placeholder="<?php esc_html_e( 'Search...', 'wp_china_yes' ); ?>" class="wp_china_yes-icon-search" />
|
||||
</div>
|
||||
<div class="wp_china_yes-modal-content">
|
||||
<div class="wp_china_yes-modal-loading"><div class="wp_china_yes-loading"></div></div>
|
||||
<div class="wp_china_yes-modal-load"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
}
|
12
framework/fields/icon/iconsax-icons.php
Executable file
12
framework/fields/icon/iconsax-icons.php
Executable file
File diff suppressed because one or more lines are too long
79
framework/fields/image_select/image_select.php
Executable file
79
framework/fields/image_select/image_select.php
Executable file
|
@ -0,0 +1,79 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: image_select
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_image_select' ) ) {
|
||||
class WP_CHINA_YES_Field_image_select extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'multiple' => false,
|
||||
'inline' => false,
|
||||
'options' => array(),
|
||||
) );
|
||||
|
||||
$inline = ( $args['inline'] ) ? ' wp_china_yes--inline-list' : '';
|
||||
|
||||
$value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
if ( ! empty( $args['options'] ) ) {
|
||||
|
||||
echo '<div class="wp_china_yes-siblings wp_china_yes--image-group'. esc_attr( $inline ) .'" data-multiple="'. esc_attr( $args['multiple'] ) .'">';
|
||||
|
||||
$num = 1;
|
||||
|
||||
foreach ( $args['options'] as $key => $option ) {
|
||||
|
||||
$type = ( $args['multiple'] ) ? 'checkbox' : 'radio';
|
||||
$extra = ( $args['multiple'] ) ? '[]' : '';
|
||||
$active = ( in_array( $key, $value ) ) ? ' wp_china_yes--active' : '';
|
||||
$checked = ( in_array( $key, $value ) ) ? ' checked' : '';
|
||||
|
||||
echo '<div class="wp_china_yes--sibling wp_china_yes--image'. esc_attr( $active ) .'">';
|
||||
echo '<figure>';
|
||||
echo '<img src="'. esc_url( $option ) .'" alt="img-'. esc_attr( $num++ ) .'" />';
|
||||
echo '<input type="'. esc_attr( $type ) .'" name="'. esc_attr( $this->field_name( $extra ) ) .'" value="'. esc_attr( $key ) .'"'. $this->field_attributes() . esc_attr( $checked ) .'/>';
|
||||
echo '</figure>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function output() {
|
||||
|
||||
$output = '';
|
||||
$bg_image = array();
|
||||
$important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
|
||||
$elements = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
|
||||
|
||||
if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
|
||||
$output = $elements .'{background-image:url('. $this->value .')'. $important .';}';
|
||||
}
|
||||
|
||||
$this->parent->output_css .= $output;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
1
framework/fields/index.php
Executable file
1
framework/fields/index.php
Executable file
|
@ -0,0 +1 @@
|
|||
<?php // Silence is golden.
|
82
framework/fields/link/link.php
Executable file
82
framework/fields/link/link.php
Executable file
|
@ -0,0 +1,82 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: link
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_link' ) ) {
|
||||
class WP_CHINA_YES_Field_link extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'add_title' => esc_html__( 'Add Link', 'wp_china_yes' ),
|
||||
'edit_title' => esc_html__( 'Edit Link', 'wp_china_yes' ),
|
||||
'remove_title' => esc_html__( 'Remove Link', 'wp_china_yes' ),
|
||||
) );
|
||||
|
||||
$default_values = array(
|
||||
'url' => '',
|
||||
'text' => '',
|
||||
'target' => '',
|
||||
);
|
||||
|
||||
$value = wp_parse_args( $this->value, $default_values );
|
||||
|
||||
$hidden = ( ! empty( $value['url'] ) || ! empty( $value['url'] ) || ! empty( $value['url'] ) ) ? ' hidden' : '';
|
||||
|
||||
$maybe_hidden = ( empty( $hidden ) ) ? ' hidden' : '';
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<textarea readonly="readonly" class="wp_china_yes--link hidden"></textarea>';
|
||||
|
||||
echo '<div class="'. esc_attr( $maybe_hidden ) .'"><div class="wp_china_yes--result">'. sprintf( '{url:"%s", text:"%s", target:"%s"}', $value['url'], $value['text'], $value['target'] ) .'</div></div>';
|
||||
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[url]' ) ) .'" value="'. esc_attr( $value['url'] ) .'"'. $this->field_attributes( array( 'class' => 'wp_china_yes--url' ) ) .' />';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[text]' ) ) .'" value="'. esc_attr( $value['text'] ) .'" class="wp_china_yes--text" />';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[target]' ) ) .'" value="'. esc_attr( $value['target'] ) .'" class="wp_china_yes--target" />';
|
||||
|
||||
echo '<a href="#" class="button button-primary wp_china_yes--add'. esc_attr( $hidden ) .'">'. $args['add_title'] .'</a> ';
|
||||
echo '<a href="#" class="button wp_china_yes--edit'. esc_attr( $maybe_hidden ) .'">'. $args['edit_title'] .'</a> ';
|
||||
echo '<a href="#" class="button wp_china_yes-warning-primary wp_china_yes--remove'. esc_attr( $maybe_hidden ) .'">'. $args['remove_title'] .'</a>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
if ( ! wp_script_is( 'wplink' ) ) {
|
||||
wp_enqueue_script( 'wplink' );
|
||||
}
|
||||
|
||||
if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
|
||||
wp_enqueue_script( 'jquery-ui-autocomplete' );
|
||||
}
|
||||
|
||||
add_action( 'admin_print_footer_scripts', array( $this, 'add_wp_link_dialog' ) );
|
||||
|
||||
}
|
||||
|
||||
public function add_wp_link_dialog() {
|
||||
|
||||
if ( ! class_exists( '_WP_Editors' ) ) {
|
||||
require_once ABSPATH . WPINC .'/class-wp-editor.php';
|
||||
}
|
||||
|
||||
wp_print_styles( 'editor-buttons' );
|
||||
|
||||
_WP_Editors::wp_link_dialog();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
91
framework/fields/link_color/link_color.php
Executable file
91
framework/fields/link_color/link_color.php
Executable file
|
@ -0,0 +1,91 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: link_color
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_link_color' ) ) {
|
||||
class WP_CHINA_YES_Field_link_color extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'color' => true,
|
||||
'hover' => true,
|
||||
'active' => false,
|
||||
'visited' => false,
|
||||
'focus' => false,
|
||||
) );
|
||||
|
||||
$default_values = array(
|
||||
'color' => '',
|
||||
'hover' => '',
|
||||
'active' => '',
|
||||
'visited' => '',
|
||||
'focus' => '',
|
||||
);
|
||||
|
||||
$color_props = array(
|
||||
'color' => esc_html__( 'Normal', 'wp_china_yes' ),
|
||||
'hover' => esc_html__( 'Hover', 'wp_china_yes' ),
|
||||
'active' => esc_html__( 'Active', 'wp_china_yes' ),
|
||||
'visited' => esc_html__( 'Visited', 'wp_china_yes' ),
|
||||
'focus' => esc_html__( 'Focus', 'wp_china_yes' )
|
||||
);
|
||||
|
||||
$value = wp_parse_args( $this->value, $default_values );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
foreach ( $color_props as $color_prop_key => $color_prop_value ) {
|
||||
|
||||
if ( ! empty( $args[$color_prop_key] ) ) {
|
||||
|
||||
$default_attr = ( ! empty( $this->field['default'][$color_prop_key] ) ) ? ' data-default-color="'. esc_attr( $this->field['default'][$color_prop_key] ) .'"' : '';
|
||||
|
||||
echo '<div class="wp_china_yes--left wp_china_yes-field-color">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_attr( $color_prop_value ) .'</div>';
|
||||
echo '<input type="text" name="'. esc_attr( $this->field_name( '['. $color_prop_key .']' ) ) .'" value="'. esc_attr( $value[$color_prop_key] ) .'" class="wp_china_yes-color"'. $default_attr . $this->field_attributes() .'/>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function output() {
|
||||
|
||||
$output = '';
|
||||
$elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
|
||||
$important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
|
||||
|
||||
if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
|
||||
foreach ( $elements as $element ) {
|
||||
|
||||
if ( isset( $this->value['color'] ) && $this->value['color'] !== '' ) { $output .= $element .'{color:'. $this->value['color'] . $important .';}'; }
|
||||
if ( isset( $this->value['hover'] ) && $this->value['hover'] !== '' ) { $output .= $element .':hover{color:'. $this->value['hover'] . $important .';}'; }
|
||||
if ( isset( $this->value['active'] ) && $this->value['active'] !== '' ) { $output .= $element .':active{color:'. $this->value['active'] . $important .';}'; }
|
||||
if ( isset( $this->value['visited'] ) && $this->value['visited'] !== '' ) { $output .= $element .':visited{color:'. $this->value['visited'] . $important .';}'; }
|
||||
if ( isset( $this->value['focus'] ) && $this->value['focus'] !== '' ) { $output .= $element .':focus{color:'. $this->value['focus'] . $important .';}'; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->parent->output_css .= $output;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
98
framework/fields/map/map.php
Executable file
98
framework/fields/map/map.php
Executable file
|
@ -0,0 +1,98 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: map
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_map' ) ) {
|
||||
class WP_CHINA_YES_Field_map extends WP_CHINA_YES_Fields {
|
||||
|
||||
public $version = '1.9.4';
|
||||
public $cdn_url = 'https://jsd.admincdn.com/npm/leaflet@';
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'placeholder' => esc_html__( 'Search...', 'wp_china_yes' ),
|
||||
'latitude_text' => esc_html__( 'Latitude', 'wp_china_yes' ),
|
||||
'longitude_text' => esc_html__( 'Longitude', 'wp_china_yes' ),
|
||||
'address_field' => '',
|
||||
'height' => '',
|
||||
) );
|
||||
|
||||
$value = wp_parse_args( $this->value, array(
|
||||
'address' => '',
|
||||
'latitude' => '20',
|
||||
'longitude' => '0',
|
||||
'zoom' => '2',
|
||||
) );
|
||||
|
||||
$default_settings = array(
|
||||
'center' => array( $value['latitude'], $value['longitude'] ),
|
||||
'zoom' => $value['zoom'],
|
||||
'scrollWheelZoom' => false,
|
||||
);
|
||||
|
||||
$settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
|
||||
$settings = wp_parse_args( $settings, $default_settings );
|
||||
|
||||
$style_attr = ( ! empty( $args['height'] ) ) ? ' style="min-height:'. esc_attr( $args['height'] ) .';"' : '';
|
||||
$placeholder = ( ! empty( $args['placeholder'] ) ) ? array( 'placeholder' => $args['placeholder'] ) : '';
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
if ( empty( $args['address_field'] ) ) {
|
||||
echo '<div class="wp_china_yes--map-search">';
|
||||
echo '<input type="text" name="'. esc_attr( $this->field_name( '[address]' ) ) .'" value="'. esc_attr( $value['address'] ) .'"'. $this->field_attributes( $placeholder ) .' />';
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<div class="wp_china_yes--address-field" data-address-field="'. esc_attr( $args['address_field'] ) .'"></div>';
|
||||
}
|
||||
|
||||
echo '<div class="wp_china_yes--map-osm-wrap"><div class="wp_china_yes--map-osm" data-map="'. esc_attr( json_encode( $settings ) ) .'"'. $style_attr .'></div></div>';
|
||||
|
||||
echo '<div class="wp_china_yes--map-inputs">';
|
||||
|
||||
echo '<div class="wp_china_yes--map-input">';
|
||||
echo '<label>'. esc_attr( $args['latitude_text'] ) .'</label>';
|
||||
echo '<input type="text" name="'. esc_attr( $this->field_name( '[latitude]' ) ) .'" value="'. esc_attr( $value['latitude'] ) .'" class="wp_china_yes--latitude" />';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="wp_china_yes--map-input">';
|
||||
echo '<label>'. esc_attr( $args['longitude_text'] ) .'</label>';
|
||||
echo '<input type="text" name="'. esc_attr( $this->field_name( '[longitude]' ) ) .'" value="'. esc_attr( $value['longitude'] ) .'" class="wp_china_yes--longitude" />';
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[zoom]' ) ) .'" value="'. esc_attr( $value['zoom'] ) .'" class="wp_china_yes--zoom" />';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
if ( ! wp_script_is( 'wp_china_yes-leaflet' ) ) {
|
||||
wp_enqueue_script( 'wp_china_yes-leaflet', esc_url( $this->cdn_url . $this->version .'/dist/leaflet.js' ), array( 'wp_china_yes' ), $this->version, true );
|
||||
}
|
||||
|
||||
if ( ! wp_style_is( 'wp_china_yes-leaflet' ) ) {
|
||||
wp_enqueue_style( 'wp_china_yes-leaflet', esc_url( $this->cdn_url . $this->version .'/dist/leaflet.css' ), array(), $this->version );
|
||||
}
|
||||
|
||||
if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
|
||||
wp_enqueue_script( 'jquery-ui-autocomplete' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
96
framework/fields/media/media.php
Executable file
96
framework/fields/media/media.php
Executable file
|
@ -0,0 +1,96 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: media
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_media' ) ) {
|
||||
class WP_CHINA_YES_Field_media extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'url' => true,
|
||||
'preview' => true,
|
||||
'preview_width' => '',
|
||||
'preview_height' => '',
|
||||
'library' => array(),
|
||||
'button_title' => esc_html__( 'Upload', 'wp_china_yes' ),
|
||||
'remove_title' => esc_html__( 'Remove', 'wp_china_yes' ),
|
||||
'preview_size' => 'thumbnail',
|
||||
) );
|
||||
|
||||
$default_values = array(
|
||||
'url' => '',
|
||||
'id' => '',
|
||||
'width' => '',
|
||||
'height' => '',
|
||||
'thumbnail' => '',
|
||||
'alt' => '',
|
||||
'title' => '',
|
||||
'description' => ''
|
||||
);
|
||||
|
||||
// fallback
|
||||
if ( is_numeric( $this->value ) ) {
|
||||
|
||||
$this->value = array(
|
||||
'id' => $this->value,
|
||||
'url' => wp_get_attachment_url( $this->value ),
|
||||
'thumbnail' => wp_get_attachment_image_src( $this->value, 'thumbnail', true )[0],
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$this->value = wp_parse_args( $this->value, $default_values );
|
||||
|
||||
$library = ( is_array( $args['library'] ) ) ? $args['library'] : array_filter( (array) $args['library'] );
|
||||
$library = ( ! empty( $library ) ) ? implode(',', $library ) : '';
|
||||
$preview_src = ( $args['preview_size'] !== 'thumbnail' ) ? $this->value['url'] : $this->value['thumbnail'];
|
||||
$hidden_url = ( empty( $args['url'] ) ) ? ' hidden' : '';
|
||||
$hidden_auto = ( empty( $this->value['url'] ) ) ? ' hidden' : '';
|
||||
$placeholder = ( empty( $this->field['placeholder'] ) ) ? ' placeholder="'. esc_html__( 'Not selected', 'wp_china_yes' ) .'"' : '';
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
if ( ! empty( $args['preview'] ) ) {
|
||||
|
||||
$preview_width = ( ! empty( $args['preview_width'] ) ) ? 'max-width:'. esc_attr( $args['preview_width'] ) .'px;' : '';
|
||||
$preview_height = ( ! empty( $args['preview_height'] ) ) ? 'max-height:'. esc_attr( $args['preview_height'] ) .'px;' : '';
|
||||
$preview_style = ( ! empty( $preview_width ) || ! empty( $preview_height ) ) ? ' style="'. esc_attr( $preview_width . $preview_height ) .'"': '';
|
||||
|
||||
echo '<div class="wp_china_yes--preview'. esc_attr( $hidden_auto ) .'">';
|
||||
echo '<div class="wp_china_yes-image-preview"'. $preview_style .'>';
|
||||
echo '<i class="wp_china_yes--remove fas fa-times"></i><span><img src="'. esc_url( $preview_src ) .'" class="wp_china_yes--src" /></span>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo '<div class="wp_china_yes--placeholder">';
|
||||
echo '<input type="text" name="'. esc_attr( $this->field_name( '[url]' ) ) .'" value="'. esc_attr( $this->value['url'] ) .'" class="wp_china_yes--url'. esc_attr( $hidden_url ) .'" readonly="readonly"'. $this->field_attributes() . $placeholder .' />';
|
||||
echo '<a href="#" class="button button-primary wp_china_yes--button" data-library="'. esc_attr( $library ) .'" data-preview-size="'. esc_attr( $args['preview_size'] ) .'">'. $args['button_title'] .'</a>';
|
||||
echo ( empty( $args['preview'] ) ) ? '<a href="#" class="button button-secondary wp_china_yes-warning-primary wp_china_yes--remove'. esc_attr( $hidden_auto ) .'">'. $args['remove_title'] .'</a>' : '';
|
||||
echo '</div>';
|
||||
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[id]' ) ) .'" value="'. esc_attr( $this->value['id'] ) .'" class="wp_china_yes--id"/>';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[width]' ) ) .'" value="'. esc_attr( $this->value['width'] ) .'" class="wp_china_yes--width"/>';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[height]' ) ) .'" value="'. esc_attr( $this->value['height'] ) .'" class="wp_china_yes--height"/>';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[thumbnail]' ) ) .'" value="'. esc_attr( $this->value['thumbnail'] ) .'" class="wp_china_yes--thumbnail"/>';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[alt]' ) ) .'" value="'. esc_attr( $this->value['alt'] ) .'" class="wp_china_yes--alt"/>';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[title]' ) ) .'" value="'. esc_attr( $this->value['title'] ) .'" class="wp_china_yes--title"/>';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[description]' ) ) .'" value="'. esc_attr( $this->value['description'] ) .'" class="wp_china_yes--description"/>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
26
framework/fields/notice/notice.php
Executable file
26
framework/fields/notice/notice.php
Executable file
|
@ -0,0 +1,26 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: notice
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_notice' ) ) {
|
||||
class WP_CHINA_YES_Field_notice extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$style = ( ! empty( $this->field['style'] ) ) ? $this->field['style'] : 'normal';
|
||||
|
||||
echo ( ! empty( $this->field['content'] ) ) ? '<div class="wp_china_yes-notice wp_china_yes-notice-'. esc_attr( $style ) .'">'. $this->field['content'] .'</div>' : '';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
63
framework/fields/number/number.php
Executable file
63
framework/fields/number/number.php
Executable file
|
@ -0,0 +1,63 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: number
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_number' ) ) {
|
||||
class WP_CHINA_YES_Field_number extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'min' => 'any',
|
||||
'max' => 'any',
|
||||
'step' => 'any',
|
||||
'unit' => '',
|
||||
) );
|
||||
|
||||
echo $this->field_before();
|
||||
echo '<div class="wp_china_yes--wrap">';
|
||||
echo '<input type="number" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes() .' min="'. esc_attr( $args['min'] ) .'" max="'. esc_attr( $args['max'] ) .'" step="'. esc_attr( $args['step'] ) .'"/>';
|
||||
echo ( ! empty( $args['unit'] ) ) ? '<span class="wp_china_yes--unit">'. esc_attr( $args['unit'] ) .'</span>' : '';
|
||||
echo '</div>';
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function output() {
|
||||
|
||||
$output = '';
|
||||
$elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
|
||||
$important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
|
||||
$mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'width';
|
||||
$unit = ( ! empty( $this->field['unit'] ) ) ? $this->field['unit'] : 'px';
|
||||
|
||||
if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
|
||||
foreach ( $elements as $key_property => $element ) {
|
||||
if ( is_numeric( $key_property ) ) {
|
||||
if ( $mode ) {
|
||||
$output = implode( ',', $elements ) .'{'. $mode .':'. $this->value . $unit . $important .';}';
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
$output .= $element .'{'. $key_property .':'. $this->value . $unit . $important .'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->parent->output_css .= $output;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
58
framework/fields/palette/palette.php
Executable file
58
framework/fields/palette/palette.php
Executable file
|
@ -0,0 +1,58 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: palette
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_palette' ) ) {
|
||||
class WP_CHINA_YES_Field_palette extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$palette = ( ! empty( $this->field['options'] ) ) ? $this->field['options'] : array();
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
if ( ! empty( $palette ) ) {
|
||||
|
||||
echo '<div class="wp_china_yes-siblings wp_china_yes--palettes">';
|
||||
|
||||
foreach ( $palette as $key => $colors ) {
|
||||
|
||||
$active = ( $key === $this->value ) ? ' wp_china_yes--active' : '';
|
||||
$checked = ( $key === $this->value ) ? ' checked' : '';
|
||||
|
||||
echo '<div class="wp_china_yes--sibling wp_china_yes--palette'. esc_attr( $active ) .'">';
|
||||
|
||||
if ( ! empty( $colors ) ) {
|
||||
|
||||
foreach ( $colors as $color ) {
|
||||
|
||||
echo '<span style="background-color: '. esc_attr( $color ) .';"></span>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '<input type="radio" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $key ) .'"'. $this->field_attributes() . esc_attr( $checked ) .'/>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
93
framework/fields/radio/radio.php
Executable file
93
framework/fields/radio/radio.php
Executable file
|
@ -0,0 +1,93 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: radio
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_radio' ) ) {
|
||||
class WP_CHINA_YES_Field_radio extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'inline' => false,
|
||||
'query_args' => array(),
|
||||
) );
|
||||
|
||||
$inline_class = ( $args['inline'] ) ? ' class="wp_china_yes--inline-list"' : '';
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
if ( isset( $this->field['options'] ) ) {
|
||||
|
||||
$options = $this->field['options'];
|
||||
$options = ( is_array( $options ) ) ? $options : array_filter( $this->field_data( $options, false, $args['query_args'] ) );
|
||||
|
||||
if ( is_array( $options ) && ! empty( $options ) ) {
|
||||
|
||||
echo '<ul'. $inline_class .'>';
|
||||
|
||||
foreach ( $options as $option_key => $option_value ) {
|
||||
|
||||
if ( is_array( $option_value ) && ! empty( $option_value ) ) {
|
||||
|
||||
echo '<li>';
|
||||
echo '<ul>';
|
||||
echo '<li><strong>'. esc_attr( $option_key ) .'</strong></li>';
|
||||
foreach ( $option_value as $sub_key => $sub_value ) {
|
||||
$checked = ( $sub_key == $this->value ) ? ' checked' : '';
|
||||
echo '<li>';
|
||||
echo '<label>';
|
||||
echo '<input type="radio" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $sub_key ) .'"'. $this->field_attributes() . esc_attr( $checked ) .'/>';
|
||||
echo '<span class="wp_china_yes--text">'. esc_attr( $sub_value ) .'</span>';
|
||||
echo '</label>';
|
||||
echo '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
echo '</li>';
|
||||
|
||||
} else {
|
||||
|
||||
$checked = ( $option_key == $this->value ) ? ' checked' : '';
|
||||
|
||||
echo '<li>';
|
||||
echo '<label>';
|
||||
echo '<input type="radio" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $option_key ) .'"'. $this->field_attributes() . esc_attr( $checked ) .'/>';
|
||||
echo '<span class="wp_china_yes--text">'. esc_attr( $option_value ) .'</span>';
|
||||
echo '</label>';
|
||||
echo '</li>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
} 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 '<label><input type="radio" name="'. esc_attr( $this->field_name() ) .'" value="1"'. $this->field_attributes() . esc_attr( checked( $this->value, 1, false ) ) .'/>';
|
||||
echo ( ! empty( $this->field['label'] ) ) ? '<span class="wp_china_yes--text">'. esc_attr( $this->field['label'] ) .'</span>' : '';
|
||||
echo '</label>';
|
||||
|
||||
}
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
108
framework/fields/repeater/repeater.php
Executable file
108
framework/fields/repeater/repeater.php
Executable file
|
@ -0,0 +1,108 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: repeater
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_repeater' ) ) {
|
||||
class WP_CHINA_YES_Field_repeater extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'max' => 0,
|
||||
'min' => 0,
|
||||
'button_title' => '<i class="fas fa-plus-circle"></i>',
|
||||
) );
|
||||
|
||||
if ( preg_match( '/'. preg_quote( '['. $this->field['id'] .']' ) .'/', $this->unique ) ) {
|
||||
|
||||
echo '<div class="wp_china_yes-notice wp_china_yes-notice-danger">'. esc_html__( 'Error: Field ID conflict.', 'wp_china_yes' ) .'</div>';
|
||||
|
||||
} else {
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<div class="wp_china_yes-repeater-item wp_china_yes-repeater-hidden" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
|
||||
echo '<div class="wp_china_yes-repeater-content">';
|
||||
foreach ( $this->field['fields'] as $field ) {
|
||||
|
||||
$field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
|
||||
$field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .'][0]' : $this->field['id'] .'[0]';
|
||||
|
||||
WP_CHINA_YES::field( $field, $field_default, '___'. $field_unique, 'field/repeater' );
|
||||
|
||||
}
|
||||
echo '</div>';
|
||||
echo '<div class="wp_china_yes-repeater-helper">';
|
||||
echo '<div class="wp_china_yes-repeater-helper-inner">';
|
||||
echo '<i class="wp_china_yes-repeater-sort fas fa-arrows-alt"></i>';
|
||||
echo '<i class="wp_china_yes-repeater-clone far fa-clone"></i>';
|
||||
echo '<i class="wp_china_yes-repeater-remove wp_china_yes-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'wp_china_yes' ) .'"></i>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="wp_china_yes-repeater-wrapper wp_china_yes-data-wrapper" data-field-id="['. esc_attr( $this->field['id'] ) .']" data-max="'. esc_attr( $args['max'] ) .'" data-min="'. esc_attr( $args['min'] ) .'">';
|
||||
|
||||
if ( ! empty( $this->value ) && is_array( $this->value ) ) {
|
||||
|
||||
$num = 0;
|
||||
|
||||
foreach ( $this->value as $key => $value ) {
|
||||
|
||||
echo '<div class="wp_china_yes-repeater-item">';
|
||||
echo '<div class="wp_china_yes-repeater-content">';
|
||||
foreach ( $this->field['fields'] as $field ) {
|
||||
|
||||
$field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']['. $num .']' : $this->field['id'] .'['. $num .']';
|
||||
$field_value = ( isset( $field['id'] ) && isset( $this->value[$key][$field['id']] ) ) ? $this->value[$key][$field['id']] : '';
|
||||
|
||||
WP_CHINA_YES::field( $field, $field_value, $field_unique, 'field/repeater' );
|
||||
|
||||
}
|
||||
echo '</div>';
|
||||
echo '<div class="wp_china_yes-repeater-helper">';
|
||||
echo '<div class="wp_china_yes-repeater-helper-inner">';
|
||||
echo '<i class="wp_china_yes-repeater-sort fas fa-arrows-alt"></i>';
|
||||
echo '<i class="wp_china_yes-repeater-clone far fa-clone"></i>';
|
||||
echo '<i class="wp_china_yes-repeater-remove wp_china_yes-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'wp_china_yes' ) .'"></i>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
$num++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="wp_china_yes-repeater-alert wp_china_yes-repeater-max">'. esc_html__( 'You cannot add more.', 'wp_china_yes' ) .'</div>';
|
||||
echo '<div class="wp_china_yes-repeater-alert wp_china_yes-repeater-min">'. esc_html__( 'You cannot remove more.', 'wp_china_yes' ) .'</div>';
|
||||
echo '<a href="#" class="button button-primary wp_china_yes-repeater-add">'. $args['button_title'] .'</a>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
132
framework/fields/select/select.php
Executable file
132
framework/fields/select/select.php
Executable file
|
@ -0,0 +1,132 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: select
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_select' ) ) {
|
||||
class WP_CHINA_YES_Field_select extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'placeholder' => '',
|
||||
'chosen' => false,
|
||||
'multiple' => false,
|
||||
'sortable' => false,
|
||||
'ajax' => false,
|
||||
'settings' => array(),
|
||||
'query_args' => array(),
|
||||
) );
|
||||
|
||||
$this->value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
if ( isset( $this->field['options'] ) ) {
|
||||
|
||||
if ( ! empty( $args['ajax'] ) ) {
|
||||
$args['settings']['data']['type'] = $args['options'];
|
||||
$args['settings']['data']['nonce'] = wp_create_nonce( 'wp_china_yes_chosen_ajax_nonce' );
|
||||
if ( ! empty( $args['query_args'] ) ) {
|
||||
$args['settings']['data']['query_args'] = $args['query_args'];
|
||||
}
|
||||
}
|
||||
|
||||
$chosen_rtl = ( is_rtl() ) ? ' chosen-rtl' : '';
|
||||
$multiple_name = ( $args['multiple'] ) ? '[]' : '';
|
||||
$multiple_attr = ( $args['multiple'] ) ? ' multiple="multiple"' : '';
|
||||
$chosen_sortable = ( $args['chosen'] && $args['sortable'] ) ? ' wp_china_yes-chosen-sortable' : '';
|
||||
$chosen_ajax = ( $args['chosen'] && $args['ajax'] ) ? ' wp_china_yes-chosen-ajax' : '';
|
||||
$placeholder_attr = ( $args['chosen'] && $args['placeholder'] ) ? ' data-placeholder="'. esc_attr( $args['placeholder'] ) .'"' : '';
|
||||
$field_class = ( $args['chosen'] ) ? ' class="wp_china_yes-chosen'. esc_attr( $chosen_rtl . $chosen_sortable . $chosen_ajax ) .'"' : '';
|
||||
$field_name = $this->field_name( $multiple_name );
|
||||
$field_attr = $this->field_attributes();
|
||||
$maybe_options = $this->field['options'];
|
||||
$chosen_data_attr = ( $args['chosen'] && ! empty( $args['settings'] ) ) ? ' data-chosen-settings="'. esc_attr( json_encode( $args['settings'] ) ) .'"' : '';
|
||||
|
||||
if ( is_string( $maybe_options ) && ! empty( $args['chosen'] ) && ! empty( $args['ajax'] ) ) {
|
||||
$options = $this->field_wp_query_data_title( $maybe_options, $this->value );
|
||||
} else if ( is_string( $maybe_options ) ) {
|
||||
$options = $this->field_data( $maybe_options, false, $args['query_args'] );
|
||||
} else {
|
||||
$options = $maybe_options;
|
||||
}
|
||||
|
||||
if ( ( is_array( $options ) && ! empty( $options ) ) || ( ! empty( $args['chosen'] ) && ! empty( $args['ajax'] ) ) ) {
|
||||
|
||||
if ( ! empty( $args['chosen'] ) && ! empty( $args['multiple'] ) ) {
|
||||
|
||||
echo '<select name="'. $field_name .'" class="wp_china_yes-hide-select hidden"'. $multiple_attr . $field_attr .'>';
|
||||
foreach ( $this->value as $option_key ) {
|
||||
echo '<option value="'. esc_attr( $option_key ) .'" selected>'. esc_attr( $option_key ) .'</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
|
||||
$field_name = '_pseudo';
|
||||
$field_attr = '';
|
||||
|
||||
}
|
||||
|
||||
// These attributes has been serialized above.
|
||||
echo '<select name="'. esc_attr( $field_name ) .'"'. $field_class . $multiple_attr . $placeholder_attr . $field_attr . $chosen_data_attr .'>';
|
||||
|
||||
if ( $args['placeholder'] && empty( $args['multiple'] ) ) {
|
||||
if ( ! empty( $args['chosen'] ) ) {
|
||||
echo '<option value=""></option>';
|
||||
} else {
|
||||
echo '<option value="">'. esc_attr( $args['placeholder'] ) .'</option>';
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $options as $option_key => $option ) {
|
||||
|
||||
if ( is_array( $option ) && ! empty( $option ) ) {
|
||||
|
||||
echo '<optgroup label="'. esc_attr( $option_key ) .'">';
|
||||
|
||||
foreach ( $option as $sub_key => $sub_value ) {
|
||||
$selected = ( in_array( $sub_key, $this->value ) ) ? ' selected' : '';
|
||||
echo '<option value="'. esc_attr( $sub_key ) .'" '. esc_attr( $selected ) .'>'. esc_attr( $sub_value ) .'</option>';
|
||||
}
|
||||
|
||||
echo '</optgroup>';
|
||||
|
||||
} else {
|
||||
$selected = ( in_array( $option_key, $this->value ) ) ? ' selected' : '';
|
||||
echo '<option value="'. esc_attr( $option_key ) .'" '. esc_attr( $selected ) .'>'. esc_attr( $option ) .'</option>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '</select>';
|
||||
|
||||
} else {
|
||||
|
||||
echo ( ! empty( $this->field['empty_message'] ) ) ? esc_attr( $this->field['empty_message'] ) : esc_html__( 'No data available.', 'wp_china_yes' );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
78
framework/fields/slider/slider.php
Executable file
78
framework/fields/slider/slider.php
Executable file
|
@ -0,0 +1,78 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: slider
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_slider' ) ) {
|
||||
class WP_CHINA_YES_Field_slider extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'max' => 100,
|
||||
'min' => 0,
|
||||
'step' => 1,
|
||||
'unit' => '',
|
||||
) );
|
||||
|
||||
$is_unit = ( ! empty( $args['unit'] ) ) ? ' wp_china_yes--is-unit' : '';
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<div class="wp_china_yes--wrap">';
|
||||
echo '<div class="wp_china_yes-slider-ui"></div>';
|
||||
echo '<div class="wp_china_yes--input">';
|
||||
echo '<input type="number" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes( array( 'class' => 'wp_china_yes-input-number'. esc_attr( $is_unit ) ) ) .' data-min="'. esc_attr( $args['min'] ) .'" data-max="'. esc_attr( $args['max'] ) .'" data-step="'. esc_attr( $args['step'] ) .'" step="any" />';
|
||||
echo ( ! empty( $args['unit'] ) ) ? '<span class="wp_china_yes--unit">'. esc_attr( $args['unit'] ) .'</span>' : '';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
if ( ! wp_script_is( 'jquery-ui-slider' ) ) {
|
||||
wp_enqueue_script( 'jquery-ui-slider' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function output() {
|
||||
|
||||
$output = '';
|
||||
$elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
|
||||
$important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
|
||||
$mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'width';
|
||||
$unit = ( ! empty( $this->field['unit'] ) ) ? $this->field['unit'] : 'px';
|
||||
|
||||
if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
|
||||
foreach ( $elements as $key_property => $element ) {
|
||||
if ( is_numeric( $key_property ) ) {
|
||||
if ( $mode ) {
|
||||
$output = implode( ',', $elements ) .'{'. $mode .':'. $this->value . $unit . $important .';}';
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
$output .= $element .'{'. $key_property .':'. $this->value . $unit . $important .'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->parent->output_css .= $output;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
87
framework/fields/sortable/sortable.php
Executable file
87
framework/fields/sortable/sortable.php
Executable file
|
@ -0,0 +1,87 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: sortable
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_sortable' ) ) {
|
||||
class WP_CHINA_YES_Field_sortable extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<div class="wp_china_yes-sortable" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
|
||||
|
||||
$pre_sortby = array();
|
||||
$pre_fields = array();
|
||||
|
||||
// Add array-keys to defined fields for sort by
|
||||
foreach ( $this->field['fields'] as $key => $field ) {
|
||||
$pre_fields[$field['id']] = $field;
|
||||
}
|
||||
|
||||
// Set sort by by saved-value or default-value
|
||||
if ( ! empty( $this->value ) ) {
|
||||
|
||||
foreach ( $this->value as $key => $value ) {
|
||||
$pre_sortby[$key] = $pre_fields[$key];
|
||||
}
|
||||
|
||||
$diff = array_diff_key( $pre_fields, $this->value );
|
||||
|
||||
if( ! empty( $diff ) ) {
|
||||
$pre_sortby = array_merge( $pre_sortby, $diff );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
foreach ( $pre_fields as $key => $value ) {
|
||||
$pre_sortby[$key] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ( $pre_sortby as $key => $field ) {
|
||||
|
||||
echo '<div class="wp_china_yes-sortable-item">';
|
||||
|
||||
echo '<div class="wp_china_yes-sortable-content">';
|
||||
|
||||
$field_default = ( isset( $this->field['default'][$key] ) ) ? $this->field['default'][$key] : '';
|
||||
$field_value = ( isset( $this->value[$key] ) ) ? $this->value[$key] : $field_default;
|
||||
$unique_id = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']' : $this->field['id'];
|
||||
|
||||
WP_CHINA_YES::field( $field, $field_value, $unique_id, 'field/sortable' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="wp_china_yes-sortable-helper"><i class="fas fa-arrows-alt"></i></div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
76
framework/fields/sorter/sorter.php
Executable file
76
framework/fields/sorter/sorter.php
Executable file
|
@ -0,0 +1,76 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: sorter
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_sorter' ) ) {
|
||||
class WP_CHINA_YES_Field_sorter extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'disabled' => true,
|
||||
'enabled_title' => esc_html__( 'Enabled', 'wp_china_yes' ),
|
||||
'disabled_title' => esc_html__( 'Disabled', 'wp_china_yes' ),
|
||||
) );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
$this->value = ( ! empty( $this->value ) ) ? $this->value : $this->field['default'];
|
||||
$enabled_options = ( ! empty( $this->value['enabled'] ) ) ? $this->value['enabled'] : array();
|
||||
$disabled_options = ( ! empty( $this->value['disabled'] ) ) ? $this->value['disabled'] : array();
|
||||
|
||||
echo '<div class="wp_china_yes-sorter" data-depend-id="'. esc_attr( $this->field['id'] ) .'"></div>';
|
||||
|
||||
echo ( $args['disabled'] ) ? '<div class="wp_china_yes-modules">' : '';
|
||||
|
||||
echo ( ! empty( $args['enabled_title'] ) ) ? '<div class="wp_china_yes-sorter-title">'. esc_attr( $args['enabled_title'] ) .'</div>' : '';
|
||||
echo '<ul class="wp_china_yes-enabled">';
|
||||
if ( ! empty( $enabled_options ) ) {
|
||||
foreach ( $enabled_options as $key => $value ) {
|
||||
echo '<li><input type="hidden" name="'. esc_attr( $this->field_name( '[enabled]['. $key .']' ) ) .'" value="'. esc_attr( $value ) .'"/><label>'. esc_attr( $value ) .'</label></li>';
|
||||
}
|
||||
}
|
||||
echo '</ul>';
|
||||
|
||||
// Check for hide/show disabled section
|
||||
if ( $args['disabled'] ) {
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="wp_china_yes-modules">';
|
||||
echo ( ! empty( $args['disabled_title'] ) ) ? '<div class="wp_china_yes-sorter-title">'. esc_attr( $args['disabled_title'] ) .'</div>' : '';
|
||||
echo '<ul class="wp_china_yes-disabled">';
|
||||
if ( ! empty( $disabled_options ) ) {
|
||||
foreach ( $disabled_options as $key => $value ) {
|
||||
echo '<li><input type="hidden" name="'. esc_attr( $this->field_name( '[disabled]['. $key .']' ) ) .'" value="'. esc_attr( $value ) .'"/><label>'. esc_attr( $value ) .'</label></li>';
|
||||
}
|
||||
}
|
||||
echo '</ul>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
171
framework/fields/spacing/spacing.php
Executable file
171
framework/fields/spacing/spacing.php
Executable file
|
@ -0,0 +1,171 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: spacing
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_spacing' ) ) {
|
||||
class WP_CHINA_YES_Field_spacing extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'top_icon' => '<i class="fas fa-long-arrow-alt-up"></i>',
|
||||
'right_icon' => '<i class="fas fa-long-arrow-alt-right"></i>',
|
||||
'bottom_icon' => '<i class="fas fa-long-arrow-alt-down"></i>',
|
||||
'left_icon' => '<i class="fas fa-long-arrow-alt-left"></i>',
|
||||
'all_icon' => '<i class="fas fa-arrows-alt"></i>',
|
||||
'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,
|
||||
'unit' => true,
|
||||
'show_units' => true,
|
||||
'all' => false,
|
||||
'units' => array( 'px', '%', 'em' )
|
||||
) );
|
||||
|
||||
$default_values = array(
|
||||
'top' => '',
|
||||
'right' => '',
|
||||
'bottom' => '',
|
||||
'left' => '',
|
||||
'all' => '',
|
||||
'unit' => 'px',
|
||||
);
|
||||
|
||||
$value = wp_parse_args( $this->value, $default_values );
|
||||
$unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
|
||||
$is_unit = ( ! empty( $unit ) ) ? ' wp_china_yes--is-unit' : '';
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<div class="wp_china_yes--inputs" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
|
||||
|
||||
if ( ! empty( $args['all'] ) ) {
|
||||
|
||||
$placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args['all_placeholder'] ) .'"' : '';
|
||||
|
||||
echo '<div class="wp_china_yes--input">';
|
||||
echo ( ! empty( $args['all_icon'] ) ) ? '<span class="wp_china_yes--label wp_china_yes--icon">'. $args['all_icon'] .'</span>' : '';
|
||||
echo '<input type="number" name="'. esc_attr( $this->field_name( '[all]' ) ) .'" value="'. esc_attr( $value['all'] ) .'"'. $placeholder .' class="wp_china_yes-input-number'. esc_attr( $is_unit ) .'" step="any" />';
|
||||
echo ( $unit ) ? '<span class="wp_china_yes--label wp_china_yes--unit">'. esc_attr( $args['units'][0] ) .'</span>' : '';
|
||||
echo '</div>';
|
||||
|
||||
} else {
|
||||
|
||||
$properties = array();
|
||||
|
||||
foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) {
|
||||
if ( ! empty( $args[$prop] ) ) {
|
||||
$properties[] = $prop;
|
||||
}
|
||||
}
|
||||
|
||||
$properties = ( $properties === array( 'right', 'left' ) ) ? array_reverse( $properties ) : $properties;
|
||||
|
||||
foreach ( $properties as $property ) {
|
||||
|
||||
$placeholder = ( ! empty( $args[$property.'_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args[$property.'_placeholder'] ) .'"' : '';
|
||||
|
||||
echo '<div class="wp_china_yes--input">';
|
||||
echo ( ! empty( $args[$property.'_icon'] ) ) ? '<span class="wp_china_yes--label wp_china_yes--icon">'. $args[$property.'_icon'] .'</span>' : '';
|
||||
echo '<input type="number" name="'. esc_attr( $this->field_name( '['. $property .']' ) ) .'" value="'. esc_attr( $value[$property] ) .'"'. $placeholder .' class="wp_china_yes-input-number'. esc_attr( $is_unit ) .'" step="any" />';
|
||||
echo ( $unit ) ? '<span class="wp_china_yes--label wp_china_yes--unit">'. esc_attr( $args['units'][0] ) .'</span>' : '';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty( $args['unit'] ) && ! empty( $args['show_units'] ) && count( $args['units'] ) > 1 ) {
|
||||
echo '<div class="wp_china_yes--input">';
|
||||
echo '<select name="'. esc_attr( $this->field_name( '[unit]' ) ) .'">';
|
||||
foreach ( $args['units'] as $unit ) {
|
||||
$selected = ( $value['unit'] === $unit ) ? ' selected' : '';
|
||||
echo '<option value="'. esc_attr( $unit ) .'"'. esc_attr( $selected ) .'>'. esc_attr( $unit ) .'</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function output() {
|
||||
|
||||
$output = '';
|
||||
$element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
|
||||
$important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
|
||||
$unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
|
||||
|
||||
$mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'padding';
|
||||
|
||||
if ( $mode === 'border-radius' || $mode === 'radius' ) {
|
||||
|
||||
$top = 'border-top-left-radius';
|
||||
$right = 'border-top-right-radius';
|
||||
$bottom = 'border-bottom-right-radius';
|
||||
$left = 'border-bottom-left-radius';
|
||||
|
||||
} else if ( $mode === 'relative' || $mode === 'absolute' || $mode === 'none' ) {
|
||||
|
||||
$top = 'top';
|
||||
$right = 'right';
|
||||
$bottom = 'bottom';
|
||||
$left = 'left';
|
||||
|
||||
} else {
|
||||
|
||||
$top = $mode .'-top';
|
||||
$right = $mode .'-right';
|
||||
$bottom = $mode .'-bottom';
|
||||
$left = $mode .'-left';
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty( $this->field['all'] ) && isset( $this->value['all'] ) && $this->value['all'] !== '' ) {
|
||||
|
||||
$output = $element .'{';
|
||||
$output .= $top .':'. $this->value['all'] . $unit . $important .';';
|
||||
$output .= $right .':'. $this->value['all'] . $unit . $important .';';
|
||||
$output .= $bottom .':'. $this->value['all'] . $unit . $important .';';
|
||||
$output .= $left .':'. $this->value['all'] . $unit . $important .';';
|
||||
$output .= '}';
|
||||
|
||||
} else {
|
||||
|
||||
$top = ( isset( $this->value['top'] ) && $this->value['top'] !== '' ) ? $top .':'. $this->value['top'] . $unit . $important .';' : '';
|
||||
$right = ( isset( $this->value['right'] ) && $this->value['right'] !== '' ) ? $right .':'. $this->value['right'] . $unit . $important .';' : '';
|
||||
$bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] !== '' ) ? $bottom .':'. $this->value['bottom'] . $unit . $important .';' : '';
|
||||
$left = ( isset( $this->value['left'] ) && $this->value['left'] !== '' ) ? $left .':'. $this->value['left'] . $unit . $important .';' : '';
|
||||
|
||||
if ( $top !== '' || $right !== '' || $bottom !== '' || $left !== '' ) {
|
||||
$output = $element .'{'. $top . $right . $bottom . $left .'}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->parent->output_css .= $output;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
70
framework/fields/spinner/spinner.php
Executable file
70
framework/fields/spinner/spinner.php
Executable file
|
@ -0,0 +1,70 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: spinner
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_spinner' ) ) {
|
||||
class WP_CHINA_YES_Field_spinner extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'max' => 100,
|
||||
'min' => 0,
|
||||
'step' => 1,
|
||||
'unit' => '',
|
||||
) );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<div class="wp_china_yes--spin"><input type="number" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes( array( 'class' => 'wp_china_yes-input-number' ) ) .' data-min="'. esc_attr( $args['min'] ) .'" data-max="'. esc_attr( $args['max'] ) .'" data-step="'. esc_attr( $args['step'] ) .'" data-unit="'. esc_attr( $args['unit'] ) .'" step="any" /></div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
if ( ! wp_script_is( 'jquery-ui-spinner' ) ) {
|
||||
wp_enqueue_script( 'jquery-ui-spinner' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function output() {
|
||||
|
||||
$output = '';
|
||||
$elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
|
||||
$important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
|
||||
$mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'width';
|
||||
$unit = ( ! empty( $this->field['unit'] ) ) ? $this->field['unit'] : 'px';
|
||||
|
||||
if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
|
||||
foreach ( $elements as $key_property => $element ) {
|
||||
if ( is_numeric( $key_property ) ) {
|
||||
if ( $mode ) {
|
||||
$output = implode( ',', $elements ) .'{'. $mode .':'. $this->value . $unit . $important .';}';
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
$output .= $element .'{'. $key_property .':'. $this->value . $unit . $important .'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->parent->output_css .= $output;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
24
framework/fields/subheading/subheading.php
Executable file
24
framework/fields/subheading/subheading.php
Executable file
|
@ -0,0 +1,24 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: subheading
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_subheading' ) ) {
|
||||
class WP_CHINA_YES_Field_subheading extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
echo ( ! empty( $this->field['content'] ) ) ? $this->field['content'] : '';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
26
framework/fields/submessage/submessage.php
Executable file
26
framework/fields/submessage/submessage.php
Executable file
|
@ -0,0 +1,26 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: submessage
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_submessage' ) ) {
|
||||
class WP_CHINA_YES_Field_submessage extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$style = ( ! empty( $this->field['style'] ) ) ? $this->field['style'] : 'normal';
|
||||
|
||||
echo '<div class="wp_china_yes-submessage wp_china_yes-submessage-'. esc_attr( $style ) .'">'. $this->field['content'] .'</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
40
framework/fields/switcher/switcher.php
Executable file
40
framework/fields/switcher/switcher.php
Executable file
|
@ -0,0 +1,40 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: switcher
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_switcher' ) ) {
|
||||
class WP_CHINA_YES_Field_switcher extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$active = ( ! empty( $this->value ) ) ? ' wp_china_yes--active' : '';
|
||||
$text_on = ( ! empty( $this->field['text_on'] ) ) ? $this->field['text_on'] : esc_html__( 'On', 'wp_china_yes' );
|
||||
$text_off = ( ! empty( $this->field['text_off'] ) ) ? $this->field['text_off'] : esc_html__( 'Off', 'wp_china_yes' );
|
||||
$text_width = ( ! empty( $this->field['text_width'] ) ) ? ' style="width: '. esc_attr( $this->field['text_width'] ) .'px;"': '';
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<div class="wp_china_yes--switcher'. esc_attr( $active ) .'"'. $text_width .'>';
|
||||
echo '<span class="wp_china_yes--on">'. esc_attr( $text_on ) .'</span>';
|
||||
echo '<span class="wp_china_yes--off">'. esc_attr( $text_off ) .'</span>';
|
||||
echo '<span class="wp_china_yes--ball"></span>';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes() .' />';
|
||||
echo '</div>';
|
||||
|
||||
echo ( ! empty( $this->field['label'] ) ) ? '<span class="wp_china_yes--label">'. esc_attr( $this->field['label'] ) . '</span>' : '';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
64
framework/fields/tabbed/tabbed.php
Executable file
64
framework/fields/tabbed/tabbed.php
Executable file
|
@ -0,0 +1,64 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: tabbed
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_tabbed' ) ) {
|
||||
class WP_CHINA_YES_Field_tabbed extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$unallows = array( 'tabbed' );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<div class="wp_china_yes-tabbed-nav" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
|
||||
foreach ( $this->field['tabs'] as $key => $tab ) {
|
||||
|
||||
$tabbed_icon = ( ! empty( $tab['icon'] ) ) ? '<i class="wp_china_yes--icon '. esc_attr( $tab['icon'] ) .'"></i>' : '';
|
||||
$tabbed_active = ( empty( $key ) ) ? 'wp_china_yes-tabbed-active' : '';
|
||||
|
||||
echo '<a href="#" class="'. esc_attr( $tabbed_active ) .'"">'. $tabbed_icon . esc_attr( $tab['title'] ) .'</a>';
|
||||
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="wp_china_yes-tabbed-contents">';
|
||||
foreach ( $this->field['tabs'] as $key => $tab ) {
|
||||
|
||||
$tabbed_hidden = ( ! empty( $key ) ) ? ' hidden' : '';
|
||||
|
||||
echo '<div class="wp_china_yes-tabbed-content'. esc_attr( $tabbed_hidden ) .'">';
|
||||
|
||||
foreach ( $tab['fields'] as $field ) {
|
||||
|
||||
if ( in_array( $field['type'], $unallows ) ) { $field['_notice'] = true; }
|
||||
|
||||
$field_id = ( isset( $field['id'] ) ) ? $field['id'] : '';
|
||||
$field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
|
||||
$field_value = ( isset( $this->value[$field_id] ) ) ? $this->value[$field_id] : $field_default;
|
||||
$unique_id = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']' : $this->field['id'];
|
||||
|
||||
WP_CHINA_YES::field( $field, $field_value, $unique_id, 'field/tabbed' );
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
30
framework/fields/text/text.php
Executable file
30
framework/fields/text/text.php
Executable file
|
@ -0,0 +1,30 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: text
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_text' ) ) {
|
||||
class WP_CHINA_YES_Field_text extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$type = ( ! empty( $this->field['attributes']['type'] ) ) ? $this->field['attributes']['type'] : 'text';
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo '<input type="'. esc_attr( $type ) .'" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes() .' />';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
58
framework/fields/textarea/textarea.php
Executable file
58
framework/fields/textarea/textarea.php
Executable file
|
@ -0,0 +1,58 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: textarea
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_textarea' ) ) {
|
||||
class WP_CHINA_YES_Field_textarea extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
echo $this->field_before();
|
||||
echo $this->shortcoder();
|
||||
echo '<textarea name="'. esc_attr( $this->field_name() ) .'"'. $this->field_attributes() .'>'. $this->value .'</textarea>';
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function shortcoder() {
|
||||
|
||||
if ( ! empty( $this->field['shortcoder'] ) ) {
|
||||
|
||||
$shortcodes = ( is_array( $this->field['shortcoder'] ) ) ? $this->field['shortcoder'] : array_filter( (array) $this->field['shortcoder'] );
|
||||
$instances = ( ! empty( WP_CHINA_YES::$shortcode_instances ) ) ? WP_CHINA_YES::$shortcode_instances : array();
|
||||
|
||||
if ( ! empty( $shortcodes ) && ! empty( $instances ) ) {
|
||||
|
||||
foreach ( $shortcodes as $shortcode ) {
|
||||
|
||||
foreach ( $instances as $instance ) {
|
||||
|
||||
if ( $instance['modal_id'] === $shortcode ) {
|
||||
|
||||
$id = $instance['modal_id'];
|
||||
$title = $instance['button_title'];
|
||||
|
||||
echo '<a href="#" class="button button-primary wp_china_yes-shortcode-button" data-modal-id="'. esc_attr( $id ) .'">'. esc_html( $title ) .'</a>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
1607
framework/fields/typography/google-fonts.php
Executable file
1607
framework/fields/typography/google-fonts.php
Executable file
File diff suppressed because it is too large
Load diff
544
framework/fields/typography/typography.php
Executable file
544
framework/fields/typography/typography.php
Executable file
|
@ -0,0 +1,544 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: typography
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_typography' ) ) {
|
||||
class WP_CHINA_YES_Field_typography extends WP_CHINA_YES_Fields {
|
||||
|
||||
public $chosen = false;
|
||||
|
||||
public $value = array();
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'font_family' => true,
|
||||
'font_weight' => true,
|
||||
'font_style' => true,
|
||||
'font_size' => true,
|
||||
'line_height' => true,
|
||||
'letter_spacing' => true,
|
||||
'text_align' => true,
|
||||
'text_transform' => true,
|
||||
'color' => true,
|
||||
'chosen' => true,
|
||||
'preview' => true,
|
||||
'subset' => true,
|
||||
'multi_subset' => false,
|
||||
'extra_styles' => false,
|
||||
'backup_font_family' => false,
|
||||
'font_variant' => false,
|
||||
'word_spacing' => false,
|
||||
'text_decoration' => false,
|
||||
'custom_style' => false,
|
||||
'compact' => false,
|
||||
'exclude' => '',
|
||||
'unit' => 'px',
|
||||
'line_height_unit' => '',
|
||||
'preview_text' => 'The quick brown fox jumps over the lazy dog',
|
||||
) );
|
||||
|
||||
if ( $args['compact'] ) {
|
||||
$args['text_transform'] = false;
|
||||
$args['text_align'] = false;
|
||||
$args['font_size'] = false;
|
||||
$args['line_height'] = false;
|
||||
$args['letter_spacing'] = false;
|
||||
$args['preview'] = false;
|
||||
$args['color'] = false;
|
||||
}
|
||||
|
||||
$default_value = array(
|
||||
'font-family' => '',
|
||||
'font-weight' => '',
|
||||
'font-style' => '',
|
||||
'font-variant' => '',
|
||||
'font-size' => '',
|
||||
'line-height' => '',
|
||||
'letter-spacing' => '',
|
||||
'word-spacing' => '',
|
||||
'text-align' => '',
|
||||
'text-transform' => '',
|
||||
'text-decoration' => '',
|
||||
'backup-font-family' => '',
|
||||
'color' => '',
|
||||
'custom-style' => '',
|
||||
'type' => '',
|
||||
'subset' => '',
|
||||
'extra-styles' => array(),
|
||||
);
|
||||
|
||||
$default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
|
||||
$this->value = wp_parse_args( $this->value, $default_value );
|
||||
$this->chosen = $args['chosen'];
|
||||
$chosen_class = ( $this->chosen ) ? ' wp_china_yes--chosen' : '';
|
||||
$line_height_unit = ( ! empty( $args['line_height_unit'] ) ) ? $args['line_height_unit'] : $args['unit'];
|
||||
|
||||
echo '<div class="wp_china_yes--typography'. esc_attr( $chosen_class ) .'" data-depend-id="'. esc_attr( $this->field['id'] ) .'" data-unit="'. esc_attr( $args['unit'] ) .'" data-line-height-unit="'. esc_attr( $line_height_unit ) .'" data-exclude="'. esc_attr( $args['exclude'] ) .'">';
|
||||
|
||||
echo '<div class="wp_china_yes--blocks wp_china_yes--blocks-selects">';
|
||||
|
||||
//
|
||||
// Font Family
|
||||
if ( ! empty( $args['font_family'] ) ) {
|
||||
echo '<div class="wp_china_yes--block">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Font Family', 'wp_china_yes' ) .'</div>';
|
||||
echo $this->create_select( array( $this->value['font-family'] => $this->value['font-family'] ), 'font-family', esc_html__( 'Select a font', 'wp_china_yes' ) );
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
//
|
||||
// Backup Font Family
|
||||
if ( ! empty( $args['backup_font_family'] ) ) {
|
||||
echo '<div class="wp_china_yes--block wp_china_yes--block-backup-font-family hidden">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Backup Font Family', 'wp_china_yes' ) .'</div>';
|
||||
echo $this->create_select( apply_filters( 'wp_china_yes_field_typography_backup_font_family', array(
|
||||
'Arial, Helvetica, sans-serif',
|
||||
"'Arial Black', Gadget, sans-serif",
|
||||
"'Comic Sans MS', cursive, sans-serif",
|
||||
'Impact, Charcoal, sans-serif',
|
||||
"'Lucida Sans Unicode', 'Lucida Grande', sans-serif",
|
||||
'Tahoma, Geneva, sans-serif',
|
||||
"'Trebuchet MS', Helvetica, sans-serif",
|
||||
'Verdana, Geneva, sans-serif',
|
||||
"'Courier New', Courier, monospace",
|
||||
"'Lucida Console', Monaco, monospace",
|
||||
'Georgia, serif',
|
||||
'Palatino Linotype'
|
||||
) ), 'backup-font-family', esc_html__( 'Default', 'wp_china_yes' ) );
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
//
|
||||
// Font Style and Extra Style Select
|
||||
if ( ! empty( $args['font_weight'] ) || ! empty( $args['font_style'] ) ) {
|
||||
|
||||
//
|
||||
// Font Style Select
|
||||
echo '<div class="wp_china_yes--block wp_china_yes--block-font-style hidden">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Font Style', 'wp_china_yes') .'</div>';
|
||||
echo '<select class="wp_china_yes--font-style-select" data-placeholder="Default">';
|
||||
echo '<option value="">'. ( ! $this->chosen ? esc_html__( 'Default', 'wp_china_yes' ) : '' ) .'</option>';
|
||||
if ( ! empty( $this->value['font-weight'] ) || ! empty( $this->value['font-style'] ) ) {
|
||||
echo '<option value="'. esc_attr( strtolower( $this->value['font-weight'] . $this->value['font-style'] ) ) .'" selected></option>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[font-weight]' ) ) .'" class="wp_china_yes--font-weight" value="'. esc_attr( $this->value['font-weight'] ) .'" />';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[font-style]' ) ) .'" class="wp_china_yes--font-style" value="'. esc_attr( $this->value['font-style'] ) .'" />';
|
||||
|
||||
//
|
||||
// Extra Font Style Select
|
||||
if ( ! empty( $args['extra_styles'] ) ) {
|
||||
echo '<div class="wp_china_yes--block-extra-styles hidden">';
|
||||
echo ( ! $this->chosen ) ? '<div class="wp_china_yes--title">'. esc_html__( 'Load Extra Styles', 'wp_china_yes' ) .'</div>' : '';
|
||||
$placeholder = ( $this->chosen ) ? esc_html__( 'Load Extra Styles', 'wp_china_yes' ) : esc_html__( 'Default', 'wp_china_yes' );
|
||||
echo $this->create_select( $this->value['extra-styles'], 'extra-styles', $placeholder, true );
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Subset
|
||||
if ( ! empty( $args['subset'] ) ) {
|
||||
echo '<div class="wp_china_yes--block wp_china_yes--block-subset hidden">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Subset', 'wp_china_yes' ) .'</div>';
|
||||
$subset = ( is_array( $this->value['subset'] ) ) ? $this->value['subset'] : array_filter( (array) $this->value['subset'] );
|
||||
echo $this->create_select( $subset, 'subset', esc_html__( 'Default', 'wp_china_yes' ), $args['multi_subset'] );
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
//
|
||||
// Text Align
|
||||
if ( ! empty( $args['text_align'] ) ) {
|
||||
echo '<div class="wp_china_yes--block">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Text Align', 'wp_china_yes' ) .'</div>';
|
||||
echo $this->create_select( array(
|
||||
'inherit' => esc_html__( 'Inherit', 'wp_china_yes' ),
|
||||
'left' => esc_html__( 'Left', 'wp_china_yes' ),
|
||||
'center' => esc_html__( 'Center', 'wp_china_yes' ),
|
||||
'right' => esc_html__( 'Right', 'wp_china_yes' ),
|
||||
'justify' => esc_html__( 'Justify', 'wp_china_yes' ),
|
||||
'initial' => esc_html__( 'Initial', 'wp_china_yes' )
|
||||
), 'text-align', esc_html__( 'Default', 'wp_china_yes' ) );
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
//
|
||||
// Font Variant
|
||||
if ( ! empty( $args['font_variant'] ) ) {
|
||||
echo '<div class="wp_china_yes--block">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Font Variant', 'wp_china_yes' ) .'</div>';
|
||||
echo $this->create_select( array(
|
||||
'normal' => esc_html__( 'Normal', 'wp_china_yes' ),
|
||||
'small-caps' => esc_html__( 'Small Caps', 'wp_china_yes' ),
|
||||
'all-small-caps' => esc_html__( 'All Small Caps', 'wp_china_yes' )
|
||||
), 'font-variant', esc_html__( 'Default', 'wp_china_yes' ) );
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
//
|
||||
// Text Transform
|
||||
if ( ! empty( $args['text_transform'] ) ) {
|
||||
echo '<div class="wp_china_yes--block">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Text Transform', 'wp_china_yes' ) .'</div>';
|
||||
echo $this->create_select( array(
|
||||
'none' => esc_html__( 'None', 'wp_china_yes' ),
|
||||
'capitalize' => esc_html__( 'Capitalize', 'wp_china_yes' ),
|
||||
'uppercase' => esc_html__( 'Uppercase', 'wp_china_yes' ),
|
||||
'lowercase' => esc_html__( 'Lowercase', 'wp_china_yes' )
|
||||
), 'text-transform', esc_html__( 'Default', 'wp_china_yes' ) );
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
//
|
||||
// Text Decoration
|
||||
if ( ! empty( $args['text_decoration'] ) ) {
|
||||
echo '<div class="wp_china_yes--block">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Text Decoration', 'wp_china_yes' ) .'</div>';
|
||||
echo $this->create_select( array(
|
||||
'none' => esc_html__( 'None', 'wp_china_yes' ),
|
||||
'underline' => esc_html__( 'Solid', 'wp_china_yes' ),
|
||||
'underline double' => esc_html__( 'Double', 'wp_china_yes' ),
|
||||
'underline dotted' => esc_html__( 'Dotted', 'wp_china_yes' ),
|
||||
'underline dashed' => esc_html__( 'Dashed', 'wp_china_yes' ),
|
||||
'underline wavy' => esc_html__( 'Wavy', 'wp_china_yes' ),
|
||||
'underline overline' => esc_html__( 'Overline', 'wp_china_yes' ),
|
||||
'line-through' => esc_html__( 'Line-through', 'wp_china_yes' )
|
||||
), 'text-decoration', esc_html__( 'Default', 'wp_china_yes' ) );
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="wp_china_yes--blocks wp_china_yes--blocks-inputs">';
|
||||
|
||||
//
|
||||
// Font Size
|
||||
if ( ! empty( $args['font_size'] ) ) {
|
||||
echo '<div class="wp_china_yes--block">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Font Size', 'wp_china_yes' ) .'</div>';
|
||||
echo '<div class="wp_china_yes--input-wrap">';
|
||||
echo '<input type="number" name="'. esc_attr( $this->field_name( '[font-size]' ) ) .'" class="wp_china_yes--font-size wp_china_yes--input wp_china_yes-input-number" value="'. esc_attr( $this->value['font-size'] ) .'" step="any" />';
|
||||
echo '<span class="wp_china_yes--unit">'. esc_attr( $args['unit'] ) .'</span>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
//
|
||||
// Line Height
|
||||
if ( ! empty( $args['line_height'] ) ) {
|
||||
echo '<div class="wp_china_yes--block">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Line Height', 'wp_china_yes' ) .'</div>';
|
||||
echo '<div class="wp_china_yes--input-wrap">';
|
||||
echo '<input type="number" name="'. esc_attr( $this->field_name( '[line-height]' ) ) .'" class="wp_china_yes--line-height wp_china_yes--input wp_china_yes-input-number" value="'. esc_attr( $this->value['line-height'] ) .'" step="any" />';
|
||||
echo '<span class="wp_china_yes--unit">'. esc_attr( $line_height_unit ) .'</span>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
//
|
||||
// Letter Spacing
|
||||
if ( ! empty( $args['letter_spacing'] ) ) {
|
||||
echo '<div class="wp_china_yes--block">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Letter Spacing', 'wp_china_yes' ) .'</div>';
|
||||
echo '<div class="wp_china_yes--input-wrap">';
|
||||
echo '<input type="number" name="'. esc_attr( $this->field_name( '[letter-spacing]' ) ) .'" class="wp_china_yes--letter-spacing wp_china_yes--input wp_china_yes-input-number" value="'. esc_attr( $this->value['letter-spacing'] ) .'" step="any" />';
|
||||
echo '<span class="wp_china_yes--unit">'. esc_attr( $args['unit'] ) .'</span>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
//
|
||||
// Word Spacing
|
||||
if ( ! empty( $args['word_spacing'] ) ) {
|
||||
echo '<div class="wp_china_yes--block">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Word Spacing', 'wp_china_yes' ) .'</div>';
|
||||
echo '<div class="wp_china_yes--input-wrap">';
|
||||
echo '<input type="number" name="'. esc_attr( $this->field_name( '[word-spacing]' ) ) .'" class="wp_china_yes--word-spacing wp_china_yes--input wp_china_yes-input-number" value="'. esc_attr( $this->value['word-spacing'] ) .'" step="any" />';
|
||||
echo '<span class="wp_china_yes--unit">'. esc_attr( $args['unit'] ) .'</span>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
//
|
||||
// Font Color
|
||||
if ( ! empty( $args['color'] ) ) {
|
||||
$default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="'. esc_attr( $default_value['color'] ) .'"' : '';
|
||||
echo '<div class="wp_china_yes--block wp_china_yes--block-font-color">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Font Color', 'wp_china_yes' ) .'</div>';
|
||||
echo '<div class="wp_china_yes-field-color">';
|
||||
echo '<input type="text" name="'. esc_attr( $this->field_name( '[color]' ) ) .'" class="wp_china_yes-color wp_china_yes--color" value="'. esc_attr( $this->value['color'] ) .'"'. $default_color_attr .' />';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
//
|
||||
// Custom style
|
||||
if ( ! empty( $args['custom_style'] ) ) {
|
||||
echo '<div class="wp_china_yes--block wp_china_yes--block-custom-style">';
|
||||
echo '<div class="wp_china_yes--title">'. esc_html__( 'Custom Style', 'wp_china_yes' ) .'</div>';
|
||||
echo '<textarea name="'. esc_attr( $this->field_name( '[custom-style]' ) ) .'" class="wp_china_yes--custom-style">'. esc_attr( $this->value['custom-style'] ) .'</textarea>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
//
|
||||
// Preview
|
||||
$always_preview = ( $args['preview'] !== 'always' ) ? ' hidden' : '';
|
||||
|
||||
if ( ! empty( $args['preview'] ) ) {
|
||||
echo '<div class="wp_china_yes--block wp_china_yes--block-preview'. esc_attr( $always_preview ) .'">';
|
||||
echo '<div class="wp_china_yes--toggle fas fa-toggle-off"></div>';
|
||||
echo '<div class="wp_china_yes--preview">'. esc_attr( $args['preview_text'] ) .'</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[type]' ) ) .'" class="wp_china_yes--type" value="'. esc_attr( $this->value['type'] ) .'" />';
|
||||
echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[unit]' ) ) .'" class="wp_china_yes--unit-save" value="'. esc_attr( $args['unit'] ) .'" />';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function create_select( $options, $name, $placeholder = '', $is_multiple = false ) {
|
||||
|
||||
$multiple_name = ( $is_multiple ) ? '[]' : '';
|
||||
$multiple_attr = ( $is_multiple ) ? ' multiple data-multiple="true"' : '';
|
||||
$chosen_rtl = ( $this->chosen && is_rtl() ) ? ' chosen-rtl' : '';
|
||||
|
||||
$output = '<select name="'. esc_attr( $this->field_name( '['. $name .']'. $multiple_name ) ) .'" class="wp_china_yes--'. esc_attr( $name ) . esc_attr( $chosen_rtl ) .'" data-placeholder="'. esc_attr( $placeholder ) .'"'. $multiple_attr .'>';
|
||||
$output .= ( ! empty( $placeholder ) ) ? '<option value="">'. esc_attr( ( ! $this->chosen ) ? $placeholder : '' ) .'</option>' : '';
|
||||
|
||||
if ( ! empty( $options ) ) {
|
||||
foreach ( $options as $option_key => $option_value ) {
|
||||
if ( $is_multiple ) {
|
||||
$selected = ( in_array( $option_value, $this->value[$name] ) ) ? ' selected' : '';
|
||||
$output .= '<option value="'. esc_attr( $option_value ) .'"'. esc_attr( $selected ).'>'. esc_attr( $option_value ) .'</option>';
|
||||
} else {
|
||||
$option_key = ( is_numeric( $option_key ) ) ? $option_value : $option_key;
|
||||
$selected = ( $option_key === $this->value[$name] ) ? ' selected' : '';
|
||||
$output .= '<option value="'. esc_attr( $option_key ) .'"'. esc_attr( $selected ).'>'. esc_attr( $option_value ) .'</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output .= '</select>';
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
if ( ! wp_script_is( 'wp_china_yes-webfontloader' ) ) {
|
||||
|
||||
WP_CHINA_YES::include_plugin_file( 'fields/typography/google-fonts.php' );
|
||||
|
||||
wp_enqueue_script( 'wp_china_yes-webfontloader', 'https://jsd.admincdn.com/npm/webfontloader@1.6.28/webfontloader.min.js', array( 'wp_china_yes' ), '1.6.28', true );
|
||||
|
||||
$webfonts = array();
|
||||
|
||||
$customwebfonts = apply_filters( 'wp_china_yes_field_typography_customwebfonts', array() );
|
||||
|
||||
if ( ! empty( $customwebfonts ) ) {
|
||||
$webfonts['custom'] = array(
|
||||
'label' => esc_html__( 'Custom Web Fonts', 'wp_china_yes' ),
|
||||
'fonts' => $customwebfonts
|
||||
);
|
||||
}
|
||||
|
||||
$webfonts['safe'] = array(
|
||||
'label' => esc_html__( 'Safe Web Fonts', 'wp_china_yes' ),
|
||||
'fonts' => apply_filters( 'wp_china_yes_field_typography_safewebfonts', array(
|
||||
'Arial',
|
||||
'Arial Black',
|
||||
'Helvetica',
|
||||
'Times New Roman',
|
||||
'Courier New',
|
||||
'Tahoma',
|
||||
'Verdana',
|
||||
'Impact',
|
||||
'Trebuchet MS',
|
||||
'Comic Sans MS',
|
||||
'Lucida Console',
|
||||
'Lucida Sans Unicode',
|
||||
'Georgia, serif',
|
||||
'Palatino Linotype'
|
||||
)
|
||||
) );
|
||||
|
||||
$webfonts['google'] = array(
|
||||
'label' => esc_html__( 'Google Web Fonts', 'wp_china_yes' ),
|
||||
'fonts' => apply_filters( 'wp_china_yes_field_typography_googlewebfonts', wp_china_yes_get_google_fonts()
|
||||
) );
|
||||
|
||||
$defaultstyles = apply_filters( 'wp_china_yes_field_typography_defaultstyles', array( 'normal', 'italic', '700', '700italic' ) );
|
||||
|
||||
$googlestyles = apply_filters( 'wp_china_yes_field_typography_googlestyles', array(
|
||||
'100' => 'Thin 100',
|
||||
'100italic' => 'Thin 100 Italic',
|
||||
'200' => 'Extra-Light 200',
|
||||
'200italic' => 'Extra-Light 200 Italic',
|
||||
'300' => 'Light 300',
|
||||
'300italic' => 'Light 300 Italic',
|
||||
'normal' => 'Normal 400',
|
||||
'italic' => 'Normal 400 Italic',
|
||||
'500' => 'Medium 500',
|
||||
'500italic' => 'Medium 500 Italic',
|
||||
'600' => 'Semi-Bold 600',
|
||||
'600italic' => 'Semi-Bold 600 Italic',
|
||||
'700' => 'Bold 700',
|
||||
'700italic' => 'Bold 700 Italic',
|
||||
'800' => 'Extra-Bold 800',
|
||||
'800italic' => 'Extra-Bold 800 Italic',
|
||||
'900' => 'Black 900',
|
||||
'900italic' => 'Black 900 Italic'
|
||||
) );
|
||||
|
||||
$webfonts = apply_filters( 'wp_china_yes_field_typography_webfonts', $webfonts );
|
||||
|
||||
wp_localize_script( 'wp_china_yes', 'wp_china_yes_typography_json', array(
|
||||
'webfonts' => $webfonts,
|
||||
'defaultstyles' => $defaultstyles,
|
||||
'googlestyles' => $googlestyles
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function enqueue_google_fonts( $method = 'enqueue' ) {
|
||||
|
||||
$is_google = false;
|
||||
|
||||
if ( ! empty( $this->value['type'] ) ) {
|
||||
$is_google = ( $this->value['type'] === 'google' ) ? true : false;
|
||||
} else {
|
||||
WP_CHINA_YES::include_plugin_file( 'fields/typography/google-fonts.php' );
|
||||
$is_google = ( array_key_exists( $this->value['font-family'], wp_china_yes_get_google_fonts() ) ) ? true : false;
|
||||
}
|
||||
|
||||
if ( $is_google ) {
|
||||
|
||||
// set style
|
||||
$font_family = ( ! empty( $this->value['font-family'] ) ) ? $this->value['font-family'] : '';
|
||||
$font_weight = ( ! empty( $this->value['font-weight'] ) ) ? $this->value['font-weight'] : '';
|
||||
$font_style = ( ! empty( $this->value['font-style'] ) ) ? $this->value['font-style'] : '';
|
||||
|
||||
if ( $font_weight || $font_style ) {
|
||||
$style = $font_weight . $font_style;
|
||||
if ( ! empty( $style ) ) {
|
||||
$style = ( $style === 'normal' ) ? '400' : $style;
|
||||
WP_CHINA_YES::$webfonts[$method][$font_family][$style] = $style;
|
||||
}
|
||||
} else {
|
||||
WP_CHINA_YES::$webfonts[$method][$font_family] = array();
|
||||
}
|
||||
|
||||
// set extra styles
|
||||
if ( ! empty( $this->value['extra-styles'] ) ) {
|
||||
foreach ( $this->value['extra-styles'] as $extra_style ) {
|
||||
if ( ! empty( $extra_style ) ) {
|
||||
$extra_style = ( $extra_style === 'normal' ) ? '400' : $extra_style;
|
||||
WP_CHINA_YES::$webfonts[$method][$font_family][$extra_style] = $extra_style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set subsets
|
||||
if ( ! empty( $this->value['subset'] ) ) {
|
||||
$this->value['subset'] = ( is_array( $this->value['subset'] ) ) ? $this->value['subset'] : array_filter( (array) $this->value['subset'] );
|
||||
foreach ( $this->value['subset'] as $subset ) {
|
||||
if( ! empty( $subset ) ) {
|
||||
WP_CHINA_YES::$subsets[$subset] = $subset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public function output() {
|
||||
|
||||
$output = '';
|
||||
$bg_image = array();
|
||||
$important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
|
||||
$element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
|
||||
|
||||
$font_family = ( ! empty( $this->value['font-family'] ) ) ? $this->value['font-family'] : '';
|
||||
$backup_family = ( ! empty( $this->value['backup-font-family'] ) ) ? ', '. $this->value['backup-font-family'] : '';
|
||||
|
||||
if ( $font_family ) {
|
||||
$output .= 'font-family:"'. $font_family .'"'. $backup_family . $important .';';
|
||||
}
|
||||
|
||||
// Common font properties
|
||||
$properties = array(
|
||||
'color',
|
||||
'font-weight',
|
||||
'font-style',
|
||||
'font-variant',
|
||||
'text-align',
|
||||
'text-transform',
|
||||
'text-decoration',
|
||||
);
|
||||
|
||||
foreach ( $properties as $property ) {
|
||||
if ( isset( $this->value[$property] ) && $this->value[$property] !== '' ) {
|
||||
$output .= $property .':'. $this->value[$property] . $important .';';
|
||||
}
|
||||
}
|
||||
|
||||
$properties = array(
|
||||
'font-size',
|
||||
'line-height',
|
||||
'letter-spacing',
|
||||
'word-spacing',
|
||||
);
|
||||
|
||||
$unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
|
||||
$line_height_unit = ( ! empty( $this->value['line_height_unit'] ) ) ? $this->value['line_height_unit'] : $unit;
|
||||
|
||||
foreach ( $properties as $property ) {
|
||||
if ( isset( $this->value[$property] ) && $this->value[$property] !== '' ) {
|
||||
$unit = ( $property === 'line-height' ) ? $line_height_unit : $unit;
|
||||
$output .= $property .':'. $this->value[$property] . $unit . $important .';';
|
||||
}
|
||||
}
|
||||
|
||||
$custom_style = ( ! empty( $this->value['custom-style'] ) ) ? $this->value['custom-style'] : '';
|
||||
|
||||
if ( $output ) {
|
||||
$output = $element .'{'. $output . $custom_style .'}';
|
||||
}
|
||||
|
||||
$this->parent->output_css .= $output;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
61
framework/fields/upload/upload.php
Executable file
61
framework/fields/upload/upload.php
Executable file
|
@ -0,0 +1,61 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: upload
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_upload' ) ) {
|
||||
class WP_CHINA_YES_Field_upload extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'library' => array(),
|
||||
'preview' => false,
|
||||
'preview_width' => '',
|
||||
'preview_height' => '',
|
||||
'button_title' => esc_html__( 'Upload', 'wp_china_yes' ),
|
||||
'remove_title' => esc_html__( 'Remove', 'wp_china_yes' ),
|
||||
) );
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
$library = ( is_array( $args['library'] ) ) ? $args['library'] : array_filter( (array) $args['library'] );
|
||||
$library = ( ! empty( $library ) ) ? implode(',', $library ) : '';
|
||||
$hidden = ( empty( $this->value ) ) ? ' hidden' : '';
|
||||
|
||||
if ( ! empty( $args['preview'] ) ) {
|
||||
|
||||
$preview_type = ( ! empty( $this->value ) ) ? strtolower( substr( strrchr( $this->value, '.' ), 1 ) ) : '';
|
||||
$preview_src = ( ! empty( $preview_type ) && in_array( $preview_type, array( 'jpg', 'jpeg', 'gif', 'png', 'svg', 'webp' ) ) ) ? $this->value : '';
|
||||
$preview_width = ( ! empty( $args['preview_width'] ) ) ? 'max-width:'. esc_attr( $args['preview_width'] ) .'px;' : '';
|
||||
$preview_height = ( ! empty( $args['preview_height'] ) ) ? 'max-height:'. esc_attr( $args['preview_height'] ) .'px;' : '';
|
||||
$preview_style = ( ! empty( $preview_width ) || ! empty( $preview_height ) ) ? ' style="'. esc_attr( $preview_width . $preview_height ) .'"': '';
|
||||
$preview_hidden = ( empty( $preview_src ) ) ? ' hidden' : '';
|
||||
|
||||
echo '<div class="wp_china_yes--preview'. esc_attr( $preview_hidden ) .'">';
|
||||
echo '<div class="wp_china_yes-image-preview"'. $preview_style .'>';
|
||||
echo '<i class="wp_china_yes--remove fas fa-times"></i><span><img src="'. esc_url( $preview_src ) .'" class="wp_china_yes--src" /></span>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo '<div class="wp_china_yes--wrap">';
|
||||
echo '<input type="text" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes() .'/>';
|
||||
echo '<a href="#" class="button button-primary wp_china_yes--button" data-library="'. esc_attr( $library ) .'">'. $args['button_title'] .'</a>';
|
||||
echo '<a href="#" class="button button-secondary wp_china_yes-warning-primary wp_china_yes--remove'. esc_attr( $hidden ) .'">'. $args['remove_title'] .'</a>';
|
||||
echo '</div>';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
107
framework/fields/wp_editor/wp_editor.php
Executable file
107
framework/fields/wp_editor/wp_editor.php
Executable file
|
@ -0,0 +1,107 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Field: wp_editor
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Field_wp_editor' ) ) {
|
||||
class WP_CHINA_YES_Field_wp_editor extends WP_CHINA_YES_Fields {
|
||||
|
||||
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
|
||||
parent::__construct( $field, $value, $unique, $where, $parent );
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$args = wp_parse_args( $this->field, array(
|
||||
'tinymce' => true,
|
||||
'quicktags' => true,
|
||||
'media_buttons' => true,
|
||||
'wpautop' => false,
|
||||
'height' => '',
|
||||
) );
|
||||
|
||||
$attributes = array(
|
||||
'rows' => 10,
|
||||
'class' => 'wp-editor-area',
|
||||
'autocomplete' => 'off',
|
||||
);
|
||||
|
||||
$editor_height = ( ! empty( $args['height'] ) ) ? ' style="height:'. esc_attr( $args['height'] ) .';"' : '';
|
||||
|
||||
$editor_settings = array(
|
||||
'tinymce' => $args['tinymce'],
|
||||
'quicktags' => $args['quicktags'],
|
||||
'media_buttons' => $args['media_buttons'],
|
||||
'wpautop' => $args['wpautop'],
|
||||
);
|
||||
|
||||
echo $this->field_before();
|
||||
|
||||
echo ( wp_china_yes_wp_editor_api() ) ? '<div class="wp_china_yes-wp-editor" data-editor-settings="'. esc_attr( json_encode( $editor_settings ) ) .'">' : '';
|
||||
|
||||
echo '<textarea name="'. esc_attr( $this->field_name() ) .'"'. $this->field_attributes( $attributes ) . $editor_height .'>'. $this->value .'</textarea>';
|
||||
|
||||
echo ( wp_china_yes_wp_editor_api() ) ? '</div>' : '';
|
||||
|
||||
echo $this->field_after();
|
||||
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
|
||||
if ( wp_china_yes_wp_editor_api() && function_exists( 'wp_enqueue_editor' ) ) {
|
||||
|
||||
wp_enqueue_editor();
|
||||
|
||||
$this->setup_wp_editor_settings();
|
||||
|
||||
add_action( 'print_default_editor_scripts', array( $this, 'setup_wp_editor_media_buttons' ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Setup wp editor media buttons
|
||||
public function setup_wp_editor_media_buttons() {
|
||||
|
||||
if ( ! function_exists( 'media_buttons' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
echo '<div class="wp-media-buttons">';
|
||||
do_action( 'media_buttons' );
|
||||
echo '</div>';
|
||||
$media_buttons = ob_get_clean();
|
||||
|
||||
echo '<script type="text/javascript">';
|
||||
echo 'var wp_china_yes_media_buttons = '. json_encode( $media_buttons ) .';';
|
||||
echo '</script>';
|
||||
|
||||
}
|
||||
|
||||
// Setup wp editor settings
|
||||
public function setup_wp_editor_settings() {
|
||||
|
||||
if ( wp_china_yes_wp_editor_api() && class_exists( '_WP_Editors') ) {
|
||||
|
||||
$defaults = apply_filters( 'wp_china_yes_wp_editor', array(
|
||||
'tinymce' => array(
|
||||
'wp_skip_init' => true
|
||||
),
|
||||
) );
|
||||
|
||||
$setup = _WP_Editors::parse_settings( 'wp_china_yes_wp_editor', $defaults );
|
||||
|
||||
_WP_Editors::editor_settings( 'wp_china_yes_wp_editor', $setup );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
190
framework/functions/actions.php
Executable file
190
framework/functions/actions.php
Executable file
|
@ -0,0 +1,190 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Get icons from admin ajax
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_get_icons' ) ) {
|
||||
function wp_china_yes_get_icons() {
|
||||
|
||||
$nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
|
||||
|
||||
if ( ! wp_verify_nonce( $nonce, 'wp_china_yes_icon_nonce' ) ) {
|
||||
wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'wp_china_yes' ) ) );
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
$icon_library = ( apply_filters( 'wp_china_yes_fa4', false ) ) ? 'fa4' : 'fa5';
|
||||
|
||||
WP_CHINA_YES::include_plugin_file( 'fields/icon/'. $icon_library .'-icons.php' );
|
||||
|
||||
$icon_lists = apply_filters( 'wp_china_yes_field_icon_add_icons', wp_china_yes_get_default_icons() );
|
||||
|
||||
if ( ! empty( $icon_lists ) ) {
|
||||
|
||||
foreach ( $icon_lists as $list ) {
|
||||
|
||||
echo ( count( $icon_lists ) >= 2 ) ? '<div class="wp_china_yes-icon-title">'. esc_attr( $list['title'] ) .'</div>' : '';
|
||||
|
||||
foreach ( $list['icons'] as $icon ) {
|
||||
echo '<i title="'. esc_attr( $icon ) .'" class="'. esc_attr( $icon ) .'"></i>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
echo '<div class="wp_china_yes-error-text">'. esc_html__( 'No data available.', 'wp_china_yes' ) .'</div>';
|
||||
|
||||
}
|
||||
|
||||
$content = ob_get_clean();
|
||||
|
||||
wp_send_json_success( array( 'content' => $content ) );
|
||||
|
||||
}
|
||||
add_action( 'wp_ajax_wp_china_yes-get-icons', 'wp_china_yes_get_icons' );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Export
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_export' ) ) {
|
||||
function wp_china_yes_export() {
|
||||
|
||||
$nonce = ( ! empty( $_GET[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'nonce' ] ) ) : '';
|
||||
$unique = ( ! empty( $_GET[ 'unique' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'unique' ] ) ) : '';
|
||||
|
||||
if ( ! wp_verify_nonce( $nonce, 'wp_china_yes_backup_nonce' ) ) {
|
||||
die( esc_html__( 'Error: Invalid nonce verification.', 'wp_china_yes' ) );
|
||||
}
|
||||
|
||||
if ( empty( $unique ) ) {
|
||||
die( esc_html__( 'Error: Invalid key.', 'wp_china_yes' ) );
|
||||
}
|
||||
|
||||
// Export
|
||||
header('Content-Type: application/json');
|
||||
header('Content-disposition: attachment; filename=backup-'. gmdate( 'd-m-Y' ) .'.json');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Pragma: no-cache');
|
||||
header('Expires: 0');
|
||||
|
||||
echo json_encode( get_option( $unique ) );
|
||||
|
||||
die();
|
||||
|
||||
}
|
||||
add_action( 'wp_ajax_wp_china_yes-export', 'wp_china_yes_export' );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Import Ajax
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_import_ajax' ) ) {
|
||||
function wp_china_yes_import_ajax() {
|
||||
|
||||
$nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
|
||||
$unique = ( ! empty( $_POST[ 'unique' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'unique' ] ) ) : '';
|
||||
$data = ( ! empty( $_POST[ 'data' ] ) ) ? wp_kses_post_deep( json_decode( wp_unslash( trim( $_POST[ 'data' ] ) ), true ) ) : array();
|
||||
|
||||
if ( ! wp_verify_nonce( $nonce, 'wp_china_yes_backup_nonce' ) ) {
|
||||
wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'wp_china_yes' ) ) );
|
||||
}
|
||||
|
||||
if ( empty( $unique ) ) {
|
||||
wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid key.', 'wp_china_yes' ) ) );
|
||||
}
|
||||
|
||||
if ( empty( $data ) || ! is_array( $data ) ) {
|
||||
wp_send_json_error( array( 'error' => esc_html__( 'Error: The response is not a valid JSON response.', 'wp_china_yes' ) ) );
|
||||
}
|
||||
|
||||
// Success
|
||||
update_option( $unique, $data, true );
|
||||
|
||||
wp_send_json_success();
|
||||
|
||||
}
|
||||
add_action( 'wp_ajax_wp_china_yes-import', 'wp_china_yes_import_ajax' );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Reset Ajax
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_reset_ajax' ) ) {
|
||||
function wp_china_yes_reset_ajax() {
|
||||
|
||||
$nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
|
||||
$unique = ( ! empty( $_POST[ 'unique' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'unique' ] ) ) : '';
|
||||
|
||||
if ( ! wp_verify_nonce( $nonce, 'wp_china_yes_backup_nonce' ) ) {
|
||||
wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'wp_china_yes' ) ) );
|
||||
}
|
||||
|
||||
// Success
|
||||
delete_option( $unique );
|
||||
|
||||
wp_send_json_success();
|
||||
|
||||
}
|
||||
add_action( 'wp_ajax_wp_china_yes-reset', 'wp_china_yes_reset_ajax' );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Chosen Ajax
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_chosen_ajax' ) ) {
|
||||
function wp_china_yes_chosen_ajax() {
|
||||
|
||||
$nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
|
||||
$type = ( ! empty( $_POST[ 'type' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'type' ] ) ) : '';
|
||||
$term = ( ! empty( $_POST[ 'term' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'term' ] ) ) : '';
|
||||
$query = ( ! empty( $_POST[ 'query_args' ] ) ) ? wp_kses_post_deep( $_POST[ 'query_args' ] ) : array();
|
||||
|
||||
if ( ! wp_verify_nonce( $nonce, 'wp_china_yes_chosen_ajax_nonce' ) ) {
|
||||
wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'wp_china_yes' ) ) );
|
||||
}
|
||||
|
||||
if ( empty( $type ) || empty( $term ) ) {
|
||||
wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid term ID.', 'wp_china_yes' ) ) );
|
||||
}
|
||||
|
||||
$capability = apply_filters( 'wp_china_yes_chosen_ajax_capability', 'manage_options' );
|
||||
|
||||
if ( ! current_user_can( $capability ) ) {
|
||||
wp_send_json_error( array( 'error' => esc_html__( 'Error: You do not have permission to do that.', 'wp_china_yes' ) ) );
|
||||
}
|
||||
|
||||
// Success
|
||||
$options = WP_CHINA_YES_Fields::field_data( $type, $term, $query );
|
||||
|
||||
wp_send_json_success( $options );
|
||||
|
||||
}
|
||||
add_action( 'wp_ajax_wp_china_yes-chosen', 'wp_china_yes_chosen_ajax' );
|
||||
}
|
142
framework/functions/customize.php
Executable file
142
framework/functions/customize.php
Executable file
|
@ -0,0 +1,142 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* WP Customize custom panel
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_Customize_Panel_WP_CHINA_YES' ) && class_exists( 'WP_Customize_Panel' ) ) {
|
||||
class WP_Customize_Panel_WP_CHINA_YES extends WP_Customize_Panel {
|
||||
public $type = 'wp_china_yes';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* WP Customize custom section
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_Customize_Section_WP_CHINA_YES' ) && class_exists( 'WP_Customize_Section' ) ) {
|
||||
class WP_Customize_Section_WP_CHINA_YES extends WP_Customize_Section {
|
||||
public $type = 'wp_china_yes';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* WP Customize custom control
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_Customize_Control_WP_CHINA_YES' ) && class_exists( 'WP_Customize_Control' ) ) {
|
||||
class WP_Customize_Control_WP_CHINA_YES extends WP_Customize_Control {
|
||||
|
||||
public $type = 'wp_china_yes';
|
||||
public $field = '';
|
||||
public $unique = '';
|
||||
|
||||
public function render() {
|
||||
|
||||
$depend = '';
|
||||
$visible = '';
|
||||
|
||||
if ( ! empty( $this->field['dependency'] ) ) {
|
||||
|
||||
$dependency = $this->field['dependency'];
|
||||
$depend_visible = '';
|
||||
$data_controller = '';
|
||||
$data_condition = '';
|
||||
$data_value = '';
|
||||
$data_global = '';
|
||||
|
||||
if ( is_array( $dependency[0] ) ) {
|
||||
$data_controller = implode( '|', array_column( $dependency, 0 ) );
|
||||
$data_condition = implode( '|', array_column( $dependency, 1 ) );
|
||||
$data_value = implode( '|', array_column( $dependency, 2 ) );
|
||||
$data_global = implode( '|', array_column( $dependency, 3 ) );
|
||||
$depend_visible = implode( '|', array_column( $dependency, 4 ) );
|
||||
} else {
|
||||
$data_controller = ( ! empty( $dependency[0] ) ) ? $dependency[0] : '';
|
||||
$data_condition = ( ! empty( $dependency[1] ) ) ? $dependency[1] : '';
|
||||
$data_value = ( ! empty( $dependency[2] ) ) ? $dependency[2] : '';
|
||||
$data_global = ( ! empty( $dependency[3] ) ) ? $dependency[3] : '';
|
||||
$depend_visible = ( ! empty( $dependency[4] ) ) ? $dependency[4] : '';
|
||||
}
|
||||
|
||||
$depend .= ' data-controller="'. esc_attr( $data_controller ) .'"';
|
||||
$depend .= ' data-condition="'. esc_attr( $data_condition ) .'"';
|
||||
$depend .= ' data-value="'. esc_attr( $data_value ) .'"';
|
||||
$depend .= ( ! empty( $data_global ) ) ? ' data-depend-global="true"' : '';
|
||||
|
||||
$visible = ' wp_china_yes-dependency-control';
|
||||
$visible .= ( ! empty( $depend_visible ) ) ? ' wp_china_yes-depend-visible' : ' wp_china_yes-depend-hidden';
|
||||
|
||||
}
|
||||
|
||||
$id = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id );
|
||||
$class = 'customize-control customize-control-'. $this->type . $visible;
|
||||
|
||||
echo '<li id="'. esc_attr( $id ) .'" class="'. esc_attr( $class ) .'"'. $depend .'>';
|
||||
$this->render_field_content();
|
||||
echo '</li>';
|
||||
|
||||
}
|
||||
|
||||
public function render_field_content() {
|
||||
|
||||
$complex = apply_filters( 'wp_china_yes_customize_complex_fields', array(
|
||||
'accordion',
|
||||
'background',
|
||||
'border',
|
||||
'button_set',
|
||||
'checkbox',
|
||||
'color_group',
|
||||
'date',
|
||||
'dimensions',
|
||||
'fieldset',
|
||||
'group',
|
||||
'image_select',
|
||||
'link',
|
||||
'link_color',
|
||||
'media',
|
||||
'palette',
|
||||
'repeater',
|
||||
'sortable',
|
||||
'sorter',
|
||||
'spacing',
|
||||
'switcher',
|
||||
'tabbed',
|
||||
'typography'
|
||||
) );
|
||||
|
||||
$field_id = ( ! empty( $this->field['id'] ) ) ? $this->field['id'] : '';
|
||||
$custom = ( ! empty( $this->field['customizer'] ) ) ? true : false;
|
||||
$is_complex = ( in_array( $this->field['type'], $complex ) ) ? true : false;
|
||||
$class = ( $is_complex || $custom ) ? ' wp_china_yes-customize-complex' : '';
|
||||
$atts = ( $is_complex || $custom ) ? ' data-unique-id="'. esc_attr( $this->unique ) .'" data-option-id="'. esc_attr( $field_id ) .'"' : '';
|
||||
|
||||
if ( ! $is_complex && ! $custom ) {
|
||||
$this->field['attributes']['data-customize-setting-link'] = $this->settings['default']->id;
|
||||
}
|
||||
|
||||
$this->field['name'] = $this->settings['default']->id;
|
||||
|
||||
$this->field['dependency'] = array();
|
||||
|
||||
echo '<div class="wp_china_yes-customize-field'. esc_attr( $class ) .'"'. $atts .'>';
|
||||
|
||||
WP_CHINA_YES::field( $this->field, $this->value(), $this->unique, 'customize' );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
58
framework/functions/helpers.php
Executable file
58
framework/functions/helpers.php
Executable file
|
@ -0,0 +1,58 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Array search key & value
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_array_search' ) ) {
|
||||
function wp_china_yes_array_search( $array, $key, $value ) {
|
||||
|
||||
$results = array();
|
||||
|
||||
if ( is_array( $array ) ) {
|
||||
if ( isset( $array[$key] ) && $array[$key] == $value ) {
|
||||
$results[] = $array;
|
||||
}
|
||||
|
||||
foreach ( $array as $sub_array ) {
|
||||
$results = array_merge( $results, wp_china_yes_array_search( $sub_array, $key, $value ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Between Microtime
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_timeout' ) ) {
|
||||
function wp_china_yes_timeout( $timenow, $starttime, $timeout = 30 ) {
|
||||
return ( ( $timenow - $starttime ) < $timeout ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Check for wp editor api
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_wp_editor_api' ) ) {
|
||||
function wp_china_yes_wp_editor_api() {
|
||||
global $wp_version;
|
||||
return version_compare( $wp_version, '4.8', '>=' );
|
||||
}
|
||||
}
|
29
framework/functions/sanitize.php
Executable file
29
framework/functions/sanitize.php
Executable file
|
@ -0,0 +1,29 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Sanitize
|
||||
* Replace letter a to letter b
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_sanitize_replace_a_to_b' ) ) {
|
||||
function wp_china_yes_sanitize_replace_a_to_b( $value ) {
|
||||
return str_replace( 'a', 'b', $value );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Sanitize title
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_sanitize_title' ) ) {
|
||||
function wp_china_yes_sanitize_title( $value ) {
|
||||
return sanitize_title( $value );
|
||||
}
|
||||
}
|
152
framework/functions/validate.php
Executable file
152
framework/functions/validate.php
Executable file
|
@ -0,0 +1,152 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Email validate
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_validate_email' ) ) {
|
||||
function wp_china_yes_validate_email( $value ) {
|
||||
|
||||
if ( ! filter_var( $value, FILTER_VALIDATE_EMAIL ) ) {
|
||||
return esc_html__( 'Please enter a valid email address.', 'wp_china_yes' );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Numeric validate
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_validate_numeric' ) ) {
|
||||
function wp_china_yes_validate_numeric( $value ) {
|
||||
|
||||
if ( ! is_numeric( $value ) ) {
|
||||
return esc_html__( 'Please enter a valid number.', 'wp_china_yes' );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Required validate
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_validate_required' ) ) {
|
||||
function wp_china_yes_validate_required( $value ) {
|
||||
|
||||
if ( empty( $value ) ) {
|
||||
return esc_html__( 'This field is required.', 'wp_china_yes' );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* URL validate
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_validate_url' ) ) {
|
||||
function wp_china_yes_validate_url( $value ) {
|
||||
|
||||
if ( ! filter_var( $value, FILTER_VALIDATE_URL ) ) {
|
||||
return esc_html__( 'Please enter a valid URL.', 'wp_china_yes' );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Email validate for Customizer
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_customize_validate_email' ) ) {
|
||||
function wp_china_yes_customize_validate_email( $validity, $value, $wp_customize ) {
|
||||
|
||||
if ( ! sanitize_email( $value ) ) {
|
||||
$validity->add( 'required', esc_html__( 'Please enter a valid email address.', 'wp_china_yes' ) );
|
||||
}
|
||||
|
||||
return $validity;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Numeric validate for Customizer
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_customize_validate_numeric' ) ) {
|
||||
function wp_china_yes_customize_validate_numeric( $validity, $value, $wp_customize ) {
|
||||
|
||||
if ( ! is_numeric( $value ) ) {
|
||||
$validity->add( 'required', esc_html__( 'Please enter a valid number.', 'wp_china_yes' ) );
|
||||
}
|
||||
|
||||
return $validity;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Required validate for Customizer
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_customize_validate_required' ) ) {
|
||||
function wp_china_yes_customize_validate_required( $validity, $value, $wp_customize ) {
|
||||
|
||||
if ( empty( $value ) ) {
|
||||
$validity->add( 'required', esc_html__( 'This field is required.', 'wp_china_yes' ) );
|
||||
}
|
||||
|
||||
return $validity;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* URL validate for Customizer
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! function_exists( 'wp_china_yes_customize_validate_url' ) ) {
|
||||
function wp_china_yes_customize_validate_url( $validity, $value, $wp_customize ) {
|
||||
|
||||
if ( ! filter_var( $value, FILTER_VALIDATE_URL ) ) {
|
||||
$validity->add( 'required', esc_html__( 'Please enter a valid URL.', 'wp_china_yes' ) );
|
||||
}
|
||||
|
||||
return $validity;
|
||||
|
||||
}
|
||||
}
|
28
framework/functions/walker.php
Executable file
28
framework/functions/walker.php
Executable file
|
@ -0,0 +1,28 @@
|
|||
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
|
||||
/**
|
||||
*
|
||||
* Custom Walker for Nav Menu Edit
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'WP_CHINA_YES_Walker_Nav_Menu_Edit' ) && class_exists( 'Walker_Nav_Menu_Edit' ) ) {
|
||||
class WP_CHINA_YES_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
|
||||
|
||||
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
||||
|
||||
$html = '';
|
||||
|
||||
parent::start_el( $html, $item, $depth, $args, $id );
|
||||
|
||||
ob_start();
|
||||
do_action( 'wp_nav_menu_item_custom_fields', $item->ID, $item, $depth, $args );
|
||||
$custom_fields = ob_get_clean();
|
||||
|
||||
$output .= preg_replace( '/(?=<(fieldset|p)[^>]+class="[^"]*field-move)/', $custom_fields, $html );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
1
framework/index.php
Executable file
1
framework/index.php
Executable file
|
@ -0,0 +1 @@
|
|||
<?php // Silence is golden.
|
BIN
framework/languages/zh_CN.mo
Executable file
BIN
framework/languages/zh_CN.mo
Executable file
Binary file not shown.
672
framework/languages/zh_CN.po
Executable file
672
framework/languages/zh_CN.po
Executable file
|
@ -0,0 +1,672 @@
|
|||
# Copyright (C) 2021 Wp_china_yes
|
||||
# This file is distributed under the same license as the Wp_china_yes Framework package.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"POT-Creation-Date: 2021-06-25 12:32:35+00:00\n"
|
||||
"PO-Revision-Date: 2021-08-19 12:18+0800\n"
|
||||
"Last-Translator: Seaton Jiang <seatonjiang@vtrois.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: zh_CN\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.4.3\n"
|
||||
"Project-Id-Version: \n"
|
||||
|
||||
#: classes/admin-options.class.php:226
|
||||
msgid "Error while saving the changes."
|
||||
msgstr "保存失败"
|
||||
|
||||
#: classes/admin-options.class.php:286
|
||||
msgid "Settings successfully imported."
|
||||
msgstr "导入成功"
|
||||
|
||||
#: classes/admin-options.class.php:298 classes/admin-options.class.php:314
|
||||
msgid "Default settings restored."
|
||||
msgstr "恢复完成"
|
||||
|
||||
#: classes/admin-options.class.php:385
|
||||
msgid "Settings saved."
|
||||
msgstr "保存成功"
|
||||
|
||||
#: classes/admin-options.class.php:565
|
||||
msgid "You have unsaved changes, save your changes!"
|
||||
msgstr "配置发生改变,请勿忘记保存!"
|
||||
|
||||
#: classes/admin-options.class.php:567
|
||||
msgid "show all settings"
|
||||
msgstr "显示所有设置"
|
||||
|
||||
#: classes/admin-options.class.php:569 fields/icon/icon.php:57
|
||||
#: fields/map/map.php:23
|
||||
msgid "Search..."
|
||||
msgstr "请输入关键词"
|
||||
|
||||
#: classes/admin-options.class.php:572 classes/admin-options.class.php:695
|
||||
msgid "Save"
|
||||
msgstr "保存配置"
|
||||
|
||||
#: classes/admin-options.class.php:572 classes/admin-options.class.php:695
|
||||
msgid "Saving..."
|
||||
msgstr "正在保存"
|
||||
|
||||
#: classes/admin-options.class.php:573 classes/admin-options.class.php:696
|
||||
msgid "Reset Section"
|
||||
msgstr "恢复此页"
|
||||
|
||||
#: classes/admin-options.class.php:573 classes/admin-options.class.php:696
|
||||
msgid "Are you sure to reset this section options?"
|
||||
msgstr "单击「确定」进行恢复,当前页面的配置将会丢失!"
|
||||
|
||||
#: classes/admin-options.class.php:574 classes/admin-options.class.php:697
|
||||
msgid "Reset All"
|
||||
msgstr "恢复全部"
|
||||
|
||||
#: classes/admin-options.class.php:574 classes/admin-options.class.php:697
|
||||
#: classes/comment-options.class.php:216 classes/metabox-options.class.php:294
|
||||
#: fields/backup/backup.php:31
|
||||
msgid "Reset"
|
||||
msgstr "恢复默认"
|
||||
|
||||
#: classes/admin-options.class.php:574 classes/admin-options.class.php:697
|
||||
msgid "Are you sure you want to reset all settings to default values?"
|
||||
msgstr "单击「确定」进行恢复,所有页面的配置都将丢失!"
|
||||
|
||||
#: classes/admin-options.class.php:672 classes/comment-options.class.php:199
|
||||
#: classes/metabox-options.class.php:277 fields/button_set/button_set.php:56
|
||||
#: fields/checkbox/checkbox.php:76 fields/radio/radio.php:75
|
||||
#: fields/select/select.php:113 functions/actions.php:41
|
||||
msgid "No data available."
|
||||
msgstr "没有可用数据"
|
||||
|
||||
#: classes/comment-options.class.php:217 classes/metabox-options.class.php:295
|
||||
msgid "update post"
|
||||
msgstr "更新文章"
|
||||
|
||||
#: classes/comment-options.class.php:217 classes/metabox-options.class.php:295
|
||||
msgid "Cancel"
|
||||
msgstr "取消"
|
||||
|
||||
#: classes/setup.class.php:592
|
||||
msgid "Are you sure?"
|
||||
msgstr "单击「确定」进行下一步操作,该操作可能会丢失部分配置!"
|
||||
|
||||
#: classes/setup.class.php:593
|
||||
msgid "Please enter %s or more characters"
|
||||
msgstr "请输入 %s 或更多字符"
|
||||
|
||||
#: classes/setup.class.php:594
|
||||
msgid "Searching..."
|
||||
msgstr "搜索中..."
|
||||
|
||||
#: classes/setup.class.php:595
|
||||
msgid "No results found."
|
||||
msgstr "未找到结果。"
|
||||
|
||||
#: classes/setup.class.php:696
|
||||
msgid "Oops! Not allowed."
|
||||
msgstr "哎呀!不允许。"
|
||||
|
||||
#: classes/setup.class.php:768 classes/setup.class.php:772
|
||||
msgid "Field not found!"
|
||||
msgstr "没有找到任何数据"
|
||||
|
||||
#: classes/shortcode-options.class.php:253 fields/group/group.php:23
|
||||
msgid "Add New"
|
||||
msgstr "新增"
|
||||
|
||||
#: classes/shortcode-options.class.php:290 functions/actions.php:16
|
||||
#: functions/actions.php:68 functions/actions.php:106 functions/actions.php:141
|
||||
#: functions/actions.php:170
|
||||
msgid "Error: Invalid nonce verification."
|
||||
msgstr "错误: 无效的nonce验证。"
|
||||
|
||||
#: fields/background/background.php:36 fields/media/media.php:59
|
||||
msgid "Not selected"
|
||||
msgstr "未选择"
|
||||
|
||||
#: fields/background/background.php:72 fields/date/date.php:31
|
||||
msgid "From"
|
||||
msgstr "从"
|
||||
|
||||
#: fields/background/background.php:90 fields/date/date.php:32
|
||||
msgid "To"
|
||||
msgstr "到"
|
||||
|
||||
#: fields/background/background.php:108
|
||||
msgid "Direction"
|
||||
msgstr "方向"
|
||||
|
||||
#: fields/background/background.php:114
|
||||
msgid "Gradient Direction"
|
||||
msgstr "渐变方向"
|
||||
|
||||
#: fields/background/background.php:115
|
||||
msgid "⇓ top to bottom"
|
||||
msgstr "⇓ 从上到下"
|
||||
|
||||
#: fields/background/background.php:116
|
||||
msgid "⇒ left to right"
|
||||
msgstr "⇒从左到右"
|
||||
|
||||
#: fields/background/background.php:117
|
||||
msgid "⇘ corner top to right"
|
||||
msgstr "⇘ 右上角"
|
||||
|
||||
#: fields/background/background.php:118
|
||||
msgid "⇙ corner top to left"
|
||||
msgstr "⇘ 左上角"
|
||||
|
||||
#: fields/background/background.php:161
|
||||
msgid "Background Position"
|
||||
msgstr "背景位置"
|
||||
|
||||
#: fields/background/background.php:162
|
||||
msgid "Left Top"
|
||||
msgstr "左上"
|
||||
|
||||
#: fields/background/background.php:163
|
||||
msgid "Left Center"
|
||||
msgstr "左中"
|
||||
|
||||
#: fields/background/background.php:164
|
||||
msgid "Left Bottom"
|
||||
msgstr "左下"
|
||||
|
||||
#: fields/background/background.php:165
|
||||
msgid "Center Top"
|
||||
msgstr "中上"
|
||||
|
||||
#: fields/background/background.php:166
|
||||
msgid "Center Center"
|
||||
msgstr "居中"
|
||||
|
||||
#: fields/background/background.php:167
|
||||
msgid "Center Bottom"
|
||||
msgstr "中下"
|
||||
|
||||
#: fields/background/background.php:168
|
||||
msgid "Right Top"
|
||||
msgstr "右上"
|
||||
|
||||
#: fields/background/background.php:169
|
||||
msgid "Right Center"
|
||||
msgstr "右中"
|
||||
|
||||
#: fields/background/background.php:170
|
||||
msgid "Right Bottom"
|
||||
msgstr "右下"
|
||||
|
||||
#: fields/background/background.php:184
|
||||
msgid "Background Repeat"
|
||||
msgstr "背景重复"
|
||||
|
||||
#: fields/background/background.php:185
|
||||
msgid "Repeat"
|
||||
msgstr "重复"
|
||||
|
||||
#: fields/background/background.php:186
|
||||
msgid "No Repeat"
|
||||
msgstr "不重复"
|
||||
|
||||
#: fields/background/background.php:187
|
||||
msgid "Repeat Horizontally"
|
||||
msgstr "水平重复"
|
||||
|
||||
#: fields/background/background.php:188
|
||||
msgid "Repeat Vertically"
|
||||
msgstr "垂直重复"
|
||||
|
||||
#: fields/background/background.php:202
|
||||
msgid "Background Attachment"
|
||||
msgstr "背景附件"
|
||||
|
||||
#: fields/background/background.php:203
|
||||
msgid "Scroll"
|
||||
msgstr "滚动"
|
||||
|
||||
#: fields/background/background.php:204
|
||||
msgid "Fixed"
|
||||
msgstr "固定"
|
||||
|
||||
#: fields/background/background.php:218
|
||||
msgid "Background Size"
|
||||
msgstr "背景大小"
|
||||
|
||||
#: fields/background/background.php:219
|
||||
msgid "Cover"
|
||||
msgstr "覆盖"
|
||||
|
||||
#: fields/background/background.php:220
|
||||
msgid "Contain"
|
||||
msgstr "包含"
|
||||
|
||||
#: fields/background/background.php:221
|
||||
msgid "Auto"
|
||||
msgstr "自动"
|
||||
|
||||
#: fields/background/background.php:235
|
||||
msgid "Background Origin"
|
||||
msgstr "背景起源"
|
||||
|
||||
#: fields/background/background.php:236 fields/background/background.php:254
|
||||
msgid "Padding Box"
|
||||
msgstr "框内边距"
|
||||
|
||||
#: fields/background/background.php:237 fields/background/background.php:253
|
||||
msgid "Border Box"
|
||||
msgstr "边框"
|
||||
|
||||
#: fields/background/background.php:238 fields/background/background.php:255
|
||||
msgid "Content Box"
|
||||
msgstr "内容框"
|
||||
|
||||
#: fields/background/background.php:252
|
||||
msgid "Background Clip"
|
||||
msgstr "背景剪辑"
|
||||
|
||||
#: fields/background/background.php:269
|
||||
msgid "Background Blend Mode"
|
||||
msgstr "背景混合模式"
|
||||
|
||||
#: fields/background/background.php:270 fields/link_color/link_color.php:36
|
||||
#: fields/typography/typography.php:186
|
||||
msgid "Normal"
|
||||
msgstr "正常"
|
||||
|
||||
#: fields/background/background.php:271
|
||||
msgid "Multiply"
|
||||
msgstr "乘"
|
||||
|
||||
#: fields/background/background.php:272
|
||||
msgid "Screen"
|
||||
msgstr "屏幕"
|
||||
|
||||
#: fields/background/background.php:273
|
||||
msgid "Overlay"
|
||||
msgstr "覆盖"
|
||||
|
||||
#: fields/background/background.php:274
|
||||
msgid "Darken"
|
||||
msgstr "变黑"
|
||||
|
||||
#: fields/background/background.php:275
|
||||
msgid "Lighten"
|
||||
msgstr "减轻"
|
||||
|
||||
#: fields/background/background.php:276
|
||||
msgid "Color Dodge"
|
||||
msgstr "颜色减淡"
|
||||
|
||||
#: fields/background/background.php:277
|
||||
msgid "Saturation"
|
||||
msgstr "饱和度"
|
||||
|
||||
#: fields/background/background.php:278
|
||||
msgid "Color"
|
||||
msgstr "颜色"
|
||||
|
||||
#: fields/background/background.php:279
|
||||
msgid "Luminosity"
|
||||
msgstr "光度"
|
||||
|
||||
#: fields/backup/backup.php:26
|
||||
msgid "Import"
|
||||
msgstr "导入"
|
||||
|
||||
#: fields/backup/backup.php:29
|
||||
msgid "Export & Download"
|
||||
msgstr "导出和下载"
|
||||
|
||||
#: fields/border/border.php:25 fields/spacing/spacing.php:25
|
||||
msgid "top"
|
||||
msgstr "顶部"
|
||||
|
||||
#: fields/border/border.php:26 fields/spacing/spacing.php:26
|
||||
msgid "right"
|
||||
msgstr "右"
|
||||
|
||||
#: fields/border/border.php:27 fields/spacing/spacing.php:27
|
||||
msgid "bottom"
|
||||
msgstr "底部"
|
||||
|
||||
#: fields/border/border.php:28 fields/spacing/spacing.php:28
|
||||
msgid "left"
|
||||
msgstr "左"
|
||||
|
||||
#: fields/border/border.php:29 fields/spacing/spacing.php:29
|
||||
msgid "all"
|
||||
msgstr "所有"
|
||||
|
||||
#: fields/border/border.php:51 fields/typography/typography.php:214
|
||||
msgid "Solid"
|
||||
msgstr "实线"
|
||||
|
||||
#: fields/border/border.php:52 fields/typography/typography.php:217
|
||||
msgid "Dashed"
|
||||
msgstr "虚线"
|
||||
|
||||
#: fields/border/border.php:53 fields/typography/typography.php:216
|
||||
msgid "Dotted"
|
||||
msgstr "点线"
|
||||
|
||||
#: fields/border/border.php:54 fields/typography/typography.php:215
|
||||
msgid "Double"
|
||||
msgstr "双线"
|
||||
|
||||
#: fields/border/border.php:55
|
||||
msgid "Inset"
|
||||
msgstr "插入"
|
||||
|
||||
#: fields/border/border.php:56
|
||||
msgid "Outset"
|
||||
msgstr "开始"
|
||||
|
||||
#: fields/border/border.php:57
|
||||
msgid "Groove"
|
||||
msgstr "凹槽"
|
||||
|
||||
#: fields/border/border.php:58
|
||||
msgid "ridge"
|
||||
msgstr "凸出"
|
||||
|
||||
#: fields/border/border.php:59 fields/typography/typography.php:199
|
||||
#: fields/typography/typography.php:213
|
||||
msgid "None"
|
||||
msgstr "无"
|
||||
|
||||
#: fields/dimensions/dimensions.php:22
|
||||
msgid "width"
|
||||
msgstr "宽度"
|
||||
|
||||
#: fields/dimensions/dimensions.php:23
|
||||
msgid "height"
|
||||
msgstr "高度"
|
||||
|
||||
#: fields/gallery/gallery.php:20
|
||||
msgid "Add Gallery"
|
||||
msgstr "添加图库"
|
||||
|
||||
#: fields/gallery/gallery.php:21
|
||||
msgid "Edit Gallery"
|
||||
msgstr "编辑图库"
|
||||
|
||||
#: fields/gallery/gallery.php:22
|
||||
msgid "Clear"
|
||||
msgstr "清除"
|
||||
|
||||
#: fields/group/group.php:35 fields/repeater/repeater.php:27
|
||||
msgid "Error: Field ID conflict."
|
||||
msgstr "错误:字段ID冲突。"
|
||||
|
||||
#: fields/group/group.php:46 fields/group/group.php:87
|
||||
#: fields/repeater/repeater.php:48 fields/repeater/repeater.php:76
|
||||
msgid "Are you sure to delete this item?"
|
||||
msgstr "确定要删除这个项目吗?"
|
||||
|
||||
#: fields/group/group.php:121 fields/repeater/repeater.php:89
|
||||
msgid "You cannot add more."
|
||||
msgstr "无法添加更多"
|
||||
|
||||
#: fields/group/group.php:122 fields/repeater/repeater.php:90
|
||||
msgid "You cannot remove more."
|
||||
msgstr "无法删除更多"
|
||||
|
||||
#: fields/icon/icon.php:20 fields/icon/icon.php:53
|
||||
msgid "Add Icon"
|
||||
msgstr "添加图标"
|
||||
|
||||
#: fields/icon/icon.php:21
|
||||
msgid "Remove Icon"
|
||||
msgstr "删除图标"
|
||||
|
||||
#: fields/link/link.php:20
|
||||
msgid "Add Link"
|
||||
msgstr "添加链接"
|
||||
|
||||
#: fields/link/link.php:21
|
||||
msgid "Edit Link"
|
||||
msgstr "编辑链接"
|
||||
|
||||
#: fields/link/link.php:22
|
||||
msgid "Remove Link"
|
||||
msgstr "移除链接"
|
||||
|
||||
#: fields/link_color/link_color.php:37
|
||||
msgid "Hover"
|
||||
msgstr "悬停"
|
||||
|
||||
#: fields/link_color/link_color.php:38
|
||||
msgid "Active"
|
||||
msgstr "启用"
|
||||
|
||||
#: fields/link_color/link_color.php:39
|
||||
msgid "Visited"
|
||||
msgstr "访问"
|
||||
|
||||
#: fields/link_color/link_color.php:40
|
||||
msgid "Focus"
|
||||
msgstr "焦点"
|
||||
|
||||
#: fields/map/map.php:24
|
||||
msgid "Latitude"
|
||||
msgstr "纬度"
|
||||
|
||||
#: fields/map/map.php:25
|
||||
msgid "Longitude"
|
||||
msgstr "经度"
|
||||
|
||||
#: fields/media/media.php:25 fields/upload/upload.php:25
|
||||
msgid "Upload"
|
||||
msgstr "上传"
|
||||
|
||||
#: fields/media/media.php:26 fields/upload/upload.php:26
|
||||
msgid "Remove"
|
||||
msgstr "删除"
|
||||
|
||||
#: fields/sorter/sorter.php:21
|
||||
msgid "Enabled"
|
||||
msgstr "启用"
|
||||
|
||||
#: fields/sorter/sorter.php:22
|
||||
msgid "Disabled"
|
||||
msgstr "禁用"
|
||||
|
||||
#: fields/switcher/switcher.php:20
|
||||
msgid "On"
|
||||
msgstr "启用"
|
||||
|
||||
#: fields/switcher/switcher.php:21
|
||||
msgid "Off"
|
||||
msgstr "禁用"
|
||||
|
||||
#: fields/typography/typography.php:96
|
||||
msgid "Font Family"
|
||||
msgstr "字体"
|
||||
|
||||
#: fields/typography/typography.php:97
|
||||
msgid "Select a font"
|
||||
msgstr "选择字体"
|
||||
|
||||
#: fields/typography/typography.php:105
|
||||
msgid "Backup Font Family"
|
||||
msgstr "备份字体系列"
|
||||
|
||||
#: fields/typography/typography.php:119 fields/typography/typography.php:132
|
||||
#: fields/typography/typography.php:145 fields/typography/typography.php:160
|
||||
#: fields/typography/typography.php:176 fields/typography/typography.php:189
|
||||
#: fields/typography/typography.php:203 fields/typography/typography.php:221
|
||||
msgid "Default"
|
||||
msgstr "默认"
|
||||
|
||||
#: fields/typography/typography.php:130
|
||||
msgid "Font Style"
|
||||
msgstr "字体样式"
|
||||
|
||||
#: fields/typography/typography.php:144 fields/typography/typography.php:145
|
||||
msgid "Load Extra Styles"
|
||||
msgstr "加载额外样式"
|
||||
|
||||
#: fields/typography/typography.php:158
|
||||
msgid "Subset"
|
||||
msgstr "子集"
|
||||
|
||||
#: fields/typography/typography.php:168
|
||||
msgid "Text Align"
|
||||
msgstr "文本对齐"
|
||||
|
||||
#: fields/typography/typography.php:170
|
||||
msgid "Inherit"
|
||||
msgstr "继承"
|
||||
|
||||
#: fields/typography/typography.php:171
|
||||
msgid "Left"
|
||||
msgstr "左侧"
|
||||
|
||||
#: fields/typography/typography.php:172
|
||||
msgid "Center"
|
||||
msgstr "居中"
|
||||
|
||||
#: fields/typography/typography.php:173
|
||||
msgid "Right"
|
||||
msgstr "右侧"
|
||||
|
||||
#: fields/typography/typography.php:174
|
||||
msgid "Justify"
|
||||
msgstr "两端对齐"
|
||||
|
||||
#: fields/typography/typography.php:175
|
||||
msgid "Initial"
|
||||
msgstr "初始"
|
||||
|
||||
#: fields/typography/typography.php:184
|
||||
msgid "Font Variant"
|
||||
msgstr "字体变体"
|
||||
|
||||
#: fields/typography/typography.php:187
|
||||
msgid "Small Caps"
|
||||
msgstr "小写"
|
||||
|
||||
#: fields/typography/typography.php:188
|
||||
msgid "All Small Caps"
|
||||
msgstr "所有字母小写"
|
||||
|
||||
#: fields/typography/typography.php:197
|
||||
msgid "Text Transform"
|
||||
msgstr "文本转换"
|
||||
|
||||
#: fields/typography/typography.php:200
|
||||
msgid "Capitalize"
|
||||
msgstr "大写"
|
||||
|
||||
#: fields/typography/typography.php:201
|
||||
msgid "Uppercase"
|
||||
msgstr "大写"
|
||||
|
||||
#: fields/typography/typography.php:202
|
||||
msgid "Lowercase"
|
||||
msgstr "小写"
|
||||
|
||||
#: fields/typography/typography.php:211
|
||||
msgid "Text Decoration"
|
||||
msgstr "文本装饰"
|
||||
|
||||
#: fields/typography/typography.php:218
|
||||
msgid "Wavy"
|
||||
msgstr "波浪"
|
||||
|
||||
#: fields/typography/typography.php:219
|
||||
msgid "Overline"
|
||||
msgstr "上划线"
|
||||
|
||||
#: fields/typography/typography.php:220
|
||||
msgid "Line-through"
|
||||
msgstr "删除线"
|
||||
|
||||
#: fields/typography/typography.php:233
|
||||
msgid "Font Size"
|
||||
msgstr "字体大小"
|
||||
|
||||
#: fields/typography/typography.php:245
|
||||
msgid "Line Height"
|
||||
msgstr "线高度"
|
||||
|
||||
#: fields/typography/typography.php:257
|
||||
msgid "Letter Spacing"
|
||||
msgstr "字母间距"
|
||||
|
||||
#: fields/typography/typography.php:269
|
||||
msgid "Word Spacing"
|
||||
msgstr "字间距"
|
||||
|
||||
#: fields/typography/typography.php:284
|
||||
msgid "Font Color"
|
||||
msgstr "字体颜色"
|
||||
|
||||
#: fields/typography/typography.php:295
|
||||
msgid "Custom Style"
|
||||
msgstr "自定义样式"
|
||||
|
||||
#: fields/typography/typography.php:362
|
||||
msgid "Custom Web Fonts"
|
||||
msgstr "自定义 Web 字体"
|
||||
|
||||
#: fields/typography/typography.php:368
|
||||
msgid "Safe Web Fonts"
|
||||
msgstr "Web 安全字体"
|
||||
|
||||
#: fields/typography/typography.php:388
|
||||
msgid "Google Web Fonts"
|
||||
msgstr "Google Web 字体"
|
||||
|
||||
#: functions/actions.php:72 functions/actions.php:110
|
||||
msgid "Error: Invalid key."
|
||||
msgstr "错误:无效密钥。"
|
||||
|
||||
#: functions/actions.php:114
|
||||
msgid "Error: The response is not a valid JSON response."
|
||||
msgstr "错误:响应不是有效的 JSON 响应。"
|
||||
|
||||
#: functions/actions.php:174
|
||||
msgid "Error: Invalid term ID."
|
||||
msgstr "错误:无效的项目ID。"
|
||||
|
||||
#: functions/actions.php:180
|
||||
msgid "Error: You do not have permission to do that."
|
||||
msgstr "错误:您无权这样做。"
|
||||
|
||||
#: functions/validate.php:14 functions/validate.php:86
|
||||
msgid "Please enter a valid email address."
|
||||
msgstr "请输入正确的电子邮件地址。"
|
||||
|
||||
#: functions/validate.php:32 functions/validate.php:106
|
||||
msgid "Please enter a valid number."
|
||||
msgstr "请输入有效的数字"
|
||||
|
||||
#: functions/validate.php:50 functions/validate.php:126
|
||||
msgid "This field is required."
|
||||
msgstr "这是必填栏。"
|
||||
|
||||
#: functions/validate.php:68 functions/validate.php:146
|
||||
msgid "Please enter a valid URL."
|
||||
msgstr "请输入有效网址"
|
||||
|
||||
#. Plugin Name of the plugin/theme
|
||||
msgid "Wp_china_yes Framework"
|
||||
msgstr "Wp_china_yes Framework"
|
||||
|
||||
#. Plugin URI of the plugin/theme
|
||||
msgid "http://wp_china_yesframework.com/"
|
||||
msgstr "http://wp_china_yesframework.com/"
|
||||
|
||||
#. Description of the plugin/theme
|
||||
msgid "A Simple and Lightweight WordPress Option Framework for Themes and Plugins"
|
||||
msgstr "一个简单且轻量的 WordPress 主题和插件选项框架"
|
||||
|
||||
#. Author of the plugin/theme
|
||||
msgid "Wp_china_yes"
|
||||
msgstr "Wp_china_yes"
|
||||
|
||||
#. Author URI of the plugin/theme
|
||||
msgid "http://wp_china_yesthemes.com/"
|
||||
msgstr "http://wp_china_yesthemes.com/"
|
21
helpers.php
Normal file → Executable file
21
helpers.php
Normal file → Executable file
|
@ -9,12 +9,19 @@ function get_settings() {
|
|||
$settings = is_multisite() ? get_site_option( 'wp_china_yes' ) : get_option( 'wp_china_yes' );
|
||||
|
||||
return wp_parse_args( $settings, [
|
||||
'store' => 'wenpai',
|
||||
'admincdn' => [
|
||||
'admin' => 'admin',
|
||||
],
|
||||
'cravatar' => 'cn',
|
||||
'windfonts' => 'off',
|
||||
'adblock' => 'off',
|
||||
'store' => 'wenpai',
|
||||
'admincdn' => [ 'admin' ],
|
||||
'cravatar' => 'cn',
|
||||
'windfonts' => 'off',
|
||||
'windfonts_list' => [],
|
||||
'windfonts_typography' => [],
|
||||
'adblock' => 'off',
|
||||
'adblock_rule' => [],
|
||||
'plane' => 'off',
|
||||
'plane_rule' => [],
|
||||
'monitor' => true,
|
||||
'memory' => true,
|
||||
'hide' => false,
|
||||
'custom_name' => 'WP-China-Yes',
|
||||
] );
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue