WordPress 4.5
[autoinstalls/wordpress.git] / wp-content / themes / twentyfourteen / inc / widgets.php
index fee265ee3c2eef3c074a42ae0ec68d91336a290e..ee766cb3086c46aed9e89894e1945b40f2de7103 100644 (file)
@@ -34,7 +34,28 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
                parent::__construct( 'widget_twentyfourteen_ephemera', __( 'Twenty Fourteen Ephemera', 'twentyfourteen' ), array(
                        'classname'   => 'widget_twentyfourteen_ephemera',
                        'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ),
+                       'customize_selective_refresh' => true,
                ) );
+
+               if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) {
+                       add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
+               }
+       }
+
+       /**
+        * Enqueue scripts.
+        *
+        * @since Twenty Fourteen 1.7
+        */
+       public function enqueue_scripts() {
+               /** This filter is documented in wp-includes/media.php */
+               $audio_library = apply_filters( 'wp_audio_shortcode_library', 'mediaelement' );
+               /** This filter is documented in wp-includes/media.php */
+               $video_library = apply_filters( 'wp_video_shortcode_library', 'mediaelement' );
+               if ( in_array( 'mediaelement', array( $video_library, $audio_library ), true ) ) {
+                       wp_enqueue_style( 'wp-mediaelement' );
+                       wp_enqueue_script( 'wp-mediaelement' );
+               }
        }
 
        /**