Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 48 Minify regex rewrite rule broken by external plugin / theme #49

Merged
merged 7 commits into from
Dec 12, 2013

Conversation

c3mdigital
Copy link
Contributor

This solves the issue by adding the minify rewrite rule to the end of the rewrite_rules_array insuring in theory that the rule can not be broken by an external rewrite filter.

@westonruter please reivew

Chris Olbekson added 2 commits November 26, 2013 12:07
- Change add_rewrite_rule to a filter for the rewrite_rules_array to insure additional plugins will not cause the rules to break
- Fixes #48
add_rewrite_rule( $regex, $redirect, 'top' );
$new_rules[$regex] = $redirect;

return $rules + $new_rules;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c3mdigital I believe this needs to be array_merge(), as using + does some strange things where it will skip merging a item from the right array, if it has the same numeric index as an item in the left.

@c3mdigital
Copy link
Contributor Author

@westonruter Yes array_merge is the way to go. Fixed in 98094cc

- Allows plugin to work with other plugins or themes who have filtered home_url
add_rewrite_rule( $regex, $redirect, 'top' );
$new_rules[$regex] = $redirect;

return array_merge( $rules, $new_rules );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c3mdigital it seems I need to reverse the order here, so that $new_rules will appear at the top. Otherwise, on one site I'm getting the page rewrite rule matching before the the minification rewrite rule can be reached.

$regex = self::get_rewrite_regex();
global $wp_rewrite;
unset( $wp_rewrite->extra_rules_top[ $regex ] );
remove_filter( 'rewrite_rules_array', array( __CLASS__, 'add_rewrite_rule' ), 99999 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c3mdigital good idea!

westonruter added a commit that referenced this pull request Dec 12, 2013
Fix rewrite rule broken by filtering home_url
@westonruter westonruter merged commit 77f3d99 into master Dec 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants