[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/ -> options-permalink.php (source)

   1  <?php
   2  /**
   3   * Permalink Settings Administration Screen.
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  /** WordPress Administration Bootstrap */
  10  require_once  __DIR__ . '/admin.php';
  11  
  12  if ( ! current_user_can( 'manage_options' ) ) {
  13      wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
  14  }
  15  
  16  // Used in the HTML title tag.
  17  $title       = __( 'Permalink Settings' );
  18  $parent_file = 'options-general.php';
  19  
  20  get_current_screen()->add_help_tab(
  21      array(
  22          'id'      => 'overview',
  23          'title'   => __( 'Overview' ),
  24          'content' => '<p>' . __( 'Permalinks are the permanent URLs to your individual pages and blog posts, as well as your category and tag archives. A permalink is the web address used to link to your content. The URL to each post should be permanent, and never change &#8212; hence the name permalink.' ) . '</p>' .
  25              '<p>' . __( 'This screen allows you to choose your permalink structure. You can choose from common settings or create custom URL structures.' ) . '</p>' .
  26              '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>',
  27      )
  28  );
  29  
  30  get_current_screen()->add_help_tab(
  31      array(
  32          'id'      => 'permalink-settings',
  33          'title'   => __( 'Permalink Settings' ),
  34          'content' => '<p>' . __( 'Permalinks can contain useful information, such as the post date, title, or other elements. You can choose from any of the suggested permalink formats, or you can craft your own if you select Custom Structure.' ) . '</p>' .
  35              '<p>' . sprintf(
  36                  /* translators: %s: Percent sign (%). */
  37                  __( 'If you pick an option other than Plain, your general URL path with structure tags (terms surrounded by %s) will also appear in the custom structure field and your path can be further modified there.' ),
  38                  '<code>%</code>'
  39              ) . '</p>' .
  40              '<p>' . sprintf(
  41                  /* translators: 1: %category%, 2: %tag% */
  42                  __( 'When you assign multiple categories or tags to a post, only one can show up in the permalink: the lowest numbered category. This applies if your custom structure includes %1$s or %2$s.' ),
  43                  '<code>%category%</code>',
  44                  '<code>%tag%</code>'
  45              ) . '</p>' .
  46              '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>',
  47      )
  48  );
  49  
  50  get_current_screen()->add_help_tab(
  51      array(
  52          'id'      => 'custom-structures',
  53          'title'   => __( 'Custom Structures' ),
  54          'content' => '<p>' . __( 'The Optional fields let you customize the &#8220;category&#8221; and &#8220;tag&#8221; base names that will appear in archive URLs. For example, the page listing all posts in the &#8220;Uncategorized&#8221; category could be <code>/topics/uncategorized</code> instead of <code>/category/uncategorized</code>.' ) . '</p>' .
  55              '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>',
  56      )
  57  );
  58  
  59  $help_sidebar_content = '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  60      '<p>' . __( '<a href="https://wordpress.org/documentation/article/settings-permalinks-screen/">Documentation on Permalinks Settings</a>' ) . '</p>' .
  61      '<p>' . __( '<a href="https://wordpress.org/documentation/article/customize-permalinks/">Documentation on Using Permalinks</a>' ) . '</p>';
  62  
  63  if ( $is_nginx ) {
  64      $help_sidebar_content .= '<p>' . __( '<a href="https://developer.wordpress.org/advanced-administration/server/web-server/nginx/">Documentation on Nginx configuration</a>.' ) . '</p>';
  65  }
  66  
  67  $help_sidebar_content .= '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>';
  68  
  69  get_current_screen()->set_help_sidebar( $help_sidebar_content );
  70  unset( $help_sidebar_content );
  71  
  72  /** @global WP_Rewrite $wp_rewrite WordPress rewrite component. */
  73  global $wp_rewrite;
  74  
  75  $home_path           = get_home_path();
  76  $iis7_permalinks     = iis7_supports_permalinks();
  77  $permalink_structure = get_option( 'permalink_structure' );
  78  
  79  $index_php_prefix = '';
  80  $blog_prefix      = '';
  81  
  82  if ( ! got_url_rewrite() ) {
  83      $index_php_prefix = '/index.php';
  84  }
  85  
  86  /*
  87   * In a subdirectory configuration of multisite, the `/blog` prefix is used by
  88   * default on the main site to avoid collisions with other sites created on that
  89   * network. If the `permalink_structure` option has been changed to remove this
  90   * base prefix, WordPress core can no longer account for the possible collision.
  91   */
  92  if ( is_multisite() && ! is_subdomain_install() && is_main_site()
  93      && str_starts_with( $permalink_structure, '/blog/' )
  94  ) {
  95      $blog_prefix = '/blog';
  96  }
  97  
  98  $category_base = get_option( 'category_base' );
  99  $tag_base      = get_option( 'tag_base' );
 100  $random_base   = get_option( 'wp_random_base' );
 101  $random_base   = is_string( $random_base ) ? $random_base : '';
 102  
 103  $structure_updated        = false;
 104  $htaccess_update_required = false;
 105  
 106  if ( isset( $_POST['permalink_structure'] ) || isset( $_POST['category_base'] ) ) {
 107      check_admin_referer( 'update-permalink' );
 108  
 109      if ( isset( $_POST['permalink_structure'] ) ) {
 110          if ( isset( $_POST['selection'] ) && 'custom' !== $_POST['selection'] ) {
 111              $permalink_structure = $_POST['selection'];
 112          } else {
 113              $permalink_structure = $_POST['permalink_structure'];
 114          }
 115  
 116          if ( ! empty( $permalink_structure ) ) {
 117              $permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );
 118  
 119              if ( $index_php_prefix && $blog_prefix ) {
 120                  $permalink_structure = $index_php_prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure );
 121              } else {
 122                  $permalink_structure = $blog_prefix . $permalink_structure;
 123              }
 124          }
 125  
 126          $permalink_structure = sanitize_option( 'permalink_structure', $permalink_structure );
 127  
 128          $wp_rewrite->set_permalink_structure( $permalink_structure );
 129  
 130          $structure_updated = true;
 131      }
 132  
 133      if ( isset( $_POST['category_base'] ) ) {
 134          $category_base = $_POST['category_base'];
 135  
 136          if ( ! empty( $category_base ) ) {
 137              $category_base = $blog_prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $category_base ) );
 138          }
 139  
 140          $wp_rewrite->set_category_base( $category_base );
 141      }
 142  
 143      if ( isset( $_POST['tag_base'] ) ) {
 144          $tag_base = $_POST['tag_base'];
 145  
 146          if ( ! empty( $tag_base ) ) {
 147              $tag_base = $blog_prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $tag_base ) );
 148          }
 149  
 150          $wp_rewrite->set_tag_base( $tag_base );
 151      }
 152  
 153      if ( wp_is_random_content_redirect_enabled() && isset( $_POST['wp_random_base'] ) && is_string( $_POST['wp_random_base'] ) ) {
 154          $random_base = $_POST['wp_random_base'];
 155  
 156          if ( ! empty( $random_base ) ) {
 157              $random_base = $blog_prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $random_base ) );
 158          }
 159  
 160          $wp_rewrite->set_random_base( $random_base );
 161      }
 162  }
 163  
 164  if ( $iis7_permalinks ) {
 165      if ( ( ! file_exists( $home_path . 'web.config' )
 166          && win_is_writable( $home_path ) ) || win_is_writable( $home_path . 'web.config' )
 167      ) {
 168          $writable = true;
 169      } else {
 170          $writable = false;
 171      }
 172  } elseif ( $is_nginx || $is_caddy ) {
 173      $writable = false;
 174  } else {
 175      if ( ( ! file_exists( $home_path . '.htaccess' )
 176          && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' )
 177      ) {
 178          $writable = true;
 179      } else {
 180          $writable       = false;
 181          $existing_rules = array_filter( extract_from_markers( $home_path . '.htaccess', 'WordPress' ) );
 182          $new_rules      = array_filter( explode( "\n", $wp_rewrite->mod_rewrite_rules() ) );
 183  
 184          $htaccess_update_required = ( $new_rules !== $existing_rules );
 185      }
 186  }
 187  
 188  $using_index_permalinks = $wp_rewrite->using_index_permalinks();
 189  
 190  if ( $structure_updated ) {
 191      $message = __( 'Permalink structure updated.' );
 192  
 193      if ( ! is_multisite() && $permalink_structure && ! $using_index_permalinks ) {
 194          if ( $iis7_permalinks ) {
 195              if ( ! $writable ) {
 196                  $message = sprintf(
 197                      /* translators: %s: web.config */
 198                      __( 'You should update your %s file now.' ),
 199                      '<code>web.config</code>'
 200                  );
 201              } else {
 202                  $message = sprintf(
 203                      /* translators: %s: web.config */
 204                      __( 'Permalink structure updated. Remove write access on %s file now!' ),
 205                      '<code>web.config</code>'
 206                  );
 207              }
 208          } elseif ( ! $is_nginx && ! $is_caddy && $htaccess_update_required && ! $writable ) {
 209              $message = sprintf(
 210                  /* translators: %s: .htaccess */
 211                  __( 'You should update your %s file now.' ),
 212                  '<code>.htaccess</code>'
 213              );
 214          }
 215      }
 216  
 217      if ( ! get_settings_errors() ) {
 218          add_settings_error( 'general', 'settings_updated', $message, 'success' );
 219      }
 220  
 221      set_transient( 'settings_errors', get_settings_errors(), 30 ); // 30 seconds.
 222  
 223      wp_redirect( admin_url( 'options-permalink.php?settings-updated=true' ) );
 224      exit;
 225  }
 226  
 227  flush_rewrite_rules();
 228  
 229  require_once  ABSPATH . 'wp-admin/admin-header.php';
 230  ?>
 231  <div class="wrap">
 232  <h1><?php echo esc_html( $title ); ?></h1>
 233  
 234  <form name="form" action="options-permalink.php" method="post">
 235  <?php wp_nonce_field( 'update-permalink' ); ?>
 236  
 237  <p>
 238  <?php
 239  printf(
 240      /* translators: %s: Documentation URL. */
 241      __( 'WordPress offers you the ability to create a custom URL structure for your permalinks and archives. Custom URL structures can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="%s">number of tags are available</a>, and here are some examples to get you started.' ),
 242      __( 'https://wordpress.org/documentation/article/customize-permalinks/' )
 243  );
 244  ?>
 245  </p>
 246  
 247  <?php
 248  if ( is_multisite() && ! is_subdomain_install() && is_main_site()
 249      && str_starts_with( $permalink_structure, '/blog/' )
 250  ) {
 251      $permalink_structure = preg_replace( '|^/?blog|', '', $permalink_structure );
 252      $category_base       = preg_replace( '|^/?blog|', '', $category_base );
 253      $tag_base            = preg_replace( '|^/?blog|', '', $tag_base );
 254      $random_base         = preg_replace( '|^/?blog|', '', $random_base ) ?? '';
 255  }
 256  
 257  $url_base = home_url( $blog_prefix . $index_php_prefix );
 258  
 259  $default_structures = array(
 260      array(
 261          'id'      => 'plain',
 262          'label'   => __( 'Plain' ),
 263          'value'   => '',
 264          'example' => home_url( '/?p=123' ),
 265      ),
 266      array(
 267          'id'      => 'day-name',
 268          'label'   => __( 'Day and name' ),
 269          'value'   => $index_php_prefix . '/%year%/%monthnum%/%day%/%postname%/',
 270          'example' => $url_base . '/' . gmdate( 'Y/m/d' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
 271      ),
 272      array(
 273          'id'      => 'month-name',
 274          'label'   => __( 'Month and name' ),
 275          'value'   => $index_php_prefix . '/%year%/%monthnum%/%postname%/',
 276          'example' => $url_base . '/' . gmdate( 'Y/m' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
 277      ),
 278      array(
 279          'id'      => 'numeric',
 280          'label'   => __( 'Numeric' ),
 281          'value'   => $index_php_prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/%post_id%',
 282          'example' => $url_base . '/' . _x( 'archives', 'sample permalink base' ) . '/123',
 283      ),
 284      array(
 285          'id'      => 'post-name',
 286          'label'   => __( 'Post name' ),
 287          'value'   => $index_php_prefix . '/%postname%/',
 288          'example' => $url_base . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
 289      ),
 290  );
 291  
 292  $default_structure_values = wp_list_pluck( $default_structures, 'value' );
 293  
 294  $available_tags = array(
 295      /* translators: %s: Permalink structure tag. */
 296      'year'     => __( '%s (The year of the post, four digits, for example 2004.)' ),
 297      /* translators: %s: Permalink structure tag. */
 298      'monthnum' => __( '%s (Month of the year, for example 05.)' ),
 299      /* translators: %s: Permalink structure tag. */
 300      'day'      => __( '%s (Day of the month, for example 28.)' ),
 301      /* translators: %s: Permalink structure tag. */
 302      'hour'     => __( '%s (Hour of the day, for example 15.)' ),
 303      /* translators: %s: Permalink structure tag. */
 304      'minute'   => __( '%s (Minute of the hour, for example 43.)' ),
 305      /* translators: %s: Permalink structure tag. */
 306      'second'   => __( '%s (Second of the minute, for example 33.)' ),
 307      /* translators: %s: Permalink structure tag. */
 308      'post_id'  => __( '%s (The unique ID of the post, for example 423.)' ),
 309      /* translators: %s: Permalink structure tag. */
 310      'postname' => __( '%s (The sanitized post title (slug).)' ),
 311      /* translators: %s: Permalink structure tag. */
 312      'category' => __( '%s (Category slug. Nested sub-categories appear as nested directories in the URL.)' ),
 313      /* translators: %s: Permalink structure tag. */
 314      'author'   => __( '%s (A sanitized version of the author name.)' ),
 315  );
 316  
 317  /**
 318   * Filters the list of available permalink structure tags on the Permalinks settings page.
 319   *
 320   * @since 4.9.0
 321   *
 322   * @param string[] $available_tags An array of key => value pairs of available permalink structure tags.
 323   */
 324  $available_tags = apply_filters( 'available_permalink_structure_tags', $available_tags );
 325  
 326  /* translators: %s: Permalink structure tag. */
 327  $tag_added = __( '%s added to permalink structure' );
 328  /* translators: %s: Permalink structure tag. */
 329  $tag_removed = __( '%s removed from permalink structure' );
 330  /* translators: %s: Permalink structure tag. */
 331  $tag_already_used = __( '%s (already used in permalink structure)' );
 332  ?>
 333  <h2 id="wp-settings-section-common-settings" class="title"><?php _e( 'Common Settings' ); ?></h2>
 334  <p>
 335  <?php
 336  printf(
 337      /* translators: %s: %postname% */
 338      __( 'Select the permalink structure for your website. Including the %s tag makes links easy to understand, and can help your posts rank higher in search engines.' ),
 339      '<code>%postname%</code>'
 340  );
 341  ?>
 342  </p>
 343  <table class="form-table permalink-structure" role="presentation">
 344  <tbody>
 345  <?php $permalink_structure_title = __( 'Permalink structure' ); ?>
 346  <tr>
 347      <th scope="row"><?php echo $permalink_structure_title; ?></th>
 348      <td>
 349          <fieldset class="structure-selection">
 350              <legend class="screen-reader-text"><?php echo $permalink_structure_title; ?></legend>
 351              <?php foreach ( $default_structures as $input ) : ?>
 352              <div class="row">
 353                  <input id="permalink-input-<?php echo esc_attr( $input['id'] ); ?>"
 354                      name="selection" aria-describedby="permalink-<?php echo esc_attr( $input['id'] ); ?>"
 355                      type="radio" value="<?php echo esc_attr( $input['value'] ); ?>"
 356                      <?php checked( $input['value'], $permalink_structure ); ?>
 357                  />
 358                  <div>
 359                      <label for="permalink-input-<?php echo esc_attr( $input['id'] ); ?>">
 360                          <?php echo esc_html( $input['label'] ); ?>
 361                      </label>
 362                      <p>
 363                          <code id="permalink-<?php echo esc_attr( $input['id'] ); ?>">
 364                              <?php echo esc_html( $input['example'] ); ?>
 365                          </code>
 366                      </p>
 367                  </div>
 368              </div><!-- .row -->
 369              <?php endforeach; ?>
 370  
 371              <div class="row">
 372                  <input id="custom_selection"
 373                      name="selection" type="radio" value="custom"
 374                      <?php checked( ! in_array( $permalink_structure, $default_structure_values, true ) ); ?>
 375                  />
 376                  <div>
 377                      <label for="custom_selection"><?php _e( 'Custom Structure' ); ?></label>
 378                      <p>
 379                          <label for="permalink_structure" class="screen-reader-text">
 380                              <?php
 381                              /* translators: Hidden accessibility text. */
 382                              _e( 'Customize permalink structure by selecting available tags' );
 383                              ?>
 384                          </label>
 385                          <span class="code">
 386                              <code id="permalink-custom"><?php echo esc_url( $url_base ); ?></code>
 387                              <input name="permalink_structure" id="permalink_structure"
 388                                  type="text" value="<?php echo esc_attr( $permalink_structure ); ?>"
 389                                  aria-describedby="permalink-custom" class="regular-text code"
 390                              />
 391                          </span>
 392                      </p>
 393  
 394                      <div class="available-structure-tags hide-if-no-js">
 395                          <div id="custom_selection_updated" aria-live="assertive" class="screen-reader-text"></div>
 396                          <?php if ( ! empty( $available_tags ) ) : ?>
 397                          <fieldset>
 398                              <legend><?php _e( 'Available tags:' ); ?></legend>
 399                              <ul role="list">
 400                              <?php foreach ( $available_tags as $tag => $explanation ) : ?>
 401                                  <li>
 402                                      <button type="button"
 403                                          class="button button-secondary"
 404                                          aria-label="<?php echo esc_attr( sprintf( $explanation, $tag ) ); ?>"
 405                                          data-added="<?php echo esc_attr( sprintf( $tag_added, $tag ) ); ?>"
 406                                          data-removed="<?php echo esc_attr( sprintf( $tag_removed, $tag ) ); ?>"
 407                                          data-used="<?php echo esc_attr( sprintf( $tag_already_used, $tag ) ); ?>">
 408                                          <?php echo '%' . esc_html( $tag ) . '%'; ?>
 409                                      </button>
 410                                  </li>
 411                              <?php endforeach; ?>
 412                              </ul>
 413                          </fieldset>
 414                          <?php endif; ?>
 415                      </div><!-- .available-structure-tags -->
 416                  </div>
 417              </div><!-- .row -->
 418          </fieldset><!-- .structure-selection -->
 419      </td>
 420  </tr>
 421  </tbody>
 422  </table>
 423  
 424  <h2 id="wp-settings-section-optional" class="title"><?php _e( 'Optional' ); ?></h2>
 425  <p class="permalink-structure-optional-description">
 426  <?php
 427  printf(
 428      /* translators: %s: Placeholder that must come at the start of the URL. */
 429      __( 'If you like, you may enter custom structures for your category and tag URLs here. For example, using <code>topics</code> as your category base would make your category links like <code>%s/topics/uncategorized/</code>. If you leave these blank the defaults will be used.' ),
 430      $url_base
 431  );
 432  ?>
 433  </p>
 434  
 435  <table class="form-table" role="presentation">
 436      <tr>
 437          <th>
 438              <label for="category_base">
 439                  <?php /* translators: Prefix for category permalinks. */ _e( 'Category base' ); ?>
 440              </label>
 441          </th>
 442          <td>
 443          <?php if ( '' === $blog_prefix ) : ?>
 444              <input name="category_base" id="category_base" type="text"
 445                  value="<?php echo esc_attr( $category_base ); ?>" class="regular-text code"
 446              />
 447          <?php else : ?>
 448              <span class="code permalink-structure-has-blog-prefix">
 449                  <code class="no-break"><?php echo $blog_prefix; ?></code>
 450                  <input name="category_base" id="category_base" type="text"
 451                      value="<?php echo esc_attr( $category_base ); ?>" class="regular-text code"
 452                  />
 453              </span>
 454          <?php endif; ?>
 455          </td>
 456      </tr>
 457      <tr>
 458          <th>
 459              <label for="tag_base"><?php _e( 'Tag base' ); ?></label>
 460          </th>
 461          <td>
 462          <?php if ( '' === $blog_prefix ) : ?>
 463              <input name="tag_base" id="tag_base" type="text"
 464                  value="<?php echo esc_attr( $tag_base ); ?>" class="regular-text code"
 465              />
 466          <?php else : ?>
 467              <span class="code permalink-structure-has-blog-prefix">
 468                  <code class="no-break"><?php echo $blog_prefix; ?></code>
 469                  <input name="tag_base" id="tag_base" type="text"
 470                      value="<?php echo esc_attr( $tag_base ); ?>" class="regular-text code"
 471                  />
 472              </span>
 473          <?php endif; ?>
 474          </td>
 475      </tr>
 476      <?php if ( wp_is_random_content_redirect_enabled() ) : ?>
 477      <tr>
 478          <th>
 479              <label for="wp_random_base">
 480                  <?php _e( 'Random base' ); ?>
 481              </label>
 482          </th>
 483          <td>
 484          <?php if ( '' === $blog_prefix ) : ?>
 485              <input name="wp_random_base" id="wp_random_base" type="text"
 486                  value="<?php echo esc_attr( $random_base ); ?>" class="regular-text code"
 487              />
 488          <?php else : ?>
 489              <span class="code permalink-structure-has-blog-prefix">
 490                  <code class="no-break"><?php echo $blog_prefix; ?></code>
 491                  <input name="wp_random_base" id="wp_random_base" type="text"
 492                      value="<?php echo esc_attr( $random_base ); ?>" class="regular-text code"
 493                  />
 494              </span>
 495          <?php endif; ?>
 496          </td>
 497      </tr>
 498      <?php endif; ?>
 499      <?php do_settings_fields( 'permalink', 'optional' ); ?>
 500  </table>
 501  
 502  <?php do_settings_sections( 'permalink' ); ?>
 503  
 504  <?php submit_button(); ?>
 505  </form>
 506  
 507  <?php if ( ! is_multisite() ) : ?>
 508      <?php
 509      if ( $iis7_permalinks ) :
 510          if ( isset( $_POST['submit'] ) && $permalink_structure && ! $using_index_permalinks && ! $writable ) :
 511              if ( file_exists( $home_path . 'web.config' ) ) :
 512                  ?>
 513                  <p id="iis-description-a">
 514                  <?php
 515                  printf(
 516                      /* translators: 1: web.config, 2: Documentation URL, 3: Ctrl + A, 4: ⌘ + A, 5: Element code. */
 517                      __( '<strong>Error:</strong> Your %1$s file is not <a href="%2$s">writable</a>, so updating it automatically was not possible. This is the URL rewrite rule you should have in your %1$s file. Click in the field and press %3$s (or %4$s on Mac) to select all. Then insert this rule inside of the %5$s element in %1$s file.' ),
 518                      '<code>web.config</code>',
 519                      __( 'https://developer.wordpress.org/advanced-administration/server/file-permissions/' ),
 520                      '<kbd>Ctrl + A</kbd>',
 521                      '<kbd>⌘ + A</kbd>',
 522                      '<code>/&lt;configuration&gt;/&lt;system.webServer&gt;/&lt;rewrite&gt;/&lt;rules&gt;</code>'
 523                  );
 524                  ?>
 525                  </p>
 526                  <form action="options-permalink.php" method="post">
 527                      <?php wp_nonce_field( 'update-permalink' ); ?>
 528                      <p>
 529                          <label for="rules"><?php _e( 'Rewrite rules:' ); ?></label><br />
 530                          <textarea rows="9" class="large-text readonly"
 531                              name="rules" id="rules" readonly="readonly"
 532                              aria-describedby="iis-description-a"
 533                          ><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules() ); ?></textarea>
 534                      </p>
 535                  </form>
 536                  <p>
 537                  <?php
 538                  printf(
 539                      /* translators: %s: web.config */
 540                      __( 'If you temporarily make your %s file writable to generate rewrite rules automatically, do not forget to revert the permissions after the rule has been saved.' ),
 541                      '<code>web.config</code>'
 542                  );
 543                  ?>
 544                  </p>
 545              <?php else : ?>
 546                  <p id="iis-description-b">
 547                  <?php
 548                  printf(
 549                      /* translators: 1: Documentation URL, 2: web.config, 3: Ctrl + A, 4: ⌘ + A */
 550                      __( '<strong>Error:</strong> The root directory of your site is not <a href="%1$s">writable</a>, so creating a file automatically was not possible. This is the URL rewrite rule you should have in your %2$s file. Create a new file called %2$s in the root directory of your site. Click in the field and press %3$s (or %4$s on Mac) to select all. Then insert this code into the %2$s file.' ),
 551                      __( 'https://developer.wordpress.org/advanced-administration/server/file-permissions/' ),
 552                      '<code>web.config</code>',
 553                      '<kbd>Ctrl + A</kbd>',
 554                      '<kbd>⌘ + A</kbd>'
 555                  );
 556                  ?>
 557                  </p>
 558                  <form action="options-permalink.php" method="post">
 559                      <?php wp_nonce_field( 'update-permalink' ); ?>
 560                      <p>
 561                          <label for="rules"><?php _e( 'Rewrite rules:' ); ?></label><br />
 562                          <textarea rows="18" class="large-text readonly"
 563                              name="rules" id="rules" readonly="readonly"
 564                              aria-describedby="iis-description-b"
 565                          ><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules( true ) ); ?></textarea>
 566                      </p>
 567                  </form>
 568                  <p>
 569                  <?php
 570                  printf(
 571                      /* translators: %s: web.config */
 572                      __( 'If you temporarily make your site&#8217;s root directory writable to generate the %s file automatically, do not forget to revert the permissions after the file has been created.' ),
 573                      '<code>web.config</code>'
 574                  );
 575                  ?>
 576                  </p>
 577              <?php endif; // End if 'web.config' exists. ?>
 578          <?php endif; // End if $_POST['submit'] && ! $writable. ?>
 579      <?php else : ?>
 580          <?php if ( $permalink_structure && ! $using_index_permalinks && ! $writable && $htaccess_update_required ) : ?>
 581              <p id="htaccess-description">
 582              <?php
 583              printf(
 584                  /* translators: 1: .htaccess, 2: Documentation URL, 3: Ctrl + A, 4: ⌘ + A */
 585                  __( '<strong>Error:</strong> Your %1$s file is not <a href="%2$s">writable</a>, so updating it automatically was not possible. These are the mod_rewrite rules you should have in your %1$s file. Click in the field and press %3$s (or %4$s on Mac) to select all.' ),
 586                  '<code>.htaccess</code>',
 587                  __( 'https://developer.wordpress.org/advanced-administration/server/file-permissions/' ),
 588                  '<kbd>Ctrl + A</kbd>',
 589                  '<kbd>⌘ + A</kbd>'
 590              );
 591              ?>
 592              </p>
 593              <form action="options-permalink.php" method="post">
 594                  <?php wp_nonce_field( 'update-permalink' ); ?>
 595                  <p>
 596                      <label for="rules"><?php _e( 'Rewrite rules:' ); ?></label><br />
 597                      <textarea rows="8" class="large-text readonly"
 598                          name="rules" id="rules" readonly="readonly"
 599                          aria-describedby="htaccess-description"
 600                      ><?php echo esc_textarea( $wp_rewrite->mod_rewrite_rules() ); ?></textarea>
 601                  </p>
 602              </form>
 603          <?php endif; // End if ! $writable && $htaccess_update_required. ?>
 604      <?php endif; // End if $iis7_permalinks. ?>
 605  <?php endif; // End if ! is_multisite(). ?>
 606  
 607  </div><!-- .wrap -->
 608  
 609  <?php require_once  ABSPATH . 'wp-admin/admin-footer.php'; ?>


Generated : Sat Oct 24 08:20:34 2026 Cross-referenced by PHPXref