Skip to content
Merged
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
2 changes: 1 addition & 1 deletion admin/class-flowplayer5-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function shortcode_row( $column, $post_id ){
switch ( $column ) {

case 'shortcode' :
echo '[flowplayer id="' . $post_id . '"]';
echo '[flowplayer id="' . absint( $post_id ) . '"]';
break;

}
Expand Down
5 changes: 4 additions & 1 deletion admin/class-flowplayer5-meta-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ public function add_video_meta_box() {
public function display_video_meta_box( $post ) {

wp_nonce_field( plugin_basename( __FILE__ ), 'fp5-nonce' );
$fp5_stored_meta = get_post_meta( $post->ID );
$fp5_stored_meta = wp_parse_args(
get_post_meta( $post->ID ),
apply_filters( 'fp5_post_meta_defaults', array() )
);

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

Expand Down
52 changes: 27 additions & 25 deletions admin/flowplayer-drive/class-flowplayer-drive.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,35 +188,37 @@ public function get_videos() {
continue;
}

$quality = $encoding->height . 'p';
$quality = $encoding->height . 'p';
$default_video = true;
$hls = '';

if ( 'mp4' === $encoding->format && 1 < $video->hlsResolutions ) {
// 'example-video-216p.mp4' - '-216p' Exclude default video size
if ( strpos( $encoding->filename, ( '-' . $quality ) ) === false ) {
$default_video = true;
continue;
// 'example-video-216p.mp4' - '-216p' Fetch sizes from non-default sizes
if ( strpos( $encoding->filename, ( '-' . $quality ) ) !== false ) {
$default_video = false;
$qualities[] = $quality;
}
$default_video = false;
$qualities[] = $quality;
}

if ( ! $default_video ) {
if ( false === $default_video ) {
continue;
}

if ( 'webm' === $encoding->format ) {
$webm = $encoding->url;
$height = $encoding->height;
$width = $encoding->width;
} elseif ( 'mp4' === $encoding->format ) {
$mp4 = $encoding->url;
$flash = $encoding->filename;
$height = $encoding->height;
$width = $encoding->width;
} elseif ( 'hls' === $encoding->format ) {
$hls = $encoding->url;
} else {
$hls = '';
switch ( $encoding->format ) {
case 'webm':
$webm = $encoding->url;
$height = $encoding->height;
$width = $encoding->width;
break;
case 'mp4':
$mp4 = $encoding->url;
$flash = $encoding->filename;
$height = $encoding->height;
$width = $encoding->width;
break;
case 'hls':
$hls = $encoding->url;
break;
}

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

$return = '<div class="video">';
$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'] . '">';
$return .= '<h2 class="video-title">' . $video['title'] . '</h2>';
$return .= '<div class="thumb" style="background-image: url(' . $video['thumbnailUrl'] . ');">';
$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'] ) . '">';
$return .= '<h2 class="video-title">' . esc_html( $video['title'] ) . '</h2>';
$return .= '<div class="thumb" style="background-image: url(' . esc_url( $video['thumbnailUrl'] ) . ');">';
$return .= '<div class="bar">';
$return .= $multi_res;
$return .= '<span class="duration">' . $video['duration'] . '</span>';
$return .= '<span class="duration">' . esc_attr( $video['duration'] ) . '</span>';
$return .= '</div>';
$return .= '</div>';
$return .= '</a>';
Expand Down
2 changes: 1 addition & 1 deletion flowplayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Plugin Name: Flowplayer HTML5 for WordPress
* Plugin URI: http://wordpress.org/plugins/flowplayer5/
* 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.
* Version: 1.10.4
* Version: 1.10.5
* Author: Flowplayer ltd.
* Author URI: http://flowplayer.org/
* Text Domain: flowplayer5
Expand Down
90 changes: 66 additions & 24 deletions frontend/class-flowplayer5-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
*/
class Flowplayer5_Frontend {

public $has_flowplayer_video = '';
public $has_flowplayer_shortcode = '';

/**
* Initialize the plugin by setting localization, filters, and administration functions.
*
* @since 1.0.0
*/
public function __construct() {
global $flowplayer5_shortcode;

$plugin = Flowplayer5::get_instance();
// Call $plugin_version from public plugin class.
$this->plugin_version = $plugin->get_plugin_version();
Expand All @@ -57,6 +61,9 @@ public function __construct() {
$this->flowplayer5_directory = '//releases.flowplayer.org/' . $this->player_version . '/'. ( $key ? 'commercial' : '' );
}

// Start check if posts have videos
add_action( 'wp_enqueue_scripts', array( $this, 'has_flowplayer_video' ) );

// Load public-facing style sheet and JavaScript.
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
Expand All @@ -77,18 +84,16 @@ public function __construct() {
public function enqueue_styles() {

// Pull options
$options = get_option( 'fp5_settings_general' );
$asf_css = ( ! empty ( $options['asf_css'] ) ? $options['asf_css'] : false );
$has_shortcode = $this->has_flowplayer_shortcode();
$has_video = isset ( $has_shortcode ) || 'flowplayer5' == get_post_type() || is_active_widget( false, false, 'flowplayer5-video-widget', true );
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$options = get_option( 'fp5_settings_general' );
$asf_css = ( ! empty ( $options['asf_css'] ) ? $options['asf_css'] : false );
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';

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

// Register stylesheets
if ( apply_filters( 'fp5_filter_has_shortcode', $has_video ) ) {
if ( $this->has_flowplayer_video ) {
wp_enqueue_style( $this->plugin_slug . '-skins' );
wp_enqueue_style( $this->plugin_slug . '-logo-origin' );
if ( $asf_css ) {
Expand All @@ -107,8 +112,6 @@ public function enqueue_scripts() {

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

Expand All @@ -118,7 +121,7 @@ public function enqueue_scripts() {
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 );

// Register JavaScript
if ( apply_filters( 'fp5_filter_has_shortcode', $has_video ) ) {
if ( $this->has_flowplayer_video ) {
wp_enqueue_script( $this->plugin_slug . '-script' );
if ( $asf_js ) {
wp_enqueue_script( $this->plugin_slug . '-asf' );
Expand Down Expand Up @@ -166,10 +169,10 @@ public function global_config_script() {
$return .= '<script>';
$return .= 'flowplayer.conf = {';
$return .= 'embed: {';
$return .= ( ! empty ( $embed_library ) ? 'library: "' . $embed_library . '",' : '' );
$return .= ( ! empty ( $embed_script ) ? 'script: "' . $embed_script . '",' : '' );
$return .= ( ! empty ( $embed_skin ) ? 'skin: "' . $embed_skin . '",' : '' );
$return .= ( ! empty ( $embed_swf ) ? 'swf: "' . $embed_swf . '"' : '' );
$return .= ( ! empty ( $embed_library ) ? 'library: "' . esc_js( $embed_library ) . '",' : '' );
$return .= ( ! empty ( $embed_script ) ? 'script: "' . esc_js( $embed_script ) . '",' : '' );
$return .= ( ! empty ( $embed_skin ) ? 'skin: "' . esc_js( $embed_skin ) . '",' : '' );
$return .= ( ! empty ( $embed_swf ) ? 'swf: "' . esc_js( $embed_swf ) . '"' : '' );
$return .= '}';
$return .= '};';
$return .= '</script>';
Expand All @@ -189,36 +192,75 @@ public function global_config_script() {
}

public function has_flowplayer_shortcode() {
$post = get_queried_object();
if ( null !== $post ) {
if ( is_404() || ! empty( $this->has_flowplayer_shortcode ) ) {
return;
}

$post = get_queried_object();
$has_shortcode = array();
$shortcode_args = array();

if ( null !== $post && is_single() ) {
$post_content = isset( $post->post_content ) ? $post->post_content : '';
$has_shortcode[] = fp5_has_shortcode_arg( $post_content, 'flowplayer' );
$shortcode_args = fp5_has_shortcode_arg( $post_content, 'flowplayer' );
foreach ( $shortcode_args as $key => $value ) {
if ( isset( $value['id'] ) ) {
$has_shortcode[ 'id' . $value['id'] ] = $value['id'];
} elseif ( isset( $value['playlist'] ) ) {
$has_shortcode[ 'playlist' . $value['playlist'] ] = $value['playlist'];
}
}
} else {
global $wp_query;
foreach ( $wp_query->posts as $post ) {
$post_content = isset( $post->post_content ) ? $post->post_content : '';
$has_shortcode[] = fp5_has_shortcode_arg( $post_content, 'flowplayer' );
$shortcode_args = fp5_has_shortcode_arg( $post_content, 'flowplayer' );
if ( ! $shortcode_args ) {
continue;
}
foreach ( $shortcode_args as $key => $value ) {
if ( isset( $value['id'] ) ) {
$has_shortcode[ 'id' . $value['id'] ] = $value['id'];
} elseif ( isset( $value['playlist'] ) ) {
$has_shortcode[ 'playlist' . $value['playlist'] ] = $value['playlist'];
}
}
}
}
$has_shortcode = iterator_to_array(new RecursiveIteratorIterator(
new RecursiveArrayIterator($has_shortcode)), FALSE);

return array_diff( $has_shortcode, array( false ) );
$this->has_flowplayer_shortcode = array_filter( $has_shortcode );
}

public function has_flowplayer_video() {
if ( ! empty( $this->has_flowplayer_video ) ){
return;
}

$has_video = 'flowplayer5' == get_post_type() || is_active_widget( false, false, 'flowplayer5-video-widget', true );
if ( ! $has_video ) {
$this->has_flowplayer_shortcode();
$has_video = ! empty ( $this->has_flowplayer_shortcode );
}

$this->has_flowplayer_video = apply_filters( 'fp5_filter_has_shortcode', $has_video );
}

public function is_multiresolution() {
$post_id = '';
$post_id = '';
$qualities = array();

// Check if the post is a flowplayer video
if ( 'flowplayer5' == get_post_type() && isset ( $post->ID ) ) {
$post_id = $post->ID;
$qualities[] = get_post_meta( $post_id, 'fp5-qualities', true );
return $qualities;
}

$shortcode_atts = $this->has_flowplayer_shortcode();
foreach ( $shortcode_atts as $post_id ) {
$qualities[] = get_post_meta( $post_id, 'fp5-qualities', true );
$this->has_flowplayer_shortcode();
foreach ( $this->has_flowplayer_shortcode as $key => $value ) {
if ( 'id' . $value === $key ) {
$qualities[] = get_post_meta( $post_id, 'fp5-qualities', true );
}
}

return $qualities;
Expand Down
2 changes: 1 addition & 1 deletion includes/class-flowplayer5.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Flowplayer5 {
*
* @var string
*/
protected $plugin_version = '1.10.4';
protected $plugin_version = '1.10.5';

/**
* Player version, used for cache-busting of style and script file references.
Expand Down
22 changes: 20 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ function fp5_video_config() {
add_action( 'fp5_video_config', 'fp5_video_config' );`


`/**
* Define post meta defaults
*/
function fp5_post_meta_defaults( $defaults ) {
$defaults['fp5-no-embed'] = array( 'true' );
return $defaults;
}
add_filter( 'fp5_post_meta_defaults', 'fp5_post_meta_defaults' );`


== Screenshots ==

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

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)

= 1.10.4 - 3 Febuary 2015 =
= 1.10.5 - 1 March 2015 =
* fix bug: playing videos on different pages
* fix bug: fix issue with videos from Flowplayer Drive
* add filter to define new video defaults

= 1.10.4 - 21 February 2015 =
* fix bug: play videos when in a blog loop
* fix bug: fix issue with loading all of the videos from Flowplayer Drive

= 1.10.3 - 3 Febuary 2015 =
= 1.10.3 - 3 February 2015 =
* fix bug: fix code Flowplayer Drive API
* fix bug: fix issue with Playlist JS

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

== Upgrade Notice ==

= 1.10.5 =
* fix bugs with Flowplayer Drive and playing videos

= 1.10.4 =
* fix bugs with Flowplayer Drive and playing videos on the blog page

Expand Down