themes-wordpress/ibis/functions.php
George Stephanis 8347656eb8 Add filter to change bundled google fonts.
Initially intended as a part-fix for #3134 to enable child themes to swap typefaces that get included more easily, this also extends that change across to many themes using the common patterns.

It explicitly does not change the following themes:

Spearhead (uses different endpoint and method)

And the following themes that have multiple functions that generate typeface includes so as to avoid confusion:

* canard
* gazette
* illustratr
* publication
2021-02-18 10:20:38 -05:00

78 lines
2.1 KiB
PHP
Executable file

<?php
/**
* Ibis functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package WordPress
* @subpackage seedlet_blocks
* @since 1.0.0
*/
if ( ! function_exists( 'ibis_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function ibis_setup() {
// Add support for editor styles.
add_theme_support( 'editor-styles' );
// Enqueue editor styles.
add_editor_style( get_stylesheet_directory_uri() . '/style-editor.css' );
}
endif;
add_action( 'after_setup_theme', 'ibis_setup', 999 );
/**
* Add Google webfonts
*
* http://themeshaper.com/2014/08/13/how-to-add-google-fonts-to-wordpress-themes/
*/
function ibis_fonts_url() {
$fonts_url = '';
/* Translators: If there are characters in your language that are not
* supported by Lora, translate this to 'off'. Do not translate
* into your own language.
*/
$lora = esc_html_x( 'on', 'Lora font: on or off', 'ibis' );
if ( 'off' !== $lora ) {
$font_families = array();
$font_families[] = 'Lora:400,400i,600,600i,700,700i';
/**
* A filter to enable child themes to add/change/omit font families.
*
* @param array $font_families An array of font families to be imploded for the Google Font API
*/
$font_families = apply_filters( 'included_google_font_families', $font_families );
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
}
return esc_url_raw( $fonts_url );
}
/**
* Enqueue scripts and styles.
*/
function ibis_enqueue() {
wp_enqueue_style( 'ibis-styles', get_stylesheet_uri() );
// enqueue Google fonts
wp_enqueue_style( 'mayland-fonts', ibis_fonts_url(), array(), null );
}
add_action( 'wp_enqueue_scripts', 'ibis_enqueue' );