10
10
require_once( dirname( __FILE__ ) . '/admin.php' );
12
12
if ( ! current_user_can( 'manage_options' ) )
13
wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
13
wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
15
15
$title = __('Permalink Settings');
16
16
$parent_file = 'options-general.php';
66
66
$blog_prefix = '/blog';
69
$category_base = get_option( 'category_base' );
70
$tag_base = get_option( 'tag_base' );
71
$update_required = false;
73
if ( $iis7_permalinks ) {
74
if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') )
78
} elseif ( $is_nginx ) {
81
if ( ( ! file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) {
85
$existing_rules = array_filter( extract_from_markers( $home_path . '.htaccess', 'WordPress' ) );
86
$new_rules = array_filter( explode( "\n", $wp_rewrite->mod_rewrite_rules() ) );
87
$update_required = ( $new_rules !== $existing_rules );
91
$using_index_permalinks = $wp_rewrite->using_index_permalinks();
69
93
if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
70
94
check_admin_referer('update-permalink');
99
126
$wp_rewrite->set_tag_base( $tag_base );
129
$message = __( 'Permalink structure updated.' );
131
if ( $iis7_permalinks ) {
132
if ( $permalink_structure && ! $using_index_permalinks && ! $writable ) {
133
$message = __( 'You should update your web.config now.' );
134
} elseif ( $permalink_structure && ! $using_index_permalinks && $writable ) {
135
$message = __( 'Permalink structure updated. Remove write access on web.config file now!' );
137
} elseif ( ! $is_nginx && $permalink_structure && ! $using_index_permalinks && ! $writable && $update_required ) {
138
$message = __( 'You should update your .htaccess now.' );
141
if ( ! get_settings_errors() ) {
142
add_settings_error( 'general', 'settings_updated', $message, 'updated' );
145
set_transient( 'settings_errors', get_settings_errors(), 30 );
102
147
wp_redirect( admin_url( 'options-permalink.php?settings-updated=true' ) );
106
$category_base = get_option( 'category_base' );
107
$tag_base = get_option( 'tag_base' );
108
$update_required = false;
110
if ( $iis7_permalinks ) {
111
if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') )
115
} elseif ( $is_nginx ) {
118
if ( ( ! file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) {
122
$existing_rules = array_filter( extract_from_markers( $home_path . '.htaccess', 'WordPress' ) );
123
$new_rules = array_filter( explode( "\n", $wp_rewrite->mod_rewrite_rules() ) );
124
$update_required = ( $new_rules !== $existing_rules );
128
if ( $wp_rewrite->using_index_permalinks() )
133
151
flush_rewrite_rules();
135
153
require( ABSPATH . 'wp-admin/admin-header.php' );
137
if ( ! empty( $_GET['settings-updated'] ) ) : ?>
138
<div id="message" class="updated notice is-dismissible"><p><?php
139
if ( ! is_multisite() ) {
140
if ( $iis7_permalinks ) {
141
if ( $permalink_structure && ! $usingpi && ! $writable ) {
142
_e('You should update your web.config now.');
143
} elseif ( $permalink_structure && ! $usingpi && $writable ) {
144
_e('Permalink structure updated. Remove write access on web.config file now!');
146
_e('Permalink structure updated.');
148
} elseif ( $is_nginx ) {
149
_e('Permalink structure updated.');
151
if ( $permalink_structure && ! $usingpi && ! $writable && $update_required ) {
152
_e('You should update your .htaccess now.');
154
_e('Permalink structure updated.');
158
_e('Permalink structure updated.');
164
155
<div class="wrap">
165
156
<h1><?php echo esc_html( $title ); ?></h1>
243
234
<?php if ( !is_multisite() ) { ?>
244
235
<?php if ( $iis7_permalinks ) :
245
if ( isset($_POST['submit']) && $permalink_structure && ! $usingpi && ! $writable ) :
236
if ( isset($_POST['submit']) && $permalink_structure && ! $using_index_permalinks && ! $writable ) :
246
237
if ( file_exists($home_path . 'web.config') ) : ?>
247
238
<p><?php _e('If your <code>web.config</code> file were <a href="https://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/<configuration>/<system.webServer>/<rewrite>/<rules></code> element in <code>web.config</code> file.') ?></p>
248
239
<form action="options-permalink.php" method="post">
262
253
<?php elseif ( $is_nginx ) : ?>
263
254
<p><?php _e( '<a href="https://codex.wordpress.org/Nginx">Documentation on Nginx configuration</a>.' ); ?></p>
265
if ( $permalink_structure && ! $usingpi && ! $writable && $update_required ) : ?>
256
if ( $permalink_structure && ! $using_index_permalinks && ! $writable && $update_required ) : ?>
266
257
<p><?php _e('If your <code>.htaccess</code> file were <a href="https://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
267
258
<form action="options-permalink.php" method="post">
268
259
<?php wp_nonce_field('update-permalink') ?>