From 47df0cc10e84334305d18deff0bcf0f015dd870d Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 13 Feb 2024 10:08:14 +0000 Subject: [PATCH] Permalinks: Detect Caddy web server support. Support pretty permalinks when Caddy server is detected. Props swissspidy, mukesh27, sadpencil, cfinnberg, viliamkopecky. Fixes #41877. Built from https://develop.svn.wordpress.org/trunk@57612 git-svn-id: http://core.svn.wordpress.org/trunk@57113 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/misc.php | 3 ++- wp-admin/options-permalink.php | 4 ++-- wp-includes/vars.php | 9 ++++++++- wp-includes/version.php | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 2a07061796..13552d56cf 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -39,11 +39,12 @@ function got_mod_rewrite() { * @since 3.7.0 * * @global bool $is_nginx + * @global bool $is_caddy * * @return bool Whether the server supports URL rewriting. */ function got_url_rewrite() { - $got_url_rewrite = ( got_mod_rewrite() || $GLOBALS['is_nginx'] || iis7_supports_permalinks() ); + $got_url_rewrite = ( got_mod_rewrite() || $GLOBALS['is_nginx'] || $GLOBALS['is_caddy'] || iis7_supports_permalinks() ); /** * Filters whether URL rewriting is available. diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php index 379dc8a0f5..46da9be8f3 100644 --- a/wp-admin/options-permalink.php +++ b/wp-admin/options-permalink.php @@ -154,7 +154,7 @@ if ( $iis7_permalinks ) { } else { $writable = false; } -} elseif ( $is_nginx ) { +} elseif ( $is_nginx || $is_caddy ) { $writable = false; } else { if ( ( ! file_exists( $home_path . '.htaccess' ) @@ -190,7 +190,7 @@ if ( $structure_updated ) { 'web.config' ); } - } elseif ( ! $is_nginx && $htaccess_update_required && ! $writable ) { + } elseif ( ! $is_nginx && ! $is_caddy && $htaccess_update_required && ! $writable ) { $message = sprintf( /* translators: %s: .htaccess */ __( 'You should update your %s file now.' ), diff --git a/wp-includes/vars.php b/wp-includes/vars.php index dc28b8509a..05df7ec99a 100644 --- a/wp-includes/vars.php +++ b/wp-includes/vars.php @@ -17,7 +17,7 @@ global $pagenow, $is_lynx, $is_gecko, $is_winIE, $is_macIE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone, $is_IE, $is_edge, - $is_apache, $is_IIS, $is_iis7, $is_nginx; + $is_apache, $is_IIS, $is_iis7, $is_nginx, $is_caddy; // On which page are we? if ( is_admin() ) { @@ -126,6 +126,13 @@ $is_apache = ( str_contains( $_SERVER['SERVER_SOFTWARE'], 'Apache' ) || str_cont */ $is_nginx = ( str_contains( $_SERVER['SERVER_SOFTWARE'], 'nginx' ) ); +/** + * Whether the server software is Caddy or something else + * + * @global bool $is_caddy + */ +$is_caddy = ( str_contains( $_SERVER['SERVER_SOFTWARE'], 'Caddy' ) ); + /** * Whether the server software is IIS or something else * diff --git a/wp-includes/version.php b/wp-includes/version.php index ec4d03244b..d53320b5cd 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5-alpha-57611'; +$wp_version = '6.5-alpha-57612'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.