Created
November 2, 2017 20:41
-
-
Save philipjohn/2a7949767a756d5f4eb868d4c4228573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'pre_update_option', 'll_kill_frontend_rewrite_rules_update', 10, 3 ); | |
function ll_kill_frontend_rewrite_rules_update( $value, $option, $old_value ) { | |
// We're only concerned with the rewrite rules option. | |
if ( 'rewrite_rules' !== $option ) { | |
return $value; | |
} | |
// We want to concentrate on frontend requests only. | |
if ( ! is_admin() && ! is_user_logged_in() ) { | |
// Returning the old value will effectively stop the update. | |
// See https://core.trac.wordpress.org/browser/tags/4.8.3/src/wp-includes/option.php#L307 | |
return $old_value; | |
} | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment