'widget_woo_archives', 'description' => __( 'A custom WooThemes archives widget.', 'woothemes' ) ); /* Widget control settings. */ $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'woo_archives' ); /* Create the widget. */ $this->WP_Widget( 'woo_archives', __('Woo - Archives', 'woothemes' ), $widget_ops, $control_ops ); } // End Constructor /*---------------------------------------- widget() ---------------------------------------- * Displays the widget on the frontend. ----------------------------------------*/ function widget( $args, $instance ) { $html = ''; extract( $args, EXTR_SKIP ); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base ); /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ( $title ) { echo $before_title . $title . $after_title; } // End IF Statement /* Widget content. */ // Add actions for plugins/themes to hook onto. do_action( 'widget_woo_archives_top' ); global $post; $myposts = get_posts( 'post_type=post&posts_per_page=-1' ); $dates_array = array(); $year_array = array(); $i = 0; $prev_post_ts = null; $prev_post_year = null; $distance_multiplier = 9; if ( count( $myposts ) > 0 ) { foreach( $myposts as $post ) { setup_postdata( $post ); $post_ts = strtotime( $post->post_date ); $post_year = date( 'Y', $post_ts ); $post_month = date( 'm', $post_ts ); // Handle the first year as a special case if ( is_null( $prev_post_year ) ) { ?>
$post_year ) { $working_year--; ?>
__( 'Archives', 'woothemes' ) ); $instance = wp_parse_args( (array) $instance, $defaults ); $instance = wp_parse_args( $instance, array_fill_keys( array( 'title' ), '' ) ); ?>