Ticket #23282: 23282.11.diff
File 23282.11.diff, 17.3 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 8581c9e..93a897f 100644
function wp_ajax_send_attachment_to_editor() { 2024 2024 $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : ''; 2025 2025 $title = ''; // We no longer insert title tags into <img> tags, as they are redundant. 2026 2026 $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt ); 2027 } elseif ( 'video' === substr( $post->post_mime_type, 0, 5 ) || 'audio' === substr( $post->post_mime_type, 0, 5 ) ) { 2028 $html = stripslashes_deep( $_POST['html'] ); 2027 2029 } 2028 2030 2029 2031 $html = apply_filters( 'media_send_to_editor', $html, $id, $attachment ); -
wp-includes/functions.php
diff --git wp-includes/functions.php wp-includes/functions.php index b29b941..78dedb6 100644
$("#wp-auth-check-form iframe").load(function(){ 4020 4020 </script> 4021 4021 </div>' ) ); 4022 4022 } 4023 4024 /** 4025 * Return RegEx body to liberally match an opening HTML tag that: 4026 * 1. Is self-closing or 4027 * 2. Has no body but has a closing tag of the same name or 4028 * 3. Contains a body and a closing tag of the same name 4029 * 4030 * Note: this RegEx does not balance inner tags and does not attempt to produce valid HTML 4031 * 4032 * @since 3.6.0 4033 * 4034 * @param string $tag An HTML tag name. Example: 'video' 4035 * @return string 4036 */ 4037 function get_tag_regex( $tag ) { 4038 if ( empty( $tag ) ) 4039 return; 4040 4041 return sprintf( '(<%1$s[^>]*(?:/?>$|>[\s\S]*?</%1$s>))', tag_escape( $tag ) ); 4042 } 4043 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..7dbbb79 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 if ( props.linkUrl.indexOf( 'mp3' ) ) 110 shortcode.mp3 = props.linkUrl; 111 else if ( props.linkUrl.indexOf( 'm4a' ) ) 112 shortcode.m4a = props.linkUrl; 113 break; 114 case 'audio/mp3': 115 shortcode.mp3 = props.linkUrl; 116 break; 117 case 'audio/m4a': 118 shortcode.m4a = props.linkUrl; 119 break; 120 case 'audio/wav': 121 shortcode.wav = props.linkUrl; 122 break; 123 case 'audio/ogg': 124 shortcode.ogg = props.linkUrl; 125 break; 126 case 'audio/x-ms-wma': 127 case 'audio/wma': 128 shortcode.wma = props.linkUrl; 129 break; 130 } 131 } 132 133 html = wp.shortcode.string({ 134 tag: 'audio', 135 attrs: shortcode 136 }); 137 138 return html; 139 }, 140 141 video: function( props, attachment ) { 142 var shortcode, html; 143 144 props = wp.media.string.props( props, attachment ); 145 146 shortcode = {}; 147 148 if ( props.mime ) { 149 switch ( props.mime ) { 150 case 'video/mp4': 151 shortcode.mp4 = props.linkUrl; 152 break; 153 case 'video/m4v': 154 shortcode.m4v = props.linkUrl; 155 break; 156 case 'video/webm': 157 shortcode.webm = props.linkUrl; 158 break; 159 case 'video/ogg': 160 shortcode.ogv = props.linkUrl; 161 break; 162 case 'video/x-ms-wmv': 163 case 'video/wmv': 164 case 'video/asf': 165 shortcode.wmv = props.linkUrl; 166 break; 167 case 'video/flv': 168 case 'video/x-flv': 169 shortcode.flv = props.linkUrl; 170 break; 171 } 172 } 173 174 html = wp.shortcode.string({ 175 tag: 'video', 176 attrs: shortcode 177 }); 178 179 return html; 180 }, 181 98 182 image: function( props, attachment ) { 99 183 var img = {}, 100 184 options, classes, shortcode, html; … … 575 659 if ( props[ prop ] ) 576 660 options[ option ] = props[ prop ]; 577 661 }); 578 662 } else if ( 'video' === attachment.type ) { 663 html = wp.media.string.video( props ); 664 } else if ( 'audio' === attachment.type ) { 665 html = wp.media.string.audio( props ); 579 666 } else { 580 667 html = wp.media.string.link( props ); 581 668 options.post_title = props.title; -
wp-includes/media.php
diff --git wp-includes/media.php wp-includes/media.php index c543389..8a7acc9 100644
function gallery_shortcode($attr) { 803 803 } 804 804 805 805 /** 806 * Return a filtered list of WP-supported audio formats 807 * 808 * @since 3.6.0 809 * @return array 810 */ 811 function wp_get_audio_extensions() { 812 return apply_filters( 'wp_audio_extensions', array( 'mp3', 'ogg', 'wma', 'm4a', 'wav' ) ); 813 } 814 815 /** 816 * The Audio shortcode. 817 * 818 * This implements the functionality of the Audio Shortcode for displaying 819 * WordPress mp3s in a post. 820 * 821 * @since 3.6.0 822 * 823 * @param array $attr Attributes of the shortcode. 824 * @return string HTML content to display audio. 825 */ 826 function wp_audio_shortcode( $attr ) { 827 $post_id = get_post() ? get_the_ID() : 0; 828 829 static $instances = 0; 830 $instances++; 831 832 $audio = null; 833 834 $default_types = wp_get_audio_extensions(); 835 $defaults_atts = array( 'src' => '' ); 836 foreach ( $default_types as $type ) 837 $defaults_atts[$type] = ''; 838 839 extract( shortcode_atts( $defaults_atts, $attr ) ); 840 841 $primary = false; 842 if ( ! empty( $src ) ) { 843 $type = wp_check_filetype( $src ); 844 if ( ! in_array( $type['ext'], $default_types ) ) { 845 printf( '<a class="wp-post-format-link-audio" href="%1$s">%1$s</a>', $src ); 846 return; 847 } 848 $primary = true; 849 array_unshift( $default_types, 'src' ); 850 } else { 851 foreach ( $default_types as $ext ) { 852 if ( ! empty( $$ext ) ) { 853 $type = wp_check_filetype( $$ext ); 854 if ( $type['ext'] === $ext ) 855 $primary = true; 856 } 857 } 858 } 859 860 if ( ! $primary ) { 861 $audios = get_post_audio( $post_id ); 862 if ( empty( $audios ) ) 863 return; 864 865 $audio = reset( $audios ); 866 $src = wp_get_attachment_url( $audio->ID ); 867 if ( empty( $src ) ) 868 return; 869 870 array_unshift( $default_types, 'src' ); 871 } 872 873 wp_enqueue_style( 'wp-mediaelement' ); 874 wp_enqueue_script( 'wp-mediaelement' ); 875 876 $atts = array( 877 sprintf( 'class="%s"', apply_filters( 'wp_audio_shortcode_class', 'wp-audio-shortcode' ) ), 878 sprintf( 'id="audio-%d-%d"', $post_id, $instances ), 879 ); 880 881 $html = sprintf( '<audio %s controls="controls" preload="none">', join( ' ', $atts ) ); 882 883 $source = '<source type="%s" src="%s" />'; 884 foreach ( $default_types as $fallback ) { 885 if ( ! empty( $$fallback ) ) { 886 $type = wp_check_filetype( $$fallback ); 887 $html .= sprintf( $source, $type['type'], $$fallback ); 888 } 889 } 890 891 $html .= '</audio>'; 892 893 return apply_filters( 'wp_audio_shortcode', $html, $src, $audio, $post_id ); 894 } 895 add_shortcode( 'audio', 'wp_audio_shortcode' ); 896 897 /** 898 * Return a filtered list of WP-supported video formats 899 * 900 * @since 3.6.0 901 * @return array 902 */ 903 function wp_get_video_extensions() { 904 return apply_filters( 'wp_video_extensions', array( 'mp4', 'm4v', 'webm', 'ogv', 'wmv', 'flv' ) ); 905 } 906 907 /** 908 * The Video shortcode. 909 * 910 * This implements the functionality of the Video Shortcode for displaying 911 * WordPress mp4s in a post. 912 * 913 * @since 3.6.0 914 * 915 * @param array $attr Attributes of the shortcode. 916 * @return string HTML content to display video. 917 */ 918 function wp_video_shortcode( $attr ) { 919 global $content_width; 920 $post_id = get_post() ? get_the_ID() : 0; 921 922 static $instances = 0; 923 $instances++; 924 925 $video = null; 926 927 $default_types = wp_get_video_extensions(); 928 $defaults_atts = array( 929 'src' => '', 930 'poster' => '', 931 'height' => 360, 932 'width' => empty( $content_width ) ? 640 : $content_width, 933 ); 934 foreach ( $default_types as $type ) 935 $defaults_atts[$type] = ''; 936 937 extract( shortcode_atts( $defaults_atts, $attr ) ); 938 939 $primary = false; 940 if ( ! empty( $src ) ) { 941 $type = wp_check_filetype( $src ); 942 if ( ! in_array( $type['ext'], $default_types ) ) { 943 printf( '<a class="wp-post-format-link-video" href="%1$s">%1$s</a>', $src ); 944 return; 945 } 946 $primary = true; 947 array_unshift( $default_types, 'src' ); 948 } else { 949 foreach ( $default_types as $ext ) { 950 if ( ! empty( $$ext ) ) { 951 $type = wp_check_filetype( $$ext ); 952 if ( $type['ext'] === $ext ) 953 $primary = true; 954 } 955 } 956 } 957 958 if ( ! $primary ) { 959 $videos = get_post_video( $post_id ); 960 if ( empty( $videos ) ) 961 return; 962 963 $video = reset( $videos ); 964 $src = wp_get_attachment_url( $video->ID ); 965 if ( empty( $src ) ) 966 return; 967 968 array_unshift( $default_types, 'src' ); 969 } 970 971 wp_enqueue_style( 'wp-mediaelement' ); 972 wp_enqueue_script( 'wp-mediaelement' ); 973 974 $atts = array( 975 sprintf( 'class="%s"', apply_filters( 'video_shortcode_class', 'wp-video-shortcode' ) ), 976 sprintf( 'id="video-%d-%d"', $post_id, $instances ), 977 sprintf( 'width="%d"', $width ), 978 sprintf( 'height="%d"', $height ), 979 ); 980 981 if ( ! empty( $poster ) ) 982 $atts[] = sprintf( 'poster="%s"', esc_url( $poster ) ); 983 984 $html = sprintf( '<video %s controls="controls" preload="none">', join( ' ', $atts ) ); 985 986 $source = '<source type="%s" src="%s" />'; 987 foreach ( $default_types as $fallback ) { 988 if ( ! empty( $$fallback ) ) { 989 $type = wp_check_filetype( $$fallback ); 990 // m4v sometimes shows up as video/mpeg which collides with mp4 991 if ( 'm4v' === $type['ext'] ) 992 $type['type'] = 'video/m4v'; 993 $html .= sprintf( $source, $type['type'], $$fallback ); 994 } 995 } 996 997 $html .= '</video>'; 998 999 return apply_filters( 'wp_video_shortcode', $html, $src, $video, $post_id ); 1000 } 1001 add_shortcode( 'video', 'wp_video_shortcode' ); 1002 1003 /** 806 1004 * Display previous image link that has the same post parent. 807 1005 * 808 1006 * @since 2.5.0 … … function wp_enqueue_media( $args = array() ) { 1542 1740 1543 1741 do_action( 'wp_enqueue_media' ); 1544 1742 } 1743 1744 /** 1745 * Retrieve audio attached to the passed post 1746 * 1747 * @since 3.6.0 1748 * 1749 * @param int $post_id Post ID 1750 * @return array Found audio attachments 1751 */ 1752 function get_post_audio( $post_id = 0 ) { 1753 $post = empty( $post_id ) ? get_post() : get_post( $post_id ); 1754 if ( empty( $post ) ) 1755 return; 1756 1757 $children = get_children( array( 1758 'post_parent' => $post->ID, 1759 'post_type' => 'attachment', 1760 'post_mime_type' => 'audio', 1761 'posts_per_page' => -1 1762 ) ); 1763 1764 if ( ! empty( $children ) ) 1765 return $children; 1766 } 1767 1768 /** 1769 * Retrieve video attached to the passed post 1770 * 1771 * @since 3.6.0 1772 * 1773 * @param int $post_id Post ID 1774 * @return array Found video attachments 1775 */ 1776 function get_post_video( $post_id = 0 ) { 1777 $post = empty( $post_id ) ? get_post() : get_post( $post_id ); 1778 if ( empty( $post ) ) 1779 return; 1780 1781 $children = get_children( array( 1782 'post_parent' => $post->ID, 1783 'post_type' => 'attachment', 1784 'post_mime_type' => 'video', 1785 'posts_per_page' => -1 1786 ) ); 1787 1788 if ( ! empty( $children ) ) 1789 return $children; 1790 } 1791 1792 /** 1793 * Audio embed handler callback. 1794 * 1795 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}. 1796 * @param array $attr Embed attributes. 1797 * @param string $url The original URL that was matched by the regex. 1798 * @param array $rawattr The original unmodified attributes. 1799 * @return string The embed HTML. 1800 */ 1801 function wp_audio_embed( $matches, $attr, $url, $rawattr ) { 1802 $audio = do_shortcode( '[audio src="' . $url . '" /]' ); 1803 return apply_filters( 'wp_audio_embed', $audio, $attr, $url, $rawattr ); 1804 } 1805 wp_embed_register_handler( 'wp_audio_embed', '#https?://.+?\.(' . join( '|', wp_get_audio_extensions() ) . ')#i', 'wp_audio_embed', 9999 ); 1806 1807 /** 1808 * Video embed handler callback. 1809 * 1810 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}. 1811 * @param array $attr Embed attributes. 1812 * @param string $url The original URL that was matched by the regex. 1813 * @param array $rawattr The original unmodified attributes. 1814 * @return string The embed HTML. 1815 */ 1816 function wp_video_embed( $matches, $attr, $url, $rawattr ) { 1817 $dimensions = ''; 1818 if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) { 1819 $dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] ); 1820 $dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] ); 1821 } 1822 $video = do_shortcode( '[video ' . $dimensions . 'src="' . $url . '" /]' ); 1823 return apply_filters( 'wp_video_embed', $video, $attr, $url, $rawattr ); 1824 } 1825 wp_embed_register_handler( 'wp_video_embed', '#https?://.+?\.(' . join( '|', wp_get_video_extensions() ) . ')#i', 'wp_video_embed', 9999 ); -
wp-includes/post-formats.php
diff --git wp-includes/post-formats.php wp-includes/post-formats.php index 828447b..7dfc171 100644
function post_formats_compat( $content, $id = 0 ) { 308 308 $show_content = true; 309 309 $format_output = ''; 310 310 $meta = get_post_format_meta( $post->ID ); 311 // passed by ref in preg_match() 312 $matches = array(); 311 313 312 314 switch ( $format ) { 313 315 case 'link': … … function post_formats_compat( $content, $id = 0 ) { 365 367 break; 366 368 367 369 case 'gallery': 368 preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches ); 369 if ( ! empty( $matches ) && isset( $matches[2] ) ) { 370 foreach ( (array) $matches[2] as $match ) { 371 if ( 'gallery' === $match ) 372 break 2; // foreach + case 373 } 374 } 375 376 if ( ! empty( $meta['gallery'] ) ) { 370 if ( ! has_shortcode( $post->post_content, $format ) && ! empty( $meta['gallery'] ) ) 377 371 $format_output .= $meta['gallery']; 378 }379 372 break; 380 373 381 374 case 'video': 382 375 case 'audio': 383 $shortcode_regex = '/' . get_shortcode_regex() . '/s'; 384 $matches = preg_match( $shortcode_regex, $content ); 385 if ( ! $matches || $format !== $matches[2] ) { 386 if ( ! empty( $meta['media'] ) ) { 387 // the metadata is a shortcode or an embed code 388 if ( preg_match( $shortcode_regex, $meta['media'] ) || preg_match( '#<[^>]+>#', $meta['media'] ) ) { 389 $format_output .= $meta['media']; 390 } elseif ( ! stristr( $content, $meta['media'] ) ) { 391 // attempt to embed the URL 392 $format_output .= sprintf( '[embed]%s[/embed]', $meta['media'] ); 393 } 376 if ( ! has_shortcode( $post->post_content, $format ) && ! empty( $meta['media'] ) ) { 377 // the metadata is a shortcode or an embed code 378 if ( preg_match( '/' . get_shortcode_regex() . '/s', $meta['media'] ) || preg_match( '#<[^>]+>#', $meta['media'] ) ) { 379 $format_output .= $meta['media']; 380 } elseif ( ! stristr( $content, $meta['media'] ) ) { 381 // attempt to embed the URL 382 $format_output .= sprintf( '[embed]%s[/embed]', $meta['media'] ); 394 383 } 395 } 384 } 396 385 break; 397 386 default: 398 387 return $content; -
wp-includes/script-loader.php
diff --git wp-includes/script-loader.php wp-includes/script-loader.php index 84b76d3..bf3e4fb 100644
function wp_default_scripts( &$scripts ) { 277 277 278 278 $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.8', 1 ); 279 279 280 $scripts->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelement-and-player$suffix.js", array('jquery'), '2.10.1', 1 ); 281 $scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement.js", array('mediaelement'), false, 1 ); 282 280 283 $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), false, 1 ); 281 284 did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n', array( 282 285 'empty' => __('Strength indicator'), … … function wp_default_styles( &$styles ) { 543 546 $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons' ) ); 544 547 $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" ); 545 548 549 $styles->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelementplayer$suffix.css" ); 550 $styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement.css", array( 'mediaelement' ) ); 551 546 552 foreach ( $rtl_styles as $rtl_style ) { 547 553 $styles->add_data( $rtl_style, 'rtl', true ); 548 554 if ( $suffix && ! in_array( $rtl_style, $no_suffix ) ) -
wp-includes/shortcodes.php
diff --git wp-includes/shortcodes.php wp-includes/shortcodes.php index bdc3f9b..b7a0b1b 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 /** 145 * Whether the passed content contains the specified shortcode 146 * 147 * @since 3.6.0 148 * 149 * @global array $shortcode_tags 150 * @param string $tag 151 * @return boolean 152 */ 153 function has_shortcode( $content, $tag ) { 154 if ( shortcode_exists( $tag ) ) { 155 $matches = array(); 156 preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); 157 if ( empty( $matches ) ) 158 return false; 159 160 foreach ( $matches as $shortcode ) { 161 if ( $tag === $shortcode[2] ) 162 return true; 163 } 164 } 165 return false; 166 } 167 168 /** 131 169 * Search content for shortcodes and filter shortcodes through their hooks. 132 170 * 133 171 * If there are no shortcode tags defined, then the content will be returned