-
lucha authored
- moved themes related patches to patches/themes (yet to check) - moved wp core patches to patches/core - split the mega-patch for hyperdb in the individual edits. I removed the one related to nextgen-gallery since I think it is not relevant anymore (but I might be wrong)
lucha authored- moved themes related patches to patches/themes (yet to check) - moved wp core patches to patches/core - split the mega-patch for hyperdb in the individual edits. I removed the one related to nextgen-gallery since I think it is not relevant anymore (but I might be wrong)
0194-patched-GreenTrack-theme-to-work-with-recent-Wordpre.patch 4.92 KiB
From 0830658ac27986e00e3c2bb854ea1aa82089e9f4 Mon Sep 17 00:00:00 2001
From: lucha <lucha@paranoici.org>
Date: Tue, 18 Apr 2017 11:26:08 +0200
Subject: [PATCH 194/229] patched GreenTrack theme to work with recent
Wordpress versions
---
wp-content/themes/GreenTrack/functions.php | 84 ++++++++++------------
1 file changed, 37 insertions(+), 47 deletions(-)
diff --git a/wp-content/themes/GreenTrack/functions.php b/wp-content/themes/GreenTrack/functions.php
index 0fe962ad..98386b92 100644
--- a/wp-content/themes/GreenTrack/functions.php
+++ b/wp-content/themes/GreenTrack/functions.php
@@ -1,12 +1,11 @@
-<?php
-/*
-Gets the number of posts and comments so we can display it in the sidebar
-*/
-$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
-if (0 < $numposts) $numposts = number_format($numposts);
-
-$numcmnts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
-if (0 < $numcmnts) $numcmnts = number_format($numcmnts);
+<?php
+/*
+Gets the number of posts and comments so we can display it in the sidebar
+*/
+$countpost = wp_count_posts();
+$numposts = $countpost->publish;
+$countcomments = wp_count_comments();
+$numcmnts = $countcomments->approved;
/*
Description: Returns a list of the most recent posts.
@@ -14,13 +13,7 @@ Created by Sadish for his GreenTrack Theme
*/
function gt_get_recent_posts($no_posts = 5, $before = '<li>', $after = '</li>', $show_pass_post = false) {
- global $wpdb, $tableposts;
- $time_difference = get_settings('gmt_offset');
- $now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600)));
- $request = "SELECT ID, post_title, post_excerpt FROM $tableposts WHERE post_status = 'publish' ";
- if(!$show_pass_post) $request .= "AND post_password ='' ";
- $request .= "AND post_date < '$now' ORDER BY post_date DESC LIMIT 0, $no_posts";
- $posts = $wpdb->get_results($request);
+ $posts = wp_get_recent_posts(array('numberposts' => $no_posts, 'post_status' => 'publish'));
$output = '';
foreach ($posts as $post) {
$post_title = stripslashes($post->post_title);
@@ -34,35 +27,32 @@ function gt_get_recent_posts($no_posts = 5, $before = '<li>', $after = '</li>',
Description: Returns a list of the most recent comments.
Created by Sadish for his GreenTrack Theme
*/
-function gt_get_recent_comments($no_comments = 5, $comment_num_of_words = 4, $before = '<li>', $after = '</li>')
-{
- global $wpdb, $tablecomments, $tableposts;
-
- $request = "SELECT ID, comment_ID, comment_content, comment_author FROM $tableposts, $tablecomments WHERE $tableposts.ID=$tablecomments.comment_post_ID AND post_status = 'publish' ";
- $request .= "AND comment_approved = '1' ORDER BY $tablecomments.comment_date DESC LIMIT $no_comments";
- $comments = $wpdb->get_results($request);
-
- $output = '';
- if($comments) {
- foreach ($comments as $comment)
- {
- $comment_author = stripslashes($comment->comment_author);
- $comment_content = strip_tags($comment->comment_content);
- $comment_content = stripslashes($comment_content);
- $words=split(" ",$comment_content);
- $comment_excerpt = join(" ",array_slice($words,0,$comment_num_of_words));
- $permalink = get_permalink($comment->ID)."#comment-".$comment->comment_ID;
- $output .= $before . '<strong>' . $comment_author . '</strong>: <a href="' . $permalink;
- $output .= '" title="'.__('Comment by','c4m').' ' . $comment_author.'">' . $comment_excerpt . '...</a>' . $after;
- }
- }
- echo $output;
- echo '<br/>'."\n";
-}
-
-
-
-
-
-
+function gt_get_recent_comments($no_comments = 5, $comment_num_of_words = 4, $before = '<li>', $after = '</li>')
+{
+ $args = array(
+ 'post_status' => 'publish',
+ 'number' => $no_comments,
+ 'order_by' => 'comment_date',
+ 'status' => 'approved'
+ );
+ $comments = get_comments($args);
+
+ $output = '';
+ if($comments) {
+ foreach ($comments as $comment)
+ {
+ $comment_author = stripslashes($comment->comment_author);
+ $comment_content = strip_tags($comment->comment_content);
+ $comment_content = stripslashes($comment_content);
+ $words=split(" ",$comment_content);
+ $comment_excerpt = join(" ",array_slice($words,0,$comment_num_of_words));
+ $permalink = get_permalink($comment->comment_ID)."#comment-".$comment->comment_ID;
+ $output .= $before . '<strong>' . $comment_author . '</strong>: <a href="' . $permalink;
+ $output .= '" title="'.__('Comment by','c4m').' ' . $comment_author.'">' . $comment_excerpt . '...</a>' . $after;
+ }
+ }
+ echo $output;
+ echo '<br/>'."\n";
+}
+
?>
\ No newline at end of file
--
2.17.1