diff --git a/trunk/public_html/wp-content/plugins/wordcamp-coming-soon-page/TODO.txt b/trunk/public_html/wp-content/plugins/wordcamp-coming-soon-page/TODO.txt index 9b8d5d255a..0a8ad5d290 100644 --- a/trunk/public_html/wp-content/plugins/wordcamp-coming-soon-page/TODO.txt +++ b/trunk/public_html/wp-content/plugins/wordcamp-coming-soon-page/TODO.txt @@ -1,24 +1,26 @@ High priority: - wccsp_image_id contact form bug confirmation that contact form was sent display dates make work consistently with any theme warn user that image preview won't update until they save settings + refactor get_contact_form_shortcode() once https://github.com/Automattic/jetpack/issues/102 is fixed Medium priority: add color pickers update image preview after they pick new but before they save/refresh - customize image size in template + add admin notice if missing page w/ contact form or it's not published contact form shortcode - lookup email from wordcamp cpt instead of admin email? internationalize any other TODOs in code + customize image size in template + - Low priority: styles make responsive & mobile-first make contact box align w/ right edge of intro text properly instead of workaround contact form submitted to latest post url instead of current page (if on home page) - make dashes/underscores consistent in html element ids/names \ No newline at end of file + make dashes/underscores consistent in html element ids/names + \ No newline at end of file diff --git a/trunk/public_html/wp-content/plugins/wordcamp-coming-soon-page/classes/wordcamp-coming-soon-page.php b/trunk/public_html/wp-content/plugins/wordcamp-coming-soon-page/classes/wordcamp-coming-soon-page.php index 7daaae4fdb..fe447c05e8 100644 --- a/trunk/public_html/wp-content/plugins/wordcamp-coming-soon-page/classes/wordcamp-coming-soon-page.php +++ b/trunk/public_html/wp-content/plugins/wordcamp-coming-soon-page/classes/wordcamp-coming-soon-page.php @@ -136,21 +136,45 @@ public function get_dates() { } /** - * Generate the contact form shortcode string - * - * @return string + * Retrieve the contact form shortcode string + * + * We can't just create an arbitrary shortcode because of https://github.com/Automattic/jetpack/issues/102. Instead we have to use a form that's tied to a page. + * This is somewhat fragile, though. It should work in most cases because the first $page that contains [contact-form] will be the one we automatically create + * when the site is created, but if the organizers delete that and then add multiple forms, the wrong form could be displayed. The alternative approaches also + * have problems, though, and #102 should be fixed relatively soon, so hopefully this will be good enough until it can be refactored. + * todo Refactor this once #102-jetpack is fixed. + * + * @return string|false */ public function get_contact_form_shortcode() { - $shortcode = sprintf( - "[contact-form to='%s' subject='%s contact request'] - [contact-field label='Name' type='name' required='1' /] - [contact-field label='Email' type='email' required='1' /] - [contact-field label='Comment' type='textarea' required='1' /] - [/contact-form]", - get_bloginfo( 'name' ), - get_option( 'admin_email' ) - ); + $contact_form_shortcode = false; + $shortcode_regex = get_shortcode_regex(); + + $all_pages = get_posts( array( + 'post_type' => 'page', + 'post_status' => 'any', + 'posts_per_page' => -1, + ) ); + + foreach ( $all_pages as $page ) { + preg_match_all( '/' . $shortcode_regex . '/s', $page->post_content, $matches, PREG_SET_ORDER ); + + foreach ( $matches as $shortcode ) { + if ( 'contact-form' === $shortcode[2] ) { + global $post; + $post = $page; + setup_postdata( $post ); + + ob_start(); + echo do_shortcode( $shortcode[0] ); + $contact_form_shortcode = ob_get_clean(); + + wp_reset_postdata(); + break; + } + } + } - return $shortcode; + return $contact_form_shortcode; } } // end WordCamp_Coming_Soon_Page diff --git a/trunk/public_html/wp-content/plugins/wordcamp-coming-soon-page/views/template-coming-soon.php b/trunk/public_html/wp-content/plugins/wordcamp-coming-soon-page/views/template-coming-soon.php index 3248e62e1f..a712e821ce 100644 --- a/trunk/public_html/wp-content/plugins/wordcamp-coming-soon-page/views/template-coming-soon.php +++ b/trunk/public_html/wp-content/plugins/wordcamp-coming-soon-page/views/template-coming-soon.php @@ -36,7 +36,7 @@

Contact the Organizers

- +