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() {
|
2022-10-28 15:43:41 +00:00
|
|
|
// Make theme available for translation.
|
|
|
|
load_theme_textdomain( 'blockbase' );
|
|
|
|
if ( ! 'blockbase' === wp_get_theme()->get( 'TextDomain' ) ) {
|
|
|
|
load_theme_textdomain( wp_get_theme()->get( 'TextDomain' ) );
|
|
|
|
}
|
|
|
|
|
2021-03-04 18:53:34 +00:00
|
|
|
// Alignwide and alignfull classes in the block editor.
|
|
|
|
add_theme_support( 'align-wide' );
|
|
|
|
|
2023-07-13 13:51:43 +00:00
|
|
|
// Add support for link color control.
|
|
|
|
add_theme_support( 'link-color' );
|
2021-03-04 18:53:34 +00:00
|
|
|
|
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-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(
|
2022-10-28 15:43:41 +00:00
|
|
|
'/assets/ponyfill.css',
|
2021-03-19 18:32:02 +00:00
|
|
|
)
|
|
|
|
);
|
2021-06-28 09:51:45 +00:00
|
|
|
|
2022-07-20 18:54:48 +00:00
|
|
|
// Register two nav menus if Gutenberg is activated (otherwise the __experimentalMenuLocation attribute isn't available)
|
|
|
|
if ( defined( 'IS_GUTENBERG_PLUGIN' ) ) {
|
|
|
|
register_nav_menus(
|
|
|
|
array(
|
|
|
|
'primary' => __( 'Primary Navigation', 'blockbase' ),
|
|
|
|
'social' => __( 'Social Navigation', 'blockbase' ),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2021-06-28 09:51:45 +00:00
|
|
|
|
2021-09-22 10:20:19 +00:00
|
|
|
add_filter(
|
|
|
|
'block_editor_settings_all',
|
|
|
|
function( $settings ) {
|
|
|
|
$settings['defaultBlockTemplate'] = '<!-- wp:group {"layout":{"inherit":true}} --><div class="wp-block-group"><!-- wp:post-content /--></div><!-- /wp:group -->';
|
|
|
|
return $settings;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2021-09-27 18:31:07 +00:00
|
|
|
// Add support for core custom logo.
|
|
|
|
add_theme_support(
|
|
|
|
'custom-logo',
|
|
|
|
array(
|
|
|
|
'height' => 192,
|
|
|
|
'width' => 192,
|
|
|
|
'flex-width' => true,
|
|
|
|
'flex-height' => true,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2021-03-19 18:32:02 +00:00
|
|
|
}
|
2021-03-04 18:53:34 +00:00
|
|
|
endif;
|
2021-10-06 10:28:32 +00:00
|
|
|
add_action( 'after_setup_theme', 'blockbase_support', 9 );
|
2021-03-04 18:53:34 +00:00
|
|
|
|
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-11-17 19:04:16 +00:00
|
|
|
// Add the child theme CSS if it exists.
|
|
|
|
if ( file_exists( get_stylesheet_directory() . '/assets/theme.css' ) ) {
|
|
|
|
add_editor_style(
|
|
|
|
'/assets/theme.css'
|
|
|
|
);
|
|
|
|
}
|
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() {
|
|
|
|
wp_enqueue_style( 'blockbase-ponyfill', get_template_directory_uri() . '/assets/ponyfill.css', array(), wp_get_theme()->get( 'Version' ) );
|
2021-11-17 19:04:16 +00:00
|
|
|
|
|
|
|
// Add the child theme CSS if it exists.
|
|
|
|
if ( file_exists( get_stylesheet_directory() . '/assets/theme.css' ) ) {
|
2022-07-20 18:54:48 +00:00
|
|
|
wp_enqueue_style( 'blockbase-child-styles', get_stylesheet_directory_uri() . '/assets/theme.css', array( 'blockbase-ponyfill' ), wp_get_theme()->get( 'Version' ) );
|
2021-11-17 19:04:16 +00:00
|
|
|
}
|
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-06-25 10:22:53 +00:00
|
|
|
/**
|
|
|
|
* Customize Global Styles
|
|
|
|
*/
|
2021-10-06 10:28:32 +00:00
|
|
|
if ( class_exists( 'WP_Theme_JSON_Resolver_Gutenberg' ) ) {
|
|
|
|
require get_template_directory() . '/inc/customizer/wp-customize-colors.php';
|
2022-03-11 08:27:22 +00:00
|
|
|
require get_template_directory() . '/inc/social-navigation.php';
|
2021-10-06 10:28:32 +00:00
|
|
|
}
|
2021-08-27 10:48:08 +00:00
|
|
|
|
2022-07-20 18:54:48 +00:00
|
|
|
require get_template_directory() . '/inc/fonts/custom-fonts.php';
|
2023-04-13 16:04:42 +00:00
|
|
|
require get_template_directory() . '/inc/rest-api.php';
|
2022-07-20 18:54:48 +00:00
|
|
|
|
|
|
|
|
2021-09-28 14:26:21 +00:00
|
|
|
// Force menus to reload
|
|
|
|
add_action(
|
|
|
|
'customize_controls_enqueue_scripts',
|
|
|
|
static function () {
|
|
|
|
wp_enqueue_script(
|
|
|
|
'wp-customize-nav-menu-refresh',
|
|
|
|
get_template_directory_uri() . '/inc/customizer/wp-customize-nav-menu-refresh.js',
|
2022-07-20 18:54:48 +00:00
|
|
|
array( 'customize-nav-menus' ),
|
2021-09-28 14:26:21 +00:00
|
|
|
wp_get_theme()->get( 'Version' ),
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2021-10-15 07:27:27 +00:00
|
|
|
|
2021-11-22 13:21:35 +00:00
|
|
|
/**
|
|
|
|
* Block Patterns.
|
|
|
|
*/
|
|
|
|
require get_template_directory() . '/inc/block-patterns.php';
|
2022-01-19 09:06:55 +00:00
|
|
|
|
|
|
|
// Add the child theme patterns if they exist.
|
|
|
|
if ( file_exists( get_stylesheet_directory() . '/inc/block-patterns.php' ) ) {
|
|
|
|
require_once get_stylesheet_directory() . '/inc/block-patterns.php';
|
2022-05-23 16:00:34 +00:00
|
|
|
}
|