form_class_attr

Add cf7skins classes to the CF7 HTML form class.

Description

form_class_attr( $class, $id ); 

Based on selected template & style eg. class="wpcf7-form cf7t-fieldset cf7s-wild-west"

Parameters (2)

0. $class
Is the CF7 HTML form class
1. $id
The id.

Usage

  1. if ( !function_exists( 'form_class_attr' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7-style/cf7-style.php'; 
  3.  
  4. // is the CF7 HTML form class 
  5. $class = null; 
  6.  
  7. // The id. 
  8. $id = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = form_class_attr($class, $id); 
  12.  

Defined (1)

The function is defined in the following location(s).

/cf7-style.php  
  1. function form_class_attr( $class, $id ) { 
  2.  
  3. // Get the current CF7 form ID 
  4. $cf7 = wpcf7_get_current_contact_form(); // Current contact form 7 object 
  5. $form_id = get_form_id( $cf7 ); 
  6. $template_class =''; 
  7. $cf7_style_id = get_post_meta( $form_id, 'cf7_style_id' ); 
  8. if ( isset( $cf7_style_id[0] ) ) { 
  9. $cf7_style_data = get_post( $cf7_style_id[0], OBJECT ); 
  10. $template_class = ( has_term( 'custom-style', 'style_category', $cf7_style_data ) ) ?  
  11. "cf7-style-" . $cf7_style_id[0] : $cf7_style_data->post_name; 
  12. }  
  13.  
  14. // Return the modified class 
  15. return $template_class;