Skip to content

Commit

Permalink
🔀 Merge branch 'main' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
MatzeKitt committed Aug 16, 2024
2 parents 2947490 + 0151b5d commit cd90ec0
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.9.2
* Improve the text for screen readers upon activating the embedded content
* Fixed compatibility with other widget plugins
* Fixed handling of videos in Divi

## 1.9.1
* Fixed an error while uninstalling the plugin
* Fixed aspect ratio of embeds embedded via Divi
Expand Down
15 changes: 15 additions & 0 deletions assets/js/divi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Divi functionality
*
* @author Epiphyt
* @license GPL2
* @package epiphyt\Embed_Privacy
*/
document.addEventListener( 'DOMContentLoaded', () => {
// Generate responsive video wrapper for Embed Privacy container
if ( $.fn.fitVids ) {
$( '#main-content' ).fitVids( {
customSelector: ".embed-privacy-container"
} );
}
} );
5 changes: 5 additions & 0 deletions assets/style/scss/divi.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.embed-privacy-container {
line-height: 1.7em;

.fluid-width-video-wrapper > & {
inset: 0;
position: absolute;
}
}

// prevent hiding container around Embed Privacy
Expand Down
6 changes: 3 additions & 3 deletions embed-privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
Plugin Name: Embed Privacy
Description: Embed Privacy prevents from loading external embeds directly and lets the user control which one should be loaded.
Version: 1.9.1
Version: 1.9.2
Author: Epiphyt
Author URI: https://epiph.yt
License: GPL2
Expand All @@ -29,7 +29,7 @@
// exit if ABSPATH is not defined
\defined( 'ABSPATH' ) || exit;

\define( 'EMBED_PRIVACY_VERSION', '1.9.1' );
\define( 'EMBED_PRIVACY_VERSION', '1.9.2' );

