Commit 7695fa80 authored by lucha's avatar lucha Committed by agata

patched GreenTrack theme to work with recent Wordpress versions

parent 29e7ff43
<?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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment