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-06-29 18:12:16 +00:00
|
|
|
// Declare that there are no <title> tags and allow WordPress to provide them
|
|
|
|
add_theme_support( 'title-tag' );
|
|
|
|
|
2021-06-28 09:51:45 +00:00
|
|
|
// Experimental support for adding blocks inside nav menus
|
|
|
|
add_theme_support( 'block-nav-menus' );
|
|
|
|
|
2021-03-19 18:32:02 +00:00
|
|
|
// Enqueue editor styles.
|
|
|
|
add_editor_style(
|
|
|
|
array(
|
|
|
|
'/assets/ponyfill.css',
|
|
|
|
)
|
|
|
|
);
|
2021-06-28 09:51:45 +00:00
|
|
|
|
|
|
|
// This theme has one menu location.
|
|
|
|
register_nav_menus(
|
|
|
|
array(
|
|
|
|
'primary' => __( 'Primary Navigation', 'blockbase' ),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2021-03-19 18:32:02 +00:00
|
|
|
}
|
2021-08-10 09:50:40 +00:00
|
|
|
add_action( 'after_setup_theme', 'blockbase_support', 9 );
|
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-08-12 11:17:10 +00:00
|
|
|
if ( empty( $theme_data ) || empty( $theme_data['typography'] ) || empty( $theme_data['typography']['fontFamilies'] ) ) {
|
2021-04-27 09:17:30 +00:00
|
|
|
return '';
|
|
|
|
}
|
2021-03-10 17:53:07 +00:00
|
|
|
|
2021-08-12 11:17:10 +00:00
|
|
|
$font_families = [];
|
|
|
|
if ( ! empty( $theme_data['typography']['fontFamilies']['theme'] ) ) {
|
|
|
|
foreach( $theme_data['typography']['fontFamilies']['theme'] as $font ) {
|
|
|
|
if ( ! empty( $font['google'] ) ) {
|
|
|
|
$font_families[] = $font['google'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! empty( $theme_data['typography']['fontFamilies']['user'] ) ) {
|
|
|
|
foreach( $theme_data['typography']['fontFamilies']['user'] as $font ) {
|
|
|
|
if ( ! empty( $font['google'] ) ) {
|
|
|
|
$font_families[] = $font['google'];
|
|
|
|
}
|
|
|
|
}
|
2021-03-10 17:53:07 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2021-07-29 19:27:42 +00:00
|
|
|
/**
|
|
|
|
* Restores the Customizer since we still rely on it.
|
|
|
|
*/
|
|
|
|
function blockbase_restore_customizer() {
|
|
|
|
remove_action( 'admin_menu', 'gutenberg_remove_legacy_pages' );
|
|
|
|
}
|
|
|
|
add_action( 'init', 'blockbase_restore_customizer' );
|
|
|
|
|
2021-06-25 10:22:53 +00:00
|
|
|
/**
|
|
|
|
* Customize Global Styles
|
|
|
|
*/
|
2021-07-14 15:25:05 +00:00
|
|
|
require get_template_directory() . '/inc/customizer/wp-customize-colors.php';
|
|
|
|
require get_template_directory() . '/inc/customizer/wp-customize-color-palettes.php';
|
|
|
|
require get_template_directory() . '/inc/customizer/wp-customize-fonts.php';
|