function enqueue_mapoptions_script() { $defaults = array('latitude' => '37.94199', 'longitude' => '-0.74363', 'zoom' => '12'); $propertyoptions = SPPCommon::get_option('property_location_defaults', array()); $propertyoptions = array_merge($defaults, $propertyoptions); SPPCommon::enqueue_data('staypressmaps', 'latitude', esc_attr($propertyoptions['latitude'])); SPPCommon::enqueue_data('staypressmaps', 'longitude', esc_attr($propertyoptions['longitude'])); SPPCommon::enqueue_data('staypressmaps', 'zoom', esc_attr($propertyoptions['zoom'])); wp_enqueue_script('googlemaps', "http://maps.google.com/maps/api/js?sensor=true", array(), $this->build); wp_enqueue_script('propertymapoptionsjs', SPPCommon::propertyaddons_url('googlemaps_location/js/optionsmap.js'), array('jquery'), $this->build); //add_action( 'admin_head', array( &$this, 'output_admin_header' ) ); add_action('admin_head', array('SPPCommon', 'print_data')); }
function do_propertymap_shortcode($atts, $content = null, $code = "") { $defaults = array("property" => "define", "holder" => '', "holderclass" => '', "item" => 'div', "itemclass" => '', "postfix" => '', "prefix" => '', "itemislink" => 'no', "itemlink" => '', "wrapwith" => '', "wrapwithclass" => '', "width" => '500px', "height" => '250px', "background" => '#99B3CC', "style" => '', "marker" => SPPCommon::property_url('images/mapicons/black%%.png'), "markershadow" => SPPCommon::property_url('images/mapicons/shadow.png'), "markerobfuscate" => '0', "shownear" => 'no', "shownearreadiuskm" => '25', "shownearmarker" => SPPCommon::property_url('images/mapicons/gray%%.png'), "shownearmarkershadow" => SPPCommon::property_url('images/mapicons/shadow.png'), "showneartypes" => STAYPRESS_PROPERTY_POST_TYPE, "shownearnumber" => 25); extract(shortcode_atts($defaults, $atts)); if ($property == 'define' && defined('STAYPRESS_ON_PROPERTY_PAGE')) { $property = (int) STAYPRESS_ON_PROPERTY_PAGE; } elseif ($property == 'define' && $this->inshortcodelist == true && !empty($this->shortcodeproperty)) { $property = (int) $this->shortcodeproperty; } elseif ($property == 'post') { $property = get_the_id(); } $html = ''; if (!empty($holder)) { $html .= "<{$holder} class='{$holderclass}'>"; } if (!empty($item)) { $html .= "<{$item} id='staypress_map_{$property}' class='staypress_map {$itemclass}' style='width: {$width}; height: {$height}; background: {$background}; {$style}'>"; } $html .= $prefix; if (!empty($wrapwith)) { $html .= "<{$wrapwith} class='{$wrapwithclass}'>"; } $html .= $content; if (!empty($wrapwith)) { $html .= "</{$wrapwith}>"; } $html .= $postfix; if (!empty($item)) { $html .= "</{$item}>"; } if (!empty($holder)) { $html .= "</{$holder}>"; } // Enqueue some data $post = get_post($property); if (!empty($post)) { if (!empty($post->latitude)) { $maindata = array("ID" => $property, "post_title" => $post->post_title, "post_excerpt" => $post->post_excerpt, "latitude" => $post->latitude, "longitude" => $post->longitude); switch ($post->post_type) { case STAYPRESS_PROPERTY_POST_TYPE: $maindata['permalink'] = sp_get_permalink('property', $post); break; case STAYPRESS_DESTINATION_POST_TYPE: // Find the location $maindata['permalink'] = get_permalink($post->ID); break; case 'post': // // case 'page': $maindata['permalink'] = get_permalink($post->ID); break; default: } SPPCommon::enqueue_data('staypress_shortcode_data', 'property_' . $property, array("1" => $maindata)); if (strtolower($shownear) == 'yes') { // Need to show the nearby items $nearby = $this->get_posts_near($post->latitude, $post->longitude, $shownearreadiuskm, $shownearnumber); if (!empty($nearby)) { $startat = 2; $nears = array(); foreach ($nearby as $key => $near) { if ($property == $near->ID) { continue; } $nears[$startat] = array("ID" => $near->ID, "post_title" => $near->post_title, "post_excerpt" => $near->post_excerpt, "latitude" => $near->latitude, "longitude" => $near->longitude); switch ($post->post_type) { case STAYPRESS_PROPERTY_POST_TYPE: $nears[$startat]['permalink'] = sp_get_permalink('property', $post); break; case STAYPRESS_DESTINATION_POST_TYPE: // Find the location $nears[$startat]['permalink'] = get_permalink($post->ID); break; case 'post': // // case 'page': $nears[$startat]['permalink'] = get_permalink($post->ID); break; default: } $startat++; } SPPCommon::enqueue_data('staypress_shortcode_data', 'near_' . $property, $nears); } } } } // enqueue the map icon locations if (!empty($marker)) { SPPCommon::enqueue_data('staypress_shortcode_data', 'mapicon_' . $property, $marker); SPPCommon::enqueue_data('staypress_shortcode_data', 'mapshadow_' . $property, $markershadow); } if (!empty($shownearmarker)) { SPPCommon::enqueue_data('staypress_shortcode_data', 'nearicon_' . $property, $shownearmarker); SPPCommon::enqueue_data('staypress_shortcode_data', 'nearshadow_' . $property, $shownearmarkershadow); } return $html; }
function enqueue_propertynear_data($posts) { global $wp_query; //print_r($wp_query); static $alphabet = array("-", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); static $propertydata = array(); static $count = 1; $defaultoptions = array('propertytext' => 'property', 'propertiestext' => 'properties', 'permalinkhasid' => 'yes', 'firstelement' => 'reference', 'propertytitlelayout' => '%title%', 'propertytitlemarker' => 'numeric'); $this->propertyoptions = SPPCommon::get_option('sp_property_options', $defaultoptions); foreach (array_slice((array) $posts, 0, 19) as $postkey => $post) { if (!empty($post->latitude)) { $key = $count++; $propertydata[$key] = array('ID' => $post->ID, 'post_title' => $post->post_title, 'post_excerpt' => $post->post_excerpt, 'latitude' => $post->latitude, 'longitude' => $post->longitude, 'permalink' => sp_get_permalink('property', $post)); if ($this->enhancetitle) { $title = $post->post_title; if (empty($this->propertyoptions['propertytitlelayout'])) { $this->propertyoptions['propertytitlelayout'] = '%title%'; } $posts[$postkey]->post_title = str_replace('%title%', $title, $this->propertyoptions['propertytitlelayout']); $posts[$postkey]->post_title = str_replace('%listmarker%', $key, $posts[$postkey]->post_title); } } } if (!empty($propertydata)) { SPPCommon::enqueue_data('staypress_data', 'propertylist_near', $propertydata); } return $posts; }