Ticket #23282: 23282.5.diff
File 23282.5.diff, 16.7 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/ajax-actions.php
diff --git wp-admin/includes/ajax-actions.php wp-admin/includes/ajax-actions.php index bd4d5b9..b0f2c0c 100644
function wp_ajax_send_attachment_to_editor() { 2030 2030 $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : ''; 2031 2031 $title = ''; // We no longer insert title tags into <img> tags, as they are redundant. 2032 2032 $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt ); 2033 } elseif ( 'video' === substr( $post->post_mime_type, 0, 5 ) || 'audio' === substr( $post->post_mime_type, 0, 5 ) ) { 2034 $html = stripslashes_deep( $_POST['html'] ); 2033 2035 } 2034 2036 2035 2037 $html = apply_filters( 'media_send_to_editor', $html, $id, $attachment ); … … function wp_ajax_heartbeat() { 2086 2088 $screen_id = sanitize_key($_POST['screenid']); 2087 2089 else 2088 2090 $screen_id = 'site'; 2089 2091 2090 2092 if ( ! empty($_POST['data']) ) { 2091 2093 $data = wp_unslash( (array) $_POST['data'] ); 2092 2094 // todo: how much to sanitize and preset and what to leave to be accessed from $data or $_POST..? -
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/js/media-editor.js
diff --git wp-includes/js/media-editor.js wp-includes/js/media-editor.js index 15eff8d..456a968 100644
66 66 src: size.url, 67 67 captionId: 'attachment_' + attachment.id 68 68 }); 69 69 } else if ( 'video' === attachment.type || 'audio' === attachment.type ) { 70 _.extend( props, _.pick( attachment, 'title', 'type', 'icon', 'mime' ) ); 70 71 // Format properties for non-images. 71 72 } else { 72 73 props.title = props.title || attachment.filename; … … 95 96 return wp.html.string( options ); 96 97 }, 97 98 99 audio: function( props, attachment ) { 100 var shortcode, html; 101 102 props = wp.media.string.props( props, attachment ); 103 104 shortcode = {}; 105 106 if ( props.mime ) { 107 switch ( props.mime ) { 108 case 'audio/mpeg': 109 shortcode.src = props.linkUrl; 110 break; 111 case 'audio/ogg': 112 shortcode.ogg = props.linkUrl; 113 break; 114 case 'audio/wma': 115 shortcode.wma = props.linkUrl; 116 break; 117 } 118 } 119 120 html = wp.shortcode.string({ 121 tag: 'audio', 122 attrs: shortcode 123 }); 124 125 return html; 126 }, 127 128 video: function( props, attachment ) { 129 var shortcode, html; 130 131 props = wp.media.string.props( props, attachment ); 132 133 shortcode = {}; 134 135 if ( props.mime ) { 136 switch ( props.mime ) { 137 case 'video/mp4': 138 shortcode.src = props.linkUrl; 139 break; 140 case 'video/webm': 141 shortcode.webm = props.linkUrl; 142 break; 143 case 'video/ogg': 144 shortcode.ogv = props.linkUrl; 145 break; 146 case 'video/quicktime': 147 shortcode.mov = props.linkUrl; 148 break; 149 case 'video/asf': 150 shortcode.wmv = props.linkUrl; 151 break; 152 case 'video/x-flv': 153 shortcode.flv = props.linkUrl; 154 break; 155 } 156 } 157 158 html = wp.shortcode.string({ 159 tag: 'video', 160 attrs: shortcode 161 }); 162 163 return html; 164 }, 165 98 166 image: function( props, attachment ) { 99 167 var img = {}, 100 168 options, classes, shortcode, html; … … 575 643 if ( props[ prop ] ) 576 644 options[ option ] = props[ prop ]; 577 645 }); 578 646 } else if ( 'video' === attachment.type ) { 647 html = wp.media.string.video( props ); 648 } else if ( 'audio' === attachment.type ) { 649 html = wp.media.string.audio( props ); 579 650 } else { 580 651 html = wp.media.string.link( props ); 581 652 options.post_title = props.title; -
wp-includes/media.php
diff --git wp-includes/media.php wp-includes/media.php index f1f3737..e57d9fb 100644
function gallery_shortcode($attr) { 803 803 } 804 804 805 805 /** 806 * The Audio shortcode. 807 * 808 * This implements the functionality of the Audio Shortcode for displaying 809 * WordPress mp3s in a post. 810 * 811 * @since 3.6.0 812 * 813 * @param array $attr Attributes of the shortcode. 814 * @return string HTML content to display audio. 815 */ 816 function wp_audio_shortcode( $attr ) { 817 $post = get_post(); 818 819 static $instances = 0; 820 $instances++; 821 822 $audio = null; 823 824 extract( shortcode_atts( array( 825 'src' => '', 826 'ogg' => '', 827 'wma' => '' 828 ), $attr ) ); 829 830 if ( empty( $src ) && empty( $ogg ) && empty( $wma ) ) { 831 $audios = get_post_audio( $post->ID ); 832 if ( empty( $audios ) ) 833 return; 834 835 $audio = reset( $audios ); 836 $src = wp_get_attachment_url( $audio->ID ); 837 if ( empty( $src ) ) 838 return; 839 } 840 841 wp_enqueue_style( 'wp-mediaelement' ); 842 wp_enqueue_script( 'wp-mediaelement' ); 843 844 $atts = array( 845 sprintf( 'class="%s"', apply_filters( 'audio_shortcode_class', 'wp-audio-shortcode' ) ), 846 sprintf( 'id="audio-%d-%d"', $post->ID, $instances ), 847 ); 848 849 $html = sprintf( '<audio %s controls="controls" preload="none">', join( ' ', $atts ) ); 850 851 $source = '<source type="%s" src="%s" />'; 852 foreach ( array( 'src', 'ogg', 'wma' ) as $fallback ) { 853 if ( ! empty( $$fallback ) ) { 854 $type = wp_check_filetype( $$fallback ); 855 $html .= sprintf( $source, $type['type'], $$fallback ); 856 } 857 } 858 859 $html .= '</audio>'; 860 861 return apply_filters( 'audio_shortcode', $html, $src, $audio, $post ); 862 } 863 add_shortcode( 'audio', 'wp_audio_shortcode' ); 864 865 /** 866 * The Video shortcode. 867 * 868 * This implements the functionality of the Video Shortcode for displaying 869 * WordPress mp4s in a post. 870 * 871 * @since 3.6.0 872 * 873 * @param array $attr Attributes of the shortcode. 874 * @return string HTML content to display video. 875 */ 876 function wp_video_shortcode( $attr ) { 877 global $content_width; 878 $post = get_post(); 879 880 static $instances = 0; 881 $instances++; 882 883 $video = null; 884 885 extract( shortcode_atts( array( 886 'src' => '', 887 'width' => empty( $content_width ) ? 640 : $content_width, 888 'height' => 360, 889 'poster' => '', 890 'webm' => '', 891 'ogv' => '', 892 'mov' => '', 893 'wmv' => '', 894 'flv' => '', 895 ), $attr ) ); 896 897 $srcs = array( 'src', 'webm', 'ogv', 'mov', 'wmv', 'flv' ); 898 $primary = false; 899 foreach ( $srcs as $type ) { 900 if ( ! empty( $$type ) ) 901 $primary = true; 902 } 903 904 if ( ! $primary ) { 905 $videos = get_post_video( $post->ID ); 906 if ( empty( $videos ) ) 907 return; 908 909 $video = reset( $videos ); 910 $src = wp_get_attachment_url( $video->ID ); 911 if ( empty( $src ) ) 912 return; 913 } 914 915 wp_enqueue_style( 'wp-mediaelement' ); 916 wp_enqueue_script( 'wp-mediaelement' ); 917 918 $atts = array( 919 sprintf( 'class="%s"', apply_filters( 'video_shortcode_class', 'wp-video-shortcode' ) ), 920 sprintf( 'id="video-%d-%d"', $post->ID, $instances ), 921 sprintf( 'width="%d"', $width ), 922 sprintf( 'height="%d"', $height ), 923 ); 924 925 if ( ! empty( $poster ) ) 926 $atts[] = sprintf( 'poster="%s"', esc_url( $poster ) ); 927 928 $html = sprintf( '<video %s controls="controls" preload="none">', join( ' ', $atts ) ); 929 930 $source = '<source type="%s" src="%s" />'; 931 foreach ( $srcs as $fallback ) { 932 if ( ! empty( $$fallback ) ) { 933 $type = wp_check_filetype( $$fallback ); 934 $html .= sprintf( $source, $type['type'], $$fallback ); 935 } 936 } 937 938 $html .= '</video>'; 939 940 return apply_filters( 'video_shortcode', $html, $src, $video, $post ); 941 } 942 add_shortcode( 'video', 'wp_video_shortcode' ); 943 944 /** 806 945 * Display previous image link that has the same post parent. 807 946 * 808 947 * @since 2.5.0 … … function wp_enqueue_media( $args = array() ) { 1542 1681 1543 1682 do_action( 'wp_enqueue_media' ); 1544 1683 } 1684 1685 /** 1686 * Retrieve audio attached to the passed post 1687 * 1688 * @since 3.6.0 1689 * 1690 * @param int $post_id Post ID 1691 * @return array Found audio attachments 1692 */ 1693 function get_post_audio( $post_id = 0 ) { 1694 $post = empty( $post_id ) ? get_post() : get_post( $post_id ); 1695 if ( empty( $post ) ) 1696 return; 1697 1698 $children = get_children( array( 1699 'post_parent' => $post->ID, 1700 'post_type' => 'attachment', 1701 'post_mime_type' => 'audio', 1702 'posts_per_page' => -1 1703 ) ); 1704 1705 if ( ! empty( $children ) ) 1706 return $children; 1707 } 1708 1709 /** 1710 * Check the content blob for an <audio>, <object>, <embed>, or <iframe>, in that order 1711 * If no HTML tag is found, check the first line of the post for a URL 1712 * 1713 * @param string $content A string which might contain audio data. 1714 * @param boolean $remove Whether to remove the found URL from the passed content. 1715 * @return string The found data 1716 */ 1717 function get_content_audio( &$content, $remove = false ) { 1718 $html = $matches = ''; 1719 foreach ( array( 'audio', 'object', 'embed', 'iframe' ) as $tag ) { 1720 if ( preg_match( '#' . get_tag_regex( $tag ) . '#', $content, $matches ) ) { 1721 $html = $matches[1]; 1722 if ( $remove ) 1723 $content = str_replace( $matches[0], '', $content ); 1724 1725 return $html; 1726 } 1727 } 1728 1729 $lines = explode( "\n", trim( $content ) ); 1730 $line = trim( array_shift( $lines ) ); 1731 1732 if ( 0 === stripos( $line, 'http' ) ) { 1733 if ( $remove ) 1734 $content = join( "\n", $lines ); 1735 1736 return $line; 1737 } 1738 } 1739 1740 /** 1741 * Return the found audio data for the passed post 1742 * 1743 * @since 3.6.0 1744 * 1745 * @param int $id Optional. Post ID 1746 */ 1747 function get_the_audio( $id = 0 ) { 1748 $post = empty( $id ) ? get_post() : get_post( $id ); 1749 if ( empty( $post ) ) 1750 return; 1751 1752 if ( shortcode_exists( 'audio' ) ) 1753 return do_shortcode( '[audio /]' ); 1754 1755 $data = get_content_audio( $post->post_content ); 1756 if ( ! empty( $data ) ) 1757 return $data; 1758 1759 $audios = get_post_audio( $post->ID ); 1760 if ( empty( $audios ) ) 1761 return; 1762 1763 $audio = reset( $audios ); 1764 return wp_get_attachment_url( $audio->ID ); 1765 } 1766 1767 /** 1768 * Output the found audio data for the current post 1769 * 1770 * @since 3.6.0 1771 */ 1772 function the_audio() { 1773 echo apply_filters( 'the_audio', get_the_audio() ); 1774 } 1775 1776 /** 1777 * Retrieve video attached to the passed post 1778 * 1779 * @since 3.6.0 1780 * 1781 * @param int $post_id Post ID 1782 * @return array Found video attachments 1783 */ 1784 function get_post_video( $post_id = 0 ) { 1785 $post = empty( $post_id ) ? get_post() : get_post( $post_id ); 1786 if ( empty( $post ) ) 1787 return; 1788 1789 $children = get_children( array( 1790 'post_parent' => $post->ID, 1791 'post_type' => 'attachment', 1792 'post_mime_type' => 'video', 1793 'posts_per_page' => -1 1794 ) ); 1795 1796 if ( ! empty( $children ) ) 1797 return $children; 1798 } 1799 1800 /** 1801 * Check the content blob for a <video>, <object>, <embed>, or <iframe>, in that order 1802 * If no HTML tag is found, check the first line of the post for a URL 1803 * 1804 * @param string $content A string which might contain video data. 1805 * @param boolean $remove Whether to remove the found URL from the passed content. 1806 * @return string The found data 1807 */ 1808 function get_content_video( &$content, $remove = false ) { 1809 $html = $matches = ''; 1810 foreach ( array( 'video', 'object', 'embed', 'iframe' ) as $tag ) { 1811 if ( preg_match( '#' . get_tag_regex( $tag ) . '#', $content, $matches ) ) { 1812 $html = $matches[1]; 1813 if ( $remove ) 1814 $content = str_replace( $matches[0], '', $content ); 1815 1816 return $html; 1817 } 1818 } 1819 1820 $lines = explode( "\n", trim( $content ) ); 1821 $line = trim( array_shift( $lines ) ); 1822 1823 if ( 0 === stripos( $line, 'http' ) ) { 1824 if ( $remove ) 1825 $content = join( "\n", $lines ); 1826 1827 return $line; 1828 } 1829 } 1830 1831 /** 1832 * Return the found video data for the passed post 1833 * 1834 * @since 3.6.0 1835 * 1836 * @param int $id Optional. Post ID 1837 */ 1838 function get_the_video( $id = 0 ) { 1839 $post = empty( $id ) ? get_post() : get_post( $id ); 1840 if ( empty( $post ) ) 1841 return; 1842 1843 if ( shortcode_exists( 'video' ) ) 1844 return do_shortcode( '[video /]' ); 1845 1846 $data = get_content_video( $post->post_content ); 1847 if ( ! empty( $data ) ) 1848 return $data; 1849 1850 $videos = get_post_video( $post->ID ); 1851 if ( empty( $videos ) ) 1852 return; 1853 1854 $video = reset( $videos ); 1855 return wp_get_attachment_url( $video->ID ); 1856 } 1857 1858 /** 1859 * Output the found video data for the current post 1860 * 1861 * @since 3.6.0 1862 */ 1863 function the_video() { 1864 echo apply_filters( 'the_video', get_the_video() ); 1865 } 1866 No newline at end of file -
wp-includes/post-formats.php
diff --git wp-includes/post-formats.php wp-includes/post-formats.php index 6d32aea..1955787 100644
function post_formats_compat( $content, $id = 0 ) { 398 398 // attempt to embed the URL 399 399 $format_output .= sprintf( '[embed]%s[/embed]', $meta['media'] ); 400 400 } 401 } elseif ( empty( $meta['media'] ) ) { 402 $data = ''; 403 // attempt to grab an embed code or URL from the content 404 if ( 'audio' === $format ) { 405 $data = get_content_audio( $content, true ); 406 } elseif ( 'video' === $format ) { 407 $data = get_content_video( $content, true ); 408 } 409 410 if ( ! empty( $data ) ) { 411 // attempt to embed the URL 412 if ( 0 === stripos( $data, 'http' ) ) 413 $format_output .= sprintf( '[embed]%s[/embed]', $data ); 414 else // data is probably an embed code 415 $format_output .= $data; 416 } elseif ( 'audio' === $format ) { 417 // get attached audio URL 418 $audios = get_post_audio( $post->ID ); 419 if ( ! empty( $audios ) ) { 420 $audio = reset( $audios ); 421 $url = wp_get_attachment_url( $audio->ID ); 422 // core or plugin support for [audio] 423 if ( shortcode_exists( 'audio' ) ) { 424 $format_output .= sprintf( '[audio src="%s"/]', $url ); 425 } else { 426 // no support detected, just add URL 427 $format_output .= sprintf( '<a href="%1$s">%1$s</a>', $url ); 428 } 429 } 430 } elseif ( 'video' === $format ) { 431 // get attached video URL 432 $videos = get_post_video( $post->ID ); 433 if ( ! empty( $videos ) ) { 434 $video = reset( $videos ); 435 $url = wp_get_attachment_url( $video->ID ); 436 // core or plugin support for [video] 437 if ( shortcode_exists( 'video' ) ) { 438 $format_output .= sprintf( '[video src="%s"/]', $url ); 439 } else { 440 // no support detected, just add URL link 441 $format_output .= sprintf( '<a href="%1$s">%1$s</a>', $url ); 442 } 443 } 444 } 401 445 } 402 446 } 403 447 break; -
wp-includes/script-loader.php
diff --git wp-includes/script-loader.php wp-includes/script-loader.php index cfb865e..2e5e527 100644
function wp_default_scripts( &$scripts ) { 274 274 275 275 $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.8', 1 ); 276 276 277 $scripts->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelement-and-player$suffix.js", array('jquery'), '2.10.1', 1 ); 278 $scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement.js", array('mediaelement'), false, 1 ); 279 277 280 $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), false, 1 ); 278 281 did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n', array( 279 282 'empty' => __('Strength indicator'), … … function wp_default_styles( &$styles ) { 538 541 $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons' ) ); 539 542 $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" ); 540 543 544 $styles->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelementplayer$suffix.css" ); 545 $styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement.css", array( 'mediaelement' ) ); 546 541 547 foreach ( $rtl_styles as $rtl_style ) { 542 548 $styles->add_data( $rtl_style, 'rtl', true ); 543 549 if ( $suffix && ! in_array( $rtl_style, $no_suffix ) ) -
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