moeffju.net

WordPress 2.1-alpha3 and Ultimate Tag Warrior

If you’re running WordPress 2.1 trunk from SVN (currently at 2.1-alpha3, r4663) with Ultimate Tag Warrior (UTW) 3.141592 (the latest version as of today), UTW will lose all tags on a post when a new comment is made.

To fix this, edit the ultimate-tag-warrior-actions*.php files (in your UTW directory, there should be one -actions.php and one -actions-wordpress2.php, simply edit both). In the function ultimate_save_tags($postID), add the following lines right after the opening curly bracket:

    if (!is_admin()) return $postID;
    if (!isset($_POST['tagset'])) return $postID;

Save the files and you should be all set.

The problem occurs because WordPress trunk calls the edit_post hook when new comments are added. UTW doesn’t check the environment and just assumes the admin wanted to delete all tags, and then dutifully removes the tags from the post.

The fix just does nothing when the edit_post hook gets called from outside the admin publish area.

Update: See also Thomas’ comment for the latest UTW version.

Do follow, please

[lang_de] Dieses Blog ist seit jetzt wieder frei von rel="nofollow". Das nofollow-Attribut hat in meinen Augen nichts gebracht - der Linkspam hat nicht abgenommen, die Suchergebnisse wurden nicht merklich besser. Statt dessen wird auch den legitimen Links (in Posts oder Kommentaren) der Google-Juice(tm?) genommen.

Also, back to the (web)roots: Do follow! [/lang_de] [lang_en] This blog is once again free from rel="nofollow". The nofollow attribute hasn’t done any good as far as I can see - the link spam has, if anything, grown, search engine’s results haven’t become noticeably better. Instead, even legitimate links (in posts or comments) are stripped of their Google juice.

Thus, back to the (web) roots: Do follow! [/lang_en]

WordPress Official Comments

If you are using the Official Comments plugin with a recent WordPress version, you might be getting Database errors when you post a comment on your own blog. To fix these, open the official-comments.php file and change:

  • in line 27: $tableusers -> $wpdb->users
  • in line 40: $tablecomments -> $wpdb->comments

WordPress get_links

Actually I was only trying to get the list of links in the sidebar sorted by the time of their last update. Naïvely, I tried to just pass get_links() the ‘_updated’ parameter, but it didn’t work. Since the codex is more or less down, and googling using a search engine didn’t help much, I resorted to just reading the fine code. So, to answer my own questions for posteriority and those using a search engine to find out about get_links:

  1. passing ‘_updated’ should work; contrary to what some believe, it does not sort by ‘time you last edited the link’, but really tries to sort on ‘time the link last updated’;
  2. if it does not work, that’s probably because api.pingomatic.com is timing out since forever, despite ‘servers donated by automattic’;
  3. all blogroll-updating plugins I found do all sorts of weird things, but don’t work in the end; I for one t hink that asking any number of services for all changes they registered in the last 5 or 10 minutes and then manually filtering for entries in ones blogroll is, well, overkill, not to mention that it causes a load of unnecessary traffic on both ends;
  4. as of now, there doesn’t seem to be a plugin that does the obvious thing, namely to just check the goddamn RSS feeds I manually entered for every link in my blogroll!

which leads us to

  1. link lists in WordPress are in a sorry state of affairs, and
  2. I should probably write such a plugin.

IP to country

[lang_de]Dieser Eintrag ist nur auf Englisch verfügbar.[/lang_de]

If you need to find out what country an IP is in, but are forced to use PHP or some other language without proper DNS querying features (but which can do UDP), here’s a little something for you.

ip2countryd-r2.tgz 344KiB - ip2countryd revision 2
Includes the required data file (~2MiB) and the cached data (~432KiB).

Runs a daemon on UDP port 8000 (by default) that responds to an input IP address with the ISO country code of the IP’s country, or ‘error’ if anything goes wrong (no mapping, not an IP, etc.). There is a test server at udp://ubermutant.net:8000/.

$ nc -u ubermutant.net 8000
207.13.77.53
us
212.227.57.11
eu

Idea from WP-ShortStat and the associated ip2country service. I wrote this just for the fun of it and because I wanted to see how long it would take me.

Total time required: ~1 hour.

[lang_en]WordPress Statistics[/lang_en][lang_de]WordPress-Statistiken[/lang_de]

[lang_en] I recently installed WP-ShortStat to gather blog statistics, and especially to make them more easily accessible (compared to webalizer). WP-ShortStat claims that one should just drop it in the plugin directory and enable it and it would work. Well, guess what happened. [/lang_en] [lang_de] Ich habe vor kurzem WP-ShortStat installiert, um mal einfach verfügbare und lesbare (im Gegensatz zu Webalizer) Blog-Statistiken zu haben. WP-ShortStat behauptet, man müsses nur einfach nur ins Plugin-Verzeichnis legen, das Plugin anschalten, und es würde funktionieren. Ratet, was statt dessen passiert ist. [/lang_de] [lang_en] At first, no stats showed up. I didn’t think much of it, since I was logged in as admin and it really shouldn’t track my own visits. Then I tried with another browser, but still got no stats. I thought of blaming WP-Cache, which might prevent the tracking function from ever getting called, but didn’t have the time to look into it. Time passes. It still doesn’t work. The author seems to have disappeared off the face of the earth. Looking into the source, I fixed a few obvious bugs ($wpss->$tz_offset, rrrright!), but still, no go. Lots of googling later, I find a bugfix (the admin detection broke with wp2.x), and just after implementing it, a maintained version of the plugin… which actually works! It still looks broken though, because the columns don’t wrap right (a relic from the original version). Also, it’s slow since every request results in another request to an ip-to-country webservice. I kid you not. All that to save shipping with a “2mb ip-to-country file” (quote from the original author). Even with HappyArts’ optimizations, I prefer to use local data. Exit WP-ShortStat.

