Skip to content
Snippets Groups Projects
Commit 572e4eed authored by lucha's avatar lucha Committed by agata
Browse files

patched GreenTrack theme to work with recent Wordpress versions

parent 303dd732
Branches
Tags
No related merge requests found
......@@ -2,11 +2,10 @@
/*
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);
$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);
......@@ -36,11 +29,13 @@ 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);
$args = array(
'post_status' => 'publish',
'number' => $no_comments,
'order_by' => 'comment_date',
'status' => 'approved'
);
$comments = get_comments($args);
$output = '';
if($comments) {
......@@ -51,7 +46,7 @@ function gt_get_recent_comments($no_comments = 5, $comment_num_of_words = 4, $be
$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;
$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;
}
......@@ -60,9 +55,4 @@ function gt_get_recent_comments($no_comments = 5, $comment_num_of_words = 4, $be
echo '<br/>'."\n";
}
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment