<?php the_title(); ?> </a> </div> </div> <div class="row"> <div class="sponsors col-sm-12"> <span class="browse-label">Sponsor<?php if (sizeof($metadata['ad_sponsors']) != 1) { echo "s"; } ?> : </span> <?php echo generate_sponsors_string($metadata['ad_sponsors']); ?> </div> </div> <div class="row"> <div class="candidates col-sm-12"> <span class="browse-label">Candidate<?php if (sizeof($metadata['ad_candidates']) != 1) { echo "s"; } ?> : </span> <?php echo generate_candidates_string($metadata['ad_candidates']); ?> </div>
<div id="about-ad-header" class="header-row row"> <div class="col-lg-12"> <h1>About This Ad</h1> </div> </div> <div class="row about-ad-row"> <div id="ad-sponsor" class="first cell"> <div class="cell-label">Sponsor <?php echo sizeof($ad_sponsors) == 1 ? '' : 's'; ?> </div> <div class="cell-value"> <?php echo generate_sponsors_string($ad_sponsors); ?> </div> </div> <div id="ad-candidate" class="cell"> <div class="cell-label">Candidate <?php echo sizeof($ad_candidates) == 1 ? '' : 's'; ?> </div> <div class="cell-value"> <?php echo generate_candidates_string($ad_candidates); ?> </div> </div>
/** Handle Requests * This is where we send off for an intense pug bomb package * @return void */ function export_handle_request() { global $wp; global $wpdb; // Collect the data associated with this ad $table_name = $wpdb->prefix . 'ad_instances'; $query = "SELECT id as id,\n network as network,\n air_time as air_time,\n archive_identifier as archive_identifier,\n wp_identifier as wp_identifier\n FROM " . $table_name . " "; if (array_key_exists('ad_identifier', $_GET)) { $ad_identifier = $_GET['ad_identifier']; $query .= "WHERE archive_identifier = '" . esc_sql($ad_identifier) . "'"; } $results = $wpdb->get_results($query); $rows = array(); $metadata_cache = array(); foreach ($results as $result) { $wp_identifier = $result->wp_identifier; $network = $result->network; $air_time = $result->air_time; $archive_identifier = $result->archive_identifier; // Cache the metadata for this identifier if (!array_key_exists($ad_identifier, $metadata_cache)) { $post_metadata = get_fields($wp_identifier); $metadata['ad_embed_url'] = $post_metadata['embed_url']; $metadata['ad_notes'] = $post_metadata['notes']; $metadata['archive_id'] = $post_metadata['archive_identifier']; $metadata['ad_sponsor'] = generate_sponsors_string($post_metadata['ad_sponsors']); $metadata['ad_candidate'] = generate_candidates_string($post_metadata['ad_candidates']); $metadata['ad_type'] = $post_metadata['ad_type']; $metadata['ad_message'] = $post_metadata['ad_message']; $metadata['ad_air_count'] = $post_metadata['air_count']; $metadata['ad_market_count'] = $post_metadata['market_count']; $metadata['ad_first_seen'] = $post_metadata['first_seen']; $metadata['ad_last_seen'] = $post_metadata['last_seen']; $metadata_cache[$ad_identifier] = $metadata; } // Load the metadata from the cache $ad_embed_url = $metadata_cache[$ad_identifier]['ad_embed_url']; $ad_notes = $metadata_cache[$ad_identifier]['ad_notes']; $ad_id = $metadata_cache[$ad_identifier]['ad_id']; $ad_sponsor = $metadata_cache[$ad_identifier]['ad_sponsor']; $ad_candidate = $metadata_cache[$ad_identifier]['ad_candidate']; $ad_type = $metadata_cache[$ad_identifier]['ad_type']; $ad_message = $metadata_cache[$ad_identifier]['ad_message']; $ad_air_count = $metadata_cache[$ad_identifier]['ad_air_count']; $ad_market_count = $metadata_cache[$ad_identifier]['ad_market_count']; $ad_first_seen = $metadata_cache[$ad_identifier]['ad_first_seen']; $ad_last_seen = $metadata_cache[$ad_identifier]['ad_last_seen']; // Create the row $row = ["wp_identifier" => $wp_identifier, "network" => $network, "air_time" => $air_time, "archive_id" => $archive_identifier, "embed_url" => $ad_embed_url, "sponsor" => $ad_sponsor, "candidate" => $ad_candidate, "type" => $ad_type, "message" => $ad_message, "air_count" => $ad_air_count, "market_count" => $ad_market_count, "first_seen" => $ad_first_seen, "last_seen" => $ad_last_seen, "notes" => $notes]; array_push($rows, $row); } export_send_response($rows); }