WordPress.org

Make WordPress Core

Ticket #16840: 16840.diff

File 16840.diff, 1.7 KB (added by scribu, 3 years ago)
  • wp-includes/rewrite.php

     
    1313 * @since 2.1.0 
    1414 * 
    1515 * @param string $regex Regular Expression to match request against. 
    16  * @param string $redirect Page to redirect to. 
     16 * @param string|array $redirect Page to redirect to. 
    1717 * @param string $after Optional, default is 'bottom'. Where to add rule, can also be 'top'. 
    1818 */ 
    1919function add_rewrite_rule($regex, $redirect, $after = 'bottom') { 
     
    17911791         * @access public 
    17921792         * 
    17931793         * @param string $regex Regular expression to match against request. 
    1794          * @param string $redirect URL regex redirects to when regex matches request. 
     1794         * @param string|array $redirect URL regex redirects to when regex matches request. 
    17951795         * @param string $after Optional, default is bottom. Location to place rule. 
    17961796         */ 
    17971797        function add_rule($regex, $redirect, $after = 'bottom') { 
    1798                 //get everything up to the first ? 
    1799                 $index = (strpos($redirect, '?') == false ? strlen($redirect) : strpos($redirect, '?')); 
    1800                 $front = substr($redirect, 0, $index); 
    1801                 if ( $front != $this->index ) { //it doesn't redirect to WP's index.php 
     1798                if ( is_array( $redirect ) ) { 
     1799                        $external = false; 
     1800                        $redirect = add_query_arg( $redirect, 'index.php' ); 
     1801                } else { 
     1802                        // get everything up to the first '?' 
     1803                        $index = (strpos($redirect, '?') == false ? strlen($redirect) : strpos($redirect, '?')); 
     1804                        $front = substr($redirect, 0, $index); 
     1805 
     1806                        $external = $front != $this->index; 
     1807                } 
     1808 
     1809                if ( $external ) { //it doesn't redirect to WP's index.php 
    18021810                        $this->add_external_rule($regex, $redirect); 
    18031811                } else { 
    18041812                        if ( 'bottom' == $after)