From f3794bd6cb7bdfa64100d672bca7a3ee1645ebaa Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Fri, 14 Apr 2017 13:24:18 -0400 Subject: [PATCH] Reverted to previous rewrite rules code then added optional parameter for member "profile" ID. --- setup/frontHooks.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 0e404f7c..4ed2b282 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -26,34 +26,27 @@ * Also note that parameters will be in the context of the main front controller constructor. */ -// Setup rewrite for member detail page +// Setup rewrite for member detail page - Now includes optional member_info ID (profile) parameter for multi-profile members add_filter( 'rewrite_rules_array', function($rules) { $newrules = array(); - $newrules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)/([^/]*)$']='index.php?pagename=$matches[1]&memberslug=$matches[2]&profile=$matches[3]'; - if ( isset( $this->config['settings']['enable_multiple_profiles'] ) && $this->config['settings']['enable_multiple_profiles'] ) { - $newrules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)$']='index.php?pagename=$matches[1]&memberslug=$matches[2]'; - } + $newrules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)/?([^/]*)?']='index.php?pagename=$matches[1]&memberslug=$matches[2]&profile=$matches[3]'; return $newrules + $rules; }); add_filter( 'query_vars', function($vars) { array_push($vars, 'memberslug'); - if ( isset( $this->config['settings']['enable_multiple_profiles'] ) && $this->config['settings']['enable_multiple_profiles'] ) { - array_push($vars, 'profile'); - } + array_push($vars, 'profile'); return $vars; }); add_action('wp_loaded', function() { $rules = get_option('rewrite_rules'); - if ( !isset( $rules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)$'] ) || - ( ( isset( $this->config['settings']['enable_multiple_profiles'] ) && $this->config['settings']['enable_multiple_profiles'] ) && !isset( $rules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)/([^/]*)$'] ) ) - ) { + if ( ! isset( $rules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)/?([^/]*)?'] ) ) { trigger_error('Doing rewrite flush - Member detail page', E_USER_NOTICE); // Logging that this is happening so we can track when that happens. global $wp_rewrite; $wp_rewrite->flush_rules(); } }); -/* + /* * Add a filter to correct rel_canonical header entries * * This replaces the WordPress wp_head "rel_canonical" action hook and -- 2.17.1