$rawpost )
$rawposts[$key]->post_content = null;
// Loop through each post and sort it into a structured array
foreach( $rawposts as $key => $post ) {
$posts[ mysql2date( 'Y.m', $post->post_date ) ][] = $post;
$rawposts[$key] = null; // Try and free up memory for users with lots of posts and poor server configs
}
$rawposts = null; // More memory cleanup
// Store the results into the WordPress cache
wp_cache_set( 'ar-posts', $posts );
return $posts;
}
// Generates the HTML output based on $atts array from the shortcode
function aureola_arch_PostList() {
global $wp_locale;
// Get the big array of all posts
$posts = aureola_arch_GetPosts();
// Sort the months based on $atts
krsort( $posts );
// Sort the posts within each month based on $atts
foreach( $posts as $key => $month ) {
$sorter = array();
foreach ( $month as $post )
$sorter[] = $post->post_date_gmt;
SORT_DESC;
array_multisort( $sorter, $sortorder, $month );
$posts[$key] = $month;
unset($month);
}
// Generate the HTML
$html = '
'. "\n";
$html .= '
' . __('Expand All', 'aureola') . "\n\n";
$html .= '
' . "\n";
$firstmonth = TRUE;
foreach( $posts as $yearmonth => $posts ) {
list( $year, $month ) = explode( '.', $yearmonth );
$firstpost = TRUE;
foreach( $posts as $post ) {
if ( TRUE == $firstpost ) {
$html .= ' - ' . sprintf( __('%1$s %2$d'), $wp_locale->get_month($month), $year );
$html .= ' (' . count($posts) . ')';
$html .= "\n
\n";
$firstpost = FALSE;
}
$html .= ' - ' . mysql2date( 'd', $post->post_date ) . ': ' . get_the_title( $post->ID ) . '';
// Unless comments are closed and there are no comments, show the comment count
if (( 0 != $post->comment_count || 'closed' != $post->comment_status ) && empty($post->post_password) )
$html .= ' (' . $post->comment_count . ')';
$html .= "
\n";
}
$html .= "
\n \n";
}
$html .= "
\n
\n";
return $html;
}
// Returns the total number of posts
function aureola_arch_PostCount() {
$num_posts = wp_count_posts( 'post' );
return number_format_i18n( $num_posts->publish );
}
// Deletes the cached filtered posts array for users using a persistent caching plugin
function DeleteCache() {
wp_cache_delete( 'ar-posts' );
}
add_action( 'edit_post', 'DeleteCache' );
?>