Making WordPress.org

Changeset 955


Ignore:
Timestamp:
10/29/2014 10:43:49 PM (10 years ago)
Author:
iandunn
Message:

WordCamp Coming Soon Page: Replace redundant code with get_wordcamp_post().

Also remove redundant isset() checks, since empty() will not throw a warning if the index isn't set.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-coming-soon-page/classes/wordcamp-coming-soon-page.php

    r398 r955  
    153153    public function get_dates() {
    154154        $dates = false;
    155         $wordcamp_site_url = site_url();
    156        
    157         switch_to_blog( BLOG_ID_CURRENT_SITE );
    158        
    159         $wordcamp_post = get_posts( array(
    160             'post_type'   => 'wordcamp',
    161             'post_status' => 'any',
    162             'meta_query'  => array(
    163                 array(
    164                     'key'   => 'URL',
    165                     'value' => $wordcamp_site_url,
    166                 ),
    167             ),
    168         ) );
    169        
    170         if ( isset( $wordcamp_post[0]->ID ) ) {
    171             $wordcamp_post_meta = get_post_custom( $wordcamp_post[0]->ID );
    172            
    173             if ( isset( $wordcamp_post_meta['Start Date (YYYY-mm-dd)'][0] ) && ! empty( $wordcamp_post_meta['Start Date (YYYY-mm-dd)'][0] ) ) {
    174                 $dates = date( 'l, F jS Y', $wordcamp_post_meta['Start Date (YYYY-mm-dd)'][0] );
    175 
    176                 if ( isset( $wordcamp_post_meta['End Date (YYYY-mm-dd)'][0] ) && ! empty( $wordcamp_post_meta['End Date (YYYY-mm-dd)'][0] ) ) {
    177                     $dates .= ' - ' . date( 'l, F jS Y', $wordcamp_post_meta['End Date (YYYY-mm-dd)'][0] );
     155        $wordcamp_post = get_wordcamp_post();
     156
     157        if ( isset( $wordcamp_post->ID ) ) {
     158            if ( ! empty( $wordcamp_post->meta['Start Date (YYYY-mm-dd)'][0] ) ) {
     159                $dates = date( 'l, F jS Y', $wordcamp_post->meta['Start Date (YYYY-mm-dd)'][0] );
     160
     161                if ( ! empty( $wordcamp_post->meta['End Date (YYYY-mm-dd)'][0] ) ) {
     162                    $dates .= ' - ' . date( 'l, F jS Y', $wordcamp_post->meta['End Date (YYYY-mm-dd)'][0] );
    178163                }
    179164            }
    180165        }
    181        
    182         restore_current_blog();
    183166       
    184167        return $dates;
Note: See TracChangeset for help on using the changeset viewer.