Featured Video Plus - Version 1.2

Version Description

  • Added support for local videos
  • Allow webM mime type for media upload
  • Added Media Settings link in plugin info
  • More notices/warnings
  • More JS
  • minimized JS and CSS
  • fixed some other stuff
Download this release

Release Info

Developer a.hoereth
Plugin Icon 128x128 Featured Video Plus
Version 1.2
Comparing to
See all releases

Code changes from version 1.1 to 1.2

README.md ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Featured Video Plus - WordPress Plugin #
2
+ Add Featured Videos to your posts and pages, just like you add Featured Images. Supports your Local Videos, YouTube, Vimeo and Dailymotion.
3
+
4
+ [On WordPress.org](http://wordpress.org/extend/plugins/featured-video-plus/)
5
+
6
+ ## Description ##
7
+ *A picture is worth a thousand words. How many words is a video worth?*
8
+
9
+ This plugin enables you to define Featured Videos in addition to Featured Images. Themes using Featured Images automatically display the videos in place.
10
+
11
+ There are three ways to get the videos onto your page:
12
+
13
+ 1. If your theme already makes use of Featured Images, these will automatically be replaced by Featured Videos if available. Alternatively you can
14
+ 2. insert the `[featured-video-plus]` shortcode in your entries or
15
+ 3. manually use the PHP functions in your theme's source files.
16
+
17
+ Beside your __Local Videos__ (`mp4`, `webM` & `ogg/ogv`) you can use __YouTube__ (w/[time-links](http://support.google.com/youtube/bin/answer.py?hl=en&answer=116618 "Link to a specific time in a video")), __Vimeo__ and __Dailymotion__. If you miss a certain video platform: [Leave me a note](http://wordpress.org/support/plugin/featured-video-plus).
18
+
19
+ The plugin adds some individualization options to your Media Settings. Beside aesthetic customizations you can turn off automatic integration and tweak some technical settings.
20
+
21
+ ### Shortcode ###
22
+
23
+ [featured-video-plus]
24
+ [featured-video-plus width=300]
25
+
26
+
27
+ ### Theme functions ###
28
+
29
+ the_post_video(array(width, height), fullscreen = true)
30
+ has_post_video(post_id)
31
+ get_the_post_video(post_id, size(width, height), fullscreen = true)
32
+
33
+ All parameters are optional. If no post_id is given the current post's id will be used.
34
+
35
+ ## Changelog ##
36
+ ### 1.2 ###
37
+ * __Added support for local videos__
38
+ * Allow webM mime type for media upload
39
+ * Added Media Settings link in plugin info
40
+ * More notices/warnings
41
+ * More JS
42
+ * minimized JS and CSS
43
+ * fixed some other stuff
44
+
45
+ ### 1.1 ###
46
+ * __Added Dailymotion__
47
+ * fixed youtube 'start at specific time' embeds
48
+ * overhaul of the interaction between Featured Videos and Featured Images
49
+ * existing featured images will no longer be replaced by newly added featured videos in the administration interface
50
+
51
+ ### 1.0 ###
52
+ * Release
css/backend-min.css ADDED
@@ -0,0 +1 @@
 
1
+ .wp-picker-holder{position:absolute;bottom:2.5em;left:-1em;z-index:1;-webkit-box-shadow:3px 3px 5px #ddd;-moz-box-shadow:3px 3px 5px #ddd;box-shadow:3px 3px 5px #ddd;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.defaultTextActive{color:#a1a1a1;font-style:italic}#fvp_activation_notification{border-color:#00adef!important;background-color:whiteSmoke!important}.fvp_hidden{display:none}.fvp_notice{-webkit-border-radius:3px;border-radius:3px;border-width:1px;border-style:solid;background-color:white;border-color:gray;margin:.5em 0;padding:.4em .6em .2em}.fvp_warning{-webkit-border-radius:3px;border-radius:3px;border-width:1px;border-style:solid;background-color:lightYellow;border-color:#e6db55;margin:.5em 0;padding:.4em .6em .2em}#featured_video_plus-box textarea{resize:none;width:100%;height:1.1em;line-height:1.1em;font-size:1em}
css/backend.css CHANGED
@@ -15,13 +15,24 @@
15
  }
16
 
17
  #fvp_activation_notification {
18
- border-color: #00adef;
19
- background-color: whiteSmoke;
20
  }
21
  .fvp_hidden {
22
  display: none;
23
  }
24
  .fvp_notice {
 
 
 
 
 
 
 
 
 
 
 
25
  -webkit-border-radius: 3px;
26
  border-radius: 3px;
27
  border-width: 1px;
@@ -30,4 +41,12 @@
30
  border-color: #E6DB55;
31
  margin: .5em 0;
32
  padding: .4em .6em .2em;
 
 
 
 
 
 
 
 
33
  }
15
  }
16
 
17
  #fvp_activation_notification {
18
+ border-color: #00adef !important;
19
+ background-color: whiteSmoke !important;
20
  }
21
  .fvp_hidden {
22
  display: none;
23
  }
24
  .fvp_notice {
25
+ -webkit-border-radius: 3px;
26
+ border-radius: 3px;
27
+ border-width: 1px;
28
+ border-style: solid;
29
+ background-color: white;
30
+ border-color: gray;
31
+ margin: .5em 0;
32
+ padding: .4em .6em .2em;
33
+ }
34
+
35
+ .fvp_warning {
36
  -webkit-border-radius: 3px;
37
  border-radius: 3px;
38
  border-width: 1px;
41
  border-color: #E6DB55;
42
  margin: .5em 0;
43
  padding: .4em .6em .2em;
44
+ }
45
+
46
+ #featured_video_plus-box textarea {
47
+ resize: none;
48
+ width: 100%;
49
+ height: 1.1em;
50
+ line-height: 1.1em;
51
+ font-size: 1em;
52
  }
featured-video-plus.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Featured Video Plus
4
  Plugin URI: https://github.com/ahoereth/featured-video-plus
5
  Description: Featured Videos just like Featured Images.
6
  Author: Alexander Höreth
7
- Version: 1.1
8
  Author URI: http://ahoereth.yrnxt.com
9
  License: GPL2
10
 
@@ -26,41 +26,61 @@ License: GPL2
26
 
27
  */
28
 
29
- require_once( plugin_dir_path(__FILE__) . 'php/general.php' );
30
- require_once( plugin_dir_path(__FILE__) . 'php/backend.php' );
31
- require_once( plugin_dir_path(__FILE__) . 'php/frontend.php' );
 
 
 
 
 
 
 
 
 
32
 
33
  // init general class, located in php/general.php
 
34
  $featured_video_plus = new featured_video_plus();
35
 
36
- // shortcode
37
- add_shortcode( 'featured-video-plus', array( &$featured_video_plus, 'shortcode' ) );
38
-
39
  // only on backend / administration interface
40
  if( is_admin() ) {
 
 
 
 
41
  // init backend class, located in php/backend.php
 
42
  $featured_video_plus_backend = new featured_video_plus_backend($featured_video_plus);
43
 
 
44
  add_action('admin_menu', array( &$featured_video_plus_backend, 'metabox_register' ) );
45
  add_action('save_post', array( &$featured_video_plus_backend, 'metabox_save' ) );
46
 
 
47
  add_action('admin_init', array( &$featured_video_plus_backend, 'settings_init' ) );
48
 
49
- // enqueue scripts and styles
50
- add_action( 'admin_enqueue_scripts', array( &$featured_video_plus_backend, 'enqueue' ) );
 
 
 
 
51
 
52
- add_action('admin_notices', array( &$featured_video_plus_backend, 'activation_notification' ) );
53
- add_action('admin_init', array( &$featured_video_plus_backend, 'ignore_activation_notification' ) );
54
  }
55
 
56
 
57
  // only on frontend / page
58
  if( !is_admin() ) {
59
  // init frontend class, located in php/frontend.php
 
60
  $featured_video_plus_frontend = new featured_video_plus_frontend($featured_video_plus);
61
 
62
  // enqueue scripts and styles
63
  add_action( 'wp_enqueue_scripts', array( &$featured_video_plus_frontend, 'enqueue' ) );
 
64
 
65
  // filter get_post_thumbnail output
66
  add_filter('post_thumbnail_html', array( &$featured_video_plus_frontend, 'filter_post_thumbnail'), 99, 5);
@@ -85,9 +105,7 @@ if( !is_admin() ) {
85
  }
86
  }
87
 
88
-
89
- include_once( dirname( __FILE__ ) . '/php/setup.php' );
90
- register_activation_hook( WP_PLUGIN_DIR . '/featured-video-plus/featured-video-plus.php', array( 'featured_video_plus_setup', 'on_activate' ) );
91
- register_uninstall_hook( WP_PLUGIN_DIR . '/featured-video-plus/featured-video-plus.php', array( 'featured_video_plus_setup', 'on_uninstall' ) );
92
 
93
  ?>
4
  Plugin URI: https://github.com/ahoereth/featured-video-plus
5
  Description: Featured Videos just like Featured Images.
6
  Author: Alexander Höreth
7
+ Version: 1.2
8
  Author URI: http://ahoereth.yrnxt.com
9
  License: GPL2
10
 
26
 
27
  */
28
 
29
+ if (!defined('FVP_VERSION'))
30
+ define('FVP_VERSION', '1.2');
31
+
32
+ if (!defined('FVP_NAME'))
33
+ define('FVP_NAME', 'featured-video-plus');
34
+ //define('FVP_NAME', trim(dirname(plugin_basename(__FILE__)), '/'));
35
+
36
+ if (!defined('FVP_DIR'))
37
+ define('FVP_DIR', plugin_dir_path(__FILE__));
38
+
39
+ if (!defined('FVP_URL'))
40
+ define('FVP_URL', WP_PLUGIN_URL . '/' . FVP_NAME);
41
 
42
  // init general class, located in php/general.php
43
+ include_once( FVP_DIR . 'php/general.php' );
44
  $featured_video_plus = new featured_video_plus();
45
 
 
 
 
46
  // only on backend / administration interface
47
  if( is_admin() ) {
48
+ // plugin upgrade/setup
49
+ include_once( FVP_DIR . '/php/upgrade.php' );
50
+ add_action( 'admin_init', 'featured_video_plus_upgrade' );
51
+
52
  // init backend class, located in php/backend.php
53
+ include_once( FVP_DIR . 'php/backend.php' );
54
  $featured_video_plus_backend = new featured_video_plus_backend($featured_video_plus);
55
 
56
+ // admin meta box
57
  add_action('admin_menu', array( &$featured_video_plus_backend, 'metabox_register' ) );
58
  add_action('save_post', array( &$featured_video_plus_backend, 'metabox_save' ) );
59
 
60
+ // admin settings
61
  add_action('admin_init', array( &$featured_video_plus_backend, 'settings_init' ) );
62
 
63
+ // enqueue admin scripts and styles
64
+ add_action('admin_enqueue_scripts', array( &$featured_video_plus_backend, 'enqueue' ) );
65
+ add_action('admin_enqueue_scripts', array( &$featured_video_plus, 'enqueue' ) );
66
+
67
+ // link to media settings on plugins overview
68
+ add_filter('plugin_action_links', array( &$featured_video_plus_backend, 'plugin_action_link' ), 10, 2);
69
 
70
+ // add upload mime types for HTML5 videos
71
+ add_filter('upload_mimes', array( &$featured_video_plus_backend, 'add_upload_mimes' ) );
72
  }
73
 
74
 
75
  // only on frontend / page
76
  if( !is_admin() ) {
77
  // init frontend class, located in php/frontend.php
78
+ include_once( FVP_DIR . 'php/frontend.php' );
79
  $featured_video_plus_frontend = new featured_video_plus_frontend($featured_video_plus);
80
 
81
  // enqueue scripts and styles
82
  add_action( 'wp_enqueue_scripts', array( &$featured_video_plus_frontend, 'enqueue' ) );
83
+ add_action( 'wp_enqueue_scripts', array( &$featured_video_plus, 'enqueue' ) );
84
 
85
  // filter get_post_thumbnail output
86
  add_filter('post_thumbnail_html', array( &$featured_video_plus_frontend, 'filter_post_thumbnail'), 99, 5);
105
  }
106
  }
107
 
108
+ // shortcode
109
+ add_shortcode( 'featured-video-plus', array( &$featured_video_plus, 'shortcode' ) );
 
 
110
 
111
  ?>
