Advertisement
kalponikoronno

Theme option part 3

Jul 30th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.50 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Kalponik oronno
  4.  *
  5.  *
  6.  */
  7.  
  8. if ( ! function_exists( 'seo_google_fonts' ) ) :
  9. /**
  10.  * Register Google fonts.
  11.  *
  12.  * @return string Google fonts URL for the theme.
  13.  */
  14. function seo_google_fonts() {
  15.     $fonts_url = '';
  16.     $fonts     = array();
  17.     $body_font_varient = cs_get_option('body_font_varient');
  18.     $body_font_varient_process = implode(',', $body_font_varient);
  19.     $body_subsets   = ':'.$body_font_varient_process.'';
  20.    
  21.    
  22.     $heading_font_varient = cs_get_option('heading_font_varient');
  23.     $heading_font_varient_process = implode(',', $heading_font_varient);
  24.     $heading_subsets   = ':'.$heading_font_varient_process.'';
  25.  
  26.    
  27.     $body_font = cs_get_option('body_font')['family'];
  28.     $body_font .= $body_subsets;
  29.    
  30.     $heading_font = cs_get_option('heading_font')['family'];
  31.     $heading_font .=  $heading_subsets;
  32.    
  33.     /* translators: If there are characters in your language that are not supported by this font, translate this to 'off'. Do not translate into your own language. */
  34.     if ( 'off' !== esc_html_x( 'on', 'Karla font: on or off', 'textdomain' ) ) {
  35.         $fonts[] = $body_font;
  36.     }
  37.  
  38.     /* translators: If there are characters in your language that are not supported by this font, translate this to 'off'. Do not translate into your own language. */
  39.     if ( 'off' !== esc_html_x( 'on', 'Lato font: on or off', 'textdomain' ) ) {
  40.         $fonts[] = $heading_font;
  41.     }
  42.  
  43.     if ( $fonts ) {
  44.         $fonts_url = add_query_arg( array(
  45.             'family' => urlencode( implode( '|', $fonts ) ),
  46.         ), 'https://fonts.googleapis.com/css' );
  47.        
  48.     }
  49.  
  50.     return $fonts_url;
  51. }
  52. endif;
  53.  
  54.  
  55. /**
  56.  * Enqueue scripts and styles.
  57.  */
  58. function seo_google_fonts_prefix() {
  59.  
  60.     // Add custom fonts, used in the main stylesheet.
  61.     wp_enqueue_style( 'seo_google-fonts', seo_google_fonts(), array(), null );
  62. }
  63. add_action( 'wp_enqueue_scripts', 'seo_google_fonts_prefix' );
  64.  
  65.  
  66. // add inline stylesheet
  67.  
  68. function seo_custom_css() {
  69.     wp_enqueue_style(
  70.         'seo_custom_style',
  71.         get_template_directory_uri() . '/assets/css/custom_style.css'
  72.     );
  73.         $body_font = cs_get_option('body_font')['family'];
  74.         $body_font_varient = cs_get_option('body_font')['variant'];
  75.         $heading_font = cs_get_option('heading_font')['family'];
  76.         $heading_font_varient = cs_get_option('heading_font')['family'];
  77.        
  78.         $enable_boxed_layout = cs_get_option('enable_boxed_layout');
  79.         $body_bg_color = cs_get_option('body_bg_color');
  80.         $body_bg = cs_get_option('body_bg');
  81.         $body_bg_image_array = wp_get_attachment_image_src($body_bg, 'large', false);
  82.         $body_bg_repeat = cs_get_option('body_bg_repeat');
  83.         $body_bg_attachment = cs_get_option('body_bg_attachment');
  84.        
  85.        
  86.         $custom_css = '
  87.         body {font-family:'.$body_font.'; font-weight:'.$body_font_varient.'}
  88.         h1,h2,h3,h4,h5,h6{font-family: '.$heading_font.';font-weight:'.$heading_font_varient.'}
  89.         ';
  90.         if($enable_boxed_layout == true){
  91.        
  92.         if(!empty($body_bg_color)){
  93.             $custom_css .='
  94.                 body{background-color:'.$body_bg_color.'}
  95.             ';
  96.         }
  97.         if(!empty($body_bg)){
  98.             $custom_css .='
  99.                 body{background-image:url:('.$body_bg_image_array[0].')}
  100.             ';
  101.         }
  102.         if(!empty($body_bg_repeat)){
  103.             $custom_css .='
  104.                 body{background-repeat:'.$body_bg_repeat.'}
  105.             ';
  106.         }
  107.         if(!empty($body_bg_attachment)){
  108.             $custom_css .='
  109.                 body{background-attachment:'.$body_bg_attachment.'}
  110.             ';
  111.         }
  112.        
  113.         }
  114.        
  115.         wp_add_inline_style( 'seo_custom_style', $custom_css );
  116. }
  117. add_action( 'wp_enqueue_scripts', 'seo_custom_css' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement