Make WordPress Core

Changeset 27549


Ignore:
Timestamp:
03/15/2014 04:34:23 AM (10 years ago)
Author:
nacin
Message:

Permalink Settings: Don't show "update your .htaccess now" if nothing needs to change.

props ldebrouwer, MikeHansenMe.
fixes #19268.

File:
1 edited

Legend:

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

    r27469 r27549  
    118118}
    119119
    120 $permalink_structure = get_option('permalink_structure');
    121 $category_base = get_option('category_base');
    122 $tag_base = get_option( 'tag_base' );
     120$permalink_structure = get_option( 'permalink_structure' );
     121$category_base       = get_option( 'category_base' );
     122$tag_base            = get_option( 'tag_base' );
     123$update_required     = false;
    123124
    124125if ( $iis7_permalinks ) {
     
    130131    $writable = false;
    131132} else {
    132     if ( ( ! file_exists($home_path . '.htaccess') && is_writable($home_path) ) || is_writable($home_path . '.htaccess') )
     133    if ( ( ! file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) {
    133134        $writable = true;
    134     else
     135    } else {
    135136        $writable = false;
     137        $existing_rules  = array_filter( extract_from_markers( $home_path . '.htaccess', 'WordPress' ) );
     138        $new_rules       = array_filter( explode( "\n", $wp_rewrite->mod_rewrite_rules() ) );
     139        $update_required = ( $new_rules !== $existing_rules );
     140    }
    136141}
    137142
     
    158163        _e('Permalink structure updated.');
    159164    } else {
    160         if ( $permalink_structure && ! $usingpi && ! $writable )
     165        if ( $permalink_structure && ! $usingpi && ! $writable && $update_required ) {
    161166            _e('You should update your .htaccess now.');
    162         else
     167        } else {
    163168            _e('Permalink structure updated.');
     169        }
    164170    }
    165171} else {
     
    274280    <?php endif; ?>
    275281<?php elseif ( ! $is_nginx ) :
    276     if ( $permalink_structure && ! $usingpi && ! $writable ) : ?>
     282    if ( $permalink_structure && ! $usingpi && ! $writable && $update_required ) : ?>
    277283<p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;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>
    278284<form action="options-permalink.php" method="post">
Note: See TracChangeset for help on using the changeset viewer.