Ticket #23572: 23572.diff
File 23572.diff, 9.0 KB (added by , 12 years ago) |
---|
-
wp-includes/formatting.php
diff --git wp-includes/formatting.php wp-includes/formatting.php index c162a35..c2d2a11 100644
function post_formats_compat( $content, $id = 0 ) { 1943 1943 // attempt to embed the URL 1944 1944 $format_output .= sprintf( '[embed]%s[/embed]', $meta['media'] ); 1945 1945 } 1946 } elseif ( empty( $meta['media'] ) ) { 1947 $data = ''; 1948 // attempt to grab an embed code or URL from the content 1949 if ( 'audio' === $format ) { 1950 $data = get_content_audio( $content, true ); 1951 } elseif ( 'video' === $format ) { 1952 $data = get_content_video( $content, true ); 1953 } 1954 1955 if ( ! empty( $data ) ) { 1956 // attempt to embed the URL 1957 if ( 0 === stripos( $data, 'http' ) ) 1958 $format_output .= sprintf( '[embed]%s[/embed]', $data ); 1959 else // data is probably an embed code 1960 $format_output .= $data; 1961 } elseif ( 'audio' === $format ) { 1962 // get attached audio URL 1963 $audios = get_post_audio( $post->ID ); 1964 if ( ! empty( $audios ) ) { 1965 $audio = reset( $audios ); 1966 $url = wp_get_attachment_url( $audio->ID ); 1967 // core or plugin support for [audio] 1968 if ( shortcode_exists( 'audio' ) ) { 1969 $format_output .= sprintf( '[audio src="%s"/]', $url ); 1970 } else { 1971 // no support detected, just add URL 1972 $format_output .= sprintf( '<a href="%1$s">%1$s</a>', $url ); 1973 } 1974 } 1975 } elseif ( 'video' === $format ) { 1976 // get attached video URL 1977 $videos = get_post_video( $post->ID ); 1978 if ( ! empty( $videos ) ) { 1979 $video = reset( $videos ); 1980 $url = wp_get_attachment_url( $video->ID ); 1981 // core or plugin support for [video] 1982 if ( shortcode_exists( 'video' ) ) { 1983 $format_output .= sprintf( '[video src="%s"/]', $url ); 1984 } else { 1985 // no support detected, just add URL link 1986 $format_output .= sprintf( '<a href="%1$s">%1$s</a>', $url ); 1987 } 1988 } 1989 } 1946 1990 } 1947 1991 } 1948 1992 break; … … function sanitize_trackback_urls( $to_ping ) { 3531 3575 * @return string|array Slashed $value 3532 3576 */ 3533 3577 function wp_slash( $value ) { 3534 if ( is_array( $value ) ) { 3578 if ( is_array( $value ) ) { 3535 3579 foreach ( $value as $k => $v ) { 3536 3580 if ( is_array( $v ) ) { 3537 3581 $value[$k] = wp_slash( $v ); … … function wp_slash( $value ) { 3540 3584 } 3541 3585 } 3542 3586 } else { 3543 $value = addslashes( $value ); 3544 } 3587 $value = addslashes( $value ); 3588 } 3545 3589 3546 return $value; 3590 return $value; 3547 3591 } 3548 3592 3549 3593 /** … … function wp_slash( $value ) { 3562 3606 * @return string|array Unslashed $value 3563 3607 */ 3564 3608 function wp_unslash( $value ) { 3565 return stripslashes_deep( $value ); 3566 } 3609 return stripslashes_deep( $value ); 3610 } 3611 No newline at end of file -
wp-includes/functions.php
diff --git wp-includes/functions.php wp-includes/functions.php index cbd7925..5ac68c7 100644
function wp_is_stream( $path ) { 3883 3883 */ 3884 3884 function wp_checkdate( $month, $day, $year, $source_date ) { 3885 3885 return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date ); 3886 } 3887 3888 /** 3889 * Return RegEx body to liberally match an opening HTML tag that: 3890 * 1. Is self-closing or 3891 * 2. Has no body but has a closing tag of the same name or 3892 * 3. Contains a body and a closing tag of the same name 3893 * 3894 * Note: this RegEx does not balance inner tags and does not attempt to produce valid HTML 3895 * 3896 * @since 3.6.0 3897 * 3898 * @param string $tag An HTML tag name. Example: 'video' 3899 * @return string 3900 */ 3901 function get_tag_regex( $tag ) { 3902 if ( empty( $tag ) ) 3903 return; 3904 3905 return sprintf( '(<%1$s[^>]*(?:/?>$|>[\s\S]*?</%1$s>))', tag_escape( $tag ) ); 3886 3906 } 3907 No newline at end of file -
wp-includes/media.php
diff --git wp-includes/media.php wp-includes/media.php index f1f3737..895edbf 100644
function wp_enqueue_media( $args = array() ) { 1542 1542 1543 1543 do_action( 'wp_enqueue_media' ); 1544 1544 } 1545 1546 /** 1547 * Retrieve audio attached to the passed post 1548 * 1549 * @since 3.6.0 1550 * 1551 * @param int $post_id Post ID 1552 * @return array Found audio attachments 1553 */ 1554 function get_post_audio( $post_id = 0 ) { 1555 $post = empty( $post_id ) ? get_post() : get_post( $post_id ); 1556 if ( empty( $post ) ) 1557 return; 1558 1559 $children = get_children( array( 1560 'post_parent' => $post->ID, 1561 'post_type' => 'attachment', 1562 'post_mime_type' => 'audio', 1563 'posts_per_page' => -1 1564 ) ); 1565 1566 if ( ! empty( $children ) ) 1567 return $children; 1568 } 1569 1570 /** 1571 * Check the content blob for an <audio>, <object>, <embed>, or <iframe>, in that order 1572 * If no HTML tag is found, check the first line of the post for a URL 1573 * 1574 * @param string $content A string which might contain audio data. 1575 * @param boolean $remove Whether to remove the found URL from the passed content. 1576 * @return string The found data 1577 */ 1578 function get_content_audio( &$content, $remove = false ) { 1579 $html = $matches = ''; 1580 foreach ( array( 'audio', 'object', 'embed', 'iframe' ) as $tag ) { 1581 if ( preg_match( '#' . get_tag_regex( $tag ) . '#', $content, $matches ) ) { 1582 $html = $matches[1]; 1583 if ( $remove ) 1584 $content = str_replace( $matches[0], '', $content ); 1585 1586 return $html; 1587 } 1588 } 1589 1590 $lines = explode( "\n", trim( $content ) ); 1591 $line = trim( array_shift( $lines ) ); 1592 1593 if ( 0 === stripos( $line, 'http' ) ) { 1594 if ( $remove ) 1595 $content = join( "\n", $lines ); 1596 1597 return $line; 1598 } 1599 } 1600 1601 /** 1602 * Return the found audio data for the passed post 1603 * 1604 * @since 3.6.0 1605 * 1606 * @param int $id Optional. Post ID 1607 */ 1608 function get_the_audio( $id = 0 ) { 1609 $post = empty( $id ) ? get_post() : get_post( $id ); 1610 if ( empty( $post ) ) 1611 return; 1612 1613 if ( shortcode_exists( 'audio' ) ) 1614 return do_shortcode( '[audio /]' ); 1615 1616 $data = get_content_audio( $post->post_content ); 1617 if ( ! empty( $data ) ) 1618 return $data; 1619 1620 $audios = get_post_audio( $post->ID ); 1621 if ( empty( $audios ) ) 1622 return; 1623 1624 $audio = reset( $audios ); 1625 return wp_get_attachment_url( $audio->ID ); 1626 } 1627 1628 /** 1629 * Output the found audio data for the current post 1630 * 1631 * @since 3.6.0 1632 */ 1633 function the_audio() { 1634 echo apply_filters( 'the_audio', get_the_audio() ); 1635 } 1636 1637 /** 1638 * Retrieve video attached to the passed post 1639 * 1640 * @since 3.6.0 1641 * 1642 * @param int $post_id Post ID 1643 * @return array Found video attachments 1644 */ 1645 function get_post_video( $post_id = 0 ) { 1646 $post = empty( $post_id ) ? get_post() : get_post( $post_id ); 1647 if ( empty( $post ) ) 1648 return; 1649 1650 $children = get_children( array( 1651 'post_parent' => $post->ID, 1652 'post_type' => 'attachment', 1653 'post_mime_type' => 'video', 1654 'posts_per_page' => -1 1655 ) ); 1656 1657 if ( ! empty( $children ) ) 1658 return $children; 1659 } 1660 1661 /** 1662 * Check the content blob for a <video>, <object>, <embed>, or <iframe>, in that order 1663 * If no HTML tag is found, check the first line of the post for a URL 1664 * 1665 * @param string $content A string which might contain video data. 1666 * @param boolean $remove Whether to remove the found URL from the passed content. 1667 * @return string The found data 1668 */ 1669 function get_content_video( &$content, $remove = false ) { 1670 $html = $matches = ''; 1671 foreach ( array( 'video', 'object', 'embed', 'iframe' ) as $tag ) { 1672 if ( preg_match( '#' . get_tag_regex( $tag ) . '#', $content, $matches ) ) { 1673 $html = $matches[1]; 1674 if ( $remove ) 1675 $content = str_replace( $matches[0], '', $content ); 1676 1677 return $html; 1678 } 1679 } 1680 1681 $lines = explode( "\n", trim( $content ) ); 1682 $line = trim( array_shift( $lines ) ); 1683 1684 if ( 0 === stripos( $line, 'http' ) ) { 1685 if ( $remove ) 1686 $content = join( "\n", $lines ); 1687 1688 return $line; 1689 } 1690 } 1691 1692 /** 1693 * Return the found video data for the passed post 1694 * 1695 * @since 3.6.0 1696 * 1697 * @param int $id Optional. Post ID 1698 */ 1699 function get_the_video( $id = 0 ) { 1700 $post = empty( $id ) ? get_post() : get_post( $id ); 1701 if ( empty( $post ) ) 1702 return; 1703 1704 if ( shortcode_exists( 'video' ) ) 1705 return do_shortcode( '[video /]' ); 1706 1707 $data = get_content_video( $post->post_content ); 1708 if ( ! empty( $data ) ) 1709 return $data; 1710 1711 $videos = get_post_video( $post->ID ); 1712 if ( empty( $videos ) ) 1713 return; 1714 1715 $video = reset( $videos ); 1716 return wp_get_attachment_url( $video->ID ); 1717 } 1718 1719 /** 1720 * Output the found video data for the current post 1721 * 1722 * @since 3.6.0 1723 */ 1724 function the_video() { 1725 echo apply_filters( 'the_video', get_the_video() ); 1726 } 1727 No newline at end of file -
wp-includes/shortcodes.php
diff --git wp-includes/shortcodes.php wp-includes/shortcodes.php index 2dfc277..716dae4 100644
function remove_all_shortcodes() { 128 128 } 129 129 130 130 /** 131 * Whether a registered shortcode exists named $tag 132 * 133 * @since 3.6.0 134 * 135 * @global array $shortcode_tags 136 * @param string $tag 137 * @return boolean 138 */ 139 function shortcode_exists( $tag ) { 140 global $shortcode_tags; 141 return array_key_exists( $tag, $shortcode_tags ); 142 } 143 144 /** 131 145 * Search content for shortcodes and filter shortcodes through their hooks. 132 146 * 133 147 * If there are no shortcode tags defined, then the content will be returned