';
$yearscount = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) as year, count(ID) as pcount FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' GROUP BY year ORDER BY post_date DESC");
foreach($yearscount as $yearc) {
$output .= '
'.$yearc->year.' ('.$yearc->pcount.' '.__(ajaxar_format_posts_count($yearc->pcount)).')';
$output .= '';
}
$output .= '';
return $output;
}
function ajaxar_get_months($ayear) {
global $wpdb, $month;
$output = '';
return $output;
}
function ajaxar_get_posts($ayear, $amonth) {
global $wpdb;
$output = '';
$monthposts = $wpdb->get_results("SELECT p.*, (select count(*) from $wpdb->comments c where p.ID = c.comment_post_ID AND c.comment_approved = '1') as xcount FROM $wpdb->posts p WHERE p.post_status = 'publish' AND p.post_type = 'post' AND YEAR(p.post_date) = $ayear AND MONTH(p.post_date) = $amonth GROUP BY p.ID ORDER BY p.post_date DESC");
foreach($monthposts as $apost) {
$output .= '- '.mysql2date(get_option('date_format'), $apost->post_date).' - '.$apost->post_title.' ('.$apost->xcount.' '.__(ajaxar_format_comments_count($apost->xcount)).')
';
}
$output .= '
';
return $output;
}
function ajaxar_format_comments_count($count) {
$c = (int) $count;
if ($c == 0) {
return 'Comments';
} else if ($c == 1) {
// Comment isn't translated in all languages, modify here the text for only one comment
return 'Comment';
}
return 'Comments';
}
function ajaxar_format_posts_count($count) {
$c = (int) $count;
if ($c == 0) {
return 'Posts';
} else if ($c == 1) {
// Post isn't translated in all languages, modify here the text for only one post
return 'Post';
}
return 'Posts';
}
function ajaxar_js() {
wp_print_scripts( array( 'sack' ));
$output .= ''."\n";
return $output;
}
function ajaxar_snippet ($content) {
if (eregi ('\[ajaxar\]', $content)) {
return eregi_replace ('\[ajaxar\]', ajaxar_get_years(), $content);
}
return $content;
}
add_action ('the_content', 'ajaxar_snippet');
?>