|
4 | 4 | *
|
5 | 5 | * Bypass your website cache when loading a Gravity Forms form.
|
6 | 6 | *
|
7 |
| - * @version 0.2 |
| 7 | + * @version 0.3 |
8 | 8 | * @author David Smith <david@gravitywiz.com>
|
9 | 9 | * @license GPL-2.0+
|
10 | 10 | * @link http://gravitywiz.com/
|
|
13 | 13 | * Plugin URI: http://gravitywiz.com/
|
14 | 14 | * Description: Bypass your website cache when loading a Gravity Forms form.
|
15 | 15 | * Author: Gravity Wiz
|
16 |
| - * Version: 0.2 |
| 16 | + * Version: 0.3 |
17 | 17 | * Author URI: http://gravitywiz.com
|
18 | 18 | *
|
19 |
| - * @todo |
20 |
| - * - Pass query string to AJAX form. |
21 | 19 | */
|
22 | 20 | class GW_Cache_Buster {
|
23 | 21 |
|
@@ -138,9 +136,21 @@ public function shortcode( $markup, $attributes, $content ) {
|
138 | 136 | }
|
139 | 137 | </style>
|
140 | 138 | </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 | + ?> |
141 | 151 | <script type="text/javascript">
|
142 | 152 | ( 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; ?>', { |
144 | 154 | action: 'gfcb_get_form',
|
145 | 155 | form_id: '<?php echo $form_id; ?>',
|
146 | 156 | atts: '<?php echo json_encode( $attributes ); ?>'
|
|
0 commit comments