Making WordPress.org


Ignore:
Timestamp:
03/24/2016 10:23:16 PM (10 years ago)
Author:
iandunn
Message:

WordCamp Forms to Drafts: Remove organizer application processing.

This hasn't been used for awhile, and is being replaced with a different method in wcpt soon.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-forms-to-drafts/wordcamp-forms-to-drafts.php

    r1291 r2796  
    2424        add_filter( 'the_content',              array( $this, 'force_login_to_view_form' ), 9 );
    2525        add_action( 'template_redirect',        array( $this, 'populate_form_based_on_user' ), 9 );
    26         add_action( 'grunion_pre_message_sent', array( $this, 'returning_organizer_application' ), 10, 3 );
    27         add_action( 'grunion_pre_message_sent', array( $this, 'new_organizer_application' ), 10, 3 );
    2826        add_action( 'grunion_pre_message_sent', array( $this, 'call_for_sponsors' ), 10, 3 );
    2927        add_action( 'grunion_pre_message_sent', array( $this, 'call_for_speakers' ), 10, 3 );
     
    196194            $wp_post_types[ $post_type ]->name = $post_type;
    197195        }
    198     }
    199 
    200     /**
    201      * Create a draft WordCamp post from a Returning Organizer Application submission.
    202      *
    203      * @param int   $submission_id
    204      * @param array $all_values
    205      * @param array $extra_values
    206      */
    207     public function returning_organizer_application( $submission_id, $all_values, $extra_values ) {
    208         if ( 'returning-organizer-application' != $this->get_form_key( $submission_id ) ) {
    209             return;
    210         }
    211 
    212         $all_values               = $this->get_unprefixed_grunion_form_values( $all_values );
    213         $wordcamp_to_form_key_map = array(
    214             'Location'                        => 'WordCamp City, State, Country',
    215             'Organizer Name'                  => 'Lead Organizer Name',
    216             'WordPress.org Username'          => 'Lead Organizer WordPress.org Username',
    217             'Email Address'                   => 'Lead Organizer Email',
    218             'Sponsor Wrangler Name'           => 'Sponsor Wrangler Name',
    219             'Sponsor Wrangler E-mail Address' => 'Sponsor Wrangler E-mail Address',
    220             'Budget Wrangler Name'            => 'Budget Wrangler Name',
    221             'Budget Wrangler E-mail Address'  => 'Budget Wrangler E-mail Address',
    222             'Number of Anticipated Attendees' => 'Number of Anticipated Attendees',
    223         );
    224 
    225         $this->simulate_post_type( 'wordcamp' );
    226 
    227         switch_to_blog( BLOG_ID_CURRENT_SITE ); // central.wordcamp.org
    228 
    229         // Create the post
    230         $draft_id = wp_insert_post( array(
    231             'post_type'   => 'wordcamp',
    232             'post_title'  => 'WordCamp ' . $all_values['WordCamp City, State, Country'],
    233             'post_status' => 'draft',
    234             'post_author' => $this->get_user_id_from_username( $all_values['Lead Organizer WordPress.org Username'] ),
    235         ) );
    236 
    237         // Create the post meta
    238         if ( $draft_id ) {
    239             foreach ( $wordcamp_to_form_key_map as $wordcamp_key => $form_key ) {
    240                 if ( ! empty( $all_values[ $form_key ] ) ) {
    241                     update_post_meta( $draft_id, $wordcamp_key, $all_values[ $form_key ] );
    242                 }
    243             }
    244         }
    245 
    246         restore_current_blog();
    247     }
    248 
    249     /**
    250      * Create a draft WordCamp post from a New Organizer Application submission.
    251      *
    252      * @param int   $submission_id
    253      * @param array $all_values
    254      * @param array $extra_values
    255      */
    256     public function new_organizer_application( $submission_id, $all_values, $extra_values ) {
    257         if ( 'new-organizer-application' != $this->get_form_key( $submission_id ) ) {
    258             return;
    259         }
    260 
    261         $all_values               = $this->get_unprefixed_grunion_form_values( $all_values );
    262         $wordcamp_to_form_key_map = array(
    263             'Location'                        => 'Enter the city, state/province, and country where you would like to organize a WordCamp.',
    264             'Organizer Name'                  => 'Lead Organizer Name',
    265             'WordPress.org Username'          => "Lead Organizer WordPress.org Username. This is the username you'd use to log in to http://wordpress.org/support/. If you don't have one, you can register on wordpress.org at https://wordpress.org/support/register.php",
    266             'Email Address'                   => 'Lead Organizer Email',
    267             'Number of Anticipated Attendees' => 'How many people do you think would attend?',
    268         );
    269 
    270         $this->simulate_post_type( 'wordcamp' );
    271 
    272         switch_to_blog( BLOG_ID_CURRENT_SITE ); // central.wordcamp.org
    273 
    274         // Create the post
    275         $draft_id = wp_insert_post( array(
    276             'post_type'   => 'wordcamp',
    277             'post_title'  => 'WordCamp ' . $all_values['Enter the city, state/province, and country where you would like to organize a WordCamp.'],
    278             'post_status' => 'draft',
    279             'post_author' => $this->get_user_id_from_username( $all_values["Lead Organizer WordPress.org Username. This is the username you'd use to log in to http://wordpress.org/support/. If you don't have one, you can register on wordpress.org at https://wordpress.org/support/register.php"] ),
    280         ) );
    281 
    282         // Create the post meta
    283         if ( $draft_id ) {
    284             foreach ( $wordcamp_to_form_key_map as $wordcamp_key => $form_key ) {
    285                 if ( ! empty( $all_values[ $form_key ] ) ) {
    286                     update_post_meta( $draft_id, $wordcamp_key, $all_values[ $form_key ] );
    287                 }
    288             }
    289 
    290             $mailing_address = sprintf(
    291                 "%s%s, %s %s\n%s",
    292                 empty( $all_values['Lead Organizer Street Address'] ) ? '' : $all_values['Lead Organizer Street Address'] . "\n",
    293                 $all_values['City'],
    294                 $all_values['State/Province'],
    295                 empty( $all_values['ZIP/Postal Code'] ) ? '' : $all_values['ZIP/Postal Code'],
    296                 $all_values['Country']
    297             );
    298 
    299             update_post_meta( $draft_id, 'Mailing Address', $mailing_address );
    300         }
    301 
    302         restore_current_blog();
    303196    }
    304197
Note: See TracChangeset for help on using the changeset viewer.