Skip to content

Commit a78fb10

Browse files
committed
Merge pull request #85 from flowplayer/develop
Version 1.10.5
2 parents 2ed1d8b + 303c744 commit a78fb10

7 files changed

Lines changed: 120 additions & 55 deletions

File tree

admin/class-flowplayer5-admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ public function shortcode_row( $column, $post_id ){
350350
switch ( $column ) {
351351

352352
case 'shortcode' :
353-
echo '[flowplayer id="' . $post_id . '"]';
353+
echo '[flowplayer id="' . absint( $post_id ) . '"]';
354354
break;
355355

356356
}

admin/class-flowplayer5-meta-box.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ public function add_video_meta_box() {
137137
public function display_video_meta_box( $post ) {
138138

139139
wp_nonce_field( plugin_basename( __FILE__ ), 'fp5-nonce' );
140-
$fp5_stored_meta = get_post_meta( $post->ID );
140+
$fp5_stored_meta = wp_parse_args(
141+
get_post_meta( $post->ID ),
142+
apply_filters( 'fp5_post_meta_defaults', array() )
143+
);
141144

142145
include_once( plugin_dir_path( __FILE__ ) . 'views/display-video-meta-box.php' );
143146

admin/flowplayer-drive/class-flowplayer-drive.php

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -188,35 +188,37 @@ public function get_videos() {
188188
continue;
189189
}
190190

191-
$quality = $encoding->height . 'p';
191+
$quality = $encoding->height . 'p';
192+
$default_video = true;
193+
$hls = '';
192194

193195
if ( 'mp4' === $encoding->format && 1 < $video->hlsResolutions ) {
194-
// 'example-video-216p.mp4' - '-216p' Exclude default video size
195-
if ( strpos( $encoding->filename, ( '-' . $quality ) ) === false ) {
196-
$default_video = true;
197-
continue;
196+
// 'example-video-216p.mp4' - '-216p' Fetch sizes from non-default sizes
197+
if ( strpos( $encoding->filename, ( '-' . $quality ) ) !== false ) {
198+
$default_video = false;
199+
$qualities[] = $quality;
198200
}
199-
$default_video = false;
200-
$qualities[] = $quality;
201201
}
202202

203-
if ( ! $default_video ) {
203+
if ( false === $default_video ) {
204204
continue;
205205
}
206206

207-
if ( 'webm' === $encoding->format ) {
208-
$webm = $encoding->url;
209-
$height = $encoding->height;
210-
$width = $encoding->width;
211-
} elseif ( 'mp4' === $encoding->format ) {
212-
$mp4 = $encoding->url;
213-
$flash = $encoding->filename;
214-
$height = $encoding->height;
215-
$width = $encoding->width;
216-
} elseif ( 'hls' === $encoding->format ) {
217-
$hls = $encoding->url;
218-
} else {
219-
$hls = '';
207+
switch ( $encoding->format ) {
208+
case 'webm':
209+
$webm = $encoding->url;
210+
$height = $encoding->height;
211+
$width = $encoding->width;
212+
break;
213+
case 'mp4':
214+
$mp4 = $encoding->url;
215+
$flash = $encoding->filename;
216+
$height = $encoding->height;
217+
$width = $encoding->width;
218+
break;
219+
case 'hls':
220+
$hls = $encoding->url;
221+
break;
220222
}
221223

222224
if ( in_array( $encoding->format, array( 'mp4', 'webm' ) ) ) {
@@ -265,12 +267,12 @@ public function get_video_html() {
265267
}
266268

267269
$return = '<div class="video">';
268-
$return .= '<a href="#" class="choose-video" data-rtmp="' . $video['rtmp'] . '" data-user-id="' . $video['userId'] . '" data-video-id="' . $video['id'] . '" data-video-name="' . $video['title'] . '" data-webm="' . $video['webm'] .'" data-mp4="' . $video['mp4'] . '" data-hls="' . $video['hls'] . '" data-flash="' . $video['flash'] . '" data-img="' . $video['snapshotUrl'] . '" data-qualities="' . implode( ',', $video['qualities'] ) . '" data-default-quality="' . $video['quality'] . '">';
269-
$return .= '<h2 class="video-title">' . $video['title'] . '</h2>';
270-
$return .= '<div class="thumb" style="background-image: url(' . $video['thumbnailUrl'] . ');">';
270+
$return .= '<a href="#" class="choose-video" data-rtmp="' . esc_attr( $video['rtmp'] ) . '" data-user-id="' . esc_attr( $video['userId'] ) . '" data-video-id="' . esc_attr( $video['id'] ) . '" data-video-name="' . esc_html( $video['title'] ) . '" data-webm="' . esc_url( $video['webm'] ) .'" data-mp4="' . esc_url( $video['mp4'] ) . '" data-hls="' . esc_attr( $video['hls'] ) . '" data-flash="' . esc_attr( $video['flash'] ) . '" data-img="' . esc_url( $video['snapshotUrl'] ) . '" data-qualities="' . esc_attr( implode( ',', $video['qualities'] ) ) . '" data-default-quality="' . esc_attr( $video['quality'] ) . '">';
271+
$return .= '<h2 class="video-title">' . esc_html( $video['title'] ) . '</h2>';
272+
$return .= '<div class="thumb" style="background-image: url(' . esc_url( $video['thumbnailUrl'] ) . ');">';
271273
$return .= '<div class="bar">';
272274
$return .= $multi_res;
273-
$return .= '<span class="duration">' . $video['duration'] . '</span>';
275+
$return .= '<span class="duration">' . esc_attr( $video['duration'] ) . '</span>';
274276
$return .= '</div>';
275277
$return .= '</div>';
276278
$return .= '</a>';

flowplayer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Plugin Name: Flowplayer HTML5 for WordPress
1212
* Plugin URI: http://wordpress.org/plugins/flowplayer5/
1313
* Description: A HTML5 responsive video player plugin. From the makers of Flowplayer. Includes player skins, tracking with Google Analytics, splash images and support for subtitles and multi-resolution videos. You can use your own watermark logo if you own a Commercial Flowplayer license.
14-
* Version: 1.10.4
14+
* Version: 1.10.5
1515
* Author: Flowplayer ltd.
1616
* Author URI: http://flowplayer.org/
1717
* Text Domain: flowplayer5

frontend/class-flowplayer5-frontend.php

Lines changed: 66 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@
2424
*/
2525
class Flowplayer5_Frontend {
2626

27+
public $has_flowplayer_video = '';
28+
public $has_flowplayer_shortcode = '';
29+
2730
/**
2831
* Initialize the plugin by setting localization, filters, and administration functions.
2932
*
3033
* @since 1.0.0
3134
*/
3235
public function __construct() {
3336
global $flowplayer5_shortcode;
37+
3438
$plugin = Flowplayer5::get_instance();
3539
// Call $plugin_version from public plugin class.
3640
$this->plugin_version = $plugin->get_plugin_version();
@@ -57,6 +61,9 @@ public function __construct() {
5761
$this->flowplayer5_directory = '//releases.flowplayer.org/' . $this->player_version . '/'. ( $key ? 'commercial' : '' );
5862
}
5963

64+
// Start check if posts have videos
65+
add_action( 'wp_enqueue_scripts', array( $this, 'has_flowplayer_video' ) );
66+
6067
// Load public-facing style sheet and JavaScript.
6168
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
6269
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
@@ -77,18 +84,16 @@ public function __construct() {
7784
public function enqueue_styles() {
7885

7986
// Pull options
80-
$options = get_option( 'fp5_settings_general' );
81-
$asf_css = ( ! empty ( $options['asf_css'] ) ? $options['asf_css'] : false );
82-
$has_shortcode = $this->has_flowplayer_shortcode();
83-
$has_video = isset ( $has_shortcode ) || 'flowplayer5' == get_post_type() || is_active_widget( false, false, 'flowplayer5-video-widget', true );
84-
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
87+
$options = get_option( 'fp5_settings_general' );
88+
$asf_css = ( ! empty ( $options['asf_css'] ) ? $options['asf_css'] : false );
89+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
8590

8691
wp_register_style( $this->plugin_slug . '-skins', trailingslashit( $this->flowplayer5_directory ) . 'skin/all-skins.css', array(), $this->player_version );
8792
wp_register_style( $this->plugin_slug . '-logo-origin', plugins_url( '/assets/css/public-concat' . $suffix . '.css', __FILE__ ), array(), $this->plugin_version );
8893
wp_register_style( $this->plugin_slug . '-asf', esc_url( $asf_css ), array(), null );
8994

9095
// Register stylesheets
91-
if ( apply_filters( 'fp5_filter_has_shortcode', $has_video ) ) {
96+
if ( $this->has_flowplayer_video ) {
9297
wp_enqueue_style( $this->plugin_slug . '-skins' );
9398
wp_enqueue_style( $this->plugin_slug . '-logo-origin' );
9499
if ( $asf_css ) {
@@ -107,8 +112,6 @@ public function enqueue_scripts() {
107112

108113
$options = get_option( 'fp5_settings_general' );
109114
$asf_js = ( ! empty ( $options['asf_js'] ) ? $options['asf_js'] : false );
110-
$has_shortcode = $this->has_flowplayer_shortcode();
111-
$has_video = isset ( $has_shortcode ) || 'flowplayer5' == get_post_type() || is_active_widget( false, false, 'flowplayer5-video-widget', true );
112115
$is_multiresolution = $this->is_multiresolution();
113116
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
114117

@@ -118,7 +121,7 @@ public function enqueue_scripts() {
118121
wp_register_script( $this->plugin_slug . '-quality-selector', plugins_url( '/assets/drive/quality-selector' . $suffix . '.js', __FILE__ ), array( $this->plugin_slug . '-script' ), $this->player_version, false );
119122

120123
// Register JavaScript
121-
if ( apply_filters( 'fp5_filter_has_shortcode', $has_video ) ) {
124+
if ( $this->has_flowplayer_video ) {
122125
wp_enqueue_script( $this->plugin_slug . '-script' );
123126
if ( $asf_js ) {
124127
wp_enqueue_script( $this->plugin_slug . '-asf' );
@@ -166,10 +169,10 @@ public function global_config_script() {
166169
$return .= '<script>';
167170
$return .= 'flowplayer.conf = {';
168171
$return .= 'embed: {';
169-
$return .= ( ! empty ( $embed_library ) ? 'library: "' . $embed_library . '",' : '' );
170-
$return .= ( ! empty ( $embed_script ) ? 'script: "' . $embed_script . '",' : '' );
171-
$return .= ( ! empty ( $embed_skin ) ? 'skin: "' . $embed_skin . '",' : '' );
172-
$return .= ( ! empty ( $embed_swf ) ? 'swf: "' . $embed_swf . '"' : '' );
172+
$return .= ( ! empty ( $embed_library ) ? 'library: "' . esc_js( $embed_library ) . '",' : '' );
173+
$return .= ( ! empty ( $embed_script ) ? 'script: "' . esc_js( $embed_script ) . '",' : '' );
174+
$return .= ( ! empty ( $embed_skin ) ? 'skin: "' . esc_js( $embed_skin ) . '",' : '' );
175+
$return .= ( ! empty ( $embed_swf ) ? 'swf: "' . esc_js( $embed_swf ) . '"' : '' );
173176
$return .= '}';
174177
$return .= '};';
175178
$return .= '</script>';
@@ -189,36 +192,75 @@ public function global_config_script() {
189192
}
190193

191194
public function has_flowplayer_shortcode() {
192-
$post = get_queried_object();
193-
if ( null !== $post ) {
195+
if ( is_404() || ! empty( $this->has_flowplayer_shortcode ) ) {
196+
return;
197+
}
198+
199+
$post = get_queried_object();
200+
$has_shortcode = array();
201+
$shortcode_args = array();
202+
203+
if ( null !== $post && is_single() ) {
194204
$post_content = isset( $post->post_content ) ? $post->post_content : '';
195-
$has_shortcode[] = fp5_has_shortcode_arg( $post_content, 'flowplayer' );
205+
$shortcode_args = fp5_has_shortcode_arg( $post_content, 'flowplayer' );
206+
foreach ( $shortcode_args as $key => $value ) {
207+
if ( isset( $value['id'] ) ) {
208+
$has_shortcode[ 'id' . $value['id'] ] = $value['id'];
209+
} elseif ( isset( $value['playlist'] ) ) {
210+
$has_shortcode[ 'playlist' . $value['playlist'] ] = $value['playlist'];
211+
}
212+
}
196213
} else {
197214
global $wp_query;
198215
foreach ( $wp_query->posts as $post ) {
199216
$post_content = isset( $post->post_content ) ? $post->post_content : '';
200-
$has_shortcode[] = fp5_has_shortcode_arg( $post_content, 'flowplayer' );
217+
$shortcode_args = fp5_has_shortcode_arg( $post_content, 'flowplayer' );
218+
if ( ! $shortcode_args ) {
219+
continue;
220+
}
221+
foreach ( $shortcode_args as $key => $value ) {
222+
if ( isset( $value['id'] ) ) {
223+
$has_shortcode[ 'id' . $value['id'] ] = $value['id'];
224+
} elseif ( isset( $value['playlist'] ) ) {
225+
$has_shortcode[ 'playlist' . $value['playlist'] ] = $value['playlist'];
226+
}
227+
}
201228
}
202229
}
203-
$has_shortcode = iterator_to_array(new RecursiveIteratorIterator(
204-
new RecursiveArrayIterator($has_shortcode)), FALSE);
205230

206-
return array_diff( $has_shortcode, array( false ) );
231+
$this->has_flowplayer_shortcode = array_filter( $has_shortcode );
232+
}
233+
234+
public function has_flowplayer_video() {
235+
if ( ! empty( $this->has_flowplayer_video ) ){
236+
return;
237+
}
238+
239+
$has_video = 'flowplayer5' == get_post_type() || is_active_widget( false, false, 'flowplayer5-video-widget', true );
240+
if ( ! $has_video ) {
241+
$this->has_flowplayer_shortcode();
242+
$has_video = ! empty ( $this->has_flowplayer_shortcode );
243+
}
244+
245+
$this->has_flowplayer_video = apply_filters( 'fp5_filter_has_shortcode', $has_video );
207246
}
208247

209248
public function is_multiresolution() {
210-
$post_id = '';
249+
$post_id = '';
211250
$qualities = array();
251+
212252
// Check if the post is a flowplayer video
213253
if ( 'flowplayer5' == get_post_type() && isset ( $post->ID ) ) {
214254
$post_id = $post->ID;
215255
$qualities[] = get_post_meta( $post_id, 'fp5-qualities', true );
216256
return $qualities;
217257
}
218258

219-
$shortcode_atts = $this->has_flowplayer_shortcode();
220-
foreach ( $shortcode_atts as $post_id ) {
221-
$qualities[] = get_post_meta( $post_id, 'fp5-qualities', true );
259+
$this->has_flowplayer_shortcode();
260+
foreach ( $this->has_flowplayer_shortcode as $key => $value ) {
261+
if ( 'id' . $value === $key ) {
262+
$qualities[] = get_post_meta( $post_id, 'fp5-qualities', true );
263+
}
222264
}
223265

224266
return $qualities;

includes/class-flowplayer5.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Flowplayer5 {
3131
*
3232
* @var string
3333
*/
34-
protected $plugin_version = '1.10.4';
34+
protected $plugin_version = '1.10.5';
3535

3636
/**
3737
* Player version, used for cache-busting of style and script file references.

readme.txt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,16 @@ function fp5_video_config() {
230230
add_action( 'fp5_video_config', 'fp5_video_config' );`
231231

232232

233+
`/**
234+
* Define post meta defaults
235+
*/
236+
function fp5_post_meta_defaults( $defaults ) {
237+
$defaults['fp5-no-embed'] = array( 'true' );
238+
return $defaults;
239+
}
240+
add_filter( 'fp5_post_meta_defaults', 'fp5_post_meta_defaults' );`
241+
242+
233243
== Screenshots ==
234244

235245
1. Posting a video
@@ -242,11 +252,16 @@ add_action( 'fp5_video_config', 'fp5_video_config' );`
242252

243253
We have a lot of plans for this plugin. You can see some of the up and coming features in the [roadmap](https://github.com/flowplayer/wordpress-flowplayer/issues?labels=enhancement&page=1&state=open)
244254

245-
= 1.10.4 - 3 Febuary 2015 =
255+
= 1.10.5 - 1 March 2015 =
256+
* fix bug: playing videos on different pages
257+
* fix bug: fix issue with videos from Flowplayer Drive
258+
* add filter to define new video defaults
259+
260+
= 1.10.4 - 21 February 2015 =
246261
* fix bug: play videos when in a blog loop
247262
* fix bug: fix issue with loading all of the videos from Flowplayer Drive
248263

249-
= 1.10.3 - 3 Febuary 2015 =
264+
= 1.10.3 - 3 February 2015 =
250265
* fix bug: fix code Flowplayer Drive API
251266
* fix bug: fix issue with Playlist JS
252267

@@ -379,6 +394,9 @@ We have a lot of plans for this plugin. You can see some of the up and coming fe
379394

380395
== Upgrade Notice ==
381396

397+
= 1.10.5 =
398+
* fix bugs with Flowplayer Drive and playing videos
399+
382400
= 1.10.4 =
383401
* fix bugs with Flowplayer Drive and playing videos on the blog page
384402

0 commit comments

Comments
 (0)