/**
  * Enqueue the single view script & add localized data
  */
 private function enqueueScripts()
 {
     wp_enqueue_script('google-maps');
     wp_enqueue_script('simple-locator');
     wp_enqueue_script('simple-locator-all', \SimpleLocator\Helpers::plugin_url() . '/assets/js/simple-locator-all-locations.js', array('jquery'), '1.0');
     wp_localize_script('simple-locator-all', 'wpsl_locator_all', array('locations' => $this->locations));
 }
예제 #2
0
 public function __construct()
 {
     $this->plugin_dir = \SimpleLocator\Helpers::plugin_url();
     $this->styles_repo = new MapStyles();
     $this->settings_repo = new SettingsRepository();
     $this->setPostType();
 }
 /**
  * The View
  */
 public function renderView($options)
 {
     $this->setOptions($options);
     $this->setLocationData();
     $this->enqueueScripts();
     include \SimpleLocator\Helpers::view('singular-post');
     return $out;
 }
 /**
  * Replace post fields from settings
  */
 private function replacePostFields($output)
 {
     if (isset($this->result->distance)) {
         $output = str_replace('[distance]', round($this->result->distance, 2) . ' ' . $this->distance_unit, $output);
     }
     $output = str_replace('[post_title]', $this->result->title, $output);
     if (strpos($output, '[post_permalink]') !== false) {
         $output = str_replace('[post_permalink]', get_permalink($this->result->id), $output);
     }
     if (strpos($output, '[post_excerpt]') !== false) {
         $output = str_replace('[post_excerpt]', Helpers::excerptByID($this->result->id), $output);
     }
     if (strpos($output, '[post_thumbnail_') !== false) {
         $output = $this->addThumbnail($output);
     }
     // Show on Map Link
     $maplink = '<a href="#" class="infowindow-open map-link" onClick="event.preventDefault(); openInfoWindow(' . $this->count . ');">' . __('Show on Map', 'wpsimplelocator') . '</a>';
     $output = str_replace('[show_on_map]', $maplink, $output);
     return $output;
 }
예제 #5
0
 /**
  * Front End of Widget
  */
 public function widget($args, $instance)
 {
     $this->setOptions();
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
     }
     $this->enqueueScripts();
     $widget_instance = true;
     include \SimpleLocator\Helpers::view('simple-locator-form-ajax');
     echo $output;
     echo $args['after_widget'];
 }
예제 #6
0
 /**
  * Meta Boxes for Output
  */
 public function displayMeta($post)
 {
     $this->setData($post);
     include \SimpleLocator\Helpers::view('post-meta/location-meta');
 }
예제 #7
0
 /**
  * The View
  */
 public function renderView($options)
 {
     $this->setOptions($options);
     $this->enqueueScripts();
     $this->localizeOptions();
     if ($this->options['ajax'] !== 'false') {
         include \SimpleLocator\Helpers::view('simple-locator-form-ajax');
         return $output;
     }
     include \SimpleLocator\Helpers::view('simple-locator-form');
     return $output;
 }
예제 #8
0
 /**
  * Enqueue the single view script & add localized data
  */
 private function enqueueScript()
 {
     if (isset($this->location_data['latitude']) && isset($this->location_data['longitude'])) {
         wp_enqueue_script('google-maps');
         wp_enqueue_script('simple-locator');
         wp_enqueue_script('simple-locator-single', \SimpleLocator\Helpers::plugin_url() . '/assets/js/simple-locator-single.js', array('jquery'), '1.0');
         wp_localize_script('simple-locator-single', 'wpsl_locator_single', $this->location_data);
     }
 }
예제 #9
0
 /**
  * The View
  */
 public function renderView($options)
 {
     $this->setOptions($options);
     $this->setTaxonomies();
     $this->enqueueScripts();
     $this->localizeOptions();
     $widget = isset($widget_instance) ? true : false;
     if ($this->options['ajax'] !== 'false') {
         include \SimpleLocator\Helpers::view('simple-locator-form-ajax');
         return apply_filters('simple_locator_form', $output, $this->options['distances'], $this->taxonomies, $widget);
     }
     include \SimpleLocator\Helpers::view('simple-locator-form');
     return apply_filters('simple_locator_form', $output, $this->options['distances'], $this->taxonomies, $widget);
 }
예제 #10
0
 /**
  * Display the Settings Page
  */
 public function settingsPage()
 {
     $tab = isset($_GET['tab']) ? $_GET['tab'] : 'general';
     include \SimpleLocator\Helpers::view('settings/settings');
 }
예제 #11
0
 if (isset($this->location_data['address']) && $this->location_data['address'] !== "") {
     $out .= $this->location_data['address'];
 }
 if (isset($this->location_data['city']) && $this->location_data['city'] !== "") {
     $out .= '<br />' . $this->location_data['city'];
 }
 if (isset($this->location_data['state']) && $this->location_data['state'] !== "") {
     $out .= ', ' . $this->location_data['state'];
 }
 if (isset($this->location_data['zip']) && $this->location_data['zip'] !== "") {
     $out .= ' ' . $this->location_data['zip'];
 }
 $out .= '</p></div>';
 // Website
 if (isset($this->location_data['website']) && $this->location_data['website'] !== "") {
     $url = \SimpleLocator\Helpers::checkURL($this->location_data['website']);
     $out .= '<div class="wpsl-location-website"><p>';
     $out .= __('Website', 'wpsimplelocator') . ':';
     $out .= ' <a href="' . $url . '" target="_blank">' . $this->location_data['website'] . '</a>';
     $out .= '</p></div>';
 }
 // Phone
 if (isset($this->location_data['phone']) && $this->location_data['phone'] !== "") {
     $out .= '<div class="wpsl-location-phone"><p>';
     $out .= __('Phone', 'wpsimplelocator') . ': ' . $this->location_data['phone'];
     $out .= '</p></div>';
 }
 // Additional info
 if (isset($this->location_data['additionalinfo']) && $this->location_data['additionalinfo'] !== "") {
     $out .= '<div class="wpsl-location-additionalinfo"><p>';
     $out .= $this->location_data['additionalinfo'];