Permalink
Browse files

Customize: Implement previewing of form submissions which use the GET…

… method.

This finally allows the search results template to navigated to in the customizer preview.

Fixes #20714.

Built from https://develop.svn.wordpress.org/trunk@38587


git-svn-id: http://core.svn.wordpress.org/trunk@38530 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
westonruter committed Sep 11, 2016
1 parent 132f3d0 commit edf170c943cfcfa122565c8f30c8b807e44e4dac
Showing with 25 additions and 3 deletions.
  1. +23 −1 wp-includes/js/customize-preview.js
  2. +1 −1 wp-includes/js/customize-preview.min.js
  3. +1 −1 wp-includes/version.php
@@ -67,8 +67,30 @@
});
// You cannot submit forms.
// @todo: Allow form submissions by mixing $_POST data with the customize setting $_POST data.
this.body.on( 'submit.preview', 'form', function( event ) {
var urlParser;
/*
* If the default wasn't prevented already (in which case the form
* submission is already being handled by JS), and if it has a GET
* request method, then take the serialized form data and add it as
* a query string to the action URL and send this in a url message
* to the Customizer pane so that it will be loaded. If the form's
* action points to a non-previewable URL, the the Customizer pane's
* previewUrl setter will reject it so that the form submission is
* a no-op, which is the same behavior as when clicking a link to an
* external site in the preview.
*/
if ( ! event.isDefaultPrevented() && 'GET' === this.method.toUpperCase() ) {
urlParser = document.createElement( 'a' );
urlParser.href = this.action;
if ( urlParser.search.substr( 1 ).length > 1 ) {
urlParser.search += '&';
}
urlParser.search += $( this ).serialize();
api.preview.send( 'url', urlParser.href );
}
event.preventDefault();
});

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-alpha-38586';
$wp_version = '4.7-alpha-38587';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 comments on commit edf170c

Please sign in to comment.