enque_selected_font

The Contact Form 7 Style enque selected font function.

Description

enque_selected_font(); 

Usage

  1. if ( !function_exists( 'enque_selected_font' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7-style/cf7-style-meta-box.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = enque_selected_font(); 
  7.  

Defined (1)

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

/cf7-style-meta-box.php  
  1. function enque_selected_font() { 
  2. if ( is_page() || is_single() || is_home() ) { 
  3. global $post; 
  4. $active_styles = active_styles(); 
  5. foreach( $active_styles as $cf7s_id ) { 
  6. if ( $cf7s_id ) { 
  7. $fontid = get_post_meta( $cf7s_id, 'cf7_style_font', true ); 
  8. $googlefont = preg_replace( "/ /", "+", $fontid ); 
  9. if( ! empty( $googlefont ) && "none" !== $googlefont ) { 
  10. wp_register_style( 'googlefont-cf7style-' . $cf7s_id, 'https://fonts.googleapis.com/css?family=' . $googlefont . ':100, 200, 300, 400, 500, 600, 700, 800, 900&subset=latin, latin-ext, cyrillic, cyrillic-ext, greek-ext, greek, vietnamese', array(), false, 'all' ); 
  11. wp_enqueue_style( 'googlefont-cf7style-' . $cf7s_id );