[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

Rewrite API: WP_Rewrite class

File Size: 1941 lines (60 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.

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

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.

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

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.

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

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.

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

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.

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

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

return: array Page rewrite rules.
since: 1.5.0

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.

return: string|false False on no permalink structure. Date permalink structure.
since: 1.5.0

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.

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

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.

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

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

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

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

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.

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

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.

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

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

return: string|false False if not found. Permalink structure string.
param: string $name Permalink structure name.
since: 2.5.0

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.

return: string|false False if not found. Permalink structure string.
since: 1.5.0

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.

return: string|false False if not found. Permalink structure string.
since: 1.5.0

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.

return: string|false False if not found. Permalink structure string.
since: 1.5.0

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.

return: string|false False if not found. Permalink structure string.
since: 1.5.0

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.

return: string|false False if not found. Permalink structure string.
since: 1.5.0

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.

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 '='.
since: 1.5.0

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

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

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.

return: array Rewrite rule list.
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.
since: 1.5.0

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.

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

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.

return: array An associate array of matches and queries.
since: 1.5.0

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.

return: array Rewrite rules.
since: 1.5.0

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.

return: string
since: 1.5.0

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.

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

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.

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'
since: 2.1.0
since: 4.4.0 Array support was added to the `$query` parameter.

add_external_rule( $regex, $query )   X-Ref
Adds a rewrite rule that doesn't correspond to index.php.

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

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

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

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.

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

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

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

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.

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

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

param: string $permalink_structure Permalink structure.
since: 1.5.0

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.

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

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.

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

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

since: 1.5.0



Generated: Thu Sep 19 01:00:03 2019 Cross-referenced by PHPXref 0.7.1