]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/rewrite.php
Wordpress 2.9
[autoinstalls/wordpress.git] / wp-includes / rewrite.php
index c84b5205ed3cf7f76cf60ab93ad643e35e8f7844..4c8d9e68cad3acf74c684cd0cbad243de10b128d 100644 (file)
@@ -299,7 +299,7 @@ function url_to_postid($url) {
                        $query = preg_replace("!^.+\?!", '', $query);
 
                        // Substitute the substring matches into the query.
                        $query = preg_replace("!^.+\?!", '', $query);
 
                        // Substitute the substring matches into the query.
-                       eval("\$query = \"" . addslashes($query) . "\";");
+                       $query = addslashes(WP_MatchesMapRegex::apply($query, $matches));
                        // Filter out non-public query vars
                        global $wp;
                        parse_str($query, $query_vars);
                        // Filter out non-public query vars
                        global $wp;
                        parse_str($query, $query_vars);
@@ -1060,6 +1060,8 @@ class WP_Rewrite {
         * @return string|bool False if not found. Permalink structure string.
         */
        function get_extra_permastruct($name) {
         * @return string|bool False if not found. Permalink structure string.
         */
        function get_extra_permastruct($name) {
+               if ( empty($this->permalink_structure) )
+                       return false;
                if ( isset($this->extra_permastructs[$name]) )
                        return $this->extra_permastructs[$name];
                return false;
                if ( isset($this->extra_permastructs[$name]) )
                        return $this->extra_permastructs[$name];
                return false;
@@ -1442,10 +1444,10 @@ class WP_Rewrite {
                                        $subcommentquery = $subquery . '&cpage=' . $this->preg_index(2);
 
                                        //do endpoints for attachments
                                        $subcommentquery = $subquery . '&cpage=' . $this->preg_index(2);
 
                                        //do endpoints for attachments
-                                       if ( !empty($endpoint) ) { foreach ( (array) $ep_query_append as $regex => $ep ) {
+                                       if ( !empty($endpoints) ) { foreach ( (array) $ep_query_append as $regex => $ep ) {
                                                if ($ep[0] & EP_ATTACHMENT) {
                                                if ($ep[0] & EP_ATTACHMENT) {
-                                                       $rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
-                                                       $rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
+                                                       $rewrite[$sub1 . $regex] = $subquery . $ep[1] . $this->preg_index(2);
+                                                       $rewrite[$sub2 . $regex] = $subquery . $ep[1] . $this->preg_index(2);
                                                }
                                        } }
 
                                                }
                                        } }
 
@@ -1607,11 +1609,11 @@ class WP_Rewrite {
         * @return array Rewrite rules.
         */
        function wp_rewrite_rules() {
         * @return array Rewrite rules.
         */
        function wp_rewrite_rules() {
-               $this->rules = get_transient('rewrite_rules');
+               $this->rules = get_option('rewrite_rules');
                if ( empty($this->rules) ) {
                        $this->matches = 'matches';
                        $this->rewrite_rules();
                if ( empty($this->rules) ) {
                        $this->matches = 'matches';
                        $this->rewrite_rules();
-                       set_transient('rewrite_rules', $this->rules);
+                       update_option('rewrite_rules', $this->rules);
                }
 
                return $this->rules;
                }
 
                return $this->rules;
@@ -1715,19 +1717,37 @@ class WP_Rewrite {
         *
         * @return string
         */
         *
         * @return string
         */
-       function iis7_url_rewrite_rules(){
+       function iis7_url_rewrite_rules($add_parent_tags = false, $indent = "  ", $end_of_line = "\n") {
 
                if ( ! $this->using_permalinks()) {
                        return '';
                }
 
                if ( ! $this->using_permalinks()) {
                        return '';
                }
-               $rules  = "<rule name=\"wordpress\" patternSyntax=\"Wildcard\">\n";
-               $rules .= "     <match url=\"*\" />\n";
-               $rules .= "     <conditions>\n";
-               $rules .= "             <add input=\"{REQUEST_FILENAME}\" matchType=\"IsFile\" negate=\"true\" />\n";
-               $rules .= "             <add input=\"{REQUEST_FILENAME}\" matchType=\"IsDirectory\" negate=\"true\" />\n";
-               $rules .= "     </conditions>\n";
-               $rules .= "     <action type=\"Rewrite\" url=\"index.php\" />\n";
-               $rules .= "</rule>";
+               
+               $rules = '';
+               $extra_indent = '';
+               if ( $add_parent_tags ) {
+                       $rules .= "<configuration>".$end_of_line;
+                       $rules .= $indent."<system.webServer>".$end_of_line;
+                       $rules .= $indent.$indent."<rewrite>".$end_of_line;
+                       $rules .= $indent.$indent.$indent."<rules>".$end_of_line;
+                       $extra_indent = $indent.$indent.$indent.$indent;
+               }
+               
+               $rules .= $extra_indent."<rule name=\"wordpress\" patternSyntax=\"Wildcard\">".$end_of_line;
+               $rules .= $extra_indent.$indent."<match url=\"*\" />".$end_of_line;
+               $rules .= $extra_indent.$indent.$indent."<conditions>".$end_of_line;
+               $rules .= $extra_indent.$indent.$indent.$indent."<add input=\"{REQUEST_FILENAME}\" matchType=\"IsFile\" negate=\"true\" />".$end_of_line;
+               $rules .= $extra_indent.$indent.$indent.$indent."<add input=\"{REQUEST_FILENAME}\" matchType=\"IsDirectory\" negate=\"true\" />".$end_of_line;
+               $rules .= $extra_indent.$indent.$indent."</conditions>".$end_of_line;
+               $rules .= $extra_indent.$indent."<action type=\"Rewrite\" url=\"index.php\" />".$end_of_line;
+               $rules .= $extra_indent."</rule>";
+               
+               if ( $add_parent_tags ) {
+                       $rules .= $end_of_line.$indent.$indent.$indent."</rules>".$end_of_line;
+                       $rules .= $indent.$indent."</rewrite>".$end_of_line;
+                       $rules .= $indent."</system.webServer>".$end_of_line;
+                       $rules .= "</configuration>";
+               }
 
                $rules = apply_filters('iis7_url_rewrite_rules', $rules);
 
 
                $rules = apply_filters('iis7_url_rewrite_rules', $rules);
 
@@ -1822,13 +1842,14 @@ class WP_Rewrite {
         *
         * @since 2.0.1
         * @access public
         *
         * @since 2.0.1
         * @access public
+        * @param $hard bool Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard).
         */
         */
-       function flush_rules() {
-               delete_transient('rewrite_rules');
+       function flush_rules($hard = true) {
+               delete_option('rewrite_rules');
                $this->wp_rewrite_rules();
                $this->wp_rewrite_rules();
-               if ( function_exists('save_mod_rewrite_rules') )
+               if ( $hard && function_exists('save_mod_rewrite_rules') )
                        save_mod_rewrite_rules();
                        save_mod_rewrite_rules();
-               if ( function_exists('iis7_save_url_rewrite_rules') )
+               if ( $hard && function_exists('iis7_save_url_rewrite_rules') )
                        iis7_save_url_rewrite_rules();
        }
 
                        iis7_save_url_rewrite_rules();
        }