| 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/widgets/ |
Upload File : |
<?php
namespace WPCOM\Widgets;
use WPCOM\Member;
class VIP extends Widget {
public function __construct() {
$this->widget_cssclass = 'widget_wpmx_vip';
$this->widget_description = '在边栏添加开通会员的入口';
$this->widget_id = 'wpmx-vip';
$this->widget_name = '#用户中心#开通会员';
$this->settings = array(
'title' => array(
'name' => '标题',
'd' => '小工具标题,可选'
),
'content' => array(
'name' => '说明文案',
't' => 'e',
'd' => '默认会员介绍说明'
),
'vip-content' => array(
'name' => '已开通会员说明文案',
't' => 'e',
'd' => '可选,已开通会员时的会员介绍说明,留空则展示默认说明文案'
),
'btn' => array(
'name' => '按钮',
'd' => '开通会员按钮文字,不设置为默认开通会员文案'
)
);
parent::__construct();
}
public function widget( $args, $instance ) {
$this->widget_start( $args, $instance );
$content = isset($instance['content']) && trim($instance['content'])!=='' ? $instance['content'] : '';
$vip_content = isset($instance['vip-content']) && trim(strip_tags($instance['vip-content'])) !== '' ? $instance['vip-content'] : '';
$user_id = get_current_user_id();
$is_vip = $user_id && Member\VIP::get_user_vip($user_id);
$content = $is_vip && $vip_content !== '' ? $vip_content : $content;
if($content!==''){ ?>
<div class="wpmx-vip-desc"><?php echo wpautop($content);?></div>
<?php }
if($is_vip){
Member\VIP::show_vip_info(false);
Member\VIP::show_vip_info_close();
}else{
$btn = isset($instance['btn']) && trim($instance['btn']) ? $instance['btn'] : Member\VIP::vip_btn_text('new');
echo '<button class="wpcom-btn btn-danger btn-block btn-lg j-vip-new">'.$btn.'</button>';
}
$this->widget_end( $args );
}
}
// register widget
add_action( 'widgets_init', function(){
register_widget( VIP::class );
} );