From: Chuck Scott Date: Fri, 2 Sep 2016 14:36:08 +0000 (-0400) Subject: Updated rewrite rules flush for package detail pages. X-Git-Tag: v1.1.16^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=a8d307c945b996c36f38257d1964ef55d27c10ff;p=WP-Plugins%2Fglm-member-db-packaging.git Updated rewrite rules flush for package detail pages. Fixed an invalid reference in a view file. --- diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 18c01aa..e7f5ad4 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -26,43 +26,25 @@ * *** Also note that parameters will be in the context of the main front controller constructor. *** */ -// Setup rewrite for member detail pages -add_filter('rewrite_rules_array', function($rules) { - - // Check if rule is not set - if ( ! isset( $rules['('.$this->config['settings']['canonical_package_page'].')/([^/]*)$'] ) ) { - - // Add the new rule - $newrules = array(); - $newrules['('.$this->config['settings']['canonical_package_page'].')/([^/]*)$']='index.php?pagename=$matches[1]&packageslug=$matches[2]'; - return $newrules + $rules; - } - - // If already set, just return the rules unchanged. - return $rules; +// Setup rewrite for package detail page +add_filter( 'rewrite_rules_array', function($rules) { + $newrules = array(); + $newrules['('.$this->config['settings']['canonical_package_page'].')/([^/]*)$']='index.php?pagename=$matches[1]&packageslug=$matches[2]'; + return $newrules + $rules; }); - -/* This code is being replace for testing by the above to avoid intermittent 404's on the detail pages. -// Check if the canonical package page rewrite rule is not currently in place. -$rules = get_option( 'rewrite_rules' ); -if ( ! isset( $rules['('.$this->config['settings']['canonical_package_page'].')/([^/]*)$'] ) ) { - - // Setup rewrite for member detail pages - add_filter('rewrite_rules_array', function($rules) { - $newrules = array(); - $newrules['('.$this->config['settings']['canonical_package_page'].')/([^/]*)$']='index.php?pagename=$matches[1]&packageslug=$matches[2]'; - return $newrules + $rules; - }); - - // Rewrite is not in place, so setup init call to add it and flush the rewrite cache - add_filter('init', function() { +add_filter( 'query_vars', function($vars) { + array_push($vars, 'packageslug'); + return $vars; +}); +add_action('wp_loaded', function() { + $rules = get_option('rewrite_rules'); + if ( ! isset( $rules['('.$this->config['settings']['canonical_package_page'].')/([^/]*)$'] ) ) { + trigger_error('Doing rewrite flush - Package detail page', E_USER_NOTICE); // Logging that this is happening so we can track when that happens. global $wp_rewrite; $wp_rewrite->flush_rules(); - }); - -} -*/ + } +}); /* * Package Detail Page Canonical URL Fix @@ -104,12 +86,6 @@ if (strpos(GLM_MEMBERS_PLUGIN_CURRENT_URL, $this->config['settings']['canonical_ } -// Add package slug query var -add_filter('query_vars', function($vars) { - array_push($vars, 'packageslug'); - return $vars; -}); - if (isset($this->config['addOns']['glm-member-db'])) { // Add content to member listing page - Get it from the existing package listing shortcode diff --git a/views/admin/management/packaging.html b/views/admin/management/packaging.html index 0c127c9..2b27667 100644 --- a/views/admin/management/packaging.html +++ b/views/admin/management/packaging.html @@ -224,10 +224,6 @@ var table = $(this).attr('data-show-table'); $('#' + table).removeClass('glm-hidden'); - if (table == 'glm-table-address') { - initMap(); - } - }); // Flash certain elements for a short time after display