mirror of
https://github.com/WenPai-org/wp-china-yes.git
synced 2025-08-07 06:13:13 +08:00
feat: v3.7.0
This commit is contained in:
parent
dd912a9e31
commit
2391c18bae
76 changed files with 9491 additions and 353 deletions
|
@ -37,7 +37,7 @@ class Monitor {
|
|||
* 初始化
|
||||
*/
|
||||
public function init() {
|
||||
if ( $this->settings['monitor'] != 'on' ) {
|
||||
if ( $this->settings['monitor'] ) {
|
||||
return;
|
||||
}
|
||||
// 检查应用市场可用性
|
||||
|
@ -104,51 +104,51 @@ class Monitor {
|
|||
*/
|
||||
public function maybe_check_admincdn() {
|
||||
// 后台加速
|
||||
if ( ! empty( $this->settings['admincdn']['admin'] ) ) {
|
||||
if ( in_array( 'admin', $this->settings['admincdn'] ) ) {
|
||||
$response = wp_remote_get( 'https://wpstatic.admincdn.com/6.4.3/wp-includes/js/wp-sanitize.min.js' );
|
||||
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
|
||||
unset( $this->settings['admincdn']['admin'] );
|
||||
$this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'admin' ] ) );
|
||||
$this->update_settings();
|
||||
}
|
||||
}
|
||||
// 前台加速
|
||||
if ( ! empty( $this->settings['admincdn']['frontend'] ) ) {
|
||||
if ( in_array( 'frontend', $this->settings['admincdn'] ) ) {
|
||||
$url = network_site_url( '/wp-includes/js/wp-sanitize.min.js' );
|
||||
$response = wp_remote_get( 'https://public.admincdn.com/' . $url );
|
||||
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
|
||||
unset( $this->settings['admincdn']['frontend'] );
|
||||
$this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'frontend' ] ) );
|
||||
$this->update_settings();
|
||||
}
|
||||
}
|
||||
// Google 字体
|
||||
if ( ! empty( $this->settings['admincdn']['googlefonts'] ) ) {
|
||||
if ( in_array( 'googlefonts', $this->settings['admincdn'] ) ) {
|
||||
$response = wp_remote_get( 'https://googlefonts.admincdn.com/css?family=Roboto:400,700' );
|
||||
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
|
||||
unset( $this->settings['admincdn']['googlefonts'] );
|
||||
$this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'googlefonts' ] ) );
|
||||
$this->update_settings();
|
||||
}
|
||||
}
|
||||
// Google 前端公共库
|
||||
if ( ! empty( $this->settings['admincdn']['googleajax'] ) ) {
|
||||
if ( in_array( 'googleajax', $this->settings['admincdn'] ) ) {
|
||||
$response = wp_remote_get( 'https://googleajax.admincdn.com/ajax/libs/jquery/3.7.1/jquery.slim.min.js' );
|
||||
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
|
||||
unset( $this->settings['admincdn']['googleajax'] );
|
||||
$this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'googleajax' ] ) );
|
||||
$this->update_settings();
|
||||
}
|
||||
}
|
||||
// CDNJS 前端公共库
|
||||
if ( ! empty( $this->settings['admincdn']['cdnjs'] ) ) {
|
||||
if ( in_array( 'cdnjs', $this->settings['admincdn'] ) ) {
|
||||
$response = wp_remote_get( 'https://cdnjs.admincdn.com/jquery/3.7.1/jquery.slim.min.js' );
|
||||
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
|
||||
unset( $this->settings['admincdn']['cdnjs'] );
|
||||
$this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'cdnjs' ] ) );
|
||||
$this->update_settings();
|
||||
}
|
||||
}
|
||||
// jsDelivr 公共库
|
||||
if ( ! empty( $this->settings['admincdn']['jsdelivr'] ) ) {
|
||||
if ( in_array( 'jsdelivr', $this->settings['admincdn'] ) ) {
|
||||
$response = wp_remote_get( 'https://jsd.admincdn.com/npm/jquery@3.7.1/dist/jquery.slim.min.js' );
|
||||
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
|
||||
unset( $this->settings['admincdn']['jsdelivr'] );
|
||||
$this->settings['admincdn'] = array_values( array_diff( $this->settings['admincdn'], [ 'jsdelivr' ] ) );
|
||||
$this->update_settings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@ namespace WenPai\ChinaYes\Service;
|
|||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use TheTNB\Setting\API;
|
||||
use WP_CHINA_YES;
|
||||
use function WenPai\ChinaYes\get_settings;
|
||||
|
||||
/**
|
||||
* Class Setting
|
||||
|
@ -12,115 +13,375 @@ use TheTNB\Setting\API;
|
|||
* @package WenPai\ChinaYes\Service
|
||||
*/
|
||||
class Setting {
|
||||
private $setting_api;
|
||||
private $prefix = 'wp_china_yes';
|
||||
private $settings;
|
||||
|
||||
public function __construct() {
|
||||
$this->setting_api = new API();
|
||||
add_action( 'admin_init', [ $this, 'admin_init' ] );
|
||||
$this->settings = get_settings();
|
||||
add_filter( 'wp_china_yes_enqueue_assets', '__return_true' );
|
||||
add_filter( 'wp_china_yes_fa4', '__return_true' );
|
||||
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_assets' ] );
|
||||
add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', [ $this, 'admin_menu' ] );
|
||||
self::admin_init();
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂载设置项
|
||||
*/
|
||||
public function admin_init() {
|
||||
WP_CHINA_YES::createOptions( $this->prefix, [
|
||||
'framework_title' => sprintf( '%s <small>v%s</small>', $this->settings['custom_name'], CHINA_YES_VERSION ),
|
||||
'menu_hidden' => $this->settings['hide'],
|
||||
'menu_title' => $this->settings['custom_name'],
|
||||
'menu_slug' => 'wp-china-yes',
|
||||
'menu_type' => 'submenu',
|
||||
'menu_parent' => is_multisite() ? 'settings.php' : 'options-general.php',
|
||||
'show_bar_menu' => false,
|
||||
'show_sub_menu' => false,
|
||||
'show_search' => false,
|
||||
'show_reset_section' => false,
|
||||
'footer_text' => sprintf( '%s 设置', $this->settings['custom_name'] ),
|
||||
'theme' => 'light',
|
||||
'enqueue_webfont' => false,
|
||||
'async_webfont' => true,
|
||||
'database' => is_multisite() ? 'network' : '',
|
||||
] );
|
||||
|
||||
$sections = [
|
||||
WP_CHINA_YES::createSection( $this->prefix, [
|
||||
'title' => '加速设置',
|
||||
'icon' => 'fa fa-rocket',
|
||||
'fields' => [
|
||||
[
|
||||
'id' => 'wp_china_yes',
|
||||
'title' => __( '设置', 'wp-china-yes' )
|
||||
]
|
||||
];
|
||||
|
||||
$fields = [
|
||||
'wp_china_yes' => [
|
||||
[
|
||||
'name' => 'store',
|
||||
'label' => __( '应用市场', 'wp-china-yes' ),
|
||||
'desc' => __( '<a href="https://wpmirror.com/" target="_blank">官方加速源(WPMirror)</a>直接从 .org 反代至大陆分发;<a href="https://wenpai.org/" target="_blank">文派开源(WenPai.org)</a>中国境内自建托管仓库,同时集成文派翻译平台。',
|
||||
'wp-china-yes' ),
|
||||
'id' => 'store',
|
||||
'type' => 'radio',
|
||||
'default' => 'wenpai',
|
||||
'title' => __( '应用市场', 'wp-china-yes' ),
|
||||
'inline' => true,
|
||||
'options' => [
|
||||
'proxy' => '官方镜像',
|
||||
'wenpai' => '文派开源',
|
||||
'off' => '不启用'
|
||||
]
|
||||
],
|
||||
'default' => 'wenpai',
|
||||
'subtitle' => '是否启用市场加速',
|
||||
'desc' => __( '<a href="https://wpmirror.com/" target="_blank">官方加速源(WPMirror)</a>直接从 .org 反代至大陆分发;<a href="https://wenpai.org/" target="_blank">文派开源(WenPai.org)</a>中国境内自建托管仓库,同时集成文派翻译平台',
|
||||
'wp-china-yes' ),
|
||||
],
|
||||
[
|
||||
'name' => 'admincdn',
|
||||
'label' => __( '萌芽加速', 'wp-china-yes' ),
|
||||
'desc' => __( '<a href="https://admincdn.com/" target="_blank">萌芽加速(adminCDN)</a>将 WordPress 依赖的静态文件切换为公共资源,加快网站访问速度。您可按需启用需要加速的项目,更多细节控制和功能,请关注 adminCDN 项目。',
|
||||
'wp-china-yes' ),
|
||||
'type' => 'multicheck',
|
||||
'default' => [
|
||||
'admin' => 'admin',
|
||||
],
|
||||
'id' => 'admincdn',
|
||||
'type' => 'checkbox',
|
||||
'title' => __( '萌芽加速', 'wp-china-yes' ),
|
||||
'inline' => true,
|
||||
'options' => [
|
||||
'admin' => '后台加速',
|
||||
'frontend' => '前台加速',
|
||||
'googlefonts' => 'Google 字体',
|
||||
'googleajax' => 'Google 前端公共库',
|
||||
'cdnjs' => 'CDNJS 前端公共库',
|
||||
'jsdelivr' => 'jsDelivr 公共库',
|
||||
]
|
||||
'jsdelivr' => 'jsDelivr 公共库'
|
||||
],
|
||||
'default' => [
|
||||
'admin' => 'admin',
|
||||
],
|
||||
'subtitle' => '是否启用萌芽加速',
|
||||
'desc' => __( '<a href="https://admincdn.com/" target="_blank">萌芽加速(adminCDN)</a>将 WordPress 依赖的静态文件切换为公共资源,加快网站访问速度。您可按需启用需要加速的项目,更多细节控制和功能,请关注 adminCDN 项目',
|
||||
'wp-china-yes' ),
|
||||
],
|
||||
[
|
||||
'name' => 'cravatar',
|
||||
'label' => __( '初认头像', 'wp-china-yes' ),
|
||||
'desc' => __( '<a href="https://cravatar.com/" target="_blank">初认头像(Cravatar)</a>Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。(任何开发者均可在自己的产品中集成该服务,不局限于 WordPress)',
|
||||
'wp-china-yes' ),
|
||||
'id' => 'cravatar',
|
||||
'type' => 'radio',
|
||||
'default' => 'cn',
|
||||
'title' => __( '初认头像', 'wp-china-yes' ),
|
||||
'inline' => true,
|
||||
'options' => [
|
||||
'cn' => '默认线路',
|
||||
'global' => '国际线路',
|
||||
'weavatar' => '备用源(<a href="https://weavatar.com/" target="_blank">WeAvatar</a>)',
|
||||
'weavatar' => '备用源(WeAvatar.com)',
|
||||
'off' => '不启用'
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'windfonts',
|
||||
'label' => __( '文风字体', 'wp-china-yes' ),
|
||||
'desc' => __( '<a href="https://windfonts.com/" target="_blank">文风字体(Windfonts)</a>为您的网页渲染中文字体并对主题、插件内的字体进行加速;优化模式可优化浏览器字体调用。',
|
||||
'default' => 'cn',
|
||||
'subtitle' => '是否启用头像加速',
|
||||
'desc' => __( '<a href="https://cravatar.com/" target="_blank">初认头像(Cravatar)</a>Gravatar 在中国的完美替代方案,您可以在 Cravatar.com 上传头像,更多选项请安装 WPAavatar 插件。(任何开发者均可在自己的产品中集成该服务,不局限于 WordPress)',
|
||||
'wp-china-yes' ),
|
||||
],
|
||||
],
|
||||
] );
|
||||
|
||||
WP_CHINA_YES::createSection( $this->prefix, [
|
||||
'title' => '文风字体',
|
||||
'icon' => 'fa fa-font',
|
||||
'fields' => [
|
||||
[
|
||||
'id' => 'windfonts',
|
||||
'type' => 'radio',
|
||||
'default' => 'off',
|
||||
'title' => __( '文风字体', 'wp-china-yes' ),
|
||||
'inline' => true,
|
||||
'options' => [
|
||||
'optimize' => '优化模式',
|
||||
'on' => '全局启用',
|
||||
'frontend' => '前台启用',
|
||||
'optimize' => '本机字体',
|
||||
'off' => '不启用',
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'adblock',
|
||||
'label' => __( '广告拦截', 'wp-china-yes' ),
|
||||
'desc' => __( '<a href="https://wp-china-yes.com/ads" target="_blank">文派叶子🍃(WP-China-Yes)</a>独家特色功能,让您拥有清爽整洁的 WordPress 后台,清除各类常用插件侵入式后台广告、通知及无用信息;启用后若存在异常拦截,请切换为手动模式,查看<a href="https://wp-china-yes.com/" target="_blank">可优化插件列表</a>。',
|
||||
'wp-china-yes' ),
|
||||
'type' => 'radio',
|
||||
'default' => 'off',
|
||||
'options' => [
|
||||
'off' => '即将上线',
|
||||
]
|
||||
'subtitle' => '是否启用文风字体定制',
|
||||
'desc' => __( '<a href="https://windfonts.com/" target="_blank">文风字体(Windfonts)</a>为您的网站增添无限活力。专为中文网页设计,旨在提升用户阅读体验和视觉享受',
|
||||
'wp-china-yes' ),
|
||||
],
|
||||
[
|
||||
'name' => 'monitor',
|
||||
'label' => __( '自动监控', 'wp-china-yes' ),
|
||||
'desc' => __( '<a href="https://wp-china-yes.com/ads" target="_blank">文派叶子🍃(WP-China-Yes)</a>支持自动监控各加速节点可用性,当节点不可用时自动切换至可用节点或关闭加速,以保证您的网站正常访问。',
|
||||
'id' => 'windfonts_list',
|
||||
'type' => 'group',
|
||||
'title' => '字体列表',
|
||||
'subtitle' => '使用的文风字体列表',
|
||||
'desc' => '支持添加多个文风字体,并配置应用元素、字体权重大小',
|
||||
'button_title' => '添加字体',
|
||||
'accordion_title_number' => true,
|
||||
'dependency' => [
|
||||
'windfonts',
|
||||
'any',
|
||||
'on,frontend',
|
||||
],
|
||||
'fields' => [
|
||||
[
|
||||
'id' => 'family',
|
||||
'type' => 'text',
|
||||
'title' => __( '字体家族', 'wp-china-yes' ),
|
||||
'subtitle' => '字体家族名称',
|
||||
'desc' => __( '填入从<a href="https://app.windfonts.com//" target="_blank">文风字体</a>获取的字体家族名称',
|
||||
'wp-china-yes' ),
|
||||
'default' => 'wenfeng-syhtcjk',
|
||||
],
|
||||
[
|
||||
'id' => 'css',
|
||||
'type' => 'text',
|
||||
'title' => __( '字体链接', 'wp-china-yes' ),
|
||||
'subtitle' => '字体 CSS 链接',
|
||||
'desc' => __( '填入从<a href="https://app.windfonts.com//" target="_blank">文风字体</a>获取的字体 CSS 链接',
|
||||
'wp-china-yes' ),
|
||||
'default' => 'https://cn.windfonts.com/wenfeng/fonts/syhtcjk/regular/web/index.css',
|
||||
'validate' => 'csf_validate_url',
|
||||
],
|
||||
[
|
||||
'id' => 'weight',
|
||||
'type' => 'number',
|
||||
'title' => __( '字体字重', 'wp-china-yes' ),
|
||||
'subtitle' => '字体字重大小',
|
||||
'desc' => __( '设置字体权重大小(字体粗细)',
|
||||
'wp-china-yes' ),
|
||||
'default' => 400,
|
||||
'attributes' => [
|
||||
'min' => 100,
|
||||
'max' => 1000,
|
||||
'step' => 10,
|
||||
],
|
||||
'validate' => 'csf_validate_numeric',
|
||||
],
|
||||
[
|
||||
'id' => 'style',
|
||||
'type' => 'select',
|
||||
'title' => __( '字体样式', 'wp-china-yes' ),
|
||||
'subtitle' => '字体样式选择',
|
||||
'options' => [
|
||||
'normal' => '正常',
|
||||
'italic' => '斜体',
|
||||
'oblique' => '倾斜',
|
||||
],
|
||||
'desc' => __( '设置字体样式(正常、斜体、倾斜)',
|
||||
'wp-china-yes' ),
|
||||
],
|
||||
[
|
||||
'id' => 'selector',
|
||||
'type' => 'textarea',
|
||||
'title' => __( '字体应用', 'wp-china-yes' ),
|
||||
'subtitle' => '字体应用元素',
|
||||
'desc' => __( '设置字体应用的元素(CSS 选择器)',
|
||||
'wp-china-yes' ),
|
||||
'default' => 'a,p,h1,h2,h3,h4,h5,h6,ul,ol,li,button,blockquote,pre,code,table,th,td,div:not([class*="star"]),label,b,i:not([class]),em,small,strong,sub,sup,ins,del,mark,abbr,dfn,span:not([class*="icon"])',
|
||||
'sanitize' => false,
|
||||
],
|
||||
[
|
||||
'id' => 'enable',
|
||||
'type' => 'switcher',
|
||||
'title' => __( '启用字体', 'wp-china-yes' ),
|
||||
'subtitle' => '是否启用该字体',
|
||||
'default' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'content',
|
||||
'content' => '默认适配规则跟随插件更新,插件更新后可删除字体重新添加以获取最新适配规则',
|
||||
],
|
||||
],
|
||||
] );
|
||||
|
||||
WP_CHINA_YES::createSection( $this->prefix, [
|
||||
'title' => '广告屏蔽',
|
||||
'icon' => 'fa fa-ban',
|
||||
'fields' => [
|
||||
[
|
||||
'id' => 'adblock',
|
||||
'type' => 'radio',
|
||||
'default' => 'on',
|
||||
'title' => __( '广告屏蔽', 'wp-china-yes' ),
|
||||
'inline' => true,
|
||||
'options' => [
|
||||
'on' => '启用',
|
||||
'off' => '不启用',
|
||||
],
|
||||
'default' => 'off',
|
||||
'subtitle' => '是否启用后台广告屏蔽',
|
||||
'desc' => __( '<a href="https://wp-china-yes.com/ads" target="_blank">文派叶子🍃(WP-China-Yes)</a>独家特色功能,让您拥有清爽整洁的 WordPress 后台,清除各类常用插件侵入式后台广告、通知及无用信息',
|
||||
'wp-china-yes' ),
|
||||
],
|
||||
[
|
||||
'id' => 'adblock_rule',
|
||||
'type' => 'group',
|
||||
'title' => '规则列表',
|
||||
'subtitle' => '使用的广告屏蔽规则列表',
|
||||
'desc' => '支持添加多条广告屏蔽规则',
|
||||
'button_title' => '添加规则',
|
||||
'accordion_title_number' => true,
|
||||
'dependency' => [
|
||||
'adblock',
|
||||
'any',
|
||||
'on',
|
||||
],
|
||||
'fields' => [
|
||||
[
|
||||
'id' => 'name',
|
||||
'type' => 'text',
|
||||
'title' => __( '规则名称', 'wp-china-yes' ),
|
||||
'subtitle' => '自定义规则名称',
|
||||
'desc' => __( '自定义规则名称,方便识别',
|
||||
'wp-china-yes' ),
|
||||
'default' => '默认规则',
|
||||
],
|
||||
[
|
||||
'id' => 'selector',
|
||||
'type' => 'textarea',
|
||||
'title' => __( '应用元素', 'wp-china-yes' ),
|
||||
'subtitle' => '规则应用元素',
|
||||
'desc' => __( '设置规则应用的广告元素(CSS 选择器)',
|
||||
'wp-china-yes' ),
|
||||
'default' => '.wpseo_content_wrapper #sidebar-container, .yoast_premium_upsell, #wpseo-local-seo-upsell, .yoast-settings-section-upsell, #rank_math_review_plugin_notice, #bwp-get-social, .bwp-button-paypal, #bwp-sidebar-right, .tjcc-custom-css #postbox-container-1, .settings_page_wpcustomtaxfilterinadmin #postbox-container-1, #duplicate-post-notice #newsletter-subscribe-form, div[id^="dnh-wrm"], .notice-info.dst-notice, #googleanalytics_terms_notice, .fw-brz-dismiss, div.elementor-message[data-notice_id="elementor_dev_promote"], .notice-success.wpcf7r-notice, .dc-text__block.disable__comment__alert, #ws_sidebar_pro_ad, .pa-new-feature-notice, #redux-connect-message, .frash-notice-email, .frash-notice-rate, #smush-box-pro-features, #wp-smush-bulk-smush-upsell-row, #easy-updates-manager-dashnotice, #metaslider-optin-notice, #extendifysdk_announcement, .ml-discount-ad, .mo-admin-notice, .post-smtp-donation, div[data-dismissible="notice-owa-sale-forever"], .neve-notice-upsell, #pagelayer_promo, #simple-custom-post-order-epsilon-review-notice, .sfsi_new_prmium_follw, div.fs-slug-the-events-calendar[data-id="connect_account"], .tribe-notice-event-tickets-install, div.notice[data-notice="webp-converter-for-media"], .webpLoader__popup.webpPopup, .put-dismiss-notice, .wp-mail-smtp-review-notice, #wp-mail-smtp-pro-banner, body div.promotion.fs-notice, .analytify-review-thumbnail, .analytify-review-notice, .jitm-banner.is-upgrade-premium, div[data-name*="wbcr_factory_notice_adverts"], .sui-subscription-notice, #sui-cross-sell-footer, .sui-cross-sell-modules, .forminator-rating-notice, .sui-dashboard-upsell-upsell, .anwp-post-grid__rate, .cff-settings-cta, .cff-header-upgrade-notice, .cff_notice.cff_review_notice_step_1, .cff_get_pro_highlight, .aal-install-elementor, #ws_sidebar_pro_ad, .bold-timeline-lite-feedback-notice-wrapper, #elementskit-lite-go-pro-noti2ce, #elementskit-lite-_plugin_rating_msg_used_in_day, .yarpp-review-notice, #prli_review_notice, #webdados_invoicexpress_nag, #vc_license-activation-notice, .villatheme-dashboard.updated, #njt-FileBird-review, .notice[data-dismissible="pro_release_notice"], #thwvsf_review_request_notice, .wpdeveloper-review-notice, div[data-notice_type="tinvwl-user-review"], div[data-notice_type="tinvwl-user-premium"], #sg-backup-review-wrapper, .notice-wpmet-jhanda-getgenie-cross-promo, .notice-getgenie-go-pro-noti2ce, .notice-wpmet-jhanda-Summer2023, .thwcfd-review-wrapper, .woo-permalink-manager-banner, div.notice.bundle-notice, div.notice[data-dismissible="notice-owa-upgrade-forever"], .wpsm-acc-r-review-notice, .wpsm_ac_h_i, .edac-review-notice, .notice-iworks-rate, #monterinsights-admin-menu-tooltip, .monsterinsights-floating-bar, #monterinsights-admin-menu-tooltip, .exactmetrics-floating-bar, #metform-unsupported-metform-pro-version, .lwptocRate, .wpsm-tabs-b-review-notice, .quadlayers_woocommerce-direct-checkout_notice_delay, .iworks-rate-notice, #metform-_plugin_rating_msg_used_in_day, [id^="wpmet-jhanda-"], #wpmet-stories, #ti-optml-notice-helper, .menu-icon-dashboard-notice, .catch-bells-admin-notice, .wpdt-bundles-notice, .td-admin-web-services, .cf-plugin-popup, .wpzinc-review-media-library-organizer, .oxi-image-notice',
|
||||
'sanitize' => false,
|
||||
],
|
||||
[
|
||||
'id' => 'enable',
|
||||
'type' => 'switcher',
|
||||
'title' => __( '启用规则', 'wp-china-yes' ),
|
||||
'subtitle' => '是否启用该规则',
|
||||
'default' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'content',
|
||||
'content' => '默认屏蔽规则跟随插件更新,插件更新后可删除规则重新添加以获取最新屏蔽规则',
|
||||
],
|
||||
],
|
||||
] );
|
||||
|
||||
WP_CHINA_YES::createSection( $this->prefix, [
|
||||
'title' => '其他设置',
|
||||
'icon' => 'fa fa-cogs',
|
||||
'fields' => [
|
||||
[
|
||||
'id' => 'monitor',
|
||||
'type' => 'switcher',
|
||||
'default' => true,
|
||||
'title' => '节点监控',
|
||||
'subtitle' => '自动监控加速节点可用性',
|
||||
'desc' => __( '<a href="https://wp-china-yes.com/ads" target="_blank">文派叶子🍃(WP-China-Yes)</a>支持自动监控各加速节点可用性,当节点不可用时自动切换至可用节点或关闭加速,以保证您的网站正常访问',
|
||||
'wp-china-yes' ),
|
||||
],
|
||||
[
|
||||
'id' => 'hide',
|
||||
'type' => 'switcher',
|
||||
'default' => false,
|
||||
'title' => '隐藏设置',
|
||||
'subtitle' => '隐藏插件设置入口',
|
||||
'desc' => __( '如果您不希望让客户知道本站启用了<a href="https://wp-china-yes.com/ads" target="_blank">文派叶子🍃(WP-China-Yes)</a>插件及服务,可开启此选项',
|
||||
'wp-china-yes' ),
|
||||
],
|
||||
[
|
||||
'id' => 'custom_name',
|
||||
'type' => 'text',
|
||||
'title' => '品牌白标',
|
||||
'subtitle' => '自定义插件显示品牌名',
|
||||
'desc' => __( '专为 WordPress 建站服务商和代理机构提供的自定义品牌功能,输入您的品牌词启用后生效',
|
||||
'wp-china-yes' ),
|
||||
'default' => "WP-China-Yes",
|
||||
],
|
||||
[
|
||||
'type' => 'content',
|
||||
'content' => '启用隐藏设置前请务必保存当前设置页面 URL,否则您将无法再次进入插件设置页面',
|
||||
],
|
||||
],
|
||||
] );
|
||||
|
||||
WP_CHINA_YES::createSection( $this->prefix, [
|
||||
'title' => '关于插件',
|
||||
'icon' => 'fa fa-info-circle',
|
||||
'fields' => [
|
||||
[
|
||||
'type' => 'heading',
|
||||
'content' => '将您的 WordPress 接入本土生态体系,这将为您提供一个更贴近中国人使用习惯的 WordPress',
|
||||
],
|
||||
[
|
||||
'type' => 'submessage',
|
||||
'content' => '100% 开源代码,一起参与文派(WordPress)软件国产化进程,打造属于您自己的开源自助建站程序',
|
||||
],
|
||||
[
|
||||
'type' => 'subheading',
|
||||
'content' => '项目简介',
|
||||
],
|
||||
[
|
||||
'type' => 'content',
|
||||
'content' => '文派叶子 🍃(WP-China-Yes)是一款不可多得的 WordPress 系统底层优化和生态基础设施软件。项目起源于 2019 年,专为解决困扰了中国互联网数十年的特色问题而存在。此为文派开源(WenPai.org)的一部分',
|
||||
],
|
||||
[
|
||||
'type' => 'subheading',
|
||||
'content' => '赞助商',
|
||||
],
|
||||
[
|
||||
'type' => 'content',
|
||||
'content' =>
|
||||
<<<HTML
|
||||
<div class="card-body sponsor-logos">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/feibisi-logo.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/shujue-logo.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/upyun-logo.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2024/07/haozi-logo.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/wpsaas-logo.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/lingding-logo.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/weixiaoduo-logo-2020.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/modiqi-logo.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/kekechong-logo-1.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/wenpai-logo@2X.png">
|
||||
</div>
|
||||
HTML,
|
||||
],
|
||||
[
|
||||
'type' => 'subheading',
|
||||
'content' => '开发者 & 贡献者',
|
||||
],
|
||||
[
|
||||
'type' => 'content',
|
||||
'content' =>
|
||||
<<<HTML
|
||||
<a href="https://www.ibadboy.net/" target="_blank">孙锡源</a> |
|
||||
<a href="https://github.com/devhaozi/" target="_blank">耗子</a> |
|
||||
<a href="https://github.com/Yulinn233/" target="_blank">Yulinn</a> |
|
||||
<a href="https://github.com/zhaofeng-shu33/" target="_blank">赵丰</a> |
|
||||
<a href="https://github.com/djl0415/" target="_blank">jialong Dong</a> |
|
||||
<a href="https://github.com/k99k5/" target="_blank">TigerKK</a> |
|
||||
<a href="https://github.com/xianyu125/" target="_blank">xianyu125</a> |
|
||||
<a href="https://github.com/ElliotHughes/" target="_blank">ElliotHughes</a> |
|
||||
<a href="https://bbs.weixiaoduo.com/users/feibisi/" target="_blank">诗语</a> |
|
||||
<a href="https://www.modiqi.com/" target="_blank">莫蒂奇</a> |
|
||||
<a href="https://bbs.weixiaoduo.com/users/weixiaoduo/" target="_blank">薇晓朵</a>
|
||||
HTML,
|
||||
]
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
$this->setting_api->set_sections( $sections );
|
||||
$this->setting_api->set_fields( $fields );
|
||||
$this->setting_api->admin_init();
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -137,15 +398,6 @@ class Setting {
|
|||
* 挂载设置页面
|
||||
*/
|
||||
public function admin_menu() {
|
||||
// 后台设置
|
||||
add_submenu_page(
|
||||
is_multisite() ? 'settings.php' : 'options-general.php',
|
||||
esc_html__( 'WP-China-Yes', 'wp-china-yes' ),
|
||||
esc_html__( 'WP-China-Yes', 'wp-china-yes' ),
|
||||
is_multisite() ? 'manage_network_options' : 'manage_options',
|
||||
'wp-china-yes',
|
||||
[ $this, 'setting_page' ]
|
||||
);
|
||||
// 插件页设置
|
||||
add_filter( 'plugin_action_links', function ( $links, $file ) {
|
||||
if ( 'wp-china-yes/wp-china-yes.php' !== $file ) {
|
||||
|
@ -159,76 +411,4 @@ class Setting {
|
|||
return $links;
|
||||
}, 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置页面模版
|
||||
*/
|
||||
public function setting_page() {
|
||||
echo <<<HTML
|
||||
<div class="settings-header">
|
||||
<div class="settings-title-section">
|
||||
<h1>文派叶子🍃(WP-China-Yes)</h1>
|
||||
</div>
|
||||
<h3>将您的 WordPress 接入本土生态体系,这将为您提供一个更贴近中国人使用习惯的 WordPress。</h3>
|
||||
<h4>100% 开源代码,一起参与文派(WordPress)软件国产化进程,打造属于您自己的开源自助建站程序。</h4>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="left-column">
|
||||
HTML;
|
||||
$this->setting_api->show_navigation();
|
||||
$this->setting_api->show_forms();
|
||||
|
||||
echo <<<HTML
|
||||
<div class="settings-footer">
|
||||
<p><strong>提示:</strong>插件会定期检查节点可用性,并在节点不可用时自动切换至可用节点,以保证您的网站正常访问。如您发现设置项被自动切换,可重新设置或关闭自动监控功能。</p>
|
||||
<p><strong>帮助:</strong>您可以随时在此处调整个性化设置以便适应不同的业务场景,萌新请保持默认即可。此项目的发展离不开您的支持和建议,<a href="https://wp-china-yes.com/contact" target="_blank">查看联系方式</a>。</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right-column">
|
||||
<div class="card">
|
||||
<h3>项目简介</h3>
|
||||
<div class="card-body">
|
||||
文派叶子 🍃(WP-China-Yes)是一款不可多得的 WordPress 系统底层优化和生态基础设施软件。项目起源于 2019 年,专为解决困扰了中国互联网数十年的特色问题而存在。此为文派开源(WenPai.org)的一部分。
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a class="button button-primary" href="https://wp-china-yes.com/" target="_blank">了解更多</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>赞助商</h3>
|
||||
<div class="card-body sponsor-logos">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/feibisi-logo.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/shujue-logo.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/upyun-logo.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/wenpai-logo@2X.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/wpsaas-logo.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/lingding-logo.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/weixiaoduo-logo-2020.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/modiqi-logo.png">
|
||||
<img src="https://wp-china-yes.com/wp-content/uploads/2023/08/kekechong-logo-1.png">
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a class="button button-primary" href="https://wp-china-yes.com/about/sponsor" target="_blank">成为赞助商</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>建站套件</h3>
|
||||
<div class="card-body">
|
||||
<ul>
|
||||
<li><a href="https://wenpai.org/plugins/wpicp-license" target="_blank">WPICP License 备案号管理器</a></li>
|
||||
<li><a href="https://wenpai.org/plugins/wpavatar/" target="_blank">WPAvatar 文派头像</a></li>
|
||||
<li><a href="https://wenpai.org/plugins/wpsite-shortcode/" target="_blank">WPSite Shortcode 网站简码</a></li>
|
||||
<li><a href="https://wenpai.org/plugins/wpfanyi-import/" target="_blank">WPfanyi Import 翻译导入器</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a class="button button-primary" href="https://wp-china-yes.com/products" target="_blank">一键安装</a>
|
||||
<a class="button button-primary" href="https://wp-china-yes.com" target="_blank">功能请求</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
HTML;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ class Super {
|
|||
*/
|
||||
if ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
||||
if (
|
||||
! empty( $this->settings['admincdn']['admin'] ) &&
|
||||
in_array( 'admin', (array) $this->settings['admincdn'] ) &&
|
||||
! stristr( $GLOBALS['wp_version'], 'alpha' ) &&
|
||||
! stristr( $GLOBALS['wp_version'], 'beta' ) &&
|
||||
! stristr( $GLOBALS['wp_version'], 'RC' )
|
||||
|
@ -158,7 +158,7 @@ class Super {
|
|||
/**
|
||||
* 前台静态加速
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['frontend'] ) ) {
|
||||
if ( in_array( 'frontend', (array) $this->settings['admincdn'] ) ) {
|
||||
$this->page_str_replace( 'template_redirect', 'preg_replace', [
|
||||
'#(?<=[(\"\'])(?:' . quotemeta( home_url() ) . ')?/(?:((?:wp-content|wp-includes)[^\"\')]+\.(css|js)[^\"\')]+))(?=[\"\')])#',
|
||||
'https://public.admincdn.com/$0'
|
||||
|
@ -168,7 +168,7 @@ class Super {
|
|||
/**
|
||||
* Google 字体替换
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['googlefonts'] ) ) {
|
||||
if ( in_array( 'googlefonts', (array) $this->settings['admincdn'] ) ) {
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'fonts.googleapis.com',
|
||||
'googlefonts.admincdn.com'
|
||||
|
@ -178,7 +178,7 @@ class Super {
|
|||
/**
|
||||
* Google 前端公共库替换
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['googleajax'] ) ) {
|
||||
if ( in_array( 'googleajax', (array) $this->settings['admincdn'] ) ) {
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'ajax.googleapis.com',
|
||||
'googleajax.admincdn.com'
|
||||
|
@ -188,7 +188,7 @@ class Super {
|
|||
/**
|
||||
* CDNJS 前端公共库替换
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['cdnjs'] ) ) {
|
||||
if ( in_array( 'cdnjs', (array) $this->settings['admincdn'] ) ) {
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'cdnjs.cloudflare.com/ajax/libs',
|
||||
'cdnjs.admincdn.com'
|
||||
|
@ -198,9 +198,9 @@ class Super {
|
|||
/**
|
||||
* jsDelivr 前端公共库替换
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['jsdelivr'] ) ) {
|
||||
if ( in_array( 'jsdelivr', (array) $this->settings['admincdn'] ) ) {
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'cdn.jsdelivr.net',
|
||||
'jsd.admincdn.com',
|
||||
'jsd.admincdn.com'
|
||||
] );
|
||||
}
|
||||
|
@ -225,6 +225,85 @@ class Super {
|
|||
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 ( ! empty( $this->settings['adblock'] ) && $this->settings['adblock'] == 'on' ) {
|
||||
add_action( 'admin_head', [ $this, 'load_adblock' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载文风字体
|
||||
*/
|
||||
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_adblock() {
|
||||
foreach ( (array) $this->settings['adblock_rule'] as $rule ) {
|
||||
if ( empty( $rule['enable'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( empty( $rule['selector'] ) ) {
|
||||
continue;
|
||||
}
|
||||
echo sprintf( <<<HTML
|
||||
<style>
|
||||
%s {
|
||||
display: none!important;
|
||||
}
|
||||
</style>
|
||||
HTML
|
||||
,
|
||||
htmlspecialchars_decode( $rule['selector'] )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,129 +1,134 @@
|
|||
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;
|
||||
}
|
||||
|
||||
#wpcontent, #wpfooter {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#wpbody-content {
|
||||
padding-bottom: 10%;
|
||||
}
|
||||
|
||||
.notice {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.sponsor-logos {
|
||||
display: flex;
|
||||
display: block;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.sponsor-logos img {
|
||||
width: 26%;
|
||||
margin-bottom: 30px;
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
height: fit-content;
|
||||
flex-basis: calc(20% - 10px);
|
||||
max-width: 85px;
|
||||
margin: 5px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 782px) {
|
||||
.auto-fold #wpcontent {
|
||||
padding: 10px;
|
||||
}
|
||||
.wp_china_yes-content a {
|
||||
color: #0073aa;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.container {
|
||||
flex-wrap: nowrap;
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
.wp_china_yes-options {
|
||||
background-color: #fff;
|
||||
padding: 1%;
|
||||
border-radius: 10px;
|
||||
text-transform: none;
|
||||
line-height: 2;
|
||||
box-shadow: 0 0.375rem 1.5rem 0 rgba(141, 153, 165, 0.13);
|
||||
max-width: 1100px;
|
||||
margin: 2rem auto;
|
||||
}
|
||||
|
||||
.left-column {
|
||||
width: 70%;
|
||||
.wp_china_yes-section-title {
|
||||
padding: 20px 30px;
|
||||
background-color: #fff;
|
||||
border-top: 0 solid #f5f5f5;
|
||||
border-bottom: 1px solid #f5f5f5;
|
||||
}
|
||||
|
||||
.right-column {
|
||||
width: 30%;
|
||||
.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 #f5f5f5;
|
||||
}
|
||||
|
||||
.wp_china_yes-theme-light .wp_china_yes-footer {
|
||||
border-top: 1px solid #fff;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.wp_china_yes-field-heading {
|
||||
font-size: 1.4em;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.wp_china_yes-theme-light .wp_china_yes-nav ul li a {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.wp_china_yes-submessage-normal {
|
||||
border-color: #ffffff;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.wp_china_yes-field + .wp_china_yes-field {
|
||||
border-top: 1px solid #ffffff;
|
||||
}
|
||||
|
||||
.wp_china_yes-theme-light .wp_china_yes-nav-normal > ul li a {
|
||||
border-bottom: 1px solid #f5f5f5;
|
||||
border-right: 1px solid #f5f5f5;
|
||||
}
|
||||
|
||||
.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: 8px;
|
||||
}
|
||||
|
||||
.wp_china_yes-field-group .wp_china_yes-cloneable-content {
|
||||
border: 0 solid #ffffff;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.wp_china_yes-sticky .wp_china_yes-header-inner {
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, .1);
|
||||
}
|
||||
|
||||
.wp_china_yes-warning-primary {
|
||||
color: #fff !important;
|
||||
border-color: #2c3338 !important;
|
||||
background: #2c3338 !important;
|
||||
}
|
||||
|
||||
.wp_china_yes-warning-primary:focus, .wp_china_yes-warning-primary:hover {
|
||||
border-color: #1d2327 !important;
|
||||
background: #1d2327 !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;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
"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",
|
||||
|
@ -12,7 +11,8 @@
|
|||
"WenPai\\ChinaYes\\": "./"
|
||||
},
|
||||
"files": [
|
||||
"helpers.php"
|
||||
"helpers.php",
|
||||
"framework/classes/setup.class.php"
|
||||
]
|
||||
},
|
||||
"authors": [
|
||||
|
|
46
composer.lock
generated
46
composer.lock
generated
|
@ -4,52 +4,8 @@
|
|||
"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",
|
||||
|
|
1
framework/assets/css/style-rtl.min.css
vendored
Normal file
1
framework/assets/css/style-rtl.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
framework/assets/css/style.min.css
vendored
Normal file
1
framework/assets/css/style.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
framework/assets/images/checkerboard.png
Normal file
BIN
framework/assets/images/checkerboard.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
1
framework/assets/images/wp-logo.svg
Normal file
1
framework/assets/images/wp-logo.svg
Normal 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
Normal file
1
framework/assets/images/wp-plugin-logo.svg
Normal 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
Normal file
2
framework/assets/js/main.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
framework/assets/js/plugins.min.js
vendored
Normal file
2
framework/assets/js/plugins.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
195
framework/classes/abstract.class.php
Normal file
195
framework/classes/abstract.class.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
667
framework/classes/admin-options.class.php
Normal file
667
framework/classes/admin-options.class.php
Normal file
|
@ -0,0 +1,667 @@
|
|||
<?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 );
|
||||
}
|
||||
|
||||
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">';
|
||||
echo '<h1>'. $this->args['framework_title'] .'</h1>';
|
||||
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>';
|
||||
|
||||
}
|
||||
|
||||
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="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
Normal file
405
framework/classes/fields.class.php
Normal 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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
800
framework/classes/setup.class.php
Normal file
800
framework/classes/setup.class.php
Normal file
|
@ -0,0 +1,800 @@
|
|||
<?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' );
|
||||
}
|
||||
|
||||
// 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
Normal file
64
framework/fields/accordion/accordion.php
Normal 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
Normal file
340
framework/fields/background/background.php
Normal 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
Normal file
38
framework/fields/backup/backup.php
Normal 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
Normal file
176
framework/fields/border/border.php
Normal 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
Normal file
67
framework/fields/button_set/button_set.php
Normal 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
Normal file
31
framework/fields/callback/callback.php
Normal 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
Normal file
101
framework/fields/checkbox/checkbox.php
Normal 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
Normal file
58
framework/fields/code_editor/code_editor.php
Normal 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
Normal file
52
framework/fields/color/color.php
Normal 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
Normal file
42
framework/fields/color_group/color_group.php
Normal 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
Normal file
28
framework/fields/content/content.php
Normal 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
Normal file
64
framework/fields/date/date.php
Normal 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
Normal file
61
framework/fields/datetime/datetime.php
Normal 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
Normal file
101
framework/fields/dimensions/dimensions.php
Normal 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
Normal file
41
framework/fields/fieldset/fieldset.php
Normal 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
Normal file
52
framework/fields/gallery/gallery.php
Normal 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
Normal file
164
framework/fields/group/group.php
Normal 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
Normal file
24
framework/fields/heading/heading.php
Normal 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
Normal file
12
framework/fields/icon/fa4-icons.php
Normal file
File diff suppressed because one or more lines are too long
12
framework/fields/icon/fa5-icons.php
Normal file
12
framework/fields/icon/fa5-icons.php
Normal file
File diff suppressed because one or more lines are too long
71
framework/fields/icon/icon.php
Normal file
71
framework/fields/icon/icon.php
Normal 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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
79
framework/fields/image_select/image_select.php
Normal file
79
framework/fields/image_select/image_select.php
Normal 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
Normal file
1
framework/fields/index.php
Normal file
|
@ -0,0 +1 @@
|
|||
<?php // Silence is golden.
|
82
framework/fields/link/link.php
Normal file
82
framework/fields/link/link.php
Normal 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
Normal file
91
framework/fields/link_color/link_color.php
Normal 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
Normal file
98
framework/fields/map/map.php
Normal 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
Normal file
96
framework/fields/media/media.php
Normal 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
Normal file
26
framework/fields/notice/notice.php
Normal 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
Normal file
63
framework/fields/number/number.php
Normal 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
Normal file
58
framework/fields/palette/palette.php
Normal 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
Normal file
93
framework/fields/radio/radio.php
Normal 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
Normal file
108
framework/fields/repeater/repeater.php
Normal 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
Normal file
132
framework/fields/select/select.php
Normal 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
Normal file
78
framework/fields/slider/slider.php
Normal 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
Normal file
87
framework/fields/sortable/sortable.php
Normal 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
Normal file
76
framework/fields/sorter/sorter.php
Normal 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
Normal file
171
framework/fields/spacing/spacing.php
Normal 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
Normal file
70
framework/fields/spinner/spinner.php
Normal 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
Normal file
24
framework/fields/subheading/subheading.php
Normal 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
Normal file
26
framework/fields/submessage/submessage.php
Normal 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
Normal file
40
framework/fields/switcher/switcher.php
Normal 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
Normal file
64
framework/fields/tabbed/tabbed.php
Normal 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
Normal file
30
framework/fields/text/text.php
Normal 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
Normal file
58
framework/fields/textarea/textarea.php
Normal 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
Normal file
1607
framework/fields/typography/google-fonts.php
Normal file
File diff suppressed because it is too large
Load diff
544
framework/fields/typography/typography.php
Normal file
544
framework/fields/typography/typography.php
Normal 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
Normal file
61
framework/fields/upload/upload.php
Normal 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
Normal file
107
framework/fields/wp_editor/wp_editor.php
Normal 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
Normal file
190
framework/functions/actions.php
Normal 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 );
|
||||
|
||||
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
Normal file
142
framework/functions/customize.php
Normal 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
Normal file
58
framework/functions/helpers.php
Normal 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
Normal file
29
framework/functions/sanitize.php
Normal 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
Normal file
152
framework/functions/validate.php
Normal 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
Normal file
28
framework/functions/walker.php
Normal 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
Normal file
1
framework/index.php
Normal file
|
@ -0,0 +1 @@
|
|||
<?php // Silence is golden.
|
BIN
framework/languages/zh_CN.mo
Normal file
BIN
framework/languages/zh_CN.mo
Normal file
Binary file not shown.
672
framework/languages/zh_CN.po
Normal file
672
framework/languages/zh_CN.po
Normal 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/"
|
10
helpers.php
10
helpers.php
|
@ -10,12 +10,14 @@ function get_settings() {
|
|||
|
||||
return wp_parse_args( $settings, [
|
||||
'store' => 'wenpai',
|
||||
'admincdn' => [
|
||||
'admin' => 'admin',
|
||||
],
|
||||
'admincdn' => [ 'admin' ],
|
||||
'cravatar' => 'cn',
|
||||
'windfonts' => 'off',
|
||||
'windfonts_list' => [],
|
||||
'adblock' => 'off',
|
||||
'monitor' => 'on',
|
||||
'adblock_rule' => [],
|
||||
'monitor' => true,
|
||||
'hide' => false,
|
||||
'custom_name' => 'WP-China-Yes',
|
||||
] );
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Description: 文派叶子 🍃(WP-China-Yes)是中国 WordPress 生态基础设施软件,犹如落叶新芽,生生不息。
|
||||
* Author: 文派开源
|
||||
* Author URI: https://wp-china-yes.com
|
||||
* Version: 3.6.5
|
||||
* Version: 3.7.0
|
||||
* License: GPLv3 or later
|
||||
* Text Domain: wp-china-yes
|
||||
* Domain Path: /languages
|
||||
|
@ -19,7 +19,7 @@ namespace WenPai\ChinaYes;
|
|||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
define( 'CHINA_YES_VERSION', '3.6.5' );
|
||||
define( 'CHINA_YES_VERSION', '3.7.0' );
|
||||
define( 'CHINA_YES_PLUGIN_FILE', __FILE__ );
|
||||
define( 'CHINA_YES_PLUGIN_URL', plugin_dir_url( CHINA_YES_PLUGIN_FILE ) );
|
||||
define( 'CHINA_YES_PLUGIN_PATH', plugin_dir_path( CHINA_YES_PLUGIN_FILE ) );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue