diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..d9426ea --- /dev/null +++ b/composer.json @@ -0,0 +1,15 @@ +{ + "name" : "michaelzangl/wp-video-embed-privacy", + "description": "Wordpress plugin for making ebedding videos GDPR compliant", + "homepage" : "https://wordpress.org/plugins/video-embed-privacy/", + "type" : "wordpress-plugin", + "license" : "GPL-2.0+", + "authors" : [ + { + "name" : "Michael Zangl" + } + ], + "require": { + "composer/installers": "~1.0" + } +} diff --git a/video-embed-privacy.css b/video-embed-privacy.css index 0256e91..0580c36 100644 --- a/video-embed-privacy.css +++ b/video-embed-privacy.css @@ -45,10 +45,16 @@ left: 50%; top: -35px; background: black; - border-radius: 5px; + border-radius: 10px; + opacity: .7; } .video-wrapped.video-wrapped-video:hover .video-wrapped-play:before { - box-shadow: 0 0 5px rgba(0, 0, 0, .3); + box-shadow: 0 0 5px rgba(0, 0, 0, .3); + opacity: 1; +} + +.video-wrapped.video-wrapped-video:hover .video-wrapped-play:after { + opacity: 1; } .video-wrapped.video-wrapped-yt .video-wrapped-play:before { @@ -62,16 +68,17 @@ .video-wrapped.video-wrapped-video .video-wrapped-play:after { content: ''; border-style: solid; - border-width: 17px 0 17px 35px; + border-width: 12px 0 12px 24px; border-color: transparent transparent transparent white; position: absolute; width: 0; height: 0; - margin-left: -15px; + margin-left: -11px; left: 50%; - top: -27px; + top: -22px; + opacity: .7; } .video-wrapped .video-wrapped-play .small { font-size: 50%; -} \ No newline at end of file +} diff --git a/video-embed-privacy.js b/video-embed-privacy.js index 4972fef..ed6eeae 100644 --- a/video-embed-privacy.js +++ b/video-embed-privacy.js @@ -1,11 +1,15 @@ +(function($) { -jQuery(function() { - jQuery(".video-wrapped").each(function() { - jQuery(this) + $.fn.videoEmbedPrivacy = function() { + $(this) .empty() - .append(jQuery('
').html(jQuery(this).attr('data-embed-play'))) + .append($('
').html($(this).attr('data-embed-play'))) .click(function(e) { if (e.target.tagName.toLowerCase() !== 'a') { - jQuery(this).html(jQuery(this).attr('data-embed-frame').replace(/(\/embed\/[^"]*\\?[^"]*)/, '$1&autoplay=1')).addClass('video-wrapped-clicked') + $(this).html($(this).attr('data-embed-frame').replace(/(\/embed\/[^"]*\\?[^"]*)/, '$1&autoplay=1')).addClass('video-wrapped-clicked') }} ) - }) -}); + return this; + }; + + $('.video-wrapped').videoEmbedPrivacy(); + +}(jQuery)); diff --git a/video-embed-privacy.php b/video-embed-privacy.php index e13d5c1..ae94559 100644 --- a/video-embed-privacy.php +++ b/video-embed-privacy.php @@ -46,7 +46,7 @@ function video_embed_privacy_defaults() { } function video_embed_privacy_option($name) { $defaults = video_embed_privacy_defaults(); - + if (!isset($defaults[$name])) { die("Unknown option: $name"); } @@ -74,9 +74,8 @@ function video_embed_privacy_available() { } function video_embed_privacy_translate($text, $url, $atts) { - wp_enqueue_script('video-embed-privacy'); $noJsText = esc_html__('Please activate JavaScript to view this video.', 'video-embed-privacy') . '
' . esc_html__('Video-Link', 'video-embed-privacy') . ': ' . $url . ''; - + $playText = '' . video_embed_privacy_option_ne('show') . '
' . sprintf(video_embed_privacy_option_ne('generic_hint'), preg_replace("~\\w+://(.*?)/.*~", "$1", $url)) . '
'; $embedText = $text; @@ -84,12 +83,12 @@ function video_embed_privacy_translate($text, $url, $atts) { if (preg_match("/width=\"(\\d+)/", $text, $widthMatches)) { $w = $widthMatches [1] * 1; } - + $h = $atts ['height']; if (preg_match("/height=\"(\\d+)/", $text, $heightMatches)) { $h = $heightMatches [1] * 1; } - + $style = 'width: ' . $w . 'px; min-height: ' . $h . 'px;'; $class = 'video-wrapped'; $doReplacement = video_embed_privacy_option('replace_unknown') === 'true'; @@ -100,7 +99,7 @@ function video_embed_privacy_translate($text, $url, $atts) { if (preg_match($settings['videoIdMatch'], $text, $matches)) { $playText = '' . video_embed_privacy_option_ne($id . '_show') . '
' . video_embed_privacy_option_ne($id . '_hint') . '
'; $v = $matches [1]; - + if (isset($settings['textFixer'])) { $embedText = $settings['textFixer']($embedText); } @@ -113,7 +112,7 @@ function video_embed_privacy_translate($text, $url, $atts) { break; } } - + if ($doReplacement) { return '
' . $noJsText . '
'; } else { @@ -125,6 +124,7 @@ function video_embed_privacy_styles() { wp_register_style('video-embed-privacy', plugins_url('video-embed-privacy.css', __FILE__)); wp_register_script('video-embed-privacy', plugins_url('video-embed-privacy.js', __FILE__), array(), '1.0', true); wp_enqueue_style('video-embed-privacy'); + wp_enqueue_script('video-embed-privacy'); } function video_embed_privacy_settings() { @@ -134,14 +134,14 @@ function video_embed_privacy_settings() { function video_embed_privacy_write_settings() { update_option('video-embed-privacy-key', wp_generate_password(48)); - + $settings = [ 'cache' => video_embed_privacy_option('cache') === 'true', 'key' => video_embed_privacy_option('key') ]; $file = dirname(__FILE__) . '/preview/settings.php'; file_put_contents($file, "