WordPress
Convert from AMM to Now Reading
As part of my upgrading to the latest/greatest version of WordPress, I switched over to using the Now Reading plugin from AMM. I switched because development on AMM seems to have come to a complete halt and it was acting somewhat flaky prior to the upgrade. One of the big problems with switching over was I didn't want to have to manually enter in all books I'd already read and rated. As Now Reading supports storing so much more data, I had to write a bit of custom SQL to import my existing info. It's not a great solution, mostly because AMM didn't store all of the same info (e.g. date entered, started and finished).
INSERT INTO wp_now_reading(b_added, b_started, b_finished, b_title, b_nice_title, b_author, b_nice_author, b_image, b_asin, b_status, b_rating, b_review)
SELECT amm_dateadded, amm_dateadded, amm_dateadded, amm_title,
REPLACE(REPLACE(REPLACE(
REPLACE(REPLACE(REPLACE(
REPLACE(REPLACE(REPLACE(
REPLACE(REPLACE(LCASE(amm_title), ',', '' ), ')', '' ), '(', '' )
, ' ', '-' ), '...', '-' ), ':', '-' )
, '!', '-' ), '?', '-' ), '&', '-' )
, '\'', '' ), '--', '-' ), amm_author, REPLACE(REPLACE(REPLACE( LCASE( amm_author ) , '.', '' ) , '&', 'and' ) , ' ', '-' ), amm_smallImageURL, amm_asin, 'read', amm_rating *2, amm_userComments
FROM wp_amm amm
WHERE amm_ProductGroup = 'Book' AND amm_asin NOT IN (SELECT b_asin FROM wp_now_reading);
This short script copied over all my books for me and got everything setup as well as could be expected given the differences in the data. Below is a list of the assumptions I made in writing this script to convert to Now Reading:
- AMM only stores one date, so I used that for all dates on the books I copied over.
- The above script limit itself to books and skips any already in your wp_now_reading table.
- Now Reading has additional fields the title & author. I'm not sure what the "b_nice_author" field is used for, but the "b_nice_title" is used when you go to edit a specific book. The format of the "b_nice_" fields seems to be to replace anything other than a letter or a number with a hyphen and to have all the letters be lower case. I tried to make sure I did the same with my script, however you may need to double-check your data before running this to make sure I didn't miss a symbol you used.
- I marked all the books I was copying over as "read".
- AMM only allowed ratings of 1 - 5; while Now Reading allows 1 - 10. So when I copied the ratings over, I doubled them.
NOTE: If you have questions about this script, post them in the comments here. Keep in mind that I'm not providing full fledged support for the script and if you don't know how to run this without asking, then you probably shouldn't be messing with it. Also, if you're really going to try running this script, then for god's sake backup your database FIRST!
Finally Upgrading
Ever since I heard WordPress was going to release 2.0.x; I've been planning my upgrade. Unfortunately RL kept interferring. Once I got my RL mostly settled down, I started working on those upgrade plans again. But then so many new/cool/wowser themes and plugins were coming out that I ended up scrapping and restarting my plans multiple times. I've finally decided to stop scrapping my plans and implement one of them, though this means all my faithful readers will be treated to some sort of blog insanity as I get everything upload, altered, activated, tweaked, upgraded and running the way I want it. After the disruption, I look forward to sharing some new features on this site with you.
And yes, that's a teaser to make sure you come back once the dust settles around here.
WordPress/Akismet Hack 0.0.2
Do you run WP? Do you also have Akismet installed? Would you like a quick reference on the Dashboard showing you some info from Akismet? I do and did want this. Since I have zero idea on how to set this up as a plugin; I simply added the code into /wp-admin/index.php. I scanned through the file until I found the section of code which creates the "Latest Activity" box. Then between the sections for "Blog Stats" and "Incoming Links"1, I added the following code:
<h3><a href="http://akismet.com/" title="Stop Comment Spam and Trackback Spam « Akismet">Akismet</a> Stats</h3>
<? php
$deadspam = get_option('akismet_spam_count');
$livespam = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'");
$sitelink = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_id = '1'");
print "Killed Spam Count: $deadspam\n";
if ($livespam == 0) {
print "Your spam queue is empty!";
} else {
print "<strong>Possible Spam Count: <a href="http://coffeebear.net/wp-admin/$sitelink/wp-admin/edit.php?page=akismet.php" title="Click here to see the moderation queue">$livespam</a></strong>\n";
}
?>
There's undoubtably a more elegant way of retrieving and displaying this information. And for somebody who actually writes PHP code regularly, this might even be a quick and easy plugin to create. Unfortunately, I've only read part of a book about PHP; so this is about as far as I can currently take the hack. Unlike what some people think, WordPress does not require you to be a PHP guru. It only requires a webserver with PHP, MySQL & a little patience2.
NOTE: THIS IS A CORE WORDPRESS FILE! EDIT AT YOUR OWN RISK! I AM NOT RESPONSIBLE IF YOU HOSE YOUR BLOG, SERVER, LIFE, THE UNIVERSE, AND EVERYTHING! BACKUP EVERYTHING BEFORE YOU EVEN CONSIDER ATTEMPTING THIS! ONLY ATTEMPT THIS HACK IF YOU FEEL COMFORTABLE EDITING CORE WORDPRESS FILES.
Update: Neto Cury was kind enough to point out an error in the above code. Though to be fair it's not entirely my fault. I pasted into this post the exact code I used in my file, but something in WP or one of the plugins I use appears to have changed the first part of the PHP coding from <? php to < ?php. I'm not sure what caused that, but to help people avoid getting errors; I've uploaded a text file containing the code for the hack. You can download that file here.
Update #2: Fixed a typo in the previous update. Sorry about that Neto!
Update #3 2007-04-21: I've updated this hack to modify the akismet plugin file (Akismet v2.0 for WordPress 2.1.3) instead of one of the WordPress core files. Read about it here.
1 Blog Stats ends at line 85 in my file and at the time of this writing I am running WordPress 1.5.2.
2 This is true of every CMS that I've looked at.
Problems (Part 2)
As you've probably noticed by now, I've found a work around to the plugin problems. From what I've been able to determine so far, the plugin is having problems calling in the Amazon product images for my sidebar. For now, I've reconfigured the plugin to display the text without images which seems to be mostly working though my sidebar is now getting tossed down to the bottom of the page. *sigh*
Update: Actually, it appears a different plugin is the source of the sidebar being shoved down. This other plugin adds in it's own CSS; so I'll be looking at that to try fixing the issue. Life is never easy.
Problems
CoffeeBear.net is currently experiencing some problems. We are aware of the issue and looking into it. We'll let you know when we have it fixed.
Update: The problem appears to be related to the plugin I've been using to display books and whatnot down the side of the site. I'm still investigating why this started happening and will restore the site to normal once I've got it fixed.
Search
Recent Comments
- FineTexan: I love Dannon coffee yogurt! My favorite way to eat it is...
- Laura: I absolutely love coffee yogurt. I am addicted, I have been...
- Rachel: Doris, I had the same problem! I absolutely loved the Dannon...
- ouini: The youth co-star was a better character / actor than I was...
- Dolores Beck: Coffee Yogurt from Dannon is something special. I also...







