Version Description
Download this release
Release Info
Developer | a.hoereth |
Plugin | Featured Video Plus |
Version | 2.2.2 |
Comparing to | |
See all releases |
Code changes from version 2.2.1 to 2.2.2
- CHANGELOG.md +4 -0
- featured-video-plus.php +2 -2
- js/frontend.js +44 -53
- js/frontend.min.js +1 -1
- php/class-backend.php +1 -1
- php/class-frontend.php +2 -148
- php/class-main.php +217 -54
- readme.txt +5 -1
- styles/frontend.css +27 -5
CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1 |
# Changelog #
|
2 |
|
|
|
|
|
|
|
|
|
3 |
## 2.2.1: 2015-09-08 ##
|
4 |
* Now compatible with infinite scroll! ([*](https://wordpress.org/support/topic/vimeo-thrumbnails-not-work), [*](https://wordpress.org/support/topic/video-embedding-issue-when-using-infinite-scroll), [*](https://wordpress.org/support/topic/featured-video-plus-jetpack-infinite-scroll-video-width-problem))
|
5 |
* Fix bad overlay sizing when loading from cache. ([*](https://wordpress.org/support/topic/video-shrinking-on-2nd-play))
|
1 |
# Changelog #
|
2 |
|
3 |
+
## 2.2.2: 2015-09-15 ##
|
4 |
+
* Fix for not correctly hidden preload images. ([*](https://wordpress.org/support/topic/your-aplication-is-not-working-right-on-wordpress-43–es_es), [*](https://wordpress.org/support/topic/play-and-load-images-appended-to-body-since-update-to-221))
|
5 |
+
* Replace features videos more reliably on AJAX requests. ([*](https://wordpress.org/support/topic/video-embedding-issue-when-using-infinite-scroll))
|
6 |
+
|
7 |
## 2.2.1: 2015-09-08 ##
|
8 |
* Now compatible with infinite scroll! ([*](https://wordpress.org/support/topic/vimeo-thrumbnails-not-work), [*](https://wordpress.org/support/topic/video-embedding-issue-when-using-infinite-scroll), [*](https://wordpress.org/support/topic/featured-video-plus-jetpack-infinite-scroll-video-width-problem))
|
9 |
* Fix bad overlay sizing when loading from cache. ([*](https://wordpress.org/support/topic/video-shrinking-on-2nd-play))
|
featured-video-plus.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Featured Video Plus
|
4 |
Plugin URI: http://yrnxt.com/wordpress/featured-video-plus/
|
5 |
Description: Add Featured Videos to your posts and pages.
|
6 |
-
Version: 2.2.
|
7 |
Author: Alexander Höreth
|
8 |
Author URI: http://yrnxt.com
|
9 |
Text Domain: featured-video-plus
|
@@ -32,7 +32,7 @@ License: GPL2
|
|
32 |
// ********************
|
33 |
// CONSTANTS
|
34 |
if ( ! defined( 'FVP_VERSION' ) ) {
|
35 |
-
define( 'FVP_VERSION', '2.2.
|
36 |
}
|
37 |
|
38 |
$pathinfo = pathinfo( dirname( plugin_basename( __FILE__ ) ) );
|
3 |
Plugin Name: Featured Video Plus
|
4 |
Plugin URI: http://yrnxt.com/wordpress/featured-video-plus/
|
5 |
Description: Add Featured Videos to your posts and pages.
|
6 |
+
Version: 2.2.2
|
7 |
Author: Alexander Höreth
|
8 |
Author URI: http://yrnxt.com
|
9 |
Text Domain: featured-video-plus
|
32 |
// ********************
|
33 |
// CONSTANTS
|
34 |
if ( ! defined( 'FVP_VERSION' ) ) {
|
35 |
+
define( 'FVP_VERSION', '2.2.2' );
|
36 |
}
|
37 |
|
38 |
$pathinfo = pathinfo( dirname( plugin_basename( __FILE__ ) ) );
|
js/frontend.js
CHANGED
@@ -4,13 +4,9 @@ var initFeaturedVideoPlus;
|
|
4 |
'use strict';
|
5 |
/* global fvpdata */
|
6 |
|
7 |
-
|
8 |
-
var
|
9 |
-
var
|
10 |
-
var loadBg = 'url(\'' + fvpdata.loadicon + '\')';
|
11 |
-
var bgState;
|
12 |
-
var cache = {};
|
13 |
-
var initTimeout;
|
14 |
|
15 |
|
16 |
/**
|
@@ -64,48 +60,33 @@ var initFeaturedVideoPlus;
|
|
64 |
|
65 |
|
66 |
/**
|
67 |
-
*
|
68 |
*/
|
69 |
-
function
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
}));
|
78 |
-
});
|
79 |
-
}
|
80 |
|
81 |
-
|
82 |
-
bgState = bgState === playBg ? loadBg : playBg;
|
83 |
-
$loader.css({ backgroundImage: bgState });
|
84 |
}
|
85 |
|
86 |
|
87 |
/**
|
88 |
* Handle mouseover and mouseout events.
|
89 |
*/
|
90 |
-
function
|
91 |
var $img = $(event.currentTarget).children('img');
|
|
|
92 |
|
93 |
-
|
94 |
-
if (
|
95 |
-
|
96 |
-
|
97 |
-
$loader.addClass($img.attr('class')).css({
|
98 |
-
height: $img.height(),
|
99 |
-
width: $img.width(),
|
100 |
-
margin: $img.css('margin')
|
101 |
-
});
|
102 |
-
|
103 |
-
// Set icon to play icon, fade out image and insert overlay.
|
104 |
-
$loader.css({ backgroundImage: (bgState = playBg) });
|
105 |
-
$img.animate({ opacity: fvpdata.opacity }).before($loader);
|
106 |
-
} else if (bgState !== loadBg) {
|
107 |
$img.animate({ opacity: 1 });
|
108 |
-
$loader.remove();
|
109 |
}
|
110 |
}
|
111 |
|
@@ -118,7 +99,8 @@ var initFeaturedVideoPlus;
|
|
118 |
var $self = $(event.currentTarget);
|
119 |
var id = parseInt($self.attr('data-id'), 10);
|
120 |
|
121 |
-
|
|
|
122 |
|
123 |
$.post(fvpdata.ajaxurl, {
|
124 |
'action' : 'fvp_get_embed',
|
@@ -136,7 +118,7 @@ var initFeaturedVideoPlus;
|
|
136 |
unwrap();
|
137 |
}
|
138 |
|
139 |
-
|
140 |
});
|
141 |
}
|
142 |
|
@@ -159,10 +141,8 @@ var initFeaturedVideoPlus;
|
|
159 |
height: '100%'
|
160 |
});
|
161 |
|
162 |
-
$('#DOMWindow').css({ backgroundImage: loadBg });
|
163 |
-
|
164 |
// Check if the result is already cached
|
165 |
-
if (!
|
166 |
$.post(fvpdata.ajaxurl, {
|
167 |
'action' : 'fvp_get_embed',
|
168 |
'fvp_nonce' : fvpdata.nonce,
|
@@ -170,7 +150,7 @@ var initFeaturedVideoPlus;
|
|
170 |
}, function(response) {
|
171 |
if (response.success) {
|
172 |
// cache the result to not reload when opened again
|
173 |
-
|
174 |
|
175 |
$('#DOMWindow').html(response.data);
|
176 |
sizeLocal();
|
@@ -179,7 +159,7 @@ var initFeaturedVideoPlus;
|
|
179 |
});
|
180 |
} else {
|
181 |
// From cache
|
182 |
-
$('#DOMWindow').html(
|
183 |
sizeLocal();
|
184 |
$(window).trigger('scroll');
|
185 |
}
|
@@ -190,6 +170,10 @@ var initFeaturedVideoPlus;
|
|
190 |
* Initialize the plugins JS functionality.
|
191 |
*/
|
192 |
function init() {
|
|
|
|
|
|
|
|
|
193 |
// remove wrapping anchors
|
194 |
// doing this twice with a 1 second delay to fix wrapped local video posters
|
195 |
unwrap();
|
@@ -202,15 +186,14 @@ var initFeaturedVideoPlus;
|
|
202 |
|
203 |
// add hover effect and preload icons
|
204 |
$('.fvp-overlay, .fvp-dynamic')
|
205 |
-
.off('mouseenter').on('mouseenter',
|
206 |
-
.off('mouseleave').on('mouseleave',
|
207 |
-
triggerPlayLoad();
|
208 |
|
209 |
// on-demand video insertion click handler
|
210 |
-
$('.fvp-dynamic').click(dynamicTrigger);
|
211 |
|
212 |
// overlay click handler
|
213 |
-
$('.fvp-overlay').click(overlayTrigger);
|
214 |
}
|
215 |
|
216 |
|
@@ -218,8 +201,13 @@ var initFeaturedVideoPlus;
|
|
218 |
* Debounced version of the init function.
|
219 |
*/
|
220 |
initFeaturedVideoPlus = function() {
|
221 |
-
|
222 |
-
|
|
|
|
|
|
|
|
|
|
|
223 |
};
|
224 |
|
225 |
|
@@ -233,6 +221,9 @@ var initFeaturedVideoPlus;
|
|
233 |
});
|
234 |
}
|
235 |
|
236 |
-
|
|
|
|
|
|
|
237 |
});
|
238 |
})(jQuery);
|
4 |
'use strict';
|
5 |
/* global fvpdata */
|
6 |
|
7 |
+
var videoCache = {};
|
8 |
+
var selectorCache;
|
9 |
+
var initTimeout = 0;
|
|
|
|
|
|
|
|
|
10 |
|
11 |
|
12 |
/**
|
60 |
|
61 |
|
62 |
/**
|
63 |
+
* Get the actionicon element from the provided container.
|
64 |
*/
|
65 |
+
function getActioniconElem(elem) {
|
66 |
+
var $elem = $(elem);
|
67 |
+
var $icon = $elem.children('.fvp-actionicon');
|
68 |
+
$icon.css({
|
69 |
+
height: $elem.height(),
|
70 |
+
width : $elem.width(),
|
71 |
+
margin: $elem.css('margin')
|
72 |
+
});
|
|
|
|
|
|
|
73 |
|
74 |
+
return $icon;
|
|
|
|
|
75 |
}
|
76 |
|
77 |
|
78 |
/**
|
79 |
* Handle mouseover and mouseout events.
|
80 |
*/
|
81 |
+
function hoverAction(event) {
|
82 |
var $img = $(event.currentTarget).children('img');
|
83 |
+
var $icon = getActioniconElem(event.currentTarget);
|
84 |
|
85 |
+
$icon.toggleClass('play');
|
86 |
+
if ($icon.hasClass('play')) {
|
87 |
+
$img.animate({ opacity: fvpdata.opacity });
|
88 |
+
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
$img.animate({ opacity: 1 });
|
|
|
90 |
}
|
91 |
}
|
92 |
|
99 |
var $self = $(event.currentTarget);
|
100 |
var id = parseInt($self.attr('data-id'), 10);
|
101 |
|
102 |
+
var $icon = getActioniconElem(event.currentTarget);
|
103 |
+
$icon.addClass('load ' + fvpdata.color);
|
104 |
|
105 |
$.post(fvpdata.ajaxurl, {
|
106 |
'action' : 'fvp_get_embed',
|
118 |
unwrap();
|
119 |
}
|
120 |
|
121 |
+
$icon.removeClass('load ' + fvpdata.color);
|
122 |
});
|
123 |
}
|
124 |
|
141 |
height: '100%'
|
142 |
});
|
143 |
|
|
|
|
|
144 |
// Check if the result is already cached
|
145 |
+
if (! videoCache[id]) {
|
146 |
$.post(fvpdata.ajaxurl, {
|
147 |
'action' : 'fvp_get_embed',
|
148 |
'fvp_nonce' : fvpdata.nonce,
|
150 |
}, function(response) {
|
151 |
if (response.success) {
|
152 |
// cache the result to not reload when opened again
|
153 |
+
videoCache[id] = response.data;
|
154 |
|
155 |
$('#DOMWindow').html(response.data);
|
156 |
sizeLocal();
|
159 |
});
|
160 |
} else {
|
161 |
// From cache
|
162 |
+
$('#DOMWindow').html( videoCache[id] );
|
163 |
sizeLocal();
|
164 |
$(window).trigger('scroll');
|
165 |
}
|
170 |
* Initialize the plugins JS functionality.
|
171 |
*/
|
172 |
function init() {
|
173 |
+
var newSet = $('.featured-video-plus, .fvp-overlay, .fvp-dynamic');
|
174 |
+
if (newSet.is(selectorCache)) { return false; }
|
175 |
+
selectorCache = newSet;
|
176 |
+
|
177 |
// remove wrapping anchors
|
178 |
// doing this twice with a 1 second delay to fix wrapped local video posters
|
179 |
unwrap();
|
186 |
|
187 |
// add hover effect and preload icons
|
188 |
$('.fvp-overlay, .fvp-dynamic')
|
189 |
+
.off('mouseenter').on('mouseenter', hoverAction)
|
190 |
+
.off('mouseleave').on('mouseleave', hoverAction);
|
|
|
191 |
|
192 |
// on-demand video insertion click handler
|
193 |
+
$('.fvp-dynamic').off('click').on('click', dynamicTrigger);
|
194 |
|
195 |
// overlay click handler
|
196 |
+
$('.fvp-overlay').off('click').on('click', overlayTrigger);
|
197 |
}
|
198 |
|
199 |
|
201 |
* Debounced version of the init function.
|
202 |
*/
|
203 |
initFeaturedVideoPlus = function() {
|
204 |
+
if (0 === initTimeout) {
|
205 |
+
init();
|
206 |
+
initTimeout = setTimeout(function() {}, 100);
|
207 |
+
} else {
|
208 |
+
clearTimeout(initTimeout);
|
209 |
+
initTimeout = setTimeout(init, 100);
|
210 |
+
}
|
211 |
};
|
212 |
|
213 |
|
221 |
});
|
222 |
}
|
223 |
|
224 |
+
// preload images
|
225 |
+
[fvpdata.playicon, fvpdata.loadicon].forEach(function(val) {
|
226 |
+
$('body').append($('<img/>', {src: val, alt: 'preload image'}).hide());
|
227 |
+
});
|
228 |
});
|
229 |
})(jQuery);
|
js/frontend.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var initFeaturedVideoPlus;!function(
|
1 |
+
var initFeaturedVideoPlus;!function(t){"use strict";function a(){t(".has-post-video a>.featured-video-plus,.has-post-video a>.fvp-dynamic,.has-post-video a>.fvp-overlay,.has-post-video a>.wp-video,.has-post-video a>.wp-video-shortcode").unwrap(),t(".has-post-video .post-thumbnail>.post-thumbnail").removeClass("post-thumbnail"),t("a.post-thumbnail:empty").not(".fvp-dynamic, .fvp-overlay").remove()}function e(){fvpdata.fitvids&&t(".featured-video-plus.fvp-responsive").fitVids({customSelector:["iframe","object","embed"]})}function o(){if(fvpdata.width&&!fvpdata.fitvids){t(".fvp-local .wp-video").css({width:fvpdata.width,height:"auto"});var a=t(".fvp-local .wp-video .wp-video-shortcode");a.attr({width:fvpdata.width,height:fvpdata.width/a.attr("width")*a.attr("heigth")})}}function i(a){var e=t(a),o=e.children(".fvp-actionicon");return o.css({height:e.height(),width:e.width(),margin:e.css("margin")}),o}function d(a){var e=t(a.currentTarget).children("img"),o=i(a.currentTarget);o.toggleClass("play"),e.animate(o.hasClass("play")?{opacity:fvpdata.opacity}:{opacity:1})}function n(o){o.preventDefault();var d=t(o.currentTarget),n=parseInt(d.attr("data-id"),10),r=i(o.currentTarget);r.addClass("load "+fvpdata.color),t.post(fvpdata.ajaxurl,{action:"fvp_get_embed",fvp_nonce:fvpdata.nonce,id:n},function(t){if(t.success){var o=d.parent();d.replaceWith(t.data),o.find(".wp-audio-shortcode, .wp-video-shortcode").mediaelementplayer(),e(),a()}r.removeClass("load "+fvpdata.color)})}function r(a){a.preventDefault();var e=t(a.currentTarget),i=parseInt(e.attr("data-id"),10);e.openDOMWindow({eventType:null,windowPadding:0,borderSize:0,windowBGColor:"transparent",overlayOpacity:100*fvpdata.opacity,width:"100%",height:"100%"}),s[i]?(t("#DOMWindow").html(s[i]),o(),t(window).trigger("scroll")):t.post(fvpdata.ajaxurl,{action:"fvp_get_embed",fvp_nonce:fvpdata.nonce,id:i},function(a){a.success&&(s[i]=a.data,t("#DOMWindow").html(a.data),o(),t(window).trigger("scroll"))})}function c(){var i=t(".featured-video-plus, .fvp-overlay, .fvp-dynamic");return i.is(p)?!1:(p=i,a(),setTimeout(a,1e3),e(),o(),t(".fvp-overlay, .fvp-dynamic").off("mouseenter").on("mouseenter",d).off("mouseleave").on("mouseleave",d),t(".fvp-dynamic").off("click").on("click",n),void t(".fvp-overlay").off("click").on("click",r))}var p,s={},v=0;initFeaturedVideoPlus=function(){0===v?(c(),v=setTimeout(function(){},100)):(clearTimeout(v),v=setTimeout(c,100))},t(document).ready(function(){window.chrome&&t(".featured-video-plus iframe").each(function(){this.src=this.src}),[fvpdata.playicon,fvpdata.loadicon].forEach(function(a){t("body").append(t("<img/>",{src:a,alt:"preload image"}).hide())})})}(jQuery);
|
php/class-backend.php
CHANGED
@@ -556,7 +556,7 @@ class FVP_Backend extends Featured_Video_Plus {
|
|
556 |
|
557 |
if ( has_post_video( $id ) ) {
|
558 |
// Return featured video html as requested.
|
559 |
-
$video = get_the_post_video( $id );
|
560 |
wp_send_json_success( $video );
|
561 |
} else {
|
562 |
// Post has no video, return featured image html.
|
556 |
|
557 |
if ( has_post_video( $id ) ) {
|
558 |
// Return featured video html as requested.
|
559 |
+
$video = $this->get_the_post_video( $id, null, true );
|
560 |
wp_send_json_success( $video );
|
561 |
} else {
|
562 |
// Post has no video, return featured image html.
|
php/class-frontend.php
CHANGED
@@ -6,9 +6,7 @@ require_once( FVP_DIR . 'php/class-main.php' );
|
|
6 |
/**
|
7 |
* Class containing frontend functionality.
|
8 |
*
|
9 |
-
* Enqueue scripts
|
10 |
-
* insert the ajax request handlers, add 'has-post-video' class and
|
11 |
-
* register the [featured-video-plus] shortcode.
|
12 |
*
|
13 |
* @since 1.0.0
|
14 |
*/
|
@@ -23,11 +21,6 @@ class FVP_Frontend extends Featured_Video_Plus {
|
|
23 |
parent::__construct();
|
24 |
|
25 |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ) );
|
26 |
-
|
27 |
-
add_filter( 'post_thumbnail_html', array( $this, 'filter_post_thumbnail' ), 99, 5 );
|
28 |
-
add_filter( 'post_class', array( $this, 'has_post_video_class' ) );
|
29 |
-
|
30 |
-
add_shortcode( 'featured-video-plus', array( $this, 'shortcode' ) );
|
31 |
}
|
32 |
|
33 |
|
@@ -100,9 +93,7 @@ class FVP_Frontend extends Featured_Video_Plus {
|
|
100 |
'dynamic' => 'dynamic' === $mode,
|
101 |
'overlay' => 'overlay' === $mode,
|
102 |
'opacity' => 0.75,
|
103 |
-
'
|
104 |
-
FVP_URL . 'img/loadicon_b.gif',
|
105 |
-
'playicon' => FVP_URL . 'img/playicon.png',
|
106 |
'width' => ! empty( $options['sizing']['width'] ) ?
|
107 |
$options['sizing']['width'] : null
|
108 |
));
|
@@ -117,141 +108,4 @@ class FVP_Frontend extends Featured_Video_Plus {
|
|
117 |
}
|
118 |
|
119 |
|
120 |
-
/**
|
121 |
-
* Display featured videos in place of featured images if a featured video is available and only if so desired by user.
|
122 |
-
*
|
123 |
-
* @see http://wordpress.stackexchange.com/a/41858
|
124 |
-
* @since 1.0.0
|
125 |
-
*
|
126 |
-
* @param string $html featured image html, ready to echo
|
127 |
-
* @param int $post_id id of target post
|
128 |
-
* @param int $post_thumbnail_id id of featured image
|
129 |
-
* @param string|array $size desired size of featured image / video
|
130 |
-
* @param array $attr
|
131 |
-
*/
|
132 |
-
public function filter_post_thumbnail(
|
133 |
-
$html,
|
134 |
-
$post_id,
|
135 |
-
$post_thumbnail_id,
|
136 |
-
$size,
|
137 |
-
$attr
|
138 |
-
) {
|
139 |
-
$size = $this->get_size();
|
140 |
-
|
141 |
-
$options = get_option( 'fvp-settings' );
|
142 |
-
$mode = ! empty( $options['mode'] ) ? $options['mode'] : null;
|
143 |
-
$conditions = ! empty( $options['conditions'] ) ?
|
144 |
-
$options['conditions'] : null;
|
145 |
-
$single_replace = is_single() &&
|
146 |
-
! empty( $options['single_replace'] ) && $options['single_replace'];
|
147 |
-
|
148 |
-
// Don't show a video.
|
149 |
-
if ( ( 'manual' === $mode ) ||
|
150 |
-
( ! self::check_conditions( $conditions ) ) ||
|
151 |
-
( ! has_post_video( $post_id ) )
|
152 |
-
) {
|
153 |
-
return $html;
|
154 |
-
}
|
155 |
-
|
156 |
-
|
157 |
-
// Playicon with onload JavaScript for initalizing FVP JS functionality
|
158 |
-
// which has to be done from here because of infinite scroll plugins.
|
159 |
-
$onload = '<img class="playicon onload" ' .
|
160 |
-
'src="'. FVP_URL . 'img/playicon.png" ' .
|
161 |
-
'alt="Featured Video Play Icon" ' .
|
162 |
-
'onload="(function() {' .
|
163 |
-
"('initFeaturedVideoPlus' in this) && ".
|
164 |
-
"('function' === typeof initFeaturedVideoPlus) && ".
|
165 |
-
"initFeaturedVideoPlus();" .
|
166 |
-
'})();" ' .
|
167 |
-
'/>';
|
168 |
-
|
169 |
-
// Show the video on-click - lazy load.
|
170 |
-
if ( 'dynamic' === $mode && ! $single_replace ) {
|
171 |
-
return sprintf(
|
172 |
-
'<a href="#" data-id="%s" class="fvp-dynamic post-thumbnail">%s</a>%s',
|
173 |
-
$post_id,
|
174 |
-
$html,
|
175 |
-
$onload
|
176 |
-
);
|
177 |
-
}
|
178 |
-
|
179 |
-
// Show the video on-click in an overlay.
|
180 |
-
if ( 'overlay' === $mode && ! $single_replace ) {
|
181 |
-
return sprintf(
|
182 |
-
'<a href="#" data-id="%s" class="fvp-overlay post-thumbnail">%s</a>%s',
|
183 |
-
$post_id,
|
184 |
-
$html,
|
185 |
-
$onload
|
186 |
-
);
|
187 |
-
}
|
188 |
-
|
189 |
-
// Replace the featured image with the video.
|
190 |
-
return get_the_post_video( $post_id, $size ) . $onload;
|
191 |
-
}
|
192 |
-
|
193 |
-
|
194 |
-
/**
|
195 |
-
* Add a 'has-post-video' class to posts if appropriate.
|
196 |
-
*
|
197 |
-
* @since 2.0.0
|
198 |
-
*
|
199 |
-
* @param {array} $classes Existing classes
|
200 |
-
* @return {array} Updated classes
|
201 |
-
*/
|
202 |
-
public function has_post_video_class( $classes ) {
|
203 |
-
global $post;
|
204 |
-
|
205 |
-
if ( has_post_video( $post->ID ) ) {
|
206 |
-
$classes[] = 'has-post-video';
|
207 |
-
}
|
208 |
-
return $classes;
|
209 |
-
}
|
210 |
-
|
211 |
-
|
212 |
-
/**
|
213 |
-
* Shortcode for usage in post or page entries. Echos the post's featured video.
|
214 |
-
*
|
215 |
-
* @since 1.0.0
|
216 |
-
*
|
217 |
-
* @param array $atts can contain the width and/or height how the featured video should be displayed in px, optional
|
218 |
-
*/
|
219 |
-
public function shortcode($atts){
|
220 |
-
$w = isset($atts['width']) ? $atts['width'] : '';
|
221 |
-
$h = isset($atts['height']) ? $atts['height'] : '';
|
222 |
-
|
223 |
-
if ( has_post_video() ) {
|
224 |
-
return get_the_post_video( null, array( $w, $h ) );
|
225 |
-
}
|
226 |
-
}
|
227 |
-
|
228 |
-
|
229 |
-
/**
|
230 |
-
* Check a given set of display conditions if one or more of them hold. If
|
231 |
-
* an empty set is given, return true.
|
232 |
-
*
|
233 |
-
* @param {assoc} $conditions
|
234 |
-
* @return {bool}
|
235 |
-
*/
|
236 |
-
private static function check_conditions( $conditions ) {
|
237 |
-
if ( empty( $conditions ) ) {
|
238 |
-
return true;
|
239 |
-
}
|
240 |
-
|
241 |
-
$conditions_hold = false;
|
242 |
-
foreach ( $conditions AS $fun => $value ) {
|
243 |
-
$negate = false;
|
244 |
-
if ( '!' === $fun[0] ) {
|
245 |
-
$negate = true;
|
246 |
-
$fun = substr( $fun, 1 );
|
247 |
-
}
|
248 |
-
|
249 |
-
if ( $value && function_exists( 'is_' . $fun ) ) {
|
250 |
-
$call = call_user_func( 'is_' . $fun );
|
251 |
-
$conditions_hold = $conditions_hold || ( $negate ? ! $call : $call );
|
252 |
-
}
|
253 |
-
}
|
254 |
-
|
255 |
-
return $conditions_hold;
|
256 |
-
}
|
257 |
}
|
6 |
/**
|
7 |
* Class containing frontend functionality.
|
8 |
*
|
9 |
+
* Enqueue scripts and styles specific to the frontend.
|
|
|
|
|
10 |
*
|
11 |
* @since 1.0.0
|
12 |
*/
|
21 |
parent::__construct();
|
22 |
|
23 |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ) );
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
|
93 |
'dynamic' => 'dynamic' === $mode,
|
94 |
'overlay' => 'overlay' === $mode,
|
95 |
'opacity' => 0.75,
|
96 |
+
'color' => 'overlay' === $mode ? 'w' : 'b',
|
|
|
|
|
97 |
'width' => ! empty( $options['sizing']['width'] ) ?
|
98 |
$options['sizing']['width'] : null
|
99 |
));
|
108 |
}
|
109 |
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
}
|
php/class-main.php
CHANGED
@@ -4,7 +4,9 @@
|
|
4 |
require_once( FVP_DIR . 'php/class-html.php' );
|
5 |
|
6 |
/**
|
7 |
-
* Class containing all functions needed on front- AND backend. Functions only
|
|
|
|
|
8 |
*
|
9 |
* @since 1.0.0
|
10 |
*/
|
@@ -16,6 +18,13 @@ class Featured_Video_Plus {
|
|
16 |
$this->oembed = new FVP_oEmbed();
|
17 |
|
18 |
add_action( 'plugins_loaded', array( $this, 'language' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
|
21 |
|
@@ -27,7 +36,11 @@ class Featured_Video_Plus {
|
|
27 |
* @param int $post_id
|
28 |
* @param string|array $size
|
29 |
*/
|
30 |
-
public function get_the_post_video(
|
|
|
|
|
|
|
|
|
31 |
$post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
|
32 |
|
33 |
if ( ! has_post_video( $post_id ) ) {
|
@@ -43,7 +56,7 @@ class Featured_Video_Plus {
|
|
43 |
$general = ! empty( $defaults['general'] ) ? $defaults['general'] : array();
|
44 |
|
45 |
// Autoplay option. Suppressed when viewing admin.
|
46 |
-
$general['autoplay'] = self::parse_autoplay_options($options
|
47 |
|
48 |
// Responsive scaling option. Not used when viewing the admin screen.
|
49 |
$responsive =
|
@@ -63,7 +76,7 @@ class Featured_Video_Plus {
|
|
63 |
switch ( $provider ) {
|
64 |
case 'local':
|
65 |
$img_meta = wp_get_attachment_metadata( $meta['id'] );
|
66 |
-
$size =
|
67 |
'width' => ! empty($img_meta['width'] ) ? $img_meta['width'] : null,
|
68 |
'height' => ! empty($img_meta['height']) ? $img_meta['height'] : null,
|
69 |
) );
|
@@ -90,7 +103,7 @@ class Featured_Video_Plus {
|
|
90 |
default:
|
91 |
$atts = array_merge(
|
92 |
$general,
|
93 |
-
|
94 |
! empty( $defaults[ $provider ] ) ? $defaults[ $provider ] : array(),
|
95 |
isset( $meta['parameters'] ) ? $meta['parameters'] : array()
|
96 |
);
|
@@ -124,6 +137,134 @@ class Featured_Video_Plus {
|
|
124 |
}
|
125 |
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
/**
|
128 |
* Determine featured video size
|
129 |
*
|
@@ -136,7 +277,7 @@ class Featured_Video_Plus {
|
|
136 |
* @return {array} The desired video size also taking the options set
|
137 |
* in the media settings into consideration.
|
138 |
*/
|
139 |
-
protected function get_size( $size = null, $original = null ) {
|
140 |
$options = get_option( 'fvp-settings' );
|
141 |
|
142 |
// fixed size requested as array( width => #, height => # ) or array( #, # )
|
@@ -144,7 +285,7 @@ class Featured_Video_Plus {
|
|
144 |
$width = isset( $size['width'] ) && is_numeric( $size['width'] ) ?
|
145 |
$size['width'] :
|
146 |
( isset( $size[0] ) && is_numeric( $size[0] ) ? $size[0] : null );
|
147 |
-
$height = isset( $size['height'] ) &&is_numeric( $size['height'] ) ?
|
148 |
$size['height'] :
|
149 |
( isset( $size[1] ) && is_numeric( $size[1] ) ? $size[1] : null );
|
150 |
|
@@ -188,6 +329,69 @@ class Featured_Video_Plus {
|
|
188 |
}
|
189 |
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
/**
|
192 |
* Parse the autoplay options to determine if video should or should not
|
193 |
* autoplay.
|
@@ -195,7 +399,10 @@ class Featured_Video_Plus {
|
|
195 |
* @param {assoic} $options
|
196 |
* @return {bool}
|
197 |
*/
|
198 |
-
private static function parse_autoplay_options(
|
|
|
|
|
|
|
199 |
if ( empty( $options['autoplay'] ) ) {
|
200 |
return false;
|
201 |
}
|
@@ -208,13 +415,12 @@ class Featured_Video_Plus {
|
|
208 |
};
|
209 |
|
210 |
$mode = ! empty( $options['mode'] ) ? $options['mode'] : null;
|
211 |
-
//$
|
212 |
-
$isajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
|
213 |
|
214 |
if (
|
215 |
! empty( $options['autoplay']['lazy'] ) &&
|
216 |
$options['autoplay']['lazy'] &&
|
217 |
-
$
|
218 |
) {
|
219 |
return true;
|
220 |
}
|
@@ -230,48 +436,5 @@ class Featured_Video_Plus {
|
|
230 |
return false;
|
231 |
}
|
232 |
|
233 |
-
/**
|
234 |
-
* Gets a post by an meta_key meta_value pair. Returns it's post_id.
|
235 |
-
*
|
236 |
-
* @see http://codex.wordpress.org/Class_Reference/wpdb
|
237 |
-
* @see http://dev.mysql.com/doc/refman/5.0/en/regexp.html#operator_regexp
|
238 |
-
* @since 1.0.0
|
239 |
-
*
|
240 |
-
* @param string $meta_key which meta_key to look for
|
241 |
-
* @param string $meta_value which meta_value to look for
|
242 |
-
*/
|
243 |
-
protected static function get_post_by_custom_meta(
|
244 |
-
$meta_key,
|
245 |
-
$meta_value = null
|
246 |
-
) {
|
247 |
-
global $wpdb;
|
248 |
-
if ( $meta_value !== null ) {
|
249 |
-
$prepared = $wpdb->prepare(
|
250 |
-
"SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key=%s AND meta_value=%s LIMIT 1",
|
251 |
-
$meta_key,
|
252 |
-
$meta_value
|
253 |
-
);
|
254 |
-
return $wpdb->get_var( $prepared );
|
255 |
-
} else {
|
256 |
-
$prepared = $wpdb->prepare(
|
257 |
-
"SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key=%s",
|
258 |
-
$meta_key
|
259 |
-
);
|
260 |
-
return $wpdb->get_col( $prepared );
|
261 |
-
}
|
262 |
-
}
|
263 |
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Initializes i18n
|
267 |
-
*
|
268 |
-
* @since 1.3.0
|
269 |
-
*/
|
270 |
-
public function language() {
|
271 |
-
load_plugin_textdomain(
|
272 |
-
'featured-video-plus',
|
273 |
-
FVP_DIR . 'lng/',
|
274 |
-
FVP_NAME . '/lng/'
|
275 |
-
);
|
276 |
-
}
|
277 |
}
|
4 |
require_once( FVP_DIR . 'php/class-html.php' );
|
5 |
|
6 |
/**
|
7 |
+
* Class containing all functions needed on front- AND backend. Functions only
|
8 |
+
* needed on one of those are found in the individual FVP_Frontend and
|
9 |
+
* FVP_Backend classes.
|
10 |
*
|
11 |
* @since 1.0.0
|
12 |
*/
|
18 |
$this->oembed = new FVP_oEmbed();
|
19 |
|
20 |
add_action( 'plugins_loaded', array( $this, 'language' ) );
|
21 |
+
|
22 |
+
add_shortcode( 'featured-video-plus', array( $this, 'shortcode' ) );
|
23 |
+
|
24 |
+
// Mainly frontend stuff, but lives here because it also needs to be
|
25 |
+
// available on the backend because thats where AJAX requests are processed.
|
26 |
+
add_filter( 'post_thumbnail_html', array( $this, 'filter_post_thumbnail' ), 99, 5 );
|
27 |
+
add_filter( 'post_class', array( $this, 'has_post_video_class' ) );
|
28 |
}
|
29 |
|
30 |
|
36 |
* @param int $post_id
|
37 |
* @param string|array $size
|
38 |
*/
|
39 |
+
public function get_the_post_video(
|
40 |
+
$post_id = null,
|
41 |
+
$size = null,
|
42 |
+
$ajax = null
|
43 |
+
) {
|
44 |
$post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
|
45 |
|
46 |
if ( ! has_post_video( $post_id ) ) {
|
56 |
$general = ! empty( $defaults['general'] ) ? $defaults['general'] : array();
|
57 |
|
58 |
// Autoplay option. Suppressed when viewing admin.
|
59 |
+
$general['autoplay'] = self::parse_autoplay_options( $options, $ajax );
|
60 |
|
61 |
// Responsive scaling option. Not used when viewing the admin screen.
|
62 |
$responsive =
|
76 |
switch ( $provider ) {
|
77 |
case 'local':
|
78 |
$img_meta = wp_get_attachment_metadata( $meta['id'] );
|
79 |
+
$size = self::get_size( $size, array(
|
80 |
'width' => ! empty($img_meta['width'] ) ? $img_meta['width'] : null,
|
81 |
'height' => ! empty($img_meta['height']) ? $img_meta['height'] : null,
|
82 |
) );
|
103 |
default:
|
104 |
$atts = array_merge(
|
105 |
$general,
|
106 |
+
self::get_size( $size ),
|
107 |
! empty( $defaults[ $provider ] ) ? $defaults[ $provider ] : array(),
|
108 |
isset( $meta['parameters'] ) ? $meta['parameters'] : array()
|
109 |
);
|
137 |
}
|
138 |
|
139 |
|
140 |
+
/**
|
141 |
+
* Shortcode for usage in post or page entries. Echos the post's featured video.
|
142 |
+
*
|
143 |
+
* @since 1.0.0
|
144 |
+
*
|
145 |
+
* @param array $atts width and height specifications, optional
|
146 |
+
*/
|
147 |
+
public function shortcode( $atts = null ) {
|
148 |
+
$w = isset( $atts['width'] ) ? $atts['width'] : '';
|
149 |
+
$h = isset( $atts['height'] ) ? $atts['height'] : '';
|
150 |
+
|
151 |
+
if ( has_post_video() ) {
|
152 |
+
return get_the_post_video( null, array( $w, $h ) );
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Filter the post thumbnail to eventually replace it with the
|
159 |
+
* featured video.
|
160 |
+
*
|
161 |
+
* @see http://wordpress.stackexchange.com/a/41858
|
162 |
+
* @since 1.0.0
|
163 |
+
*
|
164 |
+
* @param string $html featured image html, ready to echo
|
165 |
+
* @param int $post_id id of target post
|
166 |
+
* @param int $post_thumbnail_id id of featured image
|
167 |
+
* @param string|array $size desired size of featured image / video
|
168 |
+
* @param array $attr
|
169 |
+
*/
|
170 |
+
public function filter_post_thumbnail(
|
171 |
+
$html,
|
172 |
+
$post_id,
|
173 |
+
$post_thumbnail_id,
|
174 |
+
$size,
|
175 |
+
$attr
|
176 |
+
) {
|
177 |
+
$size = self::get_size();
|
178 |
+
|
179 |
+
$options = get_option( 'fvp-settings' );
|
180 |
+
$mode = ! empty( $options['mode'] ) ? $options['mode'] : null;
|
181 |
+
$conditions = ! empty( $options['conditions'] ) ?
|
182 |
+
$options['conditions'] : null;
|
183 |
+
$single_replace = is_single() &&
|
184 |
+
! empty( $options['single_replace'] ) && $options['single_replace'];
|
185 |
+
|
186 |
+
// Don't show a video.
|
187 |
+
if ( ( 'manual' === $mode ) ||
|
188 |
+
( ! self::check_conditions( $conditions ) ) ||
|
189 |
+
( ! has_post_video( $post_id ) )
|
190 |
+
) {
|
191 |
+
return $html;
|
192 |
+
}
|
193 |
+
|
194 |
+
|
195 |
+
// On-load JavaScript for initalizing FVP JS functionality.
|
196 |
+
// Doing this here in order to also have it fire when posts are loaded
|
197 |
+
// over AJAX.
|
198 |
+
$onload = '<img class="fvp-onload" ' .
|
199 |
+
'src="'. FVP_URL . 'img/playicon.png" ' .
|
200 |
+
'alt="Featured Video Play Icon" ' .
|
201 |
+
'onload="(function() {' .
|
202 |
+
"('initFeaturedVideoPlus' in this) && ".
|
203 |
+
"('function' === typeof initFeaturedVideoPlus) && ".
|
204 |
+
"initFeaturedVideoPlus();" .
|
205 |
+
'})();" ' .
|
206 |
+
'/>';
|
207 |
+
|
208 |
+
// Action icon overlay container.
|
209 |
+
$actionicon = '<div class="fvp-actionicon"></div>';
|
210 |
+
|
211 |
+
// Show the video on-click - lazy load.
|
212 |
+
if ( 'dynamic' === $mode && ! $single_replace ) {
|
213 |
+
return sprintf(
|
214 |
+
'<a href="#" data-id="%s" class="fvp-dynamic post-thumbnail">%s</a>%s',
|
215 |
+
$post_id,
|
216 |
+
$actionicon . $html,
|
217 |
+
$onload
|
218 |
+
);
|
219 |
+
}
|
220 |
+
|
221 |
+
// Show the video on-click in an overlay.
|
222 |
+
if ( 'overlay' === $mode && ! $single_replace ) {
|
223 |
+
return sprintf(
|
224 |
+
'<a href="#" data-id="%s" class="fvp-overlay post-thumbnail">%s</a>%s',
|
225 |
+
$post_id,
|
226 |
+
$actionicon . $html,
|
227 |
+
$onload
|
228 |
+
);
|
229 |
+
}
|
230 |
+
|
231 |
+
// Replace the featured image with the video.
|
232 |
+
return get_the_post_video( $post_id, $size ) . $onload;
|
233 |
+
}
|
234 |
+
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Add a 'has-post-video' class to posts if appropriate.
|
238 |
+
*
|
239 |
+
* @since 2.0.0
|
240 |
+
*
|
241 |
+
* @param {array} $classes Existing classes
|
242 |
+
* @return {array} Updated classes
|
243 |
+
*/
|
244 |
+
public function has_post_video_class( $classes ) {
|
245 |
+
global $post;
|
246 |
+
|
247 |
+
if ( has_post_video( $post->ID ) ) {
|
248 |
+
$classes[] = 'has-post-video';
|
249 |
+
}
|
250 |
+
return $classes;
|
251 |
+
}
|
252 |
+
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Initializes i18n
|
256 |
+
*
|
257 |
+
* @since 1.3.0
|
258 |
+
*/
|
259 |
+
public function language() {
|
260 |
+
load_plugin_textdomain(
|
261 |
+
'featured-video-plus',
|
262 |
+
FVP_DIR . 'lng/',
|
263 |
+
FVP_NAME . '/lng/'
|
264 |
+
);
|
265 |
+
}
|
266 |
+
|
267 |
+
|
268 |
/**
|
269 |
* Determine featured video size
|
270 |
*
|
277 |
* @return {array} The desired video size also taking the options set
|
278 |
* in the media settings into consideration.
|
279 |
*/
|
280 |
+
protected static function get_size( $size = null, $original = null ) {
|
281 |
$options = get_option( 'fvp-settings' );
|
282 |
|
283 |
// fixed size requested as array( width => #, height => # ) or array( #, # )
|
285 |
$width = isset( $size['width'] ) && is_numeric( $size['width'] ) ?
|
286 |
$size['width'] :
|
287 |
( isset( $size[0] ) && is_numeric( $size[0] ) ? $size[0] : null );
|
288 |
+
$height = isset( $size['height'] ) && is_numeric( $size['height'] ) ?
|
289 |
$size['height'] :
|
290 |
( isset( $size[1] ) && is_numeric( $size[1] ) ? $size[1] : null );
|
291 |
|
329 |
}
|
330 |
|
331 |
|
332 |
+
/**
|
333 |
+
* Gets a post by an meta_key meta_value pair. Returns it's post_id.
|
334 |
+
*
|
335 |
+
* @see http://codex.wordpress.org/Class_Reference/wpdb
|
336 |
+
* @see http://dev.mysql.com/doc/refman/5.0/en/regexp.html#operator_regexp
|
337 |
+
* @since 1.0.0
|
338 |
+
*
|
339 |
+
* @param string $meta_key which meta_key to look for
|
340 |
+
* @param string $meta_value which meta_value to look for
|
341 |
+
*/
|
342 |
+
protected static function get_post_by_custom_meta(
|
343 |
+
$meta_key,
|
344 |
+
$meta_value = null
|
345 |
+
) {
|
346 |
+
global $wpdb;
|
347 |
+
if ( $meta_value !== null ) {
|
348 |
+
$prepared = $wpdb->prepare(
|
349 |
+
"SELECT post_id FROM {$wpdb->postmeta} " .
|
350 |
+
"WHERE meta_key=%s AND meta_value=%s LIMIT 1",
|
351 |
+
$meta_key,
|
352 |
+
$meta_value
|
353 |
+
);
|
354 |
+
return $wpdb->get_var( $prepared );
|
355 |
+
} else {
|
356 |
+
$prepared = $wpdb->prepare(
|
357 |
+
"SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key=%s",
|
358 |
+
$meta_key
|
359 |
+
);
|
360 |
+
return $wpdb->get_col( $prepared );
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Check a given set of display conditions if one or more of them hold. If
|
367 |
+
* an empty set is given, return true.
|
368 |
+
*
|
369 |
+
* @param {assoc} $conditions
|
370 |
+
* @return {bool}
|
371 |
+
*/
|
372 |
+
private static function check_conditions( $conditions ) {
|
373 |
+
if ( empty( $conditions ) ) {
|
374 |
+
return true;
|
375 |
+
}
|
376 |
+
|
377 |
+
$conditions_hold = false;
|
378 |
+
foreach ( $conditions AS $fun => $value ) {
|
379 |
+
$negate = false;
|
380 |
+
if ( '!' === $fun[0] ) {
|
381 |
+
$negate = true;
|
382 |
+
$fun = substr( $fun, 1 );
|
383 |
+
}
|
384 |
+
|
385 |
+
if ( $value && function_exists( 'is_' . $fun ) ) {
|
386 |
+
$call = call_user_func( 'is_' . $fun );
|
387 |
+
$conditions_hold = $conditions_hold || ( $negate ? ! $call : $call );
|
388 |
+
}
|
389 |
+
}
|
390 |
+
|
391 |
+
return $conditions_hold;
|
392 |
+
}
|
393 |
+
|
394 |
+
|
395 |
/**
|
396 |
* Parse the autoplay options to determine if video should or should not
|
397 |
* autoplay.
|
399 |
* @param {assoic} $options
|
400 |
* @return {bool}
|
401 |
*/
|
402 |
+
private static function parse_autoplay_options(
|
403 |
+
$options = array(),
|
404 |
+
$ajax = null
|
405 |
+
) {
|
406 |
if ( empty( $options['autoplay'] ) ) {
|
407 |
return false;
|
408 |
}
|
415 |
};
|
416 |
|
417 |
$mode = ! empty( $options['mode'] ) ? $options['mode'] : null;
|
418 |
+
//$ajax = defined( 'DOING_AJAX' ) && DOING_AJAX && $ajax;
|
|
|
419 |
|
420 |
if (
|
421 |
! empty( $options['autoplay']['lazy'] ) &&
|
422 |
$options['autoplay']['lazy'] &&
|
423 |
+
$ajax
|
424 |
) {
|
425 |
return true;
|
426 |
}
|
436 |
return false;
|
437 |
}
|
438 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
440 |
}
|
readme.txt
CHANGED
@@ -10,7 +10,7 @@ License: GPLv2 or later
|
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
Requires at least: 3.7
|
12 |
Tested up to: 4.3
|
13 |
-
Stable tag: 2.2.
|
14 |
|
15 |
Add Featured Videos to your posts and pages. Works like magic with most themes which use Featured Images. Local Media, YouTube, Vimeo and many more.
|
16 |
|
@@ -107,6 +107,10 @@ Yes, please! Check out the public [Featured Video Plus Translation Project](http
|
|
107 |
|
108 |
== Changelog ==
|
109 |
|
|
|
|
|
|
|
|
|
110 |
= 2.2.1: 2015-09-08 =
|
111 |
* Now compatible with infinite scroll! ([*](https://wordpress.org/support/topic/vimeo-thrumbnails-not-work), [*](https://wordpress.org/support/topic/video-embedding-issue-when-using-infinite-scroll), [*](https://wordpress.org/support/topic/featured-video-plus-jetpack-infinite-scroll-video-width-problem))
|
112 |
* Fix bad overlay sizing when loading from cache. ([*](https://wordpress.org/support/topic/video-shrinking-on-2nd-play))
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
Requires at least: 3.7
|
12 |
Tested up to: 4.3
|
13 |
+
Stable tag: 2.2.2
|
14 |
|
15 |
Add Featured Videos to your posts and pages. Works like magic with most themes which use Featured Images. Local Media, YouTube, Vimeo and many more.
|
16 |
|
107 |
|
108 |
== Changelog ==
|
109 |
|
110 |
+
= 2.2.2: 2015-09-15 =
|
111 |
+
* Fix for not correctly hidden preload images. ([*](https://wordpress.org/support/topic/your-aplication-is-not-working-right-on-wordpress-43–es_es), [*](https://wordpress.org/support/topic/play-and-load-images-appended-to-body-since-update-to-221))
|
112 |
+
* Replace features videos more reliably on AJAX requests. ([*](https://wordpress.org/support/topic/video-embedding-issue-when-using-infinite-scroll))
|
113 |
+
|
114 |
= 2.2.1: 2015-09-08 =
|
115 |
* Now compatible with infinite scroll! ([*](https://wordpress.org/support/topic/vimeo-thrumbnails-not-work), [*](https://wordpress.org/support/topic/video-embedding-issue-when-using-infinite-scroll), [*](https://wordpress.org/support/topic/featured-video-plus-jetpack-infinite-scroll-video-width-problem))
|
116 |
* Fix bad overlay sizing when loading from cache. ([*](https://wordpress.org/support/topic/video-shrinking-on-2nd-play))
|
styles/frontend.css
CHANGED
@@ -53,14 +53,32 @@
|
|
53 |
height: auto;
|
54 |
width: auto;
|
55 |
}
|
56 |
-
.fvp-overlay .fvp-
|
57 |
-
.fvp-dynamic .fvp-
|
58 |
background: transparent no-repeat scroll center center;
|
59 |
position: absolute;
|
60 |
top: 0;
|
61 |
left: 0;
|
62 |
z-index: 999;
|
63 |
pointer-events: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
#DOMWindow {
|
66 |
background: transparent center center no-repeat;
|
@@ -68,6 +86,13 @@
|
|
68 |
height: auto;
|
69 |
margin: auto auto;
|
70 |
overflow: hidden;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
.featured-video-plus .wp-video a:not(.post-thumbnail) {
|
73 |
display: none;
|
@@ -78,6 +103,3 @@
|
|
78 |
.featured-video-plus.fvp-responsive.fvp-spotify .fluid-width-video-wrapper {
|
79 |
padding-top: 100% !important;
|
80 |
}
|
81 |
-
.onload.playicon {
|
82 |
-
display: none;
|
83 |
-
}
|
53 |
height: auto;
|
54 |
width: auto;
|
55 |
}
|
56 |
+
.fvp-overlay .fvp-actionicon,
|
57 |
+
.fvp-dynamic .fvp-actionicon {
|
58 |
background: transparent no-repeat scroll center center;
|
59 |
position: absolute;
|
60 |
top: 0;
|
61 |
left: 0;
|
62 |
z-index: 999;
|
63 |
pointer-events: none;
|
64 |
+
display: none;
|
65 |
+
}
|
66 |
+
.fvp-overlay .fvp-actionicon.play,
|
67 |
+
.fvp-dynamic .fvp-actionicon.play {
|
68 |
+
display: block;
|
69 |
+
background-image: url('../img/playicon.png');
|
70 |
+
}
|
71 |
+
.fvp-overlay .fvp-actionicon.load,
|
72 |
+
.fvp-dynamic .fvp-actionicon.load {
|
73 |
+
display: block;
|
74 |
+
}
|
75 |
+
.fvp-overlay .fvp-actionicon.load.w,
|
76 |
+
.fvp-dynamic .fvp-actionicon.load.w {
|
77 |
+
background-image: url('../img/loadicon_w.gif');
|
78 |
+
}
|
79 |
+
.fvp-overlay .fvp-actionicon.load.b,
|
80 |
+
.fvp-dynamic .fvp-actionicon.load.b {
|
81 |
+
background-image: url('../img/loadicon_b.gif');
|
82 |
}
|
83 |
#DOMWindow {
|
84 |
background: transparent center center no-repeat;
|
86 |
height: auto;
|
87 |
margin: auto auto;
|
88 |
overflow: hidden;
|
89 |
+
background-image: url('../img/loadicon_w.gif');
|
90 |
+
}
|
91 |
+
.fvp-onload {
|
92 |
+
display: none !important;
|
93 |
+
height: 0;
|
94 |
+
width: 0;
|
95 |
+
visibility: hidden;
|
96 |
}
|
97 |
.featured-video-plus .wp-video a:not(.post-thumbnail) {
|
98 |
display: none;
|
103 |
.featured-video-plus.fvp-responsive.fvp-spotify .fluid-width-video-wrapper {
|
104 |
padding-top: 100% !important;
|
105 |
}
|
|
|
|
|
|