Version Description
No known upgrade issues.
Download this release
Release Info
Developer | mpwalsh8 |
Plugin | Google Forms |
Version | 0.61 |
Comparing to | |
See all releases |
Code changes from version 0.60 to 0.61
- css/wpgform.css +7 -2
- index.php +3 -3
- readme.txt +56 -3
- wpgform-core.php +147 -48
css/wpgform.css
CHANGED
@@ -123,7 +123,7 @@ div.ss-secondary-text {
|
|
123 |
}
|
124 |
|
125 |
/* This hides the "Never submit passwords through Google Forms." warning. */
|
126 |
-
|
127 |
display: none;
|
128 |
}
|
129 |
|
@@ -151,7 +151,7 @@ div.error-message {
|
|
151 |
}
|
152 |
|
153 |
/* 2013-10-30: Attempt to make text entry boxes a reasonable width */
|
154 |
-
input.ss-q-short,
|
155 |
width: auto;
|
156 |
}
|
157 |
|
@@ -172,3 +172,8 @@ tr.rShim td, tr.rShim ~ tr td {
|
|
172 |
div div span.powered, div.listview {
|
173 |
display: none;
|
174 |
}
|
|
|
|
|
|
|
|
|
|
123 |
}
|
124 |
|
125 |
/* This hides the "Never submit passwords through Google Forms." warning. */
|
126 |
+
td.ss-form-entry > div.ss-secondary-text {
|
127 |
display: none;
|
128 |
}
|
129 |
|
151 |
}
|
152 |
|
153 |
/* 2013-10-30: Attempt to make text entry boxes a reasonable width */
|
154 |
+
input.ss-q-short, textarea.ss-q-long {
|
155 |
width: auto;
|
156 |
}
|
157 |
|
172 |
div div span.powered, div.listview {
|
173 |
display: none;
|
174 |
}
|
175 |
+
|
176 |
+
/** Hide the "This is a required question" message **/
|
177 |
+
div.ss-form-container div.required-message {
|
178 |
+
display: none;
|
179 |
+
}
|
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
|
@@ -25,7 +25,7 @@
|
|
25 |
*
|
26 |
*/
|
27 |
|
28 |
-
define('WPGFORM_VERSION', '0.
|
29 |
|
30 |
require_once('wpgform-core.php') ;
|
31 |
require_once('wpgform-post-type.php') ;
|
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.61
|
8 |
+
* Build: 0.61.$WCREV$
|
9 |
* Last Modified: $WCDATE$
|
10 |
* Author: Mike Walsh
|
11 |
* Author URI: http://www.michaelwalsh.org
|
25 |
*
|
26 |
*/
|
27 |
|
28 |
+
define('WPGFORM_VERSION', '0.61') ;
|
29 |
|
30 |
require_once('wpgform-core.php') ;
|
31 |
require_once('wpgform-post-type.php') ;
|
readme.txt
CHANGED
@@ -5,6 +5,7 @@ Tags: Google Forms, Google Docs, Google, Spreadsheet, shortcode, forms
|
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 3.7.1
|
7 |
Stable tag: 0.60
|
|
|
8 |
|
9 |
Embeds a published, public Google Form in a WordPress post, page, or widget.
|
10 |
|
@@ -36,11 +37,12 @@ As features have been added, usage of the `gform` shortcode has grown increasing
|
|
36 |
|
37 |
The WordPress Google Form shortcode `wpgform` supports a single attribute. The rest of the controls are derived from the information stored with the Custom Post Type.
|
38 |
|
39 |
-
`[wpgform id='<Google Form CPT Id>']`
|
40 |
|
41 |
*NOTE:* In the above syntax, values enclosed in angle brackets <>, indicate a string you need to replace with an appropriate value. Do not include the angle brackets in your string!
|
42 |
|
43 |
* __id__: The numeric id of the Google Form Custom Post Type.
|
|
|
44 |
|
45 |
The WordPress Google Form shortcode `gform` supports a number of attributes that allow further control and customization of the Google Form.
|
46 |
|
@@ -69,6 +71,10 @@ The WordPress Google Form shortcode `gform` supports a number of attributes that
|
|
69 |
|
70 |
`[gform form='https://docs.google.com/spreadsheet/viewform?hl=en_US&pli=1&formkey=ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678#gid=0' confirm='http://www.example.com/thankyou/' style='ajax' class='mygform' legal='off' prefix='mygform-' br='on' title='on' maph1h2='on' email='on' spreadsheet='https://docs.google.com/spreadsheet/ccc?key=0AgBHWDGsX0PUdE56R1ZldXo4a0N3VTNMNEpSemdGV3c' unitethemehack='off' validation='on' captcha='on' columns='1']`
|
71 |
|
|
|
|
|
|
|
|
|
72 |
== Frequently Asked Questions ==
|
73 |
|
74 |
= The default style is ugly. Can I change it? =
|
@@ -163,7 +169,7 @@ There are two ways to customize the Google Form CSS.
|
|
163 |
|
164 |
= Default Google Form CSS =
|
165 |
|
166 |
-
As of 2013-
|
167 |
|
168 |
`
|
169 |
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
@@ -291,7 +297,7 @@ div.ss-secondary-text {
|
|
291 |
}
|
292 |
|
293 |
/* This hides the "Never submit passwords through Google Forms." warning. */
|
294 |
-
|
295 |
display: none;
|
296 |
}
|
297 |
|
@@ -302,6 +308,49 @@ div.password-warning {
|
|
302 |
div.ss-form-container li {
|
303 |
list-style-type: none;
|
304 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
`
|
306 |
|
307 |
== Screenshots ==
|
@@ -316,6 +365,10 @@ No known upgrade issues.
|
|
316 |
|
317 |
== Changelog ==
|
318 |
|
|
|
|
|
|
|
|
|
319 |
= Version 0.60 =
|
320 |
* Beta reference removed from version string.
|
321 |
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 3.7.1
|
7 |
Stable tag: 0.60
|
8 |
+
License: GPL
|
9 |
|
10 |
Embeds a published, public Google Form in a WordPress post, page, or widget.
|
11 |
|
37 |
|
38 |
The WordPress Google Form shortcode `wpgform` supports a single attribute. The rest of the controls are derived from the information stored with the Custom Post Type.
|
39 |
|
40 |
+
`[wpgform id='<Google Form CPT Id>' uid='<unique text string>']`
|
41 |
|
42 |
*NOTE:* In the above syntax, values enclosed in angle brackets <>, indicate a string you need to replace with an appropriate value. Do not include the angle brackets in your string!
|
43 |
|
44 |
* __id__: The numeric id of the Google Form Custom Post Type.
|
45 |
+
* __uid__: A unique string (e.g. 'A-') used to ensure form element ID attributes are unique when a form appears on a page multiple times. (optional)
|
46 |
|
47 |
The WordPress Google Form shortcode `gform` supports a number of attributes that allow further control and customization of the Google Form.
|
48 |
|
71 |
|
72 |
`[gform form='https://docs.google.com/spreadsheet/viewform?hl=en_US&pli=1&formkey=ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678#gid=0' confirm='http://www.example.com/thankyou/' style='ajax' class='mygform' legal='off' prefix='mygform-' br='on' title='on' maph1h2='on' email='on' spreadsheet='https://docs.google.com/spreadsheet/ccc?key=0AgBHWDGsX0PUdE56R1ZldXo4a0N3VTNMNEpSemdGV3c' unitethemehack='off' validation='on' captcha='on' columns='1']`
|
73 |
|
74 |
+
== License ==
|
75 |
+
|
76 |
+
This plugin is available under the GPL license, which means that it's free. If you use it for a commercial web site, if you appreciate my efforts or if you want to encourage me to develop and maintain it, please consider making a donation using Paypal, a secured payment solution. You just need to click the donate button on the the [plugin overview page](http://michaelwalsh.org/wordpress/wordpress-plugins/wpgform/) and follow the instructions.
|
77 |
+
|
78 |
== Frequently Asked Questions ==
|
79 |
|
80 |
= The default style is ugly. Can I change it? =
|
169 |
|
170 |
= Default Google Form CSS =
|
171 |
|
172 |
+
As of 2013-12-04, the following is are the CSS classes which Google Forms make use of. The CSS below represents the default CSS provided by WordPress Google Form. These CSS definitions can be copied and pasted into your theme CSS or the WordPress Google Form custom CSS setting and changed as desired. Some of the classes are redundant to account for both the new and old style of Google Forms.
|
173 |
|
174 |
`
|
175 |
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
297 |
}
|
298 |
|
299 |
/* This hides the "Never submit passwords through Google Forms." warning. */
|
300 |
+
td.ss-form-entry > div.ss-secondary-text {
|
301 |
display: none;
|
302 |
}
|
303 |
|
308 |
div.ss-form-container li {
|
309 |
list-style-type: none;
|
310 |
}
|
311 |
+
|
312 |
+
/* 2013-06-04: Hide "Edit this Form" link */
|
313 |
+
a.ss-edit-link {
|
314 |
+
display: none;
|
315 |
+
}
|
316 |
+
|
317 |
+
/* 2013-06-06: Hide help text for scales */
|
318 |
+
div.aria-only-help {
|
319 |
+
display: none;
|
320 |
+
}
|
321 |
+
|
322 |
+
/* 2013-10-30: Hide default error messages */
|
323 |
+
div.error-message {
|
324 |
+
display: none;
|
325 |
+
}
|
326 |
+
|
327 |
+
/* 2013-10-30: Attempt to make text entry boxes a reasonable width */
|
328 |
+
input.ss-q-short, textarea.ss-q-long {
|
329 |
+
width: auto;
|
330 |
+
}
|
331 |
+
|
332 |
+
/* 2013-11-15: CSS to support using WordPress Google form to render spreadsheets */
|
333 |
+
|
334 |
+
/** Hide the gunk that Google adds to make the table work **/
|
335 |
+
td.hd, td.headerEnd, tr.rShim, td.sortBar {
|
336 |
+
display: none;
|
337 |
+
width: 0px !important;
|
338 |
+
padding: 0px !important;
|
339 |
+
}
|
340 |
+
|
341 |
+
/** Empty selector but could be used to select all of the table cells **/
|
342 |
+
tr.rShim td, tr.rShim ~ tr td {
|
343 |
+
}
|
344 |
+
|
345 |
+
/** Hide the "powered" and "listview" DIVs that Google adds **/
|
346 |
+
div div span.powered, div.listview {
|
347 |
+
display: none;
|
348 |
+
}
|
349 |
+
|
350 |
+
/** Hide the "This is a required question" message **/
|
351 |
+
div.ss-form-container div.required-message {
|
352 |
+
display: none;
|
353 |
+
}
|
354 |
`
|
355 |
|
356 |
== Screenshots ==
|
365 |
|
366 |
== Changelog ==
|
367 |
|
368 |
+
= Version 0.61 =
|
369 |
+
* Fixed some default CSS rules which were incorrect.
|
370 |
+
* Added support for multiple instances of the same form on a single page.
|
371 |
+
|
372 |
= Version 0.60 =
|
373 |
* Beta reference removed from version string.
|
374 |
|
wpgform-core.php
CHANGED
@@ -354,6 +354,16 @@ class wpGForm
|
|
354 |
*/
|
355 |
static $wpgform_js = false ;
|
356 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
/**
|
358 |
* Property to store Javascript output in footer
|
359 |
*/
|
@@ -389,6 +399,16 @@ class wpGForm
|
|
389 |
*/
|
390 |
static $wpgform_user_sendto = null ;
|
391 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
/**
|
393 |
* Property to store the various options which control the
|
394 |
* HTML manipulation and generation. These array keys map
|
@@ -401,6 +421,7 @@ class wpGForm
|
|
401 |
*/
|
402 |
protected static $options = array(
|
403 |
'form' => false, // Google Form URL
|
|
|
404 |
'confirm' => null, // Custom confirmation page URL to redirect to
|
405 |
'alert' => null, // Optional Alert Message
|
406 |
'class' => 'wpgform', // Container element's custom class value
|
@@ -541,6 +562,8 @@ class wpGForm
|
|
541 |
else
|
542 |
return false ;
|
543 |
|
|
|
|
|
544 |
// get current form meta data fields
|
545 |
|
546 |
$fields = array_merge(
|
@@ -604,6 +627,7 @@ class wpGForm
|
|
604 |
|
605 |
// Property short cut
|
606 |
$o = &self::$options ;
|
|
|
607 |
|
608 |
$wpgform_options = wpgform_get_plugin_options() ;
|
609 |
|
@@ -634,6 +658,7 @@ class wpGForm
|
|
634 |
else
|
635 |
{
|
636 |
$form = $o['form'] ;
|
|
|
637 |
$prefix = $o['prefix'] ;
|
638 |
$suffix = $o['suffix'] ;
|
639 |
$confirm = $o['confirm'] ;
|
@@ -656,6 +681,7 @@ class wpGForm
|
|
656 |
$user_email_sendto = "" ;
|
657 |
|
658 |
// Generate the User Email HTML if requested
|
|
|
659 |
|
660 |
if ($user_email)
|
661 |
{
|
@@ -671,7 +697,7 @@ class wpGForm
|
|
671 |
__('Email Address')) ;
|
672 |
$user_email_html .= sprintf('<span class="%sss-required-asterisk">*</span></label>', $prefix) ;
|
673 |
$user_email_html .= sprintf('<label for="wpgform-user-email" class="%sss-q-help"></label>', $prefix) ;
|
674 |
-
$user_email_html .= sprintf('<input style="width: 250px;" type="text" id="
|
675 |
$user_email_html .= '</div></div></div>' ;
|
676 |
}
|
677 |
|
@@ -718,12 +744,12 @@ class wpGForm
|
|
718 |
$captcha_html .= sprintf('<div class="%sss-item %sss-item-required %sss-text">', $prefix, $prefix, $prefix) ;
|
719 |
$captcha_html .= sprintf('<div class="%sss-form-entry">', $prefix) ;
|
720 |
if ((int)$wpgform_options['captcha_terms'] === 2)
|
721 |
-
$captcha_html .= sprintf('<label for="
|
722 |
else
|
723 |
-
$captcha_html .= sprintf('<label for="
|
724 |
$captcha_html .= sprintf('<span class="%sss-required-asterisk">*</span></label>', $prefix) ;
|
725 |
-
$captcha_html .= sprintf('<label for="
|
726 |
-
$captcha_html .= sprintf('<input style="width: 100px;" type="text" id="
|
727 |
$captcha_html .= '</div></div>' ;
|
728 |
|
729 |
// Add in the optional CAPTCHA description if one has been set
|
@@ -798,6 +824,12 @@ class wpGForm
|
|
798 |
$patterns = array('/entry_([0-9]+)_(single|group)_/', '/entry_([0-9]+)_/', '/entry_([0-9]+)/') ;
|
799 |
$replacements = array('entry.\1.\2.', 'entry.\1.', 'entry.\1') ;
|
800 |
|
|
|
|
|
|
|
|
|
|
|
|
|
801 |
foreach ($presets as $key => $value)
|
802 |
{
|
803 |
unset($preset) ;
|
@@ -919,6 +951,42 @@ class wpGForm
|
|
919 |
|
920 |
$html = wp_kses($html, $allowed_tags) ;
|
921 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
922 |
if (WPGFORM_DEBUG)
|
923 |
{
|
924 |
wpgform_whereami(__FILE__, __LINE__, 'ConstructGoogleForm') ;
|
@@ -1064,6 +1132,8 @@ class wpGForm
|
|
1064 |
// Need to fix the name arguments for checkboxes so PHP will pass them as an array correctly.
|
1065 |
// This jQuery script reformats the checkboxes so that Googles Python script will read them.
|
1066 |
|
|
|
|
|
1067 |
$vMsgs_js = array() ;
|
1068 |
$vRules_js = array() ;
|
1069 |
|
@@ -1074,11 +1144,11 @@ jQuery(document).ready(function($) {
|
|
1074 |
', WPGFORM_VERSION) ;
|
1075 |
|
1076 |
// Insert breaks between labels and input fields?
|
1077 |
-
if ($br) $js .= '
|
1078 |
// Insert br elements before input and textarea boxes
|
1079 |
-
$("
|
1080 |
-
$("
|
1081 |
-
' ;
|
1082 |
|
1083 |
// Did short code specify a CSS prefix?
|
1084 |
if (!is_null($prefix)) $js .= sprintf('
|
@@ -1115,14 +1185,14 @@ jQuery(document).ready(function($) {
|
|
1115 |
{
|
1116 |
$js .= sprintf('
|
1117 |
// Construct Email User Validation
|
1118 |
-
if ($("
|
1119 |
-
$("
|
1120 |
$("div.wpgform-user-email").show();
|
1121 |
$.validator.addClassRules("wpgform-user-email", {
|
1122 |
required: true
|
1123 |
});
|
1124 |
}
|
1125 |
-
', $user_email_html) ;
|
1126 |
$vRules_js[] = '
|
1127 |
"wpgform-user-email": {
|
1128 |
email: true
|
@@ -1137,22 +1207,17 @@ jQuery(document).ready(function($) {
|
|
1137 |
$js .= sprintf('
|
1138 |
// Construct CAPTCHA
|
1139 |
$.validator.methods.equal = function(value, element, param) { return value == param; };
|
1140 |
-
if ($("
|
1141 |
-
$("
|
1142 |
$("div.wpgform-captcha").show();
|
1143 |
$.validator.addClassRules("wpgform-captcha", {
|
1144 |
required: true,
|
1145 |
});
|
1146 |
}
|
1147 |
-
', $captcha_html, self::$wpgform_captcha['c']) ;
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
}
|
1152 |
-
', self::$wpgform_captcha['x']) ;
|
1153 |
-
$vMsgs_js[] = sprintf('
|
1154 |
-
"wpgform-captcha": "%s"
|
1155 |
-
', __('Incorrect answer.', WPGFORM_I18N_DOMAIN)) ;
|
1156 |
}
|
1157 |
|
1158 |
// Build extra jQuery Validation rules
|
@@ -1167,10 +1232,16 @@ jQuery(document).ready(function($) {
|
|
1167 |
$meta_type = get_post_meta($o['id'], $field['type_id'], true);
|
1168 |
$meta_value = get_post_meta($o['id'], $field['value_id'], true);
|
1169 |
|
1170 |
-
if (!empty($meta_field))
|
|
|
1171 |
foreach ($meta_field as $key => $value)
|
1172 |
-
|
1173 |
-
|
|
|
|
|
|
|
|
|
|
|
1174 |
}
|
1175 |
}
|
1176 |
}
|
@@ -1189,33 +1260,44 @@ jQuery(document).ready(function($) {
|
|
1189 |
if ($validation)
|
1190 |
{
|
1191 |
$js .= sprintf('
|
1192 |
-
$("
|
1193 |
errorClass: "wpgform-error",
|
1194 |
-
rules: {%s', PHP_EOL) ;
|
1195 |
if (!empty($extras))
|
1196 |
{
|
|
|
1197 |
foreach ($extras as $key => $value)
|
1198 |
{
|
1199 |
-
|
|
|
1200 |
foreach ($value as $extra)
|
1201 |
$js .= sprintf('%s%s', $extra, $extra === end($value) ? '}' : ', ') ;
|
1202 |
$js .= sprintf('%s%s%s', $value === end($extras) ? '' : ',', PHP_EOL, $value === end($extras) ? ' ' : '') ;
|
1203 |
}
|
1204 |
}
|
1205 |
-
if (empty($vRules_js))
|
1206 |
-
|
1207 |
-
|
|
|
|
|
|
|
1208 |
foreach ($vRules_js as $r)
|
1209 |
-
$js .= sprintf('%s%s', $r, $r === end($vRules_js) ? ' },' : ',') ;
|
1210 |
-
|
1211 |
-
messages: {' ;
|
1212 |
-
if (empty($vMsgs_js))
|
1213 |
-
$js .= '}' ;
|
1214 |
else
|
|
|
|
|
|
|
|
|
|
|
|
|
1215 |
foreach ($vMsgs_js as $m)
|
1216 |
-
$js .= sprintf('%s%s', $m, $m === end($vMsgs_js) ? ' }' : ',') ;
|
|
|
|
|
|
|
1217 |
$js .= '
|
1218 |
-
}) ;' ;
|
1219 |
}
|
1220 |
|
1221 |
// Handle hidden fields
|
@@ -1252,7 +1334,14 @@ jQuery(document).ready(function($) {
|
|
1252 |
$patterns = array('/^entry.([0-9]+).(single|group)./', '/^entry.([0-9]+)_/', '/^entry.([0-9]+)/') ;
|
1253 |
$replacements = array('entry_\1_\2_', 'entry_\1_', 'entry_\1') ;
|
1254 |
|
1255 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1256 |
foreach ($meta_field as $key => $value)
|
1257 |
{
|
1258 |
$mf = preg_replace($patterns, $replacements, $meta_field[$key]) ;
|
@@ -1260,8 +1349,11 @@ jQuery(document).ready(function($) {
|
|
1260 |
if (empty($meta_value[$key]) || in_array($meta_type[$key], $ignore))
|
1261 |
$meta_value[$key] = $values[$meta_type[$key]] ;
|
1262 |
|
1263 |
-
|
1264 |
-
|
|
|
|
|
|
|
1265 |
}
|
1266 |
}
|
1267 |
}
|
@@ -1319,7 +1411,7 @@ jQuery(document).ready(function($) {
|
|
1319 |
// Make sure we don\'t split labels and input fields
|
1320 |
$("div.%sss-item").addClass("wpgform-dontsplit");
|
1321 |
// Wrap all of the form content in a DIV so it can be split
|
1322 |
-
$("
|
1323 |
// Columnize the form content.
|
1324 |
$(function(){
|
1325 |
$(".wpgform-wrapper").columnize({
|
@@ -1329,9 +1421,9 @@ jQuery(document).ready(function($) {
|
|
1329 |
// Wrap each column so it can styled easier
|
1330 |
$(".wpgform-column").wrapInner("<div style=\"border: 0px dashed green;\" class=\"wpgform-column-wrapper\"></div>");
|
1331 |
});
|
1332 |
-
$("
|
1333 |
$("div.%sss-form-container").after("<div style=\"border: 0px dashed black; clear: both;\"></div>");
|
1334 |
-
', $prefix, $columns, $prefix) ;
|
1335 |
|
1336 |
// Load the confirmation URL via AJAX?
|
1337 |
if (self::$posted && is_null($action) && !is_null($confirm) &&
|
@@ -1412,8 +1504,8 @@ jQuery(document).ready(function($) {
|
|
1412 |
if (is_null(self::$wpgform_submitted_form_id) ||
|
1413 |
self::$wpgform_submitted_form_id == self::$wpgform_form_id - 1)
|
1414 |
{
|
1415 |
-
self::$wpgform_js = true ;
|
1416 |
-
self::$wpgform_footer_js
|
1417 |
}
|
1418 |
}
|
1419 |
|
@@ -1509,15 +1601,22 @@ jQuery(document).ready(function($) {
|
|
1509 |
|
1510 |
if (WPGFORM_DEBUG) wpgform_preprint_r($options) ;
|
1511 |
$form = $options['form'] ;
|
|
|
1512 |
|
1513 |
$body = '' ;
|
1514 |
|
1515 |
// The name of the form fields are munged, they need
|
1516 |
// to be restored before the parameters can be posted
|
1517 |
|
1518 |
-
$patterns = array('
|
1519 |
$replacements = array('entry.\1.\2.', 'entry.\1.', 'entry.\1') ;
|
1520 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1521 |
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ProcessGoogleForm') ;
|
1522 |
if (WPGFORM_DEBUG) wpgform_preprint_r($_POST) ;
|
1523 |
|
354 |
*/
|
355 |
static $wpgform_js = false ;
|
356 |
|
357 |
+
/**
|
358 |
+
* Property to hold global plugin Javascript output
|
359 |
+
*/
|
360 |
+
static $wpgform_plugin_js = '' ;
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Property to hold form specific Javascript output
|
364 |
+
*/
|
365 |
+
static $wpgform_form_js = array() ;
|
366 |
+
|
367 |
/**
|
368 |
* Property to store Javascript output in footer
|
369 |
*/
|
399 |
*/
|
400 |
static $wpgform_user_sendto = null ;
|
401 |
|
402 |
+
/**
|
403 |
+
* Property to store jQuery Validation messages
|
404 |
+
*/
|
405 |
+
//static $vMsgs_js = array() ;
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Property to store jQuery Validation rules
|
409 |
+
*/
|
410 |
+
//static $vRules_js = array() ;
|
411 |
+
|
412 |
/**
|
413 |
* Property to store the various options which control the
|
414 |
* HTML manipulation and generation. These array keys map
|
421 |
*/
|
422 |
protected static $options = array(
|
423 |
'form' => false, // Google Form URL
|
424 |
+
'uid' => '', // Unique identifier string to prepend to id and name attributes
|
425 |
'confirm' => null, // Custom confirmation page URL to redirect to
|
426 |
'alert' => null, // Optional Alert Message
|
427 |
'class' => 'wpgform', // Container element's custom class value
|
562 |
else
|
563 |
return false ;
|
564 |
|
565 |
+
if (array_key_exists('uid', $options)) $o['uid'] = $options['uid'] ;
|
566 |
+
|
567 |
// get current form meta data fields
|
568 |
|
569 |
$fields = array_merge(
|
627 |
|
628 |
// Property short cut
|
629 |
$o = &self::$options ;
|
630 |
+
//printf('<pre>%s</pre>', print_r($o, true)) ;
|
631 |
|
632 |
$wpgform_options = wpgform_get_plugin_options() ;
|
633 |
|
658 |
else
|
659 |
{
|
660 |
$form = $o['form'] ;
|
661 |
+
$uid = $o['uid'] ;
|
662 |
$prefix = $o['prefix'] ;
|
663 |
$suffix = $o['suffix'] ;
|
664 |
$confirm = $o['confirm'] ;
|
681 |
$user_email_sendto = "" ;
|
682 |
|
683 |
// Generate the User Email HTML if requested
|
684 |
+
//printf('<h1>%s::%s -> %s</h1>', basename(__FILE__), __LINE__, $uid) ;
|
685 |
|
686 |
if ($user_email)
|
687 |
{
|
697 |
__('Email Address')) ;
|
698 |
$user_email_html .= sprintf('<span class="%sss-required-asterisk">*</span></label>', $prefix) ;
|
699 |
$user_email_html .= sprintf('<label for="wpgform-user-email" class="%sss-q-help"></label>', $prefix) ;
|
700 |
+
$user_email_html .= sprintf('<input style="width: 250px;" type="text" id="%swpgform-user-email" class="%sss-q-short" value="%s" name="%swpgform-user-email">', $uid, $prefix, $user_email_sendto, $uid) ;
|
701 |
$user_email_html .= '</div></div></div>' ;
|
702 |
}
|
703 |
|
744 |
$captcha_html .= sprintf('<div class="%sss-item %sss-item-required %sss-text">', $prefix, $prefix, $prefix) ;
|
745 |
$captcha_html .= sprintf('<div class="%sss-form-entry">', $prefix) ;
|
746 |
if ((int)$wpgform_options['captcha_terms'] === 2)
|
747 |
+
$captcha_html .= sprintf('<label for="%swpgform-captcha" class="%sss-q-title">%s %s %s %s ?', $uid, $prefix, __('What is', WPGFORM_I18N_DOMAIN), $a, $op1, $b) ;
|
748 |
else
|
749 |
+
$captcha_html .= sprintf('<label for="%swpgform-captcha" class="%sss-q-title">%s %s %s %s %s %s?', $uid, $prefix, __('What is', WPGFORM_I18N_DOMAIN), $a, $op1, $b, $op2, $c) ;
|
750 |
$captcha_html .= sprintf('<span class="%sss-required-asterisk">*</span></label>', $prefix) ;
|
751 |
+
$captcha_html .= sprintf('<label for="%swpgform-captcha" class="%sss-q-help"></label>', $uid, $prefix) ;
|
752 |
+
$captcha_html .= sprintf('<input style="width: 100px;" type="text" id="%swpgform-captcha" class="%sss-q-short" value="" name="%swpgform-captcha">', $uid, $prefix, $uid) ;
|
753 |
$captcha_html .= '</div></div>' ;
|
754 |
|
755 |
// Add in the optional CAPTCHA description if one has been set
|
824 |
$patterns = array('/entry_([0-9]+)_(single|group)_/', '/entry_([0-9]+)_/', '/entry_([0-9]+)/') ;
|
825 |
$replacements = array('entry.\1.\2.', 'entry.\1.', 'entry.\1') ;
|
826 |
|
827 |
+
error_log(sprintf('%s::%s', basename(__FILE__), __LINE__)) ;
|
828 |
+
error_log(print_r($replacements, true)) ;
|
829 |
+
|
830 |
+
foreach ($replacements as $key => $value)
|
831 |
+
$replacements[$key] = sprintf('%s%s', $uid, $value) ;
|
832 |
+
|
833 |
foreach ($presets as $key => $value)
|
834 |
{
|
835 |
unset($preset) ;
|
951 |
|
952 |
$html = wp_kses($html, $allowed_tags) ;
|
953 |
|
954 |
+
if (1):
|
955 |
+
$patterns = array(
|
956 |
+
'/entry\.([0-9]+)\.(single|group)\./',
|
957 |
+
'/entry\.([0-9]+)_/',
|
958 |
+
'/entry\.([0-9]+)/',
|
959 |
+
'/entry_([0-9]+)\.(single|group)\./',
|
960 |
+
'/entry_([0-9]+)_/',
|
961 |
+
'/entry_([0-9]+)/',
|
962 |
+
) ;
|
963 |
+
|
964 |
+
$replacements = array(
|
965 |
+
'entry.\1_\2_',
|
966 |
+
'entry.\1_',
|
967 |
+
'entry.\1',
|
968 |
+
'entry_\1_\2_',
|
969 |
+
'entry_\1_',
|
970 |
+
'entry_\1',
|
971 |
+
) ;
|
972 |
+
|
973 |
+
foreach ($replacements as $key => $value)
|
974 |
+
$replacements[$key] = sprintf('%s%s', $uid, $value) ;
|
975 |
+
|
976 |
+
// Handle form id attribute
|
977 |
+
$patterns[] = '/id="ss-form"/' ;
|
978 |
+
$replacements[] = sprintf('id="%sss-form"', $uid) ;
|
979 |
+
|
980 |
+
// Handle submit button id attribute
|
981 |
+
$patterns[] = '/id="ss-submit"/' ;
|
982 |
+
$replacements[] = sprintf('id="%sss-submit"', $uid) ;
|
983 |
+
|
984 |
+
error_log(sprintf('%s::%s', basename(__FILE__), __LINE__)) ;
|
985 |
+
error_log(print_r($replacements, true)) ;
|
986 |
+
$html = preg_replace($patterns, $replacements, $html) ;
|
987 |
+
//error_log(print_r($html, true)) ;
|
988 |
+
endif;
|
989 |
+
|
990 |
if (WPGFORM_DEBUG)
|
991 |
{
|
992 |
wpgform_whereami(__FILE__, __LINE__, 'ConstructGoogleForm') ;
|
1132 |
// Need to fix the name arguments for checkboxes so PHP will pass them as an array correctly.
|
1133 |
// This jQuery script reformats the checkboxes so that Googles Python script will read them.
|
1134 |
|
1135 |
+
//$vMsgs_js = &self::$vMsgs_js ;
|
1136 |
+
//$vRules_js = &self::$vRules_js ;
|
1137 |
$vMsgs_js = array() ;
|
1138 |
$vRules_js = array() ;
|
1139 |
|
1144 |
', WPGFORM_VERSION) ;
|
1145 |
|
1146 |
// Insert breaks between labels and input fields?
|
1147 |
+
if ($br) $js .= sprintf('
|
1148 |
// Insert br elements before input and textarea boxes
|
1149 |
+
$("#%sss-form textarea").before("<br/>");
|
1150 |
+
$("#%sss-form input[type=text]").before("<br/>");
|
1151 |
+
', $uid, $uid) ;
|
1152 |
|
1153 |
// Did short code specify a CSS prefix?
|
1154 |
if (!is_null($prefix)) $js .= sprintf('
|
1185 |
{
|
1186 |
$js .= sprintf('
|
1187 |
// Construct Email User Validation
|
1188 |
+
if ($("#%sss-form input[type=submit][name=submit]").length) {
|
1189 |
+
$("#%sss-form input[type=submit][name=submit]").before(\'%s\');
|
1190 |
$("div.wpgform-user-email").show();
|
1191 |
$.validator.addClassRules("wpgform-user-email", {
|
1192 |
required: true
|
1193 |
});
|
1194 |
}
|
1195 |
+
', $uid, $uid, $user_email_html) ;
|
1196 |
$vRules_js[] = '
|
1197 |
"wpgform-user-email": {
|
1198 |
email: true
|
1207 |
$js .= sprintf('
|
1208 |
// Construct CAPTCHA
|
1209 |
$.validator.methods.equal = function(value, element, param) { return value == param; };
|
1210 |
+
if ($("#%sss-form input[type=submit][name=submit]").length) {
|
1211 |
+
$("#%sss-form input[type=submit][name=submit]").before(\'%s\');
|
1212 |
$("div.wpgform-captcha").show();
|
1213 |
$.validator.addClassRules("wpgform-captcha", {
|
1214 |
required: true,
|
1215 |
});
|
1216 |
}
|
1217 |
+
', $uid, $uid, $captcha_html, self::$wpgform_captcha['c']) ;
|
1218 |
+
|
1219 |
+
$vRules_js[] = sprintf(' "%swpgform-captcha": { equal: %s }', $uid, self::$wpgform_captcha['x']) ;
|
1220 |
+
$vMsgs_js[] = sprintf(' "%swpgform-captcha": "%s" ', $uid, __('Incorrect answer.', WPGFORM_I18N_DOMAIN)) ;
|
|
|
|
|
|
|
|
|
|
|
1221 |
}
|
1222 |
|
1223 |
// Build extra jQuery Validation rules
|
1232 |
$meta_type = get_post_meta($o['id'], $field['type_id'], true);
|
1233 |
$meta_value = get_post_meta($o['id'], $field['value_id'], true);
|
1234 |
|
1235 |
+
if (!empty($meta_field))
|
1236 |
+
{
|
1237 |
foreach ($meta_field as $key => $value)
|
1238 |
+
{
|
1239 |
+
if (!empty($value))
|
1240 |
+
{
|
1241 |
+
$extras[$value][] = sprintf('%s: %s',
|
1242 |
+
$meta_type[$key], empty($meta_value[$key]) ? 'true' : $meta_value[$key]) ;
|
1243 |
+
}
|
1244 |
+
}
|
1245 |
}
|
1246 |
}
|
1247 |
}
|
1260 |
if ($validation)
|
1261 |
{
|
1262 |
$js .= sprintf('
|
1263 |
+
$("#%sss-form").validate({
|
1264 |
errorClass: "wpgform-error",
|
1265 |
+
rules: {%s', $uid, PHP_EOL) ;
|
1266 |
if (!empty($extras))
|
1267 |
{
|
1268 |
+
error_log(sprintf('%s::%s -> %s', basename(__FILE__), __LINE__, print_r($extras, true))) ;
|
1269 |
foreach ($extras as $key => $value)
|
1270 |
{
|
1271 |
+
error_log(sprintf('%s::%s -> %s', basename(__FILE__), __LINE__, print_r($key, true))) ;
|
1272 |
+
$js .= sprintf(' "%s%s": {', $uid, $key) ;
|
1273 |
foreach ($value as $extra)
|
1274 |
$js .= sprintf('%s%s', $extra, $extra === end($value) ? '}' : ', ') ;
|
1275 |
$js .= sprintf('%s%s%s', $value === end($extras) ? '' : ',', PHP_EOL, $value === end($extras) ? ' ' : '') ;
|
1276 |
}
|
1277 |
}
|
1278 |
+
if (!empty($vRules_js))
|
1279 |
+
{
|
1280 |
+
// Clean up JS if extras were already output
|
1281 |
+
if (!empty($extras))
|
1282 |
+
$js = sprintf('%s,%s', substr($js, 0, strrpos($js, '}') + 1), PHP_EOL) ;
|
1283 |
+
|
1284 |
foreach ($vRules_js as $r)
|
1285 |
+
$js .= sprintf(' %s%s', $r, $r === end($vRules_js) ? sprintf('%s },', PHP_EOL) : ', ') ;
|
1286 |
+
}
|
|
|
|
|
|
|
1287 |
else
|
1288 |
+
$js .= '},' ;
|
1289 |
+
|
1290 |
+
$js .= sprintf('%s messages: {%s', PHP_EOL, PHP_EOL) ;
|
1291 |
+
|
1292 |
+
if (!empty($vMsgs_js))
|
1293 |
+
{
|
1294 |
foreach ($vMsgs_js as $m)
|
1295 |
+
$js .= sprintf(' %s%s', $m, $m === end($vMsgs_js) ? sprintf('%s },', PHP_EOL) : ', ') ;
|
1296 |
+
}
|
1297 |
+
else
|
1298 |
+
$js .= '}' ;
|
1299 |
$js .= '
|
1300 |
+
}) ;' . PHP_EOL ;
|
1301 |
}
|
1302 |
|
1303 |
// Handle hidden fields
|
1334 |
$patterns = array('/^entry.([0-9]+).(single|group)./', '/^entry.([0-9]+)_/', '/^entry.([0-9]+)/') ;
|
1335 |
$replacements = array('entry_\1_\2_', 'entry_\1_', 'entry_\1') ;
|
1336 |
|
1337 |
+
foreach ($replacements as $key => $value)
|
1338 |
+
$replacements[$key] = sprintf('%s%s', $uid, $value) ;
|
1339 |
+
|
1340 |
+
error_log(sprintf('%s::%s', basename(__FILE__), __LINE__)) ;
|
1341 |
+
error_log(print_r($replacements, true)) ;
|
1342 |
+
|
1343 |
+
if (!empty($meta_field))
|
1344 |
+
{
|
1345 |
foreach ($meta_field as $key => $value)
|
1346 |
{
|
1347 |
$mf = preg_replace($patterns, $replacements, $meta_field[$key]) ;
|
1349 |
if (empty($meta_value[$key]) || in_array($meta_type[$key], $ignore))
|
1350 |
$meta_value[$key] = $values[$meta_type[$key]] ;
|
1351 |
|
1352 |
+
if (!empty($mf))
|
1353 |
+
{
|
1354 |
+
$js .= sprintf(' $("#%s").val("%s");%s', $mf, $meta_value[$key], PHP_EOL) ;
|
1355 |
+
$js .= sprintf(' $("#%s").parent().css("display", "none");%s', $mf, PHP_EOL) ;
|
1356 |
+
}
|
1357 |
}
|
1358 |
}
|
1359 |
}
|
1411 |
// Make sure we don\'t split labels and input fields
|
1412 |
$("div.%sss-item").addClass("wpgform-dontsplit");
|
1413 |
// Wrap all of the form content in a DIV so it can be split
|
1414 |
+
$("#%sss-form").wrapInner("<div style=\"border: 0px dashed blue;\" class=\"wpgform-wrapper\"></div>");
|
1415 |
// Columnize the form content.
|
1416 |
$(function(){
|
1417 |
$(".wpgform-wrapper").columnize({
|
1421 |
// Wrap each column so it can styled easier
|
1422 |
$(".wpgform-column").wrapInner("<div style=\"border: 0px dashed green;\" class=\"wpgform-column-wrapper\"></div>");
|
1423 |
});
|
1424 |
+
$("#%sss-form").append("<div style=\"border: 0px dashed black; clear: both;\"></div>");
|
1425 |
$("div.%sss-form-container").after("<div style=\"border: 0px dashed black; clear: both;\"></div>");
|
1426 |
+
', $prefix, $uid, $columns, $uid, $prefix) ;
|
1427 |
|
1428 |
// Load the confirmation URL via AJAX?
|
1429 |
if (self::$posted && is_null($action) && !is_null($confirm) &&
|
1504 |
if (is_null(self::$wpgform_submitted_form_id) ||
|
1505 |
self::$wpgform_submitted_form_id == self::$wpgform_form_id - 1)
|
1506 |
{
|
1507 |
+
//self::$wpgform_js = true ;
|
1508 |
+
self::$wpgform_footer_js .= $js ;
|
1509 |
}
|
1510 |
}
|
1511 |
|
1601 |
|
1602 |
if (WPGFORM_DEBUG) wpgform_preprint_r($options) ;
|
1603 |
$form = $options['form'] ;
|
1604 |
+
$uid = $options['uid'] ;
|
1605 |
|
1606 |
$body = '' ;
|
1607 |
|
1608 |
// The name of the form fields are munged, they need
|
1609 |
// to be restored before the parameters can be posted
|
1610 |
|
1611 |
+
$patterns = array('entry_([0-9]+)_(single|group)_', 'entry_([0-9]+)_', 'entry_([0-9]+)') ;
|
1612 |
$replacements = array('entry.\1.\2.', 'entry.\1.', 'entry.\1') ;
|
1613 |
|
1614 |
+
foreach ($patterns as $key => $value)
|
1615 |
+
$patterns[$key] = sprintf('/^%s%s/', $uid, $value) ;
|
1616 |
+
|
1617 |
+
error_log(sprintf('%s::%s', basename(__FILE__), __LINE__)) ;
|
1618 |
+
error_log(print_r($patterns, true)) ;
|
1619 |
+
|
1620 |
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ProcessGoogleForm') ;
|
1621 |
if (WPGFORM_DEBUG) wpgform_preprint_r($_POST) ;
|
1622 |
|