Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

User:IanD/WP itunes

Displaying current and recent songs on your blog

In order to use the following, you need:

  1. A Mac, running OS X and iTunes
  2. Wordpress - This plugin is known to work with WP1.2.2 up to WP1.5.1.2.

Optionally, you can use an AppleScript. Which you can find here: http://www.adamztech.com/adamzblog/?p=18 Works with Wordpress 2.1. Edit the script in Script Editor, and save as a 'stay open' application.

Implementation

  1. Get the Kung-tunes plugin from VersionTracker
  2. Install it. When you run the application, iTunes should start. Alternatively start iTunes first.

Configure Kung-tunes

  1. Get kung-tunes to upload files - you need to set it up to transfer to the root wp folder. The settings are:
Upload method: ftp
URL - ftp.your_ftp_path.com (my normal ftp path)
Proxy - field blank
File path - blank
name - trackinfo.txt
  1. FTP settings
Directory - /wordpress/ (the path to your wp root folder)
username - my ftp username
password - my ftp password
Only the use PASV-mode for file transfer box is ticked. (the default)

If you get this all right, you should then be able to get trackinfo.txt to appear your wp root when you click the upload now button.

Displaying the track listing on your blog

  1. Copy the following and save it as a plugin - myitunes.php (check it for white spaces):
< ?php
/*
Plugin Name: My iTunes
Plugin URI: http://chrisjdavis.org/index/category/wp-hacks/
Description: A plugin that parses the text file created by Kung-Tunes
and displays it on your site.
Author: Chris J. Davis
Author URI: http://chrisjdavis.org/
*/
function display_tunes() {
$fp=fopen("trackinfo.txt","r");
$track=fgets($fp,1024);
echo “$track";
fclose($fp);
}
?>
  1. Upload it into your plugins folder and activate it through your administration interface.
  2. Call the function into your blog with the function:
<?php display_tunes() ?>

Format the appearance of the tracklisting via the 'Formats' menu within kung-tunes.