Making WordPress.org

Ticket #1405: 1405-wcorg.diff

File 1405-wcorg.diff, 1.2 KB (added by coreymckrill, 7 years ago)

Patch for WordCamp.org

  • wcorg-misc.php

     
    123123add_action( 'init', 'wcorg_show_tagregator_log' );
    124124
    125125/**
     126 * Tell Tagregator to stop importing items for a camp 2 weeks after it has occurred.
     127 *
     128 * @param DateTime|null $end_date The date that Tagregator should stop importing items for a camp. Default null.
     129 */
     130function wcorg_set_per_camp_tagregator_end_date( $end_date ) {
     131        $details = get_wordcamp_post();
     132
     133        if ( isset( $details->meta['Start Date (YYYY-mm-dd)'][0] ) ) {
     134                $offset = '2 weeks';
     135
     136                // Despite its key/label, the start date value is actually stored as a Unix timestamp.
     137                $camp_start_timestamp = $details->meta['Start Date (YYYY-mm-dd)'][0];
     138                $end_date             = date_create( date( 'Y-m-d', $camp_start_timestamp ) . ' + ' . $offset );
     139        }
     140
     141        return $end_date;
     142}
     143add_filter( 'tggr_end_date', 'wcorg_set_per_camp_tagregator_end_date' );
     144
     145/**
    126146 * Prepend a unique string to contact form subjects.
    127147 *
    128148 * Otherwise some e-mail clients and management systems -- *cough* SupportPress *cough* -- will incorrectly group