Video Thumbnails - Version 1.7

Version Description

  • Added new option to scan past posts for video thumbnails
Download this release

Release Info

Developer sutherlandboswell
Plugin Icon 128x128 Video Thumbnails
Version 1.7
Comparing to
See all releases

Code changes from version 1.6 to 1.7

Files changed (2) hide show
  1. readme.txt +5 -1
  2. video-thumbnails.php +100 -2
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://amzn.com/w/1L25YG6FO8AZ1
4
  Tags: Video, YouTube, Vimeo, Blip.tv, Justin.tv, Thumbnails
5
  Requires at least: 3.0
6
  Tested up to: 3.1
7
- Stable tag: 1.6
8
 
9
  Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
10
 
@@ -82,6 +82,9 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
82
 
83
  == Changelog ==
84
 
 
 
 
85
  = 1.6 =
86
  * Added support for custom post types
87
 
@@ -196,6 +199,7 @@ This version adds the thumbnail URL to the post's meta data, meaning any outside
196
 
197
  This plugin is still very young, and has a future planned as the ultimate plugin for video thumbnails. Here's some of the planned additions:
198
 
 
199
  * Better Blip.tv support
200
  * More services
201
  * Option to display video thumbnails on the admin post list page
4
  Tags: Video, YouTube, Vimeo, Blip.tv, Justin.tv, Thumbnails
5
  Requires at least: 3.0
6
  Tested up to: 3.1
7
+ Stable tag: 1.7
8
 
9
  Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
10
 
82
 
83
  == Changelog ==
84
 
85
+ = 1.7 =
86
+ * Added new option to scan past posts for video thumbnails
87
+
88
  = 1.6 =
89
  * Added support for custom post types
90
 
199
 
200
  This plugin is still very young, and has a future planned as the ultimate plugin for video thumbnails. Here's some of the planned additions:
201
 
202
+ * DailyMotion and MetaCafe support coming very soon!
203
  * Better Blip.tv support
204
  * More services
205
  * Option to display video thumbnails on the admin post list page
video-thumbnails.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://sutherlandboswell.com/2010/11/wordpress-video-thumbnails/
5
  Description: Automatically retrieve video thumbnails for your posts and display them in your theme. Currently supports YouTube, Vimeo, Blip.tv, and Justin.tv.
6
  Author: Sutherland Boswell
7
  Author URI: http://sutherlandboswell.com
8
- Version: 1.6
9
  License: GPL2
10
  */
11
  /* Copyright 2010 Sutherland Boswell (email : sutherland.boswell@gmail.com)
@@ -278,10 +278,14 @@ function video_thumbnail_admin(){
278
 
279
  // AJAX Searching
280
 
281
- add_action('admin_head', 'video_thumbnails_ajax');
 
 
282
 
283
  function video_thumbnails_ajax() {
284
  ?>
 
 
285
  <script type="text/javascript" >
286
  function video_thumbnails_reset(id) {
287
 
@@ -369,6 +373,92 @@ function video_thumbnails_curl_check(){
369
  }
370
  }
371
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
  // Aministration
373
 
374
  add_action('admin_menu', 'video_thumbnails_menu');
@@ -442,7 +532,15 @@ function video_thumbnails_checkbox_option($option_name, $option_description) { ?
442
  <input type="hidden" name="page_options" value="video_thumbnails_save_media,video_thumbnails_set_featured,video_thumbnails_post_types" />
443
 
444
  </form>
 
 
 
 
 
 
445
 
 
 
446
 
447
  </div>
448
 
5
  Description: Automatically retrieve video thumbnails for your posts and display them in your theme. Currently supports YouTube, Vimeo, Blip.tv, and Justin.tv.
6
  Author: Sutherland Boswell
7
  Author URI: http://sutherlandboswell.com
8
+ Version: 1.7
9
  License: GPL2
10
  */
