2021-03-04 18:53:34 +00:00
|
|
|
<?php
|
2021-05-25 09:37:50 +00:00
|
|
|
if ( ! function_exists( 'blockbase_support' ) ) :
|
|
|
|
function blockbase_support() {
|
2021-03-04 18:53:34 +00:00
|
|
|
|
|
|
|
// 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-04 18:53:34 +00:00
|
|
|
// Add support for editor styles.
|
|
|
|
add_theme_support( 'editor-styles' );
|
2021-03-19 18:32:02 +00:00
|
|
|
|
2021-05-06 15:06:23 +00:00
|
|
|
// Add support for post thumbnails.
|
|
|
|
add_theme_support( 'post-thumbnails' );
|
|
|
|
|
2021-03-19 18:32:02 +00:00
|
|
|
// Enqueue editor styles.
|
|
|
|
add_editor_style(
|
|
|
|
array(
|
|
|
|
'/assets/ponyfill.css',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2021-05-25 09:37:50 +00:00
|
|
|
add_action( 'after_setup_theme', 'blockbase_support' );
|
2021-03-04 18:53:34 +00:00
|
|
|
endif;
|
|
|
|
|
2021-03-17 12:37:41 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Enqueue scripts and styles.
|
|
|
|
*/
|
2021-05-25 09:37:50 +00:00
|
|
|
function blockbase_editor_styles() {
|
2021-03-17 12:37:41 +00:00
|
|
|
// Enqueue editor styles.
|
2021-03-19 18:32:02 +00:00
|
|
|
add_editor_style(
|
|
|
|
array(
|
2021-05-25 09:37:50 +00:00
|
|
|
blockbase_fonts_url(),
|
2021-03-19 18:32:02 +00:00
|
|
|
)
|
|
|
|
);
|
2021-03-17 12:37:41 +00:00
|
|
|
}
|
2021-05-25 09:37:50 +00:00
|
|
|
add_action( 'admin_init', 'blockbase_editor_styles' );
|
2021-03-17 12:37:41 +00:00
|
|
|
|
2021-03-04 18:53:34 +00:00
|
|
|
/**
|
2021-03-10 17:53:07 +00:00
|
|
|
*
|
2021-03-04 18:53:34 +00:00
|
|
|
* Enqueue scripts and styles.
|
|
|
|
*/
|
2021-05-25 09:37:50 +00:00
|
|
|
function blockbase_scripts() {
|
2021-03-10 17:53:07 +00:00
|
|
|
// Enqueue Google fonts
|
2021-05-25 09:37:50 +00:00
|
|
|
wp_enqueue_style( 'blockbase-fonts', blockbase_fonts_url(), array(), null );
|
|
|
|
wp_enqueue_style( 'blockbase-ponyfill', get_template_directory_uri() . '/assets/ponyfill.css', array(), wp_get_theme()->get( 'Version' ) );
|
2021-03-04 18:53:34 +00:00
|
|
|
}
|
2021-05-25 09:37:50 +00:00
|
|
|
add_action( 'wp_enqueue_scripts', 'blockbase_scripts' );
|
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-05-25 09:37:50 +00:00
|
|
|
function blockbase_fonts_url() {
|
2021-05-24 21:23:13 +00:00
|
|
|
if ( ! class_exists( 'WP_Theme_JSON_Resolver_Gutenberg' ) ) {
|
2021-04-27 09:17:30 +00:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2021-05-24 21:23:13 +00:00
|
|
|
$theme_data = WP_Theme_JSON_Resolver_Gutenberg::get_merged_data()->get_settings();
|
2021-05-05 17:51:52 +00:00
|
|
|
if ( empty( $theme_data ) || empty( $theme_data['custom'] ) ) {
|
2021-04-27 09:17:30 +00:00
|
|
|
return '';
|
|
|
|
}
|
2021-03-10 17:53:07 +00:00
|
|
|
|
2021-05-05 17:51:52 +00:00
|
|
|
$custom_data = $theme_data['custom'];
|
2021-04-27 16:19:31 +00:00
|
|
|
if ( ! array_key_exists( 'fontsToLoadFromGoogle', $custom_data ) ) {
|
2021-04-27 14:21:27 +00:00
|
|
|
return '';
|
2021-03-10 17:53:07 +00:00
|
|
|
}
|
|
|
|
|
2021-05-05 17:51:52 +00:00
|
|
|
$font_families = $theme_data['custom']['fontsToLoadFromGoogle'];
|
2021-04-27 14:21:27 +00:00
|
|
|
$font_families[] = 'display=swap';
|
|
|
|
|
|
|
|
// Make a single request for the theme fonts.
|
|
|
|
return esc_url_raw( 'https://fonts.googleapis.com/css2?' . implode( '&', $font_families ) );
|
2021-03-10 17:53:07 +00:00
|
|
|
}
|
2021-06-25 10:22:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Customize Global Styles
|
|
|
|
*/
|
|
|
|
require get_template_directory() . '/inc/customization.php';
|