feat: Initial WordPress project
This commit is contained in:
0
wp-content/mu-plugins/.gitkeep
Normal file
0
wp-content/mu-plugins/.gitkeep
Normal file
10
wp-content/mu-plugins/disable-headless-update.php
Normal file
10
wp-content/mu-plugins/disable-headless-update.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
// Disable 'headless' theme updates
|
||||
add_filter( 'site_transient_update_themes', 'headless_disable_theme_updates' );
|
||||
function headless_disable_theme_updates( $transient ) {
|
||||
if ( isset( $transient->response['headless'] ) ) {
|
||||
unset( $transient->response['headless'] );
|
||||
}
|
||||
return $transient;
|
||||
}
|
||||
20
wp-content/mu-plugins/headless-home-url.php
Normal file
20
wp-content/mu-plugins/headless-home-url.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
// Customize home URL for headless WordPress
|
||||
add_filter( 'home_url', 'headless_home_url', 10, 4 );
|
||||
function headless_home_url( $url, $path, $orig_scheme, $blog_id ) {
|
||||
// Exclude specific patterns from rewriting
|
||||
$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 );
|
||||
}
|
||||
}
|
||||
|
||||
// Rewrite URL protocol to match original home scheme
|
||||
$scheme = wp_parse_url( get_option( 'home' ) )['scheme'] ?? 'https';
|
||||
return preg_replace( '#^https:#i', "$scheme:", $url );
|
||||
}
|
||||
Reference in New Issue
Block a user