Google XML Sitemap for Videos - Version 2.5

Version Description

= * added - Your sitemaps now look gorgeous in the browser. Just open the sitemap-video.xml file directly in any modern browser. * added - Sitemap now renders higher quality image thumbnails for YouTube videos

Download this release

Release Info

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

Code changes from version 2.4.1 to 2.5

Files changed (3) hide show
  1. readme.txt +3 -3
  2. video-sitemap.php +19 -21
  3. video-sitemap.xsl +42 -7
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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.3.1
6
- Stable tag: 2.4.1
7
 
8
  This plugin will help you generate Google Video Sitemaps (XML) for your WordPress blog.
9
 
@@ -62,8 +62,8 @@ The Sitemaps protocol enables you to let search engines know what content you wo
62
 
63
  == Changelog ==
64
 
65
- = 2.4.1 =
66
-
67
  * added - Sitemap now renders higher quality image thumbnails for YouTube videos
68
 
69
  = 2.4 =
3
  Tags: youtube, xml sitemaps, google sitemaps, videos, seo, sitemaps, video sitemap
4
  Requires at least: 2.9.2
5
  Tested up to: 3.3.1
6
+ Stable tag: 2.5
7
 
8
  This plugin will help you generate Google Video Sitemaps (XML) for your WordPress blog.
9
 
62
 
63
  == Changelog ==
64
 
65
+ = 2.5 =
66
+ * added - Your sitemaps now look gorgeous in the browser. Just open the sitemap-video.xml file directly in any modern browser.
67
  * added - Sitemap now renders higher quality image thumbnails for YouTube videos
68
 
69
  = 2.4 =
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.4
8
  Author URI: http://www.labnol.org/
9
  */
10
 
@@ -63,11 +63,11 @@ exit();
63
  <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>
64
  <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>
65
  <h3>Stay Connected</h3>
66
- <p>Please email your suggestions to Amit Agarwal at amit@labnol.org. You can also connect with <a href="http://www.labnol.org/" target="_blank">Digital Inspiration</a> on <a href="http://twitter.com/labnol" target="_blank">Twitter</a>, <a href="http://www.youtube.com/labnol" target="_blank">YouTube</a> and <a href="http://www.facebook.com/digital.inspiration" target="_blank">Facebook</a>. </p>
67
- <p><a href="https://twitter.com/labnol" class="twitter-follow-button" data-show-count="true" data-lang="en" >Follow @labnol</a></p>
68
  <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
69
- <iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fdigital.inspiration&amp;send=false&amp;layout=standard&amp;width=500&amp;show_faces=true&amp;action=recommend&amp;colorscheme=light&amp;font=arial&amp;height=80&amp;appId=197498283654348" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:80px;" allowTransparency="true"></iframe>
70
-
 
71
  <hr />
72
  <?php } else { ?>
73
  <div class="wrap">
@@ -82,8 +82,7 @@ exit();
82
  </div>
83
  </form>
84
  <p>You can click the button above to generate a Video Sitemap for your website. Once you have created your Sitemap, you should submit it to Google using Webmaster Tools. </p>
85
- <code>This WordPress plugin was developed by <a href="http://www.labnol.org/about/">Amit Agarwal</a> of <a href="http://www.labnol.org/">Digital Inspiration</a>.</code>
86
- </div>
87
  <?php }
88
  }
89
 
