diff --git a/wp-includes/media.php b/wp-includes/media.php
index 974aa79..216f6fc 100644
|
a
|
b
|
function wp_audio_shortcode( $attr, $content = '' ) {
|
| 1571 | 1571 | $attr_strings[] = $k . '="' . esc_attr( $v ) . '"'; |
| 1572 | 1572 | } |
| 1573 | 1573 | |
| 1574 | | $html = ''; |
| 1575 | | if ( 'mediaelement' === $library && 1 === $instances ) |
| 1576 | | $html .= "<!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->\n"; |
| | 1574 | /** |
| | 1575 | * Filters the HTML added inside the audio shortcode output. |
| | 1576 | * |
| | 1577 | * Give the possibility to insert some HTML code before the <audio> tag |
| | 1578 | * generated by an audio shortcode. |
| | 1579 | * |
| | 1580 | * @since 4.0.0 |
| | 1581 | * |
| | 1582 | * @param string $html Empty variable to be replaced with the HTML snippet to insert before the <audio> tag. |
| | 1583 | * @param string $library Media library used for the audio shortcode. |
| | 1584 | * @param int $instances Unique numeric ID of this audio shortcode instance. |
| | 1585 | */ |
| | 1586 | $html = apply_filters('wp_audio_shortcode_pre_html', '', $library, $instances); |
| 1577 | 1587 | $html .= sprintf( '<audio %s controls="controls">', join( ' ', $attr_strings ) ); |
| 1578 | 1588 | |
| 1579 | 1589 | $fileurl = ''; |
| … |
… |
function wp_audio_shortcode( $attr, $content = '' ) {
|
| 1588 | 1598 | } |
| 1589 | 1599 | } |
| 1590 | 1600 | |
| 1591 | | if ( 'mediaelement' === $library ) |
| 1592 | | $html .= wp_mediaelement_fallback( $fileurl ); |
| | 1601 | /** |
| | 1602 | * Filters the HTML added inside the audio shortcode output. |
| | 1603 | * |
| | 1604 | * Give the possibility to insert some HTML code inside the <audio> tag |
| | 1605 | * generated by an audio shortcode. |
| | 1606 | * |
| | 1607 | * @since 4.0.0 |
| | 1608 | * |
| | 1609 | * @param string $html Empty variable to be replaced with the HTML snippet to append into the <audio> tag. |
| | 1610 | * @param string $library Media library used for the audio shortcode. |
| | 1611 | * @param string $fileurl The URL of the audio file. |
| | 1612 | * @param int $post_id Post ID. |
| | 1613 | */ |
| | 1614 | $html .= apply_filters('wp_audio_shortcode_inside_html', '', $library, $fileurl, $post_id); |
| 1593 | 1615 | $html .= '</audio>'; |
| 1594 | 1616 | |
| 1595 | 1617 | /** |
| … |
… |
function wp_audio_shortcode( $attr, $content = '' ) {
|
| 1607 | 1629 | } |
| 1608 | 1630 | add_shortcode( 'audio', 'wp_audio_shortcode' ); |
| 1609 | 1631 | |
| | 1632 | function wp_mediaelement_audio_shortcode_pre_html($html, $library, $instances) { |
| | 1633 | if ( 'mediaelement' === $library && 1 === $instances ) |
| | 1634 | $html .= "<!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->\n"; |
| | 1635 | return $html; |
| | 1636 | } |
| | 1637 | add_filter('wp_audio_shortcode_pre_html', 'wp_mediaelement_audio_shortcode_pre_html', 10, 3); |
| | 1638 | |
| | 1639 | function wp_mediaelement_audio_shortcode_inside_html($html, $library, $fileurl, $post_id) { |
| | 1640 | if ( 'mediaelement' === $library ) |
| | 1641 | $html .= wp_mediaelement_fallback( $fileurl ); |
| | 1642 | return $html; |
| | 1643 | } |
| | 1644 | add_filter('wp_audio_shortcode_inside_html', 'wp_mediaelement_audio_shortcode_inside_html', 10, 4); |
| | 1645 | |
| 1610 | 1646 | /** |
| 1611 | 1647 | * Return a filtered list of WP-supported video formats |
| 1612 | 1648 | * |
| … |
… |
function wp_video_shortcode( $attr, $content = '' ) {
|
| 1711 | 1747 | } |
| 1712 | 1748 | } |
| 1713 | 1749 | |
| 1714 | | $yt_pattern = '#^https?://(:?www\.)?(:?youtube\.com/watch|youtu\.be/)#'; |
| | 1750 | /** |
| | 1751 | * Filters the default external video providers patterns used for the video shortcode. |
| | 1752 | * |
| | 1753 | * @since 4.0.0 |
| | 1754 | * |
| | 1755 | * @param array $patterns An associative array listing the external video providers. |
| | 1756 | */ |
| | 1757 | $ext_providers_patterns = apply_filters( 'wp_video_external_providers', array( |
| | 1758 | 'youtube' => array( |
| | 1759 | 'pattern' => '#^https?://(:?www\.)?(:?youtube\.com/watch|youtu\.be/)#', |
| | 1760 | 'mimetype' => 'video/youtube', |
| | 1761 | ), |
| | 1762 | )); |
| 1715 | 1763 | |
| 1716 | 1764 | $primary = false; |
| | 1765 | $match = false; |
| 1717 | 1766 | if ( ! empty( $src ) ) { |
| 1718 | | if ( ! preg_match( $yt_pattern, $src ) ) { |
| | 1767 | foreach($ext_providers_patterns as $provider) { |
| | 1768 | if( preg_match( $provider['pattern'], $src ) ) { |
| | 1769 | $match = true; |
| | 1770 | break; |
| | 1771 | } |
| | 1772 | } |
| | 1773 | if ( ! $match ) { |
| 1719 | 1774 | $type = wp_check_filetype( $src, wp_get_mime_types() ); |
| 1720 | 1775 | if ( ! in_array( strtolower( $type['ext'] ), $default_types ) ) { |
| 1721 | 1776 | return sprintf( '<a class="wp-embedded-video" href="%s">%s</a>', esc_url( $src ), esc_html( $src ) ); |
| … |
… |
function wp_video_shortcode( $attr, $content = '' ) {
|
| 1788 | 1843 | $attr_strings[] = $k . '="' . esc_attr( $v ) . '"'; |
| 1789 | 1844 | } |
| 1790 | 1845 | |
| 1791 | | $html = ''; |
| 1792 | | if ( 'mediaelement' === $library && 1 === $instances ) |
| 1793 | | $html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n"; |
| | 1846 | /** |
| | 1847 | * Filters the HTML added before the video shortcode output. |
| | 1848 | * |
| | 1849 | * Give the possibility to insert some HTML code before the <video> tag |
| | 1850 | * generated by a video shortcode. |
| | 1851 | * |
| | 1852 | * @since 4.0.0 |
| | 1853 | * |
| | 1854 | * @param string $html Empty variable to be replaced with the HTML snippet to insert before the <video> tag. |
| | 1855 | * @param string $library Media library used for the video shortcode. |
| | 1856 | * @param int $instances Unique numeric ID of this video shortcode instance. |
| | 1857 | */ |
| | 1858 | $html = apply_filters('wp_video_shortcode_pre_html', '', $library, $instances); |
| 1794 | 1859 | $html .= sprintf( '<video %s controls="controls">', join( ' ', $attr_strings ) ); |
| 1795 | 1860 | |
| 1796 | 1861 | $fileurl = ''; |
| … |
… |
function wp_video_shortcode( $attr, $content = '' ) {
|
| 1800 | 1865 | if ( empty( $fileurl ) ) |
| 1801 | 1866 | $fileurl = $$fallback; |
| 1802 | 1867 | |
| 1803 | | if ( 'src' === $fallback && preg_match( $yt_pattern, $src ) ) { |
| 1804 | | $type = array( 'type' => 'video/youtube' ); |
| 1805 | | } else { |
| | 1868 | $match = false; |
| | 1869 | foreach( $ext_providers_patterns as $provider ) { |
| | 1870 | if( 'src' === $fallback && preg_match( $provider['pattern'], $src ) ) { |
| | 1871 | $match = true; |
| | 1872 | $type = array( 'type' => $provider['mimetype'] ); |
| | 1873 | break; |
| | 1874 | } |
| | 1875 | } |
| | 1876 | if ( ! $match ) { |
| 1806 | 1877 | $type = wp_check_filetype( $$fallback, wp_get_mime_types() ); |
| 1807 | 1878 | } |
| 1808 | 1879 | $url = add_query_arg( '_', $instances, $$fallback ); |
| … |
… |
function wp_video_shortcode( $attr, $content = '' ) {
|
| 1817 | 1888 | $html .= trim( $content ); |
| 1818 | 1889 | } |
| 1819 | 1890 | |
| 1820 | | if ( 'mediaelement' === $library ) |
| 1821 | | $html .= wp_mediaelement_fallback( $fileurl ); |
| | 1891 | /** |
| | 1892 | * Filters the HTML added inside the video shortcode output. |
| | 1893 | * |
| | 1894 | * Give the possibility to insert some HTML code inside the <video> tag |
| | 1895 | * generated by a video shortcode. |
| | 1896 | * |
| | 1897 | * @since 4.0.0 |
| | 1898 | * |
| | 1899 | * @param string $html Empty variable to be replaced with the HTML snippet to append into the <video> tag. |
| | 1900 | * @param string $library Media library used for the video shortcode. |
| | 1901 | * @param string $fileurl The URL of the video file. |
| | 1902 | * @param int $post_id Post ID. |
| | 1903 | */ |
| | 1904 | $html .= apply_filters('wp_video_shortcode_inside_html', '', $library, $fileurl, $post_id); |
| 1822 | 1905 | $html .= '</video>'; |
| 1823 | 1906 | |
| 1824 | 1907 | $html = sprintf( '<div style="width: %dpx; max-width: 100%%;" class="wp-video">%s</div>', $width, $html ); |
| … |
… |
function wp_video_shortcode( $attr, $content = '' ) {
|
| 1838 | 1921 | } |
| 1839 | 1922 | add_shortcode( 'video', 'wp_video_shortcode' ); |
| 1840 | 1923 | |
| | 1924 | function wp_mediaelement_video_shortcode_pre_html($html, $library, $instances) { |
| | 1925 | if ( 'mediaelement' === $library && 1 === $instances ) |
| | 1926 | $html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n"; |
| | 1927 | return $html; |
| | 1928 | } |
| | 1929 | add_filter('wp_video_shortcode_pre_html', 'wp_mediaelement_video_shortcode_pre_html', 10, 3); |
| | 1930 | |
| | 1931 | function wp_mediaelement_video_shortcode_inside_html($html, $library, $fileurl, $post_id) { |
| | 1932 | if ( 'mediaelement' === $library ) |
| | 1933 | $html .= wp_mediaelement_fallback( $fileurl ); |
| | 1934 | return $html; |
| | 1935 | } |
| | 1936 | add_filter('wp_video_shortcode_inside_html', 'wp_mediaelement_video_shortcode_inside_html', 10, 4); |
| | 1937 | |
| 1841 | 1938 | /** |
| 1842 | 1939 | * Display previous image link that has the same post parent. |
| 1843 | 1940 | * |