From 9b7f1e81ecb758c66e45979c4cfd3a8c535695fe Mon Sep 17 00:00:00 2001 From: Sebastian Landwehr Date: Sat, 19 May 2018 14:00:34 +0200 Subject: [PATCH 1/6] composer.json --- composer.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 composer.json diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..26029ca --- /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" + } +} From 6d3fccde3b7f911e43e62d981e0c0ad2c37b3ffa Mon Sep 17 00:00:00 2001 From: Sebastian Landwehr Date: Sat, 19 May 2018 14:02:01 +0200 Subject: [PATCH 2/6] formatting --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 26029ca..d9426ea 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,6 @@ } ], "require": { - "composer/installers": "~1.0" + "composer/installers": "~1.0" } } From 8fac04587f7ee3baef6f199d9b85f73a0e823b4a Mon Sep 17 00:00:00 2001 From: Sebastian Landwehr Date: Sat, 19 May 2018 14:11:01 +0200 Subject: [PATCH 3/6] fix issue where video-embed-privacy.js is not added on all lages --- video-embed-privacy.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/video-embed-privacy.php b/video-embed-privacy.php index e13d5c1..844818e 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,9 @@ function video_embed_privacy_available() { } function video_embed_privacy_translate($text, $url, $atts) { - wp_enqueue_script('video-embed-privacy'); + wp_enqueue_script('video-embed-privacy', plugins_url('video-embed-privacy.js', __FILE__), array(), '1.0', true); $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 +84,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 +100,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 +113,7 @@ function video_embed_privacy_translate($text, $url, $atts) { break; } } - + if ($doReplacement) { return '
' . $noJsText . '
'; } else { @@ -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, " Date: Sat, 19 May 2018 14:38:39 +0200 Subject: [PATCH 4/6] some theming for the play button --- video-embed-privacy.css | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) 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 +} From 29581035e853864273ecebe107a9ba761e8ab2dc Mon Sep 17 00:00:00 2001 From: Sebastian Landwehr Date: Sat, 19 May 2018 15:14:02 +0200 Subject: [PATCH 5/6] always load js file because of ajax --- video-embed-privacy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video-embed-privacy.php b/video-embed-privacy.php index 844818e..ae94559 100644 --- a/video-embed-privacy.php +++ b/video-embed-privacy.php @@ -74,7 +74,6 @@ function video_embed_privacy_available() { } function video_embed_privacy_translate($text, $url, $atts) { - wp_enqueue_script('video-embed-privacy', plugins_url('video-embed-privacy.js', __FILE__), array(), '1.0', true); $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)) . '
'; @@ -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() { From 1110c5a018e028b2a06d46543bd85eb919b1dcaf Mon Sep 17 00:00:00 2001 From: Sebastian Landwehr Date: Sat, 19 May 2018 15:30:38 +0200 Subject: [PATCH 6/6] jquery plugin --- video-embed-privacy.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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));