Google XML Sitemap for Videos - Version 2.2.1

Version Description

Download this release

Release Info

Developer labnol
Plugin Icon wp plugin Google XML Sitemap for Videos
Version 2.2.1
Comparing to
See all releases

Code changes from version 2.2 to 2.2.1

Files changed (2) hide show
  1. readme.txt +7 -2
  2. video-sitemap.php +19 -14
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: labnol
3
  Tags: youtube, xml sitemaps, google sitemaps, videos, seo, sitemaps, video sitemap
4
  Requires at least: 2.9.2
5
- Tested up to: 3.0.1
6
- Stable tag: 2.2
7
 
8
  This plugin will help you generate Google Video Sitemaps (XML) for your WordPress blog.
9
 
@@ -62,6 +62,11 @@ The Sitemaps protocol enables you to let search engines know what content you wo
62
 
63
  == Changelog ==
64
 
 
 
 
 
 
65
  = 2.2 =
66
  * fixed - The sitemaps protocol allows only one category per video
67
  * fixed - location of sitemap in the error messages - thanks @ashishmohta
2
  Contributors: labnol
3
  Tags: youtube, xml sitemaps, google sitemaps, videos, seo, sitemaps, video sitemap
4
  Requires at least: 2.9.2
5
+ Tested up to: 3.1.2
6
+ Stable tag: 2.3
7
 
8
  This plugin will help you generate Google Video Sitemaps (XML) for your WordPress blog.
9
 
62
 
63
  == Changelog ==
64
 
65
+ = 2.3 =
66
+ * added - Support for IFRAME based YouTube embeds
67
+ * fixed - Improved discovery code for YouTube videos
68
+ * added - The plugin ensures that no video is included twice in the XML sitemap
69
+
70
  = 2.2 =
71
  * fixed - The sitemaps protocol allows only one category per video
72
  * fixed - location of sitemap in the error messages - thanks @ashishmohta
video-sitemap.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Google XML Sitemap for Videos
4
  Plugin URI: http://www.labnol.org/software/xml-video-sitemaps-for-google/14085/
5
  Description: This plugin will generate a XML Video Sitemap for your WordPress blog. Open the <a href="tools.php?page=video-sitemap-generate-page">settings page</a> to create your video sitemap.
6
  Author: Amit Agarwal
7
- Version: 2.2
8
  Author URI: http://www.labnol.org/
9
  */
10
 
@@ -62,7 +62,7 @@ exit();
62
  <iframe src="http://www.facebook.com/plugins/likebox.php?id=5791561181&amp;width=250&amp;height=260&amp;connections=8&amp;stream=false&amp;header=false" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:250px; height:260px"></iframe>
63
  </div>
64
  <h2>XML Sitemap for Videos</h2>
65
- <?php $sitemapurl = $_SERVER["DOCUMENT_ROOT"] . "/sitemap-video.xml"; ?>
66
  <p>The XML Sitemap was generated successfully. Please open the <a target="_blank" href="<?php echo $sitemapurl; ?>">Sitemap file</a> in your favorite web browser to confirm that there are no errors.</p>
67
  <p>You can submit your Video XML Sitemap through <a href="http://www.google.com/webmasters/tools/" target="_blank">Webmaster Tools</a> or you can directly <a target="_blank" href="http://www.google.com/webmasters/sitemaps/ping?sitemap=<?php echo $sitemapurl; ?>">ping Google</a>.</p>
68
  <h3>Suggestions?</h3>
