| 1 | <?php
 | 
|---|
| 2 | function archives_block($options)
 | 
|---|
| 3 | {
 | 
|---|
| 4 |         $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
 | 
|---|
| 5 |         $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_archives_block.html' : trim( $options[1] );
 | 
|---|
| 6 |         $type = empty( $options[2] ) ? 'monthly' : $options[2] ;
 | 
|---|
| 7 |         $limit  = !is_numeric( $options[3] ) ? 0 : $options[3] ;
 | 
|---|
| 8 |         $show_post_count = empty( $options[4] ) ? false : true ;                
 | 
|---|
| 9 |         $drop_down = empty( $options[5] ) ? false : true ;      
 | 
|---|
| 10 |         
 | 
|---|
| 11 |         switch($type){
 | 
|---|
| 12 |                 case 'yearly':
 | 
|---|
| 13 |                         $select_str = __('Select Yearly', 'xpress');
 | 
|---|
| 14 |                         break;
 | 
|---|
| 15 |                 case 'monthly':
 | 
|---|
| 16 |                         $select_str = __('Select Monthly', 'xpress');
 | 
|---|
| 17 |                         break;
 | 
|---|
| 18 |                 case 'weekly':
 | 
|---|
| 19 |                         $select_str = __('Select Weekly', 'xpress');
 | 
|---|
| 20 |                         break;
 | 
|---|
| 21 |                 case 'daily':
 | 
|---|
| 22 |                         $select_str = __('Select Daily', 'xpress');
 | 
|---|
| 23 |                         break;
 | 
|---|
| 24 |                 case 'postbypost':
 | 
|---|
| 25 |                         $select_str = __('Select Post', 'xpress');
 | 
|---|
| 26 |                         break;
 | 
|---|
| 27 |                 default:
 | 
|---|
| 28 |                         $select_str = __('Select Monthly', 'xpress');
 | 
|---|
| 29 |         }
 | 
|---|
| 30 |         
 | 
|---|
| 31 |         if ($drop_down) $format = 'option'; else $format = 'html';
 | 
|---|
| 32 |         if ($limit == 0 ) $limit_str = ''; else $limit_str = $limit;
 | 
|---|
| 33 |         
 | 
|---|
| 34 |         $param = array(
 | 
|---|
| 35 |                 'type' => $type, 
 | 
|---|
| 36 |                 'limit' => $limit_str, 
 | 
|---|
| 37 |                 'format' => $format, 
 | 
|---|
| 38 |                 'before' => '', 
 | 
|---|
| 39 |                 'after' => '',
 | 
|---|
| 40 |                 'show_post_count' => $show_post_count
 | 
|---|
| 41 |         );
 | 
|---|
| 42 |         
 | 
|---|
| 43 |         ob_start();
 | 
|---|
| 44 |                 wp_get_archives($param);
 | 
|---|
| 45 |                 $get_archives_output = ob_get_contents();
 | 
|---|
| 46 |         ob_end_clean();
 | 
|---|
| 47 |         
 | 
|---|
| 48 | 
 | 
|---|
| 49 |         if($drop_down){
 | 
|---|
| 50 |                 
 | 
|---|
| 51 | 
 | 
|---|
| 52 |                 $output = '<form id="archiveform" action="">';
 | 
|---|
| 53 |                 $output .= '<select name="archive_chrono" onchange="window.location = (document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);">';
 | 
|---|
| 54 |                 $output .= "<option value=''>" . $select_str . "</option>\n";
 | 
|---|
| 55 |                 $output .=  $get_archives_output;
 | 
|---|
| 56 |                 $output .= '</select>';
 | 
|---|
| 57 |                 $output .= '</form>';
 | 
|---|
| 58 |                 
 | 
|---|
| 59 |                 $output  = '<select name="archive-dropdown"' . "onChange='document.location.href=this.options[this.selectedIndex].value;'>\n";
 | 
|---|
| 60 |                 $output .= '<option value="">'.attribute_escape($select_str) . "</option>\n";
 | 
|---|
| 61 |                 $output .=      $get_archives_output;
 | 
|---|
| 62 |                 $output .=      "</select>\n";
 | 
|---|
| 63 |                 
 | 
|---|
| 64 |         } else {
 | 
|---|
| 65 |                 $output  = "<ul>\n";
 | 
|---|
| 66 |                 $output .=  $get_archives_output;
 | 
|---|
| 67 |                 $output  .= "</ul>\n";
 | 
|---|
| 68 |         }
 | 
|---|
| 69 |         $block['archive'] = $output;
 | 
|---|
| 70 |         return $block ; 
 | 
|---|
| 71 | }
 | 
|---|
| 72 | 
 | 
|---|
| 73 | ?> | 
|---|