| Server IP : 43.141.49.92 / Your IP : 113.219.202.141 Web Server : Apache System : Linux VM-8-5-opencloudos 6.6.34-9.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 19 19:35:45 CST 2024 x86_64 User : www ( 1000) PHP Version : 8.1.27 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/wwwroot/www.ucppt.com/wp-content/plugins/wpcom-member-pro/includes/ |
Upload File : |
<?php defined( 'ABSPATH' ) || exit;
use WPCOM\Member;
use WPCOM\Themer\Session;
add_action('after_setup_theme', 'WPCOM_MP_init');
function WPCOM_MP_init() {
if(defined('WPMX_VERSION')){
add_action('admin_enqueue_scripts', 'WPCOM_MP_scripts');
if ($GLOBALS['wpcom_mp']->is_active()) {
$options = $GLOBALS['wpmx_options'];
if (!function_exists('wpcom_setup') || !(method_exists('WPCOM', 'load_file') && WPCOM::load_file(FRAMEWORK_PATH . '/includes/follow.php'))) {
if(apply_filters( 'wpcom_member_show_profile', true ) && (!isset($options['member_group_on']) || (isset($options['member_group_on']) && $options['member_group_on']=='1'))) {
require_once WPCOM_MP_DIR . 'includes/user-groups.php';
new Member\User_Groups();
}
if( isset($options['member_follow']) && $options['member_follow']=='1' && file_exists(WPCOM_MP_DIR . 'includes/follow.php') ) {
require_once WPCOM_MP_DIR . 'includes/follow.php';
new Member\Follow();
}
if( isset($options['member_messages']) && $options['member_messages']=='1' && file_exists(WPCOM_MP_DIR . 'includes/messages.php') ) {
require_once WPCOM_MP_DIR . 'includes/messages.php';
new Member\Messages();
}
if( isset($options['member_notify']) && $options['member_notify']=='1' && file_exists(WPCOM_MP_DIR . 'includes/notifications.php') ) {
require_once WPCOM_MP_DIR . 'includes/notifications.php';
$GLOBALS['_notification'] = new Member\Notifications();
}
}
require_once WPCOM_MP_DIR . 'includes/orders.php';
require_once WPCOM_MP_DIR . 'includes/premium-content.php';
if(!class_exists('WPCOM_Hidden_Content') && !class_exists(Member\Hidden_Content::class)) require_once WPCOM_MP_DIR . 'includes/hidden-content.php';
require_once WPCOM_MP_DIR . 'includes/premium-download.php';
require_once WPCOM_MP_DIR . 'includes/virtual-service.php';
require_once WPCOM_MP_DIR . 'includes/copy-post.php';
if(isset($options['cards_on']) && $options['cards_on'] == '1'){
require_once WPCOM_MP_DIR . 'includes/cards.php';
}
if(isset($options['invitation_code']) && $options['invitation_code'] == '1'){
require_once WPCOM_MP_DIR . 'includes/invitation-code.php';
}
require_once WPCOM_MP_DIR . 'includes/vip.php';
require_once WPCOM_ADMIN_PATH . 'includes/class-widget.php';
require_once WPCOM_MP_DIR . 'widgets/vip.php';
require_once WPCOM_MP_DIR . 'widgets/premium-download.php';
if(isset($options['wallet_on']) && $options['wallet_on'] == '1'){
require_once WPCOM_MP_DIR . 'includes/wallet.php';
}
if(isset($options['points_on']) && $options['points_on'] == '1'){
require_once WPCOM_MP_DIR . 'includes/points.php';
}
if(isset($options['aff']) && $options['aff'] == '1'){
require_once WPCOM_MP_DIR . 'includes/affiliate.php';
}
require_once WPCOM_MP_DIR . 'includes/overview.php';
add_action('wp_enqueue_scripts', 'WPCOM_MP_scripts');
add_action('embed_head', 'WPCOM_MP_scripts');
add_action('admin_init', 'WPCOM_MP_gutenberg_blocks');
WPCOM_MP_init_payment();
}
}else{
add_action( 'admin_notices', 'WPCOM_MP_install_plugin' );
}
load_plugin_textdomain( WPCMP_TD, false, basename( WPCOM_MP_DIR ) . '/lang' );
add_filter('block_categories_all', 'WPCOM_MP_block_categories', 20);
}
add_filter('wpmx_localize_script', function($data){
$data['pro_ver'] = WPCOM_MP_VERSION;
return $data;
});
function WPCOM_MP_block_categories($categories) {
$exist = 0;
if($categories){
foreach($categories as $cat){
if($cat && $cat['slug'] && $cat['slug'] === WPCMP_TD){
$exist = 1;
break;
}
}
}
if(!$exist){
$categories = array_merge(
$categories,
array(
array(
'slug' => WPCMP_TD,
'title' => __('WPCOM扩展区块', WPCMP_TD)
),
)
);
}
return $categories;
}
function WPCOM_MP_install_plugin(){
$class = 'notice notice-warning is-dismissible';
$message = '<b>WPCOM用户中心高级版</b>插件基于<b>WPCOM用户中心</b>插件实现,请先安装好依赖插件,具体下载和安装请参考文档:<a href="https://www.wpcom.cn/docs/member-pro" target="_blank">https://www.wpcom.cn/docs/member-pro</a>';
printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), $message);
}
add_filter('wpcom_init_plugin_options', 'WPCOM_MP_init_options');
function WPCOM_MP_init_options($options){
if(function_exists('wpcom_setup') && $options['plugin-slug'] === 'wpcom-member-pro' && empty($options['options'])){
$options['options'] = $GLOBALS['options'];
}else if($options['plugin-slug'] === 'wpcom-member-pro' && !($options['options'] && isset($options['options']['help_url']))){
$o = get_option('wpcom_mp_options');
if($o) {
$o = is_string($o) ? json_decode($o, true) : $o;
$options['options'] = is_array($options['options']) ? $options['options'] : [];
if($o) $options['options'] = array_merge($options['options'], $o);
}
}
return $options;
}
function WPCOM_MP_scripts(){
$action = current_filter();
if ($action === 'wp_enqueue_scripts') {
wp_enqueue_script('wpcom-member-pro', WPCOM_MP_URI . 'js/index.js', array('jquery'), WPCOM_MP_VERSION, true);
wp_enqueue_style('wpcom-member-pro', WPCOM_MP_URI . 'css/style.css', array(), WPCOM_MP_VERSION);
}else if ($action === 'embed_head') {
wp_enqueue_style('wpcom-member-pro', WPCOM_MP_URI . 'css/style.css', array(), WPCOM_MP_VERSION);
}else{
wp_enqueue_style('wpcom-member-pro', WPCOM_MP_URI . 'css/admin.css', array(), WPCOM_MP_VERSION);
}
}
function WPCOM_MP_gutenberg_blocks(){
wp_register_script('wpcom-member-blocks', WPCOM_MP_URI . 'js/blocks.js', array('wp-blocks', 'wp-element', 'wp-components'), WPCOM_MP_VERSION, true);
wp_register_style('wpcom-member-blocks', WPCOM_MP_URI . 'css/blocks.css', array('wp-edit-blocks'), WPCOM_MP_VERSION);
wp_localize_script('wpcom-member-blocks', '_wpcom_member_blocks', apply_filters('wpcom_blocks_script', array('exclude' => array())));
register_block_type('wpcom/member-blocks', array(
'editor_script' => 'wpcom-member-blocks',
'editor_style' => 'wpcom-member-blocks'
));
}
add_filter('wpcom_blocks_script', function($blocks){
wp_enqueue_script('lodash');
$blocks['exclude_widgets'] = isset($blocks['exclude_widgets']) ? $blocks['exclude_widgets'] : array();
$blocks['exclude_widgets'] = array_merge($blocks['exclude_widgets'], array('wpcom/premium-content', 'wpcom/premium-download', 'wpcom/hidden-download', 'wpcom/hidden-content', 'wpcom/virtual-service'));
return $blocks;
});
function WPCOM_MP_init_payment(){
add_filter('wpcom_payment_gateways', 'WPCOM_MP_init_payment_config', 99);
include_once WPCOM_MP_DIR . 'payment/payment.php';
include_once WPCOM_MP_DIR . 'payment/alipay.php';
include_once WPCOM_MP_DIR . 'payment/wxpay.php';
include_once WPCOM_MP_DIR . 'payment/wxpay-xunhu.php';
include_once WPCOM_MP_DIR . 'payment/alipay-xunhu.php';
include_once WPCOM_MP_DIR . 'payment/yzf.php';
include_once WPCOM_MP_DIR . 'payment/wallet.php';
include_once WPCOM_MP_DIR . 'payment/paypal.php';
if(wpcom_mp_options('points_on') == '1'){
include_once WPCOM_MP_DIR . 'payment/points.php';
}
if(class_exists('WC_Payment_Gateway') && get_current_user_id() && wpcom_mp_options('wallet_on') == '1'){
include_once WPCOM_MP_DIR . 'payment/wallet-woo.php';
new Member\Payments\Wallet_Woo();
}
}
function WPCOM_MP_init_payment_config($gateways){
$payment_gateways = wpcom_mp_options('payment_gateways');
if($payment_gateways){
$_gateways = array();
foreach($payment_gateways as $index => $api){
if(isset($gateways[$api]) && $gateways[$api]) {
$_gateways[$api] = $gateways[$api];
if(method_exists($_gateways[$api], 'init')) $_gateways[$api]->init($index);
}
}
}
if(wpcom_mp_options('wallet_on') == '1' && isset($gateways['wallet']) && $gateways['wallet']){
$_gateways['wallet'] = $gateways['wallet'];
}
if(wpcom_mp_options('points_on') == '1' && isset($gateways['points']) && $gateways['points']){
$_gateways['points'] = $gateways['points'];
}
return $_gateways;
}
function wpcom_mp_options($key){
global $wpmx_options;
if(!$wpmx_options) $wpmx_options = get_option('wpmx_options');
if($key && isset($wpmx_options[$key])){
return $wpmx_options[$key];
}
return '';
}
add_filter('wpcom_get_settings_for_wpmx_options', 'WPCOM_MP_filter_settings');
function WPCOM_MP_filter_settings($settings){
$res = array();
if($settings){
foreach($settings as $k => $v){
if(in_array($k, array('dl_tpl_id', 'dl_tpl_name', 'dl_tpl_key', 'dl_tpl_val'))){
$res[$k] = $v;
}
}
}
return $res;
}
if(!function_exists('wpcom_sms_code_items')){
add_filter( 'wpcom_sms_code_items', 'wpcom_sms_code_items' );
function wpcom_sms_code_items($items){
$items += array(
10 => array(
'type' => 'text',
'label' => _x('Phone number', 'label', WPCMP_TD),
'icon' => 'phone',
'name' => 'user_phone',
'require' => true,
'validate' => 'phone',
'placeholder' => _x('Phone number', 'placeholder', WPCMP_TD),
),
20 => array(
'type' => wpcom_member_captcha_type()
),
30 => array(
'type' => 'smsCode',
'label' => _x('Verification code', 'label', WPCMP_TD),
'name' => 'sms_code',
'icon' => 'shield-check',
'validate' => 'sms_code:user_phone',
'target' => 'user_phone',
'require' => true,
'placeholder' => _x('Please enter your verification code', 'placeholder', WPCMP_TD)
)
);
return $items;
}
add_action( 'wp_ajax_wpcom_send_sms_code', function_exists('wpmx_send_sms_code') ? 'wpmx_send_sms_code' : 'wpcom_send_sms_code' );
add_action( 'wp_ajax_nopriv_wpcom_send_sms_code', function_exists('wpmx_send_sms_code') ? 'wpmx_send_sms_code' : 'wpcom_send_sms_code' );
function wpcom_send_sms_code(){
$res = array();
$res['result'] = 1; // 0:发送失败;1:发送成功;-1:nonce校验失败;-2:滑动解锁验证失败;-3:请先滑动解锁
$res['error'] = '';
$errors = apply_filters( 'wpcom_member_errors', array() );
$msg = array(
'0' => __( 'Failed to send', WPCMP_TD ),
'1' => __('Send success', WPCMP_TD),
'-1' => $errors['nonce'],
'-2' => $errors['captcha_fail'],
'-3' => $errors['captcha_verify']
);
if( (isset($_POST['member_form_accountbind_nonce']) && isset($_POST['user_email'])) ||
(isset($_POST['member_form_account_change_bind_nonce']) && isset($_POST['type']) && $_POST['type']=='email') ){
$filter = 'wpcom_email_code_items';
}else{
$filter = 'wpcom_sms_code_items';
}
$items = apply_filters($filter, array());
$target = 'user_phone';
if($items){
foreach ($items as $item){
if($item['type']==='smsCode'){
$target = $item['target'];
break;
}
}
}
if( isset($_POST['member_form_smscode_nonce'])){ // 找回密码的验证短信
$_POST[$target] = Session::get('lost_password_phone');
}
if( isset($_POST['member_form_account_change_bind_nonce'])){ // 更换绑定安全验证短信
$user = wp_get_current_user();
$_POST[$target] = isset($_POST['type']) && $_POST['type']=='phone' ? $user->mobile_phone : $user->user_email;
}
$res = wpcom_form_validate( $res, 'send_sms_code', $filter );
if ($res['result'] == 1) {
if(is_email($_POST[$target])){
if(!wpcom_send_email_code($_POST[$target])){
$res['result'] = 0;
$res['error'] = __('Failed to send email', WPCMP_TD);
}
}else{
$send = wpcom_sms_code_sender($_POST[$target], isset($_POST['user_phone_country']) ? $_POST['user_phone_country'] : '');
if($send->result !== 0){ // 发送失败
$res['result'] = 0;
$res['error'] = $send->errmsg;
}
}
if($res['result'] == 1){
if(isset($_POST['ticket'])){
$ticket = sanitize_text_field($_POST['ticket']);
$randstr = sanitize_text_field($_POST['randstr']);
$last_ticket = $ticket . '+' . $randstr;
}else if(isset($_POST['csessionid'])){
$csessionid = sanitize_text_field($_POST['csessionid']);
$token = sanitize_text_field($_POST['token']);
$sig = sanitize_text_field($_POST['sig']);
$scene = sanitize_text_field($_POST['scene']);
$last_ticket = $csessionid . '+' . $token . '+' . $sig . '+' . $scene;
}else if(isset($_POST['h-captcha-response'])){
$last_ticket = sanitize_text_field($_POST['h-captcha-response']);
}else if(isset($_POST['g-recaptcha-response'])){
$last_ticket = sanitize_text_field($_POST['g-recaptcha-response']);
}else if(isset($_POST['verify-key'])){
$last_ticket = sanitize_text_field($_POST['verify-key']);
}
if(isset($last_ticket)) Session::set('last_ticket', $last_ticket);
}
}
if ( $res['error'] == '' && isset($msg[$res['result']]) ) $res['error'] = $msg[$res['result']];
wp_send_json($res);
}
// 找回密码的短信验证码验证
add_action( 'wp_ajax_wpcom_smscode', 'wpcom_smscode' );
add_action( 'wp_ajax_nopriv_wpcom_smscode', 'wpcom_smscode' );
function wpcom_smscode(){
$res = array();
$res['result'] = 1; // 0:验证失败;1:验证成功;-1:nonce校验失败;-2:滑动解锁验证失败;-3:请先滑动解锁
$res['error'] = '';
$errors = apply_filters( 'wpcom_member_errors', array() );
$msg = array(
'0' => __('verification failed', WPCMP_TD),
'1' => __('Verified successfully', WPCMP_TD),
'-1' => $errors['nonce'],
'-2' => $errors['captcha_fail'],
'-3' => $errors['captcha_verify']
);
$items = apply_filters('wpcom_sms_code_items', array());
$target = 'user_phone';
if($items){
foreach ($items as $item){
if($item['type']==='smsCode'){
$target = $item['target'];
break;
}
}
}
if( isset($_POST['member_form_smscode_nonce'])){ // 找回密码的验证短信
$_POST[$target] = Session::get('lost_password_phone');
}
$res = wpcom_form_validate( $res, 'member_form_smscode', 'wpcom_sms_code_items' );
$res = apply_filters( 'wpcom_smscode_form_validate', $res );
if ($res['result'] == 1) {
Session::delete('', 'code_'.sanitize_text_field($_POST[$target]));
Session::delete('', 'lost_password_phone');
$args = array(
'meta_key' => 'mobile_phone',
'meta_value' => sanitize_text_field($_POST[$target]),
);
$users = get_users($args);
$user = $users[0];
$user_login = $user->user_login;
$key = get_password_reset_key( $user );
$url = add_query_arg( array(
'subpage' => 'reset',
'key' => $key,
'login' => rawurlencode( $user_login )
), wpcom_lostpassword_url() );
$res['redirect_to'] = $url;
}
if ( $res['error'] == '' && isset($msg[$res['result']]) ) $res['error'] = $msg[$res['result']];
wp_send_json($res);
}
}
if(!function_exists('wpcom_sms_code_sender')){
function wpcom_sms_code_sender( $phone, $nationCode='86' ){
$options = $GLOBALS['wpmx_options'];
if($phone){
$api = isset($options['sms_api']) && $options['sms_api'] ? $options['sms_api'] : 0;
$code = wpcom_generate_sms_code($phone);
$nationCode = preg_replace('/^\+/', '', $nationCode);
/**
* 可通过此 hook 自定义短信发送接口
* @param string $phone 手机号码
* @param string $code 验证码
* @param string $nationCode 国家代码
*
* @return object {result:0, errmsg: '发送成功'} result = 0 表示发送成功,如发送失败可通过 errmsg 返回错误信息
*/
$sender = apply_filters('wpcom_sms_code_sender', null, $phone, $code, $nationCode);
if($sender !== null) return $sender;
if($api == '0'){
include_once WPCOM_MP_DIR . 'sdk/qcloudsms/index.php';
$params = [$code, function_exists('wpcom_sms_code_expire') ? wpcom_sms_code_expire(false) : 10];
return wpcom_qcloud_sms_sender($phone, $params, $nationCode);
}else if($api == '1'){
include_once WPCOM_MP_DIR . 'sdk/dysmsapi.php';
$sms = new Dysmsapi();
return $sms->send($phone, $code, $nationCode);
}else if($api == '2'){
include_once WPCOM_MP_DIR . 'sdk/dypnsapi.php';
$sms = new Dypnsapi();
return $sms->send($phone, $code, $nationCode);
}
}
}
}
if(!function_exists('wpcom_get_scan_login_info')){
function wpcom_get_scan_login_info(){
$options = $GLOBALS['wpmx_options'];
if(wp_is_mobile()) return false;
$social_login_on = isset($options['social_login_on']) && $options['social_login_on']=='1';
$scan_login = $social_login_on && isset($options['scan_login']) && $options['scan_login'] ? $options['scan_login'] : 0;
if($scan_login){
$socials = apply_filters( 'wpcom_socials', array() );
$method = '';
foreach ($socials as $s){
if(isset($s['icon']) && $s['icon'] === 'wechat'){
$method = $s;
break;
}
}
if($method){
return array(
'type' => $scan_login,
'api' => $method
);
}
}
return false;
}
}
add_filter('wpmx_admin_options', 'WPCOM_MP__add_member_options', 10);
function WPCOM_MP__add_member_options($options){
if(function_exists('wpcom_setup')) {
if(!WPCOM::load_file(FRAMEWORK_PATH . '/includes/follow.php')){
$show_profile = apply_filters( 'wpcom_member_show_profile', true );
if($options){
$_options = array();
foreach($options as $option){
if(isset($option['name']) && $option['name'] === '_member_page'){
if($show_profile){
$_options[]= array(
'name' => 'member_group_on',
'title' => '开启用户分组',
'desc' => '是否启用用户分组功能',
'std' => '1',
'type' => 't'
);
$_options[]= array(
'name' => 'member_group',
'filter' => 'member_group_on:1',
'title' => '默认分组',
'desc' => '用户注册后默认的用户分组,用户分组可以到后台【用户>用户分组】下创建管理',
'type' => 'cs',
'tax' => 'user-groups'
);
}
$_options[] = array(
'name' => 'member_follow',
'title' => '用户关注',
'std' => '1',
'type' => 't'
);
$_options[] = array(
'name' => 'member_messages',
'title' => '私信功能',
'std' => '1',
'type' => 't'
);
$_options[] = array(
'name' => 'member_notify',
'title' => '系统通知',
'std' => '1',
'type' => 't'
);
$_options[] = $option;
}else{
$_options[] = $option;
}
}
$options = $_options;
}
}
return $options;
}
if($options){
$_options = array();
$show_profile = apply_filters( 'wpcom_member_show_profile', true );
foreach($options as $option){
if($show_profile && isset($option['name']) && $option['name'] === '_member_page'){
$_options[]= array(
'name' => 'member_group_on',
'title' => '开启用户分组',
'desc' => '是否启用用户分组功能',
'std' => '1',
'type' => 't'
);
$_options[]= array(
'name' => 'member_group',
'filter' => 'member_group_on:1',
'title' => '默认分组',
'desc' => '用户注册后默认的用户分组,用户分组可以到后台【用户>用户分组】下创建管理',
'type' => 'cs',
'tax' => 'user-groups'
);
$_options[] = array(
'name' => 'member_follow',
'title' => '用户关注',
'std' => '1',
'type' => 't'
);
$_options[] = array(
'name' => 'member_messages',
'title' => '私信功能',
'std' => '1',
'type' => 't'
);
$_options[] = array(
'name' => 'member_notify',
'title' => '系统通知',
'std' => '1',
'type' => 't'
);
$_options[] = $option;
}else if(isset($option['name']) && $option['name'] === 'login_redirect'){
$_options[] = array(
'name' => 'captcha_images',
'filter' => 'member_captcha:9',
'title' => '人机验证拼图',
'desc' => '推荐尺寸/比例:<b>390*200</b>,最多可设置<b>20张</b>图片,不设置则默认调用<b>Unsplash</b>随机图片,由于网络问题可能偶尔会有请求较慢的情况,还是建议自己设置<br><b>温馨提示:</b>如果网站图片使用了<b>CDN/云储存</b>等方式导致图片使用独立(子)域名的情况会有跨域问题,需要为HTTP响应头添加 <code>Access-Control-Allow-Origin: *</code>,参考<a href="https://www.wpcom.cn/help/161.html" target="_blank">这篇教程【<b>解决办法-跨域问题</b>】</a>部分说明',
'type' => 'at',
'limit' => 20
);
$_options[] = $option;
$_options = array_merge($_options, array(
array(
'l' => '手机注册',
't' => 'tt'
),
array(
'n' => 'enable_phone',
'l' => '开启手机注册',
't' => 't'
),
array(
'n' => 'phone_compatible',
'f' => 'enable_phone:0',
'l' => '兼容手机登录',
'd' => '如果之前开启过手机注册登录功能,关闭后默认将无法再使用原先手机号进行登录,开启兼容后可使用手机号作为用户名登录',
't' => 't'
),
array(
't' => 'w',
'f' => 'enable_phone:1',
'o' => array(
array(
'n' => 'sms_login',
'l' => '手机快捷登录',
'd' => '使用手机短信验证码快捷登录',
't' => 'r',
'ux' => 1,
's' => '0',
'o' => array(
'0' => '不启用',
'1' => '启用',
'2' => '启用并优先使用快捷登录'
)
),
array(
'n' => 'sms_api',
'l' => '短信接口',
't' => 'r',
'ux' => 1,
's' => '0',
'o' => array(
'0' => '腾讯云',
'1' => '阿里云·短信服务',
'2' => '阿里云·短信认证服务(个人可用)'
)
),
array(
't' => 'w',
'f' => 'sms_api:0',
'o' => array(
array(
'l' => '腾讯云短信接口',
't' => 'tt'
),
array(
'n' => 'qcloud_sms_appid',
'l' => 'AppID'
),
array(
'n' => 'qcloud_sms_appkey',
'l' => 'App Key'
),
array(
'n' => 'qcloud_sms_tid',
'l' => '短信模板ID',
'd' => '短信正文模板的ID,短信正文有两个参数,分别是<b>{1}:验证码,{2}:验证码有效分钟数</b>,如果参数错误会提示<b>package format error, template params error</b>'
),
array(
'n' => 'qcloud_sms_sign',
'l' => '短信签名'
)
)
),
array(
't' => 'w',
'f' => 'sms_api:1,sms_api:2',
'o' => array(
array(
'l' => '阿里云短信接口',
't' => 'tt'
),
array(
'n' => 'aliyun_sms_keyid',
'l' => 'AccessKey Id'
),
array(
'n' => 'aliyun_sms_secret',
'l' => 'AccessKey Secret'
),
array(
'n' => 'aliyun_sms_tcode',
'l' => '模版CODE',
'd' => '短信模版内容有1个参数:<b>${code}</b>,表示验证码,如果使用短信认证接口默认有${code}和${min}两个参数,分别是验证码和验证码有效分钟数'
),
array(
'n' => 'aliyun_sms_sign',
'l' => '签名名称'
)
)
)
)
),
));
}else if(isset($option['filter']) && $option['filter'] === 'social_login_on:1'){
$option['options'][] = array(
'name' => 'scan_login',
'title' => '扫码登录',
'std' => '0',
'type' => 'r',
'ux' => 1,
'desc' => '登录框右上角可切换扫码登录,此功能基于<b>微信登录</b>实现,请确保社交登录方式有微信登录接口',
'options' => array(
'0' => '不开启',
'1' => '开启',
'2' => '开启并设为默认'
)
);
foreach($option['options'] as $x => $o){
if(isset($o['name']) && $o['name'] === '_social_login' && isset($option['options'][$x]['options'])){
$option['options'][$x]['options'][] = array(
'type' => 'w',
'filter' => 'sl_type:wechat2',
'name'=> 'sl_w',
'options' => array(
array(
'name' => 'sl_wechat_follow',
'title' => '扫码关注登录',
'desc' => '开启将使用扫码关注公众号的方式登录;<b>此方式无法获取昵称、头像,请谨慎开启</b>',
'type' => 't'
),
array(
'name' => 'sl_wechat2_type',
'title' => '公众号类型',
'filter' => 'sl_wechat_follow:1',
'desc' => '认证服务号可直接扫码关注登录,订阅号或未认证公众号关注后可发送关键词获取验证码进行登录',
'type' => 'r',
'ux' => 1,
'o' => array(
'0' => '认证服务号',
'1' => '订阅号或未认证公众号'
)
),
array(
'name' => 'sl_wechat2_qr',
'filter' => 'sl_wechat_follow:1&&sl_wechat2_type:1',
'title' => '公众号二维码',
't' => 'at'
),
array(
'name' => 'sl_wechat2_keyword',
'filter' => 'sl_wechat_follow:1&&sl_wechat2_type:1',
'title' => '登录回复关键词',
'd' => '发送此关键词可获取登录验证码,不填写默认为“登录”'
),
array(
'name' => 'sl_wechat2_code',
'filter' => 'sl_wechat_follow:1&&sl_wechat2_type:1',
'title' => '验证码回复消息',
'd' => '回复关键词后下发给用户的验证码消息内容,可以配置两个参数,分别是:<b>%CODE%</b>:验证码;<b>%TIME%</b>:验证码有效分钟数<br>不填写默认为:验证码:%CODE%。此验证码只用于网站登录,请勿转发他人,%TIME%分钟内有效。',
't' => 'ta',
),
array(
'name' => 'sl_wechat2_aeskey',
'filter' => 'sl_wechat_follow:1',
'title' => '消息加解密密钥(EncodingAESKey)',
'desc' => '可在公众号后台 设置与开发>基本配置>服务器配置 下设置获取'
),
array(
'name' => 'sl_wechat2_welc',
'filter' => 'sl_wechat_follow:1&&sl_wechat2_type:0',
'title' => '公众号端登录提示',
'type' => 'ta',
'desc' => '如需添加链接请使用a标签添加,例如:<a href="链接地址">链接文本</a>'
)
)
);
}
}
$_options[] = $option;
}else{
$_options[] = $option;
}
}
$options = $_options;
}
return $options;
}
add_filter( 'wpcom_socials', 'WPCOM_MP__socials_wechat_follow' );
function WPCOM_MP__socials_wechat_follow( $social ){
if(function_exists('wpcom_setup')) return $social;
$options = $GLOBALS['wpmx_options'];
if(!empty($social )){
$_social = array();
foreach($social as $item){
if($item && isset($item['name']) && $item['name'] === 'wechat2'){
$i = $item['index'];
if(isset($options['sl_wechat_follow']) && isset($options['sl_wechat_follow'][$i]) && $options['sl_wechat_follow'][$i]){
$item['follow'] = 1;
$item['aeskey'] = $options['sl_wechat2_aeskey'][$i];
$item['welcome'] = isset($options['sl_wechat2_welc'][$i]) ? $options['sl_wechat2_welc'][$i] : '';
}
}
$_social[] = $item;
}
$social = $_social;
}
return $social;
}
add_filter('wpcom_profile_menus', 'WPCOM_MP_add_profile_menus', 9);
function WPCOM_MP_add_profile_menus($menus){
if($menus && !empty($menus)){
$menu = array(
'url' => wpcom_subpage_url('orders-list'),
'title' => '我的订单'
);
array_splice($menus, -2, 0, array($menu));
}
return $menus;
}
if(!function_exists('wpcom_get_captcha_image')){
add_filter('wpcom_captcha_data', 'wpcom_get_captcha_image');
function wpcom_get_captcha_image($res){
if($res && isset($res['nonce'])){
$options = $GLOBALS['wpmx_options'];
if(isset($options['captcha_images']) && is_array($options['captcha_images']) && !empty($options['captcha_images'])){
shuffle($options['captcha_images']);
if($image = wp_get_attachment_url($options['captcha_images'][0])) $res['image'] = $image;
}
}
return $res;
}
}
function WPCOM_MP_can_setup_order(){
$user = wp_get_current_user();
if (isset($user->ID) && $user->ID) {
return true;
}else if(isset($GLOBALS['wpmx_options']['anonymous_order']) && $GLOBALS['wpmx_options']['anonymous_order'] == '1'){
return true;
}
return false;
}
function WPCOM_MP_get_gutenberg_blocks($post_id=0){
global $post;
if(!class_exists(\WPCOM\Modules\Module::class)) return false;
if(!$post_id && $post && isset($post->ID)) $post_id = $post->ID;
if($post_id){
$modules = get_post_meta($post_id, '_page_modules', true);
if ($modules && is_array($modules)) {
$_blocks = WPCOM_MP_get_gutenberg_blocks_loop($modules);
$blocks = parse_blocks($_blocks);
return $blocks;
}
}
}
function WPCOM_MP_get_gutenberg_blocks_loop($modules){
$res = '';
if ($modules && is_array($modules)) {
foreach($modules as $module){
if($module['type'] === 'gutenberg' && isset($module['settings']['content'])){
$content = $module['settings']['content'];
if($content) $res .= $content . "\r\n";
}else if($module['settings'] && isset($module['settings']['modules']) && $module['settings']['modules']){
$res .= WPCOM_MP_get_gutenberg_blocks_loop($module['settings']['modules']);
}else if ($module['settings'] && isset($module['settings']['girds']) && $module['settings']['girds']) {
foreach ($module['settings']['girds'] as $girds) {
if($girds){
$res .= WPCOM_MP_get_gutenberg_blocks_loop($girds);
}
}
}
}
}
return $res;
}
function WPCOM_MP_get_module_block($blockId, $blockName, $post_id=0){
global $post;
if(!class_exists(\WPCOM\Modules\Module::class)) return false;
if(!$post_id && $post && isset($post->ID)) $post_id = $post->ID;
if($blockId && $post_id){
$modules = get_post_meta($post_id, '_page_modules', true);
if ($modules && is_array($modules)) {
$block = WPCOM_MP_get_module_block_loop($modules, $blockId, $blockName);
return $block;
}
}
}
function WPCOM_MP_get_module_block_loop($modules, $blockId, $blockName){
if ($modules && is_array($modules)) {
foreach($modules as $module){
if($module['type'] === 'gutenberg' && isset($module['settings']['content'])){
$content = $module['settings']['content'];
if($content){
$blocks = parse_blocks($content);
$block = WPCOM_MP_loop_find_block($blocks, $blockId, $blockName);
}
}else if($module['settings'] && isset($module['settings']['modules']) && $module['settings']['modules']){
$block = WPCOM_MP_get_module_block_loop($module['settings']['modules'], $blockId, $blockName);
}else if ($module['settings'] && isset($module['settings']['girds']) && $module['settings']['girds']) {
foreach ($module['settings']['girds'] as $girds) {
if($girds){
$block = WPCOM_MP_get_module_block_loop($girds, $blockId, $blockName);
if($block) break;
}
}
}
if($block) return $block;
}
}
}
function WPCOM_MP_loop_find_block($blocks, $blockId, $blockName) {
if ($blocks && $blockId && $blockName) {
foreach ($blocks as $block) {
if ($block['blockName'] === $blockName && isset($block['attrs']) && isset($block['attrs']['id']) && $block['attrs']['id'] === $blockId) {
return $block;
} else if (isset($block['innerBlocks']) && $block['innerBlocks']) {
$_block = WPCOM_MP_loop_find_block($block['innerBlocks'], $blockId, $blockName);
if($_block) return $_block;
}
}
}
}
function WPCOM_MP_block_bg(){
echo '<svg class="hidden-content-bg" width="879" height="205" viewBox="0 45 820 160" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient x1="100%" y1="23.013%" x2="9.11%" y2="68.305%" id="la"><stop stop-color="var(--member-color, var(--theme-color))" stop-opacity=".01" offset=".533%"/><stop stop-color="var(--member-color, var(--theme-color))" stop-opacity=".15" offset="100%"/></linearGradient>
<linearGradient x1="81.006%" y1="27.662%" x2=".899%" y2="69.383%" id="lb"><stop stop-color="var(--member-color, var(--theme-color))" stop-opacity=".15" offset="0%"/><stop stop-color="var(--member-color, var(--theme-color))" stop-opacity=".01" offset="100%"/></linearGradient>
</defs>
<g fill="none" fill-rule="evenodd"><path d="M9.871 124.063c7.9 9.12 28.19 21.598 46.66 5.41 19.19-16.818 27.986-42.87 15.531-51.971-12.454-9.102-37.594-6.819-59.32 1.62-21.727 8.44-10.77 35.822-2.87 44.941z" fill="url(#la)" transform="translate(67.938 .937)"/><path d="M610.783 44.063c-25.145 39.42-47.054 78.134-30.12 105.532 16.932 27.398 74.377 30.672 171.4 6.468 97.021-24.203 52.5-112.016 17.794-141.793-34.705-29.777-133.929-9.626-159.074 29.793z" fill="url(#lb)" transform="translate(67.938 .937)"/><path fill-opacity=".06" fill="var(--member-color, var(--theme-color))" d="M325.477 101.51l-11.132 16.084-1.86-1.118L323.96 100.2z"/><path fill-opacity=".06" fill="var(--member-color, var(--theme-color))" d="M363.904 94.28l-1.494 1.24 8.566 10.255 1.487-1.383z"/><path fill-opacity=".06" fill="var(--member-color, var(--theme-color))" d="M215.386 150.719v.88l14.355 2.179v-.821z"/><path fill-opacity=".06" fill="var(--member-color, var(--theme-color))" d="M144.006 125.22l.63.83 11.67-6.978-.569-.758-11.38 6.686"/><path fill-opacity=".06" fill="var(--member-color, var(--theme-color))" d="M530.724 87.128l-.41.92 13.227 4.995.396-.942z"/><path fill-opacity=".06" fill="var(--member-color, var(--theme-color))" d="M613.697 99.184l.65.711 13.93-15.484-.8-.593z"/><path fill-opacity=".06" fill="var(--member-color, var(--theme-color))" d="M605.186 140.762l-.794.433 6.098 17.285.821-.419z"/></g>
</svg>';
}
add_filter( 'wpcom_init_plugin_options', 'WPCOM_MP_unlock_price', 8);
function WPCOM_MP_unlock_price($res){
if($res && isset($res['type']) && $res['type'] === 'post' && isset($res['plugin-slug']) && $res['plugin-slug'] === 'wpcom-member-pro'){
$res['hooks'] = $res['hooks'] ?? [];
$res['hooks']['vip_price'] = $res['hooks']['vip_price'] ?? [];
$options = $GLOBALS['wpmx_options'];
$is_points = isset($options['points_on']) && $options['points_on'] == '1';
if($is_points){
$res['hooks']['vip_price'][] = array(
'f' => 'unlock_type:3',
'n' => 'pay_type',
'l' => '使用积分购买',
't' => 't',
'ux' => 1,
's' => 0,
'd' => '如果开启积分功能则可设置使用积分的方式购买;开启后下列价格选项单位均为积分',
);
}
$res['hooks']['vip_price'][] = [
'f' => 'unlock_type:3',
'n' => 'unlock_price',
'l' => '付费价格',
'd' => $is_points ? '单位:元,开启使用积分购买则单位为:积分' : '单位:元'
];
}
return $res;
}