wp/wp-includes/rewrite.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
   224  * Add an endpoint, like /trackback/.
   224  * Add an endpoint, like /trackback/.
   225  *
   225  *
   226  * Adding an endpoint creates extra rewrite rules for each of the matching
   226  * Adding an endpoint creates extra rewrite rules for each of the matching
   227  * places specified by the provided bitmask. For example:
   227  * places specified by the provided bitmask. For example:
   228  *
   228  *
   229  * <code>
   229  *     add_rewrite_endpoint( 'json', EP_PERMALINK | EP_PAGES );
   230  * add_rewrite_endpoint( 'json', EP_PERMALINK | EP_PAGES );
       
   231  * </code>
       
   232  *
   230  *
   233  * will add a new rewrite rule ending with "json(/(.*))?/?$" for every permastruct
   231  * will add a new rewrite rule ending with "json(/(.*))?/?$" for every permastruct
   234  * that describes a permalink (post) or page. This is rewritten to "json=$match"
   232  * that describes a permalink (post) or page. This is rewritten to "json=$match"
   235  * where $match is the part of the URL matched by the endpoint regex (e.g. "foo" in
   233  * where $match is the part of the URL matched by the endpoint regex (e.g. "foo" in
   236  * "<permalink>/json/foo/").
   234  * "[permalink]/json/foo/").
   237  *
   235  *
   238  * A new query var with the same name as the endpoint will also be created.
   236  * A new query var with the same name as the endpoint will also be created.
   239  *
   237  *
   240  * When specifying $places ensure that you are using the EP_* constants (or a
   238  * When specifying $places ensure that you are using the EP_* constants (or a
   241  * combination of them using the bitwise OR operator) as their values are not
   239  * combination of them using the bitwise OR operator) as their values are not
   242  * guaranteed to remain static (especially EP_ALL).
   240  * guaranteed to remain static (especially `EP_ALL`).
   243  *
   241  *
   244  * Be sure to flush the rewrite rules - flush_rewrite_rules() - when your plugin gets
   242  * Be sure to flush the rewrite rules - {@see flush_rewrite_rules()} - when your plugin gets
   245  * activated and deactivated.
   243  * activated and deactivated.
   246  *
   244  *
   247  * @since 2.1.0
   245  * @since 2.1.0
   248  * @see WP_Rewrite::add_endpoint()
   246  * @see WP_Rewrite::add_endpoint()
   249  * @global object $wp_rewrite
   247  * @global object $wp_rewrite
   250  *
   248  *
   251  * @param string $name Name of the endpoint.
   249  * @param string $name Name of the endpoint.
   252  * @param int $places Endpoint mask describing the places the endpoint should be added.
   250  * @param int $places Endpoint mask describing the places the endpoint should be added.
   253  */
   251  * @param string $query_var Name of the corresponding query variable. Defaults to $name.
   254 function add_rewrite_endpoint( $name, $places ) {
   252  */
       
   253 function add_rewrite_endpoint( $name, $places, $query_var = null ) {
   255 	global $wp_rewrite;
   254 	global $wp_rewrite;
   256 	$wp_rewrite->add_endpoint( $name, $places );
   255 	$wp_rewrite->add_endpoint( $name, $places, $query_var );
   257 }
   256 }
   258 
   257 
   259 /**
   258 /**
   260  * Filter the URL base for taxonomies.
   259  * Filter the URL base for taxonomies.
   261  *
   260  *
   286  * @return int Post ID, or 0 on failure.
   285  * @return int Post ID, or 0 on failure.
   287  */
   286  */
   288 function url_to_postid($url) {
   287 function url_to_postid($url) {
   289 	global $wp_rewrite;
   288 	global $wp_rewrite;
   290 
   289 
   291 	$url = apply_filters('url_to_postid', $url);
   290 	/**
       
   291 	 * Filter the URL to derive the post ID from.
       
   292 	 *
       
   293 	 * @since 2.2.0
       
   294 	 *
       
   295 	 * @param string $url The URL to derive the post ID from.
       
   296 	 */
       
   297 	$url = apply_filters( 'url_to_postid', $url );
   292 
   298 
   293 	// First, check to see if there is a 'p=N' or 'page_id=N' to match against
   299 	// First, check to see if there is a 'p=N' or 'page_id=N' to match against
   294 	if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) )	{
   300 	if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) )	{
   295 		$id = absint($values[2]);
   301 		$id = absint($values[2]);
   296 		if ( $id )
   302 		if ( $id )
   352 		// If the requesting file is the anchor of the match, prepend it
   358 		// If the requesting file is the anchor of the match, prepend it
   353 		// to the path info.
   359 		// to the path info.
   354 		if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) )
   360 		if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) )
   355 			$request_match = $url . '/' . $request;
   361 			$request_match = $url . '/' . $request;
   356 
   362 
   357 		if ( preg_match("!^$match!", $request_match, $matches) ) {
   363 		if ( preg_match("#^$match#", $request_match, $matches) ) {
   358 
   364 
   359 			if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
   365 			if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
   360 				// this is a verbose page match, lets check to be sure about it
   366 				// This is a verbose page match, let's check to be sure about it.
   361 				if ( ! get_page_by_path( $matches[ $varmatch[1] ] ) )
   367 				if ( ! get_page_by_path( $matches[ $varmatch[1] ] ) )
   362 					continue;
   368 					continue;
   363 			}
   369 			}
   364 
   370 
   365 			// Got a match.
   371 			// Got a match.
   412 class WP_Rewrite {
   418 class WP_Rewrite {
   413 	/**
   419 	/**
   414 	 * Permalink structure for posts.
   420 	 * Permalink structure for posts.
   415 	 *
   421 	 *
   416 	 * @since 1.5.0
   422 	 * @since 1.5.0
       
   423 	 * @var string
       
   424 	 */
       
   425 	public $permalink_structure;
       
   426 
       
   427 	/**
       
   428 	 * Whether to add trailing slashes.
       
   429 	 *
       
   430 	 * @since 2.2.0
       
   431 	 * @var bool
       
   432 	 */
       
   433 	public $use_trailing_slashes;
       
   434 
       
   435 	/**
       
   436 	 * Base for the author permalink structure (example.com/$author_base/authorname).
       
   437 	 *
       
   438 	 * @since 1.5.0
   417 	 * @access private
   439 	 * @access private
   418 	 * @var string
   440 	 * @var string
   419 	 */
   441 	 */
   420 	var $permalink_structure;
   442 	var $author_base = 'author';
   421 
   443 
   422 	/**
   444 	/**
   423 	 * Whether to add trailing slashes.
   445 	 * Permalink structure for author archives.
   424 	 *
       
   425 	 * @since 2.2.0
       
   426 	 * @access private
       
   427 	 * @var bool
       
   428 	 */
       
   429 	var $use_trailing_slashes;
       
   430 
       
   431 	/**
       
   432 	 * Base for the author permalink structure (example.com/$author_base/authorname).
       
   433 	 *
   446 	 *
   434 	 * @since 1.5.0
   447 	 * @since 1.5.0
   435 	 * @access private
   448 	 * @access private
   436 	 * @var string
   449 	 * @var string
   437 	 */
   450 	 */
   438 	var $author_base = 'author';
   451 	var $author_structure;
   439 
   452 
   440 	/**
   453 	/**
   441 	 * Permalink structure for author archives.
   454 	 * Permalink structure for date archives.
   442 	 *
   455 	 *
   443 	 * @since 1.5.0
   456 	 * @since 1.5.0
   444 	 * @access private
   457 	 * @access private
   445 	 * @var string
   458 	 * @var string
   446 	 */
   459 	 */
   447 	var $author_structure;
   460 	var $date_structure;
   448 
   461 
   449 	/**
   462 	/**
   450 	 * Permalink structure for date archives.
   463 	 * Permalink structure for pages.
   451 	 *
   464 	 *
   452 	 * @since 1.5.0
   465 	 * @since 1.5.0
   453 	 * @access private
   466 	 * @access private
   454 	 * @var string
   467 	 * @var string
   455 	 */
   468 	 */
   456 	var $date_structure;
   469 	var $page_structure;
   457 
   470 
   458 	/**
   471 	/**
   459 	 * Permalink structure for pages.
   472 	 * Base of the search permalink structure (example.com/$search_base/query).
   460 	 *
   473 	 *
   461 	 * @since 1.5.0
   474 	 * @since 1.5.0
   462 	 * @access private
   475 	 * @access private
   463 	 * @var string
   476 	 * @var string
   464 	 */
   477 	 */
   465 	var $page_structure;
   478 	var $search_base = 'search';
   466 
   479 
   467 	/**
   480 	/**
   468 	 * Base of the search permalink structure (example.com/$search_base/query).
   481 	 * Permalink structure for searches.
   469 	 *
   482 	 *
   470 	 * @since 1.5.0
   483 	 * @since 1.5.0
   471 	 * @access private
   484 	 * @access private
   472 	 * @var string
   485 	 * @var string
   473 	 */
   486 	 */
   474 	var $search_base = 'search';
   487 	var $search_structure;
   475 
   488 
   476 	/**
   489 	/**
   477 	 * Permalink structure for searches.
   490 	 * Comments permalink base.
   478 	 *
   491 	 *
   479 	 * @since 1.5.0
   492 	 * @since 1.5.0
   480 	 * @access private
   493 	 * @access private
   481 	 * @var string
   494 	 * @var string
   482 	 */
   495 	 */
   483 	var $search_structure;
   496 	var $comments_base = 'comments';
   484 
   497 
   485 	/**
   498 	/**
   486 	 * Comments permalink base.
   499 	 * Pagination permalink base.
   487 	 *
   500 	 *
   488 	 * @since 1.5.0
   501 	 * @since 3.1.0
       
   502 	 * @var string
       
   503 	 */
       
   504 	public $pagination_base = 'page';
       
   505 
       
   506 	/**
       
   507 	 * Comments pagination permalink base.
       
   508 	 *
       
   509 	 * @since 4.2.0
   489 	 * @access private
   510 	 * @access private
   490 	 * @var string
   511 	 * @var string
   491 	 */
   512 	 */
   492 	var $comments_base = 'comments';
   513 	var $comments_pagination_base = 'comment-page';
   493 
   514 
   494 	/**
   515 	/**
   495 	 * Pagination permalink base.
   516 	 * Feed permalink base.
   496 	 *
   517 	 *
   497 	 * @since 3.1.0
   518 	 * @since 1.5.0
   498 	 * @access private
   519 	 * @access private
   499 	 * @var string
   520 	 * @var string
   500 	 */
   521 	 */
   501 	var $pagination_base = 'page';
   522 	var $feed_base = 'feed';
   502 
   523 
   503 	/**
   524 	/**
   504 	 * Feed permalink base.
   525 	 * Comments feed permalink structure.
   505 	 *
   526 	 *
   506 	 * @since 1.5.0
   527 	 * @since 1.5.0
   507 	 * @access private
   528 	 * @access private
   508 	 * @var string
   529 	 * @var string
   509 	 */
   530 	 */
   510 	var $feed_base = 'feed';
   531 	var $comment_feed_structure;
   511 
       
   512 	/**
       
   513 	 * Comments feed permalink structure.
       
   514 	 *
       
   515 	 * @since 1.5.0
       
   516 	 * @access private
       
   517 	 * @var string
       
   518 	 */
       
   519 	var $comments_feed_structure;
       
   520 
   532 
   521 	/**
   533 	/**
   522 	 * Feed request permalink structure.
   534 	 * Feed request permalink structure.
   523 	 *
   535 	 *
   524 	 * @since 1.5.0
   536 	 * @since 1.5.0
   534 	 * is "/archive/". If the permalink structure is "/%year%/%postname%/"
   546 	 * is "/archive/". If the permalink structure is "/%year%/%postname%/"
   535 	 * then the front is "/".
   547 	 * then the front is "/".
   536 	 *
   548 	 *
   537 	 * @see WP_Rewrite::init()
   549 	 * @see WP_Rewrite::init()
   538 	 * @since 1.5.0
   550 	 * @since 1.5.0
   539 	 * @access private
       
   540 	 * @var string
   551 	 * @var string
   541 	 */
   552 	 */
   542 	var $front;
   553 	public $front;
   543 
   554 
   544 	/**
   555 	/**
   545 	 * The prefix for all permalink structures.
   556 	 * The prefix for all permalink structures.
   546 	 *
   557 	 *
   547 	 * If PATHINFO/index permalinks are in use then the root is the value of
   558 	 * If PATHINFO/index permalinks are in use then the root is the value of
   549 	 * the root will be empty.
   560 	 * the root will be empty.
   550 	 *
   561 	 *
   551 	 * @see WP_Rewrite::init()
   562 	 * @see WP_Rewrite::init()
   552 	 * @see WP_Rewrite::using_index_permalinks()
   563 	 * @see WP_Rewrite::using_index_permalinks()
   553 	 * @since 1.5.0
   564 	 * @since 1.5.0
   554 	 * @access private
       
   555 	 * @var string
   565 	 * @var string
   556 	 */
   566 	 */
   557 	var $root = '';
   567 	public $root = '';
   558 
   568 
   559 	/**
   569 	/**
   560 	 * The name of the index file which is the entry point to all requests.
   570 	 * The name of the index file which is the entry point to all requests.
   561 	 *
   571 	 *
   562 	 * @since 1.5.0
   572 	 * @since 1.5.0
   563 	 * @access public
   573 	 * @access public
   564 	 * @var string
   574 	 * @var string
   565 	 */
   575 	 */
   566 	var $index = 'index.php';
   576 	public $index = 'index.php';
   567 
   577 
   568 	/**
   578 	/**
   569 	 * Variable name to use for regex matches in the rewritten query.
   579 	 * Variable name to use for regex matches in the rewritten query.
   570 	 *
   580 	 *
   571 	 * @since 1.5.0
   581 	 * @since 1.5.0
   644 	 * @see WP_Rewrite::mod_rewrite_rules()
   654 	 * @see WP_Rewrite::mod_rewrite_rules()
   645 	 * @since 2.0.0
   655 	 * @since 2.0.0
   646 	 * @access public
   656 	 * @access public
   647 	 * @var bool
   657 	 * @var bool
   648 	 */
   658 	 */
   649 	var $use_verbose_rules = false;
   659 	public $use_verbose_rules = false;
   650 
   660 
   651 	/**
   661 	/**
   652 	 * Could post permalinks be confused with those of pages?
   662 	 * Could post permalinks be confused with those of pages?
   653 	 *
   663 	 *
   654 	 * If the first rewrite tag in the post permalink structure is one that could
   664 	 * If the first rewrite tag in the post permalink structure is one that could
   656 	 * set to true. Prior to WordPress 3.3 this flag indicated that every page
   666 	 * set to true. Prior to WordPress 3.3 this flag indicated that every page
   657 	 * would have a set of rules added to the top of the rewrite rules array.
   667 	 * would have a set of rules added to the top of the rewrite rules array.
   658 	 * Now it tells {@link WP::parse_request()} to check if a URL matching the
   668 	 * Now it tells {@link WP::parse_request()} to check if a URL matching the
   659 	 * page permastruct is actually a page before accepting it.
   669 	 * page permastruct is actually a page before accepting it.
   660 	 *
   670 	 *
   661 	 * @link http://core.trac.wordpress.org/ticket/16687
   671 	 * @link https://core.trac.wordpress.org/ticket/16687
   662 	 * @see WP_Rewrite::init()
   672 	 * @see WP_Rewrite::init()
   663 	 * @since 2.5.0
   673 	 * @since 2.5.0
   664 	 * @access public
   674 	 * @access public
   665 	 * @var bool
   675 	 * @var bool
   666 	 */
   676 	 */
   667 	var $use_verbose_page_rules = true;
   677 	public $use_verbose_page_rules = true;
   668 
   678 
   669 	/**
   679 	/**
   670 	 * Rewrite tags that can be used in permalink structures.
   680 	 * Rewrite tags that can be used in permalink structures.
   671 	 *
   681 	 *
   672 	 * These are translated into the regular expressions stored in
   682 	 * These are translated into the regular expressions stored in
   738 
   748 
   739 	/**
   749 	/**
   740 	 * Supported default feeds.
   750 	 * Supported default feeds.
   741 	 *
   751 	 *
   742 	 * @since 1.5.0
   752 	 * @since 1.5.0
   743 	 * @access private
       
   744 	 * @var array
   753 	 * @var array
   745 	 */
   754 	 */
   746 	var $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
   755 	public $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
   747 
   756 
   748 	/**
   757 	/**
   749 	 * Whether permalinks are being used.
   758 	 * Whether permalinks are being used.
   750 	 *
   759 	 *
   751 	 * This can be either rewrite module or permalink in the HTTP query string.
   760 	 * This can be either rewrite module or permalink in the HTTP query string.
   753 	 * @since 1.5.0
   762 	 * @since 1.5.0
   754 	 * @access public
   763 	 * @access public
   755 	 *
   764 	 *
   756 	 * @return bool True, if permalinks are enabled.
   765 	 * @return bool True, if permalinks are enabled.
   757 	 */
   766 	 */
   758 	function using_permalinks() {
   767 	public function using_permalinks() {
   759 		return ! empty($this->permalink_structure);
   768 		return ! empty($this->permalink_structure);
   760 	}
   769 	}
   761 
   770 
   762 	/**
   771 	/**
   763 	 * Whether permalinks are being used and rewrite module is not enabled.
   772 	 * Whether permalinks are being used and rewrite module is not enabled.
   767 	 * @since 1.5.0
   776 	 * @since 1.5.0
   768 	 * @access public
   777 	 * @access public
   769 	 *
   778 	 *
   770 	 * @return bool
   779 	 * @return bool
   771 	 */
   780 	 */
   772 	function using_index_permalinks() {
   781 	public function using_index_permalinks() {
   773 		if ( empty($this->permalink_structure) )
   782 		if ( empty($this->permalink_structure) )
   774 			return false;
   783 			return false;
   775 
   784 
   776 		// If the index is not in the permalink, we're using mod_rewrite.
   785 		// If the index is not in the permalink, we're using mod_rewrite.
   777 		if ( preg_match('#^/*' . $this->index . '#', $this->permalink_structure) )
   786 		if ( preg_match('#^/*' . $this->index . '#', $this->permalink_structure) )
   788 	 * @since 1.5.0
   797 	 * @since 1.5.0
   789 	 * @access public
   798 	 * @access public
   790 	 *
   799 	 *
   791 	 * @return bool
   800 	 * @return bool
   792 	 */
   801 	 */
   793 	function using_mod_rewrite_permalinks() {
   802 	public function using_mod_rewrite_permalinks() {
   794 		if ( $this->using_permalinks() && ! $this->using_index_permalinks() )
   803 		if ( $this->using_permalinks() && ! $this->using_index_permalinks() )
   795 			return true;
   804 			return true;
   796 		else
   805 		else
   797 			return false;
   806 			return false;
   798 	}
   807 	}
   811 	 * @access public
   820 	 * @access public
   812 	 *
   821 	 *
   813 	 * @param int $number Index number.
   822 	 * @param int $number Index number.
   814 	 * @return string
   823 	 * @return string
   815 	 */
   824 	 */
   816 	function preg_index($number) {
   825 	public function preg_index($number) {
   817 		$match_prefix = '$';
   826 		$match_prefix = '$';
   818 		$match_suffix = '';
   827 		$match_suffix = '';
   819 
   828 
   820 		if ( ! empty($this->matches) ) {
   829 		if ( ! empty($this->matches) ) {
   821 			$match_prefix = '$' . $this->matches . '[';
   830 			$match_prefix = '$' . $this->matches . '[';
   834 	 * @since 2.5.0
   843 	 * @since 2.5.0
   835 	 * @access public
   844 	 * @access public
   836 	 *
   845 	 *
   837 	 * @return array Array of page URIs as first element and attachment URIs as second element.
   846 	 * @return array Array of page URIs as first element and attachment URIs as second element.
   838 	 */
   847 	 */
   839 	function page_uri_index() {
   848 	public function page_uri_index() {
   840 		global $wpdb;
   849 		global $wpdb;
   841 
   850 
   842 		//get pages in order of hierarchy, i.e. children after parents
   851 		//get pages in order of hierarchy, i.e. children after parents
   843 		$pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'page' AND post_status != 'auto-draft'");
   852 		$pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'page' AND post_status != 'auto-draft'");
   844 		$posts = get_page_hierarchy( $pages );
   853 		$posts = get_page_hierarchy( $pages );
   876 	 * @since 1.5.0
   885 	 * @since 1.5.0
   877 	 * @access public
   886 	 * @access public
   878 	 *
   887 	 *
   879 	 * @return array
   888 	 * @return array
   880 	 */
   889 	 */
   881 	function page_rewrite_rules() {
   890 	public function page_rewrite_rules() {
   882 		// the extra .? at the beginning prevents clashes with other regular expressions in the rules array
   891 		// the extra .? at the beginning prevents clashes with other regular expressions in the rules array
   883 		$this->add_rewrite_tag( '%pagename%', '(.?.+?)', 'pagename=' );
   892 		$this->add_rewrite_tag( '%pagename%', '(.?.+?)', 'pagename=' );
   884 
   893 
   885 		return $this->generate_rewrite_rules( $this->get_page_permastruct(), EP_PAGES, true, true, false, false );
   894 		return $this->generate_rewrite_rules( $this->get_page_permastruct(), EP_PAGES, true, true, false, false );
   886 	}
   895 	}
   901 	 * structure.
   910 	 * structure.
   902 	 *
   911 	 *
   903 	 * @since 1.5.0
   912 	 * @since 1.5.0
   904 	 * @access public
   913 	 * @access public
   905 	 *
   914 	 *
   906 	 * @return bool|string False on no permalink structure. Date permalink structure.
   915 	 * @return string|false False on no permalink structure. Date permalink structure.
   907 	 */
   916 	 */
   908 	function get_date_permastruct() {
   917 	public function get_date_permastruct() {
   909 		if ( isset($this->date_structure) )
   918 		if ( isset($this->date_structure) )
   910 			return $this->date_structure;
   919 			return $this->date_structure;
   911 
   920 
   912 		if ( empty($this->permalink_structure) ) {
   921 		if ( empty($this->permalink_structure) ) {
   913 			$this->date_structure = '';
   922 			$this->date_structure = '';
   955 	 * permalink structures.
   964 	 * permalink structures.
   956 	 *
   965 	 *
   957 	 * @since 1.5.0
   966 	 * @since 1.5.0
   958 	 * @access public
   967 	 * @access public
   959 	 *
   968 	 *
   960 	 * @return bool|string False on failure. Year structure on success.
   969 	 * @return false|string False on failure. Year structure on success.
   961 	 */
   970 	 */
   962 	function get_year_permastruct() {
   971 	public function get_year_permastruct() {
   963 		$structure = $this->get_date_permastruct();
   972 		$structure = $this->get_date_permastruct();
   964 
   973 
   965 		if ( empty($structure) )
   974 		if ( empty($structure) )
   966 			return false;
   975 			return false;
   967 
   976 
   980 	 * structures. Keeps the year permalink structure.
   989 	 * structures. Keeps the year permalink structure.
   981 	 *
   990 	 *
   982 	 * @since 1.5.0
   991 	 * @since 1.5.0
   983 	 * @access public
   992 	 * @access public
   984 	 *
   993 	 *
   985 	 * @return bool|string False on failure. Year/Month structure on success.
   994 	 * @return false|string False on failure. Year/Month structure on success.
   986 	 */
   995 	 */
   987 	function get_month_permastruct() {
   996 	public function get_month_permastruct() {
   988 		$structure = $this->get_date_permastruct();
   997 		$structure = $this->get_date_permastruct();
   989 
   998 
   990 		if ( empty($structure) )
   999 		if ( empty($structure) )
   991 			return false;
  1000 			return false;
   992 
  1001 
  1003 	 * Keeps date permalink structure with all year, month, and day.
  1012 	 * Keeps date permalink structure with all year, month, and day.
  1004 	 *
  1013 	 *
  1005 	 * @since 1.5.0
  1014 	 * @since 1.5.0
  1006 	 * @access public
  1015 	 * @access public
  1007 	 *
  1016 	 *
  1008 	 * @return bool|string False on failure. Year/Month/Day structure on success.
  1017 	 * @return string|false False on failure. Year/Month/Day structure on success.
  1009 	 */
  1018 	 */
  1010 	function get_day_permastruct() {
  1019 	public function get_day_permastruct() {
  1011 		return $this->get_date_permastruct();
  1020 		return $this->get_date_permastruct();
  1012 	}
  1021 	}
  1013 
  1022 
  1014 	/**
  1023 	/**
  1015 	 * Retrieve the permalink structure for categories.
  1024 	 * Retrieve the permalink structure for categories.
  1022 	 * @since 1.5.0
  1031 	 * @since 1.5.0
  1023 	 * @access public
  1032 	 * @access public
  1024 	 *
  1033 	 *
  1025 	 * @return bool|string False on failure. Category permalink structure.
  1034 	 * @return bool|string False on failure. Category permalink structure.
  1026 	 */
  1035 	 */
  1027 	function get_category_permastruct() {
  1036 	public function get_category_permastruct() {
  1028 		return $this->get_extra_permastruct('category');
  1037 		return $this->get_extra_permastruct('category');
  1029 	}
  1038 	}
  1030 
  1039 
  1031 	/**
  1040 	/**
  1032 	 * Retrieve the permalink structure for tags.
  1041 	 * Retrieve the permalink structure for tags.
  1039 	 * @since 2.3.0
  1048 	 * @since 2.3.0
  1040 	 * @access public
  1049 	 * @access public
  1041 	 *
  1050 	 *
  1042 	 * @return bool|string False on failure. Tag permalink structure.
  1051 	 * @return bool|string False on failure. Tag permalink structure.
  1043 	 */
  1052 	 */
  1044 	function get_tag_permastruct() {
  1053 	public function get_tag_permastruct() {
  1045 		return $this->get_extra_permastruct('post_tag');
  1054 		return $this->get_extra_permastruct('post_tag');
  1046 	}
  1055 	}
  1047 
  1056 
  1048 	/**
  1057 	/**
  1049 	 * Retrieve extra permalink structure by name.
  1058 	 * Retrieve extra permalink structure by name.
  1052 	 * @access public
  1061 	 * @access public
  1053 	 *
  1062 	 *
  1054 	 * @param string $name Permalink structure name.
  1063 	 * @param string $name Permalink structure name.
  1055 	 * @return string|bool False if not found. Permalink structure string.
  1064 	 * @return string|bool False if not found. Permalink structure string.
  1056 	 */
  1065 	 */
  1057 	function get_extra_permastruct($name) {
  1066 	public function get_extra_permastruct($name) {
  1058 		if ( empty($this->permalink_structure) )
  1067 		if ( empty($this->permalink_structure) )
  1059 			return false;
  1068 			return false;
  1060 
  1069 
  1061 		if ( isset($this->extra_permastructs[$name]) )
  1070 		if ( isset($this->extra_permastructs[$name]) )
  1062 			return $this->extra_permastructs[$name]['struct'];
  1071 			return $this->extra_permastructs[$name]['struct'];
  1072 	 * without attempting to set the value again.
  1081 	 * without attempting to set the value again.
  1073 	 *
  1082 	 *
  1074 	 * @since 1.5.0
  1083 	 * @since 1.5.0
  1075 	 * @access public
  1084 	 * @access public
  1076 	 *
  1085 	 *
  1077 	 * @return string|bool False if not found. Permalink structure string.
  1086 	 * @return string|false False if not found. Permalink structure string.
  1078 	 */
  1087 	 */
  1079 	function get_author_permastruct() {
  1088 	public function get_author_permastruct() {
  1080 		if ( isset($this->author_structure) )
  1089 		if ( isset($this->author_structure) )
  1081 			return $this->author_structure;
  1090 			return $this->author_structure;
  1082 
  1091 
  1083 		if ( empty($this->permalink_structure) ) {
  1092 		if ( empty($this->permalink_structure) ) {
  1084 			$this->author_structure = '';
  1093 			$this->author_structure = '';
  1098 	 * without attempting to set the value again.
  1107 	 * without attempting to set the value again.
  1099 	 *
  1108 	 *
  1100 	 * @since 1.5.0
  1109 	 * @since 1.5.0
  1101 	 * @access public
  1110 	 * @access public
  1102 	 *
  1111 	 *
  1103 	 * @return string|bool False if not found. Permalink structure string.
  1112 	 * @return string|false False if not found. Permalink structure string.
  1104 	 */
  1113 	 */
  1105 	function get_search_permastruct() {
  1114 	public function get_search_permastruct() {
  1106 		if ( isset($this->search_structure) )
  1115 		if ( isset($this->search_structure) )
  1107 			return $this->search_structure;
  1116 			return $this->search_structure;
  1108 
  1117 
  1109 		if ( empty($this->permalink_structure) ) {
  1118 		if ( empty($this->permalink_structure) ) {
  1110 			$this->search_structure = '';
  1119 			$this->search_structure = '';
  1124 	 * value again.
  1133 	 * value again.
  1125 	 *
  1134 	 *
  1126 	 * @since 1.5.0
  1135 	 * @since 1.5.0
  1127 	 * @access public
  1136 	 * @access public
  1128 	 *
  1137 	 *
  1129 	 * @return string|bool False if not found. Permalink structure string.
  1138 	 * @return string|false False if not found. Permalink structure string.
  1130 	 */
  1139 	 */
  1131 	function get_page_permastruct() {
  1140 	public function get_page_permastruct() {
  1132 		if ( isset($this->page_structure) )
  1141 		if ( isset($this->page_structure) )
  1133 			return $this->page_structure;
  1142 			return $this->page_structure;
  1134 
  1143 
  1135 		if (empty($this->permalink_structure)) {
  1144 		if (empty($this->permalink_structure)) {
  1136 			$this->page_structure = '';
  1145 			$this->page_structure = '';
  1150 	 * without attempting to set the value again.
  1159 	 * without attempting to set the value again.
  1151 	 *
  1160 	 *
  1152 	 * @since 1.5.0
  1161 	 * @since 1.5.0
  1153 	 * @access public
  1162 	 * @access public
  1154 	 *
  1163 	 *
  1155 	 * @return string|bool False if not found. Permalink structure string.
  1164 	 * @return string|false False if not found. Permalink structure string.
  1156 	 */
  1165 	 */
  1157 	function get_feed_permastruct() {
  1166 	public function get_feed_permastruct() {
  1158 		if ( isset($this->feed_structure) )
  1167 		if ( isset($this->feed_structure) )
  1159 			return $this->feed_structure;
  1168 			return $this->feed_structure;
  1160 
  1169 
  1161 		if ( empty($this->permalink_structure) ) {
  1170 		if ( empty($this->permalink_structure) ) {
  1162 			$this->feed_structure = '';
  1171 			$this->feed_structure = '';
  1178 	 * @since 1.5.0
  1187 	 * @since 1.5.0
  1179 	 * @access public
  1188 	 * @access public
  1180 	 *
  1189 	 *
  1181 	 * @return string|bool False if not found. Permalink structure string.
  1190 	 * @return string|bool False if not found. Permalink structure string.
  1182 	 */
  1191 	 */
  1183 	function get_comment_feed_permastruct() {
  1192 	public function get_comment_feed_permastruct() {
  1184 		if ( isset($this->comment_feed_structure) )
  1193 		if ( isset($this->comment_feed_structure) )
  1185 			return $this->comment_feed_structure;
  1194 			return $this->comment_feed_structure;
  1186 
  1195 
  1187 		if (empty($this->permalink_structure)) {
  1196 		if (empty($this->permalink_structure)) {
  1188 			$this->comment_feed_structure = '';
  1197 			$this->comment_feed_structure = '';
  1208 	 *
  1217 	 *
  1209 	 * @param string $tag Name of the rewrite tag to add or update.
  1218 	 * @param string $tag Name of the rewrite tag to add or update.
  1210 	 * @param string $regex Regular expression to substitute the tag for in rewrite rules.
  1219 	 * @param string $regex Regular expression to substitute the tag for in rewrite rules.
  1211 	 * @param string $query String to append to the rewritten query. Must end in '='.
  1220 	 * @param string $query String to append to the rewritten query. Must end in '='.
  1212 	 */
  1221 	 */
  1213 	function add_rewrite_tag( $tag, $regex, $query ) {
  1222 	public function add_rewrite_tag( $tag, $regex, $query ) {
  1214 		$position = array_search( $tag, $this->rewritecode );
  1223 		$position = array_search( $tag, $this->rewritecode );
  1215 		if ( false !== $position && null !== $position ) {
  1224 		if ( false !== $position && null !== $position ) {
  1216 			$this->rewritereplace[ $position ] = $regex;
  1225 			$this->rewritereplace[ $position ] = $regex;
  1217 			$this->queryreplace[ $position ] = $query;
  1226 			$this->queryreplace[ $position ] = $query;
  1218 		} else {
  1227 		} else {
  1240 	 * @param bool $walk_dirs Should the 'directories' making up the structure be walked over and rewrite rules
  1249 	 * @param bool $walk_dirs Should the 'directories' making up the structure be walked over and rewrite rules
  1241 	 *                        built for each in turn? Default is true.
  1250 	 *                        built for each in turn? Default is true.
  1242 	 * @param bool $endpoints Should endpoints be applied to the generated rewrite rules? Default is true.
  1251 	 * @param bool $endpoints Should endpoints be applied to the generated rewrite rules? Default is true.
  1243 	 * @return array Rewrite rule list.
  1252 	 * @return array Rewrite rule list.
  1244 	 */
  1253 	 */
  1245 	function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
  1254 	public function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
  1246 		//build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
  1255 		//build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
  1247 		$feedregex2 = '';
  1256 		$feedregex2 = '';
  1248 		foreach ( (array) $this->feeds as $feed_name)
  1257 		foreach ( (array) $this->feeds as $feed_name)
  1249 			$feedregex2 .= $feed_name . '|';
  1258 			$feedregex2 .= $feed_name . '|';
  1250 		$feedregex2 = '(' . trim($feedregex2, '|') . ')/?$';
  1259 		$feedregex2 = '(' . trim($feedregex2, '|') . ')/?$';
  1254 		$feedregex = $this->feed_base . '/' . $feedregex2;
  1263 		$feedregex = $this->feed_base . '/' . $feedregex2;
  1255 
  1264 
  1256 		//build a regex to match the trackback and page/xx parts of URLs
  1265 		//build a regex to match the trackback and page/xx parts of URLs
  1257 		$trackbackregex = 'trackback/?$';
  1266 		$trackbackregex = 'trackback/?$';
  1258 		$pageregex = $this->pagination_base . '/?([0-9]{1,})/?$';
  1267 		$pageregex = $this->pagination_base . '/?([0-9]{1,})/?$';
  1259 		$commentregex = 'comment-page-([0-9]{1,})/?$';
  1268 		$commentregex = $this->comments_pagination_base . '-([0-9]{1,})/?$';
  1260 
  1269 
  1261 		//build up an array of endpoint regexes to append => queries to append
  1270 		//build up an array of endpoint regexes to append => queries to append
  1262 		if ( $endpoints ) {
  1271 		if ( $endpoints ) {
  1263 			$ep_query_append = array ();
  1272 			$ep_query_append = array ();
  1264 			foreach ( (array) $this->endpoints as $endpoint) {
  1273 			foreach ( (array) $this->endpoints as $endpoint) {
  1265 				//match everything after the endpoint name, but allow for nothing to appear there
  1274 				//match everything after the endpoint name, but allow for nothing to appear there
  1266 				$epmatch = $endpoint[1] . '(/(.*))?/?$';
  1275 				$epmatch = $endpoint[1] . '(/(.*))?/?$';
  1267 				//this will be appended on to the rest of the query for each dir
  1276 				//this will be appended on to the rest of the query for each dir
  1268 				$epquery = '&' . $endpoint[1] . '=';
  1277 				$epquery = '&' . $endpoint[2] . '=';
  1269 				$ep_query_append[$epmatch] = array ( $endpoint[0], $epquery );
  1278 				$ep_query_append[$epmatch] = array ( $endpoint[0], $epquery );
  1270 			}
  1279 			}
  1271 		}
  1280 		}
  1272 
  1281 
  1273 		//get everything up to the first rewrite tag
  1282 		//get everything up to the first rewrite tag
  1280 		$index = $this->index; //probably 'index.php'
  1289 		$index = $this->index; //probably 'index.php'
  1281 		$feedindex = $index;
  1290 		$feedindex = $index;
  1282 		$trackbackindex = $index;
  1291 		$trackbackindex = $index;
  1283 		//build a list from the rewritecode and queryreplace arrays, that will look something like
  1292 		//build a list from the rewritecode and queryreplace arrays, that will look something like
  1284 		//tagname=$matches[i] where i is the current $i
  1293 		//tagname=$matches[i] where i is the current $i
       
  1294 		$queries = array();
  1285 		for ( $i = 0; $i < $num_tokens; ++$i ) {
  1295 		for ( $i = 0; $i < $num_tokens; ++$i ) {
  1286 			if ( 0 < $i )
  1296 			if ( 0 < $i )
  1287 				$queries[$i] = $queries[$i - 1] . '&';
  1297 				$queries[$i] = $queries[$i - 1] . '&';
  1288 			else
  1298 			else
  1289 				$queries[$i] = '';
  1299 				$queries[$i] = '';
  1320 
  1330 
  1321 			//make a list of tags, and store how many there are in $num_toks
  1331 			//make a list of tags, and store how many there are in $num_toks
  1322 			$num_toks = preg_match_all('/%.+?%/', $struct, $toks);
  1332 			$num_toks = preg_match_all('/%.+?%/', $struct, $toks);
  1323 
  1333 
  1324 			//get the 'tagname=$matches[i]'
  1334 			//get the 'tagname=$matches[i]'
  1325 			$query = ( isset($queries) && is_array($queries) && !empty($num_toks) ) ? $queries[$num_toks - 1] : '';
  1335 			$query = ( ! empty( $num_toks ) && isset( $queries[$num_toks - 1] ) ) ? $queries[$num_toks - 1] : '';
  1326 
  1336 
  1327 			//set up $ep_mask_specific which is used to match more specific URL types
  1337 			//set up $ep_mask_specific which is used to match more specific URL types
  1328 			switch ( $dirs[$j] ) {
  1338 			switch ( $dirs[$j] ) {
  1329 				case '%year%':
  1339 				case '%year%':
  1330 					$ep_mask_specific = EP_YEAR;
  1340 					$ep_mask_specific = EP_YEAR;
  1373 				$rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
  1383 				$rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
  1374 			if ( $paged ) //...and /page/xx ones
  1384 			if ( $paged ) //...and /page/xx ones
  1375 				$rewrite = array_merge($rewrite, array($pagematch => $pagequery));
  1385 				$rewrite = array_merge($rewrite, array($pagematch => $pagequery));
  1376 
  1386 
  1377 			//only on pages with comments add ../comment-page-xx/
  1387 			//only on pages with comments add ../comment-page-xx/
  1378 			if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask )
  1388 			if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask ) {
  1379 				$rewrite = array_merge($rewrite, array($commentmatch => $commentquery));
  1389 				$rewrite = array_merge($rewrite, array($commentmatch => $commentquery));
  1380 			else if ( EP_ROOT & $ep_mask && get_option('page_on_front') )
  1390 			} elseif ( EP_ROOT & $ep_mask && get_option('page_on_front') ) {
  1381 				$rewrite = array_merge($rewrite, array($rootcommentmatch => $rootcommentquery));
  1391 				$rewrite = array_merge($rewrite, array($rootcommentmatch => $rootcommentquery));
  1382 
  1392 			}
  1383 			//do endpoints
  1393 			//do endpoints
  1384 			if ( $endpoints ) {
  1394 			if ( $endpoints ) {
  1385 				foreach ( (array) $ep_query_append as $regex => $ep) {
  1395 				foreach ( (array) $ep_query_append as $regex => $ep) {
  1386 					//add the endpoints on if the mask fits
  1396 					//add the endpoints on if the mask fits
  1387 					if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific )
  1397 					if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific )
  1510 	 *
  1520 	 *
  1511 	 * @param string $permalink_structure The permalink structure to generate rules.
  1521 	 * @param string $permalink_structure The permalink structure to generate rules.
  1512 	 * @param bool $walk_dirs Optional, default is false. Whether to create list of directories to walk over.
  1522 	 * @param bool $walk_dirs Optional, default is false. Whether to create list of directories to walk over.
  1513 	 * @return array
  1523 	 * @return array
  1514 	 */
  1524 	 */
  1515 	function generate_rewrite_rule($permalink_structure, $walk_dirs = false) {
  1525 	public function generate_rewrite_rule($permalink_structure, $walk_dirs = false) {
  1516 		return $this->generate_rewrite_rules($permalink_structure, EP_NONE, false, false, false, $walk_dirs);
  1526 		return $this->generate_rewrite_rules($permalink_structure, EP_NONE, false, false, false, $walk_dirs);
  1517 	}
  1527 	}
  1518 
  1528 
  1519 	/**
  1529 	/**
  1520 	 * Construct rewrite matches and queries from permalink structure.
  1530 	 * Construct rewrite matches and queries from permalink structure.
  1532 	 * @since 1.5.0
  1542 	 * @since 1.5.0
  1533 	 * @access public
  1543 	 * @access public
  1534 	 *
  1544 	 *
  1535 	 * @return array An associate array of matches and queries.
  1545 	 * @return array An associate array of matches and queries.
  1536 	 */
  1546 	 */
  1537 	function rewrite_rules() {
  1547 	public function rewrite_rules() {
  1538 		$rewrite = array();
  1548 		$rewrite = array();
  1539 
  1549 
  1540 		if ( empty($this->permalink_structure) )
  1550 		if ( empty($this->permalink_structure) )
  1541 			return $rewrite;
  1551 			return $rewrite;
  1542 
  1552 
  1556 			$registration_pages['.*wp-signup.php$'] = $this->index . '?signup=true';
  1566 			$registration_pages['.*wp-signup.php$'] = $this->index . '?signup=true';
  1557 			$registration_pages['.*wp-activate.php$'] = $this->index . '?activate=true';
  1567 			$registration_pages['.*wp-activate.php$'] = $this->index . '?activate=true';
  1558 		}
  1568 		}
  1559 		$registration_pages['.*wp-register.php$'] = $this->index . '?register=true'; // Deprecated
  1569 		$registration_pages['.*wp-register.php$'] = $this->index . '?register=true'; // Deprecated
  1560 
  1570 
  1561 		// Post
  1571 		// Post rewrite rules.
  1562 		$post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK );
  1572 		$post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK );
  1563 		$post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
  1573 
  1564 
  1574 		/**
  1565 		// Date
  1575 		 * Filter rewrite rules used for "post" archives.
       
  1576 		 *
       
  1577 		 * @since 1.5.0
       
  1578 		 *
       
  1579 		 * @param array $post_rewrite The rewrite rules for posts.
       
  1580 		 */
       
  1581 		$post_rewrite = apply_filters( 'post_rewrite_rules', $post_rewrite );
       
  1582 
       
  1583 		// Date rewrite rules.
  1566 		$date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE);
  1584 		$date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE);
  1567 		$date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);
  1585 
  1568 
  1586 		/**
  1569 		// Root
  1587 		 * Filter rewrite rules used for date archives.
       
  1588 		 *
       
  1589 		 * Likely date archives would include /yyyy/, /yyyy/mm/, and /yyyy/mm/dd/.
       
  1590 		 *
       
  1591 		 * @since 1.5.0
       
  1592 		 *
       
  1593 		 * @param array $date_rewrite The rewrite rules for date archives.
       
  1594 		 */
       
  1595 		$date_rewrite = apply_filters( 'date_rewrite_rules', $date_rewrite );
       
  1596 
       
  1597 		// Root-level rewrite rules.
  1570 		$root_rewrite = $this->generate_rewrite_rules($this->root . '/', EP_ROOT);
  1598 		$root_rewrite = $this->generate_rewrite_rules($this->root . '/', EP_ROOT);
  1571 		$root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
  1599 
  1572 
  1600 		/**
  1573 		// Comments
  1601 		 * Filter rewrite rules used for root-level archives.
       
  1602 		 *
       
  1603 		 * Likely root-level archives would include pagination rules for the homepage
       
  1604 		 * as well as site-wide post feeds (e.g. /feed/, and /feed/atom/).
       
  1605 		 *
       
  1606 		 * @since 1.5.0
       
  1607 		 *
       
  1608 		 * @param array $root_rewrite The root-level rewrite rules.
       
  1609 		 */
       
  1610 		$root_rewrite = apply_filters( 'root_rewrite_rules', $root_rewrite );
       
  1611 
       
  1612 		// Comments rewrite rules.
  1574 		$comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, EP_COMMENTS, false, true, true, false);
  1613 		$comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, EP_COMMENTS, false, true, true, false);
  1575 		$comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
  1614 
  1576 
  1615 		/**
  1577 		// Search
  1616 		 * Filter rewrite rules used for comment feed archives.
       
  1617 		 *
       
  1618 		 * Likely comments feed archives include /comments/feed/, and /comments/feed/atom/.
       
  1619 		 *
       
  1620 		 * @since 1.5.0
       
  1621 		 *
       
  1622 		 * @param array $comments_rewrite The rewrite rules for the site-wide comments feeds.
       
  1623 		 */
       
  1624 		$comments_rewrite = apply_filters( 'comments_rewrite_rules', $comments_rewrite );
       
  1625 
       
  1626 		// Search rewrite rules.
  1578 		$search_structure = $this->get_search_permastruct();
  1627 		$search_structure = $this->get_search_permastruct();
  1579 		$search_rewrite = $this->generate_rewrite_rules($search_structure, EP_SEARCH);
  1628 		$search_rewrite = $this->generate_rewrite_rules($search_structure, EP_SEARCH);
  1580 		$search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
  1629 
  1581 
  1630 		/**
  1582 		// Authors
  1631 		 * Filter rewrite rules used for search archives.
       
  1632 		 *
       
  1633 		 * Likely search-related archives include /search/search+query/ as well as
       
  1634 		 * pagination and feed paths for a search.
       
  1635 		 *
       
  1636 		 * @since 1.5.0
       
  1637 		 *
       
  1638 		 * @param array $search_rewrite The rewrite rules for search queries.
       
  1639 		 */
       
  1640 		$search_rewrite = apply_filters( 'search_rewrite_rules', $search_rewrite );
       
  1641 
       
  1642 		// Author rewrite rules.
  1583 		$author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS);
  1643 		$author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS);
  1584 		$author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
  1644 
  1585 
  1645 		/**
  1586 		// Pages
  1646 		 * Filter rewrite rules used for author archives.
       
  1647 		 *
       
  1648 		 * Likely author archives would include /author/author-name/, as well as
       
  1649 		 * pagination and feed paths for author archives.
       
  1650 		 *
       
  1651 		 * @since 1.5.0
       
  1652 		 *
       
  1653 		 * @param array $author_rewrite The rewrite rules for author archives.
       
  1654 		 */
       
  1655 		$author_rewrite = apply_filters( 'author_rewrite_rules', $author_rewrite );
       
  1656 
       
  1657 		// Pages rewrite rules.
  1587 		$page_rewrite = $this->page_rewrite_rules();
  1658 		$page_rewrite = $this->page_rewrite_rules();
  1588 		$page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
  1659 
  1589 
  1660 		/**
  1590 		// Extra permastructs
  1661 		 * Filter rewrite rules used for "page" post type archives.
       
  1662 		 *
       
  1663 		 * @since 1.5.0
       
  1664 		 *
       
  1665 		 * @param array $page_rewrite The rewrite rules for the "page" post type.
       
  1666 		 */
       
  1667 		$page_rewrite = apply_filters( 'page_rewrite_rules', $page_rewrite );
       
  1668 
       
  1669 		// Extra permastructs.
  1591 		foreach ( $this->extra_permastructs as $permastructname => $struct ) {
  1670 		foreach ( $this->extra_permastructs as $permastructname => $struct ) {
  1592 			if ( is_array( $struct ) ) {
  1671 			if ( is_array( $struct ) ) {
  1593 				if ( count( $struct ) == 2 )
  1672 				if ( count( $struct ) == 2 )
  1594 					$rules = $this->generate_rewrite_rules( $struct[0], $struct[1] );
  1673 					$rules = $this->generate_rewrite_rules( $struct[0], $struct[1] );
  1595 				else
  1674 				else
  1596 					$rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] );
  1675 					$rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] );
  1597 			} else {
  1676 			} else {
  1598 				$rules = $this->generate_rewrite_rules( $struct );
  1677 				$rules = $this->generate_rewrite_rules( $struct );
  1599 			}
  1678 			}
  1600 
  1679 
  1601 			$rules = apply_filters($permastructname . '_rewrite_rules', $rules);
  1680 			/**
  1602 			if ( 'post_tag' == $permastructname )
  1681 			 * Filter rewrite rules used for individual permastructs.
  1603 				$rules = apply_filters('tag_rewrite_rules', $rules);
  1682 			 *
       
  1683 			 * The dynamic portion of the hook name, `$permastructname`, refers
       
  1684 			 * to the name of the registered permastruct, e.g. 'post_tag' (tags),
       
  1685 			 * 'category' (categories), etc.
       
  1686 			 *
       
  1687 			 * @since 3.1.0
       
  1688 			 *
       
  1689 			 * @param array $rules The rewrite rules generated for the current permastruct.
       
  1690 			 */
       
  1691 			$rules = apply_filters( $permastructname . '_rewrite_rules', $rules );
       
  1692 			if ( 'post_tag' == $permastructname ) {
       
  1693 
       
  1694 				/**
       
  1695 				 * Filter rewrite rules used specifically for Tags.
       
  1696 				 *
       
  1697 				 * @since 2.3.0
       
  1698 				 * @deprecated 3.1.0 Use 'post_tag_rewrite_rules' instead
       
  1699 				 *
       
  1700 				 * @param array $rules The rewrite rules generated for tags.
       
  1701 				 */
       
  1702 				$rules = apply_filters( 'tag_rewrite_rules', $rules );
       
  1703 			}
  1604 
  1704 
  1605 			$this->extra_rules_top = array_merge($this->extra_rules_top, $rules);
  1705 			$this->extra_rules_top = array_merge($this->extra_rules_top, $rules);
  1606 		}
  1706 		}
  1607 
  1707 
  1608 		// Put them together.
  1708 		// Put them together.
  1609 		if ( $this->use_verbose_page_rules )
  1709 		if ( $this->use_verbose_page_rules )
  1610 			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules);
  1710 			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules);
  1611 		else
  1711 		else
  1612 			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
  1712 			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
  1613 
  1713 
  1614 		do_action_ref_array('generate_rewrite_rules', array(&$this));
  1714 		/**
  1615 		$this->rules = apply_filters('rewrite_rules_array', $this->rules);
  1715 		 * Fires after the rewrite rules are generated.
       
  1716 		 *
       
  1717 		 * @since 1.5.0
       
  1718 		 *
       
  1719 		 * @param WP_Rewrite $this Current WP_Rewrite instance, passed by reference.
       
  1720 		 */
       
  1721 		do_action_ref_array( 'generate_rewrite_rules', array( &$this ) );
       
  1722 
       
  1723 		/**
       
  1724 		 * Filter the full set of generated rewrite rules.
       
  1725 		 *
       
  1726 		 * @since 1.5.0
       
  1727 		 *
       
  1728 		 * @param array $this->rules The compiled array of rewrite rules.
       
  1729 		 */
       
  1730 		$this->rules = apply_filters( 'rewrite_rules_array', $this->rules );
  1616 
  1731 
  1617 		return $this->rules;
  1732 		return $this->rules;
  1618 	}
  1733 	}
  1619 
  1734 
  1620 	/**
  1735 	/**
  1629 	 * @since 1.5.0
  1744 	 * @since 1.5.0
  1630 	 * @access public
  1745 	 * @access public
  1631 	 *
  1746 	 *
  1632 	 * @return array Rewrite rules.
  1747 	 * @return array Rewrite rules.
  1633 	 */
  1748 	 */
  1634 	function wp_rewrite_rules() {
  1749 	public function wp_rewrite_rules() {
  1635 		$this->rules = get_option('rewrite_rules');
  1750 		$this->rules = get_option('rewrite_rules');
  1636 		if ( empty($this->rules) ) {
  1751 		if ( empty($this->rules) ) {
  1637 			$this->matches = 'matches';
  1752 			$this->matches = 'matches';
  1638 			$this->rewrite_rules();
  1753 			$this->rewrite_rules();
  1639 			update_option('rewrite_rules', $this->rules);
  1754 			update_option('rewrite_rules', $this->rules);
  1654 	 * @since 1.5.0
  1769 	 * @since 1.5.0
  1655 	 * @access public
  1770 	 * @access public
  1656 	 *
  1771 	 *
  1657 	 * @return string
  1772 	 * @return string
  1658 	 */
  1773 	 */
  1659 	function mod_rewrite_rules() {
  1774 	public function mod_rewrite_rules() {
  1660 		if ( ! $this->using_permalinks() )
  1775 		if ( ! $this->using_permalinks() )
  1661 			return '';
  1776 			return '';
  1662 
  1777 
  1663 		$site_root = parse_url( site_url() );
  1778 		$site_root = parse_url( site_url() );
  1664 		if ( isset( $site_root['path'] ) )
  1779 		if ( isset( $site_root['path'] ) )
  1718 				"RewriteRule . {$home_root}{$this->index} [L]\n";
  1833 				"RewriteRule . {$home_root}{$this->index} [L]\n";
  1719 		}
  1834 		}
  1720 
  1835 
  1721 		$rules .= "</IfModule>\n";
  1836 		$rules .= "</IfModule>\n";
  1722 
  1837 
  1723 		$rules = apply_filters('mod_rewrite_rules', $rules);
  1838 		/**
  1724 		$rules = apply_filters('rewrite_rules', $rules);  // Deprecated
  1839 		 *
       
  1840 		 * Filter the list of rewrite rules formatted for output to an .htaccess file.
       
  1841 		 *
       
  1842 		 * @since 1.5.0
       
  1843 		 *
       
  1844 		 * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
       
  1845 		 */
       
  1846 		$rules = apply_filters( 'mod_rewrite_rules', $rules );
       
  1847 
       
  1848 		/**
       
  1849 		 * Filter the list of rewrite rules formatted for output to an .htaccess file.
       
  1850 		 *
       
  1851 		 * @since 1.5.0
       
  1852 		 * @deprecated 1.5.0 Use the mod_rewrite_rules filter instead.
       
  1853 		 *
       
  1854 		 * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
       
  1855 		 */
       
  1856 		$rules = apply_filters( 'rewrite_rules', $rules );  // Deprecated
  1725 
  1857 
  1726 		return $rules;
  1858 		return $rules;
  1727 	}
  1859 	}
  1728 
  1860 
  1729 	/**
  1861 	/**
  1735 	 * @since 2.8.0
  1867 	 * @since 2.8.0
  1736 	 * @access public
  1868 	 * @access public
  1737 	 *
  1869 	 *
  1738 	 * @return string
  1870 	 * @return string
  1739 	 */
  1871 	 */
  1740 	function iis7_url_rewrite_rules( $add_parent_tags = false ) {
  1872 	public function iis7_url_rewrite_rules( $add_parent_tags = false ) {
  1741 
  1873 
  1742 		if ( ! $this->using_permalinks() )
  1874 		if ( ! $this->using_permalinks() )
  1743 			return '';
  1875 			return '';
  1744 		$rules = '';
  1876 		$rules = '';
  1745 		if ( $add_parent_tags ) {
  1877 		if ( $add_parent_tags ) {
  1765 		</rewrite>
  1897 		</rewrite>
  1766 	</system.webServer>
  1898 	</system.webServer>
  1767 </configuration>';
  1899 </configuration>';
  1768 		}
  1900 		}
  1769 
  1901 
  1770 		$rules = apply_filters('iis7_url_rewrite_rules', $rules);
  1902 		/**
       
  1903 		 * Filter the list of rewrite rules formatted for output to a web.config.
       
  1904 		 *
       
  1905 		 * @since 2.8.0
       
  1906 		 *
       
  1907 		 * @param string $rules Rewrite rules formatted for IIS web.config.
       
  1908 		 */
       
  1909 		$rules = apply_filters( 'iis7_url_rewrite_rules', $rules );
  1771 
  1910 
  1772 		return $rules;
  1911 		return $rules;
  1773 	}
  1912 	}
  1774 
  1913 
  1775 	/**
  1914 	/**
  1783 	 *
  1922 	 *
  1784 	 * @param string $regex Regular expression to match against request.
  1923 	 * @param string $regex Regular expression to match against request.
  1785 	 * @param string $redirect URL regex redirects to when regex matches request.
  1924 	 * @param string $redirect URL regex redirects to when regex matches request.
  1786 	 * @param string $after Optional, default is bottom. Location to place rule.
  1925 	 * @param string $after Optional, default is bottom. Location to place rule.
  1787 	 */
  1926 	 */
  1788 	function add_rule($regex, $redirect, $after = 'bottom') {
  1927 	public function add_rule($regex, $redirect, $after = 'bottom') {
  1789 		//get everything up to the first ?
  1928 		//get everything up to the first ?
  1790 		$index = (strpos($redirect, '?') == false ? strlen($redirect) : strpos($redirect, '?'));
  1929 		$index = (strpos($redirect, '?') == false ? strlen($redirect) : strpos($redirect, '?'));
  1791 		$front = substr($redirect, 0, $index);
  1930 		$front = substr($redirect, 0, $index);
  1792 		if ( $front != $this->index ) { //it doesn't redirect to WP's index.php
  1931 		if ( $front != $this->index ) { //it doesn't redirect to WP's index.php
  1793 			$this->add_external_rule($regex, $redirect);
  1932 			$this->add_external_rule($regex, $redirect);
  1809 	 * @access public
  1948 	 * @access public
  1810 	 *
  1949 	 *
  1811 	 * @param string $regex Regular expression to match against request.
  1950 	 * @param string $regex Regular expression to match against request.
  1812 	 * @param string $redirect URL regex redirects to when regex matches request.
  1951 	 * @param string $redirect URL regex redirects to when regex matches request.
  1813 	 */
  1952 	 */
  1814 	function add_external_rule($regex, $redirect) {
  1953 	public function add_external_rule($regex, $redirect) {
  1815 		$this->non_wp_rules[$regex] = $redirect;
  1954 		$this->non_wp_rules[$regex] = $redirect;
  1816 	}
  1955 	}
  1817 
  1956 
  1818 	/**
  1957 	/**
  1819 	 * Add an endpoint, like /trackback/.
  1958 	 * Add an endpoint, like /trackback/.
  1820 	 *
  1959 	 *
  1821 	 * See {@link add_rewrite_endpoint()} for full documentation.
       
  1822 	 *
       
  1823 	 * @see add_rewrite_endpoint()
       
  1824 	 * @since 2.1.0
  1960 	 * @since 2.1.0
  1825 	 * @access public
  1961 	 * @since 3.9.0 $query_var parameter added.
       
  1962 	 * @access public
       
  1963 	 *
       
  1964 	 * @see add_rewrite_endpoint() for full documentation.
  1826 	 * @uses WP::add_query_var()
  1965 	 * @uses WP::add_query_var()
  1827 	 *
  1966 	 *
  1828 	 * @param string $name Name of the endpoint.
  1967 	 * @param string $name      Name of the endpoint.
  1829 	 * @param int $places Endpoint mask describing the places the endpoint should be added.
  1968 	 * @param int    $places    Endpoint mask describing the places the endpoint should be added.
  1830 	 */
  1969 	 * @param string $query_var Name of the corresponding query variable. Default is value of $name.
  1831 	function add_endpoint($name, $places) {
  1970 	 */
       
  1971 	public function add_endpoint( $name, $places, $query_var = null ) {
  1832 		global $wp;
  1972 		global $wp;
  1833 		$this->endpoints[] = array ( $places, $name );
  1973 		if ( null === $query_var ) {
  1834 		$wp->add_query_var($name);
  1974 			$query_var = $name;
       
  1975 		}
       
  1976 		$this->endpoints[] = array( $places, $name, $query_var );
       
  1977 		$wp->add_query_var( $query_var );
  1835 	}
  1978 	}
  1836 
  1979 
  1837 	/**
  1980 	/**
  1838 	 * Add a new permalink structure.
  1981 	 * Add a new permalink structure.
  1839 	 *
  1982 	 *
  1860 	 *     - forcomments (bool) - Should the feed rules be a query for a comments feed? Default is false.
  2003 	 *     - forcomments (bool) - Should the feed rules be a query for a comments feed? Default is false.
  1861 	 *     - walk_dirs (bool) - Should the 'directories' making up the structure be walked over and rewrite
  2004 	 *     - walk_dirs (bool) - Should the 'directories' making up the structure be walked over and rewrite
  1862 	 *                          rules built for each in turn? Default is true.
  2005 	 *                          rules built for each in turn? Default is true.
  1863 	 *     - endpoints (bool) - Should endpoints be applied to the generated rewrite rules? Default is true.
  2006 	 *     - endpoints (bool) - Should endpoints be applied to the generated rewrite rules? Default is true.
  1864 	 */
  2007 	 */
  1865 	function add_permastruct( $name, $struct, $args = array() ) {
  2008 	public function add_permastruct( $name, $struct, $args = array() ) {
  1866 		// backwards compatibility for the old parameters: $with_front and $ep_mask
  2009 		// backwards compatibility for the old parameters: $with_front and $ep_mask
  1867 		if ( ! is_array( $args ) )
  2010 		if ( ! is_array( $args ) )
  1868 			$args = array( 'with_front' => $args );
  2011 			$args = array( 'with_front' => $args );
  1869 		if ( func_num_args() == 4 )
  2012 		if ( func_num_args() == 4 )
  1870 			$args['ep_mask'] = func_get_arg( 3 );
  2013 			$args['ep_mask'] = func_get_arg( 3 );
  1899 	 *
  2042 	 *
  1900 	 * @since 2.0.1
  2043 	 * @since 2.0.1
  1901 	 * @access public
  2044 	 * @access public
  1902 	 * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard).
  2045 	 * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard).
  1903 	 */
  2046 	 */
  1904 	function flush_rules($hard = true) {
  2047 	public function flush_rules( $hard = true ) {
       
  2048 		static $do_hard_later;
       
  2049 
       
  2050 		// Prevent this action from running before everyone has registered their rewrites
       
  2051 		if ( ! did_action( 'wp_loaded' ) ) {
       
  2052 			add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
       
  2053 			$do_hard_later = ( isset( $do_hard_later ) ) ? $do_hard_later || $hard : $hard;
       
  2054 			return;
       
  2055 		}
       
  2056 
       
  2057 		if ( isset( $do_hard_later ) ) {
       
  2058 			$hard = $do_hard_later;
       
  2059 			unset( $do_hard_later );
       
  2060 		}
       
  2061 
  1905 		delete_option('rewrite_rules');
  2062 		delete_option('rewrite_rules');
  1906 		$this->wp_rewrite_rules();
  2063 		$this->wp_rewrite_rules();
  1907 		/**
  2064 		/**
  1908 		 * Filter whether a "hard" rewrite rule flush should be performed when requested.
  2065 		 * Filter whether a "hard" rewrite rule flush should be performed when requested.
  1909 		 *
  2066 		 *
  1910 		 * A "hard" flush updates .htaccess (Apache) or web.config (IIS).
  2067 		 * A "hard" flush updates .htaccess (Apache) or web.config (IIS).
  1911 		 *
  2068 		 *
  1912 		 * @since 3.7.0
  2069 		 * @since 3.7.0
  1913 		 * @param bool $hard Defaults to true.
  2070 		 *
       
  2071 		 * @param bool $hard Whether to flush rewrite rules "hard". Default true.
  1914 		 */
  2072 		 */
  1915 		if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) )
  2073 		if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) {
  1916 			return;
  2074 			return;
       
  2075 		}
  1917 		if ( function_exists( 'save_mod_rewrite_rules' ) )
  2076 		if ( function_exists( 'save_mod_rewrite_rules' ) )
  1918 			save_mod_rewrite_rules();
  2077 			save_mod_rewrite_rules();
  1919 		if ( function_exists( 'iis7_save_url_rewrite_rules' ) )
  2078 		if ( function_exists( 'iis7_save_url_rewrite_rules' ) )
  1920 			iis7_save_url_rewrite_rules();
  2079 			iis7_save_url_rewrite_rules();
  1921 	}
  2080 	}
  1928 	 * '%tag%', or '%author%'.
  2087 	 * '%tag%', or '%author%'.
  1929 	 *
  2088 	 *
  1930 	 * @since 1.5.0
  2089 	 * @since 1.5.0
  1931 	 * @access public
  2090 	 * @access public
  1932 	 */
  2091 	 */
  1933 	function init() {
  2092 	public function init() {
  1934 		$this->extra_rules = $this->non_wp_rules = $this->endpoints = array();
  2093 		$this->extra_rules = $this->non_wp_rules = $this->endpoints = array();
  1935 		$this->permalink_structure = get_option('permalink_structure');
  2094 		$this->permalink_structure = get_option('permalink_structure');
  1936 		$this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%'));
  2095 		$this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%'));
  1937 		$this->root = '';
  2096 		$this->root = '';
  1938 		if ( $this->using_index_permalinks() )
  2097 		if ( $this->using_index_permalinks() )
  1965 	 * @since 1.5.0
  2124 	 * @since 1.5.0
  1966 	 * @access public
  2125 	 * @access public
  1967 	 *
  2126 	 *
  1968 	 * @param string $permalink_structure Permalink structure.
  2127 	 * @param string $permalink_structure Permalink structure.
  1969 	 */
  2128 	 */
  1970 	function set_permalink_structure($permalink_structure) {
  2129 	public function set_permalink_structure($permalink_structure) {
  1971 		if ( $permalink_structure != $this->permalink_structure ) {
  2130 		if ( $permalink_structure != $this->permalink_structure ) {
  1972 			$old_permalink_structure = $this->permalink_structure;
  2131 			$old_permalink_structure = $this->permalink_structure;
  1973 			update_option('permalink_structure', $permalink_structure);
  2132 			update_option('permalink_structure', $permalink_structure);
  1974 			$this->init();
  2133 			$this->init();
  1975 			do_action('permalink_structure_changed', $old_permalink_structure, $permalink_structure);
  2134 
       
  2135 			/**
       
  2136 			 * Fires after the permalink structure is updated.
       
  2137 			 *
       
  2138 			 * @since 2.8.0
       
  2139 			 *
       
  2140 			 * @param string $old_permalink_structure The previous permalink structure.
       
  2141 			 * @param string $permalink_structure     The new permalink structure.
       
  2142 			 */
       
  2143 			do_action( 'permalink_structure_changed', $old_permalink_structure, $permalink_structure );
  1976 		}
  2144 		}
  1977 	}
  2145 	}
  1978 
  2146 
  1979 	/**
  2147 	/**
  1980 	 * Set the category base for the category permalink.
  2148 	 * Set the category base for the category permalink.
  1986 	 * @since 1.5.0
  2154 	 * @since 1.5.0
  1987 	 * @access public
  2155 	 * @access public
  1988 	 *
  2156 	 *
  1989 	 * @param string $category_base Category permalink structure base.
  2157 	 * @param string $category_base Category permalink structure base.
  1990 	 */
  2158 	 */
  1991 	function set_category_base($category_base) {
  2159 	public function set_category_base($category_base) {
  1992 		if ( $category_base != get_option('category_base') ) {
  2160 		if ( $category_base != get_option('category_base') ) {
  1993 			update_option('category_base', $category_base);
  2161 			update_option('category_base', $category_base);
  1994 			$this->init();
  2162 			$this->init();
  1995 		}
  2163 		}
  1996 	}
  2164 	}
  2005 	 * @since 2.3.0
  2173 	 * @since 2.3.0
  2006 	 * @access public
  2174 	 * @access public
  2007 	 *
  2175 	 *
  2008 	 * @param string $tag_base Tag permalink structure base.
  2176 	 * @param string $tag_base Tag permalink structure base.
  2009 	 */
  2177 	 */
  2010 	function set_tag_base( $tag_base ) {
  2178 	public function set_tag_base( $tag_base ) {
  2011 		if ( $tag_base != get_option( 'tag_base') ) {
  2179 		if ( $tag_base != get_option( 'tag_base') ) {
  2012 			update_option( 'tag_base', $tag_base );
  2180 			update_option( 'tag_base', $tag_base );
  2013 			$this->init();
  2181 			$this->init();
  2014 		}
  2182 		}
  2015 	}
  2183 	}
  2018 	 * Constructor - Calls init(), which runs setup.
  2186 	 * Constructor - Calls init(), which runs setup.
  2019 	 *
  2187 	 *
  2020 	 * @since 1.5.0
  2188 	 * @since 1.5.0
  2021 	 * @access public
  2189 	 * @access public
  2022 	 *
  2190 	 *
  2023 	 * @return WP_Rewrite
  2191 	 */
  2024 	 */
  2192 	public function __construct() {
  2025 	function __construct() {
       
  2026 		$this->init();
  2193 		$this->init();
  2027 	}
  2194 	}
  2028 }
  2195 }