diff --git wp-admin/includes/upgrade.php wp-admin/includes/upgrade.php
index 1c0f9f7..2009b32 100644
|
|
|
endif; |
| 264 | 264 | |
| 265 | 265 | if ( ! function_exists( 'wp_install_maybe_enable_pretty_permalinks' ) ) : |
| 266 | 266 | /** |
| 267 | | * Enable pretty permalinks if available. |
| | 267 | * Enable pretty permalinks. |
| 268 | 268 | * |
| 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. |
| 272 | 270 | * |
| 273 | 271 | * @since 4.2.0 |
| 274 | 272 | * |
| … |
… |
if ( ! function_exists( 'wp_install_maybe_enable_pretty_permalinks' ) ) : |
| 277 | 275 | function wp_install_maybe_enable_pretty_permalinks() { |
| 278 | 276 | global $wp_rewrite; |
| 279 | 277 | |
| 280 | | // Bail if we alredy have permalinks enabled (Multisite) |
| | 278 | // Bail if a permalink structure is already enabled. |
| 281 | 279 | if ( get_option( 'permalink_structure' ) ) { |
| 282 | 280 | return; |
| 283 | 281 | } |
| 284 | 282 | |
| 285 | 283 | /* |
| 286 | | * The Permalink structures which WordPress should attempt to use. |
| | 284 | * The Permalink structures to attempt. |
| | 285 | * |
| 287 | 286 | * 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. |
| 290 | 290 | */ |
| 291 | 291 | $permalink_structures = array( |
| 292 | 292 | '/%year%/%monthnum%/%day%/%postname%/', |
| … |
… |
function wp_install_maybe_enable_pretty_permalinks() { |
| 294 | 294 | ); |
| 295 | 295 | |
| 296 | 296 | foreach ( (array) $permalink_structures as $permalink_structure ) { |
| 297 | | // Set the desired Permalink structure to try |
| 298 | 297 | $wp_rewrite->set_permalink_structure( $permalink_structure ); |
| 299 | 298 | |
| 300 | 299 | /* |
| … |
… |
function wp_install_maybe_enable_pretty_permalinks() { |
| 303 | 302 | */ |
| 304 | 303 | $wp_rewrite->flush_rules( true ); |
| 305 | 304 | |
| 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. |
| 307 | 306 | $test_url = get_permalink( 1 ); |
| 308 | 307 | if ( ! $test_url ) { |
| 309 | 308 | $test_url = home_url( '/wordpress-check-for-rewrites/' ); |
| 310 | 309 | } |
| 311 | 310 | |
| 312 | 311 | /* |
| 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 |
| 314 | 313 | * 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. |
| 315 | 317 | */ |
| 316 | 318 | $response = wp_remote_get( $test_url, array( 'timeout' => 5 ) ); |
| 317 | 319 | $x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' ); |
| … |
… |
function wp_install_maybe_enable_pretty_permalinks() { |
| 323 | 325 | } |
| 324 | 326 | |
| 325 | 327 | /* |
| 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. |
| 328 | 330 | */ |
| 329 | 331 | $wp_rewrite->set_permalink_structure( '' ); |
| 330 | 332 | $wp_rewrite->flush_rules( true ); |