Enter WP-SlimStat. It’s a rewrite/conglomeration/bastardization/whatever of WP-ShortStat and something else, and it claims to fix all the bugs WP-ShortStat, have more features, be equally easily installed, and not break the WP admin area. Plus it can import WP-ShortStat data. Installation really is as easy as promised, and the admin panel looks neat and doesn’t break things.

Just don’t look at the main page.

For WP-SlimStat to work, you must have WPLANG defined and it must not be empty, lest you get a fatal error “Cannot instantiate non-existent class: CachedFileReader”. Most non-english blogs should be fine, the others should define('WPLANG','en'); in their wp-config.php.

I’m happy to report that after this little fix, things work. But the original author of WP-SlimStat still hasn’t incorporated the fix. What is it with writing stats plugins and disappearing?

I sense a conspiracy. [/lang_en] [lang_de] Zuerst erschienen einfach keine Statistiken. Ich hab mir nicht viel dabei gedacht, weil ich noch als Admin eingeloggt war, und das Plugin meine eigenen Besuche wirklich nicht mitzählen sollte. Also hab ich es mit einem anderen Browser versucht, aber immer noch keine Stats gekriegt. Ich dachte mir, dass es an WP-Cache liegen könnte, weil die Tracking-Funktion vielleicht nie aufgerufen würde, hatte aber keine Zeit, mir das ganze genauer anzusehen. Ein paar Tage später. Es geht immer noch nicht. Der Autor scheint vom Erdboden verschluckt worden zu sein. Im Source finde und behebe ich ein paar offensichtliche Bugs ($wpss->$tz_offset… äh, nein), aber mehr als leere Stats kriege ich trotzdem nicht. Viel googlen später finde ich einen Bugfix (die Admin-Erkennung geht mit WP 2.x nicht mehr), und kurz nachdem ich damit fertig bin, eine aktualisierte Version des Plugins… die sogar funktioniert! Leider sieht’s immer noch mies aus, weil die Spalten nicht richtig umbrechen (ein Relikt aus der Originalversion des Plugins). Außerdem ist es recht langsam, weil jeder Request eine Anfrage bei einem IP-to-Country Webservice nach sich zieht. Ernsthaft. Alles nur, um kein “2mb ip-to-country file” (Zitat Original-Autor) zu brauchen. Auch wenn HappyArts da noch einiges optimiert haben, ich mag lokale Daten. Abtritt WP-ShortStat.

Auftritt WP-SlimStat: Ein Rewrite/Zusammenballen/Bastardisieren/whatever von WP-ShortStat und anderen Scripts, behauptet, alle Bugs von WP-ShortStat zu beheben, mehr Features zu haben, genauso leicht installierbar zu sein, und das Admin Panel nicht zu zerhauen. Außerdem kann es die Daten von WP-ShortStat importieren. Die Installation ist auch wirklich so leicht wie versprochen, und das Admin Panel sieht nett aus und ist vor allem nicht völlig zerstört.

Die Hauptseite ist eine ganz andere Angelegenheit.

Damit WP-SlimStat funktioniert, muss die Konstante WPLANG definiert und nicht leer sein, weil man sonst einen Fatal Error “Cannot instantiate non-existent class: CachedFileReader” kriegt. Die meisten nicht-englischsprachigen Blogs sollten kein Problem haben, alle anderen sollten define('WPLANG','en'); in ihre wp-config.php eintragen.

Nach diesem kleinen Fix funktioniert netterweise endlich alles. Leider hat der Autor von WP-SlimStat den Bugfix immer noch nicht eingebaut. Warum verschwindet jeder, der Statistik-Plugins für WordPress schreibt, plötzlich?

Ich wittere eine Verschwörung. [/lang_de]

UX UX UX (in multiple languages)

You are HP-UX. You're still strong despite the passage of time.  Though few understand you, those who do love you deeply and appreciate you.
Which OS are You?

[lang_de] Hurrah. Hat irgendwie was von Horoskopen.

Eigentlich teste ich nur das Polyglot-Plugin. Es funktioniert, aber der Code schreit eigentlich nach einem Rewrite… später.

Augen nach oben rechts wenden, lustige kleine Flaggen sehen, ausprobieren, und hoffentlich keine Fehler finden… jetzt. ;) [/lang_de]

[lang_en] Huzzah. Feels a little like horoscopes.

Actually I’m just testing the Polyglot plugin. It works, but the code is literally screaming for a rewrite… later.

Look to the upper right corner, see the nifty little flags, try them, hopefully don’t find any bugs… now. ;) [/lang_en]

The new black box

black box is now using my custom-made black box wordpress theme:

black box 1.0

See it in action. Sorry, the theme is for schuehsch exclusively. :)