
<?php
if (!defined('ABSPATH')) {
exit;
}
add_action('admin_menu', 'create_weixin_menu');
function create_weixin_menu()
{
$page_title = "小程序配置";
$menu_title = "小程序配置";
$capability = "administrator";
$menu_slug = "app_setting";
$function = "weixin_settings_page";
$icon_url = plugins_url('me-config/includes/images/icon16.png');
$position = 66;
add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position);
add_action('admin_init', 'register_weixinsettings');
}
function register_weixinsettings()
{
register_setting('weixin-group', 'local_appid');
register_setting('weixin-group', 'local_secret');
register_setting('weixin-group', 'local_mchid');
register_setting('weixin-group', 'local_paykey');
register_setting('weixin-group', 'local_paybody');
register_setting('weixin-group', 'local_swipe');
register_setting('weixin-group', 'local_display_categories');
register_setting('weixin-group', 'local_enable_comment_option');
register_setting('weixin-group', 'local_enable_comment_check');
register_setting('weixin-group', 'local_poster_imageurl');
register_setting('weixin-group', 'local_praise_word');
register_setting('weixin-group', 'local_enterprise_minapp');
register_setting('weixin-group', 'local_list_ad');
register_setting('weixin-group', 'local_list_ad_id');
register_setting('weixin-group', 'local_list_ad_every');
register_setting('weixin-group', 'local_detail_ad');
register_setting('weixin-group', 'local_detail_ad_id ');
}
function loding_res()
{
wp_enqueue_style('local_css', ME_BASE_URL . "includes/js/tab/tabs.css");
wp_enqueue_script('local_js', ME_BASE_URL . "includes/js/tab/tabs.min.js");
}
function weixin_settings_page()
{
?>
<div class="wrap">
<h2>小程序设置</h2>
<?php
if (!empty($_REQUEST['settings-updated'])) {
echo '<div id="message" class="updated fade"><p><strong>设置已保存</strong></p></div>';
}
if (version_compare(PHP_VERSION, '5.6.0', '<=')) {
echo '<div class="notice notice-error is-dismissible"> <p><font color="red">提示:php版本小于5.6.0, 插件程序将无法正常使用,当前系统的php版本是:' . PHP_VERSION . '</font></p> </div>';
}
?>
<form method="post" action="options.php">
<div class="responsive-tabs">
<?php settings_fields('weixin-group'); ?>
<?php do_settings_sections('weixin-group'); ?>
<div class="responsive-tabs">
<h2> 常规设置</h2>
<div class="section">
<table class="form-table">
<tr valign="top"> <th scope="row">AppID</th> <td><input type="text" name="local_appid" style="width:400px; height:40px" value="<?php echo esc_attr(get_option('local_appid')); ?>" />* </td> </tr>
<tr valign="top"> <th scope="row">AppSecret</th> <td><input type="text" name="local_secret" style="width:400px; height:40px" value="<?php echo esc_attr(get_option('local_secret')); ?>" />* </td> </tr>
<tr valign="top"> <th scope="row">商户号MCHID</th> <td><input type="text" name="local_mchid" style="width:400px; height:40px" value="<?php echo esc_attr(get_option('local_mchid')); ?>" /> <p style="color: #959595; display:inline">微信支付商户后台获取</p> </td> </tr>
<tr valign="top"> <th scope="row">商户支付密钥key</th> <td><input type="text" name="local_paykey" style="width:400px; height:40px" value="<?php echo esc_attr(get_option('local_paykey')); ?>" /> <p style="color: #959595; display:inline">微信支付商户后台获取</p> </td> </tr>
<tr valign="top"> <th scope="row">支付描述</th> <td><input type="text" name="local_paybody" style="width:400px; height:40px" value="<?php echo esc_attr(get_option('local_paybody')); ?>" />* </td> </tr>
<tr valign="top">
<th scope="row">小程序首页滑动文章ID</th>
<td><input type="text" name="local_swipe" style="width:400px; height:40px" value="<?php echo esc_attr(get_option('local_swipe')); ?>" />
<p style="color: #959595; display:inline">* 请用英文半角逗号分隔</p>
</td>
</tr>
<tr valign="top">
<th scope="row">在小程序里显示的文章分类id</th>
<td><input type="text" name="local_display_categories" style="width:400px; height:40px" value="<?php echo esc_attr(get_option('local_display_categories')); ?>" />
<br />
<p style="color: #959595 ; display:inline">* 文章分类id,只支持一级分类,请用英文半角逗号分隔,留空则显示所有分类</p>
</td>
</tr>
<tr valign="top">
<th scope="row">开启小程序的评论</th>
<td>
<?php
$local_enable_comment_option = get_option('local_enable_comment_option');
$checkbox = empty($local_enable_comment_option) ? '' : 'checked';
echo '<input name="local_enable_comment_option" type="checkbox" value="1" ' . $checkbox . ' />';
?>
    开启评论审核
<?php
$local_enable_comment_check = get_option('local_enable_comment_check');
$checkbox1 = empty($local_enable_comment_check) ? '' : 'checked';
echo '<input name="local_enable_comment_check" type="checkbox" value="1" ' . $checkbox1 . ' />';
?>
</td>
</tr>
<tr valign="top">
<th scope="row">海报图片默认地址</th>
<td><input type="text" name="local_poster_imageurl" style="width:400px; height:40px" value="<?php echo esc_attr(get_option('local_poster_imageurl')); ?>" /><br />
<p style="color: #959595; display:inline">* 请输完整的图片地址,例如:https://www.watch-life.net/images/poster.jpg</p>
</td>
</tr>
<tr valign="top">
<th scope="row">"赞赏"文字调整为</th>
<td><input type="text" name="local_praise_word" placeholder="喜欢" style="width:400px; height:40px" value="<?php echo esc_attr(get_option('local_praise_word')); ?>" /><br />
<p style="color: #959595; display:inline">* 例如:<code>鼓励</code>,<code>喜欢</code>,<code>稀罕</code>,不要超过两个汉字</p>
</td>
</tr>
</table>
</div>
<h2>广告设置</h2>
<div class="section">
<table class="form-table">
<tr valign="top">
<th scope="row">开启文章列表广告</th>
<td>
<?php
$local_list_ad = get_option('local_list_ad');
$checkbox = empty($local_list_ad) ? '' : 'checked';
echo '<input name="local_list_ad" type="checkbox" value="1" ' . $checkbox . ' />';
?>
   广告id: <input type="text" name="local_list_ad_id" style="width:300px; height:40px" value="<?php echo esc_attr(get_option('local_list_ad_id')); ?>" />
<br />             每<input type="number" name="local_list_ad_every" style="width:40px; height:40px" value="<?php echo esc_attr(get_option('local_list_ad_every')); ?>" />条列表展示一条广告<br />
<p style="color: #959595; display:inline">            请输入整数,否则无法正常展示广告</p>
</td>
</td>
</tr>
<tr valign="top">
<th scope="row">开启内容详情页广告</th>
<td>
<?php
$local_detail_ad = get_option('local_detail_ad');
$checkbox = empty($local_detail_ad) ? '' : 'checked';
echo '<input name="local_detail_ad" type="checkbox" value="1" ' . $checkbox . ' />';
?>
   广告id: <input type="text" name="local_detail_ad_id" style="width:300px; height:40px" value="<?php echo esc_attr(get_option('local_detail_ad_id')); ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row">激励视频广告id</th>
<td>
<input type="text" name="local_excitation_ad_id" style="width:300px; height:40px" value="<?php echo esc_attr(get_option('local_excitation_ad_id')); ?>" />
</td>
</tr>
</table>
</div>
</div>
<?php submit_button(); ?>
</form>
<?php loding_res() ?>
<script>
jQuery(document).ready(function($) {
RESPONSIVEUI.responsiveTabs();
});
</script>
</div>
<?php
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现