rubenbristian

Google Fonts in WordPress Customizer #1

Jul 16th, 2014
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. /* Use list in customizer field */
  2.  
  3. $wp_customize->add_setting(
  4.     'theme_font', array(
  5.         'default' => '',
  6.         'type' => 'option',
  7.         'capability' => 'edit_theme_options'
  8.     )
  9. );
  10. $wp_customize->add_control('theme_font',
  11.     array(
  12.         'label' => 'Font',
  13.         'section' => 'typography',
  14.         'settings' => 'theme_font',
  15.         'type' => 'select',
  16.         'choices' => $google_fonts
  17.     )
  18. );
  19.  
  20. /* Use font in front */
  21.  
  22. // Get protocol
  23. protocol = is_ssl() ? 'https' : 'http';
  24.  
  25. // Get font array
  26. $theme_font = is_serialized( get_option('theme_font' ) ) ? unserialize( get_option('lobo_type_1' ) ) : array( 'default' => true, 'font-family' => '"Helvetica Neue", Helvetica, Arial, sans-serif' );
  27.  
  28. // Enqueue the font if it's not one of the defaults
  29. if ( ! isset( $theme_font['default'] ) ) {
  30.     wp_enqueue_style( $theme_font['css-name'], "$protocol://fonts.googleapis.com/css?family=" . $theme_font['css-name'] . ":300,400,400italic,500,600,700,700,800,900" );
  31. }
  32.  
  33. // Custom CSS to paste in your own way
  34. $custom_font = 'h1, h2, h3, h4, h5, h6 { font-family:' . $theme_font['font-family'] . ';}';
Add Comment
Please, Sign In to add comment