Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add composer.json, so we can use wpackagist to include the plugin #11

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
19 changes: 13 additions & 6 deletions video-embed-privacy.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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%;
}
}
18 changes: 11 additions & 7 deletions video-embed-privacy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
(function($) {

jQuery(function() {
jQuery(".video-wrapped").each(function() {
jQuery(this)
$.fn.videoEmbedPrivacy = function() {
$(this)
.empty()
.append(jQuery('<div class="video-wrapped-play">').html(jQuery(this).attr('data-embed-play')))
.append($('<div class="video-wrapped-play">').html($(this).attr('data-embed-play')))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that Wordpress is using the $ shortcut for jQuery, but I'd prefer to keep the long version for compatibility.

.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));
18 changes: 9 additions & 9 deletions video-embed-privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -74,22 +74,21 @@ 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') . '<br/>' . esc_html__('Video-Link', 'video-embed-privacy') . ': <a href="' . htmlspecialchars($url) . '">' . $url . '</a>';

$playText = '<span>' . video_embed_privacy_option_ne('show') . '</span><div class="small"><span>' . sprintf(video_embed_privacy_option_ne('generic_hint'), preg_replace("~\\w+://(.*?)/.*~", "$1", $url)) . '</span></div>';
$embedText = $text;

$w = $atts ['width'];
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';
Expand All @@ -100,7 +99,7 @@ function video_embed_privacy_translate($text, $url, $atts) {
if (preg_match($settings['videoIdMatch'], $text, $matches)) {
$playText = '<span>' . video_embed_privacy_option_ne($id . '_show') . '</span><div class="small"><span>' . video_embed_privacy_option_ne($id . '_hint') . '</span></div>';
$v = $matches [1];

if (isset($settings['textFixer'])) {
$embedText = $settings['textFixer']($embedText);
}
Expand All @@ -113,7 +112,7 @@ function video_embed_privacy_translate($text, $url, $atts) {
break;
}
}

if ($doReplacement) {
return '<div class="' . $class . '" style="' . $style . '" data-embed-frame="' . htmlspecialchars($embedText) . '" data-embed-play="' . htmlspecialchars($playText) . '"><div class="video-wrapped-nojs"><span>' . $noJsText . '</span></div></div>';
} else {
Expand All @@ -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() {
Expand All @@ -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, "<?php if(!defined('__ACCESS_VEP_SETTINGS__')) die('Illegal access.'); return " . var_export($settings, true) . ';');

}

function video_embed_privacy_add_action_links ( $links ) {
Expand Down