@@ -107,26 +107,31 @@ function video_sitemap_loop () {
107
  $xml .= '<!-- Generated-on="' . date("F j, Y, g:i a") .'" -->' . "\n";
108
  $xml .= '<?xml-stylesheet type="text/xsl" href="' . get_bloginfo('wpurl') . '/wp-content/plugins/xml-sitemaps-for-videos/video-sitemap.xsl"?>' . "\n" ;
109
  $xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">' . "\n";
 
 
110
 
111
  foreach ($posts as $post) {
112
- if (preg_match_all ("(<embed[^>]*src=['\"]http:\/\/www.youtube.com\/v\/([a-zA-Z0-9\-_]*)|youtube.com\/watch\?v=([a-zA-Z0-9\-_]*))",
113
- $post->post_content, $matches, PREG_SET_ORDER)) {
114
 
115
  $excerpt = ($post->post_excerpt != "") ? $post->post_excerpt : $post->post_title ;
116
  $permalink = get_permalink($post->id);
117
 
118
  foreach ($matches as $match) {
119
- $id = $match [1];
120
- if ($id == '') $id = $match [2];
121
- if ($id == '') $id = $match [3];
122
 
123
- $xml .= "\n <url>\n";
124
- $xml .= " <loc>$permalink</loc>\n";
125
- $xml .= " <video:video>\n";
126
- $xml .= " <video:player_loc allow_embed=\"yes\" autoplay=\"autoplay=1\">http://www.youtube.com/v/$id</video:player_loc>\n";
127
- $xml .= " <video:thumbnail_loc>http://i.ytimg.com/vi/$id/2.jpg</video:thumbnail_loc>\n";
128
- $xml .= " <video:title>" . htmlspecialchars($post->post_title) . "</video:title>\n";
129
- $xml .= " <video:description>" . htmlspecialchars($excerpt) . "</video:description>\n";
 
 
 
 
 
130
 
131
  if ($_POST['time'] == 1) {
132
  $duration = youtube_duration ($id);
4
  Plugin URI: http://www.labnol.org/software/xml-video-sitemaps-for-google/14085/
5
  Description: This plugin will generate a XML Video Sitemap for your WordPress blog. Open the <a href="tools.php?page=video-sitemap-generate-page">settings page</a> to create your video sitemap.
6
  Author: Amit Agarwal
7
+ Version: 2.3
8
  Author URI: http://www.labnol.org/
9
  */
10
 
62
  <iframe src="http://www.facebook.com/plugins/likebox.php?id=5791561181&amp;width=250&amp;height=260&amp;connections=8&amp;stream=false&amp;header=false" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:250px; height:260px"></iframe>
63
  </div>
64
  <h2>XML Sitemap for Videos</h2>
65
+ <?php $sitemapurl = get_bloginfo('home') . "/sitemap-video.xml"; ?>
66
  <p>The XML Sitemap was generated successfully. Please open the <a target="_blank" href="<?php echo $sitemapurl; ?>">Sitemap file</a> in your favorite web browser to confirm that there are no errors.</p>
67
  <p>You can submit your Video XML Sitemap through <a href="http://www.google.com/webmasters/tools/" target="_blank">Webmaster Tools</a> or you can directly <a target="_blank" href="http://www.google.com/webmasters/sitemaps/ping?sitemap=<?php echo $sitemapurl; ?>">ping Google</a>.</p>
68
  <h3>Suggestions?</h3>
107
  $xml .= '<!-- Generated-on="' . date("F j, Y, g:i a") .'" -->' . "\n";
108
  $xml .= '<?xml-stylesheet type="text/xsl" href="' . get_bloginfo('wpurl') . '/wp-content/plugins/xml-sitemaps-for-videos/video-sitemap.xsl"?>' . "\n" ;
109
  $xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">' . "\n";
110
+
111
+ $videos = array();
112
 
113
  foreach ($posts as $post) {
114
+ if (preg_match_all ("/youtube.com\/(v\/|watch\?v=|embed\/)([a-zA-Z0-9\-_]*)/", $x, $matches, PREG_SET_ORDER)) {
 
115
 
116
  $excerpt = ($post->post_excerpt != "") ? $post->post_excerpt : $post->post_title ;
117
  $permalink = get_permalink($post->id);
118
 
119
  foreach ($matches as $match) {
120
+
121
+ $id = $match [2];
 
122
 
123
+ if (in_array($id, $videos))
124
+ continue;
125
+
126
+ array_push($videos, $id);
127
+
128
+ $xml .= "\n <url>\n";
129
+ $xml .= " <loc>$permalink</loc>\n";
130
+ $xml .= " <video:video>\n";
131
+ $xml .= " <video:player_loc allow_embed=\"yes\" autoplay=\"autoplay=1\">http://www.youtube.com/v/$id</video:player_loc>\n";
132
+ $xml .= " <video:thumbnail_loc>http://i.ytimg.com/vi/$id/2.jpg</video:thumbnail_loc>\n";
133
+ $xml .= " <video:title>" . htmlspecialchars($post->post_title) . "</video:title>\n";
134
+ $xml .= " <video:description>" . htmlspecialchars($excerpt) . "</video:description>\n";
135
 
136
  if ($_POST['time'] == 1) {
137
  $duration = youtube_duration ($id);