From 2f267f6a2a14d43d656f482b1d362223b154ffe2 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 10 Sep 2013 22:19:09 +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. Built from https://develop.svn.wordpress.org/trunk@25328 git-svn-id: http://core.svn.wordpress.org/trunk@25290 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rewrite.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 00a9fad04c..782e664b81 100644 --- a/wp-includes/rewrite.php +++ b/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(); }