diff --git a/CHANGELOG.md b/CHANGELOG.md index f82a5f2..a8977ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ### HEAD +* Make sure rewrites are added to .htaccess immediately after activation * Move HTML5 Boilerplate's .htaccess to a [plugin](https://github.com/retlehs/wp-h5bp-htaccess) * Rename page-custom.php to template-custom.php * Don't warn about unwritable htaccess if that option is disabled diff --git a/lib/activation.php b/lib/activation.php index ce8add8..d675f1e 100644 --- a/lib/activation.php +++ b/lib/activation.php @@ -38,8 +38,7 @@ function roots_theme_activation_options_add_page() { ); } else { if (is_admin() && isset($_GET['page']) && $_GET['page'] === 'theme_activation_options') { - global $wp_rewrite; - $wp_rewrite->flush_rules(); + flush_rewrite_rules(); wp_redirect(admin_url('themes.php')); exit; } @@ -217,14 +216,12 @@ function roots_theme_activation_action() { if ($roots_theme_activation_options['change_permalink_structure']) { $roots_theme_activation_options['change_permalink_structure'] = false; - global $wp_rewrite; if (get_option('permalink_structure') !== '/%postname%/') { + global $wp_rewrite; $wp_rewrite->set_permalink_structure('/%postname%/'); + flush_rewrite_rules(); } - - $wp_rewrite->init(); - $wp_rewrite->flush_rules(); } if ($roots_theme_activation_options['change_uploads_folder']) { diff --git a/lib/rewrites.php b/lib/rewrites.php index e2db26d..f13a2b0 100644 --- a/lib/rewrites.php +++ b/lib/rewrites.php @@ -35,7 +35,7 @@ function roots_clean_urls($content) { } } -if (!is_multisite() && !is_child_theme() && get_option('permalink_structure')) { +if (!is_multisite() && !is_child_theme()) { if (current_theme_supports('rewrites')) { add_action('generate_rewrite_rules', 'roots_add_rewrites'); }