Google Forms - Version 0.15

Version Description

No known upgrade issues.

Download this release

Release Info

Developer mpwalsh8
Plugin Icon wp plugin Google Forms
Version 0.15
Comparing to
See all releases

Code changes from version 0.14 to 0.15

Files changed (3) hide show
  1. index.php +2 -2
  2. readme.txt +9 -1
  3. wpgform-core.php +26 -75
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.14
8
- * Build: 0.14.$WCREV$
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.15
8
+ * Build: 0.15.$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.14
8
 
9
  Embeds a published, public Google Form in a WordPress post, page, or widget.
10
 
@@ -78,6 +78,9 @@ label.ss-q-title:after {
78
  }
79
  `
80
 
 
 
 
81
  == CSS ==
82
 
83
  As of 2011-09-21, Google Forms make use of 20+ CSS class definitions. By default, the WordPress Google Form plugin includes CSS declarations for all of the classes however the bulk of them are empty. The default CSS sets the font and makes the entry boxes wider. The default CSS that ships with WordPress Google Form can optionally be turned off via the WordPress Google Form settings.
@@ -173,6 +176,11 @@ No known upgrade issues.
173
 
174
  == Changelog ==
175
 
 
 
 
 
 
176
  = Version 0.14
177
  * Fixed minor bug with default options which manifested itself as an array index warning on the Options page.
178
 
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.15
8
 
9
  Embeds a published, public Google Form in a WordPress post, page, or widget.
10
 
78
  }
79
  `
80
 
81
+ = No matter what I do, I always get the *Unable to retrieve Google Form. Please try reloading this page.* error message. Why is this?
82
+ Validate that the WordPress HTTP API is working correctly. If you are seeing HTTP API errors on the WordPress Dashboard or when you attempt to access the plugin repository through the Dashboard, the WordPress Google Form will likely fail too. It requires the WordPress HTTP API to be working. With some free hosting plans, ISPs disable the ability to access remote content.
83
+
84
  == CSS ==
85
 
86
  As of 2011-09-21, Google Forms make use of 20+ CSS class definitions. By default, the WordPress Google Form plugin includes CSS declarations for all of the classes however the bulk of them are empty. The default CSS sets the font and makes the entry boxes wider. The default CSS that ships with WordPress Google Form can optionally be turned off via the WordPress Google Form settings.
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.
182
+ * Removed debug and other deprecated code (e.g. wpgform_footer()).
183
+
184
  = Version 0.14
185
  * Fixed minor bug with default options which manifested itself as an array index warning on the Options page.
186
 
wpgform-core.php CHANGED
@@ -37,8 +37,6 @@ function wpgform_init()
37
  add_filter('widget_text', 'do_shortcode') ;
38
 
39
  add_action('template_redirect', 'wpgform_head') ;
40
-
41
- //add_action('wp_footer', 'wpgform_footer') ;
42
  }
43
 
44
  /**
@@ -70,8 +68,25 @@ function wpgform_get_plugin_options()
70
  // Get the default options in case anything new has been added
71
  $default_options = wpgform_get_default_plugin_options() ;
72
 
73
- // Merge the default with any options currently saves by WordPress
74
- $plugin_options = wp_parse_args(get_option('wpgform_options', array()), $default_options) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  return $plugin_options ;
77
  }
@@ -245,11 +260,7 @@ class wpGForm
245
  if (!empty($_POST))
246
  {
247
  $posted = true ;
248
- //echo '<h1>Posted!</h1>' ;
249
- //var_dump($_POST) ;
250
- //var_dump($form) ;
251
  $action = $_POST['gform-action'] ;
252
- //var_dump($action) ;
253
  unset($_POST['gform-action']) ;
254
 
255
  $params = array() ;
@@ -258,32 +269,17 @@ class wpGForm
258
  // to be restored before the parameters can be posted
259
 
260
  foreach ($_POST as $key => $value)
261
- {
262
- //printf('<h3>Fixing parameter "%s"</h3>', $key) ;
263
  $params[str_replace('_', '.', $key)] = $value ;
264
- }
265
 
266
  // Remove the action from the form and POST it
267
 
268
  $form = str_replace($action, 'action=""', $form) ;
269
 
270
  $response = wp_remote_post($action, array('sslverify' => false, 'body' => $params)) ;
271
- //var_dump($response) ;
272
-
273
- /*
274
- if( is_wp_error( $response ) ) {
275
- echo 'Something went wrong!';
276
- } else {
277
- echo 'Response:<pre>';
278
- //print_r( $response );
279
- echo '</pre>';
280
- }
281
- */
282
  }
283
  else
284
  {
285
  $posted = false ;
286
- //echo '<h1>Not Posted!</h1>' ;
287
  $response = wp_remote_get($form, array('sslverify' => false)) ;
288
  }
289
 
@@ -312,6 +308,11 @@ class wpGForm
312
  ,'br' => array()
313
  ,'div' => array('class' => array())
314
  ,'h1' => array('class' => array())
 
 
 
 
 
315
  ,'i' => array()
316
  ,'label' => array('class' => array(), 'for' => array())
317
  ,'input' => array('id' => array(), 'name' => array(), 'class' => array(), 'type' => array(), 'value' => array(), 'checked' => array())
@@ -339,7 +340,7 @@ class wpGForm
339
  // If there are no DIVs, then we have garbage and should stop now!
340
 
341
  if ($first_div === false)
