Make WordPress Core

Ticket #6481: 6481.3.diff

File 6481.3.diff, 2.4 KB (added by ericlewis, 10 years ago)
  • src/wp-admin/includes/schema.php

     
    397397        'links_updated_date_format' => __('F j, Y g:i a'),
    398398        'comment_moderation' => 0,
    399399        'moderation_notify' => 1,
    400         'permalink_structure' => '',
     400        'permalink_structure' => '/%year%/%monthnum%/%day%/%postname%/',
    401401        'gzipcompression' => 0,
    402402        'hack_file' => 0,
    403403        'blog_charset' => 'UTF-8',
     
    495495        if ( is_multisite() ) {
    496496                /* translators: blog tagline */
    497497                $options[ 'blogdescription' ] = sprintf(__('Just another %s site'), get_current_site()->site_name );
    498                 $options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/';
    499498        }
    500499
    501500        // Set autoload to no for these options
  • src/wp-admin/includes/upgrade.php

     
    241241        elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) )
    242242                update_user_meta( $user_id, 'show_welcome_panel', 2 );
    243243
     244        if ( ! is_multisite() ) {
     245                // Verify pretty permalinks work, falling back to ugly permalinks if they don't.
     246                $pretty_permalinks_work = wp_install_verify_permalink_structure();
     247                if ( ! $pretty_permalinks_work ) {
     248                        $wp_rewrite->set_permalink_structure('');
     249                        $wp_rewrite->flush_rules();
     250                }
     251        }
     252
    244253        if ( is_multisite() ) {
    245254                // Flush rules to pick up the new page.
    246255                $wp_rewrite->init();
     
    260269}
    261270endif;
    262271
     272/**
     273 * Verify whether the default pretty permalink structure works.
     274 *
     275 * @since 4.1.0
     276 *
     277 * @return bool
     278 */
     279function wp_install_verify_permalink_structure() {
     280        global $wp_rewrite;
     281        // Flush rules with the hard option to force refresh of the web-server's
     282        // rewrite config file (e.g. .htaccess or web.config).
     283        $wp_rewrite->flush_rules( true );
     284
     285        // Send a HEAD request to the dummy post made in wp_install_defaults()
     286        // to smoke test pretty permalinks.
     287        $link = get_permalink(1);
     288        $response = wp_remote_head( $link );
     289
     290        $good_response = is_array( $response ) && isset( $response['response'], $response['response']['code'] )
     291                && $response['response']['code'] == 200;
     292
     293        return $good_response;
     294}
     295
    263296if ( !function_exists('wp_new_blog_notification') ) :
    264297/**
    265298 * {@internal Missing Short Description}}