Migration to WordPress
I have been migrating my old, dusty web page from its classy Apache mod_userdir site to WordPress. I’ve had this domain sitting around since 2000, so I figured I would finally put it to use. I’ve moved over most of the salvageable content such as the venerable Maki game and recipes. The rest will come as time allows.
The process has rekindled my hatred of PHP. This is not to say that it’s not a good language for its niche and that its libraries aren’t useful. Okay, strike what I said. What I really meant to say was that it has rekindled my hatred of other people’s PHP. It is almost as far down in the depths of software maintenance hell as Perl. I would be ashamed to let anyone see my code if it was as bad what I’ve been reading these past few days. Maybe I’m a stickler for readable, formatted, and clean code. You can’t even tell what kinds of acrobatics are going on or realize the lack of design until you format it, and though I’m neglecting to mention the other benefits, that’s the point. Anyway, there are a lot of decent plugins and themes for WordPress out there, and I winnowed down the list to a few that I felt were useful enough to justify the added risk until I’m done with all of the security assessments. However, there were a few problems along the way, and so we begin…
WordPress
Step 1: Remove Hello Dolly plugin.
SimplePie caching doesn’t seem to work. As far as I can tell, it simply sticks things into the MySQL DB with its cache subclass and never pulls anything out. (It may not even clean up expired or abandoned cache entries.) I haven’t looked into it that much yet, but performance of the Live Blogroll mouse hover feed summaries sucks due to all of the fetching and parsing. Plugging in the new SimplePie 1.2 library doesn’t seem to break or fix anything, but at least it’s newer!
Creative Commons Configurator
Great plugin makes this a pretty painless exercise, except for editing footer.php. I wish it just used a WP hook to handle this bit. Anyway, changing the relevant part of the theme’s footer.php into the following takes care of the only problem I found.
<div id="credits">
<p>© <?php echo date("Y"); ?> <?php bloginfo('name'); ?> <?php bccl_full_html_license() ?></p>
<p><a href="feed:<?php bloginfo('rss2_url'); ?>">Full RSS</a> - <a href="feed:<?php bloginfo('comments_rss2_url'); ?>">Comments RSS</a></p>
</div>
SyntaxHighlighter Evolved
This excellent plugin allows for the source code formatting seen here. Highly recommended, unless you have no interest in posting source code.
Google Analytics for WordPress
This has broken exit link tracking for bookmarks as of v3.2.4. Fixing it is simple. Edit googleanalytics.php and change lines (some spaces were added for display purposes)
if ($options['domainorurl'] == "domain") {
$bookmark->link_rel = $bookmark->link_rel."\" onclick=\"javascript:pageTracker._trackPageview('" . $options['blogrollprefix'] . "/" . $target["host"] . "');";
} else if ($options['domainorurl'] == "url") {
$bookmark->link_rel = $bookmark->link_rel."\" onclick=\"javascript:pageTracker._trackPageview('" . $options['blogrollprefix'] . "/" . $bookmark->link_url . "');";
}
… to…
if ($options['domainorurl'] == "domain") {
$bookmark->link_target .= "\" onclick=\"javascript:pageTracker._trackPageview('" . $options['blogrollprefix'] . "/" . $target["host"] . "');";
} else if ($options['domainorurl'] == "url") {
$bookmark->link_target .= "\" onclick=\"javascript:pageTracker._trackPageview('" . $options['blogrollprefix'] . "/" . $bookmark->link_url . "');";
}
Amazon Showcase
This plugin would be a lot easier to use if you could override the defaults for each item. Changing the settings on each item is a pain, but at least it doesn’t break. Overall, pretty good.
This bit enables Google Analytics exit tracking in the Amazon Showcase plugin. Changing the “advanced” item HTML template in each item is the only way to do it right now, short of editing the plugin code’s default or adding a default template setting to the plugin. I wish there were more tags for substitution, because that entire url in the tracker is annoying. I’ll fix it later…
<div class="amzshcs-item" id="amzshcs-item-[itemIdentifier]"><a href="[url]" onclick="javascript:pageTracker._trackPageview('/outbound/amazon/[url]');">[image]</a></div>
Okay, I fixed it. Here’s the diff:
diff -ur amazon-showcase-wordpress-widget.orig/amazonshowcase.php amazon-showcase-wordpress-widget/amazonshowcase.php
--- amazon-showcase-wordpress-widget.orig/amazonshowcase.php 2009-09-25 23:52:14.000000000 -0500
+++ amazon-showcase-wordpress-widget/amazonshowcase.php 2009-11-27 17:53:06.000000000 -0600
@@ -664,7 +664,8 @@
'title' => $title,
'author' => $authors,
'url' => $url,
- 'images' => $images
+ 'images' => $images,
+ 'asin' => strtolower($asin)
);
}
@@ -682,7 +683,7 @@
var $_displayNum = 0;
var $_sortMethod = 'normal';
var $_items = array();
- var $_defaultItemTemplate = '<div class="amzshcs-item" id="amzshcs-item-[itemIdentifier]"> <a href="[url]">[image]</a> </div>';
+ var $_defaultItemTemplate = '<div class="amzshcs-item" id="amzshcs-item-[itemIdentifier]"><a href="[url]">[image]</a></div>';
var $_defaultShowcaseTemplate = '<div class="amzshcs" id="amzshcs-[showcaseIdentifier]">[showcaseItems]</div>';
/**
@@ -1077,6 +1078,7 @@
$itemHtml[$itemIdentifier] = str_replace('[author]', $authors, $itemHtml[$itemIdentifier]);
$itemHtml[$itemIdentifier] = str_replace('[title]', $item['amazonCache']['data']['title'], $itemHtml[$itemIdentifier]);
$itemHtml[$itemIdentifier] = str_replace('[url]', $item['amazonCache']['data']['url'], $itemHtml[$itemIdentifier]);
+ $itemHtml[$itemIdentifier] = str_replace('[asin]', $item['amazonCache']['data']['asin'], $itemHtml[$itemIdentifier]);
$image = '';
$image_url = '';
@@ -1199,7 +1201,7 @@
<tr valign="top">
<th scope="col" width="180">ASIN (or ISBN-10)</th>
<th scope="col" width="160">Image Size</th>
- <th scope="col">Template (Advanced users only)<br /><small>Available Tags: [title] [author] [url] [image] [image_url] [image_width] [image_height]</small></th>
+ <th scope="col">Template (Advanced users only)<br /><small>Available Tags: [title] [author] [url] [image] [image_url] [image_width] [image_height] [asin]</small></th>
<th scope="col" width="120">Thumbnail Preview</th>
</tr>
</thead>
@@ -1359,4 +1361,4 @@
}
-?>
\ No newline at end of file
+?>
Now the outbound links won’t have a monster URL in each one. Here is the new showcase bit:
<div class="amzshcs-item" id="amzshcs-item-[itemIdentifier]"><a href="[url]" onclick="javascript:pageTracker._trackPageview('/outbound/amazon/[asin]');">[image]</a></div>
Easy AdSense
This one is pretty good, as well. There are only a few minor issues with extra spaces before img src attributes in admin.php and easy-adsenser.php. The shameless ad sharing and advertising defaults are cute touches, too.
FeedBurner FeedSmith
This intercepts your local feed requests and redirects them to Google (FeedBurner) so they can insert AdSense ads. Cut and dry.
Live Blogroll
This is the magic behind the mouse hover feed summaries in the sidebar. I had to rewrite a large portion of this, first to do the feed detection and caching a little better, and later to bring it up to speed with SimplePie. There were some bugs, of course!
Firstly, it creates invalid XHTML. It adds a livelinks classed span tag for the hover in the middle of a list, so it doesn’t validate. Getting around that was kind of a pain. Ultimately, I had to modify my theme to not squelch the li classes for the links widget in functions.php. That file is a mess stock, so line numbers here are useless.
'before_widget' => '<li id="%1$s" class="widget sidebaritem %2$s">',
Then I had to tell Live Blogroll to use that class (widget_links, later placed into the %2 expansion) instead of the livelinks class. I’m in contact with the author with the updates, but the zip with its unofficial new version number are available here.
I also had to disable this plugin’s jQuery because it conflicts with the one included with my theme. Nothing seems to have broken, so yay.
I added a mouse cursor change so it looks like an RSS feed icon. Without it, I don’t know how anyone would be able to tell that it was doing something special. Unfortunately, I don’t care enough to finish it and make the icon change back when fetching is complete.
SafiTech
Simple theme. It’s unrecognizable in parts at this point from being rewritten, but it was a good start. One day I’ll have to get its jQuery updated.
One thing I didn’t like was the lack of parent/child navigation for pages. I wanted to show links to all children of the current page and a link to the parent page if the parent was not a top level page. (People can navigate to those with the main menu bar.) I added this bit of code in page.php after the end of the post content:
<?php
if (is_page()) {
if ($post->post_parent) {
$parent = get_post($post->post_parent);
$grandparent = $parent->post_parent;
} else {
$grandparent = NULL;
}
$children = wp_list_pages('title_li=&child_of=' . $post->ID . '&echo=0&depth=1');
if ($grandparent || $grandparent === 0 || $children) {
?>
<hr />
<ul>
<?php
if ($grandparent || $grandparent === 0) {
?>
<li class="page_item"><a href="<?php echo get_permalink($post->post_parent) ?>" title="<?php echo get_the_title($post->post_parent); ?>">..</a></li>
<?php
}
if ($children) {
echo $children;
}
?>
</ul>
<?php
}
}
?>
That’s all folks.

Migration to WordPress by cum grano salis — nobody likes a clever bastard, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.

Leave a Reply
You must be logged in to post a comment.