342
- return '<div class="gform-error">Unable to retrieve Google Form.</div>' ;
343
 
344
  // Strip off anything prior to the first DIV, we don't want it.
345
 
@@ -396,7 +397,6 @@ class wpGForm
396
  {
397
  for ($i=0; $i< count($matches[0]); $i++)
398
  {
399
- //echo "<h1>matched $i: ".$matches[0][$i]."</h1>";
400
  $action = $matches[0][$i] ;
401
  }
402
 
@@ -424,17 +424,7 @@ class wpGForm
424
  // Output Javscript for form validation
425
  $js = '
426
  <script type="text/javascript">
427
- jQuery(document).ready(function($) {
428
-
429
- /*
430
- $("div > .ss-item-required input").addClass("gform-required");
431
- $("div > .ss-item-required textarea").addClass("gform-required");
432
- $.validator.addClassRules("gform-required", {
433
- required: true
434
- });
435
- //$("#ss-form").validate({
436
- //errorClass: "gform-error"
437
- //}) ;*/' ;
438
 
439
  // Before closing the <script> tag, is the form read only?
440
  if ($readonly) $js .= '
@@ -492,44 +482,5 @@ function wpgform_head()
492
  wp_enqueue_style('gform',
493
  plugins_url(plugin_basename(dirname(__FILE__) . '/gforms.css'))) ;
494
  }
495
-
496
- // Load the jQuery Validate from the Microsoft CDN, it isn't
497
- // available from the Google CDN or I'd load it from there!
498
- wp_register_script('jquery-validate',
499
- 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js',
500
- array('jquery'), false, true) ;
501
- wp_enqueue_script('jquery-validate') ;
502
- }
503
-
504
- /**
505
- * wpgform_footer()
506
- *
507
- * WordPress footer actions
508
- */
509
- function wpgform_footer()
510
- {
511
- //
512
- // jQuery script to initialize the form validation
513
- // neccessary so bad or missing data is submitted.
514
- // When required fields are blank the normal Google
515
- // processing for form errors doesn't occur, this
516
- // jQuery script handles it gracefully. The fields
517
- // have only rudimentary validation.
518
- //
519
- ?>
520
-
521
- <script type="text/javascript">
522
- jQuery(document).ready(function($) {
523
- $("div > .ss-item-required input").addClass("gform-required");
524
- $("div > .ss-item-required textarea").addClass("gform-required");
525
- $.validator.addClassRules("gform-required", {
526
- required: true
527
- });
528
- $("#ss-form").validate({
529
- errorClass: "gform-error"
530
- }) ;
531
- });
532
- </script>
533
- <?php
534
  }
535
  ?>
37
  add_filter('widget_text', 'do_shortcode') ;
38
 
39
  add_action('template_redirect', 'wpgform_head') ;
 
 
40
  }
41
 
42
  /**
68
  // Get the default options in case anything new has been added
69
  $default_options = wpgform_get_default_plugin_options() ;
70
 
71
+ // If there is nothing persistent saved, return the default
72
+
73
+ if (get_option('wpgform_options') === false)
74
+ return $default_options ;
75
+
76
+ // One of the issues with simply merging the defaults is that by
77
+ // using checkboxes (which is the correct UI decision) WordPress does
78
+ // not save anything for the fields which are unchecked which then
79
+ // causes wp_parse_args() to incorrectly pick up the defaults.
80
+ // Since the array keys are used to build the form, we need for them
81
+ // to "exist" so if they don't, they are created and set to null.
82
+
83
+ $plugin_options = get_option('wpgform_options', $default_options) ;
84
+
85
+ foreach ($default_options as $key => $value)
86
+ {
87
+ if (!array_key_exists($key, $plugin_options))
88
+ $plugin_options[$key] = null ;
89
+ }
90
 
91
  return $plugin_options ;
92
  }
260
  if (!empty($_POST))
261
  {
262
  $posted = true ;
 
 
 
263
  $action = $_POST['gform-action'] ;
 
264
  unset($_POST['gform-action']) ;
265
 
266
  $params = array() ;
269
  // to be restored before the parameters can be posted
270
 
271
  foreach ($_POST as $key => $value)
 
 
272
  $params[str_replace('_', '.', $key)] = $value ;
 
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, array('sslverify' => false, 'body' => $params)) ;
 
 
 
 
 
 
 
 
 
 
 
279
  }
280
  else
281
  {
282
  $posted = false ;
 
283
  $response = wp_remote_get($form, array('sslverify' => false)) ;
284
  }
285
 
308
  ,'br' => array()
309
  ,'div' => array('class' => array())
310
  ,'h1' => array('class' => array())
311
+ ,'h2' => array('class' => array())
312
+ ,'h3' => array('class' => array())
313
+ ,'h4' => array('class' => array())
314
+ ,'h5' => array('class' => array())
315
+ ,'h6' => array('class' => array())
316
  ,'i' => array()
317
  ,'label' => array('class' => array(), 'for' => array())
318
  ,'input' => array('id' => array(), 'name' => array(), 'class' => array(), 'type' => array(), 'value' => array(), 'checked' => array())
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
 
397
  {
398
  for ($i=0; $i< count($matches[0]); $i++)
399
  {
 
400
  $action = $matches[0][$i] ;
401
  }
402
 
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 .= '
482
  wp_enqueue_style('gform',
483
  plugins_url(plugin_basename(dirname(__FILE__) . '/gforms.css'))) ;
484
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  }
486
  ?>