Version Description
No known upgrade issues.
Download this release
Release Info
Developer | mpwalsh8 |
Plugin | Google Forms |
Version | 0.16 |
Comparing to | |
See all releases |
Code changes from version 0.15 to 0.16
- index.php +2 -2
- readme.txt +6 -1
- wpgform-core.php +44 -12
index.php
CHANGED
@@ -4,8 +4,8 @@
|
|
4 |
* Plugin Name: WordPress Google Form
|
5 |
* Plugin URI: http://michaelwalsh.org/wordpress/wordpress-plugins/wpgform/
|
6 |
* Description: Add Google Forms to a WordPress web site. Display a Google Form directly into your posts, pages or sidebar. Style the Google Form to match your existing theme and display a custom confirmation page after form submission.
|
7 |
-
* Version: 0.
|
8 |
-
* Build: 0.
|
9 |
* Last Modified: $WCDATE$
|
10 |
* Author: Mike Walsh
|
11 |
* Author URI: http://www.michaelwalsh.org
|
4 |
* Plugin Name: WordPress Google Form
|
5 |
* Plugin URI: http://michaelwalsh.org/wordpress/wordpress-plugins/wpgform/
|
6 |
* Description: Add Google Forms to a WordPress web site. Display a Google Form directly into your posts, pages or sidebar. Style the Google Form to match your existing theme and display a custom confirmation page after form submission.
|
7 |
+
* Version: 0.16
|
8 |
+
* Build: 0.16.$WCREV$
|
9 |
* Last Modified: $WCDATE$
|
10 |
* Author: Mike Walsh
|
11 |
* Author URI: http://www.michaelwalsh.org
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: Google Forms, Google Docs, Google, Spreadsheet, shortcode, forms
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3.1
|
7 |
-
Stable tag: 0.
|
8 |
|
9 |
Embeds a published, public Google Form in a WordPress post, page, or widget.
|
10 |
|
@@ -176,6 +176,11 @@ No known upgrade issues.
|
|
176 |
|
177 |
== Changelog ==
|
178 |
|
|
|
|
|
|
|
|
|
|
|
179 |
= Version 0.15
|
180 |
* Fixed bug with default options which manifested itself always loading the default options for any setting which is on by default even when turned off by user.
|
181 |
* Removed loading of jQuery-Validate as it is no longer used.
|
4 |
Tags: Google Forms, Google Docs, Google, Spreadsheet, shortcode, forms
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3.1
|
7 |
+
Stable tag: 0.16
|
8 |
|
9 |
Embeds a published, public Google Form in a WordPress post, page, or widget.
|
10 |
|
176 |
|
177 |
== Changelog ==
|
178 |
|
179 |
+
= Version 0.16 =
|
180 |
+
* Fixed bug with *select* input tags. Selected value was not being retained on a multipage form.
|
181 |
+
* Fixed bug with passing checkbox values. Only one value, the last selected, was being passed for a multiple choice question.
|
182 |
+
* Rearchitected process for passing parameters to the Google Form with wp_remote_post().
|
183 |
+
|
184 |
= Version 0.15
|
185 |
* Fixed bug with default options which manifested itself always loading the default options for any setting which is on by default even when turned off by user.
|
186 |
* Removed loading of jQuery-Validate as it is no longer used.
|
wpgform-core.php
CHANGED
@@ -263,19 +263,38 @@ class wpGForm
|
|
263 |
$action = $_POST['gform-action'] ;
|
264 |
unset($_POST['gform-action']) ;
|
265 |
|
266 |
-
$
|
267 |
|
268 |
// The name of the form fields are munged, they need
|
269 |
// to be restored before the parameters can be posted
|
270 |
|
271 |
-
|
272 |
-
|
273 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
// Remove the action from the form and POST it
|
275 |
|
276 |
$form = str_replace($action, 'action=""', $form) ;
|
277 |
|
278 |
-
$response = wp_remote_post($action,
|
|
|
279 |
}
|
280 |
else
|
281 |
{
|
@@ -317,7 +336,7 @@ class wpGForm
|
|
317 |
,'label' => array('class' => array(), 'for' => array())
|
318 |
,'input' => array('id' => array(), 'name' => array(), 'class' => array(), 'type' => array(), 'value' => array(), 'checked' => array())
|
319 |
,'select' => array('name' => array(), 'for' => array(), 'checked' => array())
|
320 |
-
,'option' => array('value' => array(), '
|
321 |
,'form' => array('id' => array(), 'class' => array(), 'action' => array(), 'method' => array(), 'target' => array(), 'onsubmit' => array())
|
322 |
,'script' => array('type' => array())
|
323 |
,'table' => array()
|
@@ -340,7 +359,10 @@ class wpGForm
|
|
340 |
// If there are no DIVs, then we have garbage and should stop now!
|
341 |
|
342 |
if ($first_div === false)
|
|
|
|
|
343 |
return '<div class="gform-error">Unexpected content encountered, unable to retrieve Google Form.</div>' ;
|
|
|
344 |
|
345 |
// Strip off anything prior to the first DIV, we don't want it.
|
346 |
|
@@ -388,10 +410,15 @@ class wpGForm
|
|
388 |
$html = preg_replace('/<div class="ss-legal"/i',
|
389 |
'<div class="ss-legal" style="display:none;"', $html) ;
|
390 |
|
391 |
-
// Need to
|
392 |
-
//
|
393 |
-
//
|
394 |
-
|
|
|
|
|
|
|
|
|
|
|
395 |
|
396 |
if (preg_match_all('/(action(\\s*)=(\\s*)([\"\'])?(?(1)(.*?)\\2|([^\s\>]+)))/', $html, $matches))
|
397 |
{
|
@@ -409,7 +436,6 @@ class wpGForm
|
|
409 |
else
|
410 |
{
|
411 |
$action = null ;
|
412 |
-
//print "<h1>A match was not found.</h1>";
|
413 |
}
|
414 |
|
415 |
// Output custom CSS?
|
@@ -424,8 +450,14 @@ class wpGForm
|
|
424 |
// Output Javscript for form validation
|
425 |
$js = '
|
426 |
<script type="text/javascript">
|
427 |
-
jQuery(document).ready(function($) {
|
428 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
// Before closing the <script> tag, is the form read only?
|
430 |
if ($readonly) $js .= '
|
431 |
$("div.ss-form-container :input").attr("disabled", true);
|
263 |
$action = $_POST['gform-action'] ;
|
264 |
unset($_POST['gform-action']) ;
|
265 |
|
266 |
+
$body = '' ;
|
267 |
|
268 |
// The name of the form fields are munged, they need
|
269 |
// to be restored before the parameters can be posted
|
270 |
|
271 |
+
$patterns = array('/^entry_([0-9])+_(single|group)_/', '/^entry_([0-9])+_/') ;
|
272 |
+
$replacements = array('entry.\1.\2.', 'entry.\1.') ;
|
273 |
|
274 |
+
foreach ($_POST as $key => $value)
|
275 |
+
{
|
276 |
+
// Need to handle parameters passed as array
|
277 |
+
// values separately because of how Python (used
|
278 |
+
// Google) handles array arguments differently than
|
279 |
+
// PHP does.
|
280 |
+
|
281 |
+
if (is_array($_POST[$key]))
|
282 |
+
{
|
283 |
+
$pa = &$_POST[$key] ;
|
284 |
+
foreach ($pa as $pv)
|
285 |
+
$body .= preg_replace($patterns, $replacements, $key) . '=' . $pv . '&' ;
|
286 |
+
}
|
287 |
+
else
|
288 |
+
{
|
289 |
+
$body .= preg_replace($patterns, $replacements, $key) . '=' . $value . '&' ;
|
290 |
+
}
|
291 |
+
}
|
292 |
// Remove the action from the form and POST it
|
293 |
|
294 |
$form = str_replace($action, 'action=""', $form) ;
|
295 |
|
296 |
+
$response = wp_remote_post($action,
|
297 |
+
array('sslverify' => false, 'body' => $body)) ;
|
298 |
}
|
299 |
else
|
300 |
{
|
336 |
,'label' => array('class' => array(), 'for' => array())
|
337 |
,'input' => array('id' => array(), 'name' => array(), 'class' => array(), 'type' => array(), 'value' => array(), 'checked' => array())
|
338 |
,'select' => array('name' => array(), 'for' => array(), 'checked' => array())
|
339 |
+
,'option' => array('value' => array(), 'selected' => array())
|
340 |
,'form' => array('id' => array(), 'class' => array(), 'action' => array(), 'method' => array(), 'target' => array(), 'onsubmit' => array())
|
341 |
,'script' => array('type' => array())
|
342 |
,'table' => array()
|
359 |
// If there are no DIVs, then we have garbage and should stop now!
|
360 |
|
361 |
if ($first_div === false)
|
362 |
+
{
|
363 |
+
print "<pre>$html</pre>" ;
|
364 |
return '<div class="gform-error">Unexpected content encountered, unable to retrieve Google Form.</div>' ;
|
365 |
+
}
|
366 |
|
367 |
// Strip off anything prior to the first DIV, we don't want it.
|
368 |
|
410 |
$html = preg_replace('/<div class="ss-legal"/i',
|
411 |
'<div class="ss-legal" style="display:none;"', $html) ;
|
412 |
|
413 |
+
// Need to fix names for checkbox items to account for how PHP
|
414 |
+
// handles arrays - each name needs to have the "[]" tacked on
|
415 |
+
// the end of it.
|
416 |
+
|
417 |
+
//$html = preg_replace('/name="entry\.[0-9]+\.group/i', '\\1[]', $html) ;
|
418 |
+
|
419 |
+
// Need to extract form action and rebuild form tag, and add hidden field
|
420 |
+
// which contains the original action. This action is used to submit the
|
421 |
+
// form via wp_remote_post().
|
422 |
|
423 |
if (preg_match_all('/(action(\\s*)=(\\s*)([\"\'])?(?(1)(.*?)\\2|([^\s\>]+)))/', $html, $matches))
|
424 |
{
|
436 |
else
|
437 |
{
|
438 |
$action = null ;
|
|
|
439 |
}
|
440 |
|
441 |
// Output custom CSS?
|
450 |
// Output Javscript for form validation
|
451 |
$js = '
|
452 |
<script type="text/javascript">
|
453 |
+
jQuery(document).ready(function($) {
|
454 |
+
//$("form input:checkbox").wrap(\'<span></span>\').parent().css({background:"yellow", border:"3px red solid"});
|
455 |
+
// Need to fix the name arguments for checkboxes
|
456 |
+
// so PHP will pass them as an array correctly.
|
457 |
+
$("div.ss-form-container input:checkbox").each(function(index) {
|
458 |
+
this.name = this.name + \'[]\';
|
459 |
+
});
|
460 |
+
' ;
|
461 |
// Before closing the <script> tag, is the form read only?
|
462 |
if ($readonly) $js .= '
|
463 |
$("div.ss-form-container :input").attr("disabled", true);
|