Skip to content

Commit 8906fa2

Browse files
committed
alternate approach
1 parent ca6fa54 commit 8906fa2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

php/media/class-video.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ public function player_enabled() {
9595
* Initialises the Cloudinary player if it's enabled and if video content is found.
9696
*/
9797
public function init_player() {
98-
9998
if ( isset( $this->config['video_player'] ) && 'cld' === $this->config['video_player'] && ! is_admin() ) {
99+
global $wp_query;
100+
$this->player_enabled = true;
101+
$posts = $wp_query->get_posts();
100102
// Check content has a video to enqueue assets in correct location.
101-
while ( have_posts() ) {
102-
the_post();
103+
foreach ( $posts as $post ) {
103104
$has_video = $this->media->filter->get_video_shortcodes( get_the_content() );
104105
$video_tags = $this->media->filter->get_media_tags( get_the_content(), 'video' );
105106
if ( ! empty( $has_video ) || ! empty( $video_tags ) ) {
@@ -124,8 +125,6 @@ public function init_player() {
124125
break; // Exit since we determined that a video is present.
125126
}
126127
}
127-
// Reset wp_query.
128-
rewind_posts();
129128
}
130129
}
131130

0 commit comments

Comments
 (0)