# Contact Form 7

Bricks has an optional integration with the popular WordPress plugin Contact Form 7, whose functions can be accessed from functions/integrations/cf7.php.

This integration is disabled by default, and can be enabled from functions.php by uncommenting the following line:

require_once get_template_directory() . '/functions/integrations/cf7.php';

# Functions

# brk_cf7_styles_scripts()

This function is used to disable Contact Form 7 CSS and JavaScript from the site Front-End, and to re-enable them only in selected pages. This can help to improve pages speed, since by default Contact Form 7 load them everywhere, even in pages that don't include a form.

To enable CSS and JavaScript on selected pages, use a series of Conditional Tags (opens new window) as a value for $has_cf7_form variable, which is then used as a condition to enable these assets. The default value of

$has_cf7_form = is_front_page() || is_page( array( 'contacts' ));

enables Contact Form 7 on the Homepage and in a page whose slug is contacts.

TIP

If you don't use Contact Form 7, or if you want to enable it everywhere on your website, you can simply leave the inclusion of the partial functions/integrations/cf7.php commented inside functions.php.

Last Updated: 12/29/2021, 10:42:08 AM