Make WordPress Core

Changeset 19753


Ignore:
Timestamp:
01/25/2012 09:58:23 PM (13 years ago)
Author:
duck_
Message:

Improve the inline documentation of rewrite endpoints. See #16303.

File:
1 edited

Legend:

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

    r19752 r19753  
    102102}
    103103
    104 //pseudo-places
    105104/**
    106105 * Endpoint Mask for default, which is nothing.
     
    211210 * Add an endpoint, like /trackback/.
    212211 *
    213  * The endpoints are added to the end of the request. So a request matching
    214  * "/2008/10/14/my_post/myep/", the endpoint will be "/myep/".
    215  *
    216  * Be sure to flush the rewrite rules (wp_rewrite->flush_rules()) when your plugin gets
    217  * activated (register_activation_hook()) and deactivated (register_deactivation_hook())
     212 * Adding an endpoint creates extra rewrite rules for each of the matching
     213 * places specified by the provided bitmask. For example:
     214 *
     215 * <code>
     216 * add_rewrite_endpoint( 'json', EP_PERMALINK | EP_PAGES );
     217 * </code>
     218 *
     219 * will add a new rewrite rule ending with "json(/(.*))?/?$" for every permastruct
     220 * that describes a permalink (post) or page. This is rewritten to "json=$match"
     221 * where $match is the part of the URL matched by the endpoint regex (e.g. "foo" in
     222 * "<permalink>/json/foo/").
     223 *
     224 * A new query var with the same name as the endpoint will also be created.
     225 *
     226 * When specifying $places ensure that you are using the EP_* constants (or a
     227 * combination of them using the bitwise OR operator) as their values are not
     228 * guaranteed to remain static (especially EP_ALL).
     229 *
     230 * Be sure to flush the rewrite rules - flush_rewrite_rules() - when your plugin gets
     231 * activated and deactivated.
    218232 *
    219233 * @since 2.1.0
    220  * @see WP_Rewrite::add_endpoint() Parameters and more description.
    221  * @uses $wp_rewrite
    222  *
    223  * @param unknown_type $name
    224  * @param unknown_type $places
    225  */
    226 function add_rewrite_endpoint($name, $places) {
     234 * @see WP_Rewrite::add_endpoint()
     235 * @global object $wp_rewrite
     236 *
     237 * @param string $name Name of the endpoint.
     238 * @param int $places Endpoint mask describing the places the endpoint should be added.
     239 */
     240function add_rewrite_endpoint( $name, $places ) {
    227241    global $wp_rewrite;
    228     $wp_rewrite->add_endpoint($name, $places);
     242    $wp_rewrite->add_endpoint( $name, $places );
    229243}
    230244
     
    18341848     * Add an endpoint, like /trackback/.
    18351849     *
    1836      * To be inserted after certain URL types (specified in $places).
    1837      *
     1850     * See {@link add_rewrite_endpoint()} for full documentation.
     1851     *
     1852     * @see add_rewrite_endpoint()
    18381853     * @since 2.1.0
    18391854     * @access public
    1840      *
    1841      * @param string $name Name of endpoint.
    1842      * @param array $places URL types that endpoint can be used.
     1855     * @uses WP::add_query_var()
     1856     *
     1857     * @param string $name Name of the endpoint.
     1858     * @param int $places Endpoint mask describing the places the endpoint should be added.
    18431859     */
    18441860    function add_endpoint($name, $places) {
Note: See TracChangeset for help on using the changeset viewer.