Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[contact-form $attributes] now ok in do_shortcode #3188

Merged
merged 2 commits into from Nov 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion modules/contact-form/grunion-contact-form.php
Expand Up @@ -283,7 +283,17 @@ function process_form_submission() {

// Format it
if ( $shortcode != '' ) {
$shortcode = '[contact-form]' . $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
Expand Down Expand Up @@ -1343,6 +1353,9 @@ static function store_shortcode( $content = null, $attributes = null ) {

if ( $shortcode_meta != '' or $shortcode_meta != $content ) {
update_post_meta( $attributes['id'], '_g_feedback_shortcode', $content );

// 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 );
}

}
Expand Down