Comprehensive Sitemap Plugin Enhancements

Some exciting development work from Michael Blouin, our VIP Intern Code Wrangler. Here’s what he’s been working on: 

A lot of upgrades have gone into Comprehensive Sitemap plugin recently, and here’s what’s new:

More Filters. We now have four new filters that provide a lot of similar functionality as is available on the regular WP.com sitemaps:

msmsitemap_changes1

  • `msm_sitemap_namespace` — Customize the namespace declaration for the sitemap during generation
  • `msm_sitemap_skip_post` — Allows a post to be skipped during sitemap generation
  • `msm_sitemap_entry` — Runs for each entry during generation. Allows you to customize every SimpleXMLElement before it is outputted.
  • `msm_sitemap_query_args` — Allows you to customize the WP_Query that is used to fetch the posts to be inserted in the sitemap.

No Sitemaps for Non-Public Blogs. Sitemaps are no longer generated or available on non-public blogs. The cron job itself is killed so it doesn’t suck up any resources and a nice 404 is given when the sitemap is requested. In the administration panel, the main sitemaps options and stats are no longer available when the sitemap is private (see screenshot):

msmsitemap_privateblog1

msmsitemap_changes2Admin Page Name Changed and Code Restructured. There is only one admin page and it lives in Tools->Sitemap. The code for the admin page has been greatly restructured and is now 314% better*.

The admin page now lives in msm_sitemap.php instead of the cron builder, where it didn’t really fit in with the rest of the functions on the block. In addition to fixing a number of translation problems we’ve also made it so that the action buttons and status text are customizable via actions and filters.

The admin page now has the following new filter and action:

  • `msm_sitemap_actions` — Allows actions to be registered for the admin page. This is how the `Generate Sitemaps` buttons and others are generated.
  • `msm_sitemap_action-$action` — This action (not a filter) is called when a pre-registered action is performed by a user. When you register an action via `msm_sitemap_actions` you provide a `$action` slug, which is used to generate the action name to be performed. If your action needs to print out a status message to the user it can use the new `Metro_Sitemap::show_action_message()` helper function.

Additional Stats Tracking. We now track the number of sitemaps that have been generated and the number of URLs indexed in each sitemap. This info is informative and helpful, and we may be able to present it in a pretty infographic in the future.

If you already have Comprehensive Sitemaps running on your blog you will have to regenerate your sitemaps for these new stats to update.

*approximate improvement, results may vary.

Thanks Michael!