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

Extracts redirect matching logic to its own match_redirect method. #198

Merged
merged 5 commits into from
Feb 19, 2020

Conversation

nicholasio
Copy link
Member

@nicholasio nicholasio commented Nov 25, 2019

Description of the Change

Introduces a new match_redirect method and updates maybe_redirect to use this new method.

It also introduces a srm_match_redirect function to expose matching redirect logic to themes and plugins.

Alternate Designs

See #197

Benefits

Code is more testable now and maybe_redirect now only does one thing.

Possible Drawbacks

None

Verification Process

Manual testing

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

Changelog Entry

Introduces a new match_redirect method and updates maybe_redirect to use this new method.

Also introduces a srm_match_redirect function to export match_redirect to themes and plugins.
@jeffpaul
Copy link
Member

@nicholasio thanks for the PR, it's greatly appreciated! I've pinged @tlovett1 for review on this in planning for getting it into our next milestoned release, so stay tuned for any feedback from that review.

dinhtungdu
dinhtungdu previously approved these changes Feb 4, 2020
Copy link
Collaborator

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Edit: This is just my preference, but if we return early in maybe_redirect method, we can save one level of indentation:

if ( empty(  $matched_redirect ) ) {
    return;
}

// Do the rest
...

@nicholasio
Copy link
Member Author

@dinhtungdu done, that is generally my preference as well.

Copy link
Collaborator

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

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

🎉

@jeffpaul jeffpaul merged commit 62a9a39 into 10up:develop Feb 19, 2020
@braders braders mentioned this pull request Feb 21, 2020
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement New feature or request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants