Category Archives: Plugins

WordPress 3.1 is Out

The latest, greatest version of WordPress was released yesterday. It comes with a whole lot fixes and new features. One of those new features is an admin bar similar to the one used on; however the admin bar only includes specific links rather than being automatically populated with all the various links that my install of WordPress has (from various plugins). I found the lack of those links for one particular plugin particularly annoying. A quick bit of research and a little bit later, I developed the Now-Reading Admin Bar Menu plugin.

I also noticed after the update that one of my client sites wasn’t working correctly. It turns out there’s a bug in WordPress 3.1 which breaks category exclusion. On my client’s site, I was using this code:

function exclude_category($query) {
$cat_id = '-'.get_cat_id('meetings');
if ( $query->is_home ) {
$query->set('cat', $cat_id);
return $query;
add_filter('pre_get_posts', 'exclude_category');

Fortunately that bug I linked to also includes a workaround. By changing the above bit of code to read as follows, I was able to fix my client’s site. ^_^

function exclude_category($query) {
$cat_id = '-'.get_cat_id('meetings');
if ( $query->is_home ) {
$query->set('category__not_in', array($cat_id));
return $query;
add_filter('pre_get_posts', 'exclude_category');

Fixing Now-Reading’s Admin Menu

I like using Now-Reading to track what books I’m currently reading, have read and want to read on my website. Unfortunately the plugin’s author has been too busy of late to update the plugin and one of the recent updates to WordPress caused Now-Reading’s admin menu to break (when using the single menu option). PHP is not a programming language that I’m really familiar with but I did some poking around in Now-Reading’s code and found if I changed this snip of code:

	if ( $options['menuLayout'] == NR_MENU_SINGLE ) {

		add_menu_page('Now Reading', 'Now Reading', 9, 'admin.php?page=add_book', 'now_reading_add');


		add_submenu_page('admin.php?page=add_book', 'Add a Book', 'Add a Book',$nr_level , 'add_book', 'now_reading_add');

		add_submenu_page('admin.php?page=add_book', 'Manage Books', 'Manage Books', $nr_level, 'manage_books', 'nr_manage');

		add_submenu_page('admin.php?page=add_book', 'Options', 'Options', 9, 'nr_options', 'nr_options');

To read like this:

	if ( $options['menuLayout'] == NR_MENU_SINGLE ) {

		add_menu_page('Now Reading', 'Now Reading', 9, 'add_book', 'now_reading_add');
		add_submenu_page('add_book', 'Add a Book', 'Add a Book',$nr_level , 'add_book', 'now_reading_add');
		add_submenu_page('add_book', 'Manage Books', 'Manage Books', $nr_level, 'manage_books', 'nr_manage');
		add_submenu_page('add_book', 'Options', 'Options', 9, 'nr_options', 'nr_options');

Then Now-Reading’s single admin menu worked properly again.

Testing… 1…

I recently added a couple of plugins to this site (and a friend’s that I maintain) to try making administrating them easier.  Both sites also happen to use a plugin to crosspost to LiveJournal and now things are acting flaky.

I’ve disabled the most likely culprit and now am writing this post to see if I’m right about which plugin is causing the problem.  Wish me luck.

Side note: Our snowblower stopped working during the last snow-storm.  The engine runs, but the auger stopped turning.  This weekend we got a bunch more snow, so I opened up the snowblower, figured out what the problem was and fixed it.  I fought the snowblower and I won!  🙂  Unfortunately while troubleshooting it, I also fought my vice-grips and the vice-grips won (I’ve got the blood blister and cuts to prove it).

UPDATE: My first guess was wrong but I’ve figured out which plugin is causing the problem and deactivated it. For the record, Referrer Detector & LiveJournal Crossposter do not play nice together.

Now-Reading Tweaks v2

Some time back, I tried to make Rob Miller’s Now-Reading plugin display who’s reading each book on the individual pages. But the PHP code I posted at that time didn’t work like I thought it did, my interests changed and I moved onto other things. Today I had a visitor stop by asking about my broken tweak. So I took another look at the code and I believe I’ve got something that works this time.

// Now-Reading Plugin: Get the display name of the book's reader
function mlm_book_reader( $echo=true ) {
	global $book;

	$user_info = get_userdata($book->reader);
	if ( $echo )
		echo $user_info->display_name;
	return $user_info->display_name;

This grabs “Display name publicly as” from the user’s profile and displays it on the page. I put the function in the functions.php file of the theme I’m using (so any automatic upgrades of the plugin won’t erase it). Then I put < ?php mlm_book_reader() ?> into my custom single.php template and viola!

Note: this has only been tested on WordPress 2.6.2 with Now-Reading 4.4.3.

Now-Reading: Default Filters on Book-Meta

Ever since upgrading to the latest version of Rob Miller’s Now-Reading plugin, I noticed my single book pages were working but not displaying everything correctly. Specifically books I’d marked having been borrowed from my local library were being displayed as:

  • I borrowed this book fromlibrary

When they should simply have a line reading “I borrowed this book from my local library”. I had spent much
time fiddling with my templates trying to figure out how the upgrade broke them and today I figured it out. The truth is my template was just fine. The problem is the newer version of Now-Reading was applying a new filter to book-meta1. That filter is wpautop and it was wrapping my variable in <p> … </p> tags. Those tags screwed up the display and made my variable checks fail. To correct the problem, I went into now-reading/default-filters.php and commented out add_filter('book_meta_val', 'wpautop');. Now my single book pages look like they’re supposed to again. Yeah!

1 This is a custom field available in the back-end of the plugin and it is where I store the information telling my template if I borrowed the book and from whom I borrowed it.

Copyright © 2004 – 2018 Powered by WordPress.