34 lines
944 B
PHP
34 lines
944 B
PHP
<?php
|
|
|
|
// Setup theme
|
|
add_action( 'after_setup_theme', 'moonshine_after_setup_theme' );
|
|
function moonshine_after_setup_theme() {
|
|
// Load textdomain
|
|
load_theme_textdomain( 'moonshine', get_theme_file_path( 'languages' ) );
|
|
|
|
// Theme features
|
|
add_theme_support( 'custom-logo' );
|
|
add_theme_support( 'editor-styles' );
|
|
remove_theme_support( 'core-block-patterns' );
|
|
|
|
// Register menus
|
|
register_nav_menu( 'main', __( "Main menu", 'moonshine' ) );
|
|
|
|
// Register sidebars
|
|
}
|
|
|
|
// Bypass headless home URL for specific cases
|
|
add_filter( 'home_url', 'moonshine_bypass_home_url', 10, 4 );
|
|
function moonshine_bypass_home_url( $url, $path, $orig_scheme, $blog_id ) {
|
|
$excluded_patterns = array(
|
|
'#/wp-json(/|$)#i', // WP REST API
|
|
'#\.(xsl|xml)$#i', // Sitemap and XSLT files
|
|
);
|
|
foreach ( $excluded_patterns as $pattern ) {
|
|
if ( preg_match( $pattern, $url ) ) {
|
|
return get_site_url( $blog_id, $path, $orig_scheme );
|
|
}
|
|
}
|
|
return $url;
|
|
}
|