js/backend-min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(d){d(".fvp_input").focus(function(){if(d(this).val()==d(this)[0].title){d(this).removeClass("defaultTextActive");d(this).val("")}});d(".fvp_input").blur(function(){if((d(this).val().length===0)||(d(this).val()==d(this)[0].title)){d(this).addClass("defaultTextActive");d(this).val(d(this)[0].title)}});d(".fvp_input").autosize().blur().keypress(function(f){if(f.keyCode==13){f.preventDefault()}});d(".fvp_input").click(function(){d(this).select()});var c=d("#fvp_video").val();if(c.length===0||c==fvp_backend_data.default_value||!c.match(fvp_backend_data.wp_upload_dir.replace(/\//g,"\\/"))){d("#fvp_sec").val(fvp_backend_data.default_value_sec).hide()}d("#fvp_video").bind("change paste keyup",function(){setTimeout(e(d(this)),200)});function e(i){var h=i.val();var g=d("#fvp_sec").val();if(h.length===0||h==fvp_backend_data.default_value){d("#fvp_video").css("backgroundColor","white");d("#fvp_sec").val(fvp_backend_data.default_value_sec).blur().hide("fast");d("#fvp_localvideo_notice").show("fast");d("#fvp_localvideo_format_warning").hide("fast")}if(h.match(fvp_backend_data.wp_upload_dir.replace(/\//g,"\\/"))){var j=/^.*\/(.*)\.(.*)$/g;var f=j.exec(d.trim(h));if(f[2]=="webm"||f[2]=="mp4"||f[2]=="ogg"||f[2]=="ogv"){d("#fvp_sec").show("fast");d("#fvp_video").css("backgroundColor","white");d("#fvp_localvideo_format_warning").hide("fast")}else{d("#fvp_sec").val(fvp_backend_data.default_value_sec).blur().hide("fast");d("#fvp_video").css("backgroundColor","lightYellow");d("#fvp_localvideo_format_warning").show("fast")}b()}else{d("#fvp_sec").hide("fast");d("#fvp_video").css("backgroundColor","white");d("#fvp_localvideo_format_warning").hide("fast")}}d("#fvp_sec").bind("change paste keyup",function(){setTimeout(a(d(this)),200)});function a(i){var h=i.val();var f=d("#fvp_video").val();if(h.length===0||h==fvp_backend_data.default_value){d("#fvp_localvideo_format_warning").hide("fast");d("#fvp_sec").css("backgroundColor","white");d("#fvp_localvideo_notice").hide("show")}if(h.match(fvp_backend_data.wp_upload_dir.replace(/\//g,"\\/"))){var j=/^.*\/(.*)\.(.*)$/g;var g=j.exec(d.trim(h));if(g[2]=="webm"||g[2]=="mp4"||g[2]=="ogg"||g[2]=="ogv"){b();d("#fvp_sec").css("backgroundColor","white");d("#fvp_localvideo_format_warning").hide("fast");d("#fvp_localvideo_notice").hide("fast")}else{b();d("#fvp_sec").css("backgroundColor","lightYellow");d("#fvp_localvideo_format_warning").show("fast")}}else{if(h.length!==0){d("#fvp_sec").css("backgroundColor","lightYellow");d("#fvp_localvideo_notdistinct_warning").show("fast")}}}function b(){if(d("#fvp_video").val()==d("#fvp_sec").val()){d("#fvp_sec").css("backgroundColor","lightYellow");d("#fvp_localvideo_notdistinct_warning").show("fast")}else{d("#fvp_localvideo_notdistinct_warning").hide("fast");d("#fvp_sec").css("backgroundColor","white")}}d("#fvp_set_featimg_link").show();d("#fvp_set_featimg_input").hide();d("#fvp_set_featimg_link, #fvp_warning_set_featimg").click(function(){d("#fvp_set_featimg").attr("checked",true);d("#fvp_set_featimg").closest("form").submit();return false});d("#remove-post-thumbnail").click(function(){d("#fvp_featimg_box_warning").removeClass("fvp_hidden")});d("#set-post-thumbnail").click(function(){d("#fvp_featimg_box_warning").addClass("fvp_hidden")})});
js/backend.js CHANGED
@@ -1,25 +1,160 @@
1
  jQuery(document).ready(function($){
2
 
3
- // remove default value of input field on focus
4
- // since 1.0
5
- $("#fvp_video").focus(function(srcc) {
 
 
6
  if ($(this).val() == $(this)[0].title) {
7
  $(this).removeClass("defaultTextActive");
8
  $(this).val("");
9
  }
10
  });
11
 
12
- $("#fvp_video").blur(function() {
13
- if ($(this).val() == "") {
 
 
 
 
14
  $(this).addClass("defaultTextActive");
15
  $(this).val($(this)[0].title);
16
  }
17
  });
18
 
19
- $("#fvp_video").blur();
20
 
21
- // replace current featured video link & checkbox
22
- // since 1.1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  $("#fvp_set_featimg_link").show();
24
  $("#fvp_set_featimg_input").hide();
25
 
@@ -30,13 +165,11 @@ jQuery(document).ready(function($){
30
  });
31
 
32
  $("#remove-post-thumbnail").click(function() {
33
- $("#fvp_set_featimg_box").removeClass("fvp_hidden");
34
  $("#fvp_featimg_box_warning").removeClass("fvp_hidden");
35
  });
36
 
37
  $("#set-post-thumbnail").click(function() {
38
- $("#fvp_set_featimg_link").html('Replace current Featured Image');
39
  $("#fvp_featimg_box_warning").addClass("fvp_hidden");
40
  });
41
-
42
  });
1
  jQuery(document).ready(function($){
2
 
3
+ /**
4
+ * remove default value on focus
5
+ * @since 1.0
6
+ */
7
+ $(".fvp_input").focus(function() {
8
  if ($(this).val() == $(this)[0].title) {
9
  $(this).removeClass("defaultTextActive");
10
  $(this).val("");
11
  }
12
  });
13
 
14
+ /**
15
+ * add default value on blur if empty
16
+ * @since 1.0
17
+ */
18
+ $(".fvp_input").blur(function() {
19
+ if ( ($(this).val().length === 0) || ($(this).val() == $(this)[0].title) ) {
20
  $(this).addClass("defaultTextActive");
21
  $(this).val($(this)[0].title);
22
  }
23
  });
24
 
 
25
 
26
+ /**
27
+ * blur both input fields on page load, autosize them and prevent enter
28
+ * @see http://www.jacklmoore.com/autosize
29
+ * @since 1.0
30
+ */
31
+ $(".fvp_input").autosize().blur().keypress(function(event) {
32
+ if (event.keyCode == 13) { // enter
33
+ event.preventDefault();
34
+ }
35
+ });
36
+
37
+ /**
38
+ * select whole input field content on click
39
+ * @since 1.2
40
+ */
41
+ $(".fvp_input").click(function() {
42
+ $(this).select();
43
+ });
44
+
45
+ /**
46
+ * hide secondary input initially
47
+ * @since 1.2
48
+ */
49
+ var value = $("#fvp_video").val();
50
+ if ( value.length === 0 || value == fvp_backend_data.default_value || !value.match( fvp_backend_data.wp_upload_dir.replace(/\//g, "\\\/") ) )
51
+ $("#fvp_sec").val( fvp_backend_data.default_value_sec ).hide();
52
+
53
+ /**
54
+ * recognize change on the primary video input
55
+ * @since 1.2
56
+ */
57
+ $("#fvp_video").bind("change paste keyup", function() {
58
+ setTimeout(handleVideoInput($(this)), 200);
59
+ });
60
+
61
+ /**
62
+ * Called when a change on the primary video input occurred
63
+ * @since 1.2
64
+ */
65
+ function handleVideoInput( obj ) {
66
+ var value = obj.val();
67
+ var sec = $('#fvp_sec').val();
68
+
69
+
70
+ if ( value.length === 0 || value == fvp_backend_data.default_value ) {
71
+ $("#fvp_video").css('backgroundColor', 'white');
72
+ $("#fvp_sec").val( fvp_backend_data.default_value_sec ).blur().hide('fast');
73
+ $("#fvp_localvideo_notice").show('fast');
74
+ $("#fvp_localvideo_format_warning").hide('fast');
75
+ }
76
+
77
+ if ( value.match( fvp_backend_data.wp_upload_dir.replace(/\//g, "\\\/") ) ) {
78
+ var file_extension = /^.*\/(.*)\.(.*)$/g;
79
+ var match = file_extension.exec($.trim(value));
80
+ if ( match[2] == 'webm' || match[2] == 'mp4' || match[2] == 'ogg' || match[2] == 'ogv' ) {
81
+ $("#fvp_sec").show('fast');
82
+ $("#fvp_video").css('backgroundColor', 'white');
83
+ $("#fvp_localvideo_format_warning").hide('fast');
84
+ } else {
85
+ $("#fvp_sec").val( fvp_backend_data.default_value_sec ).blur().hide('fast');
86
+ $("#fvp_video").css('backgroundColor', 'lightYellow');
87
+ $("#fvp_localvideo_format_warning").show('fast');
88
+ }
89
+ distinctContent();
90
+ } else {
91
+ $("#fvp_sec").hide('fast');
92
+ $("#fvp_video").css('backgroundColor', 'white');
93
+ $("#fvp_localvideo_format_warning").hide('fast');
94
+ }
95
+ }
96
+
97
+ /**
98
+ * recognize change on the secondary video input
99
+ * @since 1.2
100
+ */
101
+ $("#fvp_sec").bind("change paste keyup", function() {
102
+ setTimeout(handleSecInput($(this)), 200);
103
+ });
104
+
105
+ /**
106
+ * Called when a change on the primary video input occurred
107
+ * @since 1.2
108
+ */
109
+ function handleSecInput( obj ) {
110
+ var value = obj.val();
111
+ var prim = $('#fvp_video').val();
112
+
113
+
114
+ if ( value.length === 0 || value == fvp_backend_data.default_value ) {
115
+ $("#fvp_localvideo_format_warning").hide('fast');
116
+ $("#fvp_sec").css('backgroundColor', 'white');
117
+ $("#fvp_localvideo_notice").hide('show');
118
+ }
119
+
120
+ if ( value.match( fvp_backend_data.wp_upload_dir.replace(/\//g, "\\\/") ) ) {
121
+ var file_extension = /^.*\/(.*)\.(.*)$/g;
122
+ var match = file_extension.exec($.trim(value));
123
+ if ( match[2] == 'webm' || match[2] == 'mp4' || match[2] == 'ogg' || match[2] == 'ogv' ) {
124
+ distinctContent();
125
+ $("#fvp_sec").css('backgroundColor', 'white');
126
+ $("#fvp_localvideo_format_warning").hide('fast');
127
+ $("#fvp_localvideo_notice").hide('fast');
128
+ } else {
129
+ distinctContent();
130
+ $("#fvp_sec").css('backgroundColor', 'lightYellow');
131
+ $("#fvp_localvideo_format_warning").show('fast');
132
+ }
133
+ } else if (value.length !== 0) {
134
+ $("#fvp_sec").css('backgroundColor', 'lightYellow');
135
+ $("#fvp_localvideo_notdistinct_warning").show('fast');
136
+ }
137
+
138
+ }
139
+
140
+ /**
141
+ * Compares the two input boxes if they contain the same URL
142
+ * @since 1.2
143
+ */
144
+ function distinctContent() {
145
+ if ( $('#fvp_video').val() == $('#fvp_sec').val() ) {
146
+ $("#fvp_sec").css('backgroundColor', 'lightYellow');
147
+ $("#fvp_localvideo_notdistinct_warning").show('fast');
148
+ } else {
149
+ $("#fvp_localvideo_notdistinct_warning").hide('fast');
150
+ $("#fvp_sec").css('backgroundColor', 'white');
151
+ }
152
+ }
153
+
154
+ /**
155
+ * set featured image link and featured image requirement warning
156
+ * @since 1.1
157
+ */
158
  $("#fvp_set_featimg_link").show();
159
  $("#fvp_set_featimg_input").hide();
160
 
165
  });
166
 
167
  $("#remove-post-thumbnail").click(function() {
168
+ //$("#fvp_set_featimg_box").removeClass("fvp_hidden");
169
  $("#fvp_featimg_box_warning").removeClass("fvp_hidden");
170
  });
171
 
172
  $("#set-post-thumbnail").click(function() {
 
173
  $("#fvp_featimg_box_warning").addClass("fvp_hidden");
174
  });
 
175
  });
js/jquery.autosize-min.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ // Autosize 1.15.2 - jQuery plugin for textareas
2
+ // (c) 2013 Jack Moore - jacklmoore.com
3
+ // license: www.opensource.org/licenses/mit-license.php
4
+ (function(a){var j,b={className:"autosizejs",append:"",callback:!1},c="hidden",d="border-box",e="lineHeight",f='<textarea tabindex="-1" style="position:absolute; top:-9999px; left:-9999px; right:auto; bottom:auto; border:0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden;"/>',g=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent"],h="oninput",i="onpropertychange",k=a(f).data("autosize",!0)[0];k.style.lineHeight="99px","99px"===a(k).css(e)&&g.push(e),k.style.lineHeight="",a.fn.autosize=function(e){return e=a.extend({},b,e||{}),k.parentNode!==document.body&&a(document.body).append(k),this.each(function(){function s(){j=b,k.className=e.className,a.each(g,function(a,b){k.style[b]=f.css(b)})}function t(){var a,d,g;j!==b&&s(),n||(n=!0,k.value=b.value+e.append,k.style.overflowY=b.style.overflowY,g=parseInt(b.style.height,10),k.style.width=f.width()+"px",k.scrollTop=0,k.scrollTop=9e4,a=k.scrollTop,a>m?(a=m,d="scroll"):l>a&&(a=l),a+=p,b.style.overflowY=d||c,g!==a&&(b.style.height=a+"px",r&&e.callback.call(b)),setTimeout(function(){n=!1},1))}var n,o,b=this,f=a(b),l=f.height(),m=parseInt(f.css("maxHeight"),10),p=0,q=b.value,r=a.isFunction(e.callback);f.data("autosize")||((f.css("box-sizing")===d||f.css("-moz-box-sizing")===d||f.css("-webkit-box-sizing")===d)&&(p=f.outerHeight()-f.height()),o="none"===f.css("resize")?"none":"horizontal",f.css({overflow:c,overflowY:c,wordWrap:"break-word",resize:o}).data("autosize",!0),m=m&&m>0?m:9e4,i in b?h in b?b[h]=b.onkeyup=t:b[i]=t:(b[h]=t,b.value="",b.value=q),a(window).resize(t),f.bind("autosize",t),t())})}})(window.jQuery||window.Zepto);
js/jquery.autosize.js ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Autosize 1.15.2 - jQuery plugin for textareas
2
+ // (c) 2013 Jack Moore - jacklmoore.com
3
+ // license: www.opensource.org/licenses/mit-license.php
4
+
5
+ (function ($) {
6
+ var
7
+ defaults = {
8
+ className: 'autosizejs',
9
+ append: "",
10
+ callback: false
11
+ },
12
+ hidden = 'hidden',
13
+ borderBox = 'border-box',
14
+ lineHeight = 'lineHeight',
15
+
16
+ // border:0 is unnecessary, but avoids a bug in FireFox on OSX (http://www.jacklmoore.com/autosize#comment-851)
17
+ copy = '<textarea tabindex="-1" style="position:absolute; top:-9999px; left:-9999px; right:auto; bottom:auto; border:0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden;"/>',
18
+
19
+ // line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
20
+ copyStyle = [
21
+ 'fontFamily',
22
+ 'fontSize',
23
+ 'fontWeight',
24
+ 'fontStyle',
25
+ 'letterSpacing',
26
+ 'textTransform',
27
+ 'wordSpacing',
28
+ 'textIndent'
29
+ ],
30
+ oninput = 'oninput',
31
+ onpropertychange = 'onpropertychange',
32
+
33
+ // to keep track which textarea is being mirrored when adjust() is called.
34
+ mirrored,
35
+
36
+ // the mirror element, which is used to calculate what size the mirrored element should be.
37
+ mirror = $(copy).data('autosize', true)[0];
38
+
39
+ // test that line-height can be accurately copied.
40
+ mirror.style.lineHeight = '99px';
41
+ if ($(mirror).css(lineHeight) === '99px') {
42
+ copyStyle.push(lineHeight);
43
+ }
44
+ mirror.style.lineHeight = '';
45
+
46
+ $.fn.autosize = function (options) {
47
+ options = $.extend({}, defaults, options || {});
48
+
49
+ if (mirror.parentNode !== document.body) {
50
+ $(document.body).append(mirror);
51
+ }
52
+
53
+ return this.each(function () {
54
+ var
55
+ ta = this,
56
+ $ta = $(ta),
57
+ minHeight = $ta.height(),
58
+ maxHeight = parseInt($ta.css('maxHeight'), 10),
59
+ active,
60
+ resize,
61
+ boxOffset = 0,
62
+ value = ta.value,
63
+ callback = $.isFunction(options.callback);
64
+
65
+ if ($ta.data('autosize')) {
66
+ // exit if autosize has already been applied, or if the textarea is the mirror element.
67
+ return;
68
+ }
69
+
70
+ if ($ta.css('box-sizing') === borderBox || $ta.css('-moz-box-sizing') === borderBox || $ta.css('-webkit-box-sizing') === borderBox){
71
+ boxOffset = $ta.outerHeight() - $ta.height();
72
+ }
73
+
74
+ resize = $ta.css('resize') === 'none' ? 'none' : 'horizontal';
75
+
76
+ $ta.css({
77
+ overflow: hidden,
78
+ overflowY: hidden,
79
+ wordWrap: 'break-word',
80
+ resize: resize
81
+ }).data('autosize', true);
82
+
83
+ // Opera returns '-1px' when max-height is set to 'none'.
84
+ maxHeight = maxHeight && maxHeight > 0 ? maxHeight : 9e4;
85
+
86
+ function initMirror() {
87
+ mirrored = ta;
88
+ mirror.className = options.className;
89
+
90
+ // mirror is a duplicate textarea located off-screen that
91
+ // is automatically updated to contain the same text as the
92
+ // original textarea. mirror always has a height of 0.
93
+ // This gives a cross-browser supported way getting the actual
94
+ // height of the text, through the scrollTop property.
95
+ $.each(copyStyle, function(i, val){
96
+ mirror.style[val] = $ta.css(val);
97
+ });
98
+ }
99
+
100
+ // Using mainly bare JS in this function because it is going
101
+ // to fire very often while typing, and needs to very efficient.
102
+ function adjust() {
103
+ var height, overflow, original;
104
+
105
+ if (mirrored !== ta) {
106
+ initMirror();
107
+ }
108
+
109
+ // the active flag keeps IE from tripping all over itself. Otherwise
110
+ // actions in the adjust function will cause IE to call adjust again.
111
+ if (!active) {
112
+ active = true;
113
+ mirror.value = ta.value + options.append;
114
+ mirror.style.overflowY = ta.style.overflowY;
115
+ original = parseInt(ta.style.height,10);
116
+
117
+ // Update the width in case the original textarea width has changed
118
+ mirror.style.width = $ta.width() + 'px';
119
+
120
+ // Needed for IE7 to reliably return the correct scrollHeight
121
+ mirror.scrollTop = 0;
122
+ // Set a very high value for scrollTop to be sure the
123
+ // mirror is scrolled all the way to the bottom.
124
+ mirror.scrollTop = 9e4;
125
+ height = mirror.scrollTop;
126
+ // Note to self: replace the previous 3 lines with 'height = mirror.scrollHeight' when dropping IE7 support.
127
+
128
+ if (height > maxHeight) {
129
+ height = maxHeight;
130
+ overflow = 'scroll';
131
+ } else if (height < minHeight) {
132
+ height = minHeight;
133
+ }
134
+ height += boxOffset;
135
+ ta.style.overflowY = overflow || hidden;
136
+
137
+ if (original !== height) {
138
+ ta.style.height = height + 'px';
139
+ if (callback) {
140
+ options.callback.call(ta);
141
+ }
142
+ }
143
+
144
+ // This small timeout gives IE a chance to draw it's scrollbar
145
+ // before adjust can be run again (prevents an infinite loop).
146
+ setTimeout(function () {
147
+ active = false;
148
+ }, 1);
149
+ }
150
+ }
151
+
152
+ if (onpropertychange in ta) {
153
+ if (oninput in ta) {
154
+ // Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
155
+ // so binding to onkeyup to catch most of those occassions. There is no way that I
156
+ // know of to detect something like 'cut' in IE9.
157
+ ta[oninput] = ta.onkeyup = adjust;
158
+ } else {
159
+ // IE7 / IE8
160
+ ta[onpropertychange] = adjust;
161
+ }
162
+ } else {
163
+ // Modern Browsers
164
+ ta[oninput] = adjust;
165
+
166
+ // The textarea overflow is now hidden, but Chrome doesn't reflow the text to account for the
167
+ // new space made available by removing the scrollbars. This workaround causes Chrome to reflow the text.
168
+ ta.value = '';
169
+ ta.value = value;
170
+ }
171
+
172
+ $(window).resize(adjust);
173
+
174
+ // Allow for manual triggering if needed.
175
+ $ta.bind('autosize', adjust);
176
+
177
+ // Call adjust in case the textarea already contains text.
178
+ adjust();
179
+ });
180
+ };
181
+ }(window.jQuery || window.Zepto));
js/jquery.fitvids_fvp-min.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * FitVids 1.0
3
+ *
4
+ * Copyright 2011, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com
5
+ * Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
6
+ * Released under the WTFPL license - http://sam.zoy.org/wtfpl/
7
+ *
8
+ * Date: Thu Sept 01 18:00:00 2011 -0500
9
+ */
10
+ (function(a){a.fn.fitVids=function(b){var c={customSelector:null};var e=document.createElement("div"),d=document.getElementsByTagName("base")[0]||document.getElementsByTagName("script")[0];e.className="fit-vids-style";e.innerHTML="&shy;<style> .fluid-width-video-wrapper { width: 100%; position: relative; padding: 0; } .fluid-width-video-wrapper iframe, .fluid-width-video-wrapper object, .fluid-width-video-wrapper embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } </style>";d.parentNode.insertBefore(e,d);if(b){a.extend(c,b)}return this.each(function(){var f=["iframe[src*='player.vimeo.com']","iframe[src*='www.youtube.com']","iframe[src*='www.youtube-nocookie.com']","iframe[src*='www.kickstarter.com']","object","embed"];if(c.customSelector){f.push(c.customSelector)}var g=a(this).find(f.join(","));g.each(function(){var l=a(this);if(this.tagName.toLowerCase()==="embed"&&l.parent("object").length||l.parent(".fluid-width-video-wrapper").length){return}var h=(this.tagName.toLowerCase()==="object"||(l.attr("height")&&!isNaN(parseInt(l.attr("height"),10))))?parseInt(l.attr("height"),10):l.height(),i=!isNaN(parseInt(l.attr("width"),10))?parseInt(l.attr("width"),10):l.width(),j=h/i;if(!l.attr("id")){var k="fitvid"+Math.floor(Math.random()*999999);l.attr("id",k)}l.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",(j*100)+"%");l.removeAttr("height").removeAttr("width")})})}})(jQuery);jQuery(document).ready(function(a){a(".featured_video_plus").fitVids()});
php/backend.php CHANGED
@@ -3,7 +3,7 @@
3
  * Class containing functions required WordPress administration panels. Metabox on post/page edit views and options section under settings->media.
4
  *
5
  * @author ahoereth
6
- * @version 2012/12/07
7
  * @see ../featured_video_plus.php
8
  * @see featured_video_plus in general.php
9
  * @since 1.0
@@ -13,6 +13,7 @@
13
  class featured_video_plus_backend {
14
  private $featured_video_plus;
15
  private $default_value;
 
16
 
17
  /**
18
  * Creates a new instace of this class, saves the featured_video_instance and default value for the meta box input.
@@ -22,11 +23,12 @@ class featured_video_plus_backend {
22
  * @param featured_video_plus_instance required, dies without
23
  */
24
  function __construct( $featured_video_plus_instance ){
25
- if ( !isset($featured_video_plus_instance) )
26
- wp_die( 'featured_video_plus general instance required!', 'Error!' );
27
 
28
- $this->featured_video_plus = $featured_video_plus_instance;
29
- $default_value = 'paste your YouTube or Vimeo URL here';
 
30
  }
31
 
32
  /**
@@ -35,6 +37,7 @@ class featured_video_plus_backend {
35
  * @see http://codex.wordpress.org/Function_Reference/wp_style_is
36
  * @see http://make.wordpress.org/core/2012/11/30/new-color-picker-in-wp-3-5/
37
  * @see http://ottopress.com/2010/passing-parameters-from-php-to-javascripts-in-plugins/
 
38
  * @since 1.0
39
  */
40
  public function enqueue($hook_suffix) {
@@ -43,26 +46,31 @@ class featured_video_plus_backend {
43
  if( wp_style_is( 'wp-color-picker', 'registered' ) ) {
44
  // >=WP3.5
45
  wp_enqueue_style( 'wp-color-picker' );
46
- wp_enqueue_script( 'fvp_backend_35', plugins_url() . '/featured-video-plus/js/backend_35.js', array( 'wp-color-picker', 'jquery' ) );
47
  } else {
48
  // <WP3.5, fallback for the new WordPress Color Picker which was added in 3.5
49
  wp_enqueue_style( 'farbtastic' );
50
  wp_enqueue_script( 'farbtastic' );
51
- wp_enqueue_script( 'fvp_backend_pre35', plugins_url() . '/featured-video-plus/js/backend_pre35.js', array( 'jquery' ) );
52
  }
53
  }
54
 
55
  // just required on post.php
56
  if($hook_suffix == 'post.php' && isset($_GET['post']) ) {
57
- wp_enqueue_script( 'fvp_backend', plugins_url() . '/featured-video-plus/js/backend.js', array( 'jquery' ) );
58
-
59
- // just required if width is set to auto
60
- $options = get_option( 'fvp-settings' );
61
- if($options['width'] == 'auto')
62
- wp_enqueue_script('fvp_fitvids', plugins_url(). '/featured-video-plus/js/jquery.fitvids_fvp.js', array( 'jquery' ), '20121207', true );
 
 
 
 
63
  }
64
 
65
- wp_enqueue_style( 'fvp_backend', plugins_url() . '/featured-video-plus/css/backend.css' );
 
66
  }
67
 
68
  /**
@@ -84,7 +92,7 @@ class featured_video_plus_backend {
84
  * @since 1.0
85
  */
86
  function metabox_content() {
87
- wp_nonce_field( plugin_basename( __FILE__ ), 'fvp_nonce');
88
 
89
  if( isset($_GET['post']) )
90
  $post_id = $_GET['post'];
@@ -100,22 +108,50 @@ class featured_video_plus_backend {
100
 
101
  $meta = unserialize( get_post_meta($post_id, '_fvp_video', true) );
102
 
 
103
  // displays the current featured video
104
  if( $has_post_video )
105
- echo "\n" . '<div id="featured_video_preview" class="featured_video_plus" style="display:block">' . $this->featured_video_plus->get_the_post_video( $post_id, array(256,144) ) . '</div>' . "\n";
106
 
107
  // input box containing the featured video URL
108
- echo "\n" . '<input id="fvp_video" name="fvp_video" type="text" value="' . $meta['full'] . '" style="width: 100%" title="' . $this->default_value . '" />' . "\n";
109
-
110
- // link/input to set as featured image
111
- $class = !$has_post_video || ($has_featimg && $featimg_is_fvp) ? ' class="fvp_hidden"' : '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  $text = 'Set as Featured Image';
113
- echo '<p id="fvp_set_featimg_box"'.$class.'><span id="fvp_set_featimg_input"><input id="fvp_set_featimg" name="fvp_set_featimg" type="checkbox" value="set_featimg" /><label for="fvp_set_featimg">&nbsp;'.$text.'</label></span>';
114
- echo '<a style="display: none;" id="fvp_set_featimg_link" href="#">'.$text.'</a></p>';
115
-
116
- $class = $has_featimg ? ' fvp_hidden' : '';
117
- echo '<div id="fvp_featimg_box_warning" class="fvp_notice'.$class.'"><p class="description">In many themes to automatically display the Featured Video a Featured Image is required!</p></div>';
118
 
 
119
  }
120
 
121
  /**
@@ -131,7 +167,7 @@ class featured_video_plus_backend {
131
  ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || // AJAX? Not used here
132
  ( !current_user_can( 'edit_post', $post_id ) ) || // Check user permissions
133
  ( false !== wp_is_post_revision( $post_id ) ) || // Return if it's a post revision
134
- ( ( isset($_POST['fvp_nonce']) && !wp_verify_nonce( $_POST['fvp_nonce'], plugin_basename( __FILE__ ) ) ) &&
135
  !is_string($set_featimg) )
136
  ) return;
137
 
@@ -148,6 +184,8 @@ class featured_video_plus_backend {
148
  $video = trim($_POST['fvp_video']);
149
  }
150
 
 
 
151
  // something changed
152
  if( ( empty($video) ) || // no video or
153
  ( isset($meta) && ($video != $meta['full'])) ) // different video?
@@ -178,9 +216,13 @@ class featured_video_plus_backend {
178
  if( empty($video) )
179
  return;
180
 
181
- if( ($video == $meta['full']) && !$set_featimg )
 
 
182
  return;
183
 
 
 
184
  /*
185
  REGEX tested using: http://www.rubular.com/
186
 
@@ -198,19 +240,32 @@ http://www.youtube.com/watch?feature=blub&v=G_Oj7UI0-pw
198
 
199
  $local = wp_upload_dir();
200
  // match different provider(!)
201
- preg_match('/(vimeo|youtu|dailymotion)/i', $video, $video_provider);
 
202
  if(!isset($video_provider[1]))
203
  return;
204
 
205
  $video_prov = $video_provider[1] == "youtu" ? "youtube" : $video_provider[1];
206
 
207
  switch ($video_prov) {
208
- /*case $local['baseurl'];
209
- $video_id = $this->get_post_by_url($video);
210
- $video_prov = 'local';
211
- //'.preg_quote($local['baseurl'], '/').'
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  break;
213
- */
214
 
215
  case 'youtube':
216
  //match provider watch feature id(!) attr(!)
@@ -290,6 +345,9 @@ http://www.youtube.com/watch?feature=blub&v=G_Oj7UI0-pw
290
  break;
291
  }
292
 
 
 
 
293
  // do we have a screen capture to pull?
294
  if( !empty($video_info['img']) ) {
295
 
@@ -305,7 +363,7 @@ http://www.youtube.com/watch?feature=blub&v=G_Oj7UI0-pw
305
  );
306
 
307
  // pull external img to local server and add to media library
308
- require_once( plugin_dir_path(__FILE__) . 'somatic_attach_external_image.php' );
309
  $video_img = somatic_attach_external_image($video_info['img'], $post_id, false, $video_info['filename'], $video_img_data);
310
 
311
  // generate picture metadata
@@ -338,11 +396,14 @@ http://www.youtube.com/watch?feature=blub&v=G_Oj7UI0-pw
338
  $meta = array(
339
  'full' => ( isset($data['url']) && !empty($data['url']) ) ? $data['url'] : $video,
340
  'id' => $video_id,
341
- 'img' => $video_img,
 
 
342
  'prov' => $video_prov,
343
  'attr' => isset($video_attr) ? $video_attr : '',
344
  'warn_featimg' => true
345
  );
 
346
  update_post_meta( $post_id, '_fvp_video', serialize($meta) );
347
 
348
  return;
@@ -355,13 +416,13 @@ http://www.youtube.com/watch?feature=blub&v=G_Oj7UI0-pw
355
  * @since 1.0
356
  */
357
  function settings_init() {
358
- add_settings_section('fvp-settings-section', 'Featured Video', array( &$this, 'settings_content' ), 'media');
359
 
360
- add_settings_field('fvp-settings-overwrite', 'Replace featured images', array( &$this, 'settings_overwrite' ), 'media', 'fvp-settings-section');
361
- add_settings_field('fvp-settings-width', 'Video width', array( &$this, 'settings_width' ), 'media', 'fvp-settings-section');
362
- add_settings_field('fvp-settings-height', 'Video height', array( &$this, 'settings_height' ), 'media', 'fvp-settings-section');
363
- add_settings_field('fvp-settings-vimeo', 'Vimeo Player Design', array( &$this, 'settings_vimeo' ), 'media', 'fvp-settings-section');
364
- add_settings_field('fvp-settings-rate', 'Support', array( &$this, 'settings_rate' ), 'media', 'fvp-settings-section');
365
 
366
  register_setting('media', 'fvp-settings', array( &$this, 'settings_save' ));
367
  }
@@ -412,10 +473,12 @@ http://www.youtube.com/watch?feature=blub&v=G_Oj7UI0-pw
412
  * @since 1.0
413
  */
414
  function settings_overwrite() {
415
- $options = get_option( 'fvp-settings' ); ?>
 
 
416
 
417
- <input type="radio" name="fvp-settings[overwrite]" id="fvp-settings-overwrite-1" value="true" <?php checked( true, $options['overwrite'], true ) ?>/><label for="fvp-settings-overwrite-1">&nbsp;yes&nbsp;<span style="font-style: italic;">(default)</span></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
418
- <input type="radio" name="fvp-settings[overwrite]" id="fvp-settings-overwrite-2" value="false" <?php checked( false, $options['overwrite'], true ) ?>/><label for="fvp-settings-overwrite-2">&nbsp;no</label>
419
  <p class="description">If a featured video is available, it can be displayed in place of the featured image.<br />For some themes this could result in displaying errors. When using this, try different <code>width</code> and <code>height</code> settings.</p>
420
 
421
  <?php }
@@ -426,10 +489,11 @@ http://www.youtube.com/watch?feature=blub&v=G_Oj7UI0-pw
426
  * @since 1.0
427
  */
428
  function settings_width() {
429
- $options = get_option( 'fvp-settings' ); ?>
 
430
 
431
- <input type="radio" name="fvp-settings[width]" id="fvp-settings-width-1" value="auto" <?php checked( 'auto', $options['width'], true ) ?>/><label for="fvp-settings-width-1">&nbsp;auto&nbsp;<span style="font-style: italic;">(default)</span></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
432
- <input type="radio" name="fvp-settings[width]" id="fvp-settings-width-2" value="fixed" <?php checked( 'fixed', $options['width'], true ) ?>/><label for="fvp-settings-width-2">&nbsp;fixed</label>
433
  <p class="description">Using <code>auto</code> the video's width will be adjusted to fit the parent element. Works best in combination with height setted to <code>auto</code> as well.</p>
434
 
435
  <?php }
@@ -440,10 +504,11 @@ http://www.youtube.com/watch?feature=blub&v=G_Oj7UI0-pw
440
  * @since 1.0
441
  */
442
  function settings_height() {
443
- $options = get_option( 'fvp-settings' ); ?>
 
444
 
445
- <input type="radio" name="fvp-settings[height]" id="fvp-settings-height-1" value="auto" <?php checked( 'auto', $options['height'], true ) ?>/><label for="fvp-settings-height-1">&nbsp;auto&nbsp;<span style="font-style: italic;">(default)</span></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
446
- <input type="radio" name="fvp-settings[height]" id="fvp-settings-height-2" value="fixed" <?php checked( 'fixed', $options['height'], true ) ?>/><label for="fvp-settings-height-2">&nbsp;fixed</label>
447
  <p class="description">If using <code>fixed</code> videos may lose their ascpect radio, resulting in <span style="font-style: italic;">not so pretty</span> black bars.</p>
448
 
449
  <?php }
@@ -457,21 +522,26 @@ http://www.youtube.com/watch?feature=blub&v=G_Oj7UI0-pw
457
  * @since 1.0
458
  */
459
  function settings_vimeo() {
460
- $options = get_option( 'fvp-settings' ); ?>
 
 
 
 
461
 
462
  <div style="position: relative; bottom: .6em;">
463
- <input type="checkbox" name="fvp-settings[vimeo][portrait]" id="fvp-settings-vimeo-1" value="display" <?php checked( 1, $options['vimeo']['portrait'], 1 ) ?>/><label for="fvp-settings-vimeo-1">&nbsp;Portrait</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
464
- <input type="checkbox" name="fvp-settings[vimeo][title]" id="fvp-settings-vimeo-2" value="display" <?php checked( 1, $options['vimeo']['title'], 1 ) ?>/><label for="fvp-settings-vimeo-2">&nbsp;Title</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
465
- <input type="checkbox" name="fvp-settings[vimeo][byline]" id="fvp-settings-vimeo-3" value="display" <?php checked( 1, $options['vimeo']['byline'], 1 ) ?>/><label for="fvp-settings-vimeo-3">&nbsp;Byline</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
466
  <span class="color-picker" style="position: relative;<?php if( wp_style_is( 'wp-color-picker', 'done' ) ) echo ' top: .6em;'; ?>" >
467
- <input type="text" name="fvp-settings[vimeo][color]" id="fvp-settings-vimeo-color" value="#<?php echo isset($options['vimeo']['color']) ? $options['vimeo']['color'] : '00adef'; ?>" data-default-color="#00adef" />
468
  <label for="fvp-settings-vimeo-color" style="display: none;">&nbsp;Color</label>
469
  <?php if( !wp_style_is('wp-color-picker', 'registered' ) ) { ?><div style="position: absolute; bottom: 0; right: -197px; background-color: #fff; z-index: 100; border: 1px solid #ccc;" id="fvp-settings-vimeo-colorpicker"></div><?php } ?>
470
  </span>
471
  </div>
472
  <p class="description">These settings could be overwritten by videos from Vimeo Plus members.</p>
473
 
474
- <?php }
 
475
 
476
  /**
477
  * Displays info about rating the plugin, giving feedback and requesting new features
@@ -493,57 +563,49 @@ http://www.youtube.com/watch?feature=blub&v=G_Oj7UI0-pw
493
  * @since 1.0
494
  */
495
  function settings_save($input) {
496
- $input['overwrite'] = $input['overwrite'] == 'true' ? true : false;
 
 
497
 
498
- $input['vimeo']['portrait'] = isset($input['vimeo']['portrait'])&& ( $input['vimeo']['portrait'] == 'display' ) ? 1 : 0;
499
- $input['vimeo']['title'] = isset($input['vimeo']['title']) && ( $input['vimeo']['title'] == 'display' ) ? 1 : 0;
500
- $input['vimeo']['byline'] = isset($input['vimeo']['byline']) && ( $input['vimeo']['byline'] == 'display' ) ? 1 : 0;
501
 
502
- if( isset($input['vimeo']['color']) ) {
503
  preg_match('/#?([0123456789abcdef]{3}[0123456789abcdef]{0,3})/i', $input['vimeo']['color'], $color);
504
- $input['vimeo']['color'] = $color[1];
505
  } else
506
- $input['vimeo']['color'] = '00adef';
507
 
508
- return $input;
 
509
  }
510
 
511
  /**
512
- * Notification shown when plugin is newly activated. Automatically hidden after 5x displayed.
513
  *
514
- * @see http://wptheming.com/2011/08/admin-notices-in-wordpress/
515
- * @since 1.0
516
  */
517
- public function activation_notification() {
518
- if ( current_user_can( 'manage_options' ) ) {
519
- global $current_user;
520
-
521
- $count = get_user_meta($current_user->ID, 'fvp_activation_notification_ignore', true);
522
- if( empty($count) || ($count <= 5) ) {
523
- $part = empty($count) ? 'There is a new box on post & page edit screens for you to add video URLs.' : '';
524
- echo "\n" . '<div class="updated" id="fvp_activation_notification"><p>';
525
- printf(__('Featured Video Plus is ready to use. %1$s<span style="font-weight: bold;">Take a look at your new <a href="%2$s" title="Media Settings">Media Settings</a></span> | <a href="%3$s">hide this notice</a>'), $part . '&nbsp;', get_admin_url(null, '/options-media.php?fvp_activation_notification_ignore=0'), '?fvp_activation_notification_ignore=0');
526
- echo "</p></div>\n";
527
-
528
- $count = empty($count) ? 1 : $count+1;
529
- update_user_meta($current_user->ID, 'fvp_activation_notification_ignore', $count);
530
- }
531
- }
532
  }
533
 
534
  /**
535
- * Function fired when notification should be hidden manually. Hides it for the current user forever.
536
  *
537
- * @see http://wptheming.com/2011/08/admin-notices-in-wordpress/
538
- * @see function activation_notification
539
- * @since 1.0
540
  */
541
- public function ignore_activation_notification() {
542
- global $current_user;
 
 
 
543
 
544
- // If user clicks to ignore the notice, add that to their user meta
545
- if ( isset($_GET['fvp_activation_notification_ignore']) && '0' == $_GET['fvp_activation_notification_ignore'] )
546
- update_user_meta($current_user->ID, 'fvp_activation_notification_ignore', 999);
547
  }
548
 
549
  /**
@@ -569,9 +631,7 @@ http://www.youtube.com/watch?feature=blub&v=G_Oj7UI0-pw
569
  $meta_key, $meta_value
570
  );
571
 
572
- $id = $wpdb->get_var( $prepared );
573
- //echo $ids;
574
- return $id;
575
  }
576
 
577
  /**
@@ -592,6 +652,5 @@ http://www.youtube.com/watch?feature=blub&v=G_Oj7UI0-pw
592
  );
593
  return $id;
594
  }
595
-
596
  }
597
  ?>
3
  * Class containing functions required WordPress administration panels. Metabox on post/page edit views and options section under settings->media.
4
  *
5
  * @author ahoereth
6
+ * @version 2013/01/09
7
  * @see ../featured_video_plus.php
8
  * @see featured_video_plus in general.php
9
  * @since 1.0
13
  class featured_video_plus_backend {
14
  private $featured_video_plus;
15
  private $default_value;
16
+ private $default_value_sec;
17
 
18
  /**
19
  * Creates a new instace of this class, saves the featured_video_instance and default value for the meta box input.
23
  * @param featured_video_plus_instance required, dies without
24
  */
25
  function __construct( $featured_video_plus_instance ){
26
+ if ( !isset($featured_video_plus_instance) )
27
+ wp_die( 'featured_video_plus general instance required!', 'Error!' );
28
 
29
+ $this->featured_video_plus = $featured_video_plus_instance;
30
+ $this->default_value = 'YouTube, Vimeo, Dailymotion; Local Media';
31
+ $this->default_value_sec = 'Fallback: same video, different format';
32
  }
33
 
34
  /**
37
  * @see http://codex.wordpress.org/Function_Reference/wp_style_is
38
  * @see http://make.wordpress.org/core/2012/11/30/new-color-picker-in-wp-3-5/
39
  * @see http://ottopress.com/2010/passing-parameters-from-php-to-javascripts-in-plugins/
40
+ * @see http://codex.wordpress.org/Function_Reference/wp_localize_script
41
  * @since 1.0
42
  */
43
  public function enqueue($hook_suffix) {
46
  if( wp_style_is( 'wp-color-picker', 'registered' ) ) {
47
  // >=WP3.5
48
  wp_enqueue_style( 'wp-color-picker' );
49
+ wp_enqueue_script( 'fvp_backend_35', FVP_URL . '/js/backend_35.js', array( 'wp-color-picker', 'jquery' ) );
50
  } else {
51
  // <WP3.5, fallback for the new WordPress Color Picker which was added in 3.5
52
  wp_enqueue_style( 'farbtastic' );
53
  wp_enqueue_script( 'farbtastic' );
54
+ wp_enqueue_script( 'fvp_backend_pre35', FVP_URL . '/js/backend_pre35.js', array( 'jquery' ) );
55
  }
56
  }
57
 
58
  // just required on post.php
59
  if($hook_suffix == 'post.php' && isset($_GET['post']) ) {
60
+ wp_enqueue_script( 'jquery.autosize', FVP_URL . '/js/jquery.autosize-min.js', array( 'jquery' ) );
61
+ wp_enqueue_script( 'fvp_backend', FVP_URL . '/js/backend-min.js', array( 'jquery','jquery.autosize' ) ); // production
62
+ //wp_enqueue_script( 'fvp_backend', FVP_URL . '/js/backend.js', array( 'jquery','jquery.autosize' ) ); // development
63
+
64
+ $upload_dir = wp_upload_dir();
65
+ wp_localize_script( 'fvp_backend', 'fvp_backend_data', array(
66
+ 'wp_upload_dir' => $upload_dir['baseurl'],
67
+ 'default_value' => $this->default_value,
68
+ 'default_value_sec' => $this->default_value_sec
69
+ ) );
70
  }
71
 
72
+ wp_enqueue_style( 'fvp_backend', FVP_URL . '/css/backend-min.css' ); // production
73
+ //wp_enqueue_style( 'fvp_backend', FVP_URL . '/css/backend.css' ); // development
74
  }
75
 
76
  /**
92
  * @since 1.0
93
  */
94
  function metabox_content() {
95
+ wp_nonce_field( FVP_NAME, 'fvp_nonce');
96
 
97
  if( isset($_GET['post']) )
98
  $post_id = $_GET['post'];
108
 
109
  $meta = unserialize( get_post_meta($post_id, '_fvp_video', true) );
110
 
111
+ echo "\n\n\n<!-- Featured Video Plus Metabox -->\n";
112
  // displays the current featured video
113
  if( $has_post_video )
114
+ echo '<div id="featured_video_preview" class="featured_video_plus" style="display:block">' . $this->featured_video_plus->get_the_post_video( $post_id, array(256,144) ) . "</div>\n";
115
 
116
  // input box containing the featured video URL
117
+ $full = isset($meta['full']) ? $meta['full'] : $this->default_value;
118
+ echo '<textarea class="fvp_input" id="fvp_video" name="fvp_video" type="text" title="' . $this->default_value . '" />' . $full . '</textarea>' . "\n";
119
+
120
+ $sec = isset($meta['sec']) ? $meta['sec'] : $this->default_value_sec;
121
+ echo '<textarea class="fvp_input" id="fvp_sec" name="fvp_sec" type="text" title="' . $this->default_value_sec . '" />' . $sec . '</textarea>' . "\n";
122
+
123
+ // local video format warning
124
+ echo '<div id="fvp_localvideo_format_warning" class="fvp_warning fvp_hidden">'."\n\t".'<p class="description">'."\n\t\t";
125
+ echo '<span style="font-weight: bold;">Supported Video Formats:</span> <code>mp4</code>, <code>webM</code> or <code>ogg/ogv</code>. <a href="http://wordpress.org/extend/plugins/featured-video-plus/faq/">More information</a>.';
126
+ echo "\n\t</p>\n</div>\n";
127
+
128
+ // local videos not distinct warning
129
+ echo '<div id="fvp_localvideo_notdistinct_warning" class="fvp_warning fvp_hidden">'."\n\t".'<p class="description">'."\n\t\t";
130
+ echo '<span style="font-weight: bold;">Fallback Video:</span> The two input fields should contain the same video but in distinct formats.';
131
+ echo "\n\t</p>\n</div>\n";
132
+
133
+ // how to use a local video notice
134
+ $class = (isset($meta['prov']) && $meta['prov'] != 'local') || (isset($meta['sec']) && !empty($meta['sec'])) ? ' fvp_hidden' : '' ;
135
+ $mediahref = (get_bloginfo('version') >= 3.5) ? '<a href="#" class="insert-media" title="Add Media">' : '<a href="media-upload.php?post_id=4&amp;type=video&amp;TB_iframe=1&amp;width=640&amp;height=207" id="add_video" class="thickbox" title="Add Video">';
136
+ $urllabel = (get_bloginfo('version') >= 3.5) ? 'Link To Media File' : 'File URL';
137
+ echo "<div id=\"fvp_localvideo_notice\" class=\"fvp_notice".$class."\">\n\t<p class=\"description\">\n\t\t";
138
+ echo '<span style="font-weight: bold;">Local Media:</span> Use the <code>' . $urllabel . '</code> from your '. $mediahref . 'Media Library</a>.';
139
+ echo "\n\t</p>\n</div>\n";
140
+
141
+ // no featured image warning
142
+ $fvp_settings = get_option( 'fvp-settings' );
143
+ $class = $has_featimg || !$has_post_video || (isset($fvp_settings['overwrite']) && !$fvp_settings['overwrite']) ? ' fvp_hidden' : '';
144
+ echo '<div id="fvp_featimg_warning" class="fvp_notice'.$class.'">'."\n\t".'<p class="description">';
145
+ echo '<span style="font-weight: bold;">Featured Image:</span> For automatically displaying the Featured Video a Featured Image is required.';
146
+ echo "</p>\n</div>\n";
147
+
148
+ // set as featured image
149
+ $class = $meta['prov'] == 'local' || !$has_post_video || ($has_featimg && $featimg_is_fvp) ? ' class="fvp_hidden"' : '';
150
  $text = 'Set as Featured Image';
151
+ echo '<p id="fvp_set_featimg_box"'.$class.'>'."\n\t".'<span id="fvp_set_featimg_input">'."\n\t\t".'<input id="fvp_set_featimg" name="fvp_set_featimg" type="checkbox" value="set_featimg" />'."\n\t\t".'<label for="fvp_set_featimg">&nbsp;'.$text.'</label>'."\n\t".'</span>'."\n";
152
+ echo "\t".'<a style="display: none;" id="fvp_set_featimg_link" href="#">'.$text.'</a>'."\n".'</p>'."\n";
 
 
 
153
 
154
+ echo "<!-- Featured Video Plus Metabox End-->\n\n\n";
155
  }
156
 
157
  /**
167
  ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || // AJAX? Not used here
168
  ( !current_user_can( 'edit_post', $post_id ) ) || // Check user permissions
169
  ( false !== wp_is_post_revision( $post_id ) ) || // Return if it's a post revision
170
+ ( ( isset($_POST['fvp_nonce']) && !wp_verify_nonce( $_POST['fvp_nonce'], FVP_NAME ) ) &&
171
  !is_string($set_featimg) )
172
  ) return;
173
 
184
  $video = trim($_POST['fvp_video']);
185
  }
186
 
187
+ $sec = isset($_POST['fvp_sec']) && !empty($_POST['fvp_sec']) ? trim($_POST['fvp_sec']) : '';
188
+
189
  // something changed
190
  if( ( empty($video) ) || // no video or
191
  ( isset($meta) && ($video != $meta['full'])) ) // different video?
216
  if( empty($video) )
217
  return;
218
 
219
+ if( ($video == $meta['full']) &&
220
+ (!$set_featimg) &&
221
+ (empty($sec) || ( isset($meta['sec']) && $meta['sec'] == $sec ) ) ) // different secondary video?
222
  return;
223
 
224
+ $options = get_option( 'fvp-settings' );
225
+
226
  /*
227
  REGEX tested using: http://www.rubular.com/
228
 
240
 
241
  $local = wp_upload_dir();
242
  // match different provider(!)
243
+
244
+ preg_match('/(vimeo|youtu|dailymotion|' . preg_quote($local['baseurl'], '/') . ')/i', $video, $video_provider);
245
  if(!isset($video_provider[1]))
246
  return;
247
 
248
  $video_prov = $video_provider[1] == "youtu" ? "youtube" : $video_provider[1];
249
 
250
  switch ($video_prov) {
251
+
252
+ case $local['baseurl']:
253
+ $ext = pathinfo( $video, PATHINFO_EXTENSION );
254
+ if( !isset($ext) || ($ext != 'mp4' && $ext != 'ogv' && $ext != 'webm' && $ext != 'ogg') ) return; // wrong extension
255
+
256
+ $video_id = $this->get_post_by_url($video);
257
+ $video_prov = 'local';
258
+
259
+ if( !empty($sec) ) {
260
+ preg_match('/(' . preg_quote($local['baseurl'], '/') . ')/i', $sec, $sec_prov);
261
+ $ext2 = pathinfo( $sec, PATHINFO_EXTENSION );
262
+ if ( isset($sec_prov[1]) && isset($ext2) && $sec_prov[1] == $video_provider[1] && $ext != $ext2 &&
263
+ ($ext2 == 'mp4' || $ext2 == 'ogv' || $ext2 == 'webm' || $ext2 == 'ogg'))
264
+ $video_sec_id = $this->get_post_by_url($sec);
265
+ else $sec = ''; // illegal second video, remove it
266
+ }
267
+
268
  break;
 
269
 
270
  case 'youtube':
271
  //match provider watch feature id(!) attr(!)
345
  break;
346
  }
347
 
348
+ if( !isset($video_id) )
349
+ return;
350
+
351
  // do we have a screen capture to pull?
352
  if( !empty($video_info['img']) ) {
353
 
363
  );
364
 
365
  // pull external img to local server and add to media library
366
+ include_once( FVP_DIR . 'php/somatic_attach_external_image.php' );
367
  $video_img = somatic_attach_external_image($video_info['img'], $post_id, false, $video_info['filename'], $video_img_data);
368
 
369
  // generate picture metadata
396
  $meta = array(
397
  'full' => ( isset($data['url']) && !empty($data['url']) ) ? $data['url'] : $video,
398
  'id' => $video_id,
399
+ 'sec' => $sec,
400
+ 'sec_id' => ( isset($video_sec_id) && !empty($video_sec_id) ) ? $video_sec_id : '',
401
+ 'img' => isset($video_img) ? $video_img : '',
402
  'prov' => $video_prov,
403
  'attr' => isset($video_attr) ? $video_attr : '',
404
  'warn_featimg' => true
405
  );
406
+
407
  update_post_meta( $post_id, '_fvp_video', serialize($meta) );
408
 
409
  return;
416
  * @since 1.0
417
  */
418
  function settings_init() {
419
+ add_settings_section('fvp-settings-section', 'Featured Video', array( &$this, 'settings_content' ), 'media');
420
 
421
+ add_settings_field('fvp-settings-overwrite', 'Replace featured images', array( &$this, 'settings_overwrite' ), 'media', 'fvp-settings-section');
422
+ add_settings_field('fvp-settings-width', 'Video width', array( &$this, 'settings_width' ), 'media', 'fvp-settings-section');
423
+ add_settings_field('fvp-settings-height', 'Video height', array( &$this, 'settings_height' ), 'media', 'fvp-settings-section');
424
+ add_settings_field('fvp-settings-vimeo', 'Vimeo Player Design', array( &$this, 'settings_vimeo' ), 'media', 'fvp-settings-section');
425
+ add_settings_field('fvp-settings-rate', 'Support', array( &$this, 'settings_rate' ), 'media', 'fvp-settings-section');
426
 
427
  register_setting('media', 'fvp-settings', array( &$this, 'settings_save' ));
428
  }
473
  * @since 1.0
474
  */
475
  function settings_overwrite() {
476
+ $options = get_option( 'fvp-settings' );
477
+ $overwrite = isset($options['overwrite']) ? $options['overwrite'] : false;
478
+ ?>
479
 
480
+ <input type="radio" name="fvp-settings[overwrite]" id="fvp-settings-overwrite-1" value="true" <?php checked( true, $overwrite, true ) ?>/><label for="fvp-settings-overwrite-1">&nbsp;yes&nbsp;<span style="font-style: italic;">(default)</span></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
481
+ <input type="radio" name="fvp-settings[overwrite]" id="fvp-settings-overwrite-2" value="false" <?php checked( false, $overwrite, true ) ?>/><label for="fvp-settings-overwrite-2">&nbsp;no</label>
482
  <p class="description">If a featured video is available, it can be displayed in place of the featured image.<br />For some themes this could result in displaying errors. When using this, try different <code>width</code> and <code>height</code> settings.</p>
483
 
484
  <?php }
489
  * @since 1.0
490
  */
491
  function settings_width() {
492
+ $options = get_option( 'fvp-settings' );
493
+ $width = isset($options['width']) ? $options['width'] : 'auto'; ?>
494
 
495
+ <input type="radio" name="fvp-settings[width]" id="fvp-settings-width-1" value="auto" <?php checked( 'auto', $width, true ) ?>/><label for="fvp-settings-width-1">&nbsp;auto&nbsp;<span style="font-style: italic;">(default)</span></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
496
+ <input type="radio" name="fvp-settings[width]" id="fvp-settings-width-2" value="fixed" <?php checked( 'fixed', $width, true ) ?>/><label for="fvp-settings-width-2">&nbsp;fixed</label>
497
  <p class="description">Using <code>auto</code> the video's width will be adjusted to fit the parent element. Works best in combination with height setted to <code>auto</code> as well.</p>
498
 
499
  <?php }
504
  * @since 1.0
505
  */
506
  function settings_height() {
507
+ $options = get_option( 'fvp-settings' );
508
+ $height = isset($options['height']) ? $options['height'] : 'auto'; ?>
509
 
510
+ <input type="radio" name="fvp-settings[height]" id="fvp-settings-height-1" value="auto" <?php checked( 'auto', $height, true ) ?>/><label for="fvp-settings-height-1">&nbsp;auto&nbsp;<span style="font-style: italic;">(default)</span></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
511
+ <input type="radio" name="fvp-settings[height]" id="fvp-settings-height-2" value="fixed" <?php checked( 'fixed', $height, true ) ?>/><label for="fvp-settings-height-2">&nbsp;fixed</label>
512
  <p class="description">If using <code>fixed</code> videos may lose their ascpect radio, resulting in <span style="font-style: italic;">not so pretty</span> black bars.</p>
513
 
514
  <?php }
522
  * @since 1.0
523
  */
524
  function settings_vimeo() {
525
+ $options = get_option( 'fvp-settings' );
526
+ $vimeo['portrait'] = isset($options['vimeo']['portrait']) ? $options['vimeo']['portrait'] : 0;
527
+ $vimeo['title'] = isset($options['vimeo']['title']) ? $options['vimeo']['title'] : 1;
528
+ $vimeo['byline'] = isset($options['vimeo']['byline']) ? $options['vimeo']['byline'] : 1;
529
+ $vimeo['color'] = isset($options['vimeo']['color']) ? $options['vimeo']['color'] : '00adef'; ?>
530
 
531
  <div style="position: relative; bottom: .6em;">
532
+ <input type="checkbox" name="fvp-settings[vimeo][portrait]" id="fvp-settings-vimeo-1" value="display" <?php checked( 1, $vimeo['portrait'], 1 ) ?>/><label for="fvp-settings-vimeo-1">&nbsp;Portrait</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
533
+ <input type="checkbox" name="fvp-settings[vimeo][title]" id="fvp-settings-vimeo-2" value="display" <?php checked( 1, $vimeo['title'], 1 ) ?>/><label for="fvp-settings-vimeo-2">&nbsp;Title</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
534
+ <input type="checkbox" name="fvp-settings[vimeo][byline]" id="fvp-settings-vimeo-3" value="display" <?php checked( 1, $vimeo['byline'], 1 ) ?>/><label for="fvp-settings-vimeo-3">&nbsp;Byline</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
535
  <span class="color-picker" style="position: relative;<?php if( wp_style_is( 'wp-color-picker', 'done' ) ) echo ' top: .6em;'; ?>" >
536
+ <input type="text" name="fvp-settings[vimeo][color]" id="fvp-settings-vimeo-color" value="#<?php echo $vimeo['color'] ?>" data-default-color="#00adef" />
537
  <label for="fvp-settings-vimeo-color" style="display: none;">&nbsp;Color</label>
538
  <?php if( !wp_style_is('wp-color-picker', 'registered' ) ) { ?><div style="position: absolute; bottom: 0; right: -197px; background-color: #fff; z-index: 100; border: 1px solid #ccc;" id="fvp-settings-vimeo-colorpicker"></div><?php } ?>
539
  </span>
540
  </div>
541
  <p class="description">These settings could be overwritten by videos from Vimeo Plus members.</p>
542
 
543
+ <?php
544
+ }
545
 
546
  /**
547
  * Displays info about rating the plugin, giving feedback and requesting new features
563
  * @since 1.0
564
  */
565
  function settings_save($input) {
566
+ $options = get_option( 'fvp-settings' );
567
+
568
+ $options['overwrite'] = isset($input['overwrite']) && $input['overwrite'] == 'true' ? true : false;
569
 
570
+ $options['vimeo']['portrait'] = isset($input['vimeo']['portrait'])&& ( $input['vimeo']['portrait'] == 'display' ) ? 1 : 0;
571
+ $options['vimeo']['title'] = isset($input['vimeo']['title']) && ( $input['vimeo']['title'] == 'display' ) ? 1 : 0;
572
+ $options['vimeo']['byline'] = isset($input['vimeo']['byline']) && ( $input['vimeo']['byline'] == 'display' ) ? 1 : 0;
573
 
574
+ if( isset($options['vimeo']['color']) ) {
575
  preg_match('/#?([0123456789abcdef]{3}[0123456789abcdef]{0,3})/i', $input['vimeo']['color'], $color);
576
+ $options['vimeo']['color'] = $color[1];
577
  } else
578
+ $options['vimeo']['color'] = '00adef';
579
 
580
+
581
+ return $options;
582
  }
583
 
584
  /**
585
+ * Function to allow more upload mime types.
586
  *
587
+ * @see http://codex.wordpress.org/Plugin_API/Filter_Reference/upload_mimes
588
+ * @since 1.2
589
  */
590
+
591
+ function add_upload_mimes( $mimes=array() ) {
592
+ $mimes['webm'] = 'video/webm';
593
+
594
+ return $mimes;
 
 
 
 
 
 
 
 
 
 
595
  }
596
 
597
  /**
598
+ * Adds a media settings link to the plugin info
599
  *
600
+ * @since 1.2
 
 
601
  */
602
+ function plugin_action_link($links, $file) {
603
+ if ($file == FVP_NAME . '/' . FVP_NAME . '.php') {
604
+ $settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/options-media.php">Media Settings</a>';
605
+ array_unshift($links, $settings_link);
606
+ }
607
 
608
+ return $links;
 
 
609
  }
610
 
611
  /**
631
  $meta_key, $meta_value
632
  );
633
 
634
+ return $wpdb->get_var( $prepared );
 
 
635
  }
636
 
637
  /**
652
  );
653
  return $id;
654
  }
 
655
  }
656
  ?>
php/frontend.php CHANGED
@@ -3,7 +3,7 @@
3
  * Class containing functions required on frontend. Enqueue scripts/styles, replace featured images by featured videos.
4
  *
5
  * @author ahoereth
6
- * @version 2012/12/07
7
  * @see ../featured_video_plus.php
8
  * @see featured_video_plus in general.php
9
  * @since 1.0
@@ -12,7 +12,7 @@
12
  */
13
  class featured_video_plus_frontend {
14
  private $featured_video_plus = null;
15
-
16
  /**
17
  * Creates a new instace of this class, saves the featured_video_instance.
18
  *
@@ -23,21 +23,18 @@ class featured_video_plus_frontend {
23
  function __construct( $featured_video_plus_instance ) {
24
  if ( !isset($featured_video_plus_instance) )
25
  wp_die( 'featured_video_plus general instance required!', 'Error!' );
26
-
27
  $this->featured_video_plus = $featured_video_plus_instance;
28
  }
29
-
30
  /**
31
  * Enqueue all scripts and styles needed when viewing the frontend.
32
  *
33
  * @since 1.0
34
  */
35
  public function enqueue() {
36
- $options = get_option( 'fvp-settings' );
37
- if($options['width'] == 'auto')
38
- wp_enqueue_script('fvp_fitvids', plugins_url(). '/featured-video-plus/js/jquery.fitvids_fvp.js', array( 'jquery' ), '20121207', true );
39
  }
40
-
41
  /**
42
  * Display featured videos in place of featured images if a featured video is available and only if so desired by user.
43
  *
@@ -52,26 +49,26 @@ class featured_video_plus_frontend {
52
  */
53
  public function filter_post_thumbnail($html, $post_id, $post_thumbnail_id, $size, $attr) {
54
  global $_wp_additional_image_sizes;
55
-
56
  $options = get_option( 'fvp-settings' );
57
  if( !$options['overwrite'] || !$this->featured_video_plus->has_post_video( $post_id ) )
58
  return $html;
59
-
60
  if( isset($_wp_additional_image_sizes[$size]) )
61
  $size = array( $_wp_additional_image_sizes[$size]['width'], $_wp_additional_image_sizes[$size]['height'] );
62
  else {
63
-
64
  if( $size == 'thumbnail' || $size == 'thumb' )
65
  $size = array( get_option( 'thumbnail_size_w' ), get_option( 'thumbnail_size_h' ) );
66
  else if( $size == 'medium' )
67
  $size = array( get_option( 'medium_size_w' ), get_option( 'medium_size_h' ) );
68
  else if( $size == 'large' )
69
  $size = array( get_option( 'large_size_w' ), get_option( 'large_size_h' ) );
70
-
71
  }
72
-
73
  return $this->featured_video_plus->get_the_post_video( $post_id, $size );
74
-
75
  }
76
  }
77
  ?>
3
  * Class containing functions required on frontend. Enqueue scripts/styles, replace featured images by featured videos.
4
  *
5
  * @author ahoereth
6
+ * @version 2013/01/09
7
  * @see ../featured_video_plus.php
8
  * @see featured_video_plus in general.php
9
  * @since 1.0
12
  */
13
  class featured_video_plus_frontend {
14
  private $featured_video_plus = null;
15
+
16
  /**
17
  * Creates a new instace of this class, saves the featured_video_instance.
18
  *
23
  function __construct( $featured_video_plus_instance ) {
24
  if ( !isset($featured_video_plus_instance) )
25
  wp_die( 'featured_video_plus general instance required!', 'Error!' );
26
+
27
  $this->featured_video_plus = $featured_video_plus_instance;
28
  }
29
+
30
  /**
31
  * Enqueue all scripts and styles needed when viewing the frontend.
32
  *
33
  * @since 1.0
34
  */
35
  public function enqueue() {
 
 
 
36
  }
37
+
38
  /**
39
  * Display featured videos in place of featured images if a featured video is available and only if so desired by user.
40
  *
49
  */
50
  public function filter_post_thumbnail($html, $post_id, $post_thumbnail_id, $size, $attr) {
51
  global $_wp_additional_image_sizes;
52
+
53
  $options = get_option( 'fvp-settings' );
54
  if( !$options['overwrite'] || !$this->featured_video_plus->has_post_video( $post_id ) )
55
  return $html;
56
+
57
  if( isset($_wp_additional_image_sizes[$size]) )
58
  $size = array( $_wp_additional_image_sizes[$size]['width'], $_wp_additional_image_sizes[$size]['height'] );
59
  else {
60
+
61
  if( $size == 'thumbnail' || $size == 'thumb' )
62
  $size = array( get_option( 'thumbnail_size_w' ), get_option( 'thumbnail_size_h' ) );
63
  else if( $size == 'medium' )
64
  $size = array( get_option( 'medium_size_w' ), get_option( 'medium_size_h' ) );
65
  else if( $size == 'large' )
66
  $size = array( get_option( 'large_size_w' ), get_option( 'large_size_h' ) );
67
+
68
  }
69
+
70
  return $this->featured_video_plus->get_the_post_video( $post_id, $size );
71
+
72
  }
73
  }
74
  ?>
php/general.php CHANGED
@@ -3,7 +3,7 @@
3
  * Class containing all functions needed on front- AND backend. Functions only needed on one of those are found in distinct classes.
4
  *
5
  * @author ahoereth
6
- * @version 2012/12/07
7
  * @see ../featured_video_plus.php
8
  * @see featured_video_plus_backend in backend.php
9
  * @see featured_video_plus_frontend in frontend.php
@@ -11,6 +11,27 @@
11
  */
12
  class featured_video_plus {
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  /**
15
  * Returns the featured video html, ready to echo.
16
  *
@@ -36,35 +57,47 @@ class featured_video_plus {
36
  if( isset($meta['id']) && !empty($meta['id']) ) {
37
  switch( $meta['prov'] ) {
38
 
39
- /*case 'local':
40
- $ext = pathinfo($meta['full'], PATHINFO_EXTENSION);
41
- //$embed = '<object width="' . $width . '" height="' . $height . '"><param name="movie" value="' . $meta['full'] . '" /> <embed type="video/flash" width=' . $width . ' height="' . $height . '" src="' . $meta['full'] . '"></embed></object>';
42
- //$embed = '<video width="' . $width . '" height="' . $height . '" controls><source src="' . $meta['full'] . '" type="video/' . $ext . '">Your browser does not support the video tag.</video>' . "\n";
43
- $embed = '<video src="' . $meta['full'] . '" controls="controls" width="' . $width . '" height="' . $height . '"></video>';
 
 
 
 
 
 
 
 
 
 
 
 
44
  break;
45
- */
46
 
47
  case 'vimeo':
48
  $options = get_option( 'fvp-settings' );
49
  $fs = $allowfullscreen ? ' webkitAllowFullScreen mozallowfullscreen allowFullScreen' : '';
50
- $embed = "\n" . '<iframe src="http://player.vimeo.com/video/'.$meta['id'].'?badge=0&amp;portrait='.$options['vimeo']['portrait'].'&amp;title='.$options['vimeo']['title'].'&amp;byline='.$options['vimeo']['byline'].'&amp;color='.$options['vimeo']['color'].'" width="'.$width.'" height="'.$height.'" frameborder="0"'.$fs.'></iframe>' . "\n";
51
  break;
52
 
53
  case 'youtube':
54
  $fs = $allowfullscreen ? 'allowfullscreen' : '';
55
  $attr = '#t=' . $meta['attr'];
56
- $embed = "\n" . '<iframe width="'.$width.'" height="'.$height.'" src="http://www.youtube.com/embed/'.$meta['id'].'?rel=0'.$attr.'" frameborder="0" ' . $fs . '></iframe>' . "\n";
57
  break;
58
 
59
  case 'dailymotion':
60
-
61
  $embed = "\n" . '<iframe src="http://www.dailymotion.com/embed/video/'.$meta['id'].'?logo=1&amp;info='.$options['vimeo']['title'].'" width="'.$width.'" height="'.$height.'" frameborder="0"></iframe>' . "\n";
62
-
63
  break;
 
64
  }
65
 
66
  if($container)
67
- $embed = '<div class="featured_video_plus">' . $embed . '</div>';
 
 
68
 
69
  return $embed;
70
  }
3
  * Class containing all functions needed on front- AND backend. Functions only needed on one of those are found in distinct classes.
4
  *
5
  * @author ahoereth
6
+ * @version 2013/01/09
7
  * @see ../featured_video_plus.php
8
  * @see featured_video_plus_backend in backend.php
9
  * @see featured_video_plus_frontend in frontend.php
11
  */
12
  class featured_video_plus {
13
 
14
+ /**
15
+ * Enqueue all scripts and styles needed when viewing the frontend and backend.
16
+ *
17
+ * @see http://videojs.com/
18
+ * @since 1.2
19
+ */
20
+ public function enqueue($hook_suffix) {
21
+ // just required on post.php
22
+ if( !is_admin() || ( $hook_suffix == 'post.php' && isset($_GET['post']) ) ) {
23
+ $options = get_option( 'fvp-settings' );
24
+
25
+ // http://videojs.com/
26
+ wp_enqueue_style( 'videojs', 'http://vjs.zencdn.net/c/video-js.css' );
27
+ wp_enqueue_script( 'videojs', 'http://vjs.zencdn.net/c/video.js' );
28
+
29
+ if( isset($options['width']) && $options['width'] == 'auto' )
30
+ wp_enqueue_script('fvp_fitvids', plugins_url(). '/featured-video-plus/js/jquery.fitvids_fvp-min.js', array( 'jquery' ), '20121207', true ); // production
31
+ //wp_enqueue_script('fvp_fitvids', plugins_url(). '/featured-video-plus/js/jquery.fitvids_fvp.js', array( 'jquery' ), '20121207', true ); // development
32
+ }
33
+ }
34
+
35
  /**
36
  * Returns the featured video html, ready to echo.
37
  *
57
  if( isset($meta['id']) && !empty($meta['id']) ) {
58
  switch( $meta['prov'] ) {
59
 
60
+ case 'local':
61
+ $featimg = has_post_thumbnail($post_id) ? wp_get_attachment_url( get_post_thumbnail_id($post_id) ) : '';
62
+
63
+ $ext = pathinfo( $meta['full'], PATHINFO_EXTENSION );
64
+ if( $ext != 'mp4' && $ext != 'ogv' && $ext != 'webm' && $ext != 'ogg' ) break;
65
+ $ext = $ext == 'ogv' ? 'ogg' : $ext;
66
+ $embed = "\n\t".'<video class="video-js vjs-default-skin" controls preload="auto" width="'.$width.'" height="'.$height.'" >'; // poster="'.$featimg.'" data-setup="{}"
67
+ $embed .= "\n\t\t".'<source src="' . $meta['full'] . '" type="video/'.$ext.'">';
68
+
69
+ if( isset($meta['sec_id']) && !empty($meta['sec_id']) ) {
70
+ $ext2 = pathinfo( $meta['sec'], PATHINFO_EXTENSION );
71
+ $ext2 = $ext2 == 'ogv' ? 'ogg' : $ext2;
72
+ if( $ext2 == 'mp4' || $ext2 == 'ogv' || $ext2 == 'webm' || $ext2 == 'ogg' )
73
+ $embed .= "\n\t\t".'<source src="' . $meta['sec'] . '" type="video/'.$ext2.'">';
74
+ }
75
+
76
+ $embed .= "\n\t</video>\n";
77
  break;
 
78
 
79
  case 'vimeo':
80
  $options = get_option( 'fvp-settings' );
81
  $fs = $allowfullscreen ? ' webkitAllowFullScreen mozallowfullscreen allowFullScreen' : '';
82
+ $embed = "\n\t" . '<iframe src="http://player.vimeo.com/video/'.$meta['id'].'?badge=0&amp;portrait='.$options['vimeo']['portrait'].'&amp;title='.$options['vimeo']['title'].'&amp;byline='.$options['vimeo']['byline'].'&amp;color='.$options['vimeo']['color'].'" width="'.$width.'" height="'.$height.'" frameborder="0"'.$fs.'></iframe>' . "\n";
83
  break;
84
 
85
  case 'youtube':
86
  $fs = $allowfullscreen ? 'allowfullscreen' : '';
87
  $attr = '#t=' . $meta['attr'];
88
+ $embed = "\n\t" . '<iframe width="'.$width.'" height="'.$height.'" src="http://www.youtube.com/embed/'.$meta['id'].'?rel=0'.$attr.'" frameborder="0" ' . $fs . '></iframe>' . "\n";
89
  break;
90
 
91
  case 'dailymotion':
 
92
  $embed = "\n" . '<iframe src="http://www.dailymotion.com/embed/video/'.$meta['id'].'?logo=1&amp;info='.$options['vimeo']['title'].'" width="'.$width.'" height="'.$height.'" frameborder="0"></iframe>' . "\n";
 
93
  break;
94
+
95
  }
96
 
97
  if($container)
98
+ $embed = "<div class=\"featured_video_plus\">" . $embed . "</div>\n\n";
99
+
100
+ $embed = "\n\n<!-- Featured Video Plus v".FVP_VERSION."-->\n" . $embed;
101
 
102
  return $embed;
103
  }
php/setup.php DELETED
@@ -1,79 +0,0 @@
1
- <?php
2
- /**
3
- * Class containing functions to run on plugin activation, deactivation and uninstallation.
4
- *
5
- * @author ahoereth
6
- * @version 2012/12/07
7
- * @see http://wordpress.stackexchange.com/a/25979
8
- * @since 1.0
9
- */
10
- class featured_video_plus_setup {
11
-
12
- /**
13
- * Just checks if the class was called directly, if yes: dies.
14
- *
15
- * @since 1.0
16
- *
17
- * @param $case = false test parameter
18
- */
19
- function __construct( $case = false ) {
20
- if ( ! $case )
21
- wp_die( 'You should not call this class directly!', 'Doing it wrong!' );
22
- }
23
-
24
- /**
25
- * Runs on activation, writes default settings to database.
26
- *
27
- * @since 1.0
28
- */
29
- public function on_activate() {
30
- $options = get_option( 'fvp-settings' );
31
- if( empty($options) ) {
32
- $options = array(
33
- 'overwrite' => true,
34
- 'width' => 'auto',
35
- 'height' => 'auto',
36
- 'vimeo' => array(
37
- 'portrait' => 0,
38
- 'title' => 1,
39
- 'byline' => 1,
40
- 'color' => '00adef'
41
- )
42
- );
43
- }
44
- update_option( 'fvp-settings', $options );
45
- }
46
-
47
- /**
48
- * Runs on uninstallation, deletes all data including post&user metadata and video screen captures.
49
- *
50
- * @since 1.0
51
- */
52
- function on_uninstall() {
53
- // important: check if the file is the one that was registered with the uninstall hook (function)
54
- //if ( __FILE__ != WP_UNINSTALL_PLUGIN )
55
- // return;
56
-
57
- delete_option( 'fvp-settings' );
58
-
59
- $post_types = get_post_types( array("public" => true) );
60
- foreach( $post_types as $post_type ) {
61
- if( $post_type != 'attachment' ) {
62
- $allposts = get_posts('numberposts=-1&post_type=' . $post_type . '&post_status=any');
63
- foreach( $allposts as $post ) {
64
- $meta = unserialize(get_post_meta( $post->ID, '_fvp_video', true ));
65
-
66
- wp_delete_attachment( $meta['img'] );
67
- delete_post_meta($post->ID, '_fvp_video');
68
- }
69
- }
70
- }
71
-
72
- $users = array_merge( get_users( array( 'role' => 'Administrator' ) ), get_users( array( 'role' => 'Super Admin' ) ) );
73
- foreach( $users as $user ) {
74
- delete_user_meta( $user-ID, 'fvp_activation_notification_ignore' );
75
- }
76
- }
77
-
78
- }
79
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
php/upgrade.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Is used on plugin upgrade and on first activation. Initializes and upgrades options, places notice etc.
4
+ *
5
+ * @since 1.2
6
+ */
7
+ function featured_video_plus_upgrade() {
8
+
9
+ $featured_video_plus_notices = new featured_video_plus_notices();
10
+
11
+ $options = get_option( 'fvp-settings', 'none' );
12
+ if( !isset($options) || $options == 'none')
13
+ $version = '0';
14
+ elseif( !isset($options['version']) )
15
+ $version = '1.1';
16
+ else
17
+ $version = $options['version'];
18
+
19
+ switch( $version ) {
20
+
21
+ case '0':
22
+ $options = array(
23
+ 'version' => '1.2',
24
+ 'overwrite' => true,
25
+ 'width' => 'auto',
26
+ 'height' => 'auto',
27
+ 'vimeo' => array(
28
+ 'portrait' => 0,
29
+ 'title' => 1,
30
+ 'byline' => 1,
31
+ 'color' => '00adef'
32
+ )
33
+ );
34
+
35
+ add_action('admin_notices', array( &$featured_video_plus_notices, 'initial_activation' ) );
36
+ break;
37
+
38
+ case '1.0':
39
+ case '1.1':
40
+ $options['version'] = '1.2';
41
+
42
+ // remove no longer needed user meta
43
+ $users = array_merge( get_users( array( 'role' => 'Administrator' ) ), get_users( array( 'role' => 'Super Admin' ) ) );
44
+ foreach( $users as $user ) {
45
+ delete_user_meta( $user->ID, 'fvp_activation_notification_ignore' );
46
+ }
47
+
48
+ add_action('admin_notices', array( &$featured_video_plus_notices, 'upgrade_11' ) );
49
+ break;
50
+
51
+ }
52
+
53
+ update_option( 'fvp-settings', $options );
54
+
55
+ }
56
+
57
+ /**
58
+ * Class containing notices for upgrading the plugin
59
+ *
60
+ * @author ahoereth
61
+ * @version 2013/01/08
62
+ * @see http://wptheming.com/2011/08/admin-notices-in-wordpress/
63
+ * @since 1.2
64
+ */
65
+ class featured_video_plus_notices {
66
+
67
+ /**
68
+ * Upgrade notification 1.1 to 1.2
69
+ *
70
+ * @since 1.2
71
+ */
72
+ function upgrade_11() {
73
+ echo "\n" . '<div class="updated" id="fvp_activation_notification"><p>';
74
+ printf('Featured Video Plus was <span style="font-weight: bold;">upgraded</span>. Version <span style="font-weight: bold;">1.2</span> now supports <span style="font-weight: bold;">local videos</span>. If you like the plugin please <a href="%1$s">rate it</a>.', 'http://wordpress.org/extend/plugins/featured-video-plus/');
75
+ echo "</p></div>\n";
76
+ }
77
+
78
+ /**
79
+ * Notification shown when plugin is newly activated.
80
+ *
81
+ * @since 1.0
82
+ */
83
+ function initial_activation() {
84
+ echo "\n" . '<div class="updated" id="fvp_activation_notification"><p>';
85
+ printf('Featured Video Plus is ready to use. There is a new box on post & page edit screens for you to add video URLs. <span style="font-weight: bold;">Take a look at your new <a href="%1$s" title="Media Settings">Media Settings</a></span>.', get_admin_url(null, '/options-media.php?fvp_activation_notification_ignore=0'));
86
+ echo "</p></div>\n";
87
+ }
88
+
89
+ }
90
+ ?>
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: a.hoereth
3
  Plugin Name: Featured Video Plus
4
  Plugin URI: https://github.com/ahoereth/featured-video-plus
5
- Tags: featured video, featured image, featured, post video, post thumbnail, video, thumbnail, html5, flash, youtube, vimeo, dailymotion
6
  Author: Alexander Höreth
7
  Author URI: http://ahoereth.yrnxt.com/
8
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=a%2ehoereth%40gmail%2ecom
@@ -10,30 +10,32 @@ License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  Requires at least: 3.1
12
  Tested up to: 3.5
13
- Stable tag: 1.1
14
 
15
- Add Featured Videos to your posts and pages, just like you add Featured Images. Works with every theme which supports Featured Images.
16
 
17
 
18
  == Description ==
 
19
 
20
- *A picture is worth a thousand words? What about a video then? How much more is it worth?*
21
 
22
- This plugin enables you to define Featured Videos for your posts and pages. When Featured Images are supported by your theme the Featured Videos will automatically be displayed inplace if available. The Featured Image will be used as fallback.
23
- The Featured Videos can either be displayed inplace of Featured Images, can be added to the theme by editing the theme's source files or inserted in your posts manually using the shortcode.
24
 
25
- The plugin will add an box to the admin interface's post and pages edit page where you can paste your videos URL. At the moment the plugin supports __YouTube__ (including [time-links](http://support.google.com/youtube/bin/answer.py?hl=en&answer=116618 "Link to a specific time in a video")), __Vimeo__ and __Dailymotion__.
26
- If you are missing a certain video platform: Leave a message in the supports forum.
 
27
 
28
- After activating the plugin you will get some additions to your media settings. There you can choose how the videos will be sized and get some other individualisation properties - have a look at the [screenshots](http://wordpress.org/extend/plugins/featured-video-plus/screenshots/). If the theme you are using does not work with any combination of the width and height settings please contact me and I will look into it.
29
 
30
- __Shortcode:__
 
 
31
 
32
  [featured-video-plus]
33
  [featured-video-plus width=300]
34
 
35
-
36
- __PHP functions:__
37
 
38
  the_post_video(array(width, height), fullscreen = true)
39
  has_post_video(post_id)
@@ -42,7 +44,9 @@ __PHP functions:__
42
  All parameters are optional. If no post_id is given the current post's id will be used.
43
 
44
 
45
- This plugin was created after using the original [Featured Video](http://wordpress.org/extend/plugins/featured-video/) plugin. Featured Video Plus is complete remake with more features and a more seemless integration into WordPress in mind.
 
 
46
 
47
  == Installation ==
48
 
@@ -50,23 +54,39 @@ This plugin was created after using the original [Featured Video](http://wordpre
50
  2. Search for "Featured Video Plus", and click "Install Now" below the plugins name
51
  3. When the installation finished, click "Activate Plugin"
52
 
53
- The plugin is ready to go. Now edit your posts and add video links to the "Featured Video" box on the right!
54
- If you want to change some settings have a look under Settings -> Media.
55
 
56
 
57
  == Changelog ==
58
 
 
 
 
 
 
 
 
 
 
59
  = 1.1 =
60
  * __Added Dailymotion__
61
  * fixed youtube 'start at specific time' embeds
62
  * overhaul of the interaction between Featured Videos and Featured Images
63
  * existing featured images will no longer be replaced by newly added featured videos in the administration interface
64
 
65
-
66
  = 1.0 =
67
  * Release
68
 
69
 
 
 
 
 
 
 
 
 
 
70
  == Screenshots ==
71
 
72
  1. Featured Video and Featured Image boxes on the post edit screen.
@@ -80,6 +100,30 @@ If you want to change some settings have a look under Settings -> Media.
80
  Maybe the plugin does not recognize the URL. Try the URL you get when clicking on share below a youtube video or the simple vimeo URL, which should look something like this: http://vimeo.com/32071937
81
  If you want to you can post the URL which is not working in the support forums and the plugin might work with it in the next release.
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  = What about other video portals? =
84
  Leave me a note in the support forums which you would like and I will consider adding them in the next release.
85
 
2
  Contributors: a.hoereth
3
  Plugin Name: Featured Video Plus
4
  Plugin URI: https://github.com/ahoereth/featured-video-plus
5
+ Tags: featured video, featured image, featured, video, post video, post thumbnail, post, thumbnail, html5, flash, youtube, vimeo, dailymotion, mp4, webm, ogg, ogv
6
  Author: Alexander Höreth
7
  Author URI: http://ahoereth.yrnxt.com/
8
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=a%2ehoereth%40gmail%2ecom
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  Requires at least: 3.1
12
  Tested up to: 3.5
13
+ Stable tag: 1.2
14
 
15
+ Add Featured Videos to your posts and pages, just like you add Featured Images. Supports your Local Videos, YouTube, Vimeo and Dailymotion.
16
 
17
 
18
  == Description ==
19
+ *A picture is worth a thousand words. How many words is a video worth?*
20
 
21
+ This plugin enables you to define Featured Videos in addition to Featured Images. Themes using Featured Images automatically display the videos in place.
22
 
23
+ There are three ways to get the videos onto your page:
 
24
 
25
+ 1. If your theme already makes use of Featured Images, these will automatically be replaced by Featured Videos if available. Alternatively you can
26
+ 2. insert the `[featured-video-plus]` shortcode in your entries or
27
+ 3. manually use the PHP functions in your theme's source files.
28
 
29
+ Beside your __Local Videos__ (`mp4`, `webM` & `ogg/ogv`) you can use __YouTube__ (w/[time-links](http://support.google.com/youtube/bin/answer.py?hl=en&answer=116618 "Link to a specific time in a video")), __Vimeo__ and __Dailymotion__. If you miss a certain video platform: [Leave me a note](http://wordpress.org/support/plugin/featured-video-plus).
30
 
31
+ The plugin adds some individualization options to your Media Settings. Beside aesthetic customizations you can turn off automatic integration and tweak some technical settings.
32
+
33
+ = Shortcode =
34
 
35
  [featured-video-plus]
36
  [featured-video-plus width=300]
37
 
38
+ = PHP functions =
 
39
 
40
  the_post_video(array(width, height), fullscreen = true)
41
  has_post_video(post_id)
44
  All parameters are optional. If no post_id is given the current post's id will be used.
45
 
46
 
47
+
48
+ *This plugin was created with the original [Featured Video](http://wordpress.org/extend/plugins/featured-video/) plugin in mind. __Featured Video Plus__ was freshly coded from ground up to be more powerful, bring you more features and to integrate more seamless into WordPress.*
49
+
50
 
51
  == Installation ==
52
 
54
  2. Search for "Featured Video Plus", and click "Install Now" below the plugins name
55
  3. When the installation finished, click "Activate Plugin"
56
 
57
+ The plugin is ready to go. Now edit your posts and add video links to the "Featured Video" box on the right! If you want to use Local Videos they need to be `mp4`, `webM` or `ogg/ogv`. If you want to change some settings have a look under Settings -> Media.
 
58
 
59
 
60
  == Changelog ==
61
 
62
+ = 1.2 =
63
+ * __Added support for local videos__
64
+ * Allow webM mime type for media upload
65
+ * Added Media Settings link in plugin info
66
+ * More notices/warnings
67
+ * More JS
68
+ * minimized JS and CSS
69
+ * fixed some other stuff
70
+
71
  = 1.1 =
72
  * __Added Dailymotion__
73
  * fixed youtube 'start at specific time' embeds
74
  * overhaul of the interaction between Featured Videos and Featured Images
75
  * existing featured images will no longer be replaced by newly added featured videos in the administration interface
76
 
 
77
  = 1.0 =
78
  * Release
79
 
80
 
81
+ == Upgrade Notice ==
82
+
83
+ = 1.2 =
84
+ Now featuring your local videos!
85
+
86
+ = 1.1 =
87
+ Feature Dailymotion Videos on your posts!
88
+
89
+
90
  == Screenshots ==
91
 
92
  1. Featured Video and Featured Image boxes on the post edit screen.
100
  Maybe the plugin does not recognize the URL. Try the URL you get when clicking on share below a youtube video or the simple vimeo URL, which should look something like this: http://vimeo.com/32071937
101
  If you want to you can post the URL which is not working in the support forums and the plugin might work with it in the next release.
102
 
103
+ = My theme uses Featured Images. Why are my videos not being displayed in place? =
104
+ For the videos to be automatically displayed you need to define a Featured Image. This image will never be shown if a video is available.
105
+ On the technical side your theme needs to feature [Post Thumbnails](http://codex.wordpress.org/Post_Thumbnails) and make use of `get_the_post_thumbnail()` or `the_post_thumbnail()`, because there is where the plugin hooks into.
106
+
107
+ If the automatic integration does not work, you can tell me in the [Support Forum](http://wordpress.org/support/plugin/featured-video-plus) which theme you are using and I will take a look at it and might be able to develop a workaround.
108
+
109
+ = Why do my videos do not fit their container? =
110
+ Take a look at your media settings and try tweaking the video size. For most installations the sizing works fine by default, if it still does not: I'm [happy to help](http://wordpress.org/support/plugin/featured-video-plus).
111
+
112
+ = I activated local video support, how do I use it? =
113
+ * Add a __mp4__, __webM__ or __ogv__ video to your Media Library
114
+ * Copy the `Link To Media File` and paste it into the Featured Video box
115
+ * For better [compatibility](http://videojs.com/#compatibilitychart) upload a second version of the same video with a different format and paste the URL in the second input box as a fallback.
116
+
117
+ = What is the easiest way to get my video into these formats? =
118
+ Take a look at the [Miro Video Converter](http://www.mirovideoconverter.com/). It is open source, lightweight and compatible with Windows, Mac and Linux.
119
+
120
+ = What can I do about those errors I get when uploading my video? =
121
+ * Read [this](http://www.wpbeginner.com/wp-tutorials/how-to-increase-the-maximum-file-upload-size-in-wordpress/) on how to increase maximum file upload size.
122
+ * WordPress by default does not support webM. The plugin activates it, but under some conditions this might not be enough and you might want to take a look at this [post](http://ottopress.com/2011/howto-html5-video-that-works-almost-everywhere/).
123
+
124
+ = What happens if the user does not use a HTML5 compatible browser? =
125
+ The video player, [VIDEOJS](http://videojs.com/), features an adobe flash fallback if you provide an MP4 video.
126
+
127
  = What about other video portals? =
128
  Leave me a note in the support forums which you would like and I will consider adding them in the next release.
129
 
uninstall.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Runs on uninstallation, deletes all data including post metadata, video screen captures and options.
5
+ *
6
+ * @since 1.2
7
+ */
8
+ if( !defined('WP_UNINSTALL_PLUGIN') ) exit();
9
+
10
+ delete_option( 'fvp-settings' );
11
+
12
+ $post_types = get_post_types( array("public" => true) );
13
+ foreach( $post_types as $post_type )
14
+ if( $post_type != 'attachment' ) {
15
+ $allposts = get_posts('numberposts=-1&post_type=' . $post_type . '&post_status=any');
16
+ foreach( $allposts as $post ) {
17
+ $meta = unserialize(get_post_meta( $post->ID, '_fvp_video', true ));
18
+ wp_delete_attachment( $meta['img'] );
19
+ delete_post_meta($meta['img'], '_fvp_image');
20
+ delete_post_meta($post->ID, '_fvp_video');
21
+ }
22
+ }
23
+
24
+ ?>