Skip to content

Instantly share code, notes, and snippets.

@Asikur22
Last active November 17, 2022 11:37
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Asikur22/e2bdcd7da7b35ad63bbb90fb1e646f14 to your computer and use it in GitHub Desktop.
Save Asikur22/e2bdcd7da7b35ad63bbb90fb1e646f14 to your computer and use it in GitHub Desktop.
Disable WP CF7 Refill #ContactForm7
/*
* Disable CF7 Refill
*/
function aa_disable_wpcf7_refill() {
global $wp_scripts;
$handle = 'contact-form-7';
$object_name = 'wpcf7';
$data = $wp_scripts->get_data( $handle, 'data' );
if ( ! empty( $data ) ) {
if ( ! is_array( $data ) ) {
$data = json_decode( str_replace( 'var ' . $object_name . ' = ', '', substr( $data, 0, - 1 ) ), true );
}
foreach ( $data as $key => $value ) {
$localized_data[ $key ] = $value;
}
unset($localized_data['cached']);
$wp_scripts->add_data( $handle, 'data', '' );
wp_localize_script( $handle, $object_name, $localized_data );
}
}
add_action( 'wpcf7_enqueue_scripts', 'aa_disable_wpcf7_refill' );
@cmdntd
Copy link

cmdntd commented Sep 13, 2021

Thanks. Your update is really ok in test.

@amircloner
Copy link

Thanks. that's work good

can you explain how it works

@Asikur22
Copy link
Author

Basically it is changing wpcf7.cached = 0

@Ninetheme
Copy link

image

there are errors
thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment