''
);
/* Get settings from database via WordPress framework */
$pandorafeeds_settings = get_option('pandorafeeds_settings');
$pandorafeeds_flash = "";
if (pandorafeeds_user_is_authorized()) {
if (isset ($_POST['account-name'])) {
$pandorafeeds_settings['account-name'] = $_POST['account-name'];
update_option('pandorafeeds_settings', $pandorafeeds_settings);
$pandorafeeds_flash = "Your settings have been saved.";
}
} else {
$pandorafeeds_flash = "You don't have enough access rights.";
}
if ($pandorafeeds_flash != '')
echo '
' . $pandorafeeds_flash . '
';
echo '';
echo '
Set Up Your Pandora-feeds
';
echo '
';
echo '
';
}
/**
* Check if the current user is allowed to activate plugins.
*/
function pandorafeeds_user_is_authorized() {
global $user_level;
if (function_exists("current_user_can")) {
return current_user_can('activate_plugins');
} else {
return $user_level > 5;
}
}
/**
* This function fetches a feed containing the pandora-staions of the user.
*
* It returns HTML-listitems ( ... ) containing the name of the station and
* links back to the site pandora has for it.
*
* Attribute:
* $nrItems - the maximum number of items, this feed should return.
* Set to -1 for complete feed.
*/
function pandorafeeds_display_user_stations($nrItems) {
$rss = pandorafeeds_get_feed('stations');
if (is_array($rss->items)) {
$rss->items = array_slice($rss->items, 0, $nrItems);
foreach ($rss->items as $nr => $item) {
while (strstr($item['link'], 'http') != $item['link'])
// get data from feed
// Big thanks go to Jean-Paul Franssen!!!
// http://www.rgb255.nl/blog/2007/02/06/wordpress-pandora-widget/
$item['link'] = substr($item['link'], 1);
$link = wp_specialchars(strip_tags($item['link']), 1);
$title = wp_specialchars(strip_tags($item['title']), 1);
$desc = wp_specialchars(strip_tags($item['description']), 1);
$oddOrEven='';
if (!pandorafeeds_is_even($nr)){ $oddOrEven='odd';}
else {$oddOrEven='even';};?>
... ) containing the name of the artist and
* links back to the backstage site pandora has for it.
*
* Attribute:
* $nrItems - the maximum number of items, this feed should return.
* Set to -1 for complete feed.
*/
function pandorafeeds_display_bookmarked_artists($nrItems) {
$rss = pandorafeeds_get_feed('favoriteartists');
if (is_array($rss->items)) {
$rss->items = array_slice($rss->items, 0, $nrItems);
foreach ($rss->items as $nr => $item) {
while (strstr($item['link'], 'http') != $item['link'])
// get data from feed
// Big thanks go to Jean-Paul Franssen!!!
// http://www.rgb255.nl/blog/2007/02/06/wordpress-pandora-widget/
$item['link'] = substr($item['link'], 1);
$link = wp_specialchars(strip_tags($item['link']), 1);
$title = wp_specialchars(strip_tags($item['title']), 1);
$oddOrEven='';
if (!pandorafeeds_is_even($nr)){ $oddOrEven='odd';}
else {$oddOrEven='even';}?>
... ) containing a cover-image of the
* song's cd, song-title and artist's name. The artist links back to the
* backstage-site pandora has for this song.
*
* Attributes:
* $rss - the feed-object. Must be passed to the function by the
* calling funtion.
*
* $nrItems - the maximum number of items, this feed should return.
* Set to -1 for complete feed.
* $showCover - Show am image of the CD-Cover
* Set to true (show the image) or to false (show no image)
*/
function pandorafeeds_render_songs($rss, $nrItems, $showCover) {
if (is_array($rss->items)) {
$rss->items = array_slice($rss->items, 0, $nrItems);
foreach ($rss->items as $nr => $item) {
while (strstr($item['link'], 'http') != $item['link'])
$item['link'] = substr($item['link'], 1);
$link = wp_specialchars(strip_tags($item['link']), 1);
$title = wp_specialchars(strip_tags($item['title']), 1);
$desc = wp_specialchars(strip_tags($item['description']), 1);
// get data from feed
// Big thanks go to Jean-Paul Franssen!!!
// http://www.rgb255.nl/blog/2007/02/06/wordpress-pandora-widget/
if (preg_match('/http:\/\/www.pandora.com\/art.*\.jpg/', $item['atom_content'], $matches)) {
$image_url = $matches[0];
} else {
$image_url = "http://www.pandora.com/images/no_album_art.jpg";
}
$track = wp_specialchars(strip_tags($item['dc']['track_title']), 1);
$artist = wp_specialchars(strip_tags($item['dc']['artist_title']), 1);
$oddOrEven='';
if (!pandorafeeds_is_even($nr)){ $oddOrEven='odd';}
else {$oddOrEven='even';}
// ############ begin rendering ############
?>
by
Could not retrieve feed-data from Pandora. The service might be down.');
}
add_action('admin_menu', 'register_with_options');
function pandorafeeds_is_even($number) {
return $number & 1; // 0 = even, 1 = odd
}
?>