Make WordPress Core


Ignore:
Timestamp:
07/16/2022 04:18:37 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Improve readability of wp-admin/options-permalink.php.

Includes:

  • Wrapping longer lines and reducing alignment levels to fit more data on the screen.
  • Restoring esc_attr() for input values, which may include translatable parts.
  • Adding comments to closing </div> tags and PHP endif statements.
  • Reducing the context switching between HTML and PHP.
  • Balancing PHP conditionals to better reflect the structure.
  • Removing repeated function calls to improve performance.
  • Renaming some variables for clarity and consistency.

Follow-up to [470], [601], [963], [1227], [1664], [2746], [3029], [6976], [7230], [11350], [14051], [14553], [21891], [34691], [34749], [37747], [38066], [41182], [41986], [42343], [43571], [48710], [50830], [51892], [53706].

See #55647.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/options-permalink.php

    r53706 r53710  
    5858
    5959$help_sidebar_content = '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    60                                                 '<p>' . __( '<a href="https://wordpress.org/support/article/settings-permalinks-screen/">Documentation on Permalinks Settings</a>' ) . '</p>' .
    61                                                 '<p>' . __( '<a href="https://wordpress.org/support/article/using-permalinks/">Documentation on Using Permalinks</a>' ) . '</p>';
     60        '<p>' . __( '<a href="https://wordpress.org/support/article/settings-permalinks-screen/">Documentation on Permalinks Settings</a>' ) . '</p>' .
     61        '<p>' . __( '<a href="https://wordpress.org/support/article/using-permalinks/">Documentation on Using Permalinks</a>' ) . '</p>';
    6262
    6363if ( $is_nginx ) {
     
    7474$permalink_structure = get_option( 'permalink_structure' );
    7575
    76 $prefix      = '';
    77 $blog_prefix = '';
     76$index_php_prefix = '';
     77$blog_prefix      = '';
     78
    7879if ( ! got_url_rewrite() ) {
    79         $prefix = '/index.php';
     80        $index_php_prefix = '/index.php';
    8081}
    8182
     
    8687 * base prefix, WordPress core can no longer account for the possible collision.
    8788 */
    88 if ( is_multisite() && ! is_subdomain_install() && is_main_site() && 0 === strpos( $permalink_structure, '/blog/' ) ) {
     89if ( is_multisite() && ! is_subdomain_install() && is_main_site()
     90        && 0 === strpos( $permalink_structure, '/blog/' )
     91) {
    8992        $blog_prefix = '/blog';
    9093}
     
    108111                if ( ! empty( $permalink_structure ) ) {
    109112                        $permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );
    110                         if ( $prefix && $blog_prefix ) {
    111                                 $permalink_structure = $prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure );
     113
     114                        if ( $index_php_prefix && $blog_prefix ) {
     115                                $permalink_structure = $index_php_prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure );
    112116                        } else {
    113117                                $permalink_structure = $blog_prefix . $permalink_structure;
     
    144148
    145149if ( $iis7_permalinks ) {
    146         if ( ( ! file_exists( $home_path . 'web.config' ) && win_is_writable( $home_path ) ) || win_is_writable( $home_path . 'web.config' ) ) {
     150        if ( ( ! file_exists( $home_path . 'web.config' )
     151                && win_is_writable( $home_path ) ) || win_is_writable( $home_path . 'web.config' )
     152        ) {
    147153                $writable = true;
    148154        } else {
     
    152158        $writable = false;
    153159} else {
    154         if ( ( ! file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) {
     160        if ( ( ! file_exists( $home_path . '.htaccess' )
     161                && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' )
     162        ) {
    155163                $writable = true;
    156164        } else {
     
    212220<?php wp_nonce_field( 'update-permalink' ); ?>
    213221
    214         <p>
    215         <?php
    216                 printf(
    217                         /* translators: %s: Documentation URL. */
    218                         __( '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.' ),
    219                         __( 'https://wordpress.org/support/article/using-permalinks/' )
    220                 );
    221                 ?>
    222         </p>
    223 
     222<p>
    224223<?php
    225 if ( is_multisite() && ! is_subdomain_install() && is_main_site() && 0 === strpos( $permalink_structure, '/blog/' ) ) {
     224printf(
     225        /* translators: %s: Documentation URL. */
     226        __( '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.' ),
     227        __( 'https://wordpress.org/support/article/using-permalinks/' )
     228);
     229?>
     230</p>
     231
     232<?php
     233if ( is_multisite() && ! is_subdomain_install() && is_main_site()
     234        && 0 === strpos( $permalink_structure, '/blog/' )
     235) {
    226236        $permalink_structure = preg_replace( '|^/?blog|', '', $permalink_structure );
    227237        $category_base       = preg_replace( '|^/?blog|', '', $category_base );
     
    229239}
    230240
    231 $structures = array(
     241$default_structures = array(
    232242        0 => '',
    233         1 => $prefix . '/%year%/%monthnum%/%day%/%postname%/',
    234         2 => $prefix . '/%year%/%monthnum%/%postname%/',
    235         3 => $prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/%post_id%',
    236         4 => $prefix . '/%postname%/',
    237 );
    238 
    239 $inputs = array(
     243        1 => $index_php_prefix . '/%year%/%monthnum%/%day%/%postname%/',
     244        2 => $index_php_prefix . '/%year%/%monthnum%/%postname%/',
     245        3 => $index_php_prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/%post_id%',
     246        4 => $index_php_prefix . '/%postname%/',
     247);
     248
     249$url_base = get_option( 'home' ) . $blog_prefix . $index_php_prefix;
     250
     251$default_structure_inputs = array(
    240252        0 => array(
    241253                'id'      => 'plain',
    242254                'label'   => __( 'Plain' ),
    243255                'example' => get_option( 'home' ) . '/?p=123',
    244                 'value'   => $structures[0],
     256                'value'   => $default_structures[0],
    245257        ),
    246258        1 => array(
    247259                'id'      => 'day-name',
    248260                'label'   => __( 'Day and name' ),
    249                 'example' => get_option( 'home' ) . $blog_prefix . $prefix . '/' . gmdate( 'Y' ) . '/' . gmdate( 'm' ) . '/' . gmdate( 'd' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
    250                 'value'   => $structures[1],
     261                'example' => $url_base . '/' . gmdate( 'Y/m/d' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
     262                'value'   => $default_structures[1],
    251263        ),
    252264        2 => array(
    253265                'id'      => 'month-name',
    254266                'label'   => __( 'Month and name' ),
    255                 'example' => get_option( 'home' ) . $blog_prefix . $prefix . '/' . gmdate( 'Y' ) . '/' . gmdate( 'm' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
    256                 'value'   => $structures[2],
     267                'example' => $url_base . '/' . gmdate( 'Y/m' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
     268                'value'   => $default_structures[2],
    257269        ),
    258270        3 => array(
    259271                'id'      => 'day-numeric',
    260272                'label'   => __( 'Numeric' ),
    261                 'example' => get_option( 'home' ) . $blog_prefix . $prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/123',
    262                 'value'   => $structures[3],
     273                'example' => $url_base . '/' . _x( 'archives', 'sample permalink base' ) . '/123',
     274                'value'   => $default_structures[3],
    263275        ),
    264276        4 => array(
    265277                'id'      => 'post-name',
    266278                'label'   => __( 'Post name' ),
    267                 'example' => get_option( 'home' ) . $blog_prefix . $prefix . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
    268                 'value'   => $structures[4],
     279                'example' => $url_base . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
     280                'value'   => $default_structures[4],
    269281        ),
    270282);
     283
     284$available_tags = array(
     285        /* translators: %s: Permalink structure tag. */
     286        'year'     => __( '%s (The year of the post, four digits, for example 2004.)' ),
     287        /* translators: %s: Permalink structure tag. */
     288        'monthnum' => __( '%s (Month of the year, for example 05.)' ),
     289        /* translators: %s: Permalink structure tag. */
     290        'day'      => __( '%s (Day of the month, for example 28.)' ),
     291        /* translators: %s: Permalink structure tag. */
     292        'hour'     => __( '%s (Hour of the day, for example 15.)' ),
     293        /* translators: %s: Permalink structure tag. */
     294        'minute'   => __( '%s (Minute of the hour, for example 43.)' ),
     295        /* translators: %s: Permalink structure tag. */
     296        'second'   => __( '%s (Second of the minute, for example 33.)' ),
     297        /* translators: %s: Permalink structure tag. */
     298        'post_id'  => __( '%s (The unique ID of the post, for example 423.)' ),
     299        /* translators: %s: Permalink structure tag. */
     300        'postname' => __( '%s (The sanitized post title (slug).)' ),
     301        /* translators: %s: Permalink structure tag. */
     302        'category' => __( '%s (Category slug. Nested sub-categories appear as nested directories in the URL.)' ),
     303        /* translators: %s: Permalink structure tag. */
     304        'author'   => __( '%s (A sanitized version of the author name.)' ),
     305);
     306
     307/**
     308 * Filters the list of available permalink structure tags on the Permalinks settings page.
     309 *
     310 * @since 4.9.0
     311 *
     312 * @param string[] $available_tags An array of key => value pairs of available permalink structure tags.
     313 */
     314$available_tags = apply_filters( 'available_permalink_structure_tags', $available_tags );
     315
     316/* translators: %s: Permalink structure tag. */
     317$tag_added = __( '%s added to permalink structure' );
     318
     319/* translators: %s: Permalink structure tag. */
     320$tag_already_used = __( '%s (already used in permalink structure)' );
    271321?>
    272322<h2 class="title"><?php _e( 'Common Settings' ); ?></h2>
    273323<table class="form-table permalink-structure" role="presentation">
    274         <tbody>
    275                 <tr>
    276                         <th scope="row"><?php _e( 'Permalink structure' ); ?></th>
    277                         <td>
    278                                 <fieldset class="structure-selection">
    279                                         <legend class="screen-reader-text"><?php _e( 'Permalink structure' ); ?></legend>
    280                                         <?php
    281                                         foreach ( $inputs as $structure_id => $structure_values ) {
    282                                                 $input_markup  = '<div class="row">';
    283                                                 $input_markup .= '<input id="permalink-input-' . $structure_values['id'] . '" name="selection" aria-describedby="permalink-' . $structure_values['id'] . '" type="radio" value="' . $structure_values['value'] . '" ' . checked( $structure_values['value'], $permalink_structure, false ) . ' />';
    284                                                 $input_markup .= '<div><label for="permalink-input-' . $structure_values['id'] . '">' . $structure_values['label'] . '</label>';
    285                                                 $input_markup .= '<p><code id="permalink-' . $structure_values['id'] . '">' . $structure_values['example'] . '</code></p>';
    286                                                 $input_markup .= '</div>';
    287                                                 $input_markup .= '</div>';
    288 
    289                                                 echo $input_markup;
    290                                         }
    291                                         ?>
    292                                         <div class="row">
    293                                                 <input id="custom_selection" name="selection" type="radio" value="custom" <?php checked( ! in_array( $permalink_structure, $structures, true ) ); ?> /><div><label for="custom_selection"><?php _e( 'Custom Structure' ); ?></label>
    294                                                 <p><label for="permalink_structure" class="screen-reader-text"><?php _e( 'Customize permalink structure by selecting available tags' ); ?></label><span class="code"><code id="permalink-custom"><?php echo get_option( 'home' ) . $blog_prefix; ?></code><input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr( $permalink_structure ); ?>" aria-describedby="permalink-custom" class="regular-text code" /></span></p>
    295                                                         <div class="available-structure-tags hide-if-no-js">
    296                                                                 <div id="custom_selection_updated" aria-live="assertive" class="screen-reader-text"></div>
    297                                                                 <?php
    298                                                                 $available_tags = array(
    299                                                                         /* translators: %s: Permalink structure tag. */
    300                                                                         'year'     => __( '%s (The year of the post, four digits, for example 2004.)' ),
    301                                                                         /* translators: %s: Permalink structure tag. */
    302                                                                         'monthnum' => __( '%s (Month of the year, for example 05.)' ),
    303                                                                         /* translators: %s: Permalink structure tag. */
    304                                                                         'day'      => __( '%s (Day of the month, for example 28.)' ),
    305                                                                         /* translators: %s: Permalink structure tag. */
    306                                                                         'hour'     => __( '%s (Hour of the day, for example 15.)' ),
    307                                                                         /* translators: %s: Permalink structure tag. */
    308                                                                         'minute'   => __( '%s (Minute of the hour, for example 43.)' ),
    309                                                                         /* translators: %s: Permalink structure tag. */
    310                                                                         'second'   => __( '%s (Second of the minute, for example 33.)' ),
    311                                                                         /* translators: %s: Permalink structure tag. */
    312                                                                         'post_id'  => __( '%s (The unique ID of the post, for example 423.)' ),
    313                                                                         /* translators: %s: Permalink structure tag. */
    314                                                                         'postname' => __( '%s (The sanitized post title (slug).)' ),
    315                                                                         /* translators: %s: Permalink structure tag. */
    316                                                                         'category' => __( '%s (Category slug. Nested sub-categories appear as nested directories in the URL.)' ),
    317                                                                         /* translators: %s: Permalink structure tag. */
    318                                                                         'author'   => __( '%s (A sanitized version of the author name.)' ),
    319                                                                 );
    320 
    321                                                                 /**
    322                                                                  * Filters the list of available permalink structure tags on the Permalinks settings page.
    323                                                                  *
    324                                                                  * @since 4.9.0
    325                                                                  *
    326                                                                  * @param string[] $available_tags An array of key => value pairs of available permalink structure tags.
    327                                                                  */
    328                                                                 $available_tags = apply_filters( 'available_permalink_structure_tags', $available_tags );
    329 
    330                                                                 /* translators: %s: Permalink structure tag. */
    331                                                                 $structure_tag_added = __( '%s added to permalink structure' );
    332 
    333                                                                 /* translators: %s: Permalink structure tag. */
    334                                                                 $structure_tag_already_used = __( '%s (already used in permalink structure)' );
    335 
    336                                                                 if ( ! empty( $available_tags ) ) :
    337                                                                         ?>
    338                                                                         <fieldset>
    339                                                                                 <legend><?php _e( 'Available tags:' ); ?></legend>
    340                                                                                 <ul role="list">
    341                                                                                         <?php foreach ( $available_tags as $tag => $explanation ) : ?>
    342                                                                                                 <li>
    343                                                                                                         <button type="button"
    344                                                                                                                         class="button button-secondary"
    345                                                                                                                         aria-label="<?php echo esc_attr( sprintf( $explanation, $tag ) ); ?>"
    346                                                                                                                         data-added="<?php echo esc_attr( sprintf( $structure_tag_added, $tag ) ); ?>"
    347                                                                                                                         data-used="<?php echo esc_attr( sprintf( $structure_tag_already_used, $tag ) ); ?>">
    348                                                                                                                 <?php echo '%' . $tag . '%'; ?>
    349                                                                                                         </button>
    350                                                                                                 </li>
    351                                                                                         <?php endforeach; ?>
    352                                                                                 </ul>
    353                                                                         </fieldset>
    354                                                                 <?php endif; ?>
    355                                                         </div>
    356                                                 </div>
    357                                         </div>
    358                                 </fieldset>
    359                         </td>
    360                 </tr>
    361         </tbody>
     324<tbody>
     325<tr>
     326        <th scope="row"><?php _e( 'Permalink structure' ); ?></th>
     327        <td>
     328                <fieldset class="structure-selection">
     329                        <legend class="screen-reader-text"><?php _e( 'Permalink structure' ); ?></legend>
     330                        <?php foreach ( $default_structure_inputs as $input ) : ?>
     331                        <div class="row">
     332                                <input id="permalink-input-<?php echo $input['id']; ?>"
     333                                        name="selection" aria-describedby="permalink-<?php echo $input['id']; ?>"
     334                                        type="radio" value="<?php echo esc_attr( $input['value'] ); ?>"
     335                                        <?php checked( $input['value'], $permalink_structure ); ?>
     336                                />
     337                                <div>
     338                                        <label for="permalink-input-<?php echo $input['id']; ?>"><?php echo $input['label']; ?></label>
     339                                        <p>
     340                                                <code id="permalink-<?php echo $input['id']; ?>"><?php echo $input['example']; ?></code>
     341                                        </p>
     342                                </div>
     343                        </div><!-- .row -->
     344                        <?php endforeach; ?>
     345
     346                        <div class="row">
     347                                <input id="custom_selection"
     348                                        name="selection" type="radio" value="custom"
     349                                        <?php checked( ! in_array( $permalink_structure, $default_structures, true ) ); ?>
     350                                />
     351                                <div>
     352                                        <label for="custom_selection"><?php _e( 'Custom Structure' ); ?></label>
     353                                        <p>
     354                                                <label for="permalink_structure" class="screen-reader-text">
     355                                                        <?php _e( 'Customize permalink structure by selecting available tags' ); ?>
     356                                                </label>
     357                                                <span class="code">
     358                                                        <code id="permalink-custom"><?php echo $url_base; ?></code>
     359                                                        <input name="permalink_structure" id="permalink_structure"
     360                                                                type="text" value="<?php echo esc_attr( $permalink_structure ); ?>"
     361                                                                aria-describedby="permalink-custom" class="regular-text code"
     362                                                        />
     363                                                </span>
     364                                        </p>
     365
     366                                        <div class="available-structure-tags hide-if-no-js">
     367                                                <div id="custom_selection_updated" aria-live="assertive" class="screen-reader-text"></div>
     368                                                <?php if ( ! empty( $available_tags ) ) : ?>
     369                                                <fieldset>
     370                                                        <legend><?php _e( 'Available tags:' ); ?></legend>
     371                                                        <ul role="list">
     372                                                        <?php foreach ( $available_tags as $tag => $explanation ) : ?>
     373                                                                <li>
     374                                                                        <button type="button"
     375                                                                                class="button button-secondary"
     376                                                                                aria-label="<?php echo esc_attr( sprintf( $explanation, $tag ) ); ?>"
     377                                                                                data-added="<?php echo esc_attr( sprintf( $tag_added, $tag ) ); ?>"
     378                                                                                data-used="<?php echo esc_attr( sprintf( $tag_already_used, $tag ) ); ?>">
     379                                                                                <?php echo '%' . $tag . '%'; ?>
     380                                                                        </button>
     381                                                                </li>
     382                                                        <?php endforeach; ?>
     383                                                        </ul>
     384                                                </fieldset>
     385                                                <?php endif; ?>
     386                                        </div><!-- .available-structure-tags -->
     387                                </div>
     388                        </div><!-- .row -->
     389                </fieldset><!-- .structure-selection -->
     390        </td>
     391</tr>
     392</tbody>
    362393</table>
    363394
     
    365396<p>
    366397<?php
    367 /* translators: %s: Placeholder that must come at the start of the URL. */
    368 printf( __( '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.' ), get_option( 'home' ) . $blog_prefix . $prefix );
     398printf(
     399        /* translators: %s: Placeholder that must come at the start of the URL. */
     400        __( '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.' ),
     401        $url_base
     402);
    369403?>
    370404</p>
     
    372406<table class="form-table" role="presentation">
    373407        <tr>
    374                 <th><label for="category_base"><?php /* translators: Prefix for category permalinks. */ _e( 'Category base' ); ?></label></th>
    375                 <td><?php echo $blog_prefix; ?> <input name="category_base" id="category_base" type="text" value="<?php echo esc_attr( $category_base ); ?>" class="regular-text code" /></td>
     408                <th>
     409                        <label for="category_base">
     410                                <?php /* translators: Prefix for category permalinks. */ _e( 'Category base' ); ?>
     411                        </label>
     412                </th>
     413                <td>
     414                        <?php echo $blog_prefix; ?>
     415                        <input name="category_base" id="category_base" type="text"
     416                                value="<?php echo esc_attr( $category_base ); ?>" class="regular-text code"
     417                        />
     418                </td>
    376419        </tr>
    377420        <tr>
    378                 <th><label for="tag_base"><?php _e( 'Tag base' ); ?></label></th>
    379                 <td><?php echo $blog_prefix; ?> <input name="tag_base" id="tag_base" type="text" value="<?php echo esc_attr( $tag_base ); ?>" class="regular-text code" /></td>
     421                <th>
     422                        <label for="tag_base"><?php _e( 'Tag base' ); ?></label>
     423                </th>
     424                <td>
     425                        <?php echo $blog_prefix; ?>
     426                        <input name="tag_base" id="tag_base" type="text"
     427                                value="<?php echo esc_attr( $tag_base ); ?>" class="regular-text code"
     428                        />
     429                </td>
    380430        </tr>
    381431        <?php do_settings_fields( 'permalink', 'optional' ); ?>
     
    386436<?php submit_button(); ?>
    387437</form>
    388 <?php if ( ! is_multisite() ) { ?>
     438
     439<?php if ( ! is_multisite() ) : ?>
    389440        <?php
    390441        if ( $iis7_permalinks ) :
     
    392443                        if ( file_exists( $home_path . 'web.config' ) ) :
    393444                                ?>
    394 <p id="iis-description-a">
     445                                <p id="iis-description-a">
    395446                                <?php
    396447                                printf(
     
    404455                                );
    405456                                ?>
    406 </p>
    407 <form action="options-permalink.php" method="post">
    408                                 <?php wp_nonce_field( 'update-permalink' ); ?>
    409         <p><label for="rules"><?php _e( 'Rewrite rules:' ); ?></label><br /><textarea rows="9" class="large-text readonly" name="rules" id="rules" readonly="readonly" aria-describedby="iis-description-a"><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules() ); ?></textarea></p>
    410 </form>
    411 <p>
     457                                </p>
     458                                <form action="options-permalink.php" method="post">
     459                                        <?php wp_nonce_field( 'update-permalink' ); ?>
     460                                        <p>
     461                                                <label for="rules"><?php _e( 'Rewrite rules:' ); ?></label><br />
     462                                                <textarea rows="9" class="large-text readonly"
     463                                                        name="rules" id="rules" readonly="readonly"
     464                                                        aria-describedby="iis-description-a"
     465                                                ><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules() ); ?></textarea>
     466                                        </p>
     467                                </form>
     468                                <p>
    412469                                <?php
    413470                                printf(
     
    417474                                );
    418475                                ?>
    419 </p>
    420                 <?php else : ?>
    421 <p id="iis-description-b">
     476                                </p>
     477                        <?php else : ?>
     478                                <p id="iis-description-b">
     479                                <?php
     480                                printf(
     481                                        /* translators: 1: Documentation URL, 2: web.config, 3: Ctrl + A, 4: ⌘ + A */
     482                                        __( '<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.' ),
     483                                        __( 'https://wordpress.org/support/article/changing-file-permissions/' ),
     484                                        '<code>web.config</code>',
     485                                        '<kbd>Ctrl + A</kbd>',
     486                                        '<kbd>⌘ + A</kbd>'
     487                                );
     488                                ?>
     489                                </p>
     490                                <form action="options-permalink.php" method="post">
     491                                        <?php wp_nonce_field( 'update-permalink' ); ?>
     492                                        <p>
     493                                                <label for="rules"><?php _e( 'Rewrite rules:' ); ?></label><br />
     494                                                <textarea rows="18" class="large-text readonly"
     495                                                        name="rules" id="rules" readonly="readonly"
     496                                                        aria-describedby="iis-description-b"
     497                                                ><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules( true ) ); ?></textarea>
     498                                        </p>
     499                                </form>
     500                                <p>
     501                                <?php
     502                                printf(
     503                                        /* translators: %s: web.config */
     504                                        __( '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.' ),
     505                                        '<code>web.config</code>'
     506                                );
     507                                ?>
     508                                </p>
     509                        <?php endif; // End if 'web.config' exists. ?>
     510                <?php endif; // End if $_POST['submit'] && ! $writable. ?>
     511        <?php else : ?>
     512                <?php if ( $permalink_structure && ! $using_index_permalinks && ! $writable && $htaccess_update_required ) : ?>
     513                        <p id="htaccess-description">
    422514                        <?php
    423515                        printf(
    424                                 /* translators: 1: Documentation URL, 2: web.config, 3: Ctrl + A, 4: ⌘ + A */
    425                                 __( '<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.' ),
     516                                /* translators: 1: .htaccess, 2: Documentation URL, 3: Ctrl + A, 4: ⌘ + A */
     517                                __( '<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.' ),
     518                                '<code>.htaccess</code>',
    426519                                __( 'https://wordpress.org/support/article/changing-file-permissions/' ),
    427                                 '<code>web.config</code>',
    428520                                '<kbd>Ctrl + A</kbd>',
    429521                                '<kbd>⌘ + A</kbd>'
    430522                        );
    431523                        ?>
    432 </p>
    433 <form action="options-permalink.php" method="post">
    434                         <?php wp_nonce_field( 'update-permalink' ); ?>
    435         <p><label for="rules"><?php _e( 'Rewrite rules:' ); ?></label><br /><textarea rows="18" class="large-text readonly" name="rules" id="rules" readonly="readonly" aria-describedby="iis-description-b"><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules( true ) ); ?></textarea></p>
    436 </form>
    437 <p>
    438                         <?php
    439                         printf(
    440                                 /* translators: %s: web.config */
    441                                 __( '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.' ),
    442                                 '<code>web.config</code>'
    443                         );
    444                         ?>
    445 </p>
    446                 <?php endif; ?>
    447         <?php endif; ?>
    448                 <?php
    449 else :
    450         if ( $permalink_structure && ! $using_index_permalinks && ! $writable && $htaccess_update_required ) :
    451                 ?>
    452 <p id="htaccess-description">
    453                 <?php
    454                 printf(
    455                         /* translators: 1: .htaccess, 2: Documentation URL, 3: Ctrl + A, 4: ⌘ + A */
    456                         __( '<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.' ),
    457                         '<code>.htaccess</code>',
    458                         __( 'https://wordpress.org/support/article/changing-file-permissions/' ),
    459                         '<kbd>Ctrl + A</kbd>',
    460                         '<kbd>⌘ + A</kbd>'
    461                 );
    462                 ?>
    463 </p>
    464 <form action="options-permalink.php" method="post">
    465                 <?php wp_nonce_field( 'update-permalink' ); ?>
    466         <p><label for="rules"><?php _e( 'Rewrite rules:' ); ?></label><br /><textarea rows="8" class="large-text readonly" name="rules" id="rules" readonly="readonly" aria-describedby="htaccess-description"><?php echo esc_textarea( $wp_rewrite->mod_rewrite_rules() ); ?></textarea></p>
    467 </form>
    468         <?php endif; ?>
    469 <?php endif; ?>
    470 <?php } // End if ! is_multisite(). ?>
    471 
    472 </div>
     524                        </p>
     525                        <form action="options-permalink.php" method="post">
     526                                <?php wp_nonce_field( 'update-permalink' ); ?>
     527                                <p>
     528                                        <label for="rules"><?php _e( 'Rewrite rules:' ); ?></label><br />
     529                                        <textarea rows="8" class="large-text readonly"
     530                                                name="rules" id="rules" readonly="readonly"
     531                                                aria-describedby="htaccess-description"
     532                                        ><?php echo esc_textarea( $wp_rewrite->mod_rewrite_rules() ); ?></textarea>
     533                                </p>
     534                        </form>
     535                <?php endif; // End if ! $writable && $htaccess_update_required. ?>
     536        <?php endif; // End if $iis7_permalinks. ?>
     537<?php endif; // End if ! is_multisite(). ?>
     538
     539</div><!-- .wrap -->
    473540
    474541<?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?>
Note: See TracChangeset for help on using the changeset viewer.