wp-wechat-config.php 17.3 KB
Newer Older
ijianbo's avatar
ijianbo 已提交
1 2 3 4 5 6 7 8
<?php 

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

function weixinapp_create_menu() {
    // 创建新的顶级菜单
J
jianbo 已提交
9
    add_menu_page('微慕小程序', '微慕小程序', 'administrator', 'weixinapp_slug', 'weixinapp_settings_page', plugins_url('rest-api-to-miniprogram/includes/images/icon16.png'),null);
ijianbo's avatar
ijianbo 已提交
10 11 12 13 14
    // 调用注册设置函数
    add_action( 'admin_init', 'register_weixinappsettings' );
}

function get_jquery_source() {
15
        $url = plugins_url('',__FILE__); 
ijianbo's avatar
ijianbo 已提交
16 17
        wp_enqueue_style("tabs", plugins_url()."/rest-api-to-miniprogram/includes/js/tab/tabs.css", false, "1.0", "all");
        wp_enqueue_script("tabs", plugins_url()."/rest-api-to-miniprogram/includes/js/tab/tabs.min.js", false, "1.0");
J
jianbo 已提交
18
        wp_enqueue_script('rawscript', plugins_url().'/'.REST_API_TO_MINIPROGRAM_PLUGIN_NAME.'/includes/js/script.js', false, '1.0');
19 20 21
        if ( function_exists( 'wp_enqueue_media' ) ) {
            wp_enqueue_media();
        }    
J
jianbo 已提交
22 23
    }

ijianbo's avatar
ijianbo 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36

function register_weixinappsettings() {
    // 注册设置
    register_setting( 'weixinapp-group', 'wf_appid' );
    register_setting( 'weixinapp-group', 'wf_secret' );
    register_setting( 'weixinapp-group', 'wf_swipe' );
    
    register_setting( 'weixinapp-group', 'wf_mchid' );
    register_setting( 'weixinapp-group', 'wf_paykey' );
    register_setting( 'weixinapp-group', 'wf_paybody' );

    register_setting( 'weixinapp-group', 'wf_poster_imageurl' );
    register_setting( 'weixinapp-group', 'wf_enable_comment_option' );
J
jianbo 已提交
37
    register_setting( 'weixinapp-group', 'wf_enable_comment_check' );
J
jianbo 已提交
38 39 40 41 42 43 44 45 46

    register_setting( 'weixinapp-group', 'wf_praise_word' );
    register_setting( 'weixinapp-group', 'wf_enterprise_minapp' );

    register_setting( 'weixinapp-group', 'wf_list_ad' );
    register_setting( 'weixinapp-group', 'wf_list_ad_id' );

    register_setting( 'weixinapp-group', 'wf_list_ad_every' );

J
jianbo 已提交
47 48

    register_setting( 'weixinapp-group', 'wf_excitation_ad_id' );
J
jianbo 已提交
49 50 51 52
    register_setting( 'weixinapp-group', 'wf_video_ad_id' );
    register_setting( 'weixinapp-group', 'wf_interstitial_ad_id' );
    
    
J
jianbo 已提交
53 54 55

    

J
jianbo 已提交
56 57
    register_setting( 'weixinapp-group', 'wf_detail_ad' );
    register_setting( 'weixinapp-group', 'wf_detail_ad_id' );
J
jianbo 已提交
58 59
    register_setting( 'weixinapp-group', 'wf_about' );
    register_setting( 'weixinapp-group', 'wf_display_categories' );
60 61 62 63 64 65 66 67 68 69 70

    register_setting( 'weixinapp-group', 'wf_downloadfile_domain' );
    register_setting( 'weixinapp-group', 'wf_business_domain' );
    register_setting( 'weixinapp-group', 'wf_zan_imageurl' );
    register_setting( 'weixinapp-group', 'wf_logo_imageurl' );

    
    


    
J
jianbo 已提交
71 72
    
    
J
jianbo 已提交
73 74 75 76 77 78 79 80 81 82 83
   


    




    

    
J
jianbo 已提交
84
    
ijianbo's avatar
ijianbo 已提交
85 86 87 88 89 90 91 92 93
       
    
    
}

