wp/wp-includes/class-wp-rewrite.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    43 	 * Base for the author permalink structure (example.com/$author_base/authorname).
    43 	 * Base for the author permalink structure (example.com/$author_base/authorname).
    44 	 *
    44 	 *
    45 	 * @since 1.5.0
    45 	 * @since 1.5.0
    46 	 * @var string
    46 	 * @var string
    47 	 */
    47 	 */
    48 	var $author_base = 'author';
    48 	public $author_base = 'author';
    49 
    49 
    50 	/**
    50 	/**
    51 	 * Permalink structure for author archives.
    51 	 * Permalink structure for author archives.
    52 	 *
    52 	 *
    53 	 * @since 1.5.0
    53 	 * @since 1.5.0
    54 	 * @var string
    54 	 * @var string
    55 	 */
    55 	 */
    56 	var $author_structure;
    56 	public $author_structure;
    57 
    57 
    58 	/**
    58 	/**
    59 	 * Permalink structure for date archives.
    59 	 * Permalink structure for date archives.
    60 	 *
    60 	 *
    61 	 * @since 1.5.0
    61 	 * @since 1.5.0
    62 	 * @var string
    62 	 * @var string
    63 	 */
    63 	 */
    64 	var $date_structure;
    64 	public $date_structure;
    65 
    65 
    66 	/**
    66 	/**
    67 	 * Permalink structure for pages.
    67 	 * Permalink structure for pages.
    68 	 *
    68 	 *
    69 	 * @since 1.5.0
    69 	 * @since 1.5.0
    70 	 * @var string
    70 	 * @var string
    71 	 */
    71 	 */
    72 	var $page_structure;
    72 	public $page_structure;
    73 
    73 
    74 	/**
    74 	/**
    75 	 * Base of the search permalink structure (example.com/$search_base/query).
    75 	 * Base of the search permalink structure (example.com/$search_base/query).
    76 	 *
    76 	 *
    77 	 * @since 1.5.0
    77 	 * @since 1.5.0
    78 	 * @var string
    78 	 * @var string
    79 	 */
    79 	 */
    80 	var $search_base = 'search';
    80 	public $search_base = 'search';
    81 
    81 
    82 	/**
    82 	/**
    83 	 * Permalink structure for searches.
    83 	 * Permalink structure for searches.
    84 	 *
    84 	 *
    85 	 * @since 1.5.0
    85 	 * @since 1.5.0
    86 	 * @var string
    86 	 * @var string
    87 	 */
    87 	 */
    88 	var $search_structure;
    88 	public $search_structure;
    89 
    89 
    90 	/**
    90 	/**
    91 	 * Comments permalink base.
    91 	 * Comments permalink base.
    92 	 *
    92 	 *
    93 	 * @since 1.5.0
    93 	 * @since 1.5.0
    94 	 * @var string
    94 	 * @var string
    95 	 */
    95 	 */
    96 	var $comments_base = 'comments';
    96 	public $comments_base = 'comments';
    97 
    97 
    98 	/**
    98 	/**
    99 	 * Pagination permalink base.
    99 	 * Pagination permalink base.
   100 	 *
   100 	 *
   101 	 * @since 3.1.0
   101 	 * @since 3.1.0
   107 	 * Comments pagination permalink base.
   107 	 * Comments pagination permalink base.
   108 	 *
   108 	 *
   109 	 * @since 4.2.0
   109 	 * @since 4.2.0
   110 	 * @var string
   110 	 * @var string
   111 	 */
   111 	 */
   112 	var $comments_pagination_base = 'comment-page';
   112 	public $comments_pagination_base = 'comment-page';
   113 
   113 
   114 	/**
   114 	/**
   115 	 * Feed permalink base.
   115 	 * Feed permalink base.
   116 	 *
   116 	 *
   117 	 * @since 1.5.0
   117 	 * @since 1.5.0
   118 	 * @var string
   118 	 * @var string
   119 	 */
   119 	 */
   120 	var $feed_base = 'feed';
   120 	public $feed_base = 'feed';
   121 
   121 
   122 	/**
   122 	/**
   123 	 * Comments feed permalink structure.
   123 	 * Comments feed permalink structure.
   124 	 *
   124 	 *
   125 	 * @since 1.5.0
   125 	 * @since 1.5.0
   126 	 * @var string
   126 	 * @var string
   127 	 */
   127 	 */
   128 	var $comment_feed_structure;
   128 	public $comment_feed_structure;
   129 
   129 
   130 	/**
   130 	/**
   131 	 * Feed request permalink structure.
   131 	 * Feed request permalink structure.
   132 	 *
   132 	 *
   133 	 * @since 1.5.0
   133 	 * @since 1.5.0
   134 	 * @var string
   134 	 * @var string
   135 	 */
   135 	 */
   136 	var $feed_structure;
   136 	public $feed_structure;
   137 
   137 
   138 	/**
   138 	/**
   139 	 * The static portion of the post permalink structure.
   139 	 * The static portion of the post permalink structure.
   140 	 *
   140 	 *
   141 	 * If the permalink structure is "/archive/%post_id%" then the front
   141 	 * If the permalink structure is "/archive/%post_id%" then the front
   176 	 * Variable name to use for regex matches in the rewritten query.
   176 	 * Variable name to use for regex matches in the rewritten query.
   177 	 *
   177 	 *
   178 	 * @since 1.5.0
   178 	 * @since 1.5.0
   179 	 * @var string
   179 	 * @var string
   180 	 */
   180 	 */
   181 	var $matches = '';
   181 	public $matches = '';
   182 
   182 
   183 	/**
   183 	/**
   184 	 * Rewrite rules to match against the request to find the redirect or query.
   184 	 * Rewrite rules to match against the request to find the redirect or query.
   185 	 *
   185 	 *
   186 	 * @since 1.5.0
   186 	 * @since 1.5.0
   187 	 * @var array
   187 	 * @var array
   188 	 */
   188 	 */
   189 	var $rules;
   189 	public $rules;
   190 
   190 
   191 	/**
   191 	/**
   192 	 * Additional rules added external to the rewrite class.
   192 	 * Additional rules added external to the rewrite class.
   193 	 *
   193 	 *
   194 	 * Those not generated by the class, see add_rewrite_rule().
   194 	 * Those not generated by the class, see add_rewrite_rule().
   195 	 *
   195 	 *
   196 	 * @since 2.1.0
   196 	 * @since 2.1.0
   197 	 * @var array
   197 	 * @var array
   198 	 */
   198 	 */
   199 	var $extra_rules = array();
   199 	public $extra_rules = array();
   200 
   200 
   201 	/**
   201 	/**
   202 	 * Additional rules that belong at the beginning to match first.
   202 	 * Additional rules that belong at the beginning to match first.
   203 	 *
   203 	 *
   204 	 * Those not generated by the class, see add_rewrite_rule().
   204 	 * Those not generated by the class, see add_rewrite_rule().
   205 	 *
   205 	 *
   206 	 * @since 2.3.0
   206 	 * @since 2.3.0
   207 	 * @var array
   207 	 * @var array
   208 	 */
   208 	 */
   209 	var $extra_rules_top = array();
   209 	public $extra_rules_top = array();
   210 
   210 
   211 	/**
   211 	/**
   212 	 * Rules that don't redirect to WordPress' index.php.
   212 	 * Rules that don't redirect to WordPress' index.php.
   213 	 *
   213 	 *
   214 	 * These rules are written to the mod_rewrite portion of the .htaccess,
   214 	 * These rules are written to the mod_rewrite portion of the .htaccess,
   215 	 * and are added by add_external_rule().
   215 	 * and are added by add_external_rule().
   216 	 *
   216 	 *
   217 	 * @since 2.1.0
   217 	 * @since 2.1.0
   218 	 * @var array
   218 	 * @var array
   219 	 */
   219 	 */
   220 	var $non_wp_rules = array();
   220 	public $non_wp_rules = array();
   221 
   221 
   222 	/**
   222 	/**
   223 	 * Extra permalink structures, e.g. categories, added by add_permastruct().
   223 	 * Extra permalink structures, e.g. categories, added by add_permastruct().
   224 	 *
   224 	 *
   225 	 * @since 2.1.0
   225 	 * @since 2.1.0
   226 	 * @var array
   226 	 * @var array
   227 	 */
   227 	 */
   228 	var $extra_permastructs = array();
   228 	public $extra_permastructs = array();
   229 
   229 
   230 	/**
   230 	/**
   231 	 * Endpoints (like /trackback/) added by add_rewrite_endpoint().
   231 	 * Endpoints (like /trackback/) added by add_rewrite_endpoint().
   232 	 *
   232 	 *
   233 	 * @since 2.1.0
   233 	 * @since 2.1.0
   234 	 * @var array
   234 	 * @var array
   235 	 */
   235 	 */
   236 	var $endpoints;
   236 	public $endpoints;
   237 
   237 
   238 	/**
   238 	/**
   239 	 * Whether to write every mod_rewrite rule for WordPress into the .htaccess file.
   239 	 * Whether to write every mod_rewrite rule for WordPress into the .htaccess file.
   240 	 *
   240 	 *
   241 	 * This is off by default, turning it on might print a lot of rewrite rules
   241 	 * This is off by default, turning it on might print a lot of rewrite rules
   275 	 * Additional tags can be added with add_rewrite_tag().
   275 	 * Additional tags can be added with add_rewrite_tag().
   276 	 *
   276 	 *
   277 	 * @since 1.5.0
   277 	 * @since 1.5.0
   278 	 * @var array
   278 	 * @var array
   279 	 */
   279 	 */
   280 	var $rewritecode = array(
   280 	public $rewritecode = array(
   281 		'%year%',
   281 		'%year%',
   282 		'%monthnum%',
   282 		'%monthnum%',
   283 		'%day%',
   283 		'%day%',
   284 		'%hour%',
   284 		'%hour%',
   285 		'%minute%',
   285 		'%minute%',
   296 	 * of rewrite tags, see WP_Rewrite::$rewritecode.
   296 	 * of rewrite tags, see WP_Rewrite::$rewritecode.
   297 	 *
   297 	 *
   298 	 * @since 1.5.0
   298 	 * @since 1.5.0
   299 	 * @var array
   299 	 * @var array
   300 	 */
   300 	 */
   301 	var $rewritereplace = array(
   301 	public $rewritereplace = array(
   302 		'([0-9]{4})',
   302 		'([0-9]{4})',
   303 		'([0-9]{1,2})',
   303 		'([0-9]{1,2})',
   304 		'([0-9]{1,2})',
   304 		'([0-9]{1,2})',
   305 		'([0-9]{1,2})',
   305 		'([0-9]{1,2})',
   306 		'([0-9]{1,2})',
   306 		'([0-9]{1,2})',
   316 	 * Query variables that rewrite tags map to, see WP_Rewrite::$rewritecode.
   316 	 * Query variables that rewrite tags map to, see WP_Rewrite::$rewritecode.
   317 	 *
   317 	 *
   318 	 * @since 1.5.0
   318 	 * @since 1.5.0
   319 	 * @var array
   319 	 * @var array
   320 	 */
   320 	 */
   321 	var $queryreplace = array(
   321 	public $queryreplace = array(
   322 		'year=',
   322 		'year=',
   323 		'monthnum=',
   323 		'monthnum=',
   324 		'day=',
   324 		'day=',
   325 		'hour=',
   325 		'hour=',
   326 		'minute=',
   326 		'minute=',
   838 	 *
   838 	 *
   839 	 * @since 1.5.0
   839 	 * @since 1.5.0
   840 	 *
   840 	 *
   841 	 * @param string $permalink_structure The permalink structure.
   841 	 * @param string $permalink_structure The permalink structure.
   842 	 * @param int    $ep_mask             Optional. Endpoint mask defining what endpoints are added to the structure.
   842 	 * @param int    $ep_mask             Optional. Endpoint mask defining what endpoints are added to the structure.
   843 	 *                                    Accepts `EP_NONE`, `EP_PERMALINK`, `EP_ATTACHMENT`, `EP_DATE`, `EP_YEAR`,
   843 	 *                                    Accepts a mask of:
   844 	 *                                    `EP_MONTH`, `EP_DAY`, `EP_ROOT`, `EP_COMMENTS`, `EP_SEARCH`, `EP_CATEGORIES`,
   844 	 *                                    - `EP_ALL`
   845 	 *                                    `EP_TAGS`, `EP_AUTHORS`, `EP_PAGES`, `EP_ALL_ARCHIVES`, and `EP_ALL`.
   845 	 *                                    - `EP_NONE`
       
   846 	 *                                    - `EP_ALL_ARCHIVES`
       
   847 	 *                                    - `EP_ATTACHMENT`
       
   848 	 *                                    - `EP_AUTHORS`
       
   849 	 *                                    - `EP_CATEGORIES`
       
   850 	 *                                    - `EP_COMMENTS`
       
   851 	 *                                    - `EP_DATE`
       
   852 	 *                                    - `EP_DAY`
       
   853 	 *                                    - `EP_MONTH`
       
   854 	 *                                    - `EP_PAGES`
       
   855 	 *                                    - `EP_PERMALINK`
       
   856 	 *                                    - `EP_ROOT`
       
   857 	 *                                    - `EP_SEARCH`
       
   858 	 *                                    - `EP_TAGS`
       
   859 	 *                                    - `EP_YEAR`
   846 	 *                                    Default `EP_NONE`.
   860 	 *                                    Default `EP_NONE`.
   847 	 * @param bool   $paged               Optional. Whether archive pagination rules should be added for the structure.
   861 	 * @param bool   $paged               Optional. Whether archive pagination rules should be added for the structure.
   848 	 *                                    Default true.
   862 	 *                                    Default true.
   849 	 * @param bool   $feed                Optional Whether feed rewrite rules should be added for the structure.
   863 	 * @param bool   $feed                Optional Whether feed rewrite rules should be added for the structure.
   850 	 *                                    Default true.
   864 	 *                                    Default true.
  1507 			$home_root = '/';
  1521 			$home_root = '/';
  1508 		}
  1522 		}
  1509 
  1523 
  1510 		$rules  = "<IfModule mod_rewrite.c>\n";
  1524 		$rules  = "<IfModule mod_rewrite.c>\n";
  1511 		$rules .= "RewriteEngine On\n";
  1525 		$rules .= "RewriteEngine On\n";
       
  1526 		$rules .= "RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]\n";
  1512 		$rules .= "RewriteBase $home_root\n";
  1527 		$rules .= "RewriteBase $home_root\n";
  1513 
  1528 
  1514 		// Prevent -f checks on index.php.
  1529 		// Prevent -f checks on index.php.
  1515 		$rules .= "RewriteRule ^index\.php$ - [L]\n";
  1530 		$rules .= "RewriteRule ^index\.php$ - [L]\n";
  1516 
  1531 
  1679 	 * @see add_rewrite_endpoint() for full documentation.
  1694 	 * @see add_rewrite_endpoint() for full documentation.
  1680 	 * @global WP $wp Current WordPress environment instance.
  1695 	 * @global WP $wp Current WordPress environment instance.
  1681 	 *
  1696 	 *
  1682 	 * @param string      $name      Name of the endpoint.
  1697 	 * @param string      $name      Name of the endpoint.
  1683 	 * @param int         $places    Endpoint mask describing the places the endpoint should be added.
  1698 	 * @param int         $places    Endpoint mask describing the places the endpoint should be added.
       
  1699 	 *                               Accepts a mask of:
       
  1700 	 *                               - `EP_ALL`
       
  1701 	 *                               - `EP_NONE`
       
  1702 	 *                               - `EP_ALL_ARCHIVES`
       
  1703 	 *                               - `EP_ATTACHMENT`
       
  1704 	 *                               - `EP_AUTHORS`
       
  1705 	 *                               - `EP_CATEGORIES`
       
  1706 	 *                               - `EP_COMMENTS`
       
  1707 	 *                               - `EP_DATE`
       
  1708 	 *                               - `EP_DAY`
       
  1709 	 *                               - `EP_MONTH`
       
  1710 	 *                               - `EP_PAGES`
       
  1711 	 *                               - `EP_PERMALINK`
       
  1712 	 *                               - `EP_ROOT`
       
  1713 	 *                               - `EP_SEARCH`
       
  1714 	 *                               - `EP_TAGS`
       
  1715 	 *                               - `EP_YEAR`
  1684 	 * @param string|bool $query_var Optional. Name of the corresponding query variable. Pass `false` to
  1716 	 * @param string|bool $query_var Optional. Name of the corresponding query variable. Pass `false` to
  1685 	 *                               skip registering a query_var for this endpoint. Defaults to the
  1717 	 *                               skip registering a query_var for this endpoint. Defaults to the
  1686 	 *                               value of `$name`.
  1718 	 *                               value of `$name`.
  1687 	 */
  1719 	 */
  1688 	public function add_endpoint( $name, $places, $query_var = true ) {
  1720 	public function add_endpoint( $name, $places, $query_var = true ) {
  1722 	 *     Default empty array.
  1754 	 *     Default empty array.
  1723 	 *
  1755 	 *
  1724 	 *     @type bool $with_front  Whether the structure should be prepended with `WP_Rewrite::$front`.
  1756 	 *     @type bool $with_front  Whether the structure should be prepended with `WP_Rewrite::$front`.
  1725 	 *                             Default true.
  1757 	 *                             Default true.
  1726 	 *     @type int  $ep_mask     The endpoint mask defining which endpoints are added to the structure.
  1758 	 *     @type int  $ep_mask     The endpoint mask defining which endpoints are added to the structure.
  1727 	 *                             Accepts `EP_NONE`, `EP_PERMALINK`, `EP_ATTACHMENT`, `EP_DATE`, `EP_YEAR`,
  1759 	 *                             Accepts a mask of:
  1728 	 *                             `EP_MONTH`, `EP_DAY`, `EP_ROOT`, `EP_COMMENTS`, `EP_SEARCH`, `EP_CATEGORIES`,
  1760 	 *                             - `EP_ALL`
  1729 	 *                             `EP_TAGS`, `EP_AUTHORS`, `EP_PAGES`, `EP_ALL_ARCHIVES`, and `EP_ALL`.
  1761 	 *                             - `EP_NONE`
       
  1762 	 *                             - `EP_ALL_ARCHIVES`
       
  1763 	 *                             - `EP_ATTACHMENT`
       
  1764 	 *                             - `EP_AUTHORS`
       
  1765 	 *                             - `EP_CATEGORIES`
       
  1766 	 *                             - `EP_COMMENTS`
       
  1767 	 *                             - `EP_DATE`
       
  1768 	 *                             - `EP_DAY`
       
  1769 	 *                             - `EP_MONTH`
       
  1770 	 *                             - `EP_PAGES`
       
  1771 	 *                             - `EP_PERMALINK`
       
  1772 	 *                             - `EP_ROOT`
       
  1773 	 *                             - `EP_SEARCH`
       
  1774 	 *                             - `EP_TAGS`
       
  1775 	 *                             - `EP_YEAR`
  1730 	 *                             Default `EP_NONE`.
  1776 	 *                             Default `EP_NONE`.
  1731 	 *     @type bool $paged       Whether archive pagination rules should be added for the structure.
  1777 	 *     @type bool $paged       Whether archive pagination rules should be added for the structure.
  1732 	 *                             Default true.
  1778 	 *                             Default true.
  1733 	 *     @type bool $feed        Whether feed rewrite rules should be added for the structure. Default true.
  1779 	 *     @type bool $feed        Whether feed rewrite rules should be added for the structure. Default true.
  1734 	 *     @type bool $forcomments Whether the feed rules should be a query for a comments feed. Default false.
  1780 	 *     @type bool $forcomments Whether the feed rules should be a query for a comments feed. Default false.