Version Description
Download this release
Release Info
Developer | labnol |
Plugin | Google XML Sitemap for Videos |
Version | 2.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.4 to 2.0
- readme.txt +53 -53
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- video-sitemap.php +145 -151
readme.txt
CHANGED
@@ -1,53 +1,53 @@
|
|
1 |
-
=== Plugin Name ===
|
2 |
-
Contributors: labnol
|
3 |
-
Tags: youtube, xml sitemaps, google sitemaps, bing, videos, seo, search engines, sitemap
|
4 |
-
Requires at least: 2.9.2
|
5 |
-
Tested up to: 3.0
|
6 |
-
Stable tag:
|
7 |
-
|
8 |
-
This plugin will help
|
9 |
-
|
10 |
-
== Description ==
|
11 |
-
|
12 |
-
Sitemaps are a way to tell Google, Bing and other search engines about web pages, images and video content on your site that they may otherwise not discover.
|
13 |
-
|
14 |
-
The Video Sitemap plugin will generate an XML Sitemap for your WordPress blog using all YouTube videos that you may have embedded in your blog posts.
|
15 |
-
|
16 |
-
Your Video Sitemap will includes web pages which embed videos from YouTube or which links to videos on YouTube. If a YouTube video that you have in your blog has been removed from YouTube, the record in the Sitemap file will be ignored by Googlebot.
|
17 |
-
|
18 |
-
**Related links:**
|
19 |
-
|
20 |
-
You can follow [Digital Inspiration](http://www.labnol.org/ "Technology Blog") on [Twitter](http://twitter.com/labnol) and [Facebook](http://www.facebook.com/digital.inspiration).
|
21 |
-
|
22 |
-
== Installation ==
|
23 |
-
|
24 |
-
Here's how you can install the plugin:
|
25 |
-
|
26 |
-
1. Upload the plugins folder to the /wp-content/plugins/ directory.
|
27 |
-
1. Activate the plugin through the 'Plugins' menu in WordPress
|
28 |
-
1. Expand the Tools menu from WordPress dashboard sidebar and select "Video Sitemap."
|
29 |
-
1. Click the "Generate Sitemap" button to create your XML Sitemap for videos.
|
30 |
-
1. Once you have created your Sitemap, you can submit it to Google using Webmaster Tools.
|
31 |
-
|
32 |
-
== Frequently Asked Questions ==
|
33 |
-
|
34 |
-
= How can I submit my video sitemap to Google? =
|
35 |
-
|
36 |
-
Once you have created your Sitemap, you can submit it to Google using Webmaster Tools. Google don't guarantee that all videos included in a Sitemap will appear in our search results, or that we will use all the video information included in your Sitemap.
|
37 |
-
|
38 |
-
= Should I check the "include video duration" option when generating the sitemap? =
|
39 |
-
|
40 |
-
If you have a *small number of videos* on your website, you may check this option. Please not that the plugin will make one call per video to the YouTube API to determine the duration of the clip. It uses CURL to interact with the YouTube API.
|
41 |
-
|
42 |
-
= Where's the sitemap file stored? =
|
43 |
-
|
44 |
-
You can find the video-sitemap.xml file in your blog's root folder.
|
45 |
-
|
46 |
-
= Can I block search engines from indexing pages that are in the XML Sitemap file? =
|
47 |
-
|
48 |
-
The Sitemaps protocol enables you to let search engines know what content you would like indexed. To tell search engines the content you don't want indexed, use a robots.txt file or add a robots meta tag to the web page that you would like to block.
|
49 |
-
|
50 |
-
== Screenshots ==
|
51 |
-
|
52 |
-
1. Click the button to generate your video sitemap.
|
53 |
-
2. This is how the XML sitemap should look like in your web browser.
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: labnol
|
3 |
+
Tags: youtube, xml sitemaps, google sitemaps, bing, videos, seo, search engines, sitemap
|
4 |
+
Requires at least: 2.9.2
|
5 |
+
Tested up to: 3.0
|
6 |
+
Stable tag: 2.0
|
7 |
+
|
8 |
+
This plugin will help you generate Google Video Sitemaps (XML) for your WordPress blog.
|
9 |
+
|
10 |
+
== Description ==
|
11 |
+
|
12 |
+
Sitemaps are a way to tell Google, Bing and other search engines about web pages, images and video content on your site that they may otherwise not discover.
|
13 |
+
|
14 |
+
The Video Sitemap plugin will generate an XML Sitemap for your WordPress blog using all YouTube videos that you may have embedded in your blog posts.
|
15 |
+
|
16 |
+
Your Video Sitemap will includes web pages which embed videos from YouTube or which links to videos on YouTube. If a YouTube video that you have in your blog has been removed from YouTube, the record in the Sitemap file will be ignored by Googlebot.
|
17 |
+
|
18 |
+
**Related links:**
|
19 |
+
|
20 |
+
You can follow [Digital Inspiration](http://www.labnol.org/ "Technology Blog") on [Twitter](http://twitter.com/labnol) and [Facebook](http://www.facebook.com/digital.inspiration).
|
21 |
+
|
22 |
+
== Installation ==
|
23 |
+
|
24 |
+
Here's how you can install the plugin:
|
25 |
+
|
26 |
+
1. Upload the plugins folder to the /wp-content/plugins/ directory.
|
27 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
28 |
+
1. Expand the Tools menu from WordPress dashboard sidebar and select "Video Sitemap."
|
29 |
+
1. Click the "Generate Sitemap" button to create your XML Sitemap for videos.
|
30 |
+
1. Once you have created your Sitemap, you can submit it to Google using Webmaster Tools.
|
31 |
+
|
32 |
+
== Frequently Asked Questions ==
|
33 |
+
|
34 |
+
= How can I submit my video sitemap to Google? =
|
35 |
+
|
36 |
+
Once you have created your Sitemap, you can submit it to Google using Webmaster Tools. Google don't guarantee that all videos included in a Sitemap will appear in our search results, or that we will use all the video information included in your Sitemap.
|
37 |
+
|
38 |
+
= Should I check the "include video duration" option when generating the sitemap? =
|
39 |
+
|
40 |
+
If you have a *small number of videos* on your website, you may check this option. Please not that the plugin will make one call per video to the YouTube API to determine the duration of the clip. It uses CURL to interact with the YouTube API.
|
41 |
+
|
42 |
+
= Where's the sitemap file stored? =
|
43 |
+
|
44 |
+
You can find the video-sitemap.xml file in your blog's root folder.
|
45 |
+
|
46 |
+
= Can I block search engines from indexing pages that are in the XML Sitemap file? =
|
47 |
+
|
48 |
+
The Sitemaps protocol enables you to let search engines know what content you would like indexed. To tell search engines the content you don't want indexed, use a robots.txt file or add a robots meta tag to the web page that you would like to block.
|
49 |
+
|
50 |
+
== Screenshots ==
|
51 |
+
|
52 |
+
1. Click the button to generate your video sitemap.
|
53 |
+
2. This is how the XML sitemap should look like in your web browser.
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
video-sitemap.php
CHANGED
@@ -1,151 +1,145 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
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.
|
6 |
-
Author: Amit Agarwal
|
7 |
-
Version:
|
8 |
-
Author URI: http://www.labnol.org/
|
9 |
-
*/
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
$xml .= "
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
$
|
109 |
-
foreach ($
|
110 |
-
$xml .= " <video:
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
$
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
} catch (Exception $e) {
|
147 |
-
# returning 0 if the YouTube API fails for some reason.
|
148 |
-
return '0';
|
149 |
-
}
|
150 |
-
}
|
151 |
-
?>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
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.0
|
8 |
+
Author URI: http://www.labnol.org/
|
9 |
+
*/
|
10 |
+
|
11 |
+
add_action ('admin_menu', 'video_sitemap_generate_page');
|
12 |
+
|
13 |
+
function video_sitemap_generate_page () {
|
14 |
+
if (function_exists ('add_submenu_page'))
|
15 |
+
add_submenu_page ('tools.php', __('Video Sitemap'), __('Video Sitemap'),
|
16 |
+
'manage_options', 'video-sitemap-generate-page', 'video_sitemap_generate');
|
17 |
+
}
|
18 |
+
|
19 |
+
function video_sitemap_generate () {
|
20 |
+
|
21 |
+
if ($_POST ['submit']) {
|
22 |
+
video_sitemap_loop ();
|
23 |
+
?>
|
24 |
+
|
25 |
+
<div class="wrap">
|
26 |
+
<div style="float:right; margin:10px">
|
27 |
+
<iframe src="http://www.facebook.com/plugins/likebox.php?id=5791561181&width=250&height=260&connections=8&stream=false&header=false" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:250px; height:260px"></iframe>
|
28 |
+
</div>
|
29 |
+
<h2>XML Sitemap for Videos</h2>
|
30 |
+
<?php $sitemapurl = get_bloginfo('url') . "/video-sitemap.xml"; ?>
|
31 |
+
<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>
|
32 |
+
<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>
|
33 |
+
<h3>Suggestions?</h3>
|
34 |
+
<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> and <a href="http://www.facebook.com/digital.inspiration" target="_blank">Facebook</a>. </p>
|
35 |
+
<?php } else { ?>
|
36 |
+
<div class="wrap">
|
37 |
+
<h2>XML Sitemap for Videos</h2>
|
38 |
+
<p>Sitemaps are a way to tell Google and other search engines about web pages, images and video content on your site that they may otherwise not discover. </p>
|
39 |
+
<h3>Create Video Sitemap</h3>
|
40 |
+
<form id="options_form" method="post" action="">
|
41 |
+
<input type="checkbox" id="sboption" name="time" value="1" />
|
42 |
+
<label for="sboption">Include video length? (Not recommended for sites will large number of videos)</label>
|
43 |
+
<div class="submit">
|
44 |
+
<input type="submit" name="submit" id="sb_submit" value="Generate Video Sitemap" />
|
45 |
+
</div>
|
46 |
+
</form>
|
47 |
+
<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>
|
48 |
+
<h3>Suggestions?</h3>
|
49 |
+
<p>Please email your suggestions to Amit Agarwal at amit@labnol.org.</p>
|
50 |
+
<p> 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> and <a href="http://www.facebook.com/digital.inspiration" target="_blank">Facebook</a>. </p>
|
51 |
+
</div>
|
52 |
+
<?php }
|
53 |
+
}
|
54 |
+
|
55 |
+
function video_sitemap_loop () {
|
56 |
+
global $wpdb;
|
57 |
+
|
58 |
+
$posts = $wpdb->get_results ("SELECT id, post_title, post_content, post_date_gmt, guid, post_excerpt
|
59 |
+
FROM $wpdb->posts
|
60 |
+
WHERE post_status = 'publish'
|
61 |
+
AND post_type = 'post'
|
62 |
+
AND post_content LIKE '%youtube.com%'
|
63 |
+
ORDER BY post_date DESC");
|
64 |
+
|
65 |
+
if (empty ($posts)) {
|
66 |
+
return false;
|
67 |
+
|
68 |
+
} else {
|
69 |
+
|
70 |
+
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
71 |
+
$xml .= '<?xml-stylesheet type="text/xsl" href="' . get_bloginfo('wpurl') . '/wp-content/plugins/xml-sitemaps-for-videos/video-sitemap.xsl"?>' . "\n" ;
|
72 |
+
$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">' . "\n";
|
73 |
+
|
74 |
+
foreach ($posts as $post) {
|
75 |
+
if (preg_match_all ("(<embed[^>]*src=['\"]http:\/\/www.youtube.com\/v\/([a-zA-Z0-9\-_]*)|youtube.com\/watch\?v=([a-zA-Z0-9\-_]*))",
|
76 |
+
$post->post_content, $matches, PREG_SET_ORDER)) {
|
77 |
+
|
78 |
+
$excerpt = ($post->post_excerpt != "") ? $post->post_excerpt : $post->post_title ;
|
79 |
+
$permalink = get_permalink($post->id);
|
80 |
+
|
81 |
+
foreach ($matches as $match) {
|
82 |
+
$id = $match [1];
|
83 |
+
if ($id == '') $id = $match [2];
|
84 |
+
if ($id == '') $id = $match [3];
|
85 |
+
|
86 |
+
$xml .= "\n <url>\n";
|
87 |
+
$xml .= " <loc>$permalink</loc>\n";
|
88 |
+
$xml .= " <video:video>\n";
|
89 |
+
$xml .= " <video:player_loc allow_embed=\"yes\" autoplay=\"autoplay=1\">http://www.youtube.com/v/$id</video:player_loc>\n";
|
90 |
+
$xml .= " <video:thumbnail_loc>http://i.ytimg.com/vi/$id/2.jpg</video:thumbnail_loc>\n";
|
91 |
+
$xml .= " <video:title>" . htmlspecialchars($post->post_title) . "</video:title>\n";
|
92 |
+
$xml .= " <video:description>" . htmlspecialchars($excerpt) . "</video:description>\n";
|
93 |
+
|
94 |
+
if ($_POST['time'] == 1) {
|
95 |
+
$duration = youtube_duration ($id);
|
96 |
+
if ($duration != 0)
|
97 |
+
$xml .= " <video:duration>".youtube_duration ($id)."</video:duration>\n";
|
98 |
+
}
|
99 |
+
|
100 |
+
$xml .= " <video:publication_date>".date (DATE_W3C, strtotime ($post->post_date_gmt))."</video:publication_date>\n";
|
101 |
+
|
102 |
+
$posttags = get_the_tags($post->id); if ($posttags) {
|
103 |
+
foreach ($posttags as $tag) {
|
104 |
+
$xml .= " <video:tag>$tag->name</video:tag>\n";
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
$postcats = get_the_category($post->id); if ($postcats) {
|
109 |
+
foreach ($postcats as $category) {
|
110 |
+
$xml .= " <video:category>$category->name</video:category>\n";
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
$xml .= " </video:video>\n </url>";
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
$xml .= "\n</urlset>";
|
120 |
+
}
|
121 |
+
|
122 |
+
$video_sitemap_url = $_SERVER["DOCUMENT_ROOT"] . '/video-sitemap.xml';
|
123 |
+
file_put_contents ($video_sitemap_url, $xml);
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
+
# given a video id, get the duration.
|
128 |
+
# might give this a delay to avoid running into issues with YouTube.
|
129 |
+
function youtube_duration ($id) {
|
130 |
+
try {
|
131 |
+
$ch = curl_init ();
|
132 |
+
curl_setopt ($ch, CURLOPT_URL, "http://gdata.youtube.com/feeds/api/videos/$id");
|
133 |
+
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
|
134 |
+
$data = curl_exec ($ch);
|
135 |
+
curl_close ($ch);
|
136 |
+
|
137 |
+
preg_match ("/duration=['\"]([0-9]*)['\"]/", $data, $match);
|
138 |
+
return $match [1];
|
139 |
+
|
140 |
+
} catch (Exception $e) {
|
141 |
+
# returning 0 if the YouTube API fails for some reason.
|
142 |
+
return '0';
|
143 |
+
}
|
144 |
+
}
|
145 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|