Skip to content

Commit

Permalink
gw-cache-buster.php: Fixed issue with Cache Buster not clearing coo…
Browse files Browse the repository at this point in the history
…kies with Paypal checkout and Nested entry.
  • Loading branch information
saifsultanc committed Jul 3, 2024
1 parent c7ba357 commit e5b32a0
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions gravity-forms/gw-cache-buster.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function init() {
return;
}

add_filter( 'gform_pre_render', array( $this, 'clear_gpnf_cookies' ) );
add_filter( 'gform_shortcode_form', array( $this, 'shortcode' ), 10, 3 );
add_filter( 'gform_save_and_continue_resume_url', array( $this, 'filter_resume_link' ), 15, 4 );
add_filter( 'gform_pre_replace_merge_tags', array( $this, 'replace_embed_url' ), 10, 4 );
Expand All @@ -49,22 +48,6 @@ public function init() {
add_action( 'wp_ajax_gfcb_get_form', array( $this, 'ajax_get_form' ) );
}

public function clear_gpnf_cookies( $form ) {

if ( class_exists( 'GPNF_Session' ) && $this->is_cache_busting_applicable() ) {
$session = new GPNF_Session( $form['id'] );
$cookie_name = $session->get_cookie_name();
foreach ( $_COOKIE as $name => $value ) {
if ( preg_match( '/^' . preg_quote( $cookie_name, '/' ) . '/', $name ) ) {
unset( $_COOKIE[ $name ] );
setcookie( $name, '', time() - ( 15 * 60 ), COOKIEPATH, COOKIE_DOMAIN, is_ssl() );
}
}
}

return $form;
}

public function shortcode( $markup, $attributes, $content ) {

$atts = shortcode_atts(
Expand Down Expand Up @@ -162,8 +145,11 @@ public function shortcode( $markup, $attributes, $content ) {
// Still needed for the AJAX submission.
$ajax_url = add_query_arg(
array(
'action' => 'gfcb_get_form',
'form_id' => $form_id,
'action' => 'gfcb_get_form',
'form_id' => $form_id,
'gpnf_context' => array(
'path' => class_exists( 'GPNF_Session' ) ? esc_js( GPNF_Session::get_session_path() ) : '',
),
),
$ajax_url
);
Expand Down

0 comments on commit e5b32a0

Please sign in to comment.