archives.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. /*
  3. Template Name: Archives Template
  4. */
  5. /************* Archive Category Walker *****************/
  6. $ms_stylesheet_directory = get_bloginfo('stylesheet_directory');
  7. class Walker_Category_Rabbit extends Walker_Category {
  8. function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
  9. extract($args);
  10. global $ms_stylesheet_directory;
  11. $cat_name = esc_attr( $category->name );
  12. $cat_name = apply_filters( 'list_cats', $cat_name, $category );
  13. $link = '<a href="' . esc_url( get_term_link($category) ) . '" ';
  14. if ( $use_desc_for_title == 0 || empty($category->description) )
  15. $link .= 'title="' . esc_attr( sprintf(__( 'View all posts filed under %s' ), $cat_name) ) . '"';
  16. else
  17. $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
  18. $link .= '>';
  19. $link .= $cat_name . '</a>';
  20. if ( !empty($feed_image) || !empty($feed) ) {
  21. $link .= ' ';
  22. if ( empty($feed_image) )
  23. $link .= '(';
  24. $link .= '<a href="' . esc_url( get_term_feed_link( $category->term_id, $category->taxonomy, $feed_type ) ) . '"';
  25. if ( empty($feed) ) {
  26. $alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s' ), $cat_name ) . '"';
  27. } else {
  28. $title = ' title="' . $feed . '"';
  29. $alt = ' alt="' . $feed . '"';
  30. $name = $feed;
  31. $link .= $title;
  32. }
  33. $link .= '>';
  34. if ( empty($feed_image) )
  35. $link .= $name;
  36. else
  37. $link .= "<img src='$feed_image'$alt$title" . ' />';
  38. $link .= '</a>';
  39. if ( empty($feed_image) )
  40. $link .= ')';
  41. }
  42. if ( !empty($show_count) )
  43. $link .= ' (' . intval($category->count) . ')';
  44. if ( 'list' == $args['style'] ) {
  45. $output .= "\t<li";
  46. $class = 'cat-item cat-item-' . $category->term_id;
  47. if ( !empty($current_category) ) {
  48. $_current_category = get_term( $current_category, $category->taxonomy );
  49. if ( $category->term_id == $current_category )
  50. $class .= ' current-cat';
  51. elseif ( $category->term_id == $_current_category->parent )
  52. $class .= ' current-cat-parent';
  53. }
  54. $output .= ' class="' . $class . '"';
  55. $output .= ">$link\n";
  56. } else {
  57. $output .= "\t$link<br />\n";
  58. }
  59. }
  60. }
  61. /* called in archives.php
  62. adds link to mosaic_page for monthly archives */
  63. function miech_archive_mosaic_filter ( $link_html ) {
  64. preg_match('/\/(\d\d\d\d)\/(\d\d)\//', $link_html, $match);
  65. $link_html = preg_replace('/<li>\s*<a href=["\'].*?["\']/i', '<li><a href="' . home_url() . '/image-mosaic?mosaic_month=' . $match[2]
  66. . '&mosaic_year=' . $match[1] . '"', $link_html );
  67. return $link_html;
  68. }
  69. /* debugging helper
  70. from http://www.stumiller.me/sending-output-to-the-wordpress-debug-log/ */
  71. if (!function_exists('write_log')) {
  72. function write_log ( $log ) {
  73. if ( true === WP_DEBUG ) {
  74. if ( is_array( $log ) || is_object( $log ) ) {
  75. error_log( print_r( $log, true ) );
  76. } else {
  77. error_log( $log );
  78. }
  79. }
  80. }
  81. }
  82. ?>
  83. <?php get_header(); ?>
  84. <div id="content" class="site-content">
  85. <div id="primary" class="content-area">
  86. <main id="main" class="site-main" role="main">
  87. <article id="post-31164" class="post-31164 page type-page status-publish hentry entry">
  88. <header class="entry-header alignwide">
  89. <h1 class="entry-title">Archives</h1>
  90. </header>
  91. <div class="entry-content">
  92. <div class="wp-block-columns">
  93. <div class="wp-block-column">
  94. <strong>Archives by Month</strong>
  95. <ul>
  96. <?php
  97. # add_filter('get_archives_link', 'miech_archive_mosaic_filter', 10, 1);
  98. wp_get_archives('type=monthly&show_post_count=1');
  99. # remove_filter('get_archives_link', 'miech_archive_mosaic_filter', 10, 1);
  100. ?>
  101. </ul>
  102. </div>
  103. <div class="wp-block-column">
  104. <strong>Archives by Category</strong>
  105. <ul>
  106. <?php /* wp_list_categories('title_li=0&show_count=1&exclude=1140&walker=Walker_Category_Rabbit'); */
  107. $MyWalker = new Walker_Category_Rabbit();
  108. wp_list_categories(array('title_li' => 0,
  109. 'show_count' => 1,
  110. /* 'exclude' => '1140', */
  111. 'walker' => $MyWalker));
  112. ?><!-- -->
  113. </ul>
  114. </div>
  115. </div>
  116. </div>
  117. </article>
  118. <?php get_footer(); ?>