Skip to content

Instantly share code, notes, and snippets.

@philipjohn
Created November 2, 2017 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philipjohn/2a7949767a756d5f4eb868d4c4228573 to your computer and use it in GitHub Desktop.
Save philipjohn/2a7949767a756d5f4eb868d4c4228573 to your computer and use it in GitHub Desktop.
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