Ticket #10384: 10384.patch
File 10384.patch, 8.8 KB (added by , 15 years ago) |
---|
-
wp-admin/includes/misc.php
145 145 * 146 146 * @return bool True if web.config was updated successfully 147 147 */ 148 function iis 7_save_url_rewrite_rules(){148 function iis_save_url_rewrite_rules(){ 149 149 global $wp_rewrite; 150 150 151 151 $home_path = get_home_path(); … … 153 153 154 154 // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP 155 155 if ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) { 156 if ( iis 7_supports_permalinks() ) {157 $rule = $wp_rewrite->iis 7_url_rewrite_rules();156 if ( iis_supports_permalinks() ) { 157 $rule = $wp_rewrite->iis_url_rewrite_rules(); 158 158 if ( ! empty($rule) ) { 159 return iis 7_add_rewrite_rule($web_config_file, $rule);159 return iis_add_rewrite_rule($web_config_file, $rule); 160 160 } else { 161 return iis 7_delete_rewrite_rule($web_config_file);161 return iis_delete_rewrite_rule($web_config_file); 162 162 } 163 163 } 164 164 } … … 429 429 } 430 430 431 431 /** 432 * Check if IIS 7 supports pretty permalinks432 * Check if IIS supports pretty permalinks via URL Rewrite Module 433 433 * 434 434 * @since 2.8.0 435 435 * 436 436 * @return bool 437 437 */ 438 function iis 7_supports_permalinks() {439 global $is_ iis7;438 function iis_supports_permalinks() { 439 global $is_IIS; 440 440 441 441 $supports_permalinks = false; 442 if ( $is_ iis7) {442 if ( $is_IIS ) { 443 443 /* First we check if the DOMDocument class exists. If it does not exist, 444 444 * which is the case for PHP 4.X, then we cannot easily update the xml configuration file, 445 445 * hence we just bail out and tell user that pretty permalinks cannot be used. … … 453 453 $supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' ); 454 454 } 455 455 456 return apply_filters('iis 7_supports_permalinks', $supports_permalinks);456 return apply_filters('iis_supports_permalinks', $supports_permalinks); 457 457 } 458 458 459 459 /** 460 * Check if rewrite rule for WordPress already exists in the IIS 7configuration file460 * Check if rewrite rule for WordPress already exists in the IIS configuration file 461 461 * 462 462 * @since 2.8.0 463 463 * 464 464 * @return bool 465 465 * @param string $filename The file path to the configuration file 466 466 */ 467 function iis 7_rewrite_rule_exists($filename) {467 function iis_rewrite_rule_exists($filename) { 468 468 if ( ! file_exists($filename) ) 469 469 return false; 470 470 if ( ! class_exists('DOMDocument') ) … … 489 489 * @param string $filename Name of the configuration file 490 490 * @return bool 491 491 */ 492 function iis 7_delete_rewrite_rule($filename) {492 function iis_delete_rewrite_rule($filename) { 493 493 // If configuration file does not exist then rules also do not exist so there is nothing to delete 494 494 if ( ! file_exists($filename) ) 495 495 return true; … … 515 515 } 516 516 517 517 /** 518 * Add WordPress rewrite rule to the IIS 7configuration file.518 * Add WordPress rewrite rule to the IIS configuration file. 519 519 * 520 520 * @since 2.8.0 521 521 * … … 523 523 * @param string $rewrite_rule The XML fragment with URL Rewrite rule 524 524 * @return bool 525 525 */ 526 function iis 7_add_rewrite_rule($filename, $rewrite_rule) {526 function iis_add_rewrite_rule($filename, $rewrite_rule) { 527 527 if ( ! class_exists('DOMDocument') ) 528 528 return false; 529 529 -
wp-admin/options-permalink.php
70 70 include('admin-header.php'); 71 71 72 72 $home_path = get_home_path(); 73 $iis 7_permalinks = iis7_supports_permalinks();73 $iis_permalinks = iis_supports_permalinks(); 74 74 75 75 if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) { 76 76 check_admin_referer('update-permalink'); … … 101 101 $category_base = get_option('category_base'); 102 102 $tag_base = get_option( 'tag_base' ); 103 103 104 if ( $iis 7_permalinks ) {104 if ( $iis_permalinks ) { 105 105 if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') ) 106 106 $writable = true; 107 107 else … … 123 123 124 124 <?php if (isset($_POST['submit'])) : ?> 125 125 <div id="message" class="updated fade"><p><?php 126 if ( $iis 7_permalinks ) {126 if ( $iis_permalinks ) { 127 127 if ( $permalink_structure && ! $usingpi && ! $writable ) 128 128 _e('You should update your web.config now'); 129 129 else if ( $permalink_structure && ! $usingpi && $writable) … … 152 152 <?php 153 153 $prefix = ''; 154 154 155 if ( ! got_mod_rewrite() && ! $iis 7_permalinks )155 if ( ! got_mod_rewrite() && ! $iis_permalinks ) 156 156 $prefix = '/index.php'; 157 157 158 158 $structures = array( … … 197 197 </table> 198 198 199 199 <h3><?php _e('Optional'); ?></h3> 200 <?php if ( $is_apache || $iis 7_permalinks ) : ?>200 <?php if ( $is_apache || $iis_permalinks ) : ?> 201 201 <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <kbd>topics</kbd> as your category base would make your category links like <code>http://example.org/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p> 202 202 <?php else : ?> 203 203 <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>topics</code> as your category base would make your category links like <code>http://example.org/index.php/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p> … … 221 221 <input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /> 222 222 </p> 223 223 </form> 224 <?php if ($iis 7_permalinks) :224 <?php if ($iis_permalinks) : 225 225 if ( isset($_POST['submit']) && $permalink_structure && ! $usingpi && ! $writable ) : ?> 226 226 <p><?php _e('If your <code>web.config</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/<configuration>/<system.webServer>/<rewrite>/<rules></code> element in <code>web.config</code> file.') ?></p> 227 227 <form action="options-permalink.php" method="post"> 228 228 <?php wp_nonce_field('update-permalink') ?> 229 <p><textarea rows="10" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_html($wp_rewrite->iis 7_url_rewrite_rules()); ?></textarea></p>229 <p><textarea rows="10" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_html($wp_rewrite->iis_url_rewrite_rules()); ?></textarea></p> 230 230 </form> 231 231 <p><?php _e('If you temporarily make your <code>web.config</code> file writable for us to generate rewrite rules automatically, do not forget to revert the permissions after rule has been saved.') ?></p> 232 232 <?php endif; ?> -
wp-includes/rewrite.php
1705 1705 } 1706 1706 1707 1707 /** 1708 * Retrieve IIS 7URL Rewrite formatted rewrite rules to write to web.config file.1708 * Retrieve IIS URL Rewrite formatted rewrite rules to write to web.config file. 1709 1709 * 1710 1710 * Does not actually write to the web.config file, but creates the rules for 1711 1711 * the process that will. … … 1715 1715 * 1716 1716 * @return string 1717 1717 */ 1718 function iis 7_url_rewrite_rules(){1718 function iis_url_rewrite_rules(){ 1719 1719 1720 1720 if ( ! $this->using_permalinks()) { 1721 1721 return ''; … … 1729 1729 $rules .= " <action type=\"Rewrite\" url=\"index.php\" />\n"; 1730 1730 $rules .= "</rule>"; 1731 1731 1732 $rules = apply_filters('iis 7_url_rewrite_rules', $rules);1732 $rules = apply_filters('iis_url_rewrite_rules', $rules); 1733 1733 1734 1734 return $rules; 1735 1735 } … … 1829 1829 $this->wp_rewrite_rules(); 1830 1830 if ( $hard && function_exists('save_mod_rewrite_rules') ) 1831 1831 save_mod_rewrite_rules(); 1832 if ( $hard && function_exists('iis 7_save_url_rewrite_rules') )1833 iis 7_save_url_rewrite_rules();1832 if ( $hard && function_exists('iis_save_url_rewrite_rules') ) 1833 iis_save_url_rewrite_rules(); 1834 1834 } 1835 1835 1836 1836 /** -
wp-includes/vars.php
73 73 */ 74 74 $is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer') !== false); 75 75 76 /**77 * Whether the server software is IIS 7.X78 * @global bool $is_iis779 */80 $is_iis7 = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false);81 82 83 76 ?> 84 No newline at end of file