Skip to content

Commit

Permalink
Merge pull request #26 from siteorigin/add-siteorigin_web_font_url-su…
Browse files Browse the repository at this point in the history
…pport

Add full `siteorigin_web_font_url` support
  • Loading branch information
AlexGStapleton authored Feb 12, 2024
2 parents e52163f + 18ee9aa commit b6fe6c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,21 +256,21 @@ function origami_save_post($post_id){
* This just displays the Google web fonts
*/
function origami_enqueue_google_webfonts(){
$google_fonts_url = esc_url( apply_filters( 'siteorigin_web_font_url', 'https://fonts.googleapis.com/css' ) );

if( ! get_header_image() ){
// Enqueue the logo font as well (Terminal Dosis 200)
wp_enqueue_style('google-webfonts', '//fonts.googleapis.com/css?family=Terminal+Dosis:200,400');
wp_enqueue_style('google-webfonts', $google_fonts_url . '?family=Terminal+Dosis:200,400');
}
else{
// Enqueue only the text fonts that we need
wp_enqueue_style('google-webfonts', '//fonts.googleapis.com/css?family=Terminal+Dosis:400');
wp_enqueue_style('google-webfonts', $google_fonts_url . '?family=Terminal+Dosis:400');
}

}
endif;
add_action('wp_enqueue_scripts', 'origami_enqueue_google_webfonts');


if(!function_exists('origami_comment')) :
/**
* Display a comment
Expand Down
16 changes: 11 additions & 5 deletions inc/customizer/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,33 @@ function __construct($defaults) {
/**
* Echo all the CSS
*/
function css() {
public function css() {
// Start by importing Google web fonts
$return = '<style type="text/css" id="customizer-css">';

if ( apply_filters( 'origami_import_google_fonts', true ) ) {
$import = array();

foreach ( $this->google_fonts as $font ) {
$import[ ] = urlencode( $font[ 0 ] ) . ':' . $font[ 1 ];
}
$import = array_unique( $import );
if ( !empty( $import ) ) {
$return .= '@import url(//fonts.googleapis.com/css?family=' . implode( '|', $import ) . '&display=block); ';

if ( ! empty( $import ) ) {
$return .= '@import url(' . esc_url( apply_filters( 'siteorigin_web_font_url', 'https://fonts.googleapis.com/css' ) . '?family=' . implode( '|', $import ) . '&display=block ' ) . ');';
}
}

foreach ( $this->css as $selector => $rules ) {
$return .= $selector . ' { ' . implode( '; ', $rules ) . ' } ';
}
if( !empty($this->raw_css) ) $return .= $this->raw_css;

if ( ! empty( $this->raw_css ) ) {
$return .= $this->raw_css;
}

$return .= '</style>';

return $return;
}

Expand Down Expand Up @@ -570,7 +576,7 @@ function create_css_builder(){
}
}
}

if ( isset( $setting['callback'] ) ) {
$val = get_theme_mod( $id );
if ( isset( $setting['default'] ) && $val != $setting['default'] ) {
Expand Down

0 comments on commit b6fe6c2

Please sign in to comment.