function weixinapp_settings_page() {
?>
<div class="wrap">

J
jianbo 已提交
94
<h2>微慕小程序设置</h2>
ijianbo's avatar
ijianbo 已提交
95 96 97


<p>Rest API to miniprogram by <a href="https://www.watch-life.net" target="_blank">守望轩</a>.
ijianbo's avatar
ijianbo 已提交
98 99 100 101 102 103 104 105
<?php

if (!empty($_REQUEST['settings-updated']))
{
    echo '<div id="message" class="updated fade"><p><strong>设置已保存</strong></p></div>';

} 

ijianbo's avatar
ijianbo 已提交
106
if (version_compare(PHP_VERSION, '5.6.0', '<=') )
ijianbo's avatar
ijianbo 已提交
107 108 109
{
    
    echo '<div class="notice notice-error is-dismissible">
ijianbo's avatar
ijianbo 已提交
110
    <p><font color="red">提示:php版本小于5.6.0, 插件程序将无法正常使用,当前系统的php版本是:'.PHP_VERSION.'</font></p>
ijianbo's avatar
ijianbo 已提交
111 112 113 114 115 116 117 118 119 120 121 122 123 124
    </div>';

}
?>
<form method="post" action="options.php">
    <div class="responsive-tabs">
    <?php settings_fields( 'weixinapp-group' ); ?>
    <?php do_settings_sections( 'weixinapp-group' ); ?>
    <div class="responsive-tabs">
    <h2> 常规设置</h2>
    <div class="section">
        <table class="form-table">
            <tr valign="top">
            <th scope="row">AppID</th>
ijianbo's avatar
ijianbo 已提交
125
            <td><input type="text" name="wf_appid" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_appid') ); ?>" />* </td>
ijianbo's avatar
ijianbo 已提交
126 127 128 129
            </tr>
             
            <tr valign="top">
            <th scope="row">AppSecret</th>
ijianbo's avatar
ijianbo 已提交
130
            <td><input type="text" name="wf_secret" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_secret') ); ?>" />* </td>
ijianbo's avatar
ijianbo 已提交
131 132 133 134
            </tr>

            <tr valign="top">
                            <th scope="row">商户号MCHID</th>
ijianbo's avatar
ijianbo 已提交
135
                            <td><input type="text" name="wf_mchid" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_mchid') ); ?>" /> <p style="color: #959595; display:inline">微信支付商户后台获取</p></td>
ijianbo's avatar
ijianbo 已提交
136 137 138 139 140
                        </tr>


                        <tr valign="top">
                            <th scope="row">商户支付密钥key</th>
ijianbo's avatar
ijianbo 已提交
141
                            <td><input type="text" name="wf_paykey" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_paykey') ); ?>" /> <p style="color: #959595; display:inline">微信支付商户后台获取</p></td>
ijianbo's avatar
ijianbo 已提交
142 143 144 145 146 147 148 149 150 151
                        </tr>

                        <tr valign="top">
                            <th scope="row">支付描述</th>
                            <td><input type="text" name="wf_paybody" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_paybody') ); ?>" /><br /><p style="color: #959595; display:inline">* 商家名称-销售商品类目,例如:守望轩-赞赏</p></td>
                        </tr>


            <tr valign="top">
            <th scope="row">小程序首页滑动文章ID</th>
152
            <td><input type="text" name="wf_swipe" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_swipe') ); ?>" /><br/><p style="color: #959595; display:inline">* 请用英文半角逗号分隔。该设置将在取消,请使用“扩展设置”。</p></td>
ijianbo's avatar
ijianbo 已提交
153 154
            </tr>

J
jianbo 已提交
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
            <tr valign="top">
                <th scope="row">在小程序里显示的文章分类id</th>
                <td><input type="text" name="wf_display_categories" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_display_categories') ); ?>" />
                <br /><p style="color: #959595 ; display:inline">* 文章分类id,只支持一级分类,请用英文半角逗号分隔,留空则显示所有分类</p>
                    </td>
            </tr>

            <tr valign="top">
            <th scope="row">选择"关于"页面</th>
            <td>
            <select id="wf_about" name="wf_about" >
            <?php

                $mypages = get_pages( array( 'child_of' =>0, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
                foreach( $mypages as $page ) {      
                    $title = $page->post_title;
                    $pageId=$page->ID;
                    ?>
                     
               <option  value="<?php echo $pageId;  ?>" <?php echo get_option('wf_about')==$pageId?'selected':''; ?>><?php echo $title ?></option>"
                   <?php }  ?>
            </select>
            </td>
            </tr>

ijianbo's avatar
ijianbo 已提交
180 181 182 183 184 185 186 187 188 189 190 191
            <tr valign="top">
            <th scope="row">开启小程序的评论</th>
            <td>

                <?php

                $wf_enable_comment_option =get_option('wf_enable_comment_option');            
                $checkbox=empty($wf_enable_comment_option)?'':'checked';
                echo '<input name="wf_enable_comment_option"  type="checkbox"  value="1" '.$checkbox. ' />';
                

                           ?>
192
                           &emsp;&emsp;&emsp;&emsp;“订阅者”用户开启评论审核
J
jianbo 已提交
193 194 195 196 197 198 199 200

                <?php
                $wf_enable_comment_check =get_option('wf_enable_comment_check');            
                $checkbox1=empty($wf_enable_comment_check)?'':'checked';
                echo '<input name="wf_enable_comment_check"  type="checkbox"  value="1" '.$checkbox1. ' />';

                ?>
                            </td>
201 202 203 204 205 206 207
            </tr>    

            <tr valign="top">
            <th scope="row">小程序logo图片地址</th>
            <td><input type="text" name="wf_logo_imageurl" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_logo_imageurl') ); ?>" /> <input id="wf_logo_imageurl-btn" class="button im-upload" type="button" value="选择图片" /><br/><p style="color: #959595; display:inline">* 请输完整的图片地址,例如:https://www.watch-life.net/images/poster.jpg</p></td>
           
            </tr> 
ijianbo's avatar
ijianbo 已提交
208 209 210

            <tr valign="top">
            <th scope="row">海报图片默认地址</th>
J
jianbo 已提交
211 212
            <td><input type="text" name="wf_poster_imageurl" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_poster_imageurl') ); ?>" /> <input id="wf_poster_imageurl-btn" class="button im-upload" type="button" value="选择图片" /><br/><p style="color: #959595; display:inline">* 请输完整的图片地址,例如:https://www.watch-life.net/images/poster.jpg</p></td>
           
ijianbo's avatar
ijianbo 已提交
213
            </tr>
J
jianbo 已提交
214

215 216 217 218 219 220
            <tr valign="top">
            <th scope="row">赞赏码图片地址</th>
            <td><input type="text" name="wf_zan_imageurl" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_zan_imageurl') ); ?>" /> <input id="wf_zan_imageurl-btn" class="button im-upload" type="button" value="选择图片" /><br/><p style="color: #959595; display:inline">* 请输完整的图片地址,例如:https://www.watch-life.net/images/poster.jpg</p></td>
           
            </tr>

J
jianbo 已提交
221 222 223
            <tr valign="top">
                            <th scope="row">"赞赏"文字调整为</th>
                            <td><input type="text" name="wf_praise_word" placeholder="喜欢" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_praise_word') ); ?>" /><br /><p style="color: #959595; display:inline">* 例如:<code>鼓励</code>,<code>喜欢</code><code>稀罕</code>,不要超过两个汉字</p></td>
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
            </tr>

            
            <tr valign="top">
                            <th scope="row">downloadFile域名</th>
                            <td>
                            <textarea name="wf_downloadfile_domain" id="wf_downloadfile_domain" class="large-text code" rows="3"><?php echo esc_attr( get_option('wf_downloadfile_domain') ); ?></textarea>
                        <br/><p style="color: #959595; display:inline">请输入域名,用英文逗号分隔</p></td>

                         <tr valign="top">
                            <th scope="row">业务域名</th>
                            <td>
                            <textarea name="wf_business_domain" id="wf_business_domain" class="large-text code" rows="3"><?php echo esc_attr( get_option('wf_business_domain') ); ?></textarea>
                        <br/><p style="color: #959595; display:inline">请输入域名,用英文逗号分隔。仅支持企业主体小程序。</p></td>
                              
J
jianbo 已提交
239 240 241 242 243 244 245 246 247 248 249

            <tr valign="top">
            <th scope="row">小程序是否是企业主体</th>
            <td>
                <?php
                $wf_enterprise_minapp =get_option('wf_enterprise_minapp');            
                $checkbox=empty($wf_enterprise_minapp)?'':'checked';
                echo '<input name="wf_enterprise_minapp"  type="checkbox"  value="1" '.$checkbox. ' />';
                ?><p style="color: #959595; display:inline">* 如果是企业主体的小程序,请勾选</p>
            </td>
        </tr> 
ijianbo's avatar
ijianbo 已提交
250 251 252
                   
        </table>
    </div>
J
jianbo 已提交
253 254 255 256 257 258 259 260 261 262 263
    <h2>广告设置</h2>
    <div class="section">
    <table class="form-table">
    <tr valign="top">
        <th scope="row">开启文章列表广告</th>
            <td>
                <?php
                $wf_list_ad =get_option('wf_list_ad');            
                $checkbox=empty($wf_list_ad)?'':'checked';
                echo '<input name="wf_list_ad"  type="checkbox"  value="1" '.$checkbox. ' />';
                ?>
264
                &emsp;&emsp;&emsp;Banner广告id:&emsp;<input type="text" name="wf_list_ad_id" style="width:300px; height:40px" value="<?php echo esc_attr( get_option('wf_list_ad_id') ); ?>" />
J
jianbo 已提交
265 266 267 268 269 270 271 272 273 274 275 276 277 278
                <br/>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<input type="number" name="wf_list_ad_every" style="width:40px; height:40px" value="<?php echo esc_attr( get_option('wf_list_ad_every') ); ?>" />条列表展示一条广告<br/><p style="color: #959595; display:inline">&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;请输入整数,否则无法正常展示广告</p>
            </td>
            </td>
        </tr>

        <tr valign="top">
        <th scope="row">开启内容详情页广告</th>
            <td>

                <?php
                $wf_detail_ad =get_option('wf_detail_ad');            
                $checkbox=empty($wf_detail_ad)?'':'checked';
                echo '<input name="wf_detail_ad"  type="checkbox"  value="1" '.$checkbox. ' />';
                ?>
279
                &emsp;&emsp;&emsp;Banner广告id:&emsp;<input type="text" name="wf_detail_ad_id" style="width:300px; height:40px" value="<?php echo esc_attr( get_option('wf_detail_ad_id') ); ?>" />
J
jianbo 已提交
280 281
            </td>
        </tr>
J
jianbo 已提交
282 283 284 285 286 287

        <tr valign="top">
                        <th scope="row">激励视频广告id</th>
                            <td>                                
                               <input type="text" name="wf_excitation_ad_id" style="width:300px; height:40px" value="<?php echo esc_attr( get_option('wf_excitation_ad_id') ); ?>" />
                            </td>
J
jianbo 已提交
288 289 290 291 292 293 294 295 296 297 298
          </tr>
          <tr valign="top">
                        <th scope="row">视频广告id</th>
                            <td>                                
                               <input type="text" name="wf_video_ad_id" style="width:300px; height:40px" value="<?php echo esc_attr( get_option('wf_video_ad_id') ); ?>" />
                            </td>
          </tr>
          <th scope="row">插屏广告id</th>
                            <td>                                
                               <input type="text" name="wf_interstitial_ad_id" style="width:300px; height:40px" value="<?php echo esc_attr( get_option('wf_interstitial_ad_id') ); ?>" />
                            </td>
J
jianbo 已提交
299
                        </tr>
J
jianbo 已提交
300 301
</table>
    </div>
ijianbo's avatar
ijianbo 已提交
302

J
jianbo 已提交
303
    <h2>微慕增强版</h2>
ijianbo's avatar
ijianbo 已提交
304
    <div class="section">
ijianbo's avatar
ijianbo 已提交
305
        <div style="display: flex; flex-direction: row; margin-bottom: 10px">
J
jianbo 已提交
306 307
            <a href="https://www.minapper.com" target="_blank" style="text-decoration: none"><div style="width:120px; height:32px; background-color: #ff8f3b; border-radius: 4px; color: #fff;display: flex;justify-content: center; align-items: center;margin-right: 16px">微慕官网</div></a>
           <a href="https://mall.minapper.com"  target="_blank" style="text-decoration: none"><div style="width:120px; height:32px; background-color: #fff; border: 1px solid #ff8f3b; border-radius: 4px; box-sizing: border-box; color: #ff8f3b;display: flex;justify-content: center; align-items: center">微慕商城</div></a>
ijianbo's avatar
ijianbo 已提交
308
        </div>
J
jianbo 已提交
309
                <p style="color: #4c4c4c;text-align:justify; line-height: 2">微慕增强版WordPress小程序是一款,在原守望轩开源小程序(现微慕开源小程序)基础上重新架构、设计、优化过的wordpress多端小程序,性能和用户体验更佳,界面设计更加简洁清新,同时打通<span style="font-weight:bold">微信小程序、QQ小程序、百度小程序、支付宝小程序、头条小程序...真正实现一站多端</span>,可使用微信扫描下方小程序码直接体验:</p>
ijianbo's avatar
ijianbo 已提交
310
        <div>
J
jianbo 已提交
311
            <img src="https://plusimg.minapper.com/wp-content/uploads/2019/08/1565183497-%E5%BE%AE%E6%85%95%E6%B5%B7%E6%8A%A5-2019%E5%B9%B47%E6%9C%88.jpg" alt="微慕增强版" width="100%"></img>
ijianbo's avatar
ijianbo 已提交
312
        </div>
ijianbo's avatar
ijianbo 已提交
313
    </div>
J
jianbo 已提交
314 315 316 317 318 319 320

    <h2>微慕版专业版</h2>
    <div class="section">
        <div style="display: flex; flex-direction: row; margin-bottom: 10px">
            <a href="https://www.minapper.com" target="_blank" style="text-decoration: none"><div style="width:120px; height:32px; background-color: #fc6e6e; border-radius: 4px; color: #fff;display: flex;justify-content: center; align-items: center;margin-right: 16px">微慕官网</div></a>
           <a href="https://mall.minapper.com"  target="_blank" style="text-decoration: none"><div style="width:120px; height:32px; background-color: #fff; border: 1px solid #fc6e6e; border-radius: 4px; box-sizing: border-box; color: #fc6e6e;display: flex;justify-content: center; align-items: center">微慕商城</div></a>
        </div>
J
jianbo 已提交
321
                <p style="color: #4c4c4c;text-align:justify; line-height: 2">微慕版专业版WordPress小程序和插件,在“守望轩”开源小程序的基础上,架构完全重构,在性能上大幅度优化,增加了<span style="font-weight:bold">动态圈子、积分系统、文章投稿、发布动态、付费阅读、会员权限、多种图文列表样式、预约表单、模板消息</span>等功能,并且免费提供标准版、旅游版、图片版、企业版4套前端模板,可使用微信扫描下方小程序码直接体验:</p>
J
jianbo 已提交
322
        <div>
J
jianbo 已提交
323
            <img src="https://www.watch-life.net/images/minapper-pro.jpg" alt="微慕专业版" width="100%"></img>
J
jianbo 已提交
324

J
jianbo 已提交
325 326 327 328 329 330 331
        </div>
    </div>

    



ijianbo's avatar
ijianbo 已提交
332 333 334 335 336 337 338
 </div>

    
    <?php submit_button();?>
</form>
 <?php get_jquery_source(); ?>
            <script>
339
               jQuery(document).ready(function($) {
ijianbo's avatar
ijianbo 已提交
340
                RESPONSIVEUI.responsiveTabs();
J
jianbo 已提交
341 342 343
                // if($("input[name=post_meta]").attr('checked')) {
                //     $("#section_meta_list").addClass("hide");
                // }
ijianbo's avatar
ijianbo 已提交
344 345 346 347
            });
            </script>
</div>
<?php }