WordPress.org

Make WordPress Core

Changeset 36181


Ignore:
Timestamp:
01/06/2016 07:39:29 AM (5 years ago)
Author:
swissspidy
Message:

Rewrite: Add a remove_permastruct() helper function.

It can be used to remove permastructs that were added using add_permastruct().

Fixes #35235.

Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-rewrite.php

    r35941 r36181  
    17461746
    17471747    /**
     1748     * Removes a permalink structure.
     1749     *
     1750     * @since 4.5.0
     1751     * @access public
     1752     *
     1753     * @param string $name Name for permalink structure.
     1754     */
     1755    public function remove_permastruct( $name ) {
     1756        unset( $this->extra_permastructs[ $name ] );
     1757    }
     1758
     1759    /**
    17481760     * Removes rewrite rules and then recreate rewrite rules.
    17491761     *
  • trunk/src/wp-includes/rewrite.php

    r35718 r36181  
    179179 *
    180180 * @see WP_Rewrite::add_permastruct()
    181  * @global WP_Rewrite $wp_rewrite
     181 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
    182182 *
    183183 * @param string $name   Name for permalink structure.
     
    196196
    197197    $wp_rewrite->add_permastruct( $name, $struct, $args );
     198}
     199
     200/**
     201 * Remove permalink structure.
     202 *
     203 * Can only be used to remove permastructs that were added using add_permastruct().
     204 * Built-in permastructs cannot be removed.
     205 *
     206 * @since 4.5.0
     207 *
     208 * @see WP_Rewrite::remove_permastruct()
     209 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
     210 *
     211 * @param string $name Name for permalink structure.
     212 */
     213function remove_permastruct( $name ) {
     214    global $wp_rewrite;
     215
     216    $wp_rewrite->remove_permastruct( $name );
    198217}
    199218
Note: See TracChangeset for help on using the changeset viewer.