Featured Video Plus - Version 1.0

Version Description

  • Release

=

Download this release

Release Info

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

Version 1.0

css/backend.css ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wp-picker-holder {
2
+ position: absolute; bottom: 2.5em; left: -1em;
3
+ z-index: 1;
4
+ -webkit-box-shadow: 3px 3px 5px #ddd;
5
+ -moz-box-shadow: 3px 3px 5px #ddd;
6
+ box-shadow: 3px 3px 5px #ddd;
7
+ -webkit-box-sizing: border-box;
8
+ -moz-box-sizing: border-box;
9
+ box-sizing: border-box;
10
+ }
11
+
12
+ .defaultTextActive {
13
+ color: #a1a1a1;
14
+ font-style: italic;
15
+ }
16
+
17
+ #fvp_activation_notification {
18
+ border-color: #00adef;
19
+ background-color: whiteSmoke;
20
+ }
featured-video-plus.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ 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.0
8
+ Author URI: http://ahoereth.yrnxt.com
9
+ License: GPL2
10
+
11
+ Copyright 2009-2012 Alexander Höreth (email: a.hoereth@gmail.com)
12
+
13
+ This program is free software; you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License version 2,
15
+ as published by the Free Software Foundation.
16
+
17
+ You may NOT assume that you can use any other version of the GPL.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ The license for this software can likely be found here:
25
+ http://www.gnu.org/licenses/gpl-2.0.html
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
+ // only on frontend / page
57
+ if( !is_admin() ) {
58
+ // init frontend class, located in php/frontend.php
59
+ $featured_video_plus_frontend = new featured_video_plus_frontend($featured_video_plus);
60
+
61
+ // enqueue scripts and styles
62
+ add_action( 'wp_enqueue_scripts', array( &$featured_video_plus_frontend, 'enqueue' ) );
63
+
64
+ // filter get_post_thumbnail output
65
+ add_filter('post_thumbnail_html', array( &$featured_video_plus_frontend, 'filter_post_thumbnail'), 99, 5);
66
+
67
+ // echos the current posts featured video
68
+ function the_post_video($width = '560', $height = '315', $allowfullscreen = true) {
69
+ echo get_the_post_video(null, $width, $height, $allowfullscreen, true);
70
+ }
71
+
72
+ // returns the posts featured video
73
+ function get_the_post_video($post_id = null, $width = '560', $height = '315', $allowfullscreen = true) {
74
+ global $featured_video_plus;
75
+ return $featured_video_plus->get_the_post_video($post_id, $width, $height, $allowfullscreen);
76
+ }
77
+
78
+ // checks if post has a featured video
79
+ function has_post_video($post_id = null){
80
+ global $featured_video_plus;
81
+ return $featured_video_plus->has_post_video($post_id);
82
+ }
83
+ }
84
+
85
+
86
+ include_once( dirname( __FILE__ ) . '/php/setup.php' );
87
+ register_activation_hook( __FILE__, array( 'featured_video_plus_setup', 'on_activate' ) );
88
+ //register_deactivation_hook( __FILE__, array( 'featured_video_plus_setup', 'on_deactivate' ) );
89
+ register_uninstall_hook( __FILE__, array( 'featured_video_plus_setup', 'on_uninstall' ) );
90
+
91
+ ?>
js/backend.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($){
2
+
3
+ $("#fvp_video").focus(function(srcc) {
4
+ if ($(this).val() == $(this)[0].title) {
5
+ $(this).removeClass("defaultTextActive");
6
+ $(this).val("");
7
+ }
8
+ });
9
+
10
+ $("#fvp_video").blur(function() {
11
+ if ($(this).val() == "") {
12
+ $(this).addClass("defaultTextActive");
13
+ $(this).val($(this)[0].title);
14
+ }
15
+ });
16
+
17
+ $("#fvp_video").blur();
18
+ });
js/backend_35.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // >=WordPress 3.5
2
+ jQuery(document).ready(function($){
3
+ var myOptions = {
4
+ // you can declare a default color here,
5
+ // or in the data-default-color attribute on the input
6
+ defaultColor: '#00adef',
7
+ // a callback to fire whenever the color changes to a valid color
8
+ change: function(event, ui){},
9
+ // a callback to fire when the input is emptied or an invalid color
10
+ clear: function() {},
11
+ // hide the color picker controls on load
12
+ hide: true,
13
+ // show a group of common colors beneath the square
14
+ // or, supply an array of colors to customize further
15
+ palettes: new Array('#00adef', '#ff9933', '#c9ff23', '#ff0179', '#ffffff')
16
+ };
17
+
18
+ $('#fvp-settings-vimeo-color').wpColorPicker(myOptions);
19
+ });
js/backend_pre35.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // <WordPress 3.5
2
+ jQuery(document).ready(function($){
3
+ $('#fvp-settings-vimeo-colorpicker').hide();
4
+ $('#fvp-settings-vimeo-colorpicker').farbtastic('#fvp-settings-vimeo-color');
5
+
6
+ $('#fvp-settings-vimeo-color').click(function() {
7
+ $('#fvp-settings-vimeo-colorpicker').fadeIn();
8
+ });
9
+
10
+ $(document).mousedown(function() {
11
+ $('#fvp-settings-vimeo-colorpicker').each(function() {
12
+ var display = $(this).css('display');
13
+ if ( display == 'block' )
14
+ $(this).fadeOut();
15
+ });
16
+ });
17
+
18
+ $("#fvp_video").focus(function(srcc) {
19
+ if ($(this).val() == $(this)[0].title) {
20
+ $(this).removeClass("defaultTextActive");
21
+ $(this).val("");
22
+ }
23
+ });
24
+
25
+ $("#fvp_video").blur(function() {
26
+ if ($(this).val() == "") {
27
+ $(this).addClass("defaultTextActive");
28
+ $(this).val($(this)[0].title);
29
+ }
30
+ });
31
+
32
+ $("#fvp_video").blur();
33
+ });
js/jquery.fitvids_fvp.js ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*global jQuery */
2
+ /*jshint multistr:true browser:true */
3
+ /*!
4
+ * FitVids 1.0
5
+ *
6
+ * Copyright 2011, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com
7
+ * Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
8
+ * Released under the WTFPL license - http://sam.zoy.org/wtfpl/
9
+ *
10
+ * Date: Thu Sept 01 18:00:00 2011 -0500
11
+ */
12
+
13
+ (function( $ ){
14
+
15
+ "use strict";
16
+
17
+ $.fn.fitVids = function( options ) {
18
+ var settings = {
19
+ customSelector: null
20
+ };
21
+
22
+ var div = document.createElement('div'),
23
+ ref = document.getElementsByTagName('base')[0] || document.getElementsByTagName('script')[0];
24
+
25
+ div.className = 'fit-vids-style';
26
+ div.innerHTML = '&shy;<style> \
27
+ .fluid-width-video-wrapper { \
28
+ width: 100%; \
29
+ position: relative; \
30
+ padding: 0; \
31
+ } \
32
+ \
33
+ .fluid-width-video-wrapper iframe, \
34
+ .fluid-width-video-wrapper object, \
35
+ .fluid-width-video-wrapper embed { \
36
+ position: absolute; \
37
+ top: 0; \
38
+ left: 0; \
39
+ width: 100%; \
40
+ height: 100%; \
41
+ } \
42
+ </style>';
43
+
44
+ ref.parentNode.insertBefore(div,ref);
45
+
46
+ if ( options ) {
47
+ $.extend( settings, options );
48
+ }
49
+
50
+ return this.each(function(){
51
+ var selectors = [
52
+ "iframe[src*='player.vimeo.com']",
53
+ "iframe[src*='www.youtube.com']",
54
+ "iframe[src*='www.youtube-nocookie.com']",
55
+ "iframe[src*='www.kickstarter.com']",
56
+ "object",
57
+ "embed"
58
+ ];
59
+
60
+ if (settings.customSelector) {
61
+ selectors.push(settings.customSelector);
62
+ }
63
+
64
+ var $allVideos = $(this).find(selectors.join(','));
65
+
66
+ $allVideos.each(function(){
67
+ var $this = $(this);
68
+ if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
69
+ var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
70
+ width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
71
+ aspectRatio = height / width;
72
+ if(!$this.attr('id')){
73
+ var videoID = 'fitvid' + Math.floor(Math.random()*999999);
74
+ $this.attr('id', videoID);
75
+ }
76
+ $this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%");
77
+ $this.removeAttr('height').removeAttr('width');
78
+ });
79
+ });
80
+ };
81
+ })( jQuery );
82
+
83
+ jQuery(document).ready(function($){
84
+ $(".featured_video_plus").fitVids();
85
+ });
license.txt ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
php/backend.php ADDED
@@ -0,0 +1,497 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
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
10
+ *
11
+ * @param featured_video_plus instance
12
+ */
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.
19
+ *
20
+ * @since 1.0
21
+ *
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
+ /**
33
+ * Enqueue all scripts and styles needed when viewing the backend.
34
+ *
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
+ * @since 1.0
38
+ */
39
+ public function enqueue($hook_suffix) {
40
+ // just required on options-media.php and would produce errors pre WordPress 3.1
41
+ if( ($hook_suffix == 'options-media.php') && (get_bloginfo('version') >= 3.1) ) {
42
+ if( wp_style_is( 'wp-color-picker', 'registered' ) ) {
43
+ // >=WP3.5
44
+ wp_enqueue_style( 'wp-color-picker' );
45
+ wp_enqueue_script( 'fvp_backend_35', plugins_url() . '/featured-video-plus/js/backend_35.js', array( 'wp-color-picker', 'jquery' ) );
46
+ } else {
47
+ // <WP3.5, fallback for the new WordPress Color Picker which was added in 3.5
48
+ wp_enqueue_style( 'farbtastic' );
49
+ wp_enqueue_script( 'farbtastic' );
50
+ wp_enqueue_script( 'fvp_backend_pre35', plugins_url() . '/featured-video-plus/js/backend_pre35.js', array( 'jquery' ) );
51
+ }
52
+ }
53
+
54
+ // just required on post.php
55
+ if($hook_suffix == 'post.php') {
56
+ wp_enqueue_script( 'fvp_backend', plugins_url() . '/featured-video-plus/js/backend.js', array( 'jquery' ) );
57
+
58
+ // just required if width is set to auto
59
+ $options = get_option( 'fvp-settings' );
60
+ if($options['width'] == 'auto')
61
+ wp_enqueue_script('fvp_fitvids', plugins_url(). '/featured-video-plus/js/jquery.fitvids_fvp.js', array( 'jquery' ), '20121207', true );
62
+ }
63
+
64
+ wp_enqueue_style( 'fvp_backend', plugins_url() . '/featured-video-plus/css/backend.css' );
65
+ }
66
+
67
+ /**
68
+ * Notification shown when plugin is newly activated. Automatically hidden after 5x displayed.
69
+ *
70
+ * @see http://wptheming.com/2011/08/admin-notices-in-wordpress/
71
+ * @since 1.0
72
+ */
73
+ public function activation_notification() {
74
+ if ( current_user_can( 'manage_options' ) ) {
75
+ global $current_user ;
76
+
77
+ $count = get_user_meta($current_user->ID, 'fvp_activation_notification_ignore', true);
78
+ if( empty($count) || ($count <= 5) ) {
79
+ $part = empty($count) ? 'There is a new box on post & page edit screens for you to add video URLs.' : '';
80
+ echo "\n" . '<div class="updated" id="fvp_activation_notification"><p>';
81
+ 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 Notice</a>'), $part . '&nbsp;', get_admin_url(null, '/options-media.php?fvp_activation_notification_ignore=0'), '?fvp_activation_notification_ignore=0');
82
+ echo "</p></div>\n";
83
+
84
+ $count = empty($count) ? 1 : $count+1;
85
+ update_user_meta($current_user->ID, 'fvp_activation_notification_ignore', $count);
86
+ }
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Function fired when notification should be hidden manually. Hides it for the current user forever.
92
+ *
93
+ * @see http://wptheming.com/2011/08/admin-notices-in-wordpress/
94
+ * @see function activation_notification
95
+ * @since 1.0
96
+ */
97
+ public function ignore_activation_notification() {
98
+ global $current_user;
99
+
100
+ // If user clicks to ignore the notice, add that to their user meta
101
+ if ( isset($_GET['fvp_activation_notification_ignore']) && '0' == $_GET['fvp_activation_notification_ignore'] )
102
+ update_user_meta($current_user->ID, 'fvp_activation_notification_ignore', 999);
103
+ }
104
+
105
+ /**
106
+ * Registers the metabox on post/page edit views.
107
+ *
108
+ * @since 1.0
109
+ */
110
+ function metabox_register() {
111
+ $post_types = get_post_types(array("public" => true));
112
+ foreach ($post_types as $post_type) {
113
+ if($post_type != 'attachment')
114
+ add_meta_box("featured_video_plus-box", 'Featured Video', array( &$this, 'metabox_content' ), $post_type, 'side', 'core');
115
+ }
116
+ }
117
+
118
+
119
+ /**
120
+ * Callback function of the metabox; generates the HTML content.
121
+ *
122
+ * @since 1.0
123
+ */
124
+ function metabox_content() {
125
+ wp_nonce_field( plugin_basename( __FILE__ ), 'fvp_nonce');
126
+
127
+ if( isset($_GET['post']) )
128
+ $post_id = $_GET['post'];
129
+ else
130
+ $post_id = $GLOBALS['post']->ID;
131
+
132
+ $meta = unserialize( get_post_meta($post_id, '_fvp_video', true) );
133
+
134
+ // displays the current featured video
135
+ if( $this->featured_video_plus->has_post_video($post_id) )
136
+ 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";
137
+
138
+ // input box containing the featured video URL
139
+ echo "\n" . '<input id="fvp_video" name="fvp_video" type="text" value="' . $meta['full'] . '" style="width: 100%" title="' . $this->default_value . '" />' . "\n";
140
+ }
141
+
142
+ /**
143
+ * Saves the changes made in the metabox: Splits URL in its parts, saves provider and id, pulls the screen capture, adds it to the gallery and as featured image.
144
+ *
145
+ * @since 1.0
146
+ *
147
+ * @param int $post_id
148
+ */
149
+ public function metabox_save($post_id){
150
+ // Autosave, do nothing
151
+ if (( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ||
152
+ ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || // AJAX? Not used here
153
+ ( !current_user_can( 'edit_post', $post_id ) ) || // Check user permissions
154
+ ( false !== wp_is_post_revision( $post_id ) ) || // Return if it's a post revision
155
+ ( !wp_verify_nonce( $_POST['fvp_nonce'], plugin_basename( __FILE__ ) ) )
156
+ ) return;
157
+
158
+ $video = $_POST['fvp_video'] == $this->default_value ? '' : $_POST['fvp_video'];
159
+ $meta = unserialize( get_post_meta($post_id, '_fvp_video', true) );
160
+
161
+ if( empty($video) && isset($meta) ) {
162
+ delete_post_meta( $post_id, '_fvp_video' );
163
+ wp_delete_attachment( $this->get_post_by_custom_meta('_fvp_image', $meta['video_prov'] . '?' . $meta['video_id'] ) );
164
+ return;
165
+ }
166
+
167
+
168
+ if($video == $meta['full'])
169
+ return;
170
+
171
+ /*
172
+ REGEX tested using: http://www.rubular.com/
173
+
174
+ Tested URLs:
175
+ http://youtu.be/G_Oj7UI0-pw
176
+ https://youtu.be/G_Oj7UI0-pw
177
+ http://vimeo.com/32071937
178
+ https://vimeo.com/32071937
179
+ http://vimeo.com/32071937#embed
180
+ http://youtu.be/9Tjg6V1Eoz4?t=2m29s
181
+ http://www.youtube.com/watch?v=9Tjg6V1Eoz4&t=2m29s
182
+ http://www.youtube.com/watch?v=G_Oj7UI0-pw
183
+ http://www.youtube.com/watch?feature=blub&v=G_Oj7UI0-pw
184
+ */
185
+
186
+ $local = wp_upload_dir();
187
+ // match different provider(!)
188
+ preg_match('/(vimeo|youtu|'.preg_quote($local['baseurl'], '/').')/i', $video, $video_provider);
189
+ $video_prov = $video_provider[1] == "youtu" ? "youtube" : $video_provider[1];
190
+ /*if( $video_prov == $local['baseurl'] ) {
191
+
192
+ $video_id = $this->get_post_by_url($video);
193
+ $video_prov = 'local';
194
+
195
+ // get video from youtube
196
+ } else */
197
+ if( $video_prov == 'youtube' ) {
198
+
199
+ //match provider watch feature id(!) attr(!)
200
+ preg_match('/youtu(?:be\.com|\.be)\/(?:watch)?(?:\?feature=[^\?&]*)*(?:[\?&]v=)?([^\?&\s]+)(?:(?:[&\?]t=)(\d+m\d+s))?/', $video, $video_data);
201
+ $video_id = $video_data[1];
202
+ if( isset($video_data[2] ) )
203
+ $video_attr = $video_data[2];
204
+
205
+ // title, allow_embed 0/1, keywords, author, iurlmaxres, thumbnail_url, timestamp, avg_rating
206
+ $tmp = download_url( 'http://youtube.com/get_video_info?video_id=' . $video_id );
207
+ $data = file_get_contents($tmp);
208
+ parse_str($data, $data);
209
+ @unlink( $tmp );
210
+
211
+ // generate video metadata
212
+ $video_info = array(
213
+ 'title' => $data['title'],
214
+ 'description' => $data['keywords'],
215
+ 'filename' => sanitize_file_name($data['title']),
216
+ 'timestamp' => $data['timestamp'],
217
+ 'author' => $data['author'],
218
+ 'tags' => $data['keywords'],
219
+ 'img' => ( isset($data['iurlmaxres']) ? $data['iurlmaxres'] : 'http://img.youtube.com/vi/' . $video_id . '/0.jpg' )
220
+ );
221
+
222
+ // get video from vimeo
223
+ } else if( $video_prov == 'vimeo' ) {
224
+
225
+ preg_match('/vimeo.com\/([^#]+)/', $video, $video_data);
226
+ $video_id = $video_data[1];
227
+
228
+ // http://developer.vimeo.com/apis/simple
229
+ // title, description, upload_date, thumbnail_large, user_name, tags
230
+ $tmp = download_url( 'http://vimeo.com/api/v2/video/' . $video_id . '.php' );
231
+ $data = unserialize(file_get_contents($tmp));
232
+ @unlink( $tmp );
233
+
234
+ // generate video metadata
235
+ $video_info = array(
236
+ 'title' => $data[0]['title'],
237
+ 'description' => $data[0]['description'],
238
+ 'filename' => sanitize_file_name( $data[0]['title'] ),
239
+ 'timestamp' => strtotime( $data[0]['upload_date'] ),
240
+ 'author' => $data[0]['user_name'],
241
+ 'tags' => $data[0]['tags'],
242
+ 'img' => $data[0]['thumbnail_large']
243
+ );
244
+
245
+ }
246
+
247
+ // do we have a screen capture to pull?
248
+ if( !empty($video_info['img']) ) {
249
+
250
+ // is this screen capture already existing in our media library?
251
+ $video_img = $this->get_post_by_custom_meta('_fvp_image', $video_prov . '?' . $video_id);
252
+ if( !isset($video_img) ) {
253
+
254
+ // generate attachment post metadata
255
+ $video_img_data = array(
256
+ 'post_content' => $video_info['description'],
257
+ 'post_title' => $video_info['title'],
258
+ 'post_name' => $video_info['filename']
259
+ );
260
+
261
+ // pull external img to local server and add to media library
262
+ require_once( plugin_dir_path(__FILE__) . 'somatic_attach_external_image.php' );
263
+ $video_img = somatic_attach_external_image($video_info['img'], $post_id, false, $video_info['filename'], $video_img_data);
264
+
265
+ // generate picture metadata
266
+ $video_img_meta = wp_get_attachment_metadata( $video_img );
267
+ $video_img_meta['image_meta'] = array(
268
+ 'aperture' => 0,
269
+ 'credit' => $video_id,
270
+ 'camera' => $video_prov,
271
+ 'caption' => $video_info['description'],
272
+ 'created_timestamp' => $video_info['timestamp'],
273
+ 'copyright' => $video_info['author'],
274
+ 'focal_length' => 0,
275
+ 'iso' => 0,
276
+ 'shutter_speed' => 0,
277
+ 'title' => $video_info['title']
278
+ );
279
+
280
+ // save picture metadata
281
+ wp_update_attachment_metadata($video_img, $video_img_meta);
282
+ update_post_meta($video_img, '_fvp_image', $video_prov . '?' . $video_id);
283
+ }
284
+
285
+ // set_post_thumbnail was added in 3.1, limits the plugin to >=3.1
286
+ if( (get_bloginfo('version') >= 3.1) )
287
+ set_post_thumbnail( $post_id, $video_img );
288
+ }
289
+
290
+ $meta = array(
291
+ 'full' => $video,
292
+ 'id' => $video_id,
293
+ 'img' => $video_img,
294
+ 'prov' => $video_prov,
295
+ 'attr' => $video_attr
296
+ );
297
+ update_post_meta( $post_id, '_fvp_video', serialize($meta) );
298
+
299
+ return;
300
+ }
301
+
302
+ /**
303
+ * Initialises the plugin settings section, the settings fields and registers the options field and save function.
304
+ *
305
+ * @see http://codex.wordpress.org/Settings_API
306
+ * @since 1.0
307
+ */
308
+ function settings_init() {
309
+ add_settings_section('fvp-settings-section', 'Featured Video', array( &$this, 'settings_content' ), 'media');
310
+
311
+ add_settings_field('fvp-settings-overwrite', 'Replace featured images', array( &$this, 'settings_overwrite' ), 'media', 'fvp-settings-section');
312
+ add_settings_field('fvp-settings-width', 'Video width', array( &$this, 'settings_width' ), 'media', 'fvp-settings-section');
313
+ add_settings_field('fvp-settings-height', 'Video height', array( &$this, 'settings_height' ), 'media', 'fvp-settings-section');
314
+ add_settings_field('fvp-settings-vimeo', 'Vimeo Player Design', array( &$this, 'settings_vimeo' ), 'media', 'fvp-settings-section');
315
+ add_settings_field('fvp-settings-rate', 'Support', array( &$this, 'settings_rate' ), 'media', 'fvp-settings-section');
316
+
317
+ register_setting('media', 'fvp-settings', array( &$this, 'settings_save' ));
318
+ }
319
+
320
+ /**
321
+ * The settings section content. Describes the plugin settings, the php functions and the WordPress shortcode.
322
+ *
323
+ * @since 1.0
324
+ */
325
+ function settings_content() { ?>
326
+
327
+ <p>To display your featured videos you can either make use of the automatical replacement, use the <code>[featured-video]</code>-shortcode or manually edit your theme's source files to make use of the plugins PHP-functions.</p>
328
+ <table>
329
+ <tr style="vertical-align: top;">
330
+ <td style="width: 50%;">
331
+ <h4 style="margin-top: 0">WordPress Shortcode Usage</h4>
332
+ <table>
333
+ <tr style="vertical-align: top;">
334
+ <td><code>[featured-video]</code></td>
335
+ <td>Displays the video in its default size, if <code>width</code> below is set to <code>auto</code> 100%, elsewise 560px.</td>
336
+ </tr>
337
+ <tr style="vertical-align: top;">
338
+ <td><code>[featured-video width=300]</code></td>
339
+ <td>Displays the video with an width of 300 pixel. Height will be fitted to the aspect ratio.</td>
340
+ </tr>
341
+ </table>
342
+ </td>
343
+ <td style="width: 50%;">
344
+ <h4 style="margin-top: 0">PHP Function Reference</h4>
345
+ <ul>
346
+ <li><code>the_post_video(array(width, height), allow_fullscreen = true)</code></li>
347
+ <li><code>has_post_video(post_id = null)</code></li>
348
+ <li><code>get_the_post_video(post_id = null, array(width, height), allow_fullscreen = true)</code></li>
349
+ </ul>
350
+ <p class="description">
351
+ All parameters are optional. If <code>post_id == null</code> the current post's id will be used.
352
+ The functions are implemented with their <a href="http://codex.wordpress.org/Post_Thumbnails#Function_Reference" title="Post Thumbnails Function Reference">"featured image"-counterparts</a> in mind, they can be used the same way.
353
+ </p>
354
+ </td>
355
+ </tr>
356
+ </table>
357
+
358
+ <?php }
359
+
360
+ /**
361
+ * Displays the setting if the plugin should display the featured video in place of featured images.
362
+ *
363
+ * @since 1.0
364
+ */
365
+ function settings_overwrite() {
366
+ $options = get_option( 'fvp-settings' ); ?>
367
+
368
+ <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;
369
+ <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>
370
+ <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>
371
+
372
+ <?php }
373
+
374
+ /**
375
+ * Displays the setting if the plugin should fit the width of the videos automatically or use fixed widths.
376
+ *
377
+ * @since 1.0
378
+ */
379
+ function settings_width() {
380
+ $options = get_option( 'fvp-settings' ); ?>
381
+
382
+ <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;
383
+ <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>
384
+ <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>
385
+
386
+ <?php }
387
+
388
+ /**
389
+ * Displays the setting if the plugin should fit the height of the videos automatically to their width/height ratio or use fixed heights, which might result in black bars.
390
+ *
391
+ * @since 1.0
392
+ */
393
+ function settings_height() {
394
+ $options = get_option( 'fvp-settings' ); ?>
395
+
396
+ <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;
397
+ <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>
398
+ <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>
399
+
400
+ <?php }
401
+
402
+ /**
403
+ * Displays the settings to style the vimeo video player. Default: &amp;title=1&amp;portrait=0&amp;byline=1&amp;color=00adef
404
+ *
405
+ * @see http://developer.vimeo.com/player/embedding
406
+ * @see http://make.wordpress.org/core/2012/11/30/new-color-picker-in-wp-3-5/
407
+ * @see http://codex.wordpress.org/Function_Reference/wp_style_is
408
+ * @since 1.0
409
+ */
410
+ function settings_vimeo() {
411
+ $options = get_option( 'fvp-settings' ); ?>
412
+
413
+ <div style="position: relative; bottom: .6em;">
414
+ <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;
415
+ <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;
416
+ <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;
417
+ <span class="color-picker" style="position: relative;<?php if( wp_style_is( 'wp-color-picker', 'done' ) ) echo ' top: .6em;'; ?>" >
418
+ <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" />
419
+ <label for="fvp-settings-vimeo-color" style="display: none;">&nbsp;Color</label>
420
+ <?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 } ?>
421
+ </span>
422
+ </div>
423
+ <p class="description">These settings could be overwritten by videos from Vimeo Plus members.</p>
424
+
425
+ <?php }
426
+
427
+ /**
428
+ * Displays info about rating the plugin, giving feedback and requesting new features
429
+ *
430
+ * @since 1.0
431
+ */
432
+ function settings_rate() { ?>
433
+
434
+ <p>
435
+ Found a bug or <span style="font-weight: bold;">missing a specific video service</span>? <a href="http://wordpress.org/extend/plugins/featured-video/" title="Featured Video Plus Support Forum on wordpress.org" style="font-weight: bold;">Leave a note</a> in the plugins support forum!<br />
436
+ No? Than please <a href="http://wordpress.org/extend/plugins/featured-video/" title="Featured Video Plus on wordpress.org" style="font-weight: bold;">rate it</a>.<br />
437
+ </p>
438
+
439
+ <?php }
440
+
441
+ /**
442
+ * Function through which all settings are passed before they are saved. Validate the data.
443
+ *
444
+ * @since 1.0
445
+ */
446
+ function settings_save($input) {
447
+ $input['overwrite'] = $input['overwrite'] == 'true' ? true : false;
448
+
449
+ $input['vimeo']['portrait'] = $input['vimeo']['portrait'] == 'display' ? 1 : 0;
450
+ $input['vimeo']['title'] = $input['vimeo']['title'] == 'display' ? 1 : 0;
451
+ $input['vimeo']['byline'] = $input['vimeo']['byline'] == 'display' ? 1 : 0;
452
+ preg_match('/#?([0123456789abcdef]{3}[0123456789abcdef]{0,3})/i', $input['vimeo']['color'], $color);
453
+ $input['vimeo']['color'] = $color[1];
454
+ return $input;
455
+ }
456
+
457
+ /**
458
+ * Gets a post by an meta_key meta_value pair. Returns it's post_id.
459
+ *
460
+ * @see http://codex.wordpress.org/Class_Reference/wpdb
461
+ * @since 1.0
462
+ *
463
+ * @param string $meta_key which meta_key to look for
464
+ * @param string $meta_value which meta_value to look for
465
+ */
466
+ function get_post_by_custom_meta($meta_key, $meta_value) {
467
+ global $wpdb;
468
+ $id = $wpdb->get_var(
469
+ $wpdb->prepare(
470
+ "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key=%s AND meta_value=%s;",
471
+ $meta_key, $meta_value
472
+ )
473
+ );
474
+ return $id;
475
+ }
476
+
477
+ /**
478
+ * Gets post id by it's url / guid.
479
+ *
480
+ * @see http://codex.wordpress.org/Class_Reference/wpdb
481
+ * @since 1.0
482
+ *
483
+ * @param string $url which url to look for
484
+ */
485
+ function get_post_by_url($url) {
486
+ global $wpdb;
487
+ $id = $wpdb->get_var(
488
+ $wpdb->prepare(
489
+ "SELECT ID FROM {$wpdb->posts} WHERE guid=%s;",
490
+ $url
491
+ )
492
+ );
493
+ return $id;
494
+ }
495
+
496
+ }
497
+ ?>
php/frontend.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
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
10
+ *
11
+ * @param featured_video_plus instance
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
+ *
19
+ * @since 1.0
20
+ *
21
+ * @param featured_video_plus_instance required, dies without
22
+ */
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
+ *
44
+ * @see http://wordpress.stackexchange.com/a/41858
45
+ * @since 1.0
46
+ *
47
+ * @param string $html featured image html, ready to echo
48
+ * @param int $post_id id of target post
49
+ * @param int $post_thumbnail_id id of featured image
50
+ * @param string|array $size desired size of featured image / video
51
+ * @param array $attr
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
+ ?>
php/general.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
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
10
+ * @since 1.0
11
+ */
12
+ class featured_video_plus {
13
+
14
+ /**
15
+ * Returns the featured video html, ready to echo.
16
+ *
17
+ * @param int $post_id
18
+ * @param string|array $size
19
+ * @param bool $allowfullscreen
20
+ * @param bool $container
21
+ */
22
+ public function get_the_post_video($post_id = null, $size = array( 560, 315 ), $allowfullscreen = true, $container = true) {
23
+
24
+ if($post_id == null)
25
+ $post_id = $GLOBALS['post']->ID;
26
+
27
+ if( !$this->has_post_video($post_id) )
28
+ return false;
29
+
30
+ $meta = unserialize( get_post_meta($post_id, '_fvp_video', true) );
31
+ $options = get_option( 'fvp-settings' );
32
+
33
+ $width = $size[0];
34
+ $height = ($options['height'] == 'auto') ? round($width / 16 * 9) : $size[1];
35
+
36
+ if( isset($meta['id']) && !empty($meta['id']) ) {
37
+ /*if( $meta['prov'] == 'local' ) {
38
+
39
+ $ext = pathinfo($meta['full'], PATHINFO_EXTENSION);
40
+ //$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>';
41
+ //$embed = '<video width="' . $width . '" height="' . $height . '" controls><source src="' . $meta['full'] . '" type="video/' . $ext . '">Your browser does not support the video tag.</video>' . "\n";
42
+ $embed = '<video src="' . $meta['full'] . '" controls="controls" width="' . $width . '" height="' . $height . '"></video>';
43
+
44
+ } else*/
45
+ if( $meta['prov'] == 'vimeo' ) {
46
+
47
+ $options = get_option( 'fvp-settings' );
48
+ $fs = $allowfullscreen ? 'webkitAllowFullScreen mozallowfullscreen allowFullScreen' : '';
49
+ $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";
50
+ }elseif( $meta['prov'] == 'youtube' ) {
51
+
52
+ $fs = $allowfullscreen ? 'allowfullscreen' : '';
53
+ $attr = '#' . $meta['attr'];
54
+ $embed = "\n" . '<iframe width="'.$width.'" height="'.$height.'" src="http://www.youtube.com/embed/' . $meta['id'] . '?rel=0' . $attr . '" frameborder="0" ' . $fs . '></iframe>' . "\n";
55
+ }
56
+
57
+ if($container)
58
+ $embed = '<div class="featured_video_plus">' . $embed . '</div>';
59
+
60
+ return $embed;
61
+ }
62
+
63
+ }
64
+
65
+ /**
66
+ * Checks if current post or post provided by parameter has a featured video.
67
+ *
68
+ * @param int $post_id id of post to check for featured video
69
+ */
70
+ public function has_post_video($post_id = null){
71
+
72
+ if($post_id == null)
73
+ $post_id = $GLOBALS['post']->ID;
74
+
75
+ $meta = unserialize( get_post_meta( $post_id, '_fvp_video', true ) );
76
+
77
+ if( !isset($meta) || empty($meta['id']) )
78
+ return false;
79
+
80
+ return true;
81
+
82
+ }
83
+
84
+ /**
85
+ * Shortcode for usage in post or page entries. Echos the post's featured video.
86
+ *
87
+ * @param array $atts can contain the width and/or height how the featured video should be displayed in px, optional
88
+ */
89
+ function shortcode($atts){
90
+
91
+ $w = isset($atts['width']) ? $atts['width'] : '560';
92
+ $h = isset($atts['height']) ? $atts['height'] : '315';
93
+
94
+ if($this->has_post_video())
95
+ echo $this->get_the_post_video(null, $w, $h, true, false);
96
+
97
+ }
98
+ }
99
+ ?>
php/setup.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @param $case = false test parameter
16
+ */
17
+ function __construct( $case = false ) {
18
+ if ( ! $case )
19
+ wp_die( 'You should not call this class directly!', 'Doing it wrong!' );
20
+ }
21
+
22
+ /**
23
+ * Runs on activation, writes default settings to database.
24
+ */
25
+ function on_activate() {
26
+ $options = array(
27
+ 'overwrite' => true,
28
+ 'width' => 'auto',
29
+ 'height' => 'auto',
30
+ 'vimeo' => array(
31
+ 'portrait' => 0,
32
+ 'title' => 1,
33
+ 'byline' => 1,
34
+ 'color' => '00adef'
35
+ )
36
+ );
37
+ add_option( 'fvp-settings', $options );
38
+ }
39
+
40
+
41
+ /* *
42
+ * Runs on deactivation. Nothing to see here.
43
+ *
44
+ function on_deactivate() {
45
+
46
+ }*/
47
+
48
+ /**
49
+ * Runs on uninstallation, deletes all data including post&user metadata and video screen captures.
50
+ */
51
+ function on_uninstall() {
52
+ // important: check if the file is the one that was registered with the uninstall hook (function)
53
+ //if ( __FILE__ != WP_UNINSTALL_PLUGIN )
54
+ // return;
55
+
56
+ delete_option( 'fvp-settings' );
57
+
58
+ $post_types = get_post_types( array("public" => true) );
59
+ foreach( $post_types as $post_type ) {
60
+ if( $post_type != 'attachment' ) {
61
+ $allposts = get_posts('numberposts=-1&post_type=' . $post_type . '&post_status=any');
62
+ foreach( $allposts as $post ) {
63
+ $meta = unserialize(get_post_meta( $post->ID, '_fvp_video', true ));
64
+
65
+ wp_delete_attachment( $meta['img'] );
66
+ delete_post_meta($post->ID, '_fvp_video');
67
+ }
68
+ }
69
+ }
70
+
71
+ $users = array_merge( get_users( array( 'role' => 'Administrator' ) ), get_users( array( 'role' => 'Super Admin' ) ) );
72
+ foreach( $users as $user ) {
73
+ delete_user_meta( $user-ID, 'fvp_activation_notification_ignore' );
74
+ }
75
+
76
+ }
77
+
78
+ }
79
+ ?>
php/somatic_attach_external_image.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Download an image from the specified URL and attach it to a post.
4
+ * Modified version of core function media_sideload_image() in /wp-admin/includes/media.php (which returns an html img tag instead of attachment ID)
5
+ * Additional functionality: ability override actual filename, and to pass $post_data to override values in wp_insert_attachment (original only allowed $desc)
6
+ *
7
+ * @since 1.4 Somatic Framework
8
+ *
9
+ * @param string $url (required) The URL of the image to download
10
+ * @param int $post_id (required) The post ID the media is to be associated with
11
+ * @param bool $thumb (optional) Whether to make this attachment the Featured Image for the post (post_thumbnail)
12
+ * @param string $filename (optional) Replacement filename for the URL filename (do not include extension)
13
+ * @param array $post_data (optional) Array of key => values for wp_posts table (ex: 'post_title' => 'foobar', 'post_status' => 'draft')
14
+ * @return int|object The ID of the attachment or a WP_Error on failure
15
+ */
16
+ function somatic_attach_external_image( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
17
+ if ( !$url || !$post_id ) return new WP_Error('missing', "Need a valid URL and post ID...");
18
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
19
+ // Download file to temp location, returns full server path to temp file, ex; /home/user/public_html/mysite/wp-content/26192277_640.tmp
20
+ $tmp = download_url( $url );
21
+
22
+ // If error storing temporarily, unlink
23
+ if ( is_wp_error( $tmp ) ) {
24
+ @unlink($file_array['tmp_name']); // clean up
25
+ $file_array['tmp_name'] = '';
26
+ return $tmp; // output wp_error
27
+ }
28
+
29
+ preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches); // fix file filename for query strings
30
+ $url_filename = basename($matches[0]); // extract filename from url for title
31
+ $url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
32
+
33
+ // override filename if given, reconstruct server path
34
+ if ( !empty( $filename ) ) {
35
+ $filename = sanitize_file_name($filename);
36
+ $tmppath = pathinfo( $tmp ); // extract path parts
37
+ $new = $tmppath['dirname'] . "/". $filename . "." . $tmppath['extension']; // build new path
38
+ rename($tmp, $new); // renames temp file on server
39
+ $tmp = $new; // push new filename (in path) to be used in file array later
40
+ }
41
+
42
+ // assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
43
+ $file_array['tmp_name'] = $tmp; // full server path to temp file
44
+
45
+ if ( !empty( $filename ) ) {
46
+ $file_array['name'] = $filename . "." . $url_type['ext']; // user given filename for title, add original URL extension
47
+ } else {
48
+ $file_array['name'] = $url_filename; // just use original URL filename
49
+ }
50
+
51
+ // set additional wp_posts columns
52
+ if ( empty( $post_data['post_title'] ) ) {
53
+ $post_data['post_title'] = basename($url_filename, "." . $url_type['ext']); // just use the original filename (no extension)
54
+ }
55
+
56
+ // make sure gets tied to parent
57
+ if ( empty( $post_data['post_parent'] ) ) {
58
+ $post_data['post_parent'] = $post_id;
59
+ }
60
+
61
+ // required libraries for media_handle_sideload
62
+ require_once(ABSPATH . 'wp-admin/includes/file.php');
63
+ require_once(ABSPATH . 'wp-admin/includes/media.php');
64
+ require_once(ABSPATH . 'wp-admin/includes/image.php');
65
+
66
+ // do the validation and storage stuff
67
+ $att_id = media_handle_sideload( $file_array, $post_id, null, $post_data ); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
68
+
69
+ // If error storing permanently, unlink
70
+ if ( is_wp_error($att_id) ) {
71
+ @unlink($file_array['tmp_name']); // clean up
72
+ return $att_id; // output wp_error
73
+ }
74
+
75
+ // set as post thumbnail if desired
76
+ if ($thumb) {
77
+ set_post_thumbnail($post_id, $att_id);
78
+ }
79
+
80
+ return $att_id;
81
+ }
82
+ ?>
readme.txt ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Featured Video Plus ===
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, post, video, thumbnail, post thumbnail, image, flash, youtube, vimeo
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
9
+ 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.0
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
+ This plugin enables you to add videos as Featured Videos to posts and pages. A screen capture of the video will be added as Featured Image automatically and then by default be replaced by the video when viewing the site.
21
+ 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.
22
+
23
+ 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")) and __Vimeo__.
24
+ If you are missing a certain video platform: Leave a message in the supports forum.
25
+
26
+ After activating the plugin you will get some additions to your media settings, where you can choose how the videos will be size and some other stuff - have a look at the 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.
27
+
28
+ Shortcode:
29
+
30
+ [featured-video-plus]
31
+ [featured-video-plus width=300]
32
+
33
+
34
+ Theme functions:
35
+
36
+ the_post_video(array(width, height), fullscreen = true)
37
+ has_post_video(post_id)
38
+ get_the_post_video(post_id, size(width, height), fullscreen = true)
39
+
40
+ All parameters are optional. If no post_id is given the current post's id will be used.
41
+
42
+
43
+ This plugin was created after using the original [Featured Video](http://wordpress.org/extend/plugins/featured-video/) plugin with more features and a more seemless integration into WordPress in mind. I hope you like it, feel free to contact me by mail or post in the support forum.
44
+
45
+ == Installation ==
46
+
47
+ 1. Visit your WordPress Administration interface and go to Plugins -> Add New
48
+ 2. Search for "Featured Video Plus", and click "Install Now" below the plugins name
49
+ 3. When the installation finished, click "Activate Plugin"
50
+
51
+ The plugin is ready to go. Now edit your posts and add video links to the "Featured Video" box on the top right!
52
+ If you want to change some settings have a look under Settings -> Media.
53
+
54
+
55
+ == Changelog ==
56
+
57
+ = 1.0 =
58
+ * Release
59
+
60
+
61
+ == Screenshots ==
62
+
63
+ 1. Featured Video and Featured Image boxes on the post edit screen.
64
+ 2. A Featured Video in the Twenty Twelve theme.
65
+ 3. Settings -> Media screen
66
+
67
+
68
+ == Frequently Asked Questions ==
69
+
70
+ = After adding the URL and saving the post I do not get any video? =
71
+ 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
72
+ 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.
73
+
74
+ = What about other video portals? =
75
+ Leave me a note in the support forums which you would like and I will consider adding them in the next release.
76
+
77
+ = Are there translated versions? =
78
+ Not yet, but I will add translation capabilities soon.