From dbe28bf8e3aed1c422a7712ae20b8c7c5925d24b Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 6 Jan 2016 07:40:26 +0000 Subject: [PATCH] Rewrite: Add a `remove_permastruct()` helper function. It can be used to remove permastructs that were added using `add_permastruct()`. Fixes #35235. Built from https://develop.svn.wordpress.org/trunk@36181 git-svn-id: http://core.svn.wordpress.org/trunk@36148 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-rewrite.php | 12 ++++++++++++ wp-includes/rewrite.php | 21 ++++++++++++++++++++- wp-includes/version.php | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-rewrite.php b/wp-includes/class-wp-rewrite.php index 035bbc3866..e6f768fed1 100644 --- a/wp-includes/class-wp-rewrite.php +++ b/wp-includes/class-wp-rewrite.php @@ -1744,6 +1744,18 @@ class WP_Rewrite { $this->extra_permastructs[ $name ] = $args; } + /** + * Removes a permalink structure. + * + * @since 4.5.0 + * @access public + * + * @param string $name Name for permalink structure. + */ + public function remove_permastruct( $name ) { + unset( $this->extra_permastructs[ $name ] ); + } + /** * Removes rewrite rules and then recreate rewrite rules. * diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 7f3b2ed321..fe6b99adb7 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -178,7 +178,7 @@ function add_rewrite_tag( $tag, $regex, $query = '' ) { * @since 3.0.0 * * @see WP_Rewrite::add_permastruct() - * @global WP_Rewrite $wp_rewrite + * @global WP_Rewrite $wp_rewrite WordPress rewrite component. * * @param string $name Name for permalink structure. * @param string $struct Permalink structure. @@ -197,6 +197,25 @@ function add_permastruct( $name, $struct, $args = array() ) { $wp_rewrite->add_permastruct( $name, $struct, $args ); } +/** + * Remove permalink structure. + * + * Can only be used to remove permastructs that were added using add_permastruct(). + * Built-in permastructs cannot be removed. + * + * @since 4.5.0 + * + * @see WP_Rewrite::remove_permastruct() + * @global WP_Rewrite $wp_rewrite WordPress rewrite component. + * + * @param string $name Name for permalink structure. + */ +function remove_permastruct( $name ) { + global $wp_rewrite; + + $wp_rewrite->remove_permastruct( $name ); +} + /** * Add a new feed type like /atom1/. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 3f193c31c0..52e7d1956a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-alpha-36180'; +$wp_version = '4.5-alpha-36181'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.