__( 'Barra lateral derecha', 'twentyten' ),
'id' => 'sidebar-derecha-widget-area',
'description' => __( 'Zona para widgets en la barra lateral derecha del blog.', 'twentyten' ),
'before_widget' => '
', // Removes
'after_widget' => '
', // Removes
'before_title' => '
', // Replaces
'after_title' => '
', // Replaces
));
}
/** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
add_action( 'widgets_init', 'archive_ajax_widgets_init' );
/* Function that registers our widget. */
function archive_ajax_load_widgets() {
register_widget( 'WP_Widget_Archivo_Chic' );
do_action('widgets_init');
}
/* Add our function to the widgets_init hook. */
add_action( 'init', 'archive_ajax_load_widgets', 1 );
class WP_Widget_Archivo_Chic extends WP_Widget {
function WP_Widget_Archivo_Chic() {
$widget_ops = array('classname' => 'widget_archive_chic', 'description' => __( "AJAX Archive by year.") );
$this->WP_Widget('archive_chic', __('AJAX Archive'), $widget_ops);
}
function widget( $args, $instance ) {
global $wpdb;
extract($args);
$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
// Use current theme search form if it exists
?>
get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND YEAR(post_date) <= YEAR (CURRENT_DATE) ORDER BY post_date DESC");
?>
$year";
?>
$months = $wpdb->get_col("SELECT DISTINCT MONTH(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND YEAR(post_date) = '".$year."' ORDER BY post_date DESC");
foreach($months as $month) :
{
$num_mes = $wpdb->get_col("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND MONTH(post_date) = '".$month."' AND YEAR(post_date) = '".$year."'" );
?>