diff --git a/modules/contact-form/grunion-contact-form.php b/modules/contact-form/grunion-contact-form.php index b8ba737fd2911..80b129ee126de 100644 --- a/modules/contact-form/grunion-contact-form.php +++ b/modules/contact-form/grunion-contact-form.php @@ -198,12 +198,20 @@ function process_form_submission() { // Get shortcode from post meta $shortcode = get_post_meta( $_POST['contact-form-id'], '_g_feedback_shortcode', true ); - // Get the attributes from post meta. $attributes not available here - $atts = get_post_meta( $_POST['contact-form-id'], '_g_feedback_shortcode_atts', true ); // Format it if ( $shortcode != '' ) { - $shortcode = '[contact-form'.$atts.']' . $shortcode . '[/contact-form]'; + + // Get attributes from post meta. + $parameters = ''; + $attributes = get_post_meta( $_POST['contact-form-id'], '_g_feedback_shortcode_atts', true ); + if ( ! empty( $attributes ) && is_array( $attributes ) ) { + foreach( array_filter( $attributes ) as $param => $value ) { + $parameters .= " $param=\"$value\""; + } + } + + $shortcode = '[contact-form' . $parameters . ']' . $shortcode . '[/contact-form]'; do_shortcode( $shortcode ); // Recreate form @@ -971,19 +979,11 @@ static function store_shortcode( $content = null, $attributes = null ) { $shortcode_meta = get_post_meta( $attributes['id'], '_g_feedback_shortcode', true ); - // Iterate through $attributes and concatenate as a string. - $atts = ' '; - foreach ($attributes as $key => $value) { - if ( '' != $value ) { - $atts .= $key.'="'.$value.'" '; - } else { - $atts .= $key.' '; - } - } - if ( $shortcode_meta != '' or $shortcode_meta != $content ) { update_post_meta( $attributes['id'], '_g_feedback_shortcode', $content ); - update_post_meta( $attributes['id'], '_g_feedback_shortcode_atts', $atts ); // Save the atts string to post_meta for later use. $sttributes is not available later in do_shortcode situations. + + // Save attributes to post_meta for later use. They're not available later in do_shortcode situations. + update_post_meta( $attributes['id'], '_g_feedback_shortcode_atts', $attributes ); } }