Tutorial: Write a Sitemap Plugin Day 5

Today I add an options panel to the Sitemap plugin. Before start coding I have to define what I want this panel to do and the data to collect.

  • the max number of urls to be added to the sitemap, blank value will mean “all”
  • a checkbox to enable the integration with other plugins (features I’ll explain on next lessons)

On the WordPress codex there are example on how to write an option panel. I don’t follow them, usually, seen that my panels are too much complex.


Tutorial: Write a Sitemap Plugin Day 4

We are at the end. At least the last day to have the plugin really working. After this lesson, I will start a new series to add some features to this plugin (control panel, options, integration with other plugins).

The last step is to print out XML elements that represent each single URL of our blog posts. On first lesson I showed up the XML format of those entries:


Tutorial: Write a Sitemap Plugin Day 2

Now we have a clear idea of the final product, so we can start to structure the plugin. Opsss, and the name? It can sound incredible but on the WordPress Plugin Directory the name “sitemap” is available.

So our plugin will be named “sitemap”.

Let’s start creating a folder named “sitemap” and the file “plugin.php” inside it. I’m used to call the main plugin file “plugin.php” it’s clear to understand (in a plugin there will be more than one php file). Surely, if you’re working with an IDE (like NetBeans) on more than one plugin, this name can create confusion (if you are a new by programmer…).


Tutorial: Write a Sitemap Plugin Day 1

I wrote a number of plugins and every time I review the code of them I found someting can be improved or adjusted. I’m not talking about bugs but different way to implement the plugin actions. This tutorial will be a set of post where I dissect “my way to write a plugin”. I don’t think it’s the best, most complete tutorial, but it m ay be useful… so… lets start.

Before all we need to decide the plugin purpose, it’s features, it’s limits. I want to write a very (very) simple plugin to generate a very (very) simple XML sitemap of this blog. As you know there are such kind of plugins, there is no need to write a new one, but this is a tutorial!