Making WordPress.org


Ignore:
Timestamp:
05/13/2015 11:17:13 PM (11 years ago)
Author:
iandunn
Message:

WordCamp Post Type: Abstract the gathering of assigned sponsor data.

File:
1 edited

Legend:

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

    r1563 r1571  
    253253     */
    254254    protected function get_stub_pages( $wordcamp, $meta ) {
     255        // todo remove the to field from all contact forms and notes, just let it default to the admin email
     256
    255257        $pages = array(
    256258            array(
     
    581583
    582584    /**
     585     * Get the assigned Multi-Event Sponsors and their sponsorship levels for the given WordCamp
     586     *
     587     * @param int $wordcamp_id
     588     *
     589     * @return array
     590     */
     591    protected function get_assigned_sponsor_data( $wordcamp_id ) {
     592        /** @var $multi_event_sponsors Multi_Event_Sponsors */
     593        global $multi_event_sponsors;
     594        $data = array();
     595
     596        switch_to_blog( BLOG_ID_CURRENT_SITE ); // central.wordcamp.org
     597
     598        $data['assigned_sponsors']  = $multi_event_sponsors->get_wordcamp_me_sponsors( $wordcamp_id, 'sponsor_level' );
     599        $data['sponsorship_levels'] = get_posts( array(
     600            'post_type'   => MES_Sponsorship_Level::POST_TYPE_SLUG,
     601            'numberposts' => -1
     602        ) );
     603
     604        restore_current_blog();
     605
     606        return $data;
     607    }
     608
     609    /**
    583610     * Generate stub posts for thanking Multi-Event Sponsors
    584611     *
     
    596623        $pages = array();
    597624
    598         switch_to_blog( BLOG_ID_CURRENT_SITE ); // central.wordcamp.org
    599         $assigned_me_sponsors = $multi_event_sponsors->get_wordcamp_me_sponsors( $wordcamp->ID, 'sponsor_level' );
    600         $sponsorship_levels   = get_posts( array(
    601             'post_type'   => MES_Sponsorship_Level::POST_TYPE_SLUG,
    602             'numberposts' => -1
    603         ) );
    604         restore_current_blog();
    605 
    606         foreach ( $sponsorship_levels as $sponsorship_level ) {
    607             if ( ! empty( $assigned_me_sponsors[ $sponsorship_level->ID ] ) ) {
     625        $assigned_sponsor_data = $this->get_assigned_sponsor_data( $wordcamp->ID );
     626
     627        foreach ( $assigned_sponsor_data['sponsorship_levels'] as $sponsorship_level ) {
     628            if ( ! empty( $assigned_sponsor_data['assigned_sponsors'][ $sponsorship_level->ID ] ) ) {
    608629                $pages[] = array(
    609630                    'title'   => sprintf( __( 'Thank you to our %s sponsors', 'wordcamporg' ), $sponsorship_level->post_title ),
     
    612633                        str_replace(
    613634                            '[sponsor_names]',
    614                             $multi_event_sponsors->get_sponsor_names( $assigned_me_sponsors[ $sponsorship_level->ID ] ),
     635                            $multi_event_sponsors->get_sponsor_names( $assigned_sponsor_data['assigned_sponsors'][ $sponsorship_level->ID ] ),
    615636                            $sponsorship_level->post_excerpt
    616637                        ),
    617                         $multi_event_sponsors->get_sponsor_excerpts( $assigned_me_sponsors[ $sponsorship_level->ID ] )
     638                        $multi_event_sponsors->get_sponsor_excerpts( $assigned_sponsor_data['assigned_sponsors'][ $sponsorship_level->ID ] )
    618639                    ),
    619640                    'status'  => 'draft',
Note: See TracChangeset for help on using the changeset viewer.