Making WordPress.org


Ignore:
Timestamp:
05/31/2017 10:18:31 PM (7 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

File:
1 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    }
Note: See TracChangeset for help on using the changeset viewer.