if ( ! \defined( 'EPI_EMBED_PRIVACY_BASE' ) ) {
\define( 'EPI_EMBED_PRIVACY_BASE', \WP_PLUGIN_DIR . '/embed-privacy/' );
Expand Down Expand Up @@ -58,7 +58,7 @@ function disable_plugin() {
/**
* Autoload all necessary classes.
*
* @param string $class The class name of the autoloaded class
* @param string $class The class name of the auto-loaded class
*/
\spl_autoload_register( function( $class ) {
$path = \explode( '\\', $class );
Expand Down
3 changes: 1 addition & 2 deletions inc/class-embed-privacy-widget-output-filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public static function get_instance() {
* Initialize the functionality by registering actions and filters.
*/
private function __construct() {
// priority of 9 to run before the Widget Logic plugin.
\add_filter( 'dynamic_sidebar_params', [ $this, 'filter_dynamic_sidebar_params' ], 9 );
\add_filter( 'dynamic_sidebar_params', [ $this, 'filter_dynamic_sidebar_params' ], \PHP_INT_MAX );
}

/**
Expand Down
26 changes: 20 additions & 6 deletions inc/class-embed-privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ public function get_output_template( $embed_provider, $embed_provider_lowercase,
$footer_content .= '<span class="embed-privacy-url"><a href="' . \esc_url( $args['embed_url'] ) . '">';
$footer_content .= \sprintf(
/* translators: content name or 'content' */
\esc_html__( 'Open %s directly', 'embed-privacy' ),
\esc_html__( 'Open "%s" directly', 'embed-privacy' ),
! empty( $args['embed_title'] ) ? $args['embed_title'] : \__( 'content', 'embed-privacy' )
);
$footer_content .= '</a></span>';
Expand All @@ -994,8 +994,16 @@ public function get_output_template( $embed_provider, $embed_provider_lowercase,
}
?>
<div class="embed-privacy-container is-disabled <?php echo \esc_attr( $embed_classes ); ?>" data-embed-id="oembed_<?php echo \esc_attr( $embed_md5 ); ?>" data-embed-provider="<?php echo \esc_attr( $embed_provider_lowercase ); ?>"<?php echo ( ! empty( $embed_thumbnail['thumbnail_path'] ) && \file_exists( $embed_thumbnail['thumbnail_path'] ) ? ' style="background-image: url(' . \esc_url( $embed_thumbnail['thumbnail_url'] ) . ');"' : '' ); ?>>
<?php /* translators: embed provider */ ?>
<button class="embed-privacy-enable screen-reader-text"><?php \printf( \esc_html__( 'Display content from %s', 'embed-privacy' ), \esc_html( $embed_provider ) ); ?></button>
<?php
/* translators: embed provider */
$button_text = \sprintf( \__( 'Display content from %s', 'embed-privacy' ), \esc_html( $embed_provider ) );

if ( ! empty( $args['embed_title'] ) ) {
/* translators: 1: embed title, 2: embed provider */
$button_text = \sprintf( \__( 'Display "%1$s" from %2$s', 'embed-privacy' ), $args['embed_title'], \esc_html( $embed_provider ) );
}
?>
<button class="embed-privacy-enable screen-reader-text"><?php echo \esc_html( $button_text ); ?></button>

<div class="embed-privacy-overlay">
<div class="embed-privacy-inner">
Expand Down Expand Up @@ -1177,7 +1185,7 @@ public function get_single_overlay( $content, $embed_provider, $embed_provider_l
}

/* translators: embed title */
$args['embed_title'] = $element->hasAttribute( 'title' ) ? \sprintf( \__( '"%s"', 'embed-privacy' ), $element->getAttribute( 'title' ) ) : '';
$args['embed_title'] = $element->hasAttribute( 'title' ) ? $element->getAttribute( 'title' ) : '';
$args['embed_url'] = $element->getAttribute( $args['element_attribute'] );
$args['height'] = $element->hasAttribute( 'height' ) ? $element->getAttribute( 'height' ) : 0;
$args['width'] = $element->hasAttribute( 'width' ) ? $element->getAttribute( 'width' ) : 0;
Expand Down Expand Up @@ -1592,6 +1600,7 @@ public function print_assets() {
}

if ( $this->is_theme( 'Divi' ) ) {
\wp_enqueue_script( 'embed-privacy-divi' );
\wp_enqueue_style( 'embed-privacy-divi' );
}

Expand Down Expand Up @@ -1696,6 +1705,11 @@ public function register_assets() {

\wp_register_style( 'embed-privacy-astra', $css_file_url, [], $file_version );

$js_file_url = \EPI_EMBED_PRIVACY_URL . 'assets/js/divi' . $suffix . '.js';
$file_version = $is_debug ? \filemtime( \EPI_EMBED_PRIVACY_BASE . 'assets/js/divi' . $suffix . '.js' ) : \EMBED_PRIVACY_VERSION;

\wp_register_script( 'embed-privacy-divi', $js_file_url, [], $file_version, [ 'strategy' => 'defer' ] );

$css_file_url = \EPI_EMBED_PRIVACY_URL . 'assets/style/divi' . $suffix . '.css';
$file_version = $is_debug ? \filemtime( \EPI_EMBED_PRIVACY_BASE . 'assets/style/divi' . $suffix . '.css' ) : \EMBED_PRIVACY_VERSION;

Expand Down Expand Up @@ -1932,7 +1946,7 @@ public function replace_embeds_oembed( $output, $url, $args ) {

$embed_provider = '';
$embed_provider_lowercase = '';
$embed_providers = $this->get_embeds( 'oembed' );
$embed_providers = $this->get_embeds();

// get embed provider name
foreach ( $embed_providers as $provider ) {
Expand Down Expand Up @@ -1976,7 +1990,7 @@ public function replace_embeds_oembed( $output, $url, $args ) {

$embed_title = $this->get_oembed_title( $output );
/* translators: embed title */
$args['embed_title'] = ! empty( $embed_title ) ? \sprintf( \__( '"%s"', 'embed-privacy' ), $embed_title ) : '';
$args['embed_title'] = ! empty( $embed_title ) ? $embed_title : '';
$args['embed_url'] = $url;
$args['strip_newlines'] = true;

Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Contributors: epiphyt, kittmedia, krafit
Tags: oembed, privacy, gutenberg
Requires at least: 5.9
Stable tag: 1.9.1
Stable tag: 1.9.2
Tested up to: 6.5
Requires PHP: 5.6
License: GPL2
Expand Down Expand Up @@ -173,6 +173,11 @@ You can report security bugs through the Patchstack Vulnerability Disclosure Pro

== Changelog ==

= 1.9.2 =
* Improve the text for screen readers upon activating the embedded content
* Fixed compatibility with other widget plugins
* Fixed handling of videos in Divi

= 1.9.1 =
* Fixed an error while uninstalling the plugin
* Fixed aspect ratio of embeds embedded via Divi
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const mode = isProduction ? 'production' : 'development';

const jsFiles = {
'admin/image-upload': path.resolve( process.cwd(), 'assets/js/admin', 'image-upload.js' ),
'divi': path.resolve( process.cwd(), 'assets/js', 'divi.js' ),
'elementor-video': path.resolve( process.cwd(), 'assets/js', 'elementor-video.js' ),
'embed-privacy': path.resolve( process.cwd(), 'assets/js', 'embed-privacy.js' ),
};
Expand Down

0 comments on commit cd90ec0

Please sign in to comment.