diff --git a/includes/api/ram-rest-posts-controller.php b/includes/api/ram-rest-posts-controller.php index 80347827b086c89dfe55a827f78bef0a336afb73..4cc9fe212909abb48247f59c6b43698d7978af3f 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 a978f8f44a95481f0fddb09c0d4f6afd58c8c3fa..96d8c8a8961086d29554447f144420de5b28cee5 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 c1ab9a308d186535ebcf75df34a491ba46a7c877..4b70cb383a8b18a6802898545b3000a44e1434f0 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