Permalink
Browse files

Babble: Fix a bug wherein if we add the home_url filter unexpectedly …

…it leads to an infinite redirect loop and no homepage.
  • Loading branch information...
1 parent 833cc26 commit a226dc84679219be053cdbcabbbe1204dfa918aa Simon Wheatley committed May 24, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −3 class-locale.php
View
11 class-locale.php
@@ -145,9 +145,14 @@ public function internal_rewrite_rules_filter( $rules ){
}
// The WP robots.txt rewrite rule will not have worked, as the
// code objects to the language prefix. Here we add it in again.
- remove_filter( 'home_url', array( $this, 'home_url' ), null, 2 );
+ $hooked = false;
+ if ( has_filter( 'home_url' ) ) {
+ remove_filter( 'home_url', array( $this, 'home_url' ), null, 2 );
+ $hooked = true;
+ }
$home_path = parse_url( home_url() );
- add_filter( 'home_url', array( $this, 'home_url' ), null, 2 );
+ if ( $hooked )
+ add_filter( 'home_url', array( $this, 'home_url' ), null, 2 );
if ( empty( $home_path['path'] ) || '/' == $home_path['path'] )
$new_rules[ 'robots\.txt$' ] = $wp_rewrite->index . '?robots=1';
return $new_rules;
@@ -196,7 +201,7 @@ public function set_locale( $locale ) {
*
* FIXME: Should I be extending and replacing the WP class?
*
- * @param object $ WP object, passed by reference (so no need to return)
+ * @param object $wp The WP object, passed by reference (so no need to return)
* @return void
**/
public function parse_request_early( $wp ) {

0 comments on commit a226dc8

Please sign in to comment.