Making WordPress.org


Ignore:
Timestamp:
06/04/2014 09:50:47 PM (12 years ago)
Author:
iandunn
Message:

WordCamp Post Type: Remove MES notification when WordCamps are scheduled.

This was migrated to the WordCamp Organizer Reminders plugin, since it's a more appropriate place for automated e-mails like this.

File:
1 edited

Legend:

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

    r664 r674  
    4343                // Post status transitions
    4444                add_action( 'transition_post_status', array( $this, 'add_organizer_to_central' ), 10, 3 );
    45                 add_action( 'transition_post_status', array( $this, 'notify_mes_sponsors_when_wordcamp_scheduled' ), 10, 3 );
    4645                add_action( 'wp_insert_post_data',    array( $this, 'require_complete_meta_to_publish_wordcamp' ), 10, 2 );
    4746
     
    444443
    445444        /**
    446          * Notify Multi Event Sponsors when a new WordCamp in their region is added to the schedule.
    447          *
    448          * This assumes that all of the meta fields we use are filled in, but that should be a safe assumption
    449          * since we require them to be before publishing the post. This will need to be updated if that ever
    450          * changes, though.
    451          *
    452          * @param string  $new_status
    453          * @param string  $old_status
    454          * @param WP_Post $wordcamp
    455          */
    456         public function notify_mes_sponsors_when_wordcamp_scheduled( $new_status, $old_status, $wordcamp ) {
    457                 if ( empty( $wordcamp->post_type ) || WCPT_POST_TYPE_ID != $wordcamp->post_type ) {
    458                         return;
    459                 }
    460 
    461                 if ( 'pending' != $old_status || 'publish' != $new_status || ! class_exists( 'MES_Sponsor' )) {
    462                         return;
    463                 }
    464 
    465                 $wordcamp_region = (int) get_post_meta( $wordcamp->ID, 'Multi-Event Sponsor Region', true );
    466 
    467                 if ( ! $wordcamp_region ) {
    468                         return;
    469                 }
    470 
    471                 $wordcamp_sponsor_wrangler_email = get_post_meta( $wordcamp->ID, 'Sponsor Wrangler E-mail Address', true );
    472                 $wordcamp_lead_organizer_email   = get_post_meta( $wordcamp->ID, 'Email Address', true );
    473 
    474                 $mes_sponsors = get_posts( array(
    475                         'post_type'   => MES_Sponsor::POST_TYPE_SLUG,
    476                         'numberposts' => -1,
    477                 ) );
    478 
    479                 foreach ( $mes_sponsors as $sponsor ) {
    480                         $sponsor_email_address         = get_post_meta( $sponsor->ID, 'mes_email_address', true );
    481                         $sponsor_first_name            = get_post_meta( $sponsor->ID, 'mes_first_name', true );
    482                         $sponsor_regional_sponsorships = get_post_meta( $sponsor->ID, 'mes_regional_sponsorships', true );
    483 
    484                         if ( ! $sponsor_email_address || ! is_numeric( $sponsor_regional_sponsorships[ $wordcamp_region ] ) ) {
    485                                 continue;
    486                         }
    487 
    488                         $headers = array(
    489                                 'Reply-To: support@wordcamp.org',
    490                                 'CC: ' . $wordcamp_sponsor_wrangler_email . ', ' . $wordcamp_lead_organizer_email,
    491                         );
    492 
    493                         $message_body = sprintf(
    494                                 "Howdy, %s! This email is to tell you that %s has been added to the schedule and has accepted your sponsorship offer.
    495 
    496                                 Their site is: %s
    497 
    498                                 Their date is: %s, and they expect about %d attendees.
    499 
    500                                 Their venue address is:
    501 
    502                                 %s
    503 
    504                                 Their shipping address is:
    505 
    506                                 %s
    507 
    508                                 Their Twitter handle is %s and their hashtag is %s
    509 
    510                                 You can reach them by emailing: %s or %s
    511 
    512                                 Your company information and logo will be displayed on the WordCamp's site shortly.
    513 
    514                                 Thanks for your support of %s!
    515 
    516                                 Best wishes,
    517 
    518                                 Andrea
    519 
    520                                 Andrea Middleton
    521                                 WordCamp Central",
    522                                 sanitize_text_field( $sponsor_first_name ),
    523                                 sanitize_text_field( $wordcamp->post_title ),
    524                                 esc_url( get_site_url( absint( get_post_meta( $wordcamp->ID, '_site_id', true ) ) ) ),
    525                                 date( 'l, F jS, Y', absint( get_post_meta( $wordcamp->ID, 'Start Date (YYYY-mm-dd)', true ) ) ),
    526                                 absint( get_post_meta( $wordcamp->ID, 'Number of Anticipated Attendees', true ) ),
    527                                 strip_tags( get_post_meta( $wordcamp->ID, 'Physical Address', true ) ),
    528                                 strip_tags( get_post_meta( $wordcamp->ID, 'Mailing Address', true ) ),
    529                                 esc_url( 'https://twitter.com/' . get_post_meta( $wordcamp->ID, 'Twitter', true ) ),
    530                                 esc_url( 'https://twitter.com/hashtag/' . get_post_meta( $wordcamp->ID, 'WordCamp Hashtag', true ) ),
    531                                 sanitize_text_field( get_post_meta( $wordcamp->ID, 'E-mail Address', true ) ),
    532                                 sanitize_text_field( get_post_meta( $wordcamp->ID, 'Sponsor Wrangler E-mail Address', true ) ),
    533                                 sanitize_text_field( $wordcamp->post_title )
    534                         );
    535 
    536                         wp_mail(
    537                                 $sponsor_email_address,
    538                                 $wordcamp->post_title . ' has accepted your sponsorship offer',
    539                                 str_replace( "\t", '', $message_body ),
    540                                 $headers
    541                         );
    542                 }
    543         }
    544 
    545         /**
    546445         * Prevent WordCamp posts from being published until all the required fields are completed.
    547446         *
Note: See TracChangeset for help on using the changeset viewer.