Version Description
- Added support for Video Thumbnails Pro, our new solution for power users and professional bloggers
- Various bugfixes and improvements
Download this release
Release Info
Developer | sutherlandboswell |
Plugin | Video Thumbnails |
Version | 2.5 |
Comparing to | |
See all releases |
Code changes from version 2.4.2 to 2.5
- js/bulk.js +36 -15
- php/class-video-thumbnails-settings.php +14 -3
- php/providers/class-vimeo-thumbnails.php +2 -0
- readme.txt +10 -2
- video-thumbnails.php +29 -6
js/bulk.js
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
jQuery(function ($) {
|
2 |
|
3 |
function VideoThumbnailsBulkScanner( posts ) {
|
@@ -17,13 +19,37 @@ jQuery(function ($) {
|
|
17 |
console.log(text);
|
18 |
};
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
VideoThumbnailsBulkScanner.prototype.startScan = function() {
|
|
|
21 |
this.paused = false;
|
22 |
if ( this.currentItem == 0 ) {
|
23 |
this.log( 'Started Scanning' );
|
24 |
this.progressBar.show();
|
25 |
this.resetProgressBar();
|
26 |
-
$('#video-thumbnails-scan-
|
27 |
} else {
|
28 |
this.log( 'Resumed Scanning' );
|
29 |
}
|
@@ -139,21 +165,16 @@ jQuery(function ($) {
|
|
139 |
|
140 |
};
|
141 |
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
e.preventDefault();
|
144 |
-
|
145 |
-
action: 'video_thumbnails_bulk_posts_query'
|
146 |
-
};
|
147 |
-
$.post(ajaxurl, data, function(response) {
|
148 |
-
var posts = $.parseJSON( response );
|
149 |
-
var r = confirm("This will scan " + posts.length + " posts, continue?");
|
150 |
-
if ( r == true ) {
|
151 |
-
x = new VideoThumbnailsBulkScanner( posts );
|
152 |
-
x.startScan();
|
153 |
-
} else {
|
154 |
-
x = "You pressed Cancel!";
|
155 |
-
}
|
156 |
-
});
|
157 |
});
|
158 |
|
159 |
});
|
1 |
+
var video_thumbnails_bulk_scanner;
|
2 |
+
|
3 |
jQuery(function ($) {
|
4 |
|
5 |
function VideoThumbnailsBulkScanner( posts ) {
|
19 |
console.log(text);
|
20 |
};
|
21 |
|
22 |
+
VideoThumbnailsBulkScanner.prototype.disableSubmit = function(text) {
|
23 |
+
$('#video-thumbnails-bulk-scan-options input[type="submit"]').attr('disabled','disabled');
|
24 |
+
};
|
25 |
+
|
26 |
+
VideoThumbnailsBulkScanner.prototype.enableSubmit = function(text) {
|
27 |
+
$('#video-thumbnails-bulk-scan-options input[type="submit"]').removeAttr('disabled');
|
28 |
+
};
|
29 |
+
|
30 |
+
VideoThumbnailsBulkScanner.prototype.findPosts = function(text) {
|
31 |
+
var data = {
|
32 |
+
action: 'video_thumbnails_bulk_posts_query',
|
33 |
+
params: $('#video-thumbnails-bulk-scan-options').serialize()
|
34 |
+
};
|
35 |
+
var self = this;
|
36 |
+
this.disableSubmit();
|
37 |
+
$('#queue-count').text('working...');
|
38 |
+
$.post(ajaxurl, data, function(response) {
|
39 |
+
self.posts = $.parseJSON( response );
|
40 |
+
$('#queue-count').text(self.posts.length+' posts');
|
41 |
+
self.enableSubmit();
|
42 |
+
});
|
43 |
+
};
|
44 |
+
|
45 |
VideoThumbnailsBulkScanner.prototype.startScan = function() {
|
46 |
+
this.disableSubmit();
|
47 |
this.paused = false;
|
48 |
if ( this.currentItem == 0 ) {
|
49 |
this.log( 'Started Scanning' );
|
50 |
this.progressBar.show();
|
51 |
this.resetProgressBar();
|
52 |
+
$('#video-thumbnails-bulk-scan-options').slideUp();
|
53 |
} else {
|
54 |
this.log( 'Resumed Scanning' );
|
55 |
}
|
165 |
|
166 |
};
|
167 |
|
168 |
+
video_thumbnails_bulk_scanner = new VideoThumbnailsBulkScanner();
|
169 |
+
video_thumbnails_bulk_scanner.findPosts();
|
170 |
+
|
171 |
+
$('#video-thumbnails-bulk-scan-options').on('change',function(e){
|
172 |
+
video_thumbnails_bulk_scanner.findPosts();
|
173 |
+
});
|
174 |
+
|
175 |
+
$('#video-thumbnails-bulk-scan-options').on('submit',function(e){
|
176 |
e.preventDefault();
|
177 |
+
video_thumbnails_bulk_scanner.startScan();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
});
|
179 |
|
180 |
});
|
php/class-video-thumbnails-settings.php
CHANGED
@@ -48,6 +48,8 @@ class Video_Thumbnails_Settings {
|
|
48 |
// Admin scripts
|
49 |
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_scripts' ) );
|
50 |
}
|
|
|
|
|
51 |
}
|
52 |
|
53 |
// Activation hook
|
@@ -567,13 +569,22 @@ class Video_Thumbnails_Settings {
|
|
567 |
}
|
568 |
?>
|
569 |
|
570 |
-
|
571 |
-
<p>All donations are appreciated!<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----"><input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"></form></p>
|
572 |
-
</div>
|
573 |
|
574 |
</div><?php
|
575 |
}
|
576 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
}
|
578 |
|
579 |
?>
|
48 |
// Admin scripts
|
49 |
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_scripts' ) );
|
50 |
}
|
51 |
+
// Add "Go Pro" call to action to settings footer
|
52 |
+
add_action( 'video_thumbnails/settings_footer', array( 'Video_Thumbnails_Settings', 'settings_footer' ) );
|
53 |
}
|
54 |
|
55 |
// Activation hook
|
569 |
}
|
570 |
?>
|
571 |
|
572 |
+
<?php do_action( 'video_thumbnails/settings_footer' ); ?>
|
|
|
|
|
573 |
|
574 |
</div><?php
|
575 |
}
|
576 |
|
577 |
+
public static function settings_footer() {
|
578 |
+
?>
|
579 |
+
<div style="width: 250px; margin: 20px 0; padding: 0 20px; background: #fff; border: 1px solid #dfdfdf; text-align: center;">
|
580 |
+
<div>
|
581 |
+
<p>Support video thumbnails and unlock additional features</p>
|
582 |
+
<p><a href="https://refactored.co/plugins/video-thumbnails" class="button button-primary button-large">Go Pro</a></p>
|
583 |
+
</div>
|
584 |
+
</div>
|
585 |
+
<?php
|
586 |
+
}
|
587 |
+
|
588 |
}
|
589 |
|
590 |
?>
|
php/providers/class-vimeo-thumbnails.php
CHANGED
@@ -90,6 +90,8 @@ class Vimeo_Thumbnails extends Video_Thumbnails_Providers {
|
|
90 |
$result = new WP_Error( 'vimeo_info_retrieval', __( 'Error retrieving video information from the URL <a href="' . $request . '">' . $request . '</a> using <code>wp_remote_get()</code><br />If opening that URL in your web browser returns anything else than an error page, the problem may be related to your web server and might be something your host administrator can solve.<br />Details: ' . $response->get_error_message() ) );
|
91 |
} elseif ( $response['response']['code'] == 404 ) {
|
92 |
$result = new WP_Error( 'vimeo_info_retrieval', __( 'The Vimeo endpoint located at <a href="' . $request . '">' . $request . '</a> returned a 404 error.<br />Details: ' . $response['response']['message'] ) );
|
|
|
|
|
93 |
} else {
|
94 |
$xml = new SimpleXMLElement( $response['body'] );
|
95 |
$result = (string) $xml->thumbnail_url;
|
90 |
$result = new WP_Error( 'vimeo_info_retrieval', __( 'Error retrieving video information from the URL <a href="' . $request . '">' . $request . '</a> using <code>wp_remote_get()</code><br />If opening that URL in your web browser returns anything else than an error page, the problem may be related to your web server and might be something your host administrator can solve.<br />Details: ' . $response->get_error_message() ) );
|
91 |
} elseif ( $response['response']['code'] == 404 ) {
|
92 |
$result = new WP_Error( 'vimeo_info_retrieval', __( 'The Vimeo endpoint located at <a href="' . $request . '">' . $request . '</a> returned a 404 error.<br />Details: ' . $response['response']['message'] ) );
|
93 |
+
} elseif ( $response['response']['code'] == 403 ) {
|
94 |
+
$result = new WP_Error( 'vimeo_info_retrieval', __( 'The Vimeo endpoint located at <a href="' . $request . '">' . $request . '</a> returned a 403 error.<br />This can occur when a video has embedding disabled or restricted to certain domains. Try entering API credentials in the provider settings.' ) );
|
95 |
} else {
|
96 |
$xml = new SimpleXMLElement( $response['body'] );
|
97 |
$result = (string) $xml->thumbnail_url;
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: sutherlandboswell
|
3 |
Donate link: http://wie.ly/u/donate
|
4 |
Tags: Video, Thumbnails, YouTube, Vimeo, Vine, Twitch, Dailymotion, Youku, Rutube, Featured Image
|
5 |
-
Requires at least: 3.
|
6 |
Tested up to: 3.8
|
7 |
-
Stable tag: 2.
|
8 |
|
9 |
Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
|
10 |
|
@@ -12,6 +12,8 @@ Video Thumbnails simplifies the process of automatically displaying video thumbn
|
|
12 |
|
13 |
Video Thumbnails makes it easy to automatically display video thumbnails in your template. When you publish a post, this plugin will find the first video embedded and locate the thumbnail for you. Thumbnails can be saved to your media library and set as a featured image automatically. There's even support for custom post types and custom fields!
|
14 |
|
|
|
|
|
15 |
Video Thumbnails currently supports these video services:
|
16 |
|
17 |
* YouTube
|
@@ -40,6 +42,8 @@ Video Thumbnails even works with most video embedding plugins, including:
|
|
40 |
* [Vimeo Shortcode](http://blog.esimplestudios.com/2010/08/embedding-vimeo-videos-in-wordpress/)
|
41 |
* [WP YouTube Lyte](http://wordpress.org/extend/plugins/wp-youtube-lyte/)
|
42 |
|
|
|
|
|
43 |
Some functions are available to advanced users who want to customize their theme:
|
44 |
|
45 |
* `<?php video_thumbnail(); ?>` will echo a thumbnail URL or the default image located at `wp-content/plugins/video-thumbnails/default.jpg` if a thumbnail cannot be found. Here is an example: `<img src="<?php video_thumbnail(); ?>" width="300" />`
|
@@ -111,6 +115,10 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
|
|
111 |
|
112 |
== Changelog ==
|
113 |
|
|
|
|
|
|
|
|
|
114 |
= 2.4.2 =
|
115 |
* Fixed bug with image download test
|
116 |
|
2 |
Contributors: sutherlandboswell
|
3 |
Donate link: http://wie.ly/u/donate
|
4 |
Tags: Video, Thumbnails, YouTube, Vimeo, Vine, Twitch, Dailymotion, Youku, Rutube, Featured Image
|
5 |
+
Requires at least: 3.2
|
6 |
Tested up to: 3.8
|
7 |
+
Stable tag: 2.5
|
8 |
|
9 |
Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
|
10 |
|
12 |
|
13 |
Video Thumbnails makes it easy to automatically display video thumbnails in your template. When you publish a post, this plugin will find the first video embedded and locate the thumbnail for you. Thumbnails can be saved to your media library and set as a featured image automatically. There's even support for custom post types and custom fields!
|
14 |
|
15 |
+
**New!** Get even more power with [Video Thumbnails Pro](https://refactored.co/plugins/video-thumbnails). Enjoy features like maximum image sizes, more powerful bulk scanning options, a customizable upload directory, and more!
|
16 |
+
|
17 |
Video Thumbnails currently supports these video services:
|
18 |
|
19 |
* YouTube
|
42 |
* [Vimeo Shortcode](http://blog.esimplestudios.com/2010/08/embedding-vimeo-videos-in-wordpress/)
|
43 |
* [WP YouTube Lyte](http://wordpress.org/extend/plugins/wp-youtube-lyte/)
|
44 |
|
45 |
+
Video Thumbnails will always be totally free while remaining a full-featured plugin, but if you'd like to support the developer consider purchasing [Video Thumbnails Pro](https://refactored.co/plugins/video-thumbnails). The pro version runs alongside the standard version and adds additional features like maximum image sizes, more powerful bulk scanning options, a customizable upload directory, and more!
|
46 |
+
|
47 |
Some functions are available to advanced users who want to customize their theme:
|
48 |
|
49 |
* `<?php video_thumbnail(); ?>` will echo a thumbnail URL or the default image located at `wp-content/plugins/video-thumbnails/default.jpg` if a thumbnail cannot be found. Here is an example: `<img src="<?php video_thumbnail(); ?>" width="300" />`
|
115 |
|
116 |
== Changelog ==
|
117 |
|
118 |
+
= 2.5 =
|
119 |
+
* Added support for [Video Thumbnails Pro](https://refactored.co/plugins/video-thumbnails), our new solution for power users and professional bloggers
|
120 |
+
* Various bugfixes and improvements
|
121 |
+
|
122 |
= 2.4.2 =
|
123 |
* Fixed bug with image download test
|
124 |
|
video-thumbnails.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Video Thumbnails
|
4 |
-
Plugin URI:
|
5 |
Description: Automatically retrieve video thumbnails for your posts and display them in your theme. Supports YouTube, Vimeo, Facebook, Vine, Justin.tv, Twitch, Dailymotion, Metacafe, Blip, Google Drive, Funny or Die, CollegeHumor, MPORA, Wistia, Youku, and Rutube.
|
6 |
Author: Sutherland Boswell
|
7 |
Author URI: http://sutherlandboswell.com
|
8 |
-
Version: 2.
|
9 |
License: GPL2
|
10 |
*/
|
11 |
/* Copyright 2014 Sutherland Boswell (email : sutherland.boswell@gmail.com)
|
@@ -28,7 +28,7 @@ License: GPL2
|
|
28 |
|
29 |
define( 'VIDEO_THUMBNAILS_PATH', dirname(__FILE__) );
|
30 |
define( 'VIDEO_THUMBNAILS_FIELD', '_video_thumbnail' );
|
31 |
-
define( 'VIDEO_THUMBNAILS_VERSION', '2.
|
32 |
|
33 |
// Providers
|
34 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
|
@@ -300,7 +300,7 @@ class Video_Thumbnails {
|
|
300 |
}
|
301 |
|
302 |
// Saves to media library
|
303 |
-
public function save_to_media_library( $image_url, $post_id ) {
|
304 |
|
305 |
$error = '';
|
306 |
$response = wp_remote_get( $image_url, array( 'sslverify' => false ) );
|
@@ -323,7 +323,9 @@ class Video_Thumbnails {
|
|
323 |
$new_filename = self::construct_filename( $post_id ) . $image_extension;
|
324 |
|
325 |
// Save the image bits using the new filename
|
|
|
326 |
$upload = wp_upload_bits( $new_filename, null, $image_contents );
|
|
|
327 |
|
328 |
// Stop for any errors while saving the data or else continue adding the image to the media library
|
329 |
if ( $upload['error'] ) {
|
@@ -331,6 +333,8 @@ class Video_Thumbnails {
|
|
331 |
return $error;
|
332 |
} else {
|
333 |
|
|
|
|
|
334 |
$image_url = $upload['url'];
|
335 |
|
336 |
$filename = $upload['file'];
|
@@ -399,11 +403,18 @@ class Video_Thumbnails {
|
|
399 |
}
|
400 |
|
401 |
function bulk_posts_query_callback() {
|
|
|
402 |
$args = array(
|
403 |
-
'
|
404 |
'post_type' => $this->settings->options['post_types'],
|
405 |
'fields' => 'ids'
|
406 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
$query = new WP_Query( $args );
|
408 |
echo json_encode( $query->posts );
|
409 |
die();
|
@@ -450,7 +461,19 @@ class Video_Thumbnails {
|
|
450 |
|
451 |
<p>Use this tool to scan all of your posts for Video Thumbnails.</p>
|
452 |
|
453 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
|
455 |
<div id="vt-bulk-scan-results">
|
456 |
<div class="progress-bar-container">
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Video Thumbnails
|
4 |
+
Plugin URI: https://refactored.co/plugins/video-thumbnails
|
5 |
Description: Automatically retrieve video thumbnails for your posts and display them in your theme. Supports YouTube, Vimeo, Facebook, Vine, Justin.tv, Twitch, Dailymotion, Metacafe, Blip, Google Drive, Funny or Die, CollegeHumor, MPORA, Wistia, Youku, and Rutube.
|
6 |
Author: Sutherland Boswell
|
7 |
Author URI: http://sutherlandboswell.com
|
8 |
+
Version: 2.5
|
9 |
License: GPL2
|
10 |
*/
|
11 |
/* Copyright 2014 Sutherland Boswell (email : sutherland.boswell@gmail.com)
|
28 |
|
29 |
define( 'VIDEO_THUMBNAILS_PATH', dirname(__FILE__) );
|
30 |
define( 'VIDEO_THUMBNAILS_FIELD', '_video_thumbnail' );
|
31 |
+
define( 'VIDEO_THUMBNAILS_VERSION', '2.5' );
|
32 |
|
33 |
// Providers
|
34 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
|
300 |
}
|
301 |
|
302 |
// Saves to media library
|
303 |
+
public static function save_to_media_library( $image_url, $post_id ) {
|
304 |
|
305 |
$error = '';
|
306 |
$response = wp_remote_get( $image_url, array( 'sslverify' => false ) );
|
323 |
$new_filename = self::construct_filename( $post_id ) . $image_extension;
|
324 |
|
325 |
// Save the image bits using the new filename
|
326 |
+
do_action( 'video_thumbnails/pre_upload_bits', $image_contents );
|
327 |
$upload = wp_upload_bits( $new_filename, null, $image_contents );
|
328 |
+
do_action( 'video_thumbnails/after_upload_bits', $upload );
|
329 |
|
330 |
// Stop for any errors while saving the data or else continue adding the image to the media library
|
331 |
if ( $upload['error'] ) {
|
333 |
return $error;
|
334 |
} else {
|
335 |
|
336 |
+
do_action( 'video_thumbnails/image_downloaded', $upload['file'] );
|
337 |
+
|
338 |
$image_url = $upload['url'];
|
339 |
|
340 |
$filename = $upload['file'];
|
403 |
}
|
404 |
|
405 |
function bulk_posts_query_callback() {
|
406 |
+
// Some default args
|
407 |
$args = array(
|
408 |
+
'posts_per_page' => -1,
|
409 |
'post_type' => $this->settings->options['post_types'],
|
410 |
'fields' => 'ids'
|
411 |
);
|
412 |
+
// Setup an array for any form data and parse the jQuery serialized data
|
413 |
+
$form_data = array();
|
414 |
+
parse_str( $_POST['params'], $form_data );
|
415 |
+
|
416 |
+
$args = apply_filters( 'video_thumbnails/bulk_posts_query', $args, $form_data );
|
417 |
+
|
418 |
$query = new WP_Query( $args );
|
419 |
echo json_encode( $query->posts );
|
420 |
die();
|
461 |
|
462 |
<p>Use this tool to scan all of your posts for Video Thumbnails.</p>
|
463 |
|
464 |
+
<form id="video-thumbnails-bulk-scan-options">
|
465 |
+
<table class="form-table">
|
466 |
+
<tbody>
|
467 |
+
<?php do_action( 'video_thumbnails/bulk_options_form'); ?>
|
468 |
+
<tr valign="top">
|
469 |
+
<th scope="row"><span id="queue-count">...</span></th>
|
470 |
+
<td>
|
471 |
+
<input type="submit" value="Scan Now" class="button button-primary">
|
472 |
+
</td>
|
473 |
+
</tr>
|
474 |
+
</tbody>
|
475 |
+
</table>
|
476 |
+
</form>
|
477 |
|
478 |
<div id="vt-bulk-scan-results">
|
479 |
<div class="progress-bar-container">
|