/* get number of downloads with this code */ $downloads = $wpdb->get_row($wpdb->prepare("SELECT COUNT(*) AS downloads FROM " . dc_tbl_downloads() . " WHERE code=(SELECT ID FROM " . dc_tbl_codes() . " WHERE CONCAT(code_prefix, code_suffix) = %s )", array($post_code))); /* check if maximum of allowed downloads is reached */ if ($downloads->downloads < $release->allowed_downloads) { /* set temporary download lease ID */ $lease_ID = md5('wp-dl-hash' . $code->ID); /* generate html code for download form */ $sku = $release->title; $product_ID = get_product_id_by_sku($sku); $artists = array(); $data = get_field('product-artists', $product_ID); foreach ($data as $d) { $artists[] = get_the_title($d->ID); } $artist = implode(" & ", $artists); $title = get_release_attribute_value($product_ID, 'release-title'); $url = get_stylesheet_directory_uri() . "/download/download.php"; $return['download_form'] = "<form id=\"ac-download-form\" name=\"ac-download-form\" action=\"" . $url . "\" method=\"GET\"> \n" . "<input type=\"hidden\" name=\"lease\" value=\"" . $lease_ID . "\" /> \n" . "<div class='title'>" . $sku . " | " . $artist . " - " . $title . "</div> \n" . get_the_post_thumbnail($product_ID, "download-thumb") . "\n" . "<a id=\"ac-download-submit\" class=\"submit\" href=\"javascript:void(0)\" onclick=\"dlFormSubmit()\"><span>Download</span></a>" . "</form>"; } else { $return['error_message'] = "Sorry, that code has already been used."; } } else { $return['error_message'] = "Sorry, that code doesn't exist."; } echo json_encode($return); /* get current IP */ // $IP = $_SERVER['REMOTE_ADDR']; /* $wpdb->insert( dc_tbl_downloads(), array( 'code' => $post_code, 'IP' => $IP),
function widget($args, $instance) { extract($args); ?> <div class="last-releases-widget"> <header class="entry-header"><h2><?php echo $instance['title']; ?> </h2></header> <hr class='small-line' /> <?php /* get last 3 releases */ $release_ct = 0; query_posts(array('post_type' => 'product', 'posts_per_page' => $this->max_releases * 2, 'product_cat' => '7inches,10inches,12inches,other,tape,digital')); while (have_posts()) { the_post(); ?> <?php /* skip non-orphane digital releases */ $post_ID = get_the_ID(); $sku = get_product_sku_by_id($post_ID); if (substr($sku, -1) == 'd') { if (!is_null(get_product_id_by_sku(substr($sku, 0, -1)))) { continue; } } $release_ct++; /* set link */ $external_link = get_field('release-external_buy_link'); if (empty($external_link)) { $link = get_permalink($post_ID); } else { $link = '/shop#' . $post_ID; } /* check release count */ if ($release_ct == $this->max_releases + 1) { break; } ?> <a href="<?php echo $link; ?> "> <?php echo the_post_thumbnail('last-releases-thumb'); ?> <div class="details"> <?php $artists = array(); $data = get_field('product-artists'); foreach ($data as $d) { $artists[] = get_the_title($d->ID); } $title = get_release_attribute_value($post->ID, 'release-title'); ?> <h3> <span class="artist"><?php echo implode(" & ", $artists); ?> </span><br /> <?php if (!empty($title)) { ?> <span class="title"><?php echo $title; ?> </span> <?php } else { ?> <?php } ?> </h3> <hr class="small-line" /> </div> </a> <?php } ?> </div><?php }
} else { $special_link = get_field('release-special_link'); if (empty($special_link)) { $link = get_permalink($post_ID); } else { $link = $special_link; $external_link = true; } } $artists = array(); $data = get_field('product-artists'); foreach ($data as $d) { $artists[] = get_the_title($d->ID); } $title = get_release_attribute_value($post_ID, 'release-title'); $format = get_release_attribute_value($post_ID, 'release-format'); $price = get_post_meta($post_ID, '_regular_price'); $is_preorder = is_preorder($post->ID); $external_buy_link = get_field('release-external_buy_link'); ?> <!-- image --> <header class="entry-header"> <?php if ($is_digital && empty($physical_product_ID)) { ?> <a href="javascript:void(0)" name="<?php echo empty($physical_product_ID) ? $post_ID : $physical_product_ID; ?> "></a> <?php
<?php } ?> <header class="entry-header"> <?php echo the_post_thumbnail('releases-grid-thumb'); ?> </header> <div class="entry-content"> <?php $artists = array(); $data = get_field('product-artists'); foreach ($data as $d) { $artists[] = get_the_title($d->ID); } $title = get_release_attribute_value($post->ID, 'release-title'); ?> <h3> <span class="artist"><?php echo implode(" & ", $artists); ?> </span><br /> <?php if (!empty($title)) { ?> <span class="title"><?php echo $title; ?> </span> <?php } else {