Changeset 2796 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-forms-to-drafts/wordcamp-forms-to-drafts.php
- Timestamp:
- 03/24/2016 10:23:16 PM (10 years ago)
- 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 24 24 add_filter( 'the_content', array( $this, 'force_login_to_view_form' ), 9 ); 25 25 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 );28 26 add_action( 'grunion_pre_message_sent', array( $this, 'call_for_sponsors' ), 10, 3 ); 29 27 add_action( 'grunion_pre_message_sent', array( $this, 'call_for_speakers' ), 10, 3 ); … … 196 194 $wp_post_types[ $post_type ]->name = $post_type; 197 195 } 198 }199 200 /**201 * Create a draft WordCamp post from a Returning Organizer Application submission.202 *203 * @param int $submission_id204 * @param array $all_values205 * @param array $extra_values206 */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.org228 229 // Create the post230 $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 meta238 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_id253 * @param array $all_values254 * @param array $extra_values255 */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.org273 274 // Create the post275 $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 meta283 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();303 196 } 304 197
Note: See TracChangeset
for help on using the changeset viewer.