Skip to content

Instantly share code, notes, and snippets.

@themeblvd
Created October 21, 2012 17:41
Show Gist options
  • Save themeblvd/3927757 to your computer and use it in GitHub Desktop.
Save themeblvd/3927757 to your computer and use it in GitHub Desktop.
Add typography options to Jump Start
<?php
/**
* Add Styles Option tab
*/
themeblvd_add_option_tab( 'styles', 'Styles', true );
/**
* Add typography section of two options,
* one for the body and for the headers.
*/
$typography_options = array(
array(
'name' => __( 'Primary Font', 'themeblvd' ),
'desc' => __( 'This applies to most of the text on your site.', 'themeblvd' ),
'id' => 'typography_body',
'std' => array('size' => '12px','face' => 'arial','color' => '', 'google' => ''),
'atts' => array('size', 'face'),
'type' => 'typography'
),
array(
'name' => __( 'Header Font', 'themeblvd' ),
'desc' => __( 'This applies to all of the primary headers throughout your site (h1, h2, h3, h4, h5, h6). This would include header tags used in redundant areas like widgets and the content of posts and pages.', 'themeblvd' ),
'id' => 'typography_header',
'std' => array('size' => '','face' => 'google','color' => '', 'google' => 'Droid Sans:700'),
'atts' => array('face'),
'type' => 'typography'
)
);
themeblvd_add_option_section( 'styles', 'typography', 'Typography', 'Configure your fonts.', $typography_options );
/**
* Incorporate those options on the
* frontend of the site.
*/
function my_fonts(){
// Get fonts saved from theme options
$body_font = themeblvd_get_option( 'typography_body' );
$header_font = themeblvd_get_option( 'typography_header' );
// Include font files from Google
themeblvd_include_google_fonts( $body_font, $header_font );
// Set CSS based on user font selections
?>
<style>
body {
font-family: <?php echo themeblvd_get_font_face($body_font); ?>;
font-size: <?php echo $body_font['size']; ?>;
}
h1, h2, h3, h4, h5, h6, .slide-title {
font-family: <?php echo themeblvd_get_font_face($header_font); ?>;
}
</style>
<?php
}
add_action( 'wp_head', 'my_fonts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment