query_total_rows = $rows; }
protected function setCurrNode ($node) { $this->query_curr_node = $node; }
// get funcs (public)
public function getTotalRows () { return $this->query_total_rows; }
public function getCurrNode () { return $this->query_curr_node; }
public function getQueryResult () { return $this->query_result; }
public function __construct() {
GLOBAL $wpdb, $TABLE_NAME;
self::$artistTable = $wpdb->prefix . $TABLE_NAME[TABLE_ARTISTS];
self::$musicTable = $wpdb->prefix . $TABLE_NAME[TABLE_ARTIST_MUSIC_ALBUMS];
self::$discographyTable = $wpdb->prefix . $TABLE_NAME[TABLE_ARTIST_ALBUM_LINKER];
$this->loadAll();
$this->artist = new Artist;
$this->album = new Music;
}
public function __destruct() {
unset($this->artist);
unset($this->album);
}
public static function callback_Connect_Artist_to_Album(){
GLOBAL $i18n_domain;
$artist_id = $_POST['artist_id'];
$album_id = $_POST['album_id'];
$discography = new Discography;
$discography->loadAllByArtistAlbum($artist_id, $album_id);
if ($discography->getTotalRows() > 0) {
_e("The Artist is already attached to that album.", $i18n_domain); // failed
} else {
$discography->insert($artist_id, $album_id);
echo "1"; // success
}
unset($discography);
die;
}
public static function callback_Disconnect_Artist_from_Album(){
GLOBAL $i18n_domain;
$artist_id = $_POST['artist_id'];
$album_id = $_POST['album_id'];
$discography = new Discography;
$discography->loadAllByArtistAlbum($artist_id, $album_id);
if ($discography->getTotalRows() > 0) {
$discography->deleteById($discography->id);
echo "1"; // success
} else {
_e("Failed to Disconnect Artist from Album as it appears there currently is no connection between them on the server. "
. "It's possible another administrator may be using this feature at the same time.", $i18n_domain); // failed
}
unset($discography);
die;
}
public static function conditionally_add_scripts_and_styles($posts){
GLOBAL $artistography_plugin_dir;
if (empty($posts)) return $posts;
$shortcode_found = false; // use this flag to see if styles and scripts need to be enqueued
foreach ($posts as $the_post) {
if (FALSE !== stripos($the_post->post_content, '[artistography_display_artist_page')) {
$shortcode_found = true; // bingo!
break;
}
}
if ($shortcode_found) {
// enqueue here
artistography_enqueue_style_and_scripts();
}
return $posts;
}
// [artistography_album_art id=""]
public static function shortCodeAlbumArt( $atts, $content=null, $code="") {
extract( shortcode_atts( array(
'id' => '0'
), $atts ) );
GLOBAL $i18n_domain;
$id = esc_attr($id);
$discography = new Discography;
$artist = new Artist;
$album = new Music;
$html = "";
$html = "[caption id=\"attachment_557\" align=\"alignleft\" width=\"300\" caption=\"Dr. Oscify Breathe Easy Soon\"]
[/caption]\n";
unset($discography);
unset($artist);
unset($album);
return do_shortcode($html);
}
// [artistography_album_download_link id=""]
public static function shortCodeAlbumDownloadLink( $atts, $content=null, $code="") {
extract( shortcode_atts( array(
'id' => '0'
), $atts ) );
GLOBAL $i18n_domain, $artistography_plugin_dir;
GLOBAL $download_icon_url, $download_icon_width, $download_icon_height;
GLOBAL $add_to_cart_icon_url, $add_to_cart_icon_width, $add_to_cart_icon_height;
$id = esc_attr($id);
$album = new Music;
$html = "";
$album->loadById($id);
if ($album->download_id > 0) {
if ($album->price == "0.00") {
$html .= " "
. " ";
} else {
$html .= "Price: " .CURRENCY. "$album->price
\n"
. "