From 4fccea305ff66c039e8893b7c784f075b0e8cdb5 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 10 Sep 2013 22:18:21 +0000 Subject: [PATCH] Add filter `flush_rewrite_rules_hard` to give devs chance to prevent writing to file when hard-flushing rewrite rules. Props jeremyfelt, nacin. Fixes #23491. git-svn-id: https://develop.svn.wordpress.org/trunk@25328 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/rewrite.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/rewrite.php b/src/wp-includes/rewrite.php index 00a9fad04c..782e664b81 100644 --- a/src/wp-includes/rewrite.php +++ b/src/wp-includes/rewrite.php @@ -1893,9 +1893,11 @@ class WP_Rewrite { function flush_rules($hard = true) { delete_option('rewrite_rules'); $this->wp_rewrite_rules(); - if ( $hard && function_exists('save_mod_rewrite_rules') ) + if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) + return; + if ( function_exists( 'save_mod_rewrite_rules' ) ) save_mod_rewrite_rules(); - if ( $hard && function_exists('iis7_save_url_rewrite_rules') ) + if ( function_exists( 'iis7_save_url_rewrite_rules' ) ) iis7_save_url_rewrite_rules(); }