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