<?php
/**
 * Settings | WPCF7
 *
 * @package Dotspice
 * @version 1.3.0
 */


if ( defined( 'WPCF7_VERSION' ) ) {

	/**
	 * Remove AUTOP from WPCF 7
	 */
	add_filter( 'wpcf7_autop_or_not', '__return_false' );


	/**
	 * Remove WPCF 7 css
	 */
	add_filter( 'wpcf7_load_css', '__return_false' );


	/**
	 * Allow Shortcodes
	 */
	function dotspice_wpcf7_form_allow_shortcodes( $wpcf7_form ) {
		$wpcf7_form = do_shortcode( $wpcf7_form );

		return $wpcf7_form;
	}
	add_filter( 'wpcf7_form_elements', 'dotspice_wpcf7_form_allow_shortcodes' );


	/**
	 * Set Bootstrap Classes
	 */
	add_filter('wpcf7_form_elements', function($content) {

		// checkbox
		$content = preg_replace( '/type="checkbox"/', 'type="checkbox" class="form-check-input"', $content);

		// radio
		$content = preg_replace( '/type="radio"/', 'type="radio" class="form-check-input"', $content);

		return $content;
	});
}