kalponikoronno

Google font ad

Jul 30th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.97 KB | None | 0 0
  1. <?php
  2.  
  3.     function seo_custom_style(){
  4.         wp_enqueue_style('custom-style',get_template_directory_uri().'/inc/custom-style.css');
  5.  
  6.         $seo_body_font = cs_get_option('body_font');
  7.         $seo_heading_font = cs_get_option('heading_font');
  8.  
  9.         if( array_key_exists('family', $seo_body_font) ){
  10.             $seo_body_font_get = $seo_body_font['family'];
  11.         }
  12.         if( array_key_exists('family', $seo_heading_font) ){
  13.             $seo_heading_font_get = $seo_heading_font['family'];
  14.         }
  15.  
  16.         $custom_css = 'body{ font-family : '.$seo_body_font_get.' }
  17.                       h1, h2, h3, h4, h5, h6 {font-family: '.$seo_heading_font_get.'}
  18.         ';
  19.  
  20.         wp_add_inline_style('custom-style',$custom_css);
  21.     }
  22.  
  23.     add_action('wp_enqueue_scripts','seo_custom_style');
  24.  
  25.     function seo_custom_google_font_get(){
  26.  
  27.         $fonts_url = '';
  28.  
  29.         $seo_body_font = cs_get_option('body_font');
  30.  
  31.         if( array_key_exists('family', $seo_body_font) ){
  32.             $seo_body_font_get = $seo_body_font['family'];
  33.         }
  34.  
  35.         if ( 'off' !== _x( 'on', 'Google font: on or off', 'seo-practice' ) ) {
  36.             $fonts_url = add_query_arg( 'family' , urlencode(''.$seo_body_font_get.':300,300i,400,400i,700,700i,900,900i&subset=latin,latin-ext'),'https://fonts.googleapis.com/css' );
  37.         }
  38.         return $fonts_url;
  39.     }
  40.  
  41.     function seo_custom_header_google_font_get(){
  42.         $fonts_url = '';
  43.  
  44.         $seo_heading_font = cs_get_option('heading_font');
  45.  
  46.         if( array_key_exists('family', $seo_heading_font) ){
  47.             $seo_heading_font_get = $seo_heading_font['family'];
  48.         }
  49.  
  50.         if ( 'off' !== _x( 'on', 'Google font: on or off', 'seo-practice' ) ) {
  51.             $fonts_url = add_query_arg( 'family' , urlencode(''.$seo_heading_font_get.':300,300i,400,400i,700,700i,900,900i&subset=latin,latin-ext'),'https://fonts.googleapis.com/css' );
  52.         }
  53.         return $fonts_url;
  54.     }
  55.  
  56.  
  57.     function seo_gf_option(){
  58.         wp_enqueue_style('seo-custom-google-font',seo_custom_google_font_get());
  59.         wp_enqueue_style('seo-custom-header-google-font',seo_custom_header_google_font_get());
  60.     }
  61.  
  62.     add_action('wp_enqueue_scripts','seo_gf_option');
Add Comment
Please, Sign In to add comment