1058 * |
1058 * |
1059 * @param string $name Permalink structure name. |
1059 * @param string $name Permalink structure name. |
1060 * @return string|bool False if not found. Permalink structure string. |
1060 * @return string|bool False if not found. Permalink structure string. |
1061 */ |
1061 */ |
1062 function get_extra_permastruct($name) { |
1062 function get_extra_permastruct($name) { |
|
1063 if ( empty($this->permalink_structure) ) |
|
1064 return false; |
1063 if ( isset($this->extra_permastructs[$name]) ) |
1065 if ( isset($this->extra_permastructs[$name]) ) |
1064 return $this->extra_permastructs[$name]; |
1066 return $this->extra_permastructs[$name]; |
1065 return false; |
1067 return false; |
1066 } |
1068 } |
1067 |
1069 |
1440 $subtbquery = $subquery . '&tb=1'; |
1442 $subtbquery = $subquery . '&tb=1'; |
1441 $subfeedquery = $subquery . '&feed=' . $this->preg_index(2); |
1443 $subfeedquery = $subquery . '&feed=' . $this->preg_index(2); |
1442 $subcommentquery = $subquery . '&cpage=' . $this->preg_index(2); |
1444 $subcommentquery = $subquery . '&cpage=' . $this->preg_index(2); |
1443 |
1445 |
1444 //do endpoints for attachments |
1446 //do endpoints for attachments |
1445 if ( !empty($endpoint) ) { foreach ( (array) $ep_query_append as $regex => $ep ) { |
1447 if ( !empty($endpoints) ) { foreach ( (array) $ep_query_append as $regex => $ep ) { |
1446 if ($ep[0] & EP_ATTACHMENT) { |
1448 if ($ep[0] & EP_ATTACHMENT) { |
1447 $rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2); |
1449 $rewrite[$sub1 . $regex] = $subquery . $ep[1] . $this->preg_index(2); |
1448 $rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2); |
1450 $rewrite[$sub2 . $regex] = $subquery . $ep[1] . $this->preg_index(2); |
1449 } |
1451 } |
1450 } } |
1452 } } |
1451 |
1453 |
1452 //now we've finished with endpoints, finish off the $sub1 and $sub2 matches |
1454 //now we've finished with endpoints, finish off the $sub1 and $sub2 matches |
1453 $sub1 .= '?$'; |
1455 $sub1 .= '?$'; |
1605 * @access public |
1607 * @access public |
1606 * |
1608 * |
1607 * @return array Rewrite rules. |
1609 * @return array Rewrite rules. |
1608 */ |
1610 */ |
1609 function wp_rewrite_rules() { |
1611 function wp_rewrite_rules() { |
1610 $this->rules = get_transient('rewrite_rules'); |
1612 $this->rules = get_option('rewrite_rules'); |
1611 if ( empty($this->rules) ) { |
1613 if ( empty($this->rules) ) { |
1612 $this->matches = 'matches'; |
1614 $this->matches = 'matches'; |
1613 $this->rewrite_rules(); |
1615 $this->rewrite_rules(); |
1614 set_transient('rewrite_rules', $this->rules); |
1616 update_option('rewrite_rules', $this->rules); |
1615 } |
1617 } |
1616 |
1618 |
1617 return $this->rules; |
1619 return $this->rules; |
1618 } |
1620 } |
1619 |
1621 |
1713 * @since 2.8.0 |
1715 * @since 2.8.0 |
1714 * @access public |
1716 * @access public |
1715 * |
1717 * |
1716 * @return string |
1718 * @return string |
1717 */ |
1719 */ |
1718 function iis7_url_rewrite_rules(){ |
1720 function iis7_url_rewrite_rules($add_parent_tags = false, $indent = " ", $end_of_line = "\n") { |
1719 |
1721 |
1720 if ( ! $this->using_permalinks()) { |
1722 if ( ! $this->using_permalinks()) { |
1721 return ''; |
1723 return ''; |
1722 } |
1724 } |
1723 $rules = "<rule name=\"wordpress\" patternSyntax=\"Wildcard\">\n"; |
1725 |
1724 $rules .= " <match url=\"*\" />\n"; |
1726 $rules = ''; |
1725 $rules .= " <conditions>\n"; |
1727 $extra_indent = ''; |
1726 $rules .= " <add input=\"{REQUEST_FILENAME}\" matchType=\"IsFile\" negate=\"true\" />\n"; |
1728 if ( $add_parent_tags ) { |
1727 $rules .= " <add input=\"{REQUEST_FILENAME}\" matchType=\"IsDirectory\" negate=\"true\" />\n"; |
1729 $rules .= "<configuration>".$end_of_line; |
1728 $rules .= " </conditions>\n"; |
1730 $rules .= $indent."<system.webServer>".$end_of_line; |
1729 $rules .= " <action type=\"Rewrite\" url=\"index.php\" />\n"; |
1731 $rules .= $indent.$indent."<rewrite>".$end_of_line; |
1730 $rules .= "</rule>"; |
1732 $rules .= $indent.$indent.$indent."<rules>".$end_of_line; |
|
1733 $extra_indent = $indent.$indent.$indent.$indent; |
|
1734 } |
|
1735 |
|
1736 $rules .= $extra_indent."<rule name=\"wordpress\" patternSyntax=\"Wildcard\">".$end_of_line; |
|
1737 $rules .= $extra_indent.$indent."<match url=\"*\" />".$end_of_line; |
|
1738 $rules .= $extra_indent.$indent.$indent."<conditions>".$end_of_line; |
|
1739 $rules .= $extra_indent.$indent.$indent.$indent."<add input=\"{REQUEST_FILENAME}\" matchType=\"IsFile\" negate=\"true\" />".$end_of_line; |
|
1740 $rules .= $extra_indent.$indent.$indent.$indent."<add input=\"{REQUEST_FILENAME}\" matchType=\"IsDirectory\" negate=\"true\" />".$end_of_line; |
|
1741 $rules .= $extra_indent.$indent.$indent."</conditions>".$end_of_line; |
|
1742 $rules .= $extra_indent.$indent."<action type=\"Rewrite\" url=\"index.php\" />".$end_of_line; |
|
1743 $rules .= $extra_indent."</rule>"; |
|
1744 |
|
1745 if ( $add_parent_tags ) { |
|
1746 $rules .= $end_of_line.$indent.$indent.$indent."</rules>".$end_of_line; |
|
1747 $rules .= $indent.$indent."</rewrite>".$end_of_line; |
|
1748 $rules .= $indent."</system.webServer>".$end_of_line; |
|
1749 $rules .= "</configuration>"; |
|
1750 } |
1731 |
1751 |
1732 $rules = apply_filters('iis7_url_rewrite_rules', $rules); |
1752 $rules = apply_filters('iis7_url_rewrite_rules', $rules); |
1733 |
1753 |
1734 return $rules; |
1754 return $rules; |
1735 } |
1755 } |
1820 * 'rewrite_rules' option. If the function named 'save_mod_rewrite_rules' |
1840 * 'rewrite_rules' option. If the function named 'save_mod_rewrite_rules' |
1821 * exists, it will be called. |
1841 * exists, it will be called. |
1822 * |
1842 * |
1823 * @since 2.0.1 |
1843 * @since 2.0.1 |
1824 * @access public |
1844 * @access public |
1825 * @param $hard bool Whether to update .htaccess (hard flush) or just update rewrite_rules transient (soft flush). Default is true (hard). |
1845 * @param $hard bool Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). |
1826 */ |
1846 */ |
1827 function flush_rules($hard = true) { |
1847 function flush_rules($hard = true) { |
1828 delete_transient('rewrite_rules'); |
1848 delete_option('rewrite_rules'); |
1829 $this->wp_rewrite_rules(); |
1849 $this->wp_rewrite_rules(); |
1830 if ( $hard && function_exists('save_mod_rewrite_rules') ) |
1850 if ( $hard && function_exists('save_mod_rewrite_rules') ) |
1831 save_mod_rewrite_rules(); |
1851 save_mod_rewrite_rules(); |
1832 if ( $hard && function_exists('iis7_save_url_rewrite_rules') ) |
1852 if ( $hard && function_exists('iis7_save_url_rewrite_rules') ) |
1833 iis7_save_url_rewrite_rules(); |
1853 iis7_save_url_rewrite_rules(); |