/**
 * the_job_location function.
 * @param  boolean $map_link whether or not to link to the map on google maps
 * @return [type]
 */
function the_job_location($map_link = true, $post = null)
{
    $location = get_the_job_location($post);
    if ($location) {
        if ($map_link) {
            echo apply_filters('the_job_location_map_link', '<a class="google_map_link" href="http://maps.google.com/maps?q=' . urlencode($location) . '&zoom=14&size=512x512&maptype=roadmap&sensor=false">' . $location . '</a>', $location, $post);
        } else {
            echo $location;
        }
    } else {
        echo apply_filters('the_job_location_anywhere_text', __('Anywhere', 'wp-job-manager'));
    }
}
 public function listing_data($data)
 {
     global $post;
     $data['id'] = $post->ID;
     $data['link'] = get_permalink($post->ID);
     $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'thumbnail');
     if (!is_array($image)) {
         $image = listify_get_cover_from_group(array('size' => 'thumbnail'));
     }
     if (is_array($image) && isset($image[0])) {
         $data['thumb'] = $image[0];
     }
     $data['title'] = the_title_attribute(array('post' => $post, 'echo' => false));
     $data['address'] = get_the_job_location($post->ID);
     /** Longitude */
     $long = esc_attr($post->geolocation_long);
     if ($long) {
         $data['longitude'] = $long;
     }
     /** Latitude */
     $lat = esc_attr($post->geolocation_lat);
     if ($lat) {
         $data['latitude'] = $lat;
     }
     /** Type (default) */
     $terms = get_the_terms(get_the_ID(), listify_get_top_level_taxonomy());
     $term_id = null;
     /** Color (default) */
     $default_color = apply_filters('listify_default_marker_color', listify_theme_mod('color-primary'));
     /** Icon (default) */
     $default_icon = apply_filters('listify_default_marker_icon', 'ion-information-circled');
     if (!is_wp_error($terms) && !empty($terms)) {
         /** Color */
         $color = listify_theme_mod('marker-color-' . current($terms)->term_id);
         $data['color'] = $color ? $color : $default_color;
         /** Icon */
         $icon = listify_theme_mod('marker-icon-' . current($terms)->term_id);
         $data['icon'] = $icon ? $icon : $default_icon;
         /** Term */
         $term_id = current($terms)->term_id;
         $data['term'] = $term_id;
     } else {
         $data['icon'] = $default_icon;
         $data['color'] = $default_color;
         $data['term'] = 0;
     }
     foreach ($data as $key => $value) {
         $data[$key] = esc_attr(strip_tags($value));
     }
     return $data;
 }
 public function get_the_location_formatted()
 {
     global $post;
     if (true == apply_filters('listify_force_skip_formatted_address', false)) {
         return $this->get_the_location(true);
     }
     $location = get_the_job_location();
     $address = apply_filters('listify_formatted_address', array('first_name' => '', 'last_name' => '', 'company' => '', 'address_1' => $post->geolocation_street, 'address_2' => '', 'street_number' => $post->geolocation_street_number, 'city' => $post->geolocation_city, 'state' => $post->geolocation_state_short, 'full_state' => $post->geolocation_state_long, 'postcode' => $post->geolocation_postcode, 'country' => $post->geolocation_country_short, 'full_country' => $post->geolocation_country_long), $location, $post);
     $email_id = get_post_meta(get_the_ID(), 'company_email', true);
     $phone = get_post_meta(get_the_ID(), '_phone', true);
     $output['start'] = '<div class="job_listing-location job_listing-location-formatted">';
     $output['map-link-start'] = sprintf('<a class="google_map_link" href="%s" target="_blank">', $this->google_maps_url());
     if (!empty($post->geolocation_street)) {
         $address_string = '<span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">' . WC()->countries->get_formatted_address($address) . '</span>';
     }
     if (!empty($phone)) {
         $phone_string = '<div class="job_listing-phone"><span itemprop="telephone">' . $phone . '</span></div>';
     }
     if (!empty($email_id)) {
         $email_string = '<div><a href="#job_listing-author-apply" data-mfp-src=".job_application" class="popup-trigger"><span class="ion-email">&nbsp;&nbsp;' . $email_id . '</span></a></div>';
     }
     $output['address'] = $address_string . $phone_string . $email_string;
     //	$output[ 'address' ] = '<span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">' . WC()->countries->get_formatted_address( $address ) . '</span>';
     $output['address'] = html_entity_decode($output['address']);
     $output['map-link-end'] = '</a>';
     $output['end'] = '</div>';
     $output = apply_filters('listify_the_location_formatted_parts', $output, $location, $post);
     $output = apply_filters('listify_the_location_formatted', implode('', $output));
     return $output;
 }
 public function get_the_location_formatted()
 {
     global $post;
     if (true == apply_filters('listify_force_skip_formatted_address', false) || !listify_has_integration('woocommerce')) {
         return $this->get_the_location(true);
     }
     $location = get_the_job_location();
     $address = apply_filters('listify_formatted_address', array('first_name' => '', 'last_name' => '', 'company' => '', 'address_1' => $post->geolocation_street, 'address_2' => '', 'street_number' => $post->geolocation_street_number, 'city' => $post->geolocation_city, 'state' => $post->geolocation_state_short, 'full_state' => $post->geolocation_state_long, 'postcode' => $post->geolocation_postcode, 'country' => $post->geolocation_country_short, 'full_country' => $post->geolocation_country_long), $location, $post);
     $output['start'] = '<div class="job_listing-location job_listing-location-formatted">';
     $output['map-link-start'] = sprintf('<a class="google_map_link" href="%s" target="_blank">', $this->google_maps_url());
     $output['address'] = '<span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">' . WC()->countries->get_formatted_address($address) . '</span>';
     $output['address'] = html_entity_decode($output['address']);
     $output['map-link-end'] = '</a>';
     $output['end'] = '</div>';
     $output = apply_filters('listify_the_location_formatted_parts', $output, $location, $post);
     $output = apply_filters('listify_the_location_formatted', implode('', $output));
     return $output;
 }
 /**
  * Add custom data to the job feed
  */
 public function job_feed_item()
 {
     $post_id = get_the_ID();
     $location = get_the_job_location($post_id);
     $job_type = get_the_job_type($post_id);
     $company = get_the_company_name($post_id);
     if ($location) {
         echo "<job_listing:location><![CDATA[" . esc_html($location) . "]]></job_listing:location>\n";
     }
     if ($job_type) {
         echo "<job_listing:job_type><![CDATA[" . esc_html($job_type->name) . "]]></job_listing:job_type>\n";
     }
     if ($company) {
         echo "<job_listing:company><![CDATA[" . esc_html($company) . "]]></job_listing:company>\n";
     }
 }
