Commit 45b33dd7 authored by lucha's avatar lucha Committed by lechuck

removed googleapis font support from path theme

parent 72486daf
......@@ -2,16 +2,16 @@
/**
* Theme Fonts - A script to allow users to select theme fonts.
*
* Theme Fonts was created to give theme developers an easy way to include multiple font settings
* and multiple font choices to their users. It's main purpose is to provide integration into the
* WordPress theme customizer to allow for the selection of fonts. The script will work with basic
* Theme Fonts was created to give theme developers an easy way to include multiple font settings
* and multiple font choices to their users. It's main purpose is to provide integration into the
* WordPress theme customizer to allow for the selection of fonts. The script will work with basic
* Web-safe fonts, custom fonts added to the theme, and fonts from Google Web Fonts.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the License,
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @package ThemeFonts
......@@ -120,9 +120,9 @@ final class Theme_Fonts {
}
/**
* This method basically serves as a wrapper on 'init' to allow themes to know when to
* register their custom fonts. It also passes the object so that theme developers can
* interact with it. They'll need to use `$object->add_setting()` and `$object->add_font()`.
* This method basically serves as a wrapper on 'init' to allow themes to know when to
* register their custom fonts. It also passes the object so that theme developers can
* interact with it. They'll need to use `$object->add_setting()` and `$object->add_font()`.
* Theme devs should just set a 'callback' when they add support for this feature.
*
* @since 0.1.0
......@@ -134,7 +134,7 @@ final class Theme_Fonts {
if ( !empty( $supports[0] ) ) {
if ( isset( $supports[0]['callback'] ) )
if ( isset( $supports[0]['callback'] ) )
add_action( 'theme_fonts_register', $supports[0]['callback'] );
if ( isset( $supports[0]['customizer'] ) && true === $supports[0]['customizer'] )
......@@ -145,7 +145,7 @@ final class Theme_Fonts {
}
/**
* Add a new font setting. Theme developers should use this method to add new font settings
* Add a new font setting. Theme developers should use this method to add new font settings
* to their theme.
*
* @since 0.1.0
......@@ -169,7 +169,7 @@ final class Theme_Fonts {
}
/**
* Add a new font for selection. Theme developers should use this method to add new fonts
* Add a new font for selection. Theme developers should use this method to add new fonts
* for their theme.
*
* @since 0.1.0
......@@ -274,70 +274,13 @@ final class Theme_Fonts {
* @return void
*/
protected function get_style_uri() {
/* Get the theme-specified settings for the 'theme-fonts' feature. */
$supports = get_theme_support( 'theme-fonts' );
/* Set up an empty string for the font string. */
$font_string = '';
/* Loop through each of the font settings and queue the fonts associated with them. */
foreach ( $this->settings as $name => $setting ) {
$font_handle = get_theme_mod( "theme_font_{$name}", $setting['default'] );
$this->queue_font( $font_handle );
}
if ( empty( $this->font_queue ) )
return '';
/* Loop through each of the queued fonts and add them to the font string. */
foreach ( $this->font_queue as $family => $args ) {
$font_string .= !empty( $font_string ) ? "|{$family}" : $family;
/* If any font styles (weight, style) were specified, add them to the string. */
if ( isset( $args['styles'] ) && is_array( $args['styles'] ) ) {
$font_styles = array_unique( $args['styles'] );
$font_string .= ':' . join( ',', $font_styles );
}
}
/* Set up the query arguments and add the font family. */
$query_args = array( 'family' => $font_string );
/* If the theme registered support for other font settings, add them. */
if ( !empty( $supports[0] ) ) {
/* Get the defined subset. */
$subset = isset( $supports[0]['subset'] ) ? $supports[0]['subset'] : array();
/* Allow devs and theme users to override the subset. */
$subset = apply_filters( 'theme_fonts_subset', $subset );
/* If a subset was defined, add it to the query args. */
if ( !empty( $subset ) )
$query_args['subset'] = urlencode( join( ',', $subset ) );
/* If specific text is requested, add it to the query args. */
if ( isset( $supports[0]['text'] ) )
$query_args['text'] = urlencode( $supports[0]['text'] );
}
/* Set up the stylesheet URI. */
$style_uri = ( is_ssl() ? 'https' : 'http' ) . '://fonts.googleapis.com/css';
/* Return the stylesheet URI with added query args. */
return add_query_arg( $query_args, $style_uri );
return '';
}
/**
* Queues a font by its font family. This is separate because multiples of the same family
* may be loaded. For example, both the 'Open Sans 400' and 'Open Sans 700 Italic' could
* be loaded. These both have the same family of 'Open Sans', so we need to queue the
* Queues a font by its font family. This is separate because multiples of the same family
* may be loaded. For example, both the 'Open Sans 400' and 'Open Sans 700 Italic' could
* be loaded. These both have the same family of 'Open Sans', so we need to queue the
* fonts and attach the styles to the font family. This is only needed for Google Web Fonts.
*
* @since 0.1.0
......@@ -384,8 +327,8 @@ final class Theme_Fonts {
}
/**
* Creates the section, settings, and controls for the WordPress theme customizer screen. Each
* font setting is given an individual setting and control within the 'fonts' section. The data
* Creates the section, settings, and controls for the WordPress theme customizer screen. Each
* font setting is given an individual setting and control within the 'fonts' section. The data
* is saved in the 'theme_mod' setting for the theme with the 'theme_font_{$setting_id}' name.
*
* @since 0.1.0
......@@ -450,8 +393,8 @@ final class Theme_Fonts {
}
/**
* Returns an array of font choices for the theme customizer. Theme developers can add fonts for
* a specific setting by using the 'setting' argument. If not set, the font is added to all
* Returns an array of font choices for the theme customizer. Theme developers can add fonts for
* a specific setting by using the 'setting' argument. If not set, the font is added to all
* settings.
*
* @since 0.1.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment