Changeset 32896 for trunk/src/wp-includes/formatting.php
- Timestamp:
- 06/21/2015 12:58:12 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r32863 r32896 1504 1504 1505 1505 /** 1506 * Converts a number of characters from a string. 1507 * 1508 * Metadata tags `<title>` and `<category>` are removed, `<br>` and `<hr>` are 1509 * converted into correct XHTML and Unicode characters are converted to the 1510 * valid range. 1506 * Converts lone & characters into `&` (a.k.a. `&`) 1511 1507 * 1512 1508 * @since 0.71 … … 1517 1513 */ 1518 1514 function convert_chars( $content, $deprecated = '' ) { 1519 if ( ! empty( $deprecated ) )1515 if ( ! empty( $deprecated ) ) { 1520 1516 _deprecated_argument( __FUNCTION__, '0.71' ); 1521 1522 // Translation of invalid Unicode references range to valid range 1517 } 1518 1519 if ( strpos( $content, '&' ) !== false ) { 1520 $content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content ); 1521 } 1522 1523 return $content; 1524 } 1525 1526 /** 1527 * Converts invalid Unicode references range to valid range. 1528 * 1529 * @since 4.3 1530 * 1531 * @param string $content String with entities that need converting. 1532 * @return string Converted string. 1533 */ 1534 function convert_invalid_entities( $content ) { 1523 1535 $wp_htmltranswinuni = array( 1524 '€' => '€', // the Euro sign1525 '' => '',1526 '‚' => '‚', // these are Windows CP1252 specific characters1527 'ƒ' => 'ƒ', // they would look weird on non-Windows browsers1528 '„' => '„',1529 '…' => '…',1530 '†' => '†',1531 '‡' => '‡',1532 'ˆ' => 'ˆ',1533 '‰' => '‰',1534 'Š' => 'Š',1535 '‹' => '‹',1536 'Œ' => 'Œ',1537 '' => '',1538 'Ž' => 'Ž',1539 '' => '',1540 '' => '',1541 '‘' => '‘',1542 '’' => '’',1543 '“' => '“',1544 '”' => '”',1545 '•' => '•',1546 '–' => '–',1547 '—' => '—',1548 '˜' => '˜',1549 '™' => '™',1550 'š' => 'š',1551 '›' => '›',1552 'œ' => 'œ',1553 '' => '',1554 'ž' => 'ž',1555 'Ÿ' => 'Ÿ'1536 '€' => '€', // the Euro sign 1537 '' => '', 1538 '‚' => '‚', // these are Windows CP1252 specific characters 1539 'ƒ' => 'ƒ', // they would look weird on non-Windows browsers 1540 '„' => '„', 1541 '…' => '…', 1542 '†' => '†', 1543 '‡' => '‡', 1544 'ˆ' => 'ˆ', 1545 '‰' => '‰', 1546 'Š' => 'Š', 1547 '‹' => '‹', 1548 'Œ' => 'Œ', 1549 '' => '', 1550 'Ž' => 'Ž', 1551 '' => '', 1552 '' => '', 1553 '‘' => '‘', 1554 '’' => '’', 1555 '“' => '“', 1556 '”' => '”', 1557 '•' => '•', 1558 '–' => '–', 1559 '—' => '—', 1560 '˜' => '˜', 1561 '™' => '™', 1562 'š' => 'š', 1563 '›' => '›', 1564 'œ' => 'œ', 1565 '' => '', 1566 'ž' => 'ž', 1567 'Ÿ' => 'Ÿ' 1556 1568 ); 1557 1569 1558 // Remove metadata tags 1559 $content = preg_replace('/<title>(.+?)<\/title>/','',$content); 1560 $content = preg_replace('/<category>(.+?)<\/category>/','',$content); 1561 1562 // Converts lone & characters into & (a.k.a. &) 1563 $content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content); 1564 1565 // Fix Word pasting 1566 $content = strtr($content, $wp_htmltranswinuni); 1567 1568 // Just a little XHTML help 1569 $content = str_replace('<br>', '<br />', $content); 1570 $content = str_replace('<hr>', '<hr />', $content); 1570 if ( strpos( $content, '' ) !== false ) { 1571 $content = strtr( $content, $wp_htmltranswinuni ); 1572 } 1571 1573 1572 1574 return $content;
Note: See TracChangeset
for help on using the changeset viewer.