Skip to content

Commit

Permalink
Minify style/scripts and add source
Browse files Browse the repository at this point in the history
  • Loading branch information
crftwrk committed Sep 8, 2023
1 parent 695c4a9 commit 37e7370
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions css/bs-cf7-style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions js/bs-cf7-script.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions main.php
Expand Up @@ -5,7 +5,7 @@
* Description: Adds Bootstrap 5 alerts and checkboxes to Contact Form 7. It´s an additional plugin and needs <a href="https://wordpress.org/plugins/contact-form-7/">CF7</a> to work.
* Author: bootScore
* Author URI: https://bootscore.me
* Version: 5.1.1
* Version: 5.2.0
*/


Expand All @@ -21,30 +21,34 @@
'bs-contact-form-7-main'
);


// Register Styles and Scripts
function contact_scripts() {

wp_enqueue_script( 'contactform-script', plugins_url( '/js/contactform-script.js' , __FILE__ ), array( 'jquery' ), '1.0', true );
wp_enqueue_script( 'bs-cf7-script.js', plugins_url( '/js/bs-cf7-script.min.js' , __FILE__ ), array( 'jquery' ), '1.0', true );

wp_register_style( 'contactform-style', plugins_url('css/contactform-style.css', __FILE__) );
wp_enqueue_style( 'contactform-style' );
wp_register_style( 'bs-cf7-style.css', plugins_url('css/bs-cf7-style.min.css', __FILE__) );
wp_enqueue_style( 'bs-cf7-style.css' );
}

add_action('wp_enqueue_scripts','contact_scripts');

//Adjust contact form 7 radios and checkboxes to match bootstrap custom radio structure.

//Adjust Contact Form 7 radios and checkboxes to match bootstrap custom radio structure.
add_filter('wpcf7_form_elements', function ($content) {
$content = preg_replace('/<label><input type="(checkbox|radio)" name="(.*?)" value="(.*?)" \/><span class="wpcf7-list-item-label">/i', '<label class="form-check form-check-inline form-check-\1"><input type="\1" name="\2" value="\3" class="form-check-input"><span class="wpcf7-list-item-label form-check-label">', $content);
$content = preg_replace('/wpcf7-checkbox\sform-check-input/i', '', $content); //removes wrong classes on type=checkbox

return $content;
});


// Disable Contact Form 7 Styles
add_action( 'wp_print_styles', 'wps_deregister_styles', 100 );
function wps_deregister_styles() {
wp_deregister_style( 'contact-form-7' );
}


// Remove <p> tags (CF7 5.7)
add_filter('wpcf7_autop_or_not', '__return_false');
File renamed without changes.
File renamed without changes.

0 comments on commit 37e7370

Please sign in to comment.