Contactform7

<?php

add_action('wp_enqueue_scripts', function () {
  if (!is_page_template('template-contact.php')) {
    wp_dequeue_script('wpcf7-redirect-script');
    wp_dequeue_script('contact-form-7');
    wp_dequeue_style('contact-form-7');
    wp_dequeue_script('google-recaptcha');
    wp_dequeue_script('wpcf7-recaptcha');
    wp_dequeue_script('googlemaps');
  }
}, 100);

add_action('wp_enqueue_scripts', function () {
  if (!is_page_template('template-contact.php')) {
    remove_action('wpcf7_enqueue_scripts', array('ContactForm7Datepicker', 'enqueue_js'));
    remove_action('wpcf7_enqueue_styles', array('ContactForm7Datepicker', 'enqueue_css'));
  }
}, 5);

add_filter('wpcf7_load_js', '__return_false');
add_filter('wpcf7_load_css', '__return_false');

// Remove contact form 7 <br> en <p> tags
add_filter('wpcf7_autop_or_not', '__return_false');


// Youngtimermagazine
// Add Google ReCaptcha in Dutch (nl_NL) to ContactForm 7
function c7_recaptcha()
{
	wp_deregister_script('google-recaptcha');

	$url = 'https://www.google.com/recaptcha/api.js';
	$url = add_query_arg(
		[
		'onload' => 'recaptchaCallback',
		'render' => 'explicit',
		'hl' => 'nl'
		],
		$url
	);

	wp_register_script('google-recaptcha', $url, [], '2.0', true);
}
add_action('wpcf7_enqueue_scripts', 'c7_recaptcha', 11);
Last Updated:
Contributors: Niek Vlam, Suite Seven