Skip to content

Commit

Permalink
Merge branch 'release/v1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
wpmark committed Dec 7, 2023
2 parents 8219d88 + b1362a4 commit 7255f76
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 20 deletions.
4 changes: 2 additions & 2 deletions assets/js/better-core-video-embeds.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// loop through each of the hd core embed wrapper elements on the page.
// these are the elements that should contain the thumbnail.
document.querySelectorAll( '.hd-bcve-wrapper' ).forEach(( el, i ) => {
document.querySelectorAll( '.hd-bcve-wrapper-js' ).forEach(( el, i ) => {

// get the associated template element which holds the embed code.
// it is the next element after the wrapper.
Expand Down Expand Up @@ -70,4 +70,4 @@ document.querySelectorAll( '.hd-bcve-wrapper' ).forEach(( el, i ) => {

});

});
});
2 changes: 1 addition & 1 deletion assets/js/better-core-video-embeds.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 24 additions & 14 deletions better-core-video-embeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@ function hd_bcve_plugins_loaded() {
*/
function hd_bcve_enqueue_scripts() {

// enqueue the front end script to invoking the video embed on image click.
wp_enqueue_script(
'better-core-video-embeds-js',
HD_BCVE_LOCATION_URL . '/assets/js/better-core-video-embeds.min.js',
false,
false,
true
);
// only if the page has a core embed block present.
if ( has_block( 'core/embed' ) ) {

// enqueue the front end script to invoking the video embed on image click.
wp_enqueue_script(
'better-core-video-embeds-js',
HD_BCVE_LOCATION_URL . '/assets/js/better-core-video-embeds.min.js',
false,
false,
true
);

}
}

add_action( 'wp_enqueue_scripts', 'hd_bcve_enqueue_scripts' );
Expand All @@ -52,11 +56,16 @@ function hd_bcve_enqueue_scripts() {
*/
function hd_bcve_register_block_style() {

// register the style for this block.
wp_enqueue_style(
'better-core-video-embeds-styles',
HD_BCVE_LOCATION_URL . '/assets/css/better-core-video-embeds.min.css'
);
// only if the page has a core embed block present.
if ( has_block( 'core/embed' ) ) {

// register the style for this block.
wp_enqueue_style(
'better-core-video-embeds-styles',
HD_BCVE_LOCATION_URL . '/assets/css/better-core-video-embeds.min.css'
);

}

}

Expand Down Expand Up @@ -184,6 +193,7 @@ function hd_bcve_render_core_embed_block( $block_content, $block, $instance ) {
$wrapper_classes = [
'wp-block-image',
'hd-bcve-wrapper',
'hd-bcve-wrapper-js',
'is--' . $block['attrs']['providerNameSlug'],
];

Expand All @@ -207,7 +217,7 @@ function hd_bcve_render_core_embed_block( $block_content, $block, $instance ) {
}

// allow the classes to be filtered.
$wrapper_classes = apply_filters( '', $wrapper_classes, $block, $video_id, $thumbnail_url );
$wrapper_classes = apply_filters( 'hd_bcve_wrapper_classes', $wrapper_classes, $block, $video_id, $thumbnail_url );

// buffer the output as we need to return not echo.
ob_start();
Expand Down
10 changes: 7 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: highrisedigital,wpmarkuk
Donate link: https://example.com/
Tags: embed, oembed, youtube, vimeo, performance, blocks
Requires at least: 6.0
Tested up to: 6.1.1
Stable tag: 1.1.3
Requires PHP: 7.0
Tested up to: 6.4.2
Stable tag: 1.2
Requires PHP: 8.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -45,6 +45,10 @@ The plugin provides progressive enhancement, therefore if you no longer use this

== Changelog ==

= 1.2 (07/12/2023) =
* Add a name for the wrapper CSS filter which was missing.
* JS and CSS target using different classes.

= 1.1.4 (22/02/2023) =
* Load the CSS and JS on all pages. Fixes problems when post content is output on templates such as archives. Found when using full site editing and the query block.

Expand Down

0 comments on commit 7255f76

Please sign in to comment.