X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/9c40b4d36daed9e28e48a5fe9205c32557195a4b..1c09677af04c9e37714e09b73eb9dbc5b2e3eb13:/wp-includes/rewrite.php diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index c84b5205..4c8d9e68 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -299,7 +299,7 @@ function url_to_postid($url) { $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); @@ -1060,6 +1060,8 @@ class WP_Rewrite { * @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; @@ -1442,10 +1444,10 @@ class WP_Rewrite { $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) { - $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() { - $this->rules = get_transient('rewrite_rules'); + $this->rules = get_option('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; @@ -1715,19 +1717,37 @@ class WP_Rewrite { * * @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 ''; } - $rules = "\n"; - $rules .= " \n"; - $rules .= " \n"; - $rules .= " \n"; - $rules .= " \n"; - $rules .= " \n"; - $rules .= " \n"; - $rules .= ""; + + $rules = ''; + $extra_indent = ''; + if ( $add_parent_tags ) { + $rules .= "".$end_of_line; + $rules .= $indent."".$end_of_line; + $rules .= $indent.$indent."".$end_of_line; + $rules .= $indent.$indent.$indent."".$end_of_line; + $extra_indent = $indent.$indent.$indent.$indent; + } + + $rules .= $extra_indent."".$end_of_line; + $rules .= $extra_indent.$indent."".$end_of_line; + $rules .= $extra_indent.$indent.$indent."".$end_of_line; + $rules .= $extra_indent.$indent.$indent.$indent."".$end_of_line; + $rules .= $extra_indent.$indent.$indent.$indent."".$end_of_line; + $rules .= $extra_indent.$indent.$indent."".$end_of_line; + $rules .= $extra_indent.$indent."".$end_of_line; + $rules .= $extra_indent.""; + + if ( $add_parent_tags ) { + $rules .= $end_of_line.$indent.$indent.$indent."".$end_of_line; + $rules .= $indent.$indent."".$end_of_line; + $rules .= $indent."".$end_of_line; + $rules .= ""; + } $rules = apply_filters('iis7_url_rewrite_rules', $rules); @@ -1822,13 +1842,14 @@ class WP_Rewrite { * * @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(); - if ( function_exists('save_mod_rewrite_rules') ) + if ( $hard && function_exists('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(); }