Making WordPress.org

Changeset 1643


Ignore:
Timestamp:
06/02/2015 07:59:40 PM (10 years ago)
Author:
iandunn
Message:

WordCamp Organizer Reminders: Add multi_event_sponsor_info placeholder.

Location:
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-organizer-reminders
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-mailer.php

    r1396 r1643  
    142142     * but those that aren't are filled with 'N/A/'.
    143143     *
     144     * This is performant right now, but if we add more function calls in $replace then it could start to slow down,
     145     * because everything in $replace is called every time the function is called, even if its corresponding $search
     146     * value isn't present in $content. If it does, then refactor it so only replace placeholders that are actually
     147     * found.
     148     *
    144149     * @param  WP_Post $wordcamp
    145150     * @param  WP_Post $email
    146151     * @param  string  $content
     152     *
    147153     * @return string
    148154     */
     
    189195            '[venue_url]',
    190196            '[venue_contact_info]',
     197
     198            // Miscellaneous
     199            '[multi_event_sponsor_info]',
    191200        );
    192201
     
    222231            empty( $wordcamp_meta['Website URL'][0] )         ? 'N/A' : $wordcamp_meta['Website URL'][0],
    223232            empty( $wordcamp_meta['Contact Information'][0] ) ? 'N/A' : $wordcamp_meta['Contact Information'][0],
     233
     234            // Miscellaneous
     235            $this->get_mes_info( $wordcamp->ID ),
    224236        );
    225237       
    226238        return str_replace( $search, $replace, $content );
     239    }
     240
     241    /**
     242     * Get formatted general info for all of the given WordCamp's ME sponsors
     243     *
     244     * @param int $wordcamp_id
     245     *
     246     * @return string
     247     */
     248    protected function get_mes_info( $wordcamp_id ) {
     249        /** @var $multi_event_sponsors Multi_Event_Sponsors */
     250        global $multi_event_sponsors;
     251
     252        $sponsors     = $multi_event_sponsors->get_wordcamp_me_sponsors( $wordcamp_id );
     253        $sponsor_info = $multi_event_sponsors->get_sponsor_info( $sponsors );
     254        $region_id    = get_post_meta( $wordcamp_id, 'Multi-Event Sponsor Region', true );
     255
     256        if ( ! $sponsors || ! $sponsor_info ) {
     257            return '';
     258        }
     259
     260        ob_start();
     261
     262        foreach ( $sponsor_info as $sponsor ) {
     263            $sponsorship_level = get_post( $sponsor['sponsorship_levels'][ $region_id ] ); // we can assume this exists because otherwise the sponsor wouldn't be in $sponsors / $sponsor_info
     264
     265            ?>
     266
     267            Company: <?php echo esc_html( $sponsor['company_name'] ); ?>
     268
     269            Sponsorship Level: <?php echo esc_html( $sponsorship_level->post_title ); ?>
     270
     271            Contact: <?php echo sprintf(
     272                '%s %s, %s',
     273                esc_html( $sponsor['contact_first_name'] ),
     274                esc_html( $sponsor['contact_last_name'] ),
     275                esc_html( $sponsor['contact_email'] )
     276            ); ?>
     277
     278            <?php
     279        }
     280
     281        return trim( str_replace( "\t", '', ob_get_clean() ) );
    227282    }
    228283
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-reminder.php

    r1396 r1643  
    215215        </ul>
    216216
     217        <h5>Miscellaneous</h5>
     218        <ul class="ul-disc">
     219            <li>[multi_event_sponsor_info]</li>
     220        </ul>
     221
    217222        <?php
    218223    }
Note: See TracChangeset for help on using the changeset viewer.