[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

Rewrite API: WP_Rewrite class

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

Defines 1 class

WP_Rewrite:: (37 methods):
  using_permalinks()
  using_index_permalinks()
  using_mod_rewrite_permalinks()
  preg_index()
  page_uri_index()
  page_rewrite_rules()
  get_date_permastruct()
  get_year_permastruct()
  get_month_permastruct()
  get_day_permastruct()
  get_category_permastruct()
  get_tag_permastruct()
  get_extra_permastruct()
  get_author_permastruct()
  get_search_permastruct()
  get_page_permastruct()
  get_feed_permastruct()
  get_comment_feed_permastruct()
  add_rewrite_tag()
  remove_rewrite_tag()
  generate_rewrite_rules()
  generate_rewrite_rule()
  rewrite_rules()
  wp_rewrite_rules()
  mod_rewrite_rules()
  iis7_url_rewrite_rules()
  add_rule()
  add_external_rule()
  add_endpoint()
  add_permastruct()
  remove_permastruct()
  flush_rules()
  init()
  set_permalink_structure()
  set_category_base()
  set_tag_base()
  __construct()


Class: WP_Rewrite  - X-Ref

Core class used to implement a rewrite component API.

The WordPress Rewrite class writes the rewrite module rules to the .htaccess
file. It also handles parsing the request to get the correct setup for the
WordPress Query class.

The Rewrite along with WP class function as a front controller for WordPress.
You can add rules to trigger your page view and processing using this
component. The full functionality of a front controller does not exist,
meaning you can't define how the template files load based on the rewrite
rules.

using_permalinks()   X-Ref
Determines whether permalinks are being used.

This can be either rewrite module or permalink in the HTTP query string.

since: 1.5.0
return: bool True, if permalinks are enabled.

using_index_permalinks()   X-Ref
Determines whether permalinks are being used and rewrite module is not enabled.

Means that permalink links are enabled and index.php is in the URL.

since: 1.5.0
return: bool Whether permalink links are enabled and index.php is in the URL.

using_mod_rewrite_permalinks()   X-Ref
Determines whether permalinks are being used and rewrite module is enabled.

Using permalinks and index.php is not in the URL.

since: 1.5.0
return: bool Whether permalink links are enabled and index.php is NOT in the URL.

preg_index( $number )   X-Ref
Indexes for matches for usage in preg_*() functions.

The format of the string is, with empty matches property value, '$NUM'.
The 'NUM' will be replaced with the value in the $number parameter. With
the matches property not empty, the value of the returned string will
contain that value of the matches property. The format then will be
'$MATCHES[NUM]', with MATCHES as the value in the property and NUM the
value of the $number parameter.

since: 1.5.0
return: string
param: int $number Index number.

page_uri_index()   X-Ref
Retrieves all page and attachments for pages URIs.

The attachments are for those that have pages as parents and will be
retrieved.

since: 2.5.0
return: array Array of page URIs as first element and attachment URIs as second element.

page_rewrite_rules()   X-Ref
Retrieves all of the rewrite rules for pages.

since: 1.5.0
return: string[] Page rewrite rules.

get_date_permastruct()   X-Ref
Retrieves date permalink structure, with year, month, and day.

The permalink structure for the date, if not set already depends on the
permalink structure. It can be one of three formats. The first is year,
month, day; the second is day, month, year; and the last format is month,
day, year. These are matched against the permalink structure for which
one is used. If none matches, then the default will be used, which is
year, month, day.

Prevents post ID and date permalinks from overlapping. In the case of
post_id, the date permalink will be prepended with front permalink with
'date/' before the actual permalink to form the complete date permalink
structure.

since: 1.5.0
return: string|false Date permalink structure on success, false on failure.

get_year_permastruct()   X-Ref
Retrieves the year permalink structure without month and day.

Gets the date permalink structure and strips out the month and day
permalink structures.

since: 1.5.0
return: string|false Year permalink structure on success, false on failure.

get_month_permastruct()   X-Ref
Retrieves the month permalink structure without day and with year.

Gets the date permalink structure and strips out the day permalink
structures. Keeps the year permalink structure.

since: 1.5.0
return: string|false Year/Month permalink structure on success, false on failure.

get_day_permastruct()   X-Ref
Retrieves the day permalink structure with month and year.

Keeps date permalink structure with all year, month, and day.

since: 1.5.0
return: string|false Year/Month/Day permalink structure on success, false on failure.

get_category_permastruct()   X-Ref
Retrieves the permalink structure for categories.

If the category_base property has no value, then the category structure
will have the front property value, followed by 'category', and finally
'%category%'. If it does, then the root property will be used, along with
the category_base property value.

since: 1.5.0
return: string|false Category permalink structure on success, false on failure.

get_tag_permastruct()   X-Ref
Retrieve the permalink structure for tags.

If the tag_base property has no value, then the tag structure will have
the front property value, followed by 'tag', and finally '%tag%'. If it
does, then the root property will be used, along with the tag_base
property value.

since: 2.3.0
return: string|false Tag permalink structure on success, false on failure.

get_extra_permastruct( $name )   X-Ref
Retrieves an extra permalink structure by name.

since: 2.5.0
return: string|false Permalink structure string on success, false on failure.
param: string $name Permalink structure name.

get_author_permastruct()   X-Ref
Retrieves the author permalink structure.

The permalink structure is front property, author base, and finally
'/%author%'. Will set the author_structure property and then return it
without attempting to set the value again.

since: 1.5.0
return: string|false Author permalink structure on success, false on failure.

get_search_permastruct()   X-Ref
Retrieves the search permalink structure.

The permalink structure is root property, search base, and finally
'/%search%'. Will set the search_structure property and then return it
without attempting to set the value again.

since: 1.5.0
return: string|false Search permalink structure on success, false on failure.

get_page_permastruct()   X-Ref
Retrieves the page permalink structure.

The permalink structure is root property, and '%pagename%'. Will set the
page_structure property and then return it without attempting to set the
value again.

since: 1.5.0
return: string|false Page permalink structure on success, false on failure.

get_feed_permastruct()   X-Ref
Retrieves the feed permalink structure.

The permalink structure is root property, feed base, and finally
'/%feed%'. Will set the feed_structure property and then return it
without attempting to set the value again.

since: 1.5.0
return: string|false Feed permalink structure on success, false on failure.

get_comment_feed_permastruct()   X-Ref
Retrieves the comment feed permalink structure.

The permalink structure is root property, comment base property, feed
base and finally '/%feed%'. Will set the comment_feed_structure property
and then return it without attempting to set the value again.

since: 1.5.0
return: string|false Comment feed permalink structure on success, false on failure.

add_rewrite_tag( $tag, $regex, $query )   X-Ref
Adds or updates existing rewrite tags (e.g. %postname%).

If the tag already exists, replace the existing pattern and query for
that tag, otherwise add the new tag.

since: 1.5.0
param: string $tag   Name of the rewrite tag to add or update.
param: string $regex Regular expression to substitute the tag for in rewrite rules.
param: string $query String to append to the rewritten query. Must end in '='.

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

since: 4.5.0
param: string $tag Name of the rewrite tag to remove.

generate_rewrite_rules( $permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true )   X-Ref
Generates rewrite rules from a permalink structure.

The main WP_Rewrite function for building the rewrite rule list. The
contents of the function is a mix of black magic and regular expressions,
so best just ignore the contents and move to the parameters.

since: 1.5.0
return: string[] Array of rewrite rules keyed by their regex pattern.
param: string $permalink_structure The permalink structure.
param: int    $ep_mask             Optional. Endpoint mask defining what endpoints are added to the structure.
param: bool   $paged               Optional. Whether archive pagination rules should be added for the structure.
param: bool   $feed                Optional Whether feed rewrite rules should be added for the structure.
param: bool   $forcomments         Optional. Whether the feed rules should be a query for a comments feed.
param: bool   $walk_dirs           Optional. Whether the 'directories' making up the structure should be walked
param: bool   $endpoints           Optional. Whether endpoints should be applied to the generated rewrite rules.

generate_rewrite_rule( $permalink_structure, $walk_dirs = false )   X-Ref
Generates rewrite rules with permalink structure and walking directory only.

Shorten version of WP_Rewrite::generate_rewrite_rules() that allows for shorter
list of parameters. See the method for longer description of what generating
rewrite rules does.

since: 1.5.0
return: array
param: string $permalink_structure The permalink structure to generate rules.
param: bool   $walk_dirs           Optional. Whether to create list of directories to walk over.

rewrite_rules()   X-Ref
Constructs rewrite matches and queries from permalink structure.

Runs the action {@see 'generate_rewrite_rules'} with the parameter that is an
reference to the current WP_Rewrite instance to further manipulate the
permalink structures and rewrite rules. Runs the {@see 'rewrite_rules_array'}
filter on the full rewrite rule array.

There are two ways to manipulate the rewrite rules, one by hooking into
the {@see 'generate_rewrite_rules'} action and gaining full control of the
object or just manipulating the rewrite rule array before it is passed
from the function.

since: 1.5.0
return: string[] An associative array of matches and queries.

wp_rewrite_rules()   X-Ref
Retrieves the rewrite rules.

The difference between this method and WP_Rewrite::rewrite_rules() is that
this method stores the rewrite rules in the 'rewrite_rules' option and retrieves
it. This prevents having to process all of the permalinks to get the rewrite rules
in the form of caching.

since: 1.5.0
return: string[] Array of rewrite rules keyed by their regex pattern.

mod_rewrite_rules()   X-Ref
Retrieves mod_rewrite-formatted rewrite rules to write to .htaccess.

Does not actually write to the .htaccess file, but creates the rules for
the process that will.

Will add the non_wp_rules property rules to the .htaccess file before
the WordPress rewrite rules one.

since: 1.5.0
return: string

iis7_url_rewrite_rules( $add_parent_tags = false )   X-Ref
Retrieves IIS7 URL Rewrite formatted rewrite rules to write to web.config file.

Does not actually write to the web.config file, but creates the rules for
the process that will.

since: 2.8.0
return: string IIS7 URL rewrite rule sets.
param: bool $add_parent_tags Optional. Whether to add parent tags to the rewrite rule sets.

add_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.

since: 2.1.0
since: 4.4.0 Array support was added to the `$query` parameter.
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_external_rule( $regex, $query )   X-Ref
Adds a rewrite rule that doesn't correspond to index.php.

since: 2.1.0
param: string $regex Regular expression to match request against.
param: string $query The corresponding query vars for this rewrite rule.

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

since: 2.1.0
since: 3.9.0 $query_var parameter added.
since: 4.3.0 Added support for skipping query var registration by passing `false` to `$query_var`.
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 Optional. Name of the corresponding query variable. Pass `false` to

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

A permalink structure (permastruct) is an abstract definition of a set of rewrite rules;
it is an easy way of expressing a set of regular expressions that rewrite to a set of
query strings. The new permastruct is added to the WP_Rewrite::$extra_permastructs array.

When the rewrite rules are built by WP_Rewrite::rewrite_rules(), all of these extra
permastructs are passed to WP_Rewrite::generate_rewrite_rules() which transforms them
into the regular expressions that many love to hate.

The `$args` parameter gives you control over how WP_Rewrite::generate_rewrite_rules()
works on the new permastruct.

since: 2.5.0
param: string $name   Name for permalink structure.
param: string $struct Permalink structure (e.g. category/%category%)
param: array  $args   {

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

since: 4.5.0
param: string $name Name for permalink structure.

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

Calls WP_Rewrite::wp_rewrite_rules() after removing the 'rewrite_rules' option.
If the function named 'save_mod_rewrite_rules' exists, it will be called.

since: 2.0.1
param: bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard).

init()   X-Ref
Sets up the object's properties.

The 'use_verbose_page_rules' object property will be set to true if the
permalink structure begins with one of the following: '%postname%', '%category%',
'%tag%', or '%author%'.

since: 1.5.0

set_permalink_structure( $permalink_structure )   X-Ref
Sets the main permalink structure for the site.

Will update the 'permalink_structure' option, if there is a difference
between the current permalink structure and the parameter value. Calls
WP_Rewrite::init() after the option is updated.

Fires the {@see 'permalink_structure_changed'} action once the init call has
processed passing the old and new values

since: 1.5.0
param: string $permalink_structure Permalink structure.

set_category_base( $category_base )   X-Ref
Sets the category base for the category permalink.

Will update the 'category_base' option, if there is a difference between
the current category base and the parameter value. Calls WP_Rewrite::init()
after the option is updated.

since: 1.5.0
param: string $category_base Category permalink structure base.

set_tag_base( $tag_base )   X-Ref
Sets the tag base for the tag permalink.

Will update the 'tag_base' option, if there is a difference between the
current tag base and the parameter value. Calls WP_Rewrite::init() after
the option is updated.

since: 2.3.0
param: string $tag_base Tag permalink structure base.

__construct()   X-Ref
Constructor - Calls init(), which runs setup.

since: 1.5.0



Generated: Wed Oct 9 01:00:02 2024 Cross-referenced by PHPXref 0.7.1