mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-22 08:11:52 +01:00
Rewrite: Add a remove_rewrite_tag()
helper function.
It can be used to properly remove registered rewrite tags. Adds unit tests. Fixes #35236. Built from https://develop.svn.wordpress.org/trunk@36217 git-svn-id: http://core.svn.wordpress.org/trunk@36184 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
668818e93d
commit
f079f57357
@ -841,6 +841,28 @@ class WP_Rewrite {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes an existing rewrite tag.
|
||||
*
|
||||
* @since 4.5.0
|
||||
* @access public
|
||||
*
|
||||
* @see WP_Rewrite::$rewritecode
|
||||
* @see WP_Rewrite::$rewritereplace
|
||||
* @see WP_Rewrite::$queryreplace
|
||||
*
|
||||
* @param string $tag Name of the rewrite tag to remove.
|
||||
*/
|
||||
public function remove_rewrite_tag( $tag ) {
|
||||
$position = array_search( $tag, $this->rewritecode );
|
||||
if ( false !== $position && null !== $position ) {
|
||||
unset( $this->rewritecode[ $position ] );
|
||||
unset( $this->rewritereplace[ $position ] );
|
||||
unset( $this->queryreplace[ $position ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates rewrite rules from a permalink structure.
|
||||
*
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.5-alpha-36216';
|
||||
$wp_version = '4.5-alpha-36217';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user