diff --git wp-includes/media.php wp-includes/media.php
index 974aa79..270fe54 100644
|
|
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 | $ext_providers_patterns = apply_filters( 'wp_video_external_providers', array( |
| 1751 | 'youtube' => array( |
| 1752 | 'pattern' => '#^https?://(:?www\.)?(:?youtube\.com/watch|youtu\.be/)#', |
| 1753 | 'mimetype' => 'video/youtube', |
| 1754 | ), |
| 1755 | )); |
1715 | 1756 | |
1716 | 1757 | $primary = false; |
| 1758 | $match = false; |
1717 | 1759 | if ( ! empty( $src ) ) { |
1718 | | if ( ! preg_match( $yt_pattern, $src ) ) { |
| 1760 | foreach($ext_providers_patterns as $provider) { |
| 1761 | if( preg_match( $provider['pattern'], $src ) ) { |
| 1762 | $match = true; |
| 1763 | break; |
| 1764 | } |
| 1765 | } |
| 1766 | if ( ! $match ) { |
1719 | 1767 | $type = wp_check_filetype( $src, wp_get_mime_types() ); |
1720 | 1768 | if ( ! in_array( strtolower( $type['ext'] ), $default_types ) ) { |
1721 | 1769 | return sprintf( '<a class="wp-embedded-video" href="%s">%s</a>', esc_url( $src ), esc_html( $src ) ); |
… |
… |
function wp_video_shortcode( $attr, $content = '' ) { |
1788 | 1836 | $attr_strings[] = $k . '="' . esc_attr( $v ) . '"'; |
1789 | 1837 | } |
1790 | 1838 | |
1791 | | $html = ''; |
1792 | | if ( 'mediaelement' === $library && 1 === $instances ) |
1793 | | $html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n"; |
| 1839 | /** |
| 1840 | * Filters the HTML added before the video shortcode output. |
| 1841 | * |
| 1842 | * Give the possibility to insert some HTML code before the <video> tag |
| 1843 | * generated by a video shortcode. |
| 1844 | * |
| 1845 | * @since 4.0.0 |
| 1846 | * |
| 1847 | * @param string $html Empty variable to be replaced with the HTML snippet to insert before the <video> tag. |
| 1848 | * @param string $library Media library used for the video shortcode. |
| 1849 | * @param int $instances Unique numeric ID of this video shortcode instance. |
| 1850 | */ |
| 1851 | $html = apply_filters('wp_video_shortcode_pre_html', '', $library, $instances); |
1794 | 1852 | $html .= sprintf( '<video %s controls="controls">', join( ' ', $attr_strings ) ); |
1795 | 1853 | |
1796 | 1854 | $fileurl = ''; |
… |
… |
function wp_video_shortcode( $attr, $content = '' ) { |
1800 | 1858 | if ( empty( $fileurl ) ) |
1801 | 1859 | $fileurl = $$fallback; |
1802 | 1860 | |
1803 | | if ( 'src' === $fallback && preg_match( $yt_pattern, $src ) ) { |
1804 | | $type = array( 'type' => 'video/youtube' ); |
1805 | | } else { |
| 1861 | $match = false; |
| 1862 | foreach( $ext_providers_patterns as $provider ) { |
| 1863 | if( 'src' === $fallback && preg_match( $provider['pattern'], $src ) ) { |
| 1864 | $match = true; |
| 1865 | $type = array( 'type' => $provider['mimetype'] ); |
| 1866 | break; |
| 1867 | } |
| 1868 | } |
| 1869 | if ( ! $match ) { |
1806 | 1870 | $type = wp_check_filetype( $$fallback, wp_get_mime_types() ); |
1807 | 1871 | } |
1808 | 1872 | $url = add_query_arg( '_', $instances, $$fallback ); |
… |
… |
function wp_video_shortcode( $attr, $content = '' ) { |
1817 | 1881 | $html .= trim( $content ); |
1818 | 1882 | } |
1819 | 1883 | |
1820 | | if ( 'mediaelement' === $library ) |
1821 | | $html .= wp_mediaelement_fallback( $fileurl ); |
| 1884 | /** |
| 1885 | * Filters the HTML added inside the video shortcode output. |
| 1886 | * |
| 1887 | * Give the possibility to insert some HTML code inside the <video> tag |
| 1888 | * generated by a video shortcode. |
| 1889 | * |
| 1890 | * @since 4.0.0 |
| 1891 | * |
| 1892 | * @param string $html Empty variable to be replaced with the HTML snippet to append into the <video> tag. |
| 1893 | * @param string $library Media library used for the video shortcode. |
| 1894 | * @param string $fileurl The URL of the video file. |
| 1895 | * @param int $post_id Post ID. |
| 1896 | */ |
| 1897 | $html .= apply_filters('wp_video_shortcode_inside_html', '', $library, $fileurl, $post_id); |
1822 | 1898 | $html .= '</video>'; |
1823 | 1899 | |
1824 | 1900 | $html = sprintf( '<div style="width: %dpx; max-width: 100%%;" class="wp-video">%s</div>', $width, $html ); |
… |
… |
function wp_video_shortcode( $attr, $content = '' ) { |
1838 | 1914 | } |
1839 | 1915 | add_shortcode( 'video', 'wp_video_shortcode' ); |
1840 | 1916 | |
| 1917 | function wp_mediaelement_video_shortcode_pre_html($html, $library, $instances) { |
| 1918 | if ( 'mediaelement' === $library && 1 === $instances ) |
| 1919 | $html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n"; |
| 1920 | return $html; |
| 1921 | } |
| 1922 | add_filter('wp_video_shortcode_pre_html', 'wp_mediaelement_video_shortcode_pre_html', 10, 3); |
| 1923 | |
| 1924 | function wp_mediaelement_video_shortcode_inside_html($html, $library, $fileurl, $post_id) { |
| 1925 | if ( 'mediaelement' === $library ) |
| 1926 | $html .= wp_mediaelement_fallback( $fileurl ); |
| 1927 | return $html; |
| 1928 | } |
| 1929 | add_filter('wp_video_shortcode_inside_html', 'wp_mediaelement_video_shortcode_inside_html', 10, 4); |
| 1930 | |
1841 | 1931 | /** |
1842 | 1932 | * Display previous image link that has the same post parent. |
1843 | 1933 | * |