11
  /* Copyright 2010 Sutherland Boswell (email : sutherland.boswell@gmail.com)
278
 
279
  // AJAX Searching
280
 
281
+ if ( in_array( basename($_SERVER['PHP_SELF']), apply_filters( 'video_thumbnails_editor_pages', array('post-new.php', 'page-new.php', 'post.php', 'page.php') ) ) ) {
282
+ add_action('admin_head', 'video_thumbnails_ajax');
283
+ }
284
 
285
  function video_thumbnails_ajax() {
286
  ?>
287
+
288
+ <!-- Video Thumbnails Researching Ajax -->
289
  <script type="text/javascript" >
290
  function video_thumbnails_reset(id) {
291
 
373
  }
374
  }
375
 
376
+ // AJAX for Past Posts
377
+
378
+ if ( isset ( $_GET['page'] ) && ( $_GET['page'] == 'video-thumbnail-options' ) ) {
379
+ add_action('admin_head', 'video_thumbnails_past_ajax');
380
+ }
381
+
382
+ function video_thumbnails_past_ajax() {
383
+ ?>
384
+
385
+ <!-- Video Thumbnails Past Post Ajax -->
386
+ <script type="text/javascript" >
387
+ function video_thumbnails_past(id) {
388
+
389
+ var data = {
390
+ action: 'video_thumbnails_past',
391
+ post_id: id
392
+ };
393
+
394
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
395
+ jQuery.post(ajaxurl, data, function(response) {
396
+
397
+
398
+ document.getElementById(id+'_result').innerHTML = response;
399
+
400
+ });
401
+
402
+ };
403
+
404
+ <?php
405
+ $video_thumbnails_post_types = get_option('video_thumbnails_post_types');
406
+ $posts = get_posts(array('showposts'=>-1,'post_type'=>$video_thumbnails_post_types));
407
+
408
+ if ($posts) {
409
+ foreach($posts as $post) {
410
+ $post_ids[] = $post->ID;
411
+ }
412
+ $ids = implode(',',$post_ids);
413
+ }
414
+ ?>
415
+
416
+ var scanComplete = false;
417
+
418
+ function scan_video_thumbnails(){
419
+
420
+ if(scanComplete==false){
421
+ scanComplete = true;
422
+ var ids = new Array(<?php echo $ids; ?>);
423
+ for (var i = 0; i < ids.length; i++){
424
+ var container = document.getElementById('video-thumbnails-past');
425
+ var new_element = document.createElement('li');
426
+ new_element.setAttribute('id',ids[i]+'_result');
427
+ new_element.innerHTML = 'Waiting...';
428
+ container.insertBefore(new_element, container.firstChild);
429
+ }
430
+ for (var i = 0; i < ids.length; i++){
431
+ document.getElementById(ids[i]+'_result').innerHTML = '<span style="color:yellow">&#8226;</span> Working...';
432
+ video_thumbnails_past(ids[i]);
433
+ }
434
+ } else {
435
+ alert('Scan has already been run, please reload the page before trying again.')
436
+ }
437
+
438
+ }
439
+ </script>
440
+
441
+ <?php
442
+ }
443
+
444
+ add_action('wp_ajax_video_thumbnails_past', 'video_thumbnails_past_callback');
445
+
446
+ function video_thumbnails_past_callback() {
447
+ global $wpdb; // this is how you get access to the database
448
+
449
+ $post_id = $_POST['post_id'];
450
+
451
+ echo get_the_title($post_id) . ' - ';
452
+
453
+ if ( ($video_thumbnail=get_video_thumbnail($post_id)) != null ) {
454
+ echo '<span style="color:green">&#10004;</span> Success!';
455
+ } else {
456
+ echo '<span style="color:red">&#10006;</span> Couldn\'t find a video thumbnail for this post.';
457
+ }
458
+
459
+ die();
460
+ }
461
+
462
  // Aministration
463
 
464
  add_action('admin_menu', 'video_thumbnails_menu');
532
  <input type="hidden" name="page_options" value="video_thumbnails_save_media,video_thumbnails_set_featured,video_thumbnails_post_types" />
533
 
534
  </form>
535
+
536
+ <h3>Scan All Posts</h3>
537
+
538
+ <p>Scan all of your past posts for video thumbnails. Be sure to save any settings before running the scan.</p>
539
+
540
+ <p><input type="submit" class="button-primary" onclick="scan_video_thumbnails();" value="Scan Past Posts" /></p>
541
 
542
+ <ol id="video-thumbnails-past">
543
+ </ol>
544
 
545
  </div>
546