function tdr_top_choices_table($args) { $defaults = array('number_to_show' => 3, 'number_to_query' => 3, 'offer_cat_terms' => get_terms('offer-category', array('fields' => 'ids')), 'rank_meta_key' => ''); $args = wp_parse_args($args, $defaults); extract($args, EXTR_SKIP); /* Set up the Query */ /* Taxonomy for the Query * ***************************************************************/ // Set up the taxonomy $offer_cat_args = array(array('taxonomy' => 'offer-category', 'field' => 'id', 'terms' => $offer_cat_terms)); /* Create the query * ***************************************************************/ $basic_query = new WP_Query(array('tax_query' => $offer_cat_args, 'post_type' => 'tdr_product', 'posts_per_page' => (int) $number_to_query, 'order' => 'ASC', 'orderby' => 'meta_value_num', 'meta_key' => 'thunder_plugin_products_rank')); // If a Rank Key is defined, reorder the Products if (!empty($rank_meta_key)) { global $tdr_rank_key; $tdr_rank_key = $rank_meta_key; usort(&$basic_query->{'posts'}, 'tdr_sort_by_offer_category_rank'); $basic_query->rewind_posts(); } // Update to only show the $number_to_show $basic_query->post_count = $number_to_show; $returner = '<div class="row">'; $returner .= '<div class="span">'; // Set up tdr_product $product = new Thunder_Plugin_Products(); while ($basic_query->have_posts()) { $basic_query->the_post(); // Get the ID for the Rating Bar, this determines how the stars appear $internal_rating = floatval($product->get_the_internal_rating()); if ($internal_rating < 2.2) { $internal_rating_id = 'two_zero'; } elseif ($internal_rating < 2.7) { $internal_rating_id = 'two_five'; } elseif ($internal_rating < 3.2) { $internal_rating_id = 'three_zero'; } elseif ($internal_rating < 3.7) { $internal_rating_id = 'three_five'; } elseif ($internal_rating < 4.2) { $internal_rating_id = 'four_zero'; } elseif ($internal_rating < 4.7) { $internal_rating_id = 'four_five'; } elseif ($internal_rating >= 4.7) { $internal_rating_id = 'five_zero'; } else { $internal_rating_id = $internal_rating; } // Force display of non-significant digits for the internal rating $internal_rating = sprintf("%1.1f", $internal_rating); // Output a row for this Product, and get its name $returner .= '<div class="row"><div class="span4" style="border-top: 1px solid #eee; padding: 10px 0;">'; $product_name = $product->get_the_affiliate_name(); // Get the logo, and set up link add_image_size('our_top_choices_thumb', 120, 30); $review_link = get_permalink(); $attr['alt'] = $product_name . ' Reviews'; $attr['title'] = $product_name . ' Reviews'; if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('tdr_product', 'thumbnail-affiliate-logo')) { $affiliate_img = MultiPostThumbnails::get_the_post_thumbnail('tdr_product', 'thumbnail-affiliate-logo', NULL, 'our_top_choices_thumb', $attr); } $returner .= "<div class='our_top_logos'>"; $returner .= "<a href='{$review_link}'>"; $returner .= $affiliate_img; $returner .= '</a>'; $returner .= "</div><!-- end .our_top_logos -->"; $returner .= "<div class='our_top_ratings' style=''>"; $returner .= "<div id='{$internal_rating_id}' class='rating-bar' style='position: relative; left: 5px;'></div>"; $returner .= "<span style='font-size: 24px; font-weight: bold; line-height: 24px; '>{$internal_rating}</span>" . " <span class='review-link'>(<a href='{$review_link}' style=''>Review</a>)</span>"; $returner .= "</div>"; $returner .= "<div class='our_top_visit' style=''>"; $product_id = $product->get_the_id(); $jump_page_url = get_home_url() . "/visit?site={$product_id}&t=sidebar"; $returner .= "<a target=_blank' href='{$jump_page_url}'><span style='font-size:10px;'>▶</span> Visit Site</a>"; $returner .= "</div>"; $returner .= '</div><!-- end .span --></div><!-- end .row -->'; } $returner .= "</div><!-- end .span -->"; $returner .= "</div><!-- end .row -->"; $returner .= '<div class="read_more_articles">'; $offer_category_permalink = get_home_url() . '/reviews'; $returner .= "<a href='{$offer_category_permalink}' id='review_page_link'>+ View All Reviews</a>"; $returner .= '</div><!-- end .read_more_articles -->'; return $returner; }
<div class="page-content"> <?php echo get_the_content(); ?> </div><!-- end .page-content --> </div><!-- end .span10 --> </div><!-- end .row --> <?php } ?> <!-- Comparisons ----------------------------------------------------------------------> <?php $product = new Thunder_Plugin_Products(); $comparison_query_args = array('post_type' => 'tdr_product', 'meta_key' => 'thunder_plugin_products_int_rating', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'tax_query' => $tax_query); $comparison_query = new WP_Query($comparison_query_args); $comp_order = 1; while ($comparison_query->have_posts()) { $comparison_query->the_post(); $affiliate_name = $product->get_the_affiliate_name(); $internal_rating = floatval($product->get_the_internal_rating()); $internal_rating_id = ttwph_get_rating_id($internal_rating); $internal_rating = sprintf("%1.1f", $internal_rating); $comparison_points = $product->get_the_comparison_points(); ?> <div class="row"> <div class="span12"> <section class='comparison-table'> <!-- Rating -->
function tdr_save_local_key_value_pair() { // Initialize $tdr_product = new Thunder_Plugin_Products(); // Setup request return info for client callback $return_array = array('message' => '', 'confirm_message' => '', 'confirm_request' => false, 'error' => '', 'confirmation_key' => ''); // Check javascript client script version if ($_POST['client_version'] != 0.1) { $return_array['error'] = 'Your browser has an old version of the page loaded. Please try refreshing your page or clearing your browser cache, then try again.'; } else { // Parse Data $key_value_pairs = $_POST['key_value_json']; $key_value_pairs = stripslashes($key_value_pairs); $key_value_pairs = json_decode($key_value_pairs, true); $save_changes = true; // Save changes unless revoked below (no data &&& no confirmation) if (empty($key_value_pairs)) { // Check for confirmation key if (!isset($_POST['confirmation_key'])) { $return_array['confirm_request'] = true; $return_array['confirm_message'] = 'No data was received. If you wanted to clear the data in this section, please confirm.'; $save_changes = false; } // Else will proceed } if ($save_changes) { // Ensure meta_id is valid (exists) $meta_id = esc_html($_POST['meta_id']); $meta_array = $tdr_product->define_custom_meta_types(); $meta_id_valid = false; foreach ($meta_array as $meta_entry) { if ($tdr_product->underscore($meta_entry['uuid']) == $meta_id) { $meta_id_valid = true; } } if (!$meta_id_valid) { $return_array['error'] = 'The submission request contained tampered information.'; } else { // Need to get post id for ajax calling post $post_id = $_POST['post_id']; $meta_value = get_post_meta($post_id, $meta_id, true); // JSON Encode the meta $new_meta_value = json_encode($key_value_pairs); /* If there the new meta value is blank but an old value existed, delete it. */ if ('' == $new_meta_value && $meta_value) { delete_post_meta($post_id, $meta_id, $meta_value); } else { update_post_meta($post_id, $meta_id, $new_meta_value); } // echo('Nice. We have found json that has ' . count( $key_value_json ) . ' pairs'); // echo('Nice. You are on post ' . $post_id); $return_array['message'] = 'Your changes have been saved'; } } } $return_json = json_encode($return_array); echo $return_json; die; // this is required to return a proper result }