mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
More concise documentation for wp_install_maybe_enable_pretty_permalinks()
See #6481. Props ericlewis. Built from https://develop.svn.wordpress.org/trunk@31160 git-svn-id: http://core.svn.wordpress.org/trunk@31141 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a114d0929b
commit
af92025162
@ -263,11 +263,9 @@ As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to d
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Enable pretty permalinks if available.
|
||||
* Enable pretty permalinks.
|
||||
*
|
||||
* This function will enable pretty permalinks if it can verify they work.
|
||||
* If all pretty permalinks formats fail to work, WordPress will fall back
|
||||
* to ugly permalinks by setting an empty permalink structure.
|
||||
* If after enabling pretty permalinks don't work, fallback to query-string permalinks.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
@ -276,16 +274,18 @@ endif;
|
||||
function wp_install_maybe_enable_pretty_permalinks() {
|
||||
global $wp_rewrite;
|
||||
|
||||
// Bail if we alredy have permalinks enabled (Multisite)
|
||||
// Bail if a permalink structure is already enabled.
|
||||
if ( get_option( 'permalink_structure' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* The Permalink structures which WordPress should attempt to use.
|
||||
* The Permalink structures to attempt.
|
||||
*
|
||||
* The first is designed for mod_rewrite or nginx rewriting.
|
||||
* The second is PATHINFO based permalinks offered under configurations
|
||||
* without rewrites enabled.
|
||||
*
|
||||
* The second is PATHINFO-based permalinks for web server configurations
|
||||
* without a true rewrite module enabled.
|
||||
*/
|
||||
$permalink_structures = array(
|
||||
'/%year%/%monthnum%/%day%/%postname%/',
|
||||
@ -293,7 +293,6 @@ function wp_install_maybe_enable_pretty_permalinks() {
|
||||
);
|
||||
|
||||
foreach ( (array) $permalink_structures as $permalink_structure ) {
|
||||
// Set the desired Permalink structure to try
|
||||
$wp_rewrite->set_permalink_structure( $permalink_structure );
|
||||
|
||||
/*
|
||||
@ -302,15 +301,18 @@ function wp_install_maybe_enable_pretty_permalinks() {
|
||||
*/
|
||||
$wp_rewrite->flush_rules( true );
|
||||
|
||||
// Test against a real WordPress Post, or if none were created, a Page URI
|
||||
// Test against a real WordPress Post, or if none were created, a random 404 page.
|
||||
$test_url = get_permalink( 1 );
|
||||
if ( ! $test_url ) {
|
||||
$test_url = home_url( '/wordpress-check-for-rewrites/' );
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a HEAD request to a random page on the site, and check whether
|
||||
* Send a request to the site, and check whether
|
||||
* the 'x-pingback' header is returned as expected.
|
||||
*
|
||||
* Uses wp_remote_get() instead of wp_remote_head() because web servers
|
||||
* can block head requests.
|
||||
*/
|
||||
$response = wp_remote_get( $test_url, array( 'timeout' => 5 ) );
|
||||
$x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' );
|
||||
@ -322,8 +324,8 @@ function wp_install_maybe_enable_pretty_permalinks() {
|
||||
}
|
||||
|
||||
/*
|
||||
* If it makes it this far, Pretty Permalinks failed to activate.
|
||||
* Reset and allow the user to select it themselves.
|
||||
* If it makes it this far, pretty permalinks failed.
|
||||
* Fallback to query-string permalinks.
|
||||
*/
|
||||
$wp_rewrite->set_permalink_structure( '' );
|
||||
$wp_rewrite->flush_rules( true );
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-alpha-31159';
|
||||
$wp_version = '4.2-alpha-31160';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user