From 03a2ee8fbd07bed7106ac70316d9ba28b4159874 Mon Sep 17 00:00:00 2001 From: Sven Lehnert Date: Sat, 30 Apr 2016 14:13:08 +0200 Subject: [PATCH] Move the check for um_flush_stop to the flush_rewrite_rules function to avoid add_rewrite_rule issues if other plugins flush_rewrite_rules. We need to make sure the add_rewrite_rule is running each time otherwise the rewrite roles get lost if other plugins flush_rewrite_rules. Now the um_flush_stop check is moved to the add_rewrite_rule function to make sure add_rewrite_rule is fired. If the option "Stop rewriting rules on every load" is set to "on" and a plugin flush_rewrite_rules your add_rewrite_rule will get recognised. I also added a filer 'up_rewrite_flush_rewrite_rules' to allow plugins to stop rewriting without manipulating the option array. I hope this makes sense for you and help you. My english is not the best let me know if I got something wrong here or you have any question left. I like to help. --- core/um-rewrite.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/um-rewrite.php b/core/um-rewrite.php index c60ebaa8..16a262b9 100644 --- a/core/um-rewrite.php +++ b/core/um-rewrite.php @@ -32,7 +32,7 @@ class UM_Rewrite { global $ultimatemember; - if ( isset( $ultimatemember->permalinks->core['user'] ) && !um_get_option('um_flush_stop') ) { + if ( isset( $ultimatemember->permalinks->core['user'] ) ) { $user_page_id = $ultimatemember->permalinks->core['user']; $account_page_id = $ultimatemember->permalinks->core['account']; @@ -84,8 +84,8 @@ class UM_Rewrite { 'top' ); - - flush_rewrite_rules( true ); + if( !apply_filters('up_rewrite_flush_rewrite_rules', um_get_option('um_flush_stop') ) ) + flush_rewrite_rules( true ); }