]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/rewrite.php
Wordpress 3.6-scripts
[autoinstalls/wordpress.git] / wp-includes / rewrite.php
index 13808d14eee1530df62375385f21d32c197e79ad..88237e06c16575f218cfa6ccc874f32f8963aa2d 100644 (file)
@@ -89,7 +89,7 @@ function add_feed($feedname, $function) {
                $wp_rewrite->feeds[] = $feedname;
        $hook = 'do_feed_' . $feedname;
        // Remove default function hook
                $wp_rewrite->feeds[] = $feedname;
        $hook = 'do_feed_' . $feedname;
        // Remove default function hook
-       remove_action($hook, $hook, 10, 1);
+       remove_action($hook, $hook);
        add_action($hook, $function, 10, 1);
        return $hook;
 }
        add_action($hook, $function, 10, 1);
        return $hook;
 }
@@ -315,7 +315,7 @@ function url_to_postid($url) {
 
        // Strip 'index.php/' if we're not using path info permalinks
        if ( !$wp_rewrite->using_index_permalinks() )
 
        // Strip 'index.php/' if we're not using path info permalinks
        if ( !$wp_rewrite->using_index_permalinks() )
-               $url = str_replace('index.php/', '', $url);
+               $url = str_replace( $wp_rewrite->index . '/', '', $url );
 
        if ( false !== strpos($url, home_url()) ) {
                // Chop off http://domain.com
 
        if ( false !== strpos($url, home_url()) ) {
                // Chop off http://domain.com
@@ -1525,8 +1525,11 @@ class WP_Rewrite {
                $home_path = parse_url( home_url() );
                $robots_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array();
 
                $home_path = parse_url( home_url() );
                $robots_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array();
 
-               // Old feed files
-               $old_feed_files = array( '.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index . '?feed=old' );
+               // Old feed and service files
+               $deprecated_files = array(
+                       '.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index . '?feed=old',
+                       '.*wp-app\.php(/.*)?$' => $this->index . '?error=403',
+               );
 
                // Registration rules
                $registration_pages = array();
 
                // Registration rules
                $registration_pages = array();
@@ -1537,7 +1540,7 @@ class WP_Rewrite {
                $registration_pages['.*wp-register.php$'] = $this->index . '?register=true'; // Deprecated
 
                // Post
                $registration_pages['.*wp-register.php$'] = $this->index . '?register=true'; // Deprecated
 
                // Post
-               $post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK, false, true, false, false );
+               $post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK );
                $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
 
                // Date
                $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
 
                // Date
@@ -1549,7 +1552,7 @@ class WP_Rewrite {
                $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
 
                // Comments
                $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
 
                // Comments
-               $comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, EP_COMMENTS, true, true, true, false);
+               $comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, EP_COMMENTS, false, true, true, false);
                $comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
 
                // Search
                $comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
 
                // Search
@@ -1585,9 +1588,9 @@ class WP_Rewrite {
 
                // Put them together.
                if ( $this->use_verbose_page_rules )
 
                // Put them together.
                if ( $this->use_verbose_page_rules )
-                       $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $old_feed_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules);
+                       $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);
                else
                else
-                       $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $old_feed_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
+                       $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);
 
                do_action_ref_array('generate_rewrite_rules', array(&$this));
                $this->rules = apply_filters('rewrite_rules_array', $this->rules);
 
                do_action_ref_array('generate_rewrite_rules', array(&$this));
                $this->rules = apply_filters('rewrite_rules_array', $this->rules);
@@ -1638,7 +1641,7 @@ class WP_Rewrite {
                if ( ! $this->using_permalinks() )
                        return '';
 
                if ( ! $this->using_permalinks() )
                        return '';
 
-               $site_root = parse_url(get_option('siteurl'));
+               $site_root = parse_url( site_url() );
                if ( isset( $site_root['path'] ) )
                        $site_root = trailingslashit($site_root['path']);
 
                if ( isset( $site_root['path'] ) )
                        $site_root = trailingslashit($site_root['path']);
 
@@ -1726,75 +1729,17 @@ class WP_Rewrite {
                <rewrite>
                        <rules>';
                }
                <rewrite>
                        <rules>';
                }
-               if ( !is_multisite() ) {
-                       $rules .= '
-                               <rule name="wordpress" patternSyntax="Wildcard">
-                                       <match url="*" />
-                                               <conditions>
-                                                       <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
-                                                       <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
-                                               </conditions>
-                                       <action type="Rewrite" url="index.php" />
-                               </rule>';
-               } else {
-                       if (is_subdomain_install()) {
-                               $rules .= '
-                               <rule name="wordpress - Rule 1" stopProcessing="true">
-                                       <match url="^index\.php$" ignoreCase="false" />
-                                       <action type="None" />
-                               </rule>
-                               <rule name="wordpress - Rule 2" stopProcessing="true">
-                                       <match url="^files/(.+)" ignoreCase="false" />
-                                       <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
-                               </rule>
-                               <rule name="wordpress - Rule 3" stopProcessing="true">
-                                       <match url="^" ignoreCase="false" />
-                                       <conditions logicalGrouping="MatchAny">
-                                               <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
-                                               <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
-                                       </conditions>
-                                       <action type="None" />
-                               </rule>
-                               <rule name="wordpress - Rule 4" stopProcessing="true">
-                                       <match url="." ignoreCase="false" />
-                                       <action type="Rewrite" url="index.php" />
-                               </rule>';
-                       } else {
-                               $rules .= '
-                               <rule name="wordpress - Rule 1" stopProcessing="true">
-                                       <match url="^index\.php$" ignoreCase="false" />
-                                       <action type="None" />
-                               </rule>
-                               <rule name="wordpress - Rule 2" stopProcessing="true">
-                                       <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
-                                       <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
-                               </rule>
-                               <rule name="wordpress - Rule 3" stopProcessing="true">
-                                       <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
-                                       <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
-                               </rule>
-                               <rule name="wordpress - Rule 4" stopProcessing="true">
-                                       <match url="^" ignoreCase="false" />
-                                       <conditions logicalGrouping="MatchAny">
-                                               <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
-                                               <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
+
+               $rules .= '
+                       <rule name="wordpress" patternSyntax="Wildcard">
+                               <match url="*" />
+                                       <conditions>
+                                               <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
+                                               <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                                        </conditions>
                                        </conditions>
-                                       <action type="None" />
-                               </rule>
-                               <rule name="wordpress - Rule 5" stopProcessing="true">
-                                       <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
-                                       <action type="Rewrite" url="{R:1}" />
-                               </rule>
-                               <rule name="wordpress - Rule 6" stopProcessing="true">
-                                       <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
-                                       <action type="Rewrite" url="{R:2}" />
-                               </rule>
-                               <rule name="wordpress - Rule 7" stopProcessing="true">
-                                       <match url="." ignoreCase="false" />
-                                       <action type="Rewrite" url="index.php" />
-                               </rule>';
-                       }
-               }
+                               <action type="Rewrite" url="index.php" />
+                       </rule>';
+
                if ( $add_parent_tags ) {
                        $rules .= '
                        </rules>
                if ( $add_parent_tags ) {
                        $rules .= '
                        </rules>
@@ -1995,9 +1940,10 @@ class WP_Rewrite {
         */
        function set_permalink_structure($permalink_structure) {
                if ( $permalink_structure != $this->permalink_structure ) {
         */
        function set_permalink_structure($permalink_structure) {
                if ( $permalink_structure != $this->permalink_structure ) {
+                       $old_permalink_structure = $this->permalink_structure;
                        update_option('permalink_structure', $permalink_structure);
                        $this->init();
                        update_option('permalink_structure', $permalink_structure);
                        $this->init();
-                       do_action('permalink_structure_changed', $this->permalink_structure, $permalink_structure);
+                       do_action('permalink_structure_changed', $old_permalink_structure, $permalink_structure);
                }
        }
 
                }
        }