[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> rewrite.php (summary)

WordPress Rewrite API

File Size: 662 lines (20 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 11 functions

  add_rewrite_rule()
  add_rewrite_tag()
  remove_rewrite_tag()
  add_permastruct()
  remove_permastruct()
  add_feed()
  flush_rewrite_rules()
  add_rewrite_endpoint()
  _wp_filter_taxonomy_base()
  wp_resolve_numeric_slug_conflicts()
  url_to_postid()

Functions
Functions that are not part of a class:

add_rewrite_rule( $regex, $query, $after = 'bottom' )   X-Ref
Adds a rewrite rule that transforms a URL structure to a set of query vars.

Any value in the $after parameter that isn't 'bottom' will result in the rule
being placed at the top of the rewrite rules.

param: string       $regex Regular expression to match request against.
param: string|array $query The corresponding query vars for this rewrite rule.
param: string       $after Optional. Priority of the new rule. Accepts 'top'

add_rewrite_tag( $tag, $regex, $query = '' )   X-Ref
Adds a new rewrite tag (like %postname%).

The `$query` parameter is optional. If it is omitted you must ensure that you call
this on, or before, the {@see 'init'} hook. This is because `$query` defaults to
`$tag=`, and for this to work a new query var has to be added.

param: string $tag   Name of the new rewrite tag.
param: string $regex Regular expression to substitute the tag for in rewrite rules.
param: string $query Optional. String to append to the rewritten query. Must end in '='. Default empty.

remove_rewrite_tag( $tag )   X-Ref
Removes an existing rewrite tag (like %postname%).

param: string $tag Name of the rewrite tag.

add_permastruct( $name, $struct, $args = array()   X-Ref
Adds a permalink structure.

param: string $name   Name for permalink structure.
param: string $struct Permalink structure.
param: array  $args   Optional. Arguments for building the rules from the permalink structure,

remove_permastruct( $name )   X-Ref
Removes a permalink structure.

Can only be used to remove permastructs that were added using add_permastruct().
Built-in permastructs cannot be removed.

param: string $name Name for permalink structure.

add_feed( $feedname, $callback )   X-Ref
Adds a new feed type like /atom1/.

param: string   $feedname Feed name. Should not start with '_'.
param: callable $callback Callback to run on feed display.
return: string Feed action name.

flush_rewrite_rules( $hard = true )   X-Ref
Removes rewrite rules and then recreate rewrite rules.

param: bool $hard Whether to update .htaccess (hard flush) or just update

add_rewrite_endpoint( $name, $places, $query_var = true )   X-Ref
Adds an endpoint, like /trackback/.

Adding an endpoint creates extra rewrite rules for each of the matching
places specified by the provided bitmask. For example:

add_rewrite_endpoint( 'json', EP_PERMALINK | EP_PAGES );

will add a new rewrite rule ending with "json(/(.*))?/?$" for every permastruct
that describes a permalink (post) or page. This is rewritten to "json=$match"
where $match is the part of the URL matched by the endpoint regex (e.g. "foo" in
"[permalink]/json/foo/").

A new query var with the same name as the endpoint will also be created.

When specifying $places ensure that you are using the EP_* constants (or a
combination of them using the bitwise OR operator) as their values are not
guaranteed to remain static (especially `EP_ALL`).

Be sure to flush the rewrite rules - see flush_rewrite_rules() - when your plugin gets
activated and deactivated.

param: string      $name      Name of the endpoint.
param: int         $places    Endpoint mask describing the places the endpoint should be added.
param: string|bool $query_var Name of the corresponding query variable. Pass `false` to skip registering a query_var

_wp_filter_taxonomy_base( $base )   X-Ref
Filters the URL base for taxonomies.

To remove any manually prepended /index.php/.

param: string $base The taxonomy base that we're going to filter
return: string

wp_resolve_numeric_slug_conflicts( $query_vars = array()   X-Ref
Resolves numeric slugs that collide with date permalinks.

Permalinks of posts with numeric slugs can sometimes look to WP_Query::parse_query()
like a date archive, as when your permalink structure is `/%year%/%postname%/` and
a post with post_name '05' has the URL `/2015/05/`.

This function detects conflicts of this type and resolves them in favor of the
post permalink.

Note that, since 4.3.0, wp_unique_post_slug() prevents the creation of post slugs
that would result in a date archive conflict. The resolution performed in this
function is primarily for legacy content, as well as cases when the admin has changed
the site's permalink structure in a way that introduces URL conflicts.

param: array $query_vars Optional. Query variables for setting up the loop, as determined in
return: array Returns the original array of query vars, with date/post conflicts resolved.

url_to_postid( $url )   X-Ref
Examines a URL and try to determine the post ID it represents.

Checks are supposedly from the hosted site blog.

param: string $url Permalink to check.
return: int Post ID, or 0 on failure.



Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref