Making WordPress.org

Changeset 8307


Ignore:
Timestamp:
02/21/2019 05:36:35 PM (6 years ago)
Author:
coreymckrill
Message:

WordCamp: Stop importing Tagregator items 2 weeks after a camp has occurred

Fixes #1405
Props coreymckrill

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-misc.php

    r8287 r8307  
    152152
    153153/**
     154 * Tell Tagregator to stop importing items for a camp 2 weeks after it has occurred.
     155 *
     156 * @param DateTime|null $end_date The date that Tagregator should stop importing items for a camp. Default null.
     157 *
     158 * @return DateTime|null
     159 */
     160function wcorg_set_per_camp_tagregator_end_date( $end_date ) {
     161    $details = get_wordcamp_post();
     162
     163    if ( isset( $details->meta['Start Date (YYYY-mm-dd)'][0] ) ) {
     164        $offset = '2 weeks';
     165
     166        // Despite its key/label, the start date value is actually stored as a Unix timestamp.
     167        $camp_start_timestamp = $details->meta['Start Date (YYYY-mm-dd)'][0];
     168        $end_date             = date_create( date( 'Y-m-d', $camp_start_timestamp ) . '  ' . $offset );
     169    }
     170
     171    return $end_date;
     172}
     173
     174add_filter( 'tggr_end_date', 'wcorg_set_per_camp_tagregator_end_date' );
     175
     176/**
    154177 * Modify the space allocation on a per-size basis.
    155178 *
Note: See TracChangeset for help on using the changeset viewer.