Version Description
Download this release
Release Info
Developer | labnol |
Plugin | Google XML Sitemap for Images |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- image-sitemap.php +93 -0
- readme.txt +43 -0
image-sitemap.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Google XML Sitemap for Images
|
4 |
+
Plugin URI: http://www.labnol.org/software/xml-video-sitemaps-for-google/14085/
|
5 |
+
Description: This plugin will generate a XML Image Sitemap for your WordPress blog. Open the <a href="tools.php?page=image-sitemap-generate-page">settings page</a> to create your image sitemap.
|
6 |
+
Author: Amit Agarwal
|
7 |
+
Version: 1.0
|
8 |
+
Author URI: http://www.labnol.org/
|
9 |
+
*/
|
10 |
+
|
11 |
+
add_action ('admin_menu', 'image_sitemap_generate_page');
|
12 |
+
|
13 |
+
function image_sitemap_generate_page () {
|
14 |
+
if (function_exists ('add_submenu_page'))
|
15 |
+
add_submenu_page ('tools.php', __('Image Sitemap'), __('Image Sitemap'),
|
16 |
+
'manage_options', 'image-sitemap-generate-page', 'image_sitemap_generate');
|
17 |
+
}
|
18 |
+
|
19 |
+
function image_sitemap_generate () {
|
20 |
+
|
21 |
+
if ($_POST ['submit']) {
|
22 |
+
image_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 Images</h2>
|
30 |
+
<?php $sitemapurl = get_bloginfo('url') . "/sitemap-image.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 Image 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 Images</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 Image Sitemap</h3>
|
40 |
+
<form id="options_form" method="post" action="">
|
41 |
+
<div class="submit">
|
42 |
+
<input type="submit" name="submit" id="sb_submit" value="Generate Image Sitemap" />
|
43 |
+
</div>
|
44 |
+
</form>
|
45 |
+
<p>You can click the button above to generate a Image Sitemap for your website. Once you have created your Sitemap, you should submit it to Google using Webmaster Tools. </p>
|
46 |
+
<h3>Suggestions?</h3>
|
47 |
+
<p>Please email your suggestions to Amit Agarwal at amit@labnol.org.</p>
|
48 |
+
<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>
|
49 |
+
</div>
|
50 |
+
<?php }
|
51 |
+
}
|
52 |
+
|
53 |
+
function image_sitemap_loop () {
|
54 |
+
global $wpdb;
|
55 |
+
|
56 |
+
$posts = $wpdb->get_results ("SELECT id, post_content FROM $wpdb->posts
|
57 |
+
WHERE post_status = 'publish'
|
58 |
+
AND (post_type = 'post' OR post_type = 'page')
|
59 |
+
ORDER BY post_date");
|
60 |
+
|
61 |
+
if (empty ($posts)) {
|
62 |
+
return false;
|
63 |
+
|
64 |
+
} else {
|
65 |
+
|
66 |
+
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
67 |
+
$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">' . "\n";
|
68 |
+
|
69 |
+
foreach ($posts as $post) {
|
70 |
+
if (preg_match_all ("/[\'\"](http:\/\/.[^\'\"]+\.(?:jpe?g|png|gif))[\'\"]/ui",
|
71 |
+
$post->post_content, $matches, PREG_SET_ORDER)) {
|
72 |
+
|
73 |
+
$permalink = get_permalink($post->id);
|
74 |
+
$xml .= "<url>\n";
|
75 |
+
$xml .= " <loc>$permalink</loc>\n";
|
76 |
+
|
77 |
+
foreach ($matches as $match) {
|
78 |
+
|
79 |
+
$xml .= " <image:image>\n";
|
80 |
+
$xml .= " <image:loc>$match[1]</image:loc>\n";
|
81 |
+
$xml .= " </image:image>\n";
|
82 |
+
}
|
83 |
+
$xml .= "</url>\n";
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
$xml .= "\n</urlset>";
|
88 |
+
}
|
89 |
+
|
90 |
+
$image_sitemap_url = $_SERVER["DOCUMENT_ROOT"] . '/sitemap-image.xml';
|
91 |
+
file_put_contents ($image_sitemap_url, $xml);
|
92 |
+
}
|
93 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: labnol
|
3 |
+
Tags: xml sitemaps, google sitemaps, bing, images, seo, search engines, sitemap, pictures
|
4 |
+
Requires at least: 2.9.2
|
5 |
+
Tested up to: 3.0
|
6 |
+
Stable tag: 1.0
|
7 |
+
|
8 |
+
This plugin will help you generate Image 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 Image Sitemap plugin will generate a sitemap for your WordPress blog with all the image URLs that are used in your posts and pages.
|
15 |
+
|
16 |
+
**Related links:**
|
17 |
+
|
18 |
+
* [Google XML Sitemap for Mobile](http://wordpress.org/extend/plugins/google-mobile-sitemap/)
|
19 |
+
* [Google XML Sitemap for Videos](http://wordpress.org/extend/plugins/xml-sitemaps-for-videos/)
|
20 |
+
* [Must have WordPress Plug-ins](http://www.labnol.org/software/must-have-wordpress-plugins/14034/) on [Digital Inspiration](http://www.labnol.org/ "Technology Blog")
|
21 |
+
|
22 |
+
For updates, you can follow the [author](http://www.labnol.org/about/ "Amit Agarwal") on [Twitter](http://twitter.com/labnol) and [Facebook](http://www.facebook.com/digital.inspiration).
|
23 |
+
|
24 |
+
== Installation ==
|
25 |
+
|
26 |
+
Here's how you can install the plugin:
|
27 |
+
|
28 |
+
1. Upload the plugins folder to the /wp-content/plugins/ directory.
|
29 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
30 |
+
1. Expand the Tools menu from WordPress dashboard sidebar and select "Image Sitemap."
|
31 |
+
1. Click the "Generate Sitemap" button to create your XML Sitemap for mobile.
|
32 |
+
1. Once you have created your Sitemap, you can submit it to Google using Webmaster Tools.
|
33 |
+
|
34 |
+
== Frequently Asked Questions ==
|
35 |
+
|
36 |
+
= How can I submit my image sitemap to Google? =
|
37 |
+
|
38 |
+
Once you have created your Sitemap, you can submit it to Google using Webmaster Tools.
|
39 |
+
|
40 |
+
= Where's the sitemap file stored? =
|
41 |
+
|
42 |
+
You can find the sitemap-image.xml file in your blog's root folder.
|
43 |
+
|