iTunesSpy with WordPress Hack

iTunesSpy is a great little tool that i just installed on my blog that tells my readers what I’m listening to at the moment… assuming they care, that is. You might ask, “so what?” Well, what if i told you, that it tells my readers what I’m listening to… WITHOUT ME HAVING TO TYPE IT IN… yes, my friends… it’s automatic.

Check out their website for details, support, and installation information: iTunesSpy
You can download the current version here: iTunesSpy v. 2.0.2

Well, the thing is, installation was not as simple as their documentation made it sound.
So after you install the script please refer to these steps below:

Step 1: Wrapping the headers in admin.php

When itunesspy plugin is installed in WordPress, activating it adds the iTunesSpy menu tab to the WP-Admin Dashboard. Since admin.php is included in the wp-itunesspy-xxx files, the header information ends up being sent twice: Once in the dashboard itself, and then when the iTunesSpy section is loaded. and this of course, is very, very bad :) To fix this, go to root>/wpadmin/admin.php and look for:


header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');

Wrap this code in a header check so it looks like this:


if (! headers_sent()) {
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
}

This will get rid of the errors you may receive saying that the header is being requested after it has already been sent.

Step 2: Editing menu.php

The iTunesSpy tab also includes menu.php, which makes a reference to the $wpdb variable, which is not set in iTunesSpy, so this will cause an error. And errors, well, they suck. So, to fix this, go to /wp-admin/menu.php and replace:


$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");

with:


if (isset($wpdb)) {
$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
} else {
$awaiting_mod = -1;
}

Final Step: Rearranging one of the functions in wp-itunesspyAdmin.php

I received an error saying: function wp_iTunesSpy_setdefault is already defined, or something of that nature. So to fix this, make sure the first conditional looks like this:


if ($user_level > 7) {
if (get_option('itunesspy_authcode') '') {
update_option('itunesspy_authcode', 'some-access-key');
}

if (get_option('itunesspy_amazonfeedlocale') ‘’) {
update_option(‘itunesspy_amazonfeedlocale’, ‘us’);
}

if (get_option(‘itunesspy_input_mode’) '') {
update_option('itunesspy_input_mode', 'get');
}

if (get_option('itunesspy_input_option') ‘’) {
update_option(‘itunesspy_input_option’, ‘fopen’);
}

}

And please erase the entire function : wp_iTunesSpy_setdefault which is defined below the conditional.

At this point you are good to go! Follow the instructions on the iTunesSpy homepage and you’re set to let the world know what you’re listening to… if they care, that is.

facebooktwittergoogle_plus