Making WordPress.org

Changeset 2730


Ignore:
Timestamp:
03/10/2016 07:19:29 PM (8 years ago)
Author:
iandunn
Message:

WordCamp Post Type: Import Multi-Event Sponsor meta data into new sites.

See https://wordpress.slack.com/archives/meta-wordcamp/p1457543255000208

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-new-site.php

    r2506 r2730  
    586586                    'term'           => $assigned_sponsor->sponsorship_level->post_name,
    587587                    'featured_image' => isset( $assigned_sponsor_data['featured_images'][ $assigned_sponsor->ID ] ) ? $assigned_sponsor_data['featured_images'][ $assigned_sponsor->ID ] : '',
     588                    'meta'           => $this->get_stub_me_sponsors_meta( $assigned_sponsor ),
    588589                );
    589590            }
     
    591592
    592593        return $me_sponsors;
     594    }
     595
     596    /**
     597     * Get the meta data for a `mes` post and prepare it for importing into a `wcb_sponsor` post
     598     *
     599     * @param WP_Post $assigned_sponsor
     600     *
     601     * @return array
     602     */
     603    protected function get_stub_me_sponsors_meta( $assigned_sponsor ) {
     604        $sponsor_meta    = array();
     605        $meta_field_keys = array(
     606            'company_name', 'website', 'first_name', 'last_name', 'email_address', 'phone_number',
     607            'street_address1', 'street_address2', 'city', 'state', 'zip_code', 'country'
     608        );
     609
     610        switch_to_blog( BLOG_ID_CURRENT_SITE );
     611
     612        foreach ( $meta_field_keys as $key ) {
     613            $sponsor_meta["_wcpt_sponsor_$key"] = get_post_meta( $assigned_sponsor->ID, "mes_$key", true );
     614        }
     615
     616        restore_current_blog();
     617
     618        return $sponsor_meta;
    593619    }
    594620
Note: See TracChangeset for help on using the changeset viewer.