diff -r 34716fd837a4 -r be944660c56a wp/wp-admin/options-permalink.php
--- a/wp/wp-admin/options-permalink.php Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-admin/options-permalink.php Wed Sep 21 18:19:35 2022 +0200
@@ -72,7 +72,7 @@
$prefix = '/index.php';
}
-/**
+/*
* In a subdirectory configuration of multisite, the `/blog` prefix is used by
* default on the main site to avoid collisions with other sites created on that
* network. If the `permalink_structure` option has been changed to remove this
@@ -82,36 +82,17 @@
$blog_prefix = '/blog';
}
-$category_base = get_option( 'category_base' );
-$tag_base = get_option( 'tag_base' );
-$update_required = false;
+$category_base = get_option( 'category_base' );
+$tag_base = get_option( 'tag_base' );
-if ( $iis7_permalinks ) {
- if ( ( ! file_exists( $home_path . 'web.config' ) && win_is_writable( $home_path ) ) || win_is_writable( $home_path . 'web.config' ) ) {
- $writable = true;
- } else {
- $writable = false;
- }
-} elseif ( $is_nginx ) {
- $writable = false;
-} else {
- if ( ( ! file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) {
- $writable = true;
- } else {
- $writable = false;
- $existing_rules = array_filter( extract_from_markers( $home_path . '.htaccess', 'WordPress' ) );
- $new_rules = array_filter( explode( "\n", $wp_rewrite->mod_rewrite_rules() ) );
- $update_required = ( $new_rules !== $existing_rules );
- }
-}
-
-$using_index_permalinks = $wp_rewrite->using_index_permalinks();
+$structure_updated = false;
+$htaccess_update_required = false;
if ( isset( $_POST['permalink_structure'] ) || isset( $_POST['category_base'] ) ) {
check_admin_referer( 'update-permalink' );
if ( isset( $_POST['permalink_structure'] ) ) {
- if ( isset( $_POST['selection'] ) && 'custom' != $_POST['selection'] ) {
+ if ( isset( $_POST['selection'] ) && 'custom' !== $_POST['selection'] ) {
$permalink_structure = $_POST['selection'];
} else {
$permalink_structure = $_POST['permalink_structure'];
@@ -129,46 +110,78 @@
$permalink_structure = sanitize_option( 'permalink_structure', $permalink_structure );
$wp_rewrite->set_permalink_structure( $permalink_structure );
+
+ $structure_updated = true;
}
if ( isset( $_POST['category_base'] ) ) {
$category_base = $_POST['category_base'];
+
if ( ! empty( $category_base ) ) {
$category_base = $blog_prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $category_base ) );
}
+
$wp_rewrite->set_category_base( $category_base );
}
if ( isset( $_POST['tag_base'] ) ) {
$tag_base = $_POST['tag_base'];
+
if ( ! empty( $tag_base ) ) {
$tag_base = $blog_prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $tag_base ) );
}
+
$wp_rewrite->set_tag_base( $tag_base );
}
+}
+if ( $iis7_permalinks ) {
+ if ( ( ! file_exists( $home_path . 'web.config' ) && win_is_writable( $home_path ) ) || win_is_writable( $home_path . 'web.config' ) ) {
+ $writable = true;
+ } else {
+ $writable = false;
+ }
+} elseif ( $is_nginx ) {
+ $writable = false;
+} else {
+ if ( ( ! file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) {
+ $writable = true;
+ } else {
+ $writable = false;
+ $existing_rules = array_filter( extract_from_markers( $home_path . '.htaccess', 'WordPress' ) );
+ $new_rules = array_filter( explode( "\n", $wp_rewrite->mod_rewrite_rules() ) );
+
+ $htaccess_update_required = ( $new_rules !== $existing_rules );
+ }
+}
+
+$using_index_permalinks = $wp_rewrite->using_index_permalinks();
+
+if ( $structure_updated ) {
$message = __( 'Permalink structure updated.' );
- if ( $iis7_permalinks ) {
- if ( $permalink_structure && ! $using_index_permalinks && ! $writable ) {
+ if ( ! is_multisite() && $permalink_structure && ! $using_index_permalinks ) {
+ if ( $iis7_permalinks ) {
+ if ( ! $writable ) {
+ $message = sprintf(
+ /* translators: %s: web.config */
+ __( 'You should update your %s file now.' ),
+ 'web.config
'
+ );
+ } else {
+ $message = sprintf(
+ /* translators: %s: web.config */
+ __( 'Permalink structure updated. Remove write access on %s file now!' ),
+ 'web.config
'
+ );
+ }
+ } elseif ( ! $is_nginx && $htaccess_update_required && ! $writable ) {
$message = sprintf(
- /* translators: %s: web.config */
+ /* translators: %s: .htaccess */
__( 'You should update your %s file now.' ),
- 'web.config
'
- );
- } elseif ( $permalink_structure && ! $using_index_permalinks && $writable ) {
- $message = sprintf(
- /* translators: %s: web.config */
- __( 'Permalink structure updated. Remove write access on %s file now!' ),
- 'web.config
'
+ '.htaccess
'
);
}
- } elseif ( ! $is_nginx && $permalink_structure && ! $using_index_permalinks && ! $writable && $update_required ) {
- $message = sprintf(
- /* translators: %s: .htaccess */
- __( 'You should update your %s file now.' ),
- '.htaccess
'
- );
}
if ( ! get_settings_errors() ) {
@@ -344,7 +357,7 @@
if ( isset( $_POST['submit'] ) && $permalink_structure && ! $using_index_permalinks && ! $writable ) :
if ( file_exists( $home_path . 'web.config' ) ) :
?>
-
+
-
+
Documentation on Nginx configuration.' ); ?>
-+