Last active
November 17, 2022 11:37
-
-
Save Asikur22/e2bdcd7da7b35ad63bbb90fb1e646f14 to your computer and use it in GitHub Desktop.
Disable WP CF7 Refill #ContactForm7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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' ); |
Thanks. that's work good
can you explain how it works
Basically it is changing wpcf7.cached = 0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. Your update is really ok in test.