@@ -91,11 +90,10 @@ function video_sitemap_loop () {
91
  global $wpdb;
92
 
93
  $posts = $wpdb->get_results ("SELECT id, post_title, post_content, post_date_gmt, post_excerpt
94
- FROM $wpdb->posts
95
- WHERE post_status = 'publish'
96
- AND (post_type = 'post' OR post_type = 'page')
97
- AND post_content LIKE '%youtube.com%'
98
- ORDER BY post_date DESC");
99
 
100
  if (empty ($posts)) {
101
  return false;
@@ -111,16 +109,16 @@ function video_sitemap_loop () {
111
  $videos = array();
112
 
113
  foreach ($posts as $post) {
114
- $c = 0;
115
  if (preg_match_all ("/youtube.com\/(v\/|watch\?v=|embed\/)([a-zA-Z0-9\-_]*)/", $post->post_content, $matches, PREG_SET_ORDER)) {
116
 
117
  $excerpt = ($post->post_excerpt != "") ? $post->post_excerpt : $post->post_title ;
118
  $permalink = get_permalink($post->id);
119
 
120
  foreach ($matches as $match) {
121
-
122
  $id = $match [2];
123
- $fix = $c++==0?'':' [Video '. $c .'] ';
124
 
125
  if (in_array($id, $videos))
126
  continue;
@@ -131,15 +129,15 @@ function video_sitemap_loop () {
131
  $xml .= " <loc>$permalink</loc>\n";
132
  $xml .= " <video:video>\n";
133
  $xml .= " <video:player_loc allow_embed=\"yes\" autoplay=\"autoplay=1\">http://www.youtube.com/v/$id</video:player_loc>\n";
134
- $xml .= " <video:thumbnail_loc>http://i.ytimg.com/vi/$id/2.jpg</video:thumbnail_loc>\n";
135
  $xml .= " <video:title>" . htmlspecialchars($post->post_title) . $fix . "</video:title>\n";
136
  $xml .= " <video:description>" . $fix . htmlspecialchars($excerpt) . "</video:description>\n";
137
 
138
  if ($_POST['time'] == 1) {
139
- $duration = youtube_duration ($id);
140
- if ($duration != 0)
141
- $xml .= " <video:duration>".youtube_duration ($id)."</video:duration>\n";
142
- }
143
 
144
  $xml .= " <video:publication_date>".date (DATE_W3C, strtotime ($post->post_date_gmt))."</video:publication_date>\n";
145
 
@@ -194,4 +192,4 @@ function youtube_duration ($id) {
194
  return '0';
195
  }
196
  }
197
- ?>
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.5
8
  Author URI: http://www.labnol.org/
9
  */
10
 
63
  <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>
64
  <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>
65
  <h3>Stay Connected</h3>
66
+ <p><a href="https://twitter.com/labnol" class="twitter-follow-button" data-show-count="true" data-lang="en" >Follow @labnol</a></p>
 
67
  <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
68
+ <iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fdigital.inspiration&amp;send=false&amp;layout=standard&amp;width=500&amp;show_faces=true&amp;action=recommend&amp;colorscheme=light&amp;font=arial&amp;height=80&amp;appId=197498283654348" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:80px;" allowTransparency="true"></iframe>
69
+ <hr />
70
+ <p>Please email your suggestions to Amit Agarwal at amit@labnol.org. You can also connect with <a href="http://www.labnol.org/" target="_blank">Digital Inspiration</a> on <a href="http://twitter.com/labnol" target="_blank">Twitter</a>, <a href="http://www.youtube.com/labnol" target="_blank">YouTube</a> and <a href="http://www.facebook.com/digital.inspiration" target="_blank">Facebook</a>. </p>
71
  <hr />
72
  <?php } else { ?>
73
  <div class="wrap">
82
  </div>
83
  </form>
84
  <p>You can click the button above to generate a Video Sitemap for your website. Once you have created your Sitemap, you should submit it to Google using Webmaster Tools. </p>
85
+ <code>This WordPress plugin was developed by <a href="http://www.labnol.org/about/">Amit Agarwal</a> of <a href="http://www.labnol.org/">Digital Inspiration</a>.</code> </div>
 
86
  <?php }
87
  }
88
 
90
  global $wpdb;
91
 
92
  $posts = $wpdb->get_results ("SELECT id, post_title, post_content, post_date_gmt, post_excerpt
93
+ FROM $wpdb->posts WHERE post_status = 'publish'
94
+ AND (post_type = 'post' OR post_type = 'page')
95
+ AND post_content LIKE '%youtube.com%'
96
+ ORDER BY post_date DESC");
 
97
 
98
  if (empty ($posts)) {
99
  return false;
109
  $videos = array();
110
 
111
  foreach ($posts as $post) {
112
+ $c = 0;
113
  if (preg_match_all ("/youtube.com\/(v\/|watch\?v=|embed\/)([a-zA-Z0-9\-_]*)/", $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
+
120
  $id = $match [2];
121
+ $fix = $c++==0?'':' [Video '. $c .'] ';
122
 
123
  if (in_array($id, $videos))
124
  continue;
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/hqdefault.jpg</video:thumbnail_loc>\n";
133
  $xml .= " <video:title>" . htmlspecialchars($post->post_title) . $fix . "</video:title>\n";
134
  $xml .= " <video:description>" . $fix . htmlspecialchars($excerpt) . "</video:description>\n";
135
 
136
  if ($_POST['time'] == 1) {
137
+ $duration = youtube_duration ($id);
138
+ if ($duration != 0)
139
+ $xml .= " <video:duration>".youtube_duration ($id)."</video:duration>\n";
140
+ }
141
 
142
  $xml .= " <video:publication_date>".date (DATE_W3C, strtotime ($post->post_date_gmt))."</video:publication_date>\n";
143
 
192
  return '0';
193
  }
194
  }
195
+ ?>
video-sitemap.xsl CHANGED
@@ -11,17 +11,51 @@
11
  <title>XML Video Sitemap</title>
12
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
13
  <style type="text/css">
14
- body{font-family:Arial,sans-serif;font-size:11px;margin:0;padding:0}.labnol{margin:10px;float:left;border-top-width:1px;border-right-width:2px;border-bottom-width:2px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:#CCC;border-right-color:#CCC;border-bottom-color:#CCC;border-left-color:#CCC;width:350px;height:110px;overflow:hidden;padding-top:5px;padding-right:5px;padding-bottom:10px;padding-left:5px}.labnol h1{font-family:Georgia,"Times New Roman",Times,serif;font-size:1.2em;margin:0;padding:0 0 5px}.labnol h1 a{text-decoration:none;color:#333}.labnol p{color:#666;margin:0px;padding-top:10px}.labnol img{float:right;padding-top:0;padding-bottom:5px;padding-left:10px;border:none}
15
- </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  </head>
17
  <body>
18
  <xsl:for-each select="sitemap:urlset/sitemap:url">
19
- <div class="labnol">
 
20
  <xsl:variable name="u"> <xsl:value-of select="sitemap:loc"/> </xsl:variable>
21
- <h1><a href="{$u}"><xsl:value-of select="video:video/video:title"/></a> </h1>
22
- <xsl:variable name="t"> <xsl:value-of select="video:video/video:thumbnail_loc"/> </xsl:variable>
23
- <a href="{$u}"><img src="{$t}" width="120" height="80" /></a>
24
- <p>
25
  <xsl:variable name="d"><xsl:value-of select="video:video/video:description"/> </xsl:variable>
26
  <xsl:choose>
27
  <xsl:when test="string-length($d) &lt; 100">
@@ -33,6 +67,7 @@
33
  </xsl:choose>
34
  </p>
35
  </div>
 
36
  </xsl:for-each>
37
  </body>
38
  </html>
11
  <title>XML Video Sitemap</title>
12
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
13
  <style type="text/css">
14
+ body {
15
+ font-family:Georgia, "Times New Roman", Times, serif;
16
+ font-size:12px;
17
+ background: url(http://img.labnol.org/files/qcpgwkr.png) repeat;
18
+ margin: 10px;
19
+ }
20
+ a {
21
+ border:none;
22
+ }
23
+ a:link {
24
+ color:#fff;
25
+ text-decoration:none;
26
+ }
27
+ .labnol {
28
+ position: relative;
29
+ float:left;
30
+ border: 2px solid #000;
31
+ margin: 5px;
32
+ }
33
+ p {
34
+ position: absolute;
35
+ top: 220px;
36
+ left: 5px;
37
+ width: 90%;
38
+ color: #CCC;
39
+ padding: 10px;
40
+ background:#000;
41
+ font-style: italic;
42
+ line-height: 18px;
43
+ }
44
+ p strong {
45
+ font-size: 18px;
46
+ color: #FFF;
47
+ line-height: 30px;
48
+ font-style: normal;
49
+ }
50
+ </style>
51
  </head>
52
  <body>
53
  <xsl:for-each select="sitemap:urlset/sitemap:url">
54
+ <a href="{$u}" target="_blank">
55
+ <div class="labnol"><img src="{$t}" width="480" height="360" />
56
  <xsl:variable name="u"> <xsl:value-of select="sitemap:loc"/> </xsl:variable>
57
+ <p><strong><xsl:value-of select="video:video/video:title"/></strong><br />
58
+ <xsl:variable name="t"> <xsl:value-of select="video:video/video:thumbnail_loc"/> </xsl:variable>
 
 
59
  <xsl:variable name="d"><xsl:value-of select="video:video/video:description"/> </xsl:variable>
60
  <xsl:choose>
61
  <xsl:when test="string-length($d) &lt; 100">
67
  </xsl:choose>
68
  </p>
69
  </div>
70
+ </a>
71
  </xsl:for-each>
72
  </body>
73
  </html>