Changeset 34708 for trunk/src/wp-includes/class-wp-rewrite.php
- Timestamp:
- 09/30/2015 01:10:03 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-rewrite.php
r34492 r34708 1511 1511 * 1512 1512 * @since 2.1.0 1513 * @ access public1514 * 1515 * @param string $regex Regular expression to match against request.1516 * @param string $redirect URL regex redirects to when regex matchesrequest.1517 * @param string $after Optional, default is bottom. Location to place rule.1518 * /1519 public function add_rule($regex, $redirect, $after = 'bottom') {1520 //get everything up to the first ?1521 $index = (strpos($redirect, '?') === false ? strlen($redirect) : strpos($redirect, '?'));1522 $front = substr($redirect, 0, $index);1523 if ( $front != $this->index ) { //it doesn't redirect to WP's index.php1524 $ this->add_external_rule($regex, $redirect);1513 * @since 4.4.0 Array support was added to the `$redirect` parameter. 1514 * @access public 1515 * 1516 * @param string $regex Regular expression to match against request. 1517 * @param string|array $redirect URL regex redirects to when regex matches request, or array 1518 * of query vars and values. 1519 * @param string $after Optional, default is bottom. Location to place rule. 1520 */ 1521 public function add_rule( $regex, $redirect, $after = 'bottom' ) { 1522 if ( is_array( $redirect ) ) { 1523 $external = false; 1524 $redirect = add_query_arg( $redirect, 'index.php' ); 1525 1525 } else { 1526 if ( 'bottom' == $after) 1527 $this->extra_rules = array_merge($this->extra_rules, array($regex => $redirect)); 1528 else 1529 $this->extra_rules_top = array_merge($this->extra_rules_top, array($regex => $redirect)); 1530 //$this->extra_rules[$regex] = $redirect; 1526 $index = false === strpos( $redirect, '?' ) ? strlen( $redirect ) : strpos( $redirect, '?' ); 1527 $front = substr( $redirect, 0, $index ); 1528 1529 $external = $front != $this->index; 1530 } 1531 1532 // "external" = it doesn't redirect to index.php 1533 if ( $external ) { 1534 $this->add_external_rule( $regex, $redirect ); 1535 } else { 1536 if ( 'bottom' == $after ) { 1537 $this->extra_rules = array_merge( $this->extra_rules, array( $regex => $redirect ) ); 1538 } else { 1539 $this->extra_rules_top = array_merge( $this->extra_rules_top, array( $regex => $redirect ) ); 1540 } 1531 1541 } 1532 1542 }
Note: See TracChangeset
for help on using the changeset viewer.