Make WordPress Core

Ticket #6481: 6481.16.diff

File 6481.16.diff, 3.0 KB (added by ericlewis, 10 years ago)
  • wp-admin/includes/upgrade.php

    diff --git wp-admin/includes/upgrade.php wp-admin/includes/upgrade.php
    index 1c0f9f7..2009b32 100644
    endif; 
    264264
    265265if ( ! function_exists( 'wp_install_maybe_enable_pretty_permalinks' ) ) :
    266266/**
    267  * Enable pretty permalinks if available.
     267 * Enable pretty permalinks.
    268268 *
    269  * This function will enable pretty permalinks if it can verify they work.
    270  * If all pretty permalinks formats fail to work, WordPress will fall back
    271  * to ugly permalinks by setting an empty permalink structure.
     269 * If after enabling pretty permalinks don't work, fallback to query-string permalinks.
    272270 *
    273271 * @since 4.2.0
    274272 *
    if ( ! function_exists( 'wp_install_maybe_enable_pretty_permalinks' ) ) : 
    277275function wp_install_maybe_enable_pretty_permalinks() {
    278276        global $wp_rewrite;
    279277
    280         // Bail if we alredy have permalinks enabled (Multisite)
     278        // Bail if a permalink structure is already enabled.
    281279        if ( get_option( 'permalink_structure' ) ) {
    282280                return;
    283281        }
    284282
    285283        /*
    286          * The Permalink structures which WordPress should attempt to use.
     284         * The Permalink structures to attempt.
     285         *
    287286         * The first is designed for mod_rewrite or nginx rewriting.
    288          * The second is PATHINFO based permalinks offered under configurations
    289          * without rewrites enabled.
     287         *
     288         * The second is PATHINFO-based permalinks for web server configurations
     289         * without a true rewrite module enabled.
    290290         */
    291291        $permalink_structures = array(
    292292                '/%year%/%monthnum%/%day%/%postname%/',
    function wp_install_maybe_enable_pretty_permalinks() { 
    294294        );
    295295
    296296        foreach ( (array) $permalink_structures as $permalink_structure ) {
    297                 // Set the desired Permalink structure to try
    298297                $wp_rewrite->set_permalink_structure( $permalink_structure );
    299298
    300299                /*
    function wp_install_maybe_enable_pretty_permalinks() { 
    303302                 */
    304303                $wp_rewrite->flush_rules( true );
    305304
    306                 // Test against a real WordPress Post, or if none were created, a Page URI
     305                // Test against a real WordPress Post, or if none were created, a random 404 page.
    307306                $test_url = get_permalink( 1 );
    308307                if ( ! $test_url ) {
    309308                        $test_url = home_url( '/wordpress-check-for-rewrites/' );
    310309                }
    311310
    312311                /*
    313                  * Send a HEAD request to a random page on the site, and check whether
     312                 * Send a request to the site, and check whether
    314313                 * the 'x-pingback' header is returned as expected.
     314                 *
     315                 * Uses wp_remote_get() instead of wp_remote_head() because web servers
     316                 * can block head requests.
    315317                 */
    316318                $response          = wp_remote_get( $test_url, array( 'timeout' => 5 ) );
    317319                $x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' );
    function wp_install_maybe_enable_pretty_permalinks() { 
    323325        }
    324326
    325327        /*
    326          * If it makes it this far, Pretty Permalinks failed to activate.
    327          * Reset and allow the user to select it themselves.
     328         * If it makes it this far, pretty permalinks failed.
     329         * Fallback to query-string permalinks.
    328330         */
    329331        $wp_rewrite->set_permalink_structure( '' );
    330332        $wp_rewrite->flush_rules( true );