提交 81f66f60 编写于 作者: ijianbo's avatar ijianbo

完善代码,加入微慕版宣传

上级 2b5e256b
......@@ -81,8 +81,8 @@ class RAW_REST_Payment_Controller extends WP_REST_Controller{
$input->SetBody($body);
$orderId =WxPayConfig::get_mchid().date("YmdHis");
$input->SetOut_trade_no($orderId);
//$input->SetTotal_fee(strval($totalFee*100));
$input->SetTotal_fee(strval($totalFee));
$input->SetTotal_fee(strval($totalFee*100));
//$input->SetTotal_fee(strval($totalFee));
$input->SetTime_start(date("YmdHis"));
$input->SetTime_expire(date("YmdHis", time() + 600));
$input->SetNotify_url(get_rest_url( null, $this->namespace . '/' . $this->resource_name . '/notify' ) );
......
......@@ -108,7 +108,7 @@ class RAM_REST_Posts_Controller extends WP_REST_Controller{
'schema' => array( $this, 'get_public_item_schema' ),
) );
register_rest_route( $this->namespace, '/' . $this->resource_name.'/hotpost', array(
register_rest_route( $this->namespace, '/' . $this->resource_name.'/likethisyear', array(
array(
'methods' => 'GET',
'callback' => array( $this, 'getTopLikePostsThisYear' ),
......@@ -381,6 +381,7 @@ class RAM_REST_Posts_Controller extends WP_REST_Controller{
function getTopLikePostsThisYear($request)
{
global $wpdb, $post, $tableposts, $tablecomments, $time_difference, $post;
$limit=10;
date_default_timezone_set('Asia/Shanghai');
$today = date("Y-m-d H:i:s"); //获取今天日期时间
// $fristday = date( "Y-m-d H:i:s", strtotime(date("Y",time())."-1"."-1")); //本年第一天;
......@@ -477,6 +478,7 @@ class RAM_REST_Posts_Controller extends WP_REST_Controller{
{
global $wpdb, $post, $tableposts, $tablecomments, $time_difference, $post;
date_default_timezone_set('Asia/Shanghai');
$limit = 10;
$today = date("Y-m-d H:i:s"); //获取今天日期时间
// $fristday = date( "Y-m-d H:i:s", strtotime(date("Y",time())."-1"."-1")); //本年第一天;
$fristday= date("Y-m-d H:i:s", strtotime("-1 year"));
......
......@@ -119,4 +119,34 @@ function custom_post_fields( $data, $post, $request) {
}
//获取文章浏览次数
function post_views($before = '(点击 ', $after = ' 次)', $echo = 1)
{
global $post;
$post_id = $post->ID;
$views = (int)get_post_meta($post_id, 'wl_pageviews', true);
if ($echo) echo $before, number_format($views), $after;
else return $views;
}
//增加或更新文章浏览次数
function addPostPageviews()
{
if (is_singular())
{
global $post;
$post_id = $post->ID;
if($post_id)
{
$post_views = (int)get_post_meta($post_id, 'wl_pageviews', true);
if(!update_post_meta($post_id, 'wl_pageviews', ($post_views+1)))
{
add_post_meta($post_id, 'wl_pageviews', 1, true);
}
}
}
}
......@@ -35,7 +35,7 @@
.responsive-tabs__panel { background:#fff; margin-top:-1px; padding:20px; border-left: 1px solid #ddd; border-right: 1px solid #ddd; border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}
@media (min-width: 768px) {
.responsive-tabs__list, .responsive-tabs__panel {
width:75%;
width:95%;
}
}
@media (max-width: 767px) {
......
......@@ -41,6 +41,9 @@ function weixinapp_settings_page() {
<div class="wrap">
<h2>微信小程序设置</h2>
<p>Rest API to miniprogram by <a href="https://www.watch-life.net" target="_blank">守望轩</a>.
<?php
if (!empty($_REQUEST['settings-updated']))
......@@ -68,23 +71,23 @@ if (version_compare(PHP_VERSION, '5.5.0', '<=') )
<table class="form-table">
<tr valign="top">
<th scope="row">AppID</th>
<td><input type="text" name="wf_appid" style="width:400px" value="<?php echo esc_attr( get_option('wf_appid') ); ?>" /></td>
<td><input type="text" name="wf_appid" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_appid') ); ?>" />* </td>
</tr>
<tr valign="top">
<th scope="row">AppSecret</th>
<td><input type="text" name="wf_secret" style="width:400px" value="<?php echo esc_attr( get_option('wf_secret') ); ?>" /></td>
<td><input type="text" name="wf_secret" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_secret') ); ?>" />* </td>
</tr>
<tr valign="top">
<th scope="row">商户号MCHID</th>
<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>
<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>
</tr>
<tr valign="top">
<th scope="row">商户支付密钥key</th>
<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>
<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>
</tr>
<tr valign="top">
......@@ -95,7 +98,7 @@ if (version_compare(PHP_VERSION, '5.5.0', '<=') )
<tr valign="top">
<th scope="row">小程序首页滑动文章ID</th>
<td><input type="text" name="wf_swipe" style="width:400px" value="<?php echo esc_attr( get_option('wf_swipe') ); ?>" />(请用英文半角逗号分隔)</td>
<td><input type="text" name="wf_swipe" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_swipe') ); ?>" /><p style="color: #959595; display:inline">* 请用英文半角逗号分隔</p></td>
</tr>
<tr valign="top">
......@@ -115,7 +118,7 @@ if (version_compare(PHP_VERSION, '5.5.0', '<=') )
<tr valign="top">
<th scope="row">海报图片默认地址</th>
<td><input type="text" name="wf_poster_imageurl" style="width:600px" value="<?php echo esc_attr( get_option('wf_poster_imageurl') ); ?>" /><br/>(请输完整的图片地址,例如:<span style="color: blue">https://www.watch-life.net/images/2017/06/winxinapp-wordpress-watch-life-new-700.jpg</span>)</td>
<td><input type="text" name="wf_poster_imageurl" style="width:400px; height:40px" value="<?php echo esc_attr( get_option('wf_poster_imageurl') ); ?>" /><br/><p style="color: #959595; display:inline">* 请输完整的图片地址,例如:https://www.watch-life.net/images/poster.jpg</p></td>
</tr>
</table>
......@@ -123,6 +126,17 @@ if (version_compare(PHP_VERSION, '5.5.0', '<=') )
<h2>微慕版(专业版)</h2>
<div class="section">
<div style="display: flex; flex-direction: row; margin-bottom: 10px">
<a href="http://www.minapper.com" 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="http://mall.minapper.com" 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>
<p style="color: #4c4c4c;text-align:justify; line-height: 2">微慕版wordpress小程序和插件,在“守望轩”开源小程序的基础上,架构完全重构,在性能上大幅度优化,增加了<span style="font-weight:bold">动态圈子、积分系统、文章投稿、发布动态、付费阅读、会员权限、多种图文列表样式、预约表单、模板消息</span>等功能,并且免费提供标准版、旅游版、图片版、企业版4套前端模板,可使用微信扫描下方小程序码直接体验:</p>
<div>
<img src="https://www.minapper.com/wp-content/uploads/2018/09/2018091118195979.jpg" alt="Smiley face" width="120px" height="270px"></img>
<img src="https://www.minapper.com/wp-content/uploads/2018/11/2018110915511992.jpg" alt="Smiley face" width="120px" height="270px"></img>
<img src="https://www.minapper.com/wp-content/uploads/2018/09/2018091118200015.jpg" alt="Smiley face" width="120px" height="270px"></img>
<img src="https://www.minapper.com/wp-content/uploads/2018/11/2018110822512777.jpg" alt="Smiley face" width="120px" height="270px"></img>
</div>
</div>
</div>
......
......@@ -2,7 +2,7 @@
/*
Plugin Name: REST API TO MiniProgram
Plugin URI: http://www.watch-life.net
Description: 为小程序提供 rest api 支持
Description: 为小程序提供 rest api 支持
Version: 0.5
Author: jianbo
Author URI: http://www.minapper.com
......@@ -39,6 +39,8 @@ if ( ! class_exists( 'RestAPIMiniProgram' ) ) {
return $endpoints;
});
// add_action( 'admin_init', 'register_restAPIWechatsettings' );
// add_action('admin_menu', 'restAPIWechat_config_menu');
//定制化内容输出,对pc端和api都生效
add_filter( 'the_content', 'custocm_content_filter' );
......@@ -49,6 +51,13 @@ if ( ! class_exists( 'RestAPIMiniProgram' ) ) {
add_filter( 'rest_prepare_category', 'custom_fields_rest_prepare_category', 10, 3 ); //获取分类的封面图片
//更新浏览次数(pc)
add_action('wp_head', 'addPostPageviews');
//获取浏览次数(pc)
add_filter('raw_post_views', 'post_views');
// 管理配置
if ( is_admin() ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册