function display_listings($atts = array(), $echo_this = false) { global $wpdb; extract(shortcode_atts(array('type' => $wpdb->escape($_POST["type"]), 'l_type' => $wpdb->escape($_REQUEST["l_type"]), 'ex_type' => $wpdb->escape($_REQUEST["ex_type"]), 'l_featured' => $wpdb->escape($_POST["l_featured"]), 'order_dir' => $wpdb->escape($_POST["order_dir"]), 'order_by' => $wpdb->escape($_POST["order_by"]), 'l_ids' => $wpdb->escape($_REQUEST["l_ids"]), 'limit' => $wpdb->escape($_REQUEST["limit"]), 'show_paging' => $wpdb->escape($_POST["show_paging"])), $atts)); $data = get_option("bepro_listings"); $num_results = empty($limit) || !is_numeric($limit) ? $data["num_listings"] : $limit; $type = empty($type) ? 1 : $type; //find which types are allowed if (!empty($ex_type) && bl_check_is_valid_cat($ex_type)) { $raw_l_types = get_terms(array('bepro_listing_types'), array('exclude' => explode(",", $ex_type))); foreach ($raw_l_types as $raw_l_type) { $l_type[] = $raw_l_type->term_id; } if (!empty($l_type) && is_array($l_type)) { $l_type = implode(",", $l_type); } } //make presumption to randomize featured listings if (empty($order_by) && !empty($l_featured)) { $order_by = 2; } if (empty($order_dir)) { $order_dir = 1; } $findings = process_listings_results($show_paging, $num_results, $l_type, $l_ids, $order_by, $order_dir); $raw_results = $findings[0]; //Create the GUI layout for the listings if (empty($raw_results) || is_null($raw_results)) { $results = "<p>your criteria returned no results.</p>"; } else { //item listing template $list_templates = isset($data['bepro_listings_list_template_' . $type]) ? $data['bepro_listings_list_template_' . $type] : $data['bepro_listings_list_template_1']; foreach ($list_templates as $key => $val) { if ($key == "style") { $results .= "<link href='" . $val . "' rel='stylesheet' />"; } else { if ($key == "template_file") { $results .= ""; } else { add_action($key, $val); } } } $previous = array(); $check = apply_filters("bl_start_bepro_listing_template", $type); $results .= @(is_numeric($check) || $check == $type) ? "" : $check; //loop over listing template file foreach ($raw_results as $result) { $check = apply_filters("bl_before_bepro_listing_template", $type, $result, $previous); $results .= @(is_numeric($check) || $check == $type) ? "" : $check; $result->featured = is_numeric($l_featured); $results .= basic_listing_layout($result, $list_templates["template_file"]); $check = apply_filters("bl_after_bepro_listing_template", $type, $result, $previous); $results .= @(is_numeric($check) || $check == $type) ? "" : $check; $previous = $result; } $check = apply_filters("bl_end_bepro_listing_template", $type); $results .= @(is_numeric($check) || $check == $type) ? "" : $check; foreach ($list_templates as $key => $val) { remove_action($key, $val); } } //show paging if not featured listings and if its selected as an option if ($show_paging == 1 && empty($l_featured)) { $pages = 0; $pages = $findings[1]; $counter = 1; $paging = "<div style='clear:both'><br /></div><div class='paging'>Pages: "; while ($pages != 0) { $selected = !empty($_REQUEST["lpage"]) && $counter == $_REQUEST["lpage"] || empty($_REQUEST["lpage"]) && $counter == 1 ? $selected = "selected" : ""; $paging .= "<a href='?lpage=" . $counter . "' class='{$selected}'>" . $counter . "</a>"; $pages--; $counter++; } $paging .= "</div>"; if ($counter > 1) { $results .= $paging; } // if no pages then dont show this $show_paging = "<div id='bl_show_paging' class='bl_shortcode_selected'>{$show_paging}</div>"; } else { if (empty($l_featured)) { $show_paging = "<div id='bl_show_paging' class='bl_shortcode_selected'>0</div>"; } } if (!empty($l_featured)) { $l_featured_id = "_featured"; } else { $show_bl_type = "<div id='bl_type' class='bl_shortcode_selected'>{$type}</div>"; $hidden_limit_text = "<div id='bl_limit' class='bl_shortcode_selected'>{$limit}</div>"; } $results = "<div id='shortcode_list{$l_featured_id}'>" . $results . "</div>"; $results .= "{$hidden_limit_text} {$show_bl_type} {$show_paging}"; if ($echo_this) { echo $results; } else { return $results; } }
<?php /** * Map tab * * @author BePro Listings * @package bepro_listings/Templates */ global $post; if ($post->post_content) { $result = process_listings_results(false, 1, false, $post->ID, 1, 1); $result = $result[0][0]; ?> <script type="text/javascript"> function launch_frontend_map() { icon_1 = new google.maps.MarkerImage('<?php echo plugins_url("bepro-listings/images/icons/icon_1.png", "bepro-listings"); ?> '); var mapOptions = { zoom: 6, center: new google.maps.LatLng(<?php echo $result->lat; ?> , <?php echo $result->lon; ?> ) }; var map = new google.maps.Map(document.getElementById('page_details_map'),