'Download', 'post_name' => 'artistography_download', 'post_content' => '[artistography_download]', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_type' => 'page' ); // Insert the post into the database $my_post_id = wp_insert_post( $my_post ); if($my_post_id) { add_option('wp_artistography_download_page', $my_post_id); } } /* Create Cart Page */ if (!get_option('wp_artistography_cart_page')) { // Create post object $my_post = array( 'post_title' => 'Cart', 'post_name' => 'artistography_cart', 'post_content' => '[artistography_show_cart]', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_type' => 'page' ); // Insert the post into the database $my_post_id = wp_insert_post( $my_post ); if($my_post_id) { add_option('wp_artistography_cart_page', $my_post_id); } } /* Create Checkout Page */ if (!get_option('wp_artistography_checkout_page')) { // Create post object $my_post = array( 'post_title' => 'Checkout', 'post_name' => 'artistography_checkout', 'post_content' => '[artistography_show_checkout]', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_type' => 'page' ); // Insert the post into the database $my_post_id = wp_insert_post( $my_post ); if($my_post_id) { add_option('wp_artistography_checkout_page', $my_post_id); } } /* Create Thank You Page */ if (!get_option('wp_artistography_thankyou_page')) { // Create post object $my_post = array( 'post_title' => 'Thank You', 'post_name' => 'artistography_thankyou', 'post_content' => '[artistography_show_thankyou]', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_type' => 'page' ); // Insert the post into the database $my_post_id = wp_insert_post( $my_post ); if($my_post_id) { add_option('wp_artistography_thankyou_page', $my_post_id); } } /* Create Orders Page */ if (!get_option('wp_artistography_orders_page')) { // Create post object $my_post = array( 'post_title' => 'Orders', 'post_name' => 'artistography_orders', 'post_content' => '[artistography_show_orders]', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_type' => 'page' ); // Insert the post into the database $my_post_id = wp_insert_post( $my_post ); if($my_post_id) { add_option('wp_artistography_orders_page', $my_post_id); } } /* Create IPN Page - PayPal Instant Notifications */ if (!get_option('wp_artistography_ipn_page')) { // Create post object $my_post = array( 'post_title' => 'IPN', 'post_name' => 'artistography_ipn', 'post_content' => '[artistography_ipn]', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_type' => 'page' ); // Insert the post into the database $my_post_id = wp_insert_post( $my_post ); if($my_post_id) { add_option('wp_artistography_ipn_page', $my_post_id); } } if (!is_dir($download_path)) { mkdir($download_path); } exec("cp $explorer_path $download_path/"); if (version_compare($version, "0.1.1", '<')) { // this is an update to at least 0.1.1 $thetable = $wpdb->prefix . $TABLE_NAME[TABLE_ARTISTS]; $query = "ALTER TABLE $thetable DROP COLUMN myspace_url"; $wpdb->query($query); $query = "ALTER TABLE $thetable DROP COLUMN birthday"; $wpdb->query($query); $query = "ALTER TABLE $thetable DROP COLUMN enabled"; $wpdb->query($query); $thetable = $wpdb->prefix . "artistography_track_list"; $query = "DROP TABLE $thetable"; $wpdb->query($query); } if (version_compare($version, "0.1.8", '<')) { $cart_page = get_option('wp_artistography_products_cart_page'); if($cart_page) { $result = wp_delete_post($cart_page, true); if($result) { delete_option('wp_aristography_products_cart_page'); } } $checkout_page = get_option('wp_artistography_products_checkout_page'); if($checkout_page) { $result = wp_delete_post($checkout_page, true); if($result) { delete_option('wp_aristography_products_checkout_page'); } } } if (version_compare($version, "0.1.9", '<')) { $thetable = $wpdb->prefix . $TABLE_NAME[TABLE_ARTIST_MUSIC_ALBUMS]; $query = "ALTER TABLE $thetable ADD COLUMN price DECIMAL (7,2) DEFAULT '0.00' NOT NULL"; $wpdb->query($query); $query = "ALTER TABLE $thetable DELETE COLUMN free_download_enabled"; $wpdb->query($query); $query = "ALTER TABLE $thetable DELETE COLUMN featured"; $wpdb->query($query); $query = "ALTER TABLE $thetable DELETE COLUMN enabled"; $wpdb->query($query); $query = "DROP TABLE wp_artistography_sales"; $wpdb->query($query); $my_post = array( 'ID' => get_option('wp_artistography_download_page'), 'comment_status' => 'closed', 'ping_status' => 'closed' ); wp_update_post( $my_post ); $my_post = array( 'ID' => get_option('wp_artistography_cart_page'), 'comment_status' => 'closed', 'ping_status' => 'closed' ); wp_update_post( $my_post ); $my_post = array( 'ID' => get_option('wp_artistography_checkout_page'), 'comment_status' => 'closed', 'ping_status' => 'closed' ); wp_update_post( $my_post ); } if (version_compare($version, "0.2.1", '<')) { $thetable = $wpdb->prefix . $TABLE_NAME[TABLE_ARTIST_ORDERS]; $query = "ALTER TABLE $thetable ADD COLUMN user_id INT(10) UNSIGNED DEFAULT '0' NOT NULL"; $wpdb->query($query); } if (version_compare($version, "0.2.1-alpha4", '<')) { $thetable = $wpdb->prefix . 'artistography_image_gallery'; $query = "DROP TABLE $thetable"; $wpdb->query($query); $thetable = $wpdb->prefix . $TABLE_NAME[TABLE_ARTIST_IMAGE_GALLERIES]; $query = "DROP TABLE $thetable"; $wpdb->query($query); } if (version_compare($version, "0.2.8-alpha2", '<')) { $thetable = $wpdb->prefix . $TABLE_NAME[TABLE_ARTIST_ORDERS]; $query = "DROP TABLE $thetable"; $wpdb->query($query); } if (version_compare($version, "0.2.8-alpha6", '<')) { delete_option('wp_artistography_business_name'); } if (version_compare($version, "0.2.8-alpha10", '<')) { $thetable = $wpdb->prefix . $TABLE_NAME[TABLE_ARTIST_ORDERS]; $query = "DROP TABLE $thetable"; $wpdb->query($query); $thetable = $wpdb->prefix . $TABLE_NAME[TABLE_ARTIST_MUSIC_ALBUMS]; $query = "ALTER TABLE $thetable DROP COLUMN artist_id"; $wpdb->query($query); } update_option('wp_artistography_version', ARTISTOGRAPHY_VERSION); // Create Data Tables If They Don't Already Exist foreach ($TABLE_NAME as $key => $value) { $thetable = $wpdb->prefix . $value; // if tables don't already exist create them if($wpdb->get_var("show tables like '$thetable'") != $thetable) { $query = "CREATE TABLE $thetable ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, create_date DATETIME NOT NULL, update_date DATETIME NOT NULL, poster_id INT(10) UNSIGNED DEFAULT '0' NOT NULL, last_updated_by_id INT(10) UNSIGNED DEFAULT '0' NOT NULL, "; switch ($key) { case TABLE_ARTISTS: $query .= "page_views INT(10) UNSIGNED DEFAULT '0' NOT NULL, name TEXT NOT NULL, picture_url TEXT NOT NULL, url TEXT, description LONGTEXT, enabled BOOLEAN DEFAULT false NOT NULL,"; break; case TABLE_SONGS: $query .= "artist_id INT(10) UNSIGNED DEFAULT '0' NOT NULL, name TEXT NOT NULL, url TEXT, price DECIMAL (7,2) DEFAULT '0.00' NOT NULL,"; break; case TABLE_SONG_ALBUM_LINKER: $query .= "song_id INT(10) UNSIGNED DEFAULT '0' NOT NULL, album_id INT(10) UNSIGNED DEFAULT '0' NOT NULL,"; break; case TABLE_ARTIST_ALBUM_LINKER: $query .= "artist_id INT(10) UNSIGNED DEFAULT '0' NOT NULL, album_id INT(10) UNSIGNED DEFAULT '0' NOT NULL,"; break; case TABLE_ARTIST_FILE_DOWNLOAD: $query .= "file_name VARCHAR(250), download_count INT(10) UNSIGNED DEFAULT '0' NOT NULL, enabled BOOLEAN DEFAULT FALSE NOT NULL,"; break; case TABLE_ARTIST_MUSIC_ALBUMS: $query .= "page_views INT(10) UNSIGNED DEFAULT '0' NOT NULL, artist_name TEXT NOT NULL, album_name TEXT NOT NULL, album_date DATETIME NOT NULL, artist_url TEXT, picture_url TEXT NOT NULL, store_url TEXT NOT NULL, download_id INT(10) UNSIGNED DEFAULT '0' NOT NULL, price DECIMAL (7,2) DEFAULT '0.00' NOT NULL, description LONGTEXT,"; break; case TABLE_ARTIST_IMAGE_GALLERIES: $query .= "page_views INT(10) UNSIGNED DEFAULT '0' NOT NULL, artist_id INT(10), name TEXT NOT NULL, gallery TEXT NOT NULL, cover_picture TEXT NOT NULL, description LONGTEXT,"; break; case TABLE_ARTIST_ORDERS: $query .= " payer_id TEXT NOT NULL, address_status TEXT, payer_status TEXT, forename TEXT NOT NULL, surname TEXT NOT NULL, email TEXT NOT NULL, address_line_1 TEXT NOT NULL, postcode TEXT NOT NULL, town TEXT NOT NULL, state TEXT NOT NULL, country_code TEXT NOT NULL, contact_phone TEXT, itemsOrdered TEXT, itemsNumberOrdered TEXT, quantityOrdered TEXT, txn_id TEXT NOT NULL, txn_type TEXT, parent_txn_id TEXT, verify_sign TEXT, payment_status TEXT NOT NULL, payment_amount TEXT, payment_currency TEXT, item_name TEXT, item_number TEXT, quantity TEXT, shipping TEXT, tax TEXT, mc_fee TEXT, mc_gross TEXT, mc_handling TEXT, mc_shipping TEXT, memo TEXT, pending_reason TEXT, refund_reason_code TEXT, refund_receipt_id TEXT, user_id INT(10) UNSIGNED DEFAULT '0' NOT NULL,"; break; } // end switch($key) $query .= "\n UNIQUE KEY id (id));"; $wpdb->query($query); } } // end foreach } register_activation_hook( __FILE__, 'artistography_pluginInstall' ); // DEACTIVATION FOR PLUGIN function artistography_pluginUninstall() { GLOBAL $wpdb, $TABLE_NAME, $download_path, $i18n_domain; if (!strcmp(get_option('wp_artistography_preserve_hidden_pages'), NULL)) { /* Delete Download Page - So it isn't visible while Artistography is disabled */ $download_page_id = get_option('wp_artistography_download_page'); if ($download_page_id) { // force delete download page $result = wp_delete_post( $download_page_id, true ); if($result) { delete_option('wp_artistography_download_page'); } } /* Delete Cart Page - So it isn't visible while Artistography is disabled */ $cart_page_id = get_option('wp_artistography_cart_page'); if ($cart_page_id) { // force delete cart page $result = wp_delete_post( $cart_page_id, true ); if($result) { delete_option('wp_artistography_cart_page'); } } /* Delete Checkout Page - So it isn't visible while Artistography is disabled */ $checkout_page_id = get_option('wp_artistography_checkout_page'); if ($checkout_page_id) { // force delete checkout page $result = wp_delete_post( $checkout_page_id, true ); if($result) { delete_option('wp_artistography_checkout_page'); } } /* Delete Orders Page - So it isn't visible while Artistography is disabled */ $orders_page_id = get_option('wp_artistography_orders_page'); if ($orders_page_id) { // force delete checkout page $result = wp_delete_post( $orders_page_id, true ); if($result) { delete_option('wp_artistography_orders_page'); } } /* Delete Thank You Page - So it isn't visible while Artistography is disabled */ $thankyou_page_id = get_option('wp_artistography_thankyou_page'); if ($thankyou_page_id) { // force delete checkout page $result = wp_delete_post( $thankyou_page_id, true ); if($result) { delete_option('wp_artistography_thankyou_page'); } } /* Delete IPN Page - So it isn't visible while Artistography is disabled */ $ipn_page_id = get_option('wp_artistography_ipn_page'); if ($ipn_page_id) { // force delete checkout page $result = wp_delete_post( $ipn_page_id, true ); if($result) { delete_option('wp_artistography_ipn_page'); } } } if (!strcmp(get_option('wp_artistography_preserve_database'), NULL)) { //Delete any options that's stored delete_option('wp_artistography_donate_email'); delete_option('wp_artistography_paypal_sandbox'); delete_option('wp_artistography_preserve_hidden_pages'); delete_option('wp_artistography_preserve_database'); delete_option('wp_artistography_email_notify_ftp'); delete_option('wp_artistography_ftp_host'); delete_option('wp_artistography_ftp_user'); delete_option('wp_artistography_ftp_pass'); delete_option('wp_artistography_ftp_path'); delete_option('wp_artistography_gallery_style'); delete_option('wp_artistography_version'); foreach ($TABLE_NAME as $key => $value) { $thetable = $wpdb->prefix . $value; $query = "DROP TABLE IF EXISTS $thetable"; $wpdb->query($query); } } } register_deactivation_hook( __FILE__, 'artistography_pluginUninstall' ); function artistography_is_current_version() { $version = get_option('wp_artistography_version'); return version_compare($version, ARTISTOGRAPHY_VERSION, '=') ? true : false; } function artistography_exclude_pages ($pages) { $excluded_ids = array( get_option('wp_artistography_download_page'), get_option('wp_artistography_cart_page'), get_option('wp_artistography_checkout_page'), get_option('wp_artistography_thankyou_page'), get_option('wp_artistography_orders_page'), get_option('wp_artistography_ipn_page') ); $shaved_pages = array(); foreach($pages as $page) { if ( ! in_array($page->ID, $excluded_ids) ) { $shaved_pages[] = $page; } } return $shaved_pages; } function my_soundmanager2_footer_hook() { $songs = new Song; if ($songs->loadByPrice('0.00')->getTotalRows() > 0) { echo '