/** * Manage releases panel - sends you out to add releases, remove releases, add reviews (and eventually add tracks). * * @return void */ function ribcage_manage_releases() { global $release, $releases, $artist, $tracks; $total_downloads = 0; $nonce = wp_create_nonce('ribcage_manage_releases'); if (isset($_REQUEST['release'])) { switch ($_REQUEST['ribcage_action']) { case 'stats': ribcage_release_stats(); return; break; case 'edit': check_admin_referer('ribcage_manage_releases'); ?> <div class="wrap"> <div id="icon-options-general" class="icon32"><br /></div> <?php $release = get_release($_REQUEST['release']); $artist = get_artist($release['release_artist']); $tracks = $release['release_tracks']; ?> <h2>Editing <?php release_title(); ?> </h2> <?php ribcage_release_form(); ?> <?php ribcage_tracks_form(); ?> </div> <?php return; break; case 'reviews': check_admin_referer('ribcage_manage_releases'); ribcage_manage_reviews(); return; break; case 'delete': check_admin_referer('ribcage_manage_releases'); delete_release($_REQUEST['release']); $message = " deleted"; break; } } if (isset($message)) { echo '<div id="message" class="updated fade"><p><strong>Release ' . $message . '.</strong></p></div>'; } register_column_headers('ribcage-manage-releases', array('cb' => '<input type="checkbox" />', 'release_image' => '', 'release_title' => 'Release', 'release_date' => 'Release Date', 'local_downloads' => 'Local Downloads', 'remote_downloads' => 'Remote Downloads', 'total_downloads' => 'Total Downloads')); $releases = list_recent_releases_blurb(); ?> <div class="wrap"> <div id="icon-options-general" class="icon32"><br /></div> <h2>Manage Releases</h2> <form action="<?php echo str_replace('%7E', '~', $_SERVER['REQUEST_URI']); ?> " method="post" id="ribcage_edit_artist" name="edit_artist"> <table class="widefat post fixed" cellspacing="0"> <thead> <tr> <?php print_column_headers('ribcage-manage-releases'); ?> </tr> </thead> <tfoot> <tr> <?php print_column_headers('ribcage-manage-releases', FALSE); ?> </tr> </tfoot> <tbody> <?php while (have_releases()) { the_release(); ?> <?php $artist = get_artist($release['release_artist']); ?> <?php echo $alt % 2 ? '<tr valign="top" class="">' : '<tr valign="top" class="alternate">'; ++$alt; ?> <th scope="row" class="check-column"><input type="checkbox" name="artistcheck[]" value="2" /></th> <td class="column-icon"><img src="<?php release_cover_tiny(); ?> " height="65px" width="65px" alt="<?php release_title(); ?> " /></td> <td class="column-name"><strong><a class="row-title" href="?page=manage_releases&release=<?php artist_id(); ?> " title="<?php artist_name(); ?> " ><?php artist_name(); ?> - <?php release_title(); ?> </strong></a><br /><div class="row-actions"><span class='stats'><a href="?page=manage_releases&release=<?php release_id(); ?> &ribcage_action=stats&_wpnonce=<?php echo $nonce; ?> ">Stats</a></span> | <span class='edit'><a href="?page=manage_releases&release=<?php release_id(); ?> &ribcage_action=edit&_wpnonce=<?php echo $nonce; ?> ">Edit</a></span> | <span class='reviews'><a href="?page=manage_releases&release=<?php release_id(); ?> &ribcage_action=reviews&_wpnonce=<?php echo $nonce; ?> ">Reviews</a></span> | <span class='delete'><a class='submitdelete' href='?page=manage_releases&release=<?php release_id(); ?> &ribcage_action=delete&_wpnonce=<?php echo $nonce; ?> ' onclick="if ( confirm('You are about to delete \'<?php artist_name(); ?> - <?php release_title(); ?> \'\n \'Cancel\' to stop, \'OK\' to delete.') ) { return true;}return false;">Delete</a></span></div></td> <td class="column-name"><?php echo date('j F Y', strtotime($release['release_date'])); ?> </td> <td class="column-name"><?php release_downloads(); ?> </td> <td class="column-name"><?php //remote_downloads(); ?> </td> <td class="column-name"><?php //echo number_format(remote_downloads(FALSE)+release_downloads(FALSE)); $total_downloads = $total_downloads + remote_downloads(FALSE)+release_downloads(FALSE); update_option('ribcage_total_downloads', $total_downloads); ?> </td> </tr> <?php } ?> </tbody> </table> </form> <p>Served <?php echo number_format($total_downloads); ?> downloads so far.</p> </div> <?php update_option('ribcage_total_downloads', $total_downloads); }
/** * Runs the whole of Ribcage. * A filter on the template that tries to find out if we are on a Ribcage page and responds accordingly. * * @author Alex Andrews <*****@*****.**> * @return void */ function ribcage_init() { global $wp_query; global $artists, $artist, $current_artist; global $releases, $release, $current_release; global $tracks, $track, $current_track; global $reviews, $review, $current_review; global $product; wp_enqueue_script('ribcage-player-popup', plugins_url('js/player.js', __FILE__), null, '3.0'); // Add our streams. add_filter('wp_head', 'ribcage_release_feeds'); if (is_ribcage_page() == 0) { return; } $GLOBALS['ribcage_page'] = TRUE; // Add our bits to the page title in the header ans elsewhere. add_filter('wp_title', 'ribcage_page_title', 10, 3); // Donate IPN from Paypal if (isset($wp_query->query_vars['ribcage_donate_ipn'])) { ribcage_donate_ipn(); } // Artist Index if (isset($wp_query->query_vars['artist_index'])) { $artists = list_artists_blurb(); $artist = $artists[$current_artist]; $wp_query->query_vars['pagename'] = 'artists'; $load = ribcage_load_template('artist-index.php'); } // Individual Artist (including bio, contact et al) if (isset($wp_query->query_vars['artist_slug'])) { $artist = get_artist_by_slug($wp_query->query_vars['artist_slug']); if (is_wp_error($artist)) { ribcage_404(); } $wp_query->query_vars['pagename'] = $wp_query->query_vars['artist_slug']; if (is_artist_page()) { switch ($wp_query->query_vars['artist_page']) { case 'press': $releases = list_artist_releases($artist['artist_id'], TRUE); $load = ribcage_load_template('press.php'); break; case 'bio': $load = ribcage_load_template('bio.php'); break; case 'feed': $releases = list_artist_releases($artist['artist_id']); $load = ribcage_load_template('feeds/artist-rss2.php'); break; default: $release = get_release_by_slug($wp_query->query_vars['artist_page']); if (is_wp_error($release)) { ribcage_404(); } $tracks = $release['release_tracks']; $reviews = $release['release_reviews']; $load = ribcage_load_template('release.php'); } } else { $releases = list_artist_releases($artist['artist_id']); $load = ribcage_load_template('artist.php'); } } // Releases Index if (isset($wp_query->query_vars['release_index']) or isset($wp_query->query_vars['release_feed'])) { $releases = list_recent_releases_blurb(); $artists = list_artists_blurb(); $wp_query->query_vars['pagename'] = 'releases'; if (isset($wp_query->query_vars['release_feed'])) { $load = ribcage_load_template('feeds/release-rss2.php'); } else { $load = ribcage_load_template('release-index.php'); } } // Downloads if (isset($wp_query->query_vars['ribcage_download'])) { // Download whole release. if (isset($wp_query->query_vars['release_slug']) && isset($wp_query->query_vars['format'])) { // Re-direct them to donate at Paypal if ($wp_query->query_vars['format'] == 'donate') { $release = get_release_by_slug($wp_query->query_vars['release_slug'], FALSE, FALSE); if (is_wp_error($release)) { ribcage_404(); } $artist = get_artist($release['release_artist']); if (is_wp_error($artist)) { ribcage_404(); } ribcage_donate(); } else { if ($wp_query->query_vars['format'] == 'back') { ribcage_donate_download_thanks(); } else { if ($wp_query->query_vars['format'] == 'skip') { $release = get_release_by_slug($wp_query->query_vars['release_slug'], FALSE, FALSE); if (is_wp_error($release)) { ribcage_404(); } $artist = get_artist($release['release_artist']); if (is_wp_error($artist)) { ribcage_404(); } $load = ribcage_load_template('download.php'); } else { $release = get_release_by_slug($wp_query->query_vars['release_slug'], FALSE, FALSE); if (is_wp_error($release)) { ribcage_404(); } $artist = get_artist($release['release_artist']); if (is_wp_error($artist)) { ribcage_404(); } $load = ribcage_load_template('post-download.php'); } } } } else { if (isset($wp_query->query_vars['track_slug'])) { $load = download_track($wp_query->query_vars['track_slug'], $wp_query->query_vars['format']); } else { if (isset($wp_query->query_vars['release_slug'])) { $release = get_release_by_slug($wp_query->query_vars['release_slug'], FALSE, FALSE); if (is_wp_error($release)) { ribcage_404(); } $artist = get_artist($release['release_artist']); if (is_wp_error($artist)) { ribcage_404(); } // Special case for Matthew Jenning's Christmas Koto if ($release["release_slug"] === 'christmas-koto') { $load = ribcage_load_template('koto-nag.php'); die; } // If we haven't seen the user before, then nag them about the download. if (!isset($_COOKIE["ask_donate"])) { setcookie("ask_donate", "1", time() + 3600); $load = ribcage_load_template('nag.php'); } else { if (isset($_COOKIE["ask_donate"])) { $random = rand(1, 8); if ($random == 5) { $load = ribcage_load_template('nag.php'); } else { $load = ribcage_load_template('download.php'); } } } // If the user has just got back from Paypal congratulate them on their brillance and given them // the download. Maybe lower the chance of a nag? } } } } // Streams if (isset($wp_query->query_vars['ribcage_stream'])) { // Stream whole release. if (isset($wp_query->query_vars['release_slug'])) { $load = stream_release($wp_query->query_vars['release_slug'], $wp_query->query_vars['stream_format']); } // Stream individual track. if (isset($wp_query->query_vars['track_slug'])) { $load = stream_track($wp_query->query_vars['track_slug']); } } if (isset($wp_query->query_vars['ribcage_player'])) { if ($wp_query->query_vars['release_slug'] == 'stats') { ribcage_log_play(); } else { $load = show_player($wp_query->query_vars['release_slug']); } } // Purchases if (isset($wp_query->query_vars['ribcage_buy']) && isset($wp_query->query_vars['ribcage_product_id'])) { // Lookup the item they are looking for in the database. $product = get_product($wp_query->query_vars['ribcage_product_id']); if (is_wp_error($product)) { ribcage_404(); } // Some products are associated with releases, some are not. if (isset($product['product_related_release'])) { $release = get_release($product['product_related_release']); $artist = get_artist($release['release_artist']); } // Set this so the feeds at the bottom of the page show up for the artist. $wp_query->query_vars['artist_slug'] = true; if (isset($wp_query->query_vars['ribcage_buy_mode'])) { switch ($wp_query->query_vars['ribcage_buy_mode']) { // Send them to Paypal case 'go-ww': case 'go-uk': ribcage_buy_process(); break; // They just got back from Paypal and it was a success. Thank them for it. // They just got back from Paypal and it was a success. Thank them for it. case 'thanks': $load = ribcage_load_template('thanks.php'); break; // We are recieving an IPN ping from Paypal. // We are recieving an IPN ping from Paypal. case 'ipn': ribcage_buy_ipn(); break; // They cancelled. // They cancelled. case 'cancel': echo "Cancelled"; break; } } else { $load = ribcage_load_template('buy.php'); } } // Did we get an error by the end of all this? If so let the user know. if (is_wp_error($load)) { echo $load->get_error_message(); } // Don't output anything else. die; }
/** * Displays recent releases widget. */ public function widget($args, $instance) { global $releases, $release, $artist; extract($args); $releases = list_recent_releases_blurb('16'); $artists = list_artists_blurb(); ?> <?php echo $before_widget; ?> <?php echo $before_title . 'Recent Releases' . $after_title; ?> <div class="textwidget" align="left"> <?php while (have_releases()) { the_release(); ?> <?php $artist = get_artist($release['release_artist']); ?> <div class="artist_slug"> <a class="slug" href="<?php echo home_url(); ?> /artists/<?php artist_slug(); ?> /<?php release_slug(); ?> "><img src="<?php release_cover_tiny(); ?> " alt="<?php release_title(); ?> " /></a> <div class="artist_slug_info"> <ul class="artist_slug_main"> <li class="artist"><a href="<?php echo home_url(); ?> /artists/<?php artist_slug(); ?> /"><?php artist_name(); ?> </a><h2><a href="<?php echo home_url(); ?> /artists/<?php artist_slug(); ?> /<?php release_slug(); ?> "><?php release_title(); ?> </a></h2></li> </ul> <ul class="artist_slug_meta"> <li class="more"><a href="<?php echo home_url(); ?> /artists/<?php artist_slug(); ?> /<?php release_slug(); ?> ">More</a></li> <li class="listen"><a href="javascript:popUp('<?php release_player_link(); ?> ')">Listen</a></li> <?php if (release_physical()) { ?> <li class="download"><a href="<?php echo home_url(); ?> /download/<?php release_slug(); ?> /">Free Download</a></li> <li class="last buy"><a href="<?php echo home_url(); ?> /buy/<?php release_product_id(); ?> ">Buy</a></li> <?php } else { ?> <li class="last download"><a href="<?php echo home_url(); ?> /download/<?php release_slug(); ?> /">Free Download</a></li> <?php } ?> </ul> </div> <!-- end div.artist_slug_info --> <div class="clear"></div> </div> <!-- end div.artist_slug --> <?php } ?> <div class="clear"></div> <p class="more_link"><a href="<?php echo home_url(); ?> /releases/">more releases ›</a></p> </div> <?php echo $after_widget; ?> <?php }
/** * Displays a form used for editing or adding a product to database. * * @param string $error Error message from the manage_products form. * @param bool $related_to_release If true then we are passing from adding a release in general so we set the relation to this automatically * @return void */ function ribcage_edit_product_form($error = 0, $related_to_release = 0) { global $artist; global $release, $releases; global $product; if (isset($_REQUEST['product'])) { $product = get_product($_REQUEST['product']); } $releases = list_recent_releases_blurb(); if ($error) { echo '<div id="message" class="error"><p><strong>' . $error . '</strong></p></div>'; } ?> <div class="wrap"> <div id="icon-options-general" class="icon32"><br /></div> <?php if (isset($_REQUEST['product'])) { ?> <h2>Editing <?php product_name(); ?> </h2> <form action="<?php echo home_url(); ?> /wp-admin/admin.php?page=manage_products&product=<?php product_id(); ?> &ribcage_action=edited" method="post" id="ribcage_edit_artist" name="edit_artist"> <?php } else { ?> <h2>Add A Product</h2> <form action="<?php echo home_url(); ?> /wp-admin/admin.php?page=manage_products&ribcage_action=add" method="post" id="ribcage_edit_artist" name="edit_artist"> <?php } ?> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="product_name">Name</label></th> <td> <input type="text" value="<?php product_name(); ?> " name="product_name" id="product_name" class="regular-text"/> </td> </tr> <tr valign="top"> <th scope="row"><label for="product_name">Price</label></th> <td> <input type="text" value="<?php echo $product['product_cost']; ?> " name="product_cost" id="product_cost" class="regular-text"/> </td> </tr> <tr valign="top"> <th scope="row"><label for="product_related_release">Related To Release</label></th> <td> <select name="product_related_release" id="product_related_release"> <option value = "">None</option> <?php while (have_releases()) { the_release(); ?> <?php $artist['artist_name'] = get_artistname_by_id($release['release_artist']); ?> <?php if ($release['release_id'] == $product['product_related_release']) { ?> <option selected value="<?php release_id(); ?> "><?php artist_name(); ?> - <?php release_title(); ?> </option> <?php } else { ?> <option value="<?php release_id(); ?> "><?php artist_name(); ?> - <?php release_title(); ?> </option> <?php } ?> <?php } ?> </select> </td> </tr> <tr valign="top"> <th scope="row"><label for="product_name">Product Description</label></th> <td> <textarea rows="10" cols="100" name="product_description" id="product_description" class="regular-text"><?php product_description(); ?> </textarea> </td> </tr> </table> <p class="submit"> <input type="submit" name="Submit" class="button-primary" value="Save Changes" /> </p> </form> </div> <?php }
</div> <div class="col3 ivystreet"> <h2><a href="http://bryan.is/a/designer" title="Bryan Klausmeyer" target="_blank">Designed by Bryan</a>.</h2> </div> <div class="clear"></div> </div> <!-- end div.colgroup1 --> <div class="colgroup2"> <div class="col1 albums"> <h2><a href="<?php echo home_url(); ?> /releases/" title="Recent Releases">Releases</a> ›</h2> <?php global $releases, $release, $artist; $releases = list_recent_releases_blurb('10'); while (have_releases()) { the_release(); ?> <?php $artist = get_artist($release['release_artist']); ?> <div class="artist_slug"> <a href="<?php echo home_url(); ?> /artists/<?php artist_slug(); ?> /<?php release_slug();
/** * Outputs a number of recent albums in an unordered list of various kinds. * * @author Alex Andrews <*****@*****.**> * @param int $amount The number of recent albums you want to output. * @param string $mode Different formats: 'list' simple list, 'covers' list of covers, similar to the sidebar widget. * @param bool $nav_bar Displays a navigation bar for each release. * @param string $css An optional css marker to put in the style of each element. */ function ribcage_albums($amount = 5, $mode = 'list', $nav_bar = TRUE, $css = NULL) { global $releases, $release; global $artist; if ($releases == NULL) { $releases = list_recent_releases_blurb($amount); } ?> <ul class="ribcage albums<?php if (isset($css)) { print " {$css}"; } ?> "> <?php while (have_releases()) { the_release(); ?> <?php $artist = get_artist($release['release_artist']); ?> <li class="ribcage albums<?php if (isset($css)) { print " {$css}"; } ?> <?php release_slug(); ?> "> <ul class="ribcage albums<?php if (isset($css)) { print " {$css}"; } ?> <?php release_slug(); ?> "> <?php if ($mode == 'covers') { ?> <li class="album_cover"><a class="ribcage albums album_cover" href="<a href="<?php echo home_url(); ?> /artists/<?php artist_slug(); ?> /<?php release_slug(); ?> "><img src="<?php release_cover_tiny(); ?> " alt="<?php release_title(); ?> " /></a></li> <?php } ?> <li class="artist"><a href="<?php echo home_url(); ?> /artists/<?php artist_slug(); ?> /"><?php artist_name(); ?> </a></li> <li class="title"><a href="<?php echo home_url(); ?> /artists/<?php artist_slug(); ?> /<?php release_slug(); ?> "><?php release_title(); ?> </a></li> <?php if ($nav_bar) { ?> <li class="nav"> <ul class="nav"> <li class="more"><a href="<?php echo home_url(); ?> /artists/<?php artist_slug(); ?> /<?php release_slug(); ?> ">More</a></li> <li class="listen"><a href="javascript:popUp('<?php release_player_link(); ?> ')">Listen</a></li> <?php if (release_physical()) { ?> <li class="download"><a href="<?php echo home_url(); ?> /download/<?php release_slug(); ?> /">Download</a></li> <li class="last buy"><a href="<?php echo home_url(); ?> /buy/<?php release_product_id(); ?> ">Buy</a></li> <?php } else { ?> <li class="last download"><a href="<?php echo home_url(); ?> /download/<?php release_slug(); ?> /">Download</a></li> <?php } ?> </ul> </li> <?php } ?> </ul> </li> <?php } ?> </ul> <?php }
/** * Adds a widget for recent releases, the quantity of which is defined by an option. * * @author Alexander Andrews **/ function recent_releases($args) { global $releases, $release, $artist; extract($args); $releases = list_recent_releases_blurb('5'); $artists = list_artists_blurb(); ?> <?php echo $before_widget; ?> <?php echo $before_title . 'Recent Releases' . $after_title; ?> <div class="textwidget" align="left"> <?php while (have_releases()) { the_release(); ?> <?php $artist = get_artist($release['release_artist']); ?> <div style="margin-bottom:25px;font-size:12px;"><a href="<?php echo get_option('siteurl'); ?> /artists/<?php artist_slug(); ?> /<?php release_slug(); ?> "><img src="<?php release_cover_tiny(); ?> " align="right" style="margin-left: 10px; border: 1px solid #000;" height="65px" width="65px" alt="<?php release_title(); ?> " /></a> <a href="<?php echo get_option('siteurl'); ?> /artists/<?php artist_slug(); ?> /" style="font-size:12px;"><?php artist_name(); ?> </a> - <a href="<?php echo get_option('siteurl'); ?> /artists/<?php artist_slug(); ?> /<?php release_slug(); ?> " style="font-size:12px;"><?php release_title(); ?> </a><br /> <div style="font-size:9px;"> <a href="<?php echo get_option('siteurl'); ?> /artists/<?php artist_slug(); ?> /<?php release_slug(); ?> " style="font-size:11px;color:black;">More</a> - <a href="javascript:popUp('<?php release_player_link(); ?> ')" style="font-size:11px;color:black;">Listen</a> - <a href="<?php echo get_option('siteurl'); ?> /download/<?php release_slug(); ?> /" style="font-size:11px;color:black;">Download</a><?php if (release_physical()) { ?> - <a href="<?php get_option('siteurl'); ?> /buy/<?php release_product_id(); ?> " style="font-size:11px;color:black;">Buy</a><?php } ?> </div> </div> <?php } ?> <p><a href="<?php echo get_option('siteurl'); ?> /releases/">More Releases...</a></p> </div> <?php echo $after_widget; ?> <?php }