Changeset 11930 for trunk/wp-includes/classes.php
- Timestamp:
- 09/14/2009 02:03:32 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/classes.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/classes.php
r11853 r11930 215 215 // Trim the query of everything up to the '?'. 216 216 $query = preg_replace("!^.+\?!", '', $query); 217 217 218 218 // Substitute the substring matches into the query. 219 219 $query = addslashes(WP_MatchesMapRegex::apply($query, $matches)); … … 1595 1595 /** 1596 1596 * Helper class to remove the need to use eval to replace $matches[] in query strings. 1597 * 1597 * 1598 1598 * @since 2.9.0 1599 1599 */ … … 1601 1601 /** 1602 1602 * store for matches 1603 * 1603 * 1604 1604 * @access private 1605 1605 * @var array 1606 1606 */ 1607 1607 var $_matches; 1608 1608 1609 1609 /** 1610 1610 * store for mapping result 1611 * 1611 * 1612 1612 * @access public 1613 1613 * @var string 1614 1614 */ 1615 1615 var $output; 1616 1616 1617 1617 /** 1618 1618 * subject to perform mapping on (query string containing $matches[] references 1619 * 1619 * 1620 1620 * @access private 1621 1621 * @var string 1622 1622 */ 1623 1623 var $_subject; 1624 1625 /** 1626 * regexp pattern to match $matches[] references 1627 * 1624 1625 /** 1626 * regexp pattern to match $matches[] references 1627 * 1628 1628 * @var string 1629 1629 */ 1630 1630 var $_pattern = '(\$matches\[[1-9]+[0-9]*\])'; // magic number 1631 1631 1632 1632 /** 1633 1633 * constructor 1634 * 1634 * 1635 1635 * @param string $subject subject if regex 1636 1636 * @param array $matches data to use in map 1637 1637 * @return self 1638 */ 1638 */ 1639 1639 function WP_MatchesMapRegex($subject, $matches) { 1640 1640 $this->_subject = $subject; 1641 1641 $this->_matches = $matches; 1642 $this->output = $this->_map(); 1643 } 1644 1642 $this->output = $this->_map(); 1643 } 1644 1645 1645 /** 1646 1646 * Substitute substring matches in subject. 1647 * 1647 * 1648 1648 * static helper function to ease use 1649 * 1649 * 1650 1650 * @access public 1651 1651 * @param string $subject subject … … 1655 1655 function apply($subject, $matches) { 1656 1656 $oSelf =& new WP_MatchesMapRegex($subject, $matches); 1657 return $oSelf->output; 1658 } 1659 1660 /** 1661 * do the actual mapping 1662 * 1657 return $oSelf->output; 1658 } 1659 1660 /** 1661 * do the actual mapping 1662 * 1663 1663 * @access private 1664 1664 * @return string … … 1668 1668 return preg_replace_callback($this->_pattern, $callback, $this->_subject); 1669 1669 } 1670 1670 1671 1671 /** 1672 1672 * preg_replace_callback hook 1673 * 1673 * 1674 1674 * @access public 1675 1675 * @param array $matches preg_replace regexp matches … … 1680 1680 return ( isset( $this->_matches[$index] ) ? $this->_matches[$index] : '' ); 1681 1681 } 1682 1682 1683 1683 } 1684 1684
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)