/**
 * the_job_location function.
 * @param  boolean $map_link whether or not to link to google maps
 * @return [type]
 */
function the_job_location($map_link = true, $post = null)
{
    $location = get_the_job_location($post);
    if ($location) {
        if ($map_link) {
            // If linking to google maps, we don't want anything but text here
            echo apply_filters('the_job_location_map_link', '<a class="google_map_link" href="' . esc_url('http://maps.google.com/maps?q=' . urlencode(strip_tags($location)) . '&zoom=14&size=512x512&maptype=roadmap&sensor=false') . '" target="_blank">' . esc_html(strip_tags($location)) . '</a>', $location, $post);
        } else {
            echo wp_kses_post($location);
        }
    } else {
        echo wp_kses_post(apply_filters('the_job_location_anywhere_text', __('Anywhere', 'wp-job-manager')));
    }
}
 /**
  * Listing Location (formatted)
  *
  * @since Listify 1.0.0
  *
  * @return void
  */
 public static function the_location_formatted()
 {
     global $post;
     $location = get_the_job_location($post);
     $output = '<div class="job_listing-location-formatted" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';
     $output .= '<a class="google_map_link" href="http://maps.google.com/maps?q=' . urlencode($location) . '&zoom=14&size=512x512&maptype=roadmap&sensor=false" target="_blank">';
     do_action('listify_the_location_formatted_start', $post);
     if ($post->geolocation_street) {
         $output .= '<span class="location-street" itemprop="streetAddress">' . $post->geolocation_street . '</span><br />';
     }
     if ($post->geolocation_city) {
         $output .= '<span class="location-locality" itemprop="addressLocality">' . $post->geolocation_city . '</span>';
     }
     if ($post->geolocation_state_long) {
         $output .= ', <span class="location-region" itemprop="addressRegion">' . $post->geolocation_state_long . '</span>';
     }
     do_action('listify_the_location_formatted_end', $post);
     $output .= '</a>';
     $output .= '</div>';
     echo $output;
 }
 /**
  * Single listing alert link
  */
 public function single_alert_link()
 {
     global $post, $job_preview;
     if (!empty($job_preview)) {
         return;
     }
     if (is_user_logged_in() && get_option('job_manager_alerts_page_id')) {
         $job_type = get_the_job_type($post);
         $link = add_query_arg(array('action' => 'add_alert', 'alert_name' => urlencode($post->post_title), 'alert_job_type' => array($job_type->slug), 'alert_location' => urlencode(strip_tags(get_the_job_location($post))), 'alert_cats' => taxonomy_exists('job_listing_category') ? wp_get_post_terms($post->ID, 'job_listing_category', array('fields' => 'ids')) : '', 'alert_keyword' => urlencode($post->post_title), 'alert_region' => taxonomy_exists('job_listing_region') ? current(wp_get_post_terms($post->ID, 'job_listing_region', array('fields' => 'ids'))) : ''), get_permalink(get_option('job_manager_alerts_page_id')));
         echo '<p class="job-manager-single-alert-link"><a href="' . esc_url($link) . '">' . __('Alert me to jobs like this', 'wp-job-manager-alerts') . '</a></p>';
     }
 }
