Making WordPress.org

Changeset 5530


Ignore:
Timestamp:
05/31/2017 10:18:31 PM (9 years ago)
Author:
coreymckrill
Message:

WordCamp Central: Add year to camp dates on the schedule

Changes the Schedule page template to emulate the organization on the
Past Camps page template, by grouping camps under a year header and
including the year in each camp's date.

This also adds a param to WordCamp_Central_Theme::the_wordcamp_date to
include the year in the camp date output. The default is to not include
it, for backcompat.

Props frq
Fixes #2065

Location:
sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/functions.php

    r4781 r5530  
    718718        }
    719719
    720         public static function the_wordcamp_date( $wordcamp_id = 0 ) {
     720        /**
     721         * Output the date or date range of a WordCamp event.
     722         *
     723         * @param int  $wordcamp_id The ID of the WordCamp post.
     724         * @param bool $show_year   Optional. True to include the year in the date output.
     725         */
     726        public static function the_wordcamp_date( $wordcamp_id = 0, $show_year = false ) {
    721727                $start_day = wcpt_get_wordcamp_start_date( $wordcamp_id, 'j' );
    722728                $start_month = wcpt_get_wordcamp_start_date( $wordcamp_id, 'F' );
    … …  
    724730                $end_month = wcpt_get_wordcamp_end_date( $wordcamp_id, 'F' );
    725731
     732                if ( $show_year ) {
     733                        $start_year = wcpt_get_wordcamp_start_date( $wordcamp_id, 'Y' );
     734                        $end_year   = wcpt_get_wordcamp_end_date( $wordcamp_id, 'Y' );
     735                }
     736
    726737                echo "$start_month $start_day";
     738
    727739                if ( $end_day ) {
    728                         echo '-';
    729                         if ( $start_month != $end_month )
     740                        if ( $show_year && $start_year !== $end_year ) {
     741                                echo ", $start_year";
     742                        }
     743
     744                        echo '–';
     745
     746                        if ( $start_month !== $end_month ) {
    730747                                echo "$end_month ";
     748                        }
    731749
    732750                        echo $end_day;
     751
     752                        if ( $show_year ) {
     753                                echo ", $end_year";
     754                        }
     755                } elseif ( $show_year ) {
     756                        echo ", $start_year";
    733757                }
    734758        }
  • sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/template-past-wordcamps.php

    r4038 r5530  
    6565
    6666                                                                                <span class="wc-date">
    67                                                                                         <?php WordCamp_Central_Theme::the_wordcamp_date( $post->ID ); ?>,
    68                                                                                         <?php wcpt_wordcamp_start_date( $post->ID, 'Y' ); ?>
     67                                                                                        <?php WordCamp_Central_Theme::the_wordcamp_date( $post->ID, true ); ?>
    6968                                                                                </span>
    7069                                                                        </a>
  • sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/template-schedule.php

    r5165 r5530  
    3838                                                ) )
    3939                                        ) :
     40                                                global $wcpt_template;
     41                                                $wordcamps = WordCamp_Central_Theme::group_wordcamps_by_year( $wcpt_template->posts );
    4042                                        ?>
    4143
    42                                         <ul class="wc-schedule-list">
    43                                         <?php while ( wcpt_wordcamps() ) : wcpt_the_wordcamp(); ?>
     44                                        <?php foreach ( $wordcamps as $year => $posts ) : ?>
     45                                                <h3 class="wc-schedule-year"><?php echo esc_html( $year ); ?></h3>
    4446
    45                                                 <li>
    46                                                         <a href="<?php echo esc_url( wcpt_get_wordcamp_url() ); ?>">
    47                                                                 <?php if ( has_post_thumbnail() ) : ?>
    48                                                                         <?php the_post_thumbnail( 'wccentral-thumbnail-small', array( 'class' => 'wc-image' ) ); ?>
    49                                                                 <?php else : ?>
    50                                                                         <div class="wc-image wp-post-image wordcamp-placeholder-thumb" title="<?php the_title(); ?>"></div>
    51                                                                 <?php endif; ?>
     47                                                <ul class="wc-schedule-list">
     48                                                        <?php foreach ( $posts as $post ) :     setup_postdata( $post ); ?>
    5249
    53                                                                 <h2 class="wc-title"><?php wcpt_wordcamp_title(); ?></h2>
    54                                                                 <span class="wc-country"><?php wcpt_wordcamp_location(); ?></span>
    55                                                                 <span class="wc-date">
    56                                                                         <?php WordCamp_Central_Theme::the_wordcamp_date(); ?>
    57                                                                 </span>
    58                                                         </a>
    59                                                 </li>
     50                                                                <li>
     51                                                                        <a href="<?php echo esc_url( WordCamp_Central_Theme::get_best_wordcamp_url( $post->ID ) ); ?>">
     52                                                                                <?php if ( has_post_thumbnail() ) : ?>
     53                                                                                        <?php the_post_thumbnail( 'wccentral-thumbnail-small', array( 'class' => 'wc-image' ) ); ?>
     54                                                                                <?php else : ?>
     55                                                                                        <div class="wc-image wp-post-image wordcamp-placeholder-thumb" title="<?php the_title(); ?>"></div>
     56                                                                                <?php endif; ?>
    6057
    61                                         <?php endwhile; // wcpt_wordcamps ?>
    62                                 </ul>
     58                                                                                <h2 class="wc-title"><?php wcpt_wordcamp_title(); ?></h2>
     59                                                                                <span class="wc-country"><?php wcpt_wordcamp_location( $post->ID ); ?></span>
     60
     61                                                                                <span class="wc-date">
     62                                                                                        <?php WordCamp_Central_Theme::the_wordcamp_date( $post->ID, true ); ?>
     63                                                                                </span>
     64                                                                        </a>
     65                                                                </li>
     66
     67                                                        <?php endforeach; // $posts as post ?>
     68                                                </ul>
     69                                        <?php wp_reset_postdata(); endforeach; ?>
     70
    6371                                <a href="<?php echo home_url( '/schedule/past-wordcamps/' ); ?>" class="wc-schedule-more">Past WordCamps &rarr;</a>
    6472
Note: See TracChangeset for help on using the changeset viewer.