From e80a2bdc6c020a0a55be9e9adeaa7f80593ec348 Mon Sep 17 00:00:00 2001 From: xjb <20397795@qq.com> Date: Mon, 11 Sep 2023 14:08:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=87=E7=AB=A0=E6=8E=92?= =?UTF-8?q?=E8=A1=8C=E7=9A=84=E5=B9=B4=E9=99=90=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/api/ram-rest-posts-controller.php | 30 +++++++++++++--------- includes/settings/wp-wechat-config.php | 15 +++++++++++ rest-api-to-miniprogram.php | 2 +- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/includes/api/ram-rest-posts-controller.php b/includes/api/ram-rest-posts-controller.php index 8034782..4cc9fe2 100644 --- a/includes/api/ram-rest-posts-controller.php +++ b/includes/api/ram-rest-posts-controller.php @@ -394,12 +394,14 @@ class RAM_REST_Posts_Controller extends WP_REST_Controller{ } } - $limit=10; + $limit=20; global $wpdb, $post, $tableposts, $tablecomments, $time_difference, $post; 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")); //本年第一天; - $fristday= date("Y-m-d H:i:s", strtotime("-1 year")); + $today = date("Y-m-d H:i:s"); //获取今天日期时间 + $hot_posts_years= empty(get_option('wf_hot_posts_years'))?'1':get_option('wf_hot_posts_years'); + $hot_posts_years ='-'.$hot_posts_years.' year'; + $fristday= date("Y-m-d H:i:s", strtotime($hot_posts_years)); + //$fristday= date("Y-m-d H:i:s", strtotime("-1 year")); $sql="SELECT ".$wpdb->posts.".ID as ID, post_title, post_name,post_content,post_date, CONVERT(".$wpdb->postmeta.".meta_value,SIGNED) AS 'pageviews_total' FROM ".$wpdb->posts." LEFT JOIN ".$wpdb->postmeta." ON ".$wpdb->posts.".ID = ".$wpdb->postmeta.".post_id WHERE ".$wpdb->postmeta.".meta_key ='wl_pageviews' AND post_date BETWEEN '".$fristday."' AND '".$today."' AND post_status = 'publish' AND post_type='post' AND post_password = '' ORDER BY pageviews_total DESC LIMIT ". $limit; $mostlikes = $wpdb->get_results($sql); $posts =array(); @@ -460,11 +462,13 @@ class RAM_REST_Posts_Controller extends WP_REST_Controller{ } global $wpdb, $post, $tableposts, $tablecomments, $time_difference, $post; - $limit=10; + $limit=20; 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")); //本年第一天; - $fristday= date("Y-m-d H:i:s", strtotime("-1 year")); + $today = date("Y-m-d H:i:s"); //获取今天日期时间 + $hot_posts_years= empty(get_option('wf_hot_posts_years'))?'1':get_option('wf_hot_posts_years'); + $hot_posts_years ='-'.$hot_posts_years.' year'; + $fristday= date("Y-m-d H:i:s", strtotime($hot_posts_years)); + //$fristday= date("Y-m-d H:i:s", strtotime("-1 year")); $sql="SELECT ".$wpdb->posts.".ID as ID, post_title, post_name,post_content,post_date, COUNT(".$wpdb->postmeta.".post_id) AS 'like_total' FROM ".$wpdb->posts." LEFT JOIN ".$wpdb->postmeta." ON ".$wpdb->posts.".ID = ".$wpdb->postmeta.".post_id WHERE ".$wpdb->postmeta.".meta_value ='like' AND post_date BETWEEN '".$fristday."' AND '".$today."' AND post_status = 'publish' AND post_type='post' AND post_password = '' GROUP BY ".$wpdb->postmeta.".post_id ORDER BY like_total DESC LIMIT ". $limit; $mostlikes = $wpdb->get_results($sql); $posts =array(); @@ -576,10 +580,12 @@ 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")); + $limit = 20; + $today = date("Y-m-d H:i:s"); //获取今天日期时间 + $hot_posts_years= empty(get_option('wf_hot_posts_years'))?'1':get_option('wf_hot_posts_years'); + $hot_posts_years ='-'.$hot_posts_years.' year'; + $fristday= date("Y-m-d H:i:s", strtotime($hot_posts_years)); + //$fristday= date("Y-m-d H:i:s", strtotime("-1 year")); $sql="SELECT ".$wpdb->posts.".ID as ID, post_title, post_name,post_content,post_date, COUNT(".$wpdb->comments.".comment_post_ID) AS 'comment_total' FROM ".$wpdb->posts." LEFT JOIN ".$wpdb->comments." ON ".$wpdb->posts.".ID = ".$wpdb->comments.".comment_post_ID WHERE comment_approved = '1' AND post_date BETWEEN '".$fristday."' AND '".$today."' AND post_status = 'publish' AND post_type='post' AND post_password = '' GROUP BY ".$wpdb->comments.".comment_post_ID ORDER BY comment_total DESC LIMIT ". $limit; $mostcommenteds = $wpdb->get_results($sql); $posts =array(); diff --git a/includes/settings/wp-wechat-config.php b/includes/settings/wp-wechat-config.php index a978f8f..96d8c8a 100644 --- a/includes/settings/wp-wechat-config.php +++ b/includes/settings/wp-wechat-config.php @@ -76,6 +76,8 @@ function register_weixinappsettings() { register_setting('weixinapp-group', 'wf_detail_bottom_display_qrcode'); register_setting('weixinapp-group', 'wf_minapper_qrcode_url'); register_setting('weixinapp-group', 'wf_updateAvatar_count'); + register_setting('weixinapp-group', 'wf_hot_posts_years'); + } @@ -182,6 +184,19 @@ $response = wp_remote_post('https://blog.minapper.com/wp-json/uniapp-builder/v1/ + + 文章排行的年限 + 距今 + 年 + + + + 开启小程序的评论 diff --git a/rest-api-to-miniprogram.php b/rest-api-to-miniprogram.php index c1ab9a3..4b70cb3 100644 --- a/rest-api-to-miniprogram.php +++ b/rest-api-to-miniprogram.php @@ -3,7 +3,7 @@ Plugin Name: REST API TO MiniProgram 微慕小程序 Plugin URI: https://www.minapper.com Description: 为微慕小程序提供定制化WordPress REST API json 输出 -Version: 4.6.8 +Version: 4.6.8.1 Author: jianbo Author URI: https://www.minapper.com License: GPL v3 -- GitLab