Make WordPress Core

Ticket #18852: 18852.patch

File 18852.patch, 5.4 KB (added by johnbillion, 14 years ago)
  • wp-admin/includes/misc.php

     
    1919}
    2020
    2121/**
     22 * Returns whether or not the server supports URL rewriting.
     23 *
     24 * @since 3.3
     25 *
     26 * @return bool Whether the server supports URL rewriting
     27 */
     28function got_url_rewrite() {
     29        global $is_nginx;
     30        $got_url_rewrite = ( got_mod_rewrite() or iis7_supports_permalinks() or $is_nginx );
     31        return apply_filters('got_url_rewrite', $got_url_rewrite);
     32}
     33
     34/**
    2235 * {@internal Missing Short Description}}
    2336 *
    2437 * @since 1.5.0
  • wp-admin/options-permalink.php

     
    5959$iis7_permalinks = iis7_supports_permalinks();
    6060
    6161$prefix = $blog_prefix = '';
    62 if ( ! got_mod_rewrite() && ! $iis7_permalinks )
     62if ( ! got_url_rewrite() )
    6363        $prefix = '/index.php';
    6464if ( is_multisite() && !is_subdomain_install() && is_main_site() )
    6565        $blog_prefix = '/blog';
     
    109109                $writable = true;
    110110        else
    111111                $writable = false;
     112} else if ( $is_nginx ) {
     113        $writable = false;
    112114} else {
    113115        if ( ( ! file_exists($home_path . '.htaccess') && is_writable($home_path) ) || is_writable($home_path . '.htaccess') )
    114116                $writable = true;
     
    134136                        _e('Permalink structure updated. Remove write access on web.config file now!');
    135137                else
    136138                        _e('Permalink structure updated');
     139        } else if ( $is_nginx ) {
     140                _e('Permalink structure updated. Ensure your nginx.conf (or equivalent) contains the rewrite rules below.');
    137141        } else {
    138142                if ( $permalink_structure && ! $usingpi && ! $writable )
    139143                        _e('You should update your .htaccess now.');
     
    207211</table>
    208212
    209213<h3><?php _e('Optional'); ?></h3>
    210 <?php if ( $is_apache || $iis7_permalinks ) : ?>
     214<?php if ( $is_apache || $iis7_permalinks || $is_nginx ) : ?>
    211215        <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <kbd>topics</kbd> as your category base would make your category links like <code>http://example.org/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p>
    212216<?php else : ?>
    213217        <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>topics</code> as your category base would make your category links like <code>http://example.org/index.php/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p>
     
    248252<p><?php _e('If you temporarily make your site&#8217;s root directory writable for us to generate the <code>web.config</code> file automatically, do not forget to revert the permissions after the file has been created.')  ?></p>
    249253                <?php endif; ?>
    250254        <?php endif; ?>
     255<?php elseif ( $is_nginx ) :
     256        if ( $permalink_structure && ! $usingpi ) : ?>
     257<p><?php _e('These are the rewrite rules you should have in your <code>nginx.conf</code> (or equivalent) file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
     258<form action="options-permalink.php" method="post">
     259<?php wp_nonce_field('update-permalink') ?>
     260        <p><textarea rows="6" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->nginx_url_rewrite_rules() ); ?></textarea></p>
     261</form>
     262        <?php endif; ?>
    251263<?php else :
    252264        if ( $permalink_structure && ! $usingpi && ! $writable ) : ?>
    253265<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>
  • wp-includes/rewrite.php

     
    17651765        }
    17661766
    17671767        /**
     1768         * Retrieve Nginx formatted rewrite rules.
     1769         *
     1770         * @since 3.3.0
     1771         * @access public
     1772         *
     1773         * @return string
     1774         */
     1775        function nginx_url_rewrite_rules() {
     1776                if ( ! $this->using_permalinks() )
     1777                        return '';
     1778
     1779                $rules = "location / {\n";
     1780                $rules .= "\t" . 'if ( -f $request_filename ) {' . "\n";
     1781                $rules .= "\t\tbreak;\n";
     1782                $rules .= "\t}\n";
     1783                $rules .= "\t" . 'try_files $uri $uri/ /index.php?$args;' . "\n";
     1784                $rules .= "}\n";
     1785
     1786                $rules = apply_filters('nginx_rewrite_rules', $rules);
     1787
     1788                return $rules;
     1789        }
     1790
     1791        /**
    17681792         * Add a straight rewrite rule.
    17691793         *
    17701794         * Any value in the $after parameter that isn't 'bottom' will be placed at
  • wp-includes/vars.php

     
    8383$is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false);
    8484
    8585/**
     86 * Whether the server software is Nginx or something else
     87 * @global bool $is_nginx
     88 */
     89$is_nginx = (strpos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false);
     90
     91/**
    8692 * Whether the server software is IIS or something else
    8793 * @global bool $is_IIS
    8894 */