felixarntz / bootstrap-for-contact-form-7

This plugin modifies the output of the popular Contact Form 7 plugin to be styled in compliance with themes using the Bootstrap CSS framework.
https://wordpress.org/plugins/bootstrap-for-contact-form-7/
GNU General Public License v2.0
24 stars 18 forks source link

inline styles don't respect CF7 conditional loading #56

Closed aatospaja closed 6 years ago

aatospaja commented 6 years ago

This plugin adds custom inline styles to the head section. (function cf7bs_inline_styles)

This unfortunately is loaded on every possible page as it is hooked on 'wp_head' -action. On the other hand, CF7 allows conditional loding of it's styles and scripts only when needed. ([https://contactform7.com/loading-javascript-and-stylesheet-only-when-it-is-necessary/])

So a major improvement to this plugin would be to respect CF7 conditionals and only add the inline styles when actually needed. Also it would be amazing to be able to disable the inline styles altogether and manually add them to theme css.

aatospaja commented 6 years ago

Actually I should have mentioned that one can remove the action manually in fuctions.php and then add the styles themselves when needed.

gidomanders commented 6 years ago

I've added a version check for CF7BS version 1.4.9+ to use a stylesheet instead of inline styles, for backwards compatibility. The only thing the inline styles will do is set the AJAX loader image, which you can disable by adding remove_action( 'wp_head', 'cf7bs_inline_styles' ); to your code if you use a custom loader. The new stylesheet will be loaded when the action wpcf7_enqueue_styles is fired, so if you use conditional loading, it will work for CF7BS too.

@felixarntz still has to approve version 1.4.8, but probably will deploy both versions shortly.

aatospaja commented 6 years ago

Well done! :)