Version Description
- Added support for TED Talks
- Improved error handling for AJAX on settings page
Download this release
Release Info
Developer | sutherlandboswell |
Plugin | Video Thumbnails |
Version | 2.8 |
Comparing to | |
See all releases |
Code changes from version 2.7.9 to 2.8
- js/settings.js +63 -15
- php/class-video-thumbnails-settings.php +1 -0
- php/providers/class-ted-thumbnails.php +71 -0
- php/providers/class-video-thumbnails-providers.php +1 -0
- readme.txt +6 -1
- video-thumbnails.php +2 -2
js/settings.js
CHANGED
@@ -6,11 +6,19 @@ jQuery(function ($) {
|
|
6 |
var data = {
|
7 |
action: 'video_thumbnail_custom_field_detection'
|
8 |
};
|
9 |
-
$.
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
});
|
16 |
});
|
@@ -21,8 +29,16 @@ jQuery(function ($) {
|
|
21 |
var data = {
|
22 |
action: 'video_thumbnail_image_download_test'
|
23 |
};
|
24 |
-
$.
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
});
|
27 |
});
|
28 |
|
@@ -32,8 +48,16 @@ jQuery(function ($) {
|
|
32 |
var data = {
|
33 |
action: 'video_thumbnail_delete_test_images'
|
34 |
};
|
35 |
-
$.
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
});
|
38 |
});
|
39 |
|
@@ -45,8 +69,16 @@ function test_video_thumbnail( test_type ) {
|
|
45 |
action: 'video_thumbnail_' + test_type + '_test'
|
46 |
};
|
47 |
document.getElementById( test_type + '-test' ).innerHTML = video_thumbnails_settings_language.working;
|
48 |
-
jQuery.
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
});
|
51 |
};
|
52 |
|
@@ -56,8 +88,16 @@ function test_video_thumbnail_markup_detection() {
|
|
56 |
markup: jQuery('#markup-input').val()
|
57 |
};
|
58 |
document.getElementById( 'markup-test-result' ).innerHTML = '<p>' + video_thumbnails_settings_language.working + '</p>';
|
59 |
-
jQuery.
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
});
|
62 |
}
|
63 |
|
@@ -70,8 +110,16 @@ function clear_all_video_thumbnails( nonce ) {
|
|
70 |
nonce: nonce
|
71 |
};
|
72 |
document.getElementById( 'clear-all-video-thumbnails-result' ).innerHTML = '<p>' + video_thumbnails_settings_language.working + '</p>';
|
73 |
-
jQuery.
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
});
|
76 |
}
|
77 |
else{
|
6 |
var data = {
|
7 |
action: 'video_thumbnail_custom_field_detection'
|
8 |
};
|
9 |
+
$.ajax({
|
10 |
+
type: "POST",
|
11 |
+
url: ajaxurl,
|
12 |
+
data: data,
|
13 |
+
success: function(response){
|
14 |
+
if (response) {
|
15 |
+
$('#custom_field').val(response);
|
16 |
+
} else {
|
17 |
+
alert(video_thumbnails_settings_language.detection_failed);
|
18 |
+
}
|
19 |
+
},
|
20 |
+
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
21 |
+
alert(video_thumbnails_settings_language.ajax_error + ' ' + XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);
|
22 |
}
|
23 |
});
|
24 |
});
|
29 |
var data = {
|
30 |
action: 'video_thumbnail_image_download_test'
|
31 |
};
|
32 |
+
$.ajax({
|
33 |
+
type: "POST",
|
34 |
+
url: ajaxurl,
|
35 |
+
data: data,
|
36 |
+
success: function(response){
|
37 |
+
$('#media-test-result').html(response);
|
38 |
+
},
|
39 |
+
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
40 |
+
$('#media-test-result').html('<p>' + video_thumbnails_settings_language.ajax_error + ' ' + XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText + '</p>');
|
41 |
+
}
|
42 |
});
|
43 |
});
|
44 |
|
48 |
var data = {
|
49 |
action: 'video_thumbnail_delete_test_images'
|
50 |
};
|
51 |
+
$.ajax({
|
52 |
+
type: "POST",
|
53 |
+
url: ajaxurl,
|
54 |
+
data: data,
|
55 |
+
success: function(response){
|
56 |
+
$('#media-test-result').html(response);
|
57 |
+
},
|
58 |
+
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
59 |
+
$('#media-test-result').html('<p>' + video_thumbnails_settings_language.ajax_error + ' ' + XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText + '</p>');
|
60 |
+
}
|
61 |
});
|
62 |
});
|
63 |
|
69 |
action: 'video_thumbnail_' + test_type + '_test'
|
70 |
};
|
71 |
document.getElementById( test_type + '-test' ).innerHTML = video_thumbnails_settings_language.working;
|
72 |
+
jQuery.ajax({
|
73 |
+
type: "POST",
|
74 |
+
url: ajaxurl,
|
75 |
+
data: data,
|
76 |
+
success: function(response){
|
77 |
+
document.getElementById( test_type + '-test' ).innerHTML = response;
|
78 |
+
},
|
79 |
+
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
80 |
+
document.getElementById( test_type + '-test' ).innerHTML = '<p>' + video_thumbnails_settings_language.ajax_error + ' ' + XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText + '</p>';
|
81 |
+
}
|
82 |
});
|
83 |
};
|
84 |
|
88 |
markup: jQuery('#markup-input').val()
|
89 |
};
|
90 |
document.getElementById( 'markup-test-result' ).innerHTML = '<p>' + video_thumbnails_settings_language.working + '</p>';
|
91 |
+
jQuery.ajax({
|
92 |
+
type: "POST",
|
93 |
+
url: ajaxurl,
|
94 |
+
data: data,
|
95 |
+
success: function(response){
|
96 |
+
document.getElementById( 'markup-test-result' ).innerHTML = response;
|
97 |
+
},
|
98 |
+
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
99 |
+
document.getElementById( 'markup-test-result' ).innerHTML = '<p>' + video_thumbnails_settings_language.ajax_error + ' ' + XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText + '</p>';
|
100 |
+
}
|
101 |
});
|
102 |
}
|
103 |
|
110 |
nonce: nonce
|
111 |
};
|
112 |
document.getElementById( 'clear-all-video-thumbnails-result' ).innerHTML = '<p>' + video_thumbnails_settings_language.working + '</p>';
|
113 |
+
jQuery.ajax({
|
114 |
+
type: "POST",
|
115 |
+
url: ajaxurl,
|
116 |
+
data: data,
|
117 |
+
success: function(response){
|
118 |
+
document.getElementById( 'clear-all-video-thumbnails-result' ).innerHTML = response;
|
119 |
+
},
|
120 |
+
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
121 |
+
document.getElementById( 'clear-all-video-thumbnails-result' ).innerHTML = '<p>' + video_thumbnails_settings_language.ajax_error + ' ' + XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText + '</p>';
|
122 |
+
}
|
123 |
});
|
124 |
}
|
125 |
else{
|
php/class-video-thumbnails-settings.php
CHANGED
@@ -140,6 +140,7 @@ class Video_Thumbnails_Settings {
|
|
140 |
wp_localize_script( 'video_thumbnails_settings', 'video_thumbnails_settings_language', array(
|
141 |
'detection_failed' => __( 'We were unable to find a video in the custom fields of your most recently updated post.', 'video-thumbnails' ),
|
142 |
'working' => __( 'Working...', 'video-thumbnails' ),
|
|
|
143 |
'clear_all_confirmation' => __( 'Are you sure you want to clear all video thumbnails? This cannot be undone.', 'video-thumbnails' ),
|
144 |
) );
|
145 |
}
|
140 |
wp_localize_script( 'video_thumbnails_settings', 'video_thumbnails_settings_language', array(
|
141 |
'detection_failed' => __( 'We were unable to find a video in the custom fields of your most recently updated post.', 'video-thumbnails' ),
|
142 |
'working' => __( 'Working...', 'video-thumbnails' ),
|
143 |
+
'ajax_error' => __( 'AJAX Error:', 'video-thumbnails' ),
|
144 |
'clear_all_confirmation' => __( 'Are you sure you want to clear all video thumbnails? This cannot be undone.', 'video-thumbnails' ),
|
145 |
) );
|
146 |
}
|
php/providers/class-ted-thumbnails.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* Copyright 2014 Sutherland Boswell (email : sutherland.boswell@gmail.com)
|
4 |
+
|
5 |
+
This program is free software; you can redistribute it and/or modify
|
6 |
+
it under the terms of the GNU General Public License, version 2, as
|
7 |
+
published by the Free Software Foundation.
|
8 |
+
|
9 |
+
This program is distributed in the hope that it will be useful,
|
10 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
+
GNU General Public License for more details.
|
13 |
+
|
14 |
+
You should have received a copy of the GNU General Public License
|
15 |
+
along with this program; if not, write to the Free Software
|
16 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
+
*/
|
18 |
+
|
19 |
+
// Require thumbnail provider class
|
20 |
+
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
|
21 |
+
|
22 |
+
class TED_Thumbnails extends Video_Thumbnails_Providers {
|
23 |
+
|
24 |
+
// Human-readable name of the video provider
|
25 |
+
public $service_name = 'TED';
|
26 |
+
const service_name = 'TED';
|
27 |
+
// Slug for the video provider
|
28 |
+
public $service_slug = 'ted';
|
29 |
+
const service_slug = 'ted';
|
30 |
+
|
31 |
+
public static function register_provider( $providers ) {
|
32 |
+
$providers[self::service_slug] = new self;
|
33 |
+
return $providers;
|
34 |
+
}
|
35 |
+
|
36 |
+
// Regex strings
|
37 |
+
public $regexes = array(
|
38 |
+
'#//embed\.ted\.com/talks/([A-Za-z0-9_-]+)\.html#', // iFrame SRC
|
39 |
+
);
|
40 |
+
|
41 |
+
// Thumbnail URL
|
42 |
+
public function get_thumbnail_url( $id ) {
|
43 |
+
$request = "http://www.ted.com/talks/oembed.json?url=http%3A%2F%2Fwww.ted.com%2Ftalks%2F$id";
|
44 |
+
$response = wp_remote_get( $request, array( 'sslverify' => false ) );
|
45 |
+
if( is_wp_error( $response ) ) {
|
46 |
+
$result = $this->construct_info_retrieval_error( $request, $response );
|
47 |
+
} else {
|
48 |
+
$result = json_decode( $response['body'] );
|
49 |
+
$result = $result->thumbnail_url;
|
50 |
+
}
|
51 |
+
return $result;
|
52 |
+
}
|
53 |
+
|
54 |
+
// Test cases
|
55 |
+
public static function get_test_cases() {
|
56 |
+
return array(
|
57 |
+
array(
|
58 |
+
'markup' => '<iframe src="http://embed.ted.com/talks/kitra_cahana_stories_of_the_homeless_and_hidden.html" width="640" height="360" frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>',
|
59 |
+
'expected' => 'http://images.ted.com/images/ted/341053090f8bac8c324c75be3114b673b4355e8a_480x360.jpg',
|
60 |
+
'expected_hash' => 'f2a5f6af49e841b4f9c7b95d6ca0372a',
|
61 |
+
'name' => __( 'iFrame Embed', 'video-thumbnails' )
|
62 |
+
),
|
63 |
+
);
|
64 |
+
}
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
// Add to provider array
|
69 |
+
add_filter( 'video_thumbnail_providers', array( 'TED_Thumbnails', 'register_provider' ) );
|
70 |
+
|
71 |
+
?>
|
php/providers/class-video-thumbnails-providers.php
CHANGED
@@ -117,6 +117,7 @@ require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-wistia-thumbnails.ph
|
|
117 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-youku-thumbnails.php' );
|
118 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-collegehumor-thumbnails.php' );
|
119 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-rutube-thumbnails.php' );
|
|
|
120 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-twitch-thumbnails.php' );
|
121 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-googledrive-thumbnails.php' );
|
122 |
|
117 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-youku-thumbnails.php' );
|
118 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-collegehumor-thumbnails.php' );
|
119 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-rutube-thumbnails.php' );
|
120 |
+
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-ted-thumbnails.php' );
|
121 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-twitch-thumbnails.php' );
|
122 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-googledrive-thumbnails.php' );
|
123 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ 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.9
|
7 |
-
Stable tag: 2.
|
8 |
|
9 |
Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
|
10 |
|
@@ -26,6 +26,7 @@ Video Thumbnails makes it easy to automatically display video thumbnails in your
|
|
26 |
* Twitch
|
27 |
* Dailymotion
|
28 |
* Metacafe
|
|
|
29 |
* VK
|
30 |
* Blip
|
31 |
* Google Drive
|
@@ -130,6 +131,10 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
|
|
130 |
|
131 |
== Changelog ==
|
132 |
|
|
|
|
|
|
|
|
|
133 |
= 2.7.9 =
|
134 |
* Better compatibility with image plugins
|
135 |
* Better Rutube support
|
4 |
Tags: Video, Thumbnails, YouTube, Vimeo, Vine, Twitch, Dailymotion, Youku, Rutube, Featured Image
|
5 |
Requires at least: 3.2
|
6 |
Tested up to: 3.9
|
7 |
+
Stable tag: 2.8
|
8 |
|
9 |
Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
|
10 |
|
26 |
* Twitch
|
27 |
* Dailymotion
|
28 |
* Metacafe
|
29 |
+
* TED
|
30 |
* VK
|
31 |
* Blip
|
32 |
* Google Drive
|
131 |
|
132 |
== Changelog ==
|
133 |
|
134 |
+
= 2.8 =
|
135 |
+
* Added support for TED Talks
|
136 |
+
* Improved error handling for AJAX on settings page
|
137 |
+
|
138 |
= 2.7.9 =
|
139 |
* Better compatibility with image plugins
|
140 |
* Better Rutube support
|
video-thumbnails.php
CHANGED
@@ -5,7 +5,7 @@ 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, VK, 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 |
Text Domain: video-thumbnails
|
11 |
Domain Path: /languages/
|
@@ -30,7 +30,7 @@ Domain Path: /languages/
|
|
30 |
|
31 |
define( 'VIDEO_THUMBNAILS_PATH', dirname(__FILE__) );
|
32 |
define( 'VIDEO_THUMBNAILS_FIELD', '_video_thumbnail' );
|
33 |
-
define( 'VIDEO_THUMBNAILS_VERSION', '2.
|
34 |
|
35 |
// Providers
|
36 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
|
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, VK, 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.8
|
9 |
License: GPL2
|
10 |
Text Domain: video-thumbnails
|
11 |
Domain Path: /languages/
|
30 |
|
31 |
define( 'VIDEO_THUMBNAILS_PATH', dirname(__FILE__) );
|
32 |
define( 'VIDEO_THUMBNAILS_FIELD', '_video_thumbnail' );
|
33 |
+
define( 'VIDEO_THUMBNAILS_VERSION', '2.8' );
|
34 |
|
35 |
// Providers
|
36 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
|