| 1842 | * Conditionally enqueue media-related CSS in the <head> |
| 1843 | * |
| 1844 | */ |
| 1845 | function wp_enqueue_media_styles() { |
| 1846 | if ( ! have_posts() ) { |
| 1847 | return; |
| 1848 | } |
| 1849 | |
| 1850 | global $wp_query; |
| 1851 | foreach ( $wp_query->posts as $post ) { |
| 1852 | if ( has_shortcode( $post->post_content, 'video' ) ) { |
| 1853 | $library = apply_filters( 'wp_video_shortcode_library', 'mediaelement' ); |
| 1854 | if ( 'mediaelement' === $library && did_action( 'init' ) ) { |
| 1855 | wp_enqueue_style( 'wp-mediaelement' ); |
| 1856 | break; |
| 1857 | } |
| 1858 | } |
| 1859 | |
| 1860 | if ( has_shortcode( $post->post_content, 'audio' ) ) { |
| 1861 | $library = apply_filters( 'wp_audio_shortcode_library', 'mediaelement' ); |
| 1862 | if ( 'mediaelement' === $library && did_action( 'init' ) ) { |
| 1863 | wp_enqueue_style( 'wp-mediaelement' ); |
| 1864 | break; |
| 1865 | } |
| 1866 | } |
| 1867 | |
| 1868 | if ( has_shortcode( $post->post_content, 'playlist' ) ) { |
| 1869 | wp_enqueue_style( 'wp-mediaelement' ); |
| 1870 | break; |
| 1871 | } |
| 1872 | } |
| 1873 | } |
| 1874 | |
| 1875 | /** |