Skip to content

Commit d32c20d

Browse files
author
Eihab
authored
Updated gw-gravity-forms-cache-buster.php to 0.3 which passes URL params.
1 parent 9ae67e8 commit d32c20d

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

gravity-forms/gw-cache-buster.php

+15-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Bypass your website cache when loading a Gravity Forms form.
66
*
7-
* @version 0.2
7+
* @version 0.3
88
* @author David Smith <david@gravitywiz.com>
99
* @license GPL-2.0+
1010
* @link http://gravitywiz.com/
@@ -13,11 +13,9 @@
1313
* Plugin URI: http://gravitywiz.com/
1414
* Description: Bypass your website cache when loading a Gravity Forms form.
1515
* Author: Gravity Wiz
16-
* Version: 0.2
16+
* Version: 0.3
1717
* Author URI: http://gravitywiz.com
1818
*
19-
* @todo
20-
* - Pass query string to AJAX form.
2119
*/
2220
class GW_Cache_Buster {
2321

@@ -138,9 +136,21 @@ public function shortcode( $markup, $attributes, $content ) {
138136
}
139137
</style>
140138
</div>
139+
<?php
140+
// Store current URL parameters and include them in AJAX call
141+
// This preserves dynamic form population
142+
$params = array();
143+
$exclude_params = array( 'action', 'form_id', 'atts' ); // Exclude parameters that may clash
144+
foreach ( $_GET as $k => $v ) {
145+
if ( ! in_array( $k, $exclude_params, true ) ) {
146+
$params[ $k ] = sprintf( '%s=%s', $k, $_GET[ $k ] );
147+
}
148+
}
149+
$params = ( count( $params ) > 0 ) ? '&' . join( '&', $params ) : '';
150+
?>
141151
<script type="text/javascript">
142152
( function ( $ ) {
143-
$.post( '<?php echo admin_url( 'admin-ajax.php' ); ?>?action=gfcb_get_form&form_id=<?php echo $form_id; ?>', {
153+
$.post( '<?php echo admin_url( 'admin-ajax.php' ); ?>?action=gfcb_get_form&form_id=<?php echo $form_id, $params; ?>', {
144154
action: 'gfcb_get_form',
145155
form_id: '<?php echo $form_id; ?>',
146156
atts: '<?php echo json_encode( $attributes ); ?>'

0 commit comments

Comments
 (0)