Skip to content

Commit

Permalink
Merge branch 'release/v1.3.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
wpmark committed Mar 21, 2024
2 parents 2db33a6 + 3e7104e commit ab05969
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
45 changes: 29 additions & 16 deletions better-core-video-embeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Description: A plugin which enhances the core video embeds for Youtube and Vimeo videos by not loading unnecessary scripts until they are needed.
Requires at least: 6.0
Requires PHP: 7.0
Version: 1.3.2
Version: 1.3.3
Author: Highrise Digital
Author URI: https://highrise.digital/
License: GPL-2.0-or-later
Expand All @@ -15,7 +15,7 @@
// define variable for path to this plugin file.
define( 'HD_BCVE_LOCATION', dirname( __FILE__ ) );
define( 'HD_BCVE_LOCATION_URL', plugins_url( '', __FILE__ ) );
define( 'HD_BCVE_VERSION', '1.3.2' );
define( 'HD_BCVE_VERSION', '1.3.3' );

/**
* Function to run on plugins load.
Expand Down Expand Up @@ -139,16 +139,29 @@ function hd_bcve_render_core_embed_block( $block_content, $block, $instance ) {
case 'www.youtube.com':
case 'youtube.com':

// parse the query part of the URL into its arguments.
parse_str( $parsed_video_url['query'], $video_url_query_args );
if ( empty( $parsed_video_url['query'] ) ) {

// if we cannot find a youtube video id.
if ( empty( $video_url_query_args['v'] ) ) {
return $block_content;
}
// if we have a path.
if ( empty( $parsed_video_url['path'] ) ) {
return $block_content;
}

// remove live/embed path and trailing slash.
$video_id = str_replace( array( 'live/', 'embed/', '/' ), '', $parsed_video_url['path'] );

} else {

// set the video id to the v query arg.
$video_id = $video_url_query_args['v'];
// parse the query part of the URL into its arguments.
parse_str( $parsed_video_url['query'], $video_url_query_args );

// if we cannot find a youtube video id.
if ( empty( $video_url_query_args['v'] ) ) {
return $block_content;
}

// set the video id to the v query arg.
$video_id = $video_url_query_args['v'];
}

// if we don't have a custom thumbnail.
if ( empty( $thumbnail_url ) ) {
Expand Down Expand Up @@ -186,7 +199,7 @@ function hd_bcve_render_core_embed_block( $block_content, $block, $instance ) {
// for vimeo urls.
case 'vimeo.com':
case 'www.vimeo.com':

// if we have a path.
if ( empty( $parsed_video_url['path'] ) ) {
return $block_content;
Expand All @@ -205,7 +218,7 @@ function hd_bcve_render_core_embed_block( $block_content, $block, $instance ) {

// break out the switch.
break;

// for vimeo urls.
case 'www.dailymotion.com':
case 'dailymotion.com':
Expand All @@ -223,9 +236,9 @@ function hd_bcve_render_core_embed_block( $block_content, $block, $instance ) {

// get the vimeo thumbnail url for this video.
$thumbnail_url = hd_bcve_get_dailymotion_video_thumbnail_url( $video_id );

}

// break out the switch.
break;

Expand Down Expand Up @@ -405,7 +418,7 @@ function hd_bcve_get_vimeo_video_thumbnail_url( $video_id = '' ) {
set_transient( 'hd_bcve_' . $video_id, $image_url, DAY_IN_SECONDS );

}

// return the url.
return apply_filters( 'hd_bcve_vimeo_video_thumbnail_url', $image_url, $video_id );

Expand Down Expand Up @@ -454,7 +467,7 @@ function hd_bcve_get_dailymotion_video_thumbnail_url( $video_id = '' ) {
set_transient( 'hd_bcve_' . $video_id, $image_url, DAY_IN_SECONDS );

}

// return the url.
return apply_filters( 'hd_bcve_dailymotion_video_thumbnail_url', $image_url, $video_id );

Expand Down
9 changes: 6 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://example.com/
Tags: embed, oembed, youtube, vimeo, performance, blocks
Requires at least: 6.0
Tested up to: 6.4.2
Stable tag: 1.3.2
Stable tag: 1.3.3
Requires PHP: 8.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -49,10 +49,13 @@ Yes! As of version 1.3, you can set a custom thumbnail on the embed block and th

== Changelog ==

= 1.3.2 (19/05/2024) =
= 1.3.3 (21/03/2024) =
* Ensure (previously) live video URLs from Youtube embed correctly. Thanks for @bacoords for the development on this.

= 1.3.2 (19/03/2024) =
* Use regex instead of the domDocument for grabbing a video caption.

= 1.3.1 (18/05/2024) =
= 1.3.1 (18/03/2024) =
* Added a fix which ensures special characters in video captions are outputted correctly.

= 1.3 (14/12/2023) =
Expand Down

0 comments on commit ab05969

Please sign in to comment.