Example #9
0
    public function widget($args, $instance)
    {
        global $post;
        if (true == apply_filters('listable_skip_geolocation_formatted_address', false)) {
            //we will use the address inputed by the user
            $address = get_the_job_location();
        } else {
            $address = get_post_meta(get_the_ID(), 'geolocation_formatted_address', true);
        }
        if (empty($address)) {
            return;
        }
        $geolocation_lat = get_post_meta(get_the_ID(), 'geolocation_lat', true);
        $geolocation_long = get_post_meta(get_the_ID(), 'geolocation_long', true);
        $get_directions_link = '';
        if (!empty($geolocation_lat) && !empty($geolocation_long) && is_numeric($geolocation_lat) && is_numeric($geolocation_long)) {
            $get_directions_link = '//maps.google.com/maps?daddr=' . $geolocation_lat . ',' . $geolocation_long;
        }
        echo $args['before_widget'];
        ?>

		<div itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">
			<div id="map" class="listing-map"></div>

			<?php 
        if (!empty($geolocation_lat) && !empty($geolocation_long) && is_numeric($geolocation_lat) && is_numeric($geolocation_long)) {
            ?>

				<meta itemprop="latitude" content="<?php 
            echo $geolocation_lat;
            ?>
"/>
				<meta itemprop="longitude" content="<?php 
            echo $geolocation_long;
            ?>
"/>

			<?php 
        }
        ?>

		</div>
		<div class="listing-map-content">
			<address class="listing-address" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
				<?php 
        echo $address;
        ?>
				<meta itemprop="streetAddress" content="<?php 
        echo trim(get_post_meta($post->ID, 'geolocation_street_number', true), '');
        ?>
 <?php 
        echo trim(get_post_meta($post->ID, 'geolocation_street', true), '');
        ?>
">
				<meta itemprop="addressLocality" content="<?php 
        echo trim(get_post_meta($post->ID, 'geolocation_city', true), '');
        ?>
">
				<meta itemprop="postalCode" content="<?php 
        echo trim(get_post_meta($post->ID, 'geolocation_postcode', true), '');
        ?>
">
				<meta itemprop="addressRegion" content="<?php 
        echo trim(get_post_meta($post->ID, 'geolocation_state', true), '');
        ?>
">
				<meta itemprop="addressCountry" content="<?php 
        echo trim(get_post_meta($post->ID, 'geolocation_country_short', true), '');
        ?>
">
			</address>
			<?php 
        if (!empty($get_directions_link)) {
            ?>
				<a href="<?php 
            echo $get_directions_link;
            ?>
" class="listing-address-directions" target="_blank"><?php 
            esc_html_e('Get directions', 'listable');
            ?>
</a>
			<?php 
        }
        ?>
		</div><!-- .listing-map-content -->

		<?php 
        echo $args['after_widget'];
    }