I’m not very smart on installing packages on Linux, but today I need to configure a Tomcat on a CentOS 5.2. The CentOS 5.2 has Tomcat 5 available as yum package, with gcc-java. But Java gurus tell me to use the original Sun JDK to run Tomcat without problems. (more…)
Not understanding how WordPress manages the magic quotes of PHP (PHP is no more supporting magic quotes gpc from version 6, and when this version will be released we see a lot of sites hacked…) I followed the WordPress startup code.
The code is all in wp-settings.php. These my conclusions:
- $_REQUEST is redefined as a pure merge of $_GET and $_POST and can have or not magic quotes, to use it you need to check the “magic_quote_gpc()” function
- $_GET, $_POST, $_COOKIE and $_SERVER arrays are forced with escaped values so to have the real values you need to strip the slashes
Today I complete two easy tasks:
- intercept the URL http://www.myblog.com/sitemap.xml to serve the sitemap (it will work only with WordPress on Apache and permalink active)
- ping Google when something happens in WordPress (eg. a post changed)
The two modifications are very easy. The first is a matter to do a little parsing of request uri:
substr($_SERVER[‘REQUEST_URI’], strlen($_SERVER[‘REQUEST_URI’])-11) == ‘sitemap.xml’
and to add a checkbox in the options panel to enable this feature.
This post contains a gallery. Unser each image of the gallery there is a link added by my plugin eCards. Clickiing that link you can send the image as a eCard.
The plugin is in the very early test phase: would you try it and help me to understand if it works?
Here the gallery:
If you try the sitemap plugin on a big blog, the sitemap generated can be broken. This is not an error of the plugin, but almost surely an out of memory error.
In PHP there are many way to try to save memory, in out plugin I will change the main loop in this way:
- I copy the current post data in a variable called $post (an associative array)
- I add the data (url, priority, change frequency) to this variable
- I use the variable to create the URL sitemap entry
- I unset the variable $posts
Printing the memory usage show there is no so big difference between the two methods, but is enough to make the plugin work on one of my sites.
It’s time to make this sitemap plugin a little bit more “social”. How? As you learnt in previous lessons, WordPress has hooks that are called to give a way to “others” to make actions (over the default behaviour of WordPress).
There are a lot (really a lot) of these hooks… and now we add one for the sitemap plugin.
Any time a sitemap URL entry is generate by our plugin, our hook lets other plugins to do something related to that entry. An example is a plugin like Global Translator: for each post the plugin is processing, may be there is a translated version in one or more languages. Global Translator can attach to our hook and give us more entries to be added to the sitemap.
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.
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: