Rewrite: Add a remove_rewrite_tag() helper function.

It can be used to properly remove registered rewrite tags. Adds unit tests.

Fixes #35236.

git-svn-id: https://develop.svn.wordpress.org/trunk@36217 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler
2016-01-07 09:38:06 +00:00
parent e5707af429
commit 79f2e50ca5
3 changed files with 163 additions and 0 deletions

View File

@@ -172,6 +172,20 @@ function add_rewrite_tag( $tag, $regex, $query = '' ) {
$wp_rewrite->add_rewrite_tag( $tag, $regex, $query );
}
/**
* Removes an existing rewrite tag (like %postname%).
*
* @since 4.5.0
*
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
*
* @param string $tag Name of the rewrite tag.
*/
function remove_rewrite_tag( $tag ) {
global $wp_rewrite;
$wp_rewrite->remove_rewrite_tag( $tag );
}
/**
* Add permalink structure.
*