2021-03-04 18:53:34 +00:00
|
|
|
<?php
|
|
|
|
if ( ! function_exists( 'blank_canvas_blocks_support' ) ) :
|
|
|
|
function blank_canvas_blocks_support() {
|
|
|
|
|
|
|
|
// Alignwide and alignfull classes in the block editor.
|
|
|
|
add_theme_support( 'align-wide' );
|
|
|
|
|
|
|
|
// Add support for experimental link color control.
|
|
|
|
add_theme_support( 'experimental-link-color' );
|
|
|
|
|
2021-03-09 20:58:28 +00:00
|
|
|
// Add support for responsive embedded content.
|
|
|
|
// https://github.com/WordPress/gutenberg/issues/26901
|
|
|
|
add_theme_support( 'responsive-embeds' );
|
|
|
|
|
2021-03-09 18:15:55 +00:00
|
|
|
// Add support for "reasonable default" block styles
|
|
|
|
add_theme_support( 'wp-block-styles');
|
|
|
|
|
2021-03-04 18:53:34 +00:00
|
|
|
// Add support for editor styles.
|
|
|
|
add_theme_support( 'editor-styles' );
|
|
|
|
|
|
|
|
// Enqueue editor styles.
|
2021-03-10 17:53:07 +00:00
|
|
|
add_editor_style( array(
|
|
|
|
blank_canvas_blocks_fonts_url(),
|
2021-03-04 18:53:34 +00:00
|
|
|
'/assets/ponyfill.css'
|
|
|
|
) );
|
|
|
|
|
|
|
|
}
|
|
|
|
add_action( 'after_setup_theme', 'blank_canvas_blocks_support' );
|
|
|
|
endif;
|
|
|
|
|
|
|
|
/**
|
2021-03-10 17:53:07 +00:00
|
|
|
*
|
2021-03-04 18:53:34 +00:00
|
|
|
* Enqueue scripts and styles.
|
|
|
|
*/
|
|
|
|
function blank_canvas_blocks_scripts() {
|
2021-03-10 17:53:07 +00:00
|
|
|
// Enqueue Google fonts
|
|
|
|
wp_enqueue_style( 'blank-canvas-blocks-fonts', blank_canvas_blocks_fonts_url(), array(), null );
|
|
|
|
|
2021-03-04 18:53:34 +00:00
|
|
|
wp_enqueue_style( 'blank_canvas_blocks-ponyfill', get_template_directory_uri() . '/assets/ponyfill.css', array(), wp_get_theme()->get( 'Version' ) );
|
|
|
|
}
|
|
|
|
add_action( 'wp_enqueue_scripts', 'blank_canvas_blocks_scripts', 11 );
|
2021-03-10 17:53:07 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-12 15:15:10 +00:00
|
|
|
* Add Google webfonts
|
2021-03-10 17:53:07 +00:00
|
|
|
*
|
2021-03-12 15:15:10 +00:00
|
|
|
* @return $fonts_url
|
2021-03-10 17:53:07 +00:00
|
|
|
*/
|
2021-03-12 15:15:10 +00:00
|
|
|
|
2021-03-10 17:53:07 +00:00
|
|
|
function blank_canvas_blocks_fonts_url() {
|
|
|
|
$fonts_url = '';
|
|
|
|
|
2021-03-12 16:46:42 +00:00
|
|
|
$theme_data = WP_Theme_JSON_Resolver::get_merged_data()->get_settings();
|
2021-03-15 16:18:15 +00:00
|
|
|
$custom_data = $theme_data['defaults']['custom'];
|
|
|
|
if ( array_key_exists( 'fontsToLoadFromGoogle', $custom_data ) ) {
|
|
|
|
$font_families = $theme_data['defaults']['custom']['fontsToLoadFromGoogle'];
|
2021-03-10 17:53:07 +00:00
|
|
|
|
2021-03-12 15:15:10 +00:00
|
|
|
$font_families[] = 'display=swap';
|
2021-03-10 17:53:07 +00:00
|
|
|
|
2021-03-12 15:15:10 +00:00
|
|
|
// Make a single request for the theme fonts.
|
|
|
|
$fonts_url = 'https://fonts.googleapis.com/css2?' . implode( '&', $font_families );
|
2021-03-10 17:53:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return esc_url_raw( $fonts_url );
|
|
|
|
}
|