fix: Bypass headless home URL for specific cases

This commit is contained in:
2026-01-22 09:02:32 -05:00
parent 4492d760bb
commit 108269e3fe

View File

@@ -16,3 +16,17 @@ function moonshine_after_setup_theme() {
// 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',
);
foreach ( $excluded_patterns as $pattern ) {
if ( preg_match( $pattern, $url ) ) {
return get_site_url( $blog_id, $path, $orig_scheme );
}
}
return $url;
}