Пример #1
0
?>
"
	         data-permalink="<?php 
the_job_permalink();
?>
"
	         data-categories="<?php 
echo $termString;
?>
"
		<?php 
echo $data_output;
?>
 >
		<aside class="card__image" style="background-image: url(<?php 
echo listable_get_post_image_src($post->ID, 'listable-card-image');
?>
);">
			<?php 
global $job_manager_bookmarks;
if ($job_manager_bookmarks !== null && method_exists($job_manager_bookmarks, 'is_bookmarked')) {
    $bookmark_state = '';
    if ($job_manager_bookmarks->is_bookmarked($post->ID)) {
        $bookmark_state = 'is--bookmarked';
    }
    ?>
				<div class="heart <?php 
    echo $bookmark_state;
    ?>
">
					<?php 
Пример #2
0
    public function widget($args, $instance)
    {
        global $post;
        $placeholders = $this->get_placeholder_strings();
        //only put in the default title if the user hasn't saved anything in the database e.g. $instance is empty (as a whole)
        $title = apply_filters('widget_title', empty($instance) ? $placeholders['title'] : $instance['title'], $instance, $this->id_base);
        $subtitle = empty($instance) ? $placeholders['subtitle'] : $instance['subtitle'];
        $number_of_items = empty($instance['number_of_items']) ? $this->defaults['number_of_items'] : $instance['number_of_items'];
        $show = empty($instance['show']) ? $this->defaults['show'] : $instance['show'];
        $orderby = empty($instance['orderby']) ? $this->defaults['orderby'] : $instance['orderby'];
        $items_ids = empty($instance['items_ids']) ? $this->defaults['items_ids'] : $instance['items_ids'];
        $categories_slug = empty($instance['categories_slug']) ? $this->defaults['categories_slug'] : $instance['categories_slug'];
        echo $args['before_widget'];
        ?>

		<div class="widget_front_page_listing_cards" itemscope itemtype="http://schema.org/LocalBusiness">
			<h3 class="widget_title  widget_title--frontpage">
				<?php 
        echo $title;
        if (!empty($subtitle)) {
            ?>
					<span class="widget_subtitle--frontpage">
						<?php 
            echo $subtitle;
            ?>
					</span>
				<?php 
        }
        ?>
			</h3>
			<?php 
        // lets query some
        $query_args = array('post_type' => 'job_listing', 'post_status' => 'publish');
        if (!empty($number_of_items) && is_numeric($number_of_items)) {
            $query_args['posts_per_page'] = $number_of_items;
        }
        if (!empty($orderby) && is_string($orderby)) {
            $query_args['orderby'] = $orderby;
        }
        if (!empty($show) && $show === 'featured') {
            $query_args['meta_key'] = '_featured';
            $query_args['meta_value'] = '1';
        }
        if (!empty($items_ids) && is_string($items_ids)) {
            $query_args['post__in'] = explode(',', $items_ids);
        }
        if (!empty($categories_slug) && is_string($categories_slug)) {
            $categories_slug = explode(',', $categories_slug);
            foreach ($categories_slug as $key => $cat) {
                $categories_slug[$key] = sanitize_title($cat);
            }
            $query_args['tax_query'] = array('relation' => 'AND', array('taxonomy' => 'job_listing_category', 'field' => 'slug', 'terms' => $categories_slug));
        }
        $listings = new WP_Query($query_args);
        if ($listings->have_posts()) {
            ?>
				<div class="grid  grid--widget  list">
					<?php 
            while ($listings->have_posts()) {
                $listings->the_post();
                $terms = get_the_terms(get_the_ID(), 'job_listing_category');
                $listing_classes = 'card  card--listing  card--widget  ';
                $listing_is_claimed = false;
                if (class_exists('WP_Job_Manager_Claim_Listing')) {
                    $classes = WP_Job_Manager_Claim_Listing()->listing->add_post_class(array());
                    if (isset($classes[0]) && !empty($classes[0])) {
                        $listing_classes .= $classes[0];
                        if ($classes[0] == 'claimed') {
                            $listing_is_claimed = true;
                        }
                    }
                }
                ?>

						<a href="<?php 
                the_job_permalink();
                ?>
" class="grid__item  grid__item--widget">
							<article class="<?php 
                echo $listing_classes;
                ?>
" data-latitude="<?php 
                echo get_post_meta($post->ID, 'geolocation_lat', true);
                ?>
"
							         data-longitude="<?php 
                echo get_post_meta($post->ID, 'geolocation_long', true);
                ?>
"
							         data-img="<?php 
                echo listable_get_post_image_src($post->ID, 'full');
                ?>
"
							         data-permalink="<?php 
                the_job_permalink();
                ?>
">

								<aside class="card__image" style="background-image: url(<?php 
                echo listable_get_post_image_src($post->ID, 'listable-card-image');
                ?>
);">
									<?php 
                global $job_manager_bookmarks;
                if ($job_manager_bookmarks !== null && method_exists($job_manager_bookmarks, 'is_bookmarked')) {
                    $bookmark_state = '';
                    if ($job_manager_bookmarks->is_bookmarked($post->ID)) {
                        $bookmark_state = 'is--bookmarked';
                    }
                    ?>
										<div class="heart <?php 
                    echo $bookmark_state;
                    ?>
">
											<?php 
                    get_template_part('assets/svg/heart-svg');
                    ?>
										</div>
									<?php 
                }
                ?>

								</aside>

								<div class="card__content">
									<h2 class="card__title" itemprop="name"><?php 
                echo get_the_title();
                if ($listing_is_claimed) {
                    echo '<span class="listing-claimed-icon">';
                    get_template_part('assets/svg/checked-icon-small');
                    echo '<span>';
                }
                ?>
</h2>
									<div class="card__tagline"><?php 
                the_company_tagline();
                ?>
</div>
									<footer class="card__footer">
										<?php 
                $rating = get_average_listing_rating($post->ID, 1);
                if (!empty($rating)) {
                    ?>
											<div class="rating  card__rating">
												<span class="js-average-rating"><?php 
                    echo get_average_listing_rating($post->ID, 1);
                    ?>
</span>
											</div>
										<?php 
                } else {
                    if (get_post_meta($post->ID, 'geolocation_street', true)) {
                        ?>
												<div class="card__rating  card__pin">
													<?php 
                        get_template_part('assets/svg/pin-simple-svg');
                        ?>
												</div>
											<?php 
                    }
                }
                ?>

										<?php 
                if (is_array($terms) || is_object($terms)) {
                    ?>

											<ul class="card__tags">
												<?php 
                    foreach ($terms as $term) {
                        $icon_url = listable_get_term_icon_url($term->term_id);
                        $attachment_id = listable_get_term_icon_id($term->term_id);
                        if (empty($icon_url)) {
                            continue;
                        }
                        ?>
													<li>
														<div class="card__tag">
															<div class="pin__icon">
																<?php 
                        listable_display_image($icon_url, '', true, $attachment_id);
                        ?>
															</div>
														</div>
													</li>
												<?php 
                    }
                    ?>
											</ul>

										<?php 
                }
                ?>

										<div class="address  card__address">
											<span class="address__street"><?php 
                echo trim(get_post_meta($post->ID, 'geolocation_street', true), '');
                ?>
</span>
											<span class="address__street-no"><?php 
                echo trim(get_post_meta($post->ID, 'geolocation_street_number', true), '');
                ?>
</span>
											<span class="address__city"><?php 
                echo trim(get_post_meta($post->ID, 'geolocation_city', true), '');
                ?>
</span>
											<span class="address__postcode"><?php 
                echo trim(get_post_meta($post->ID, 'geolocation_postcode', true), '');
                ?>
</span>
											<span class="address__country"><?php 
                echo trim(get_post_meta($post->ID, 'geolocation_country_short', true), '');
                ?>
</span>
											<span class="address__country-short"><?php 
                echo trim(get_post_meta($post->ID, 'geolocation_country_long', true), '');
                ?>
</span>
										</div>
									</footer>
								</div><!-- .card__content -->
							</article><!-- .card.card--listing -->
						</a><!-- .grid_item -->

					<?php 
            }
            wp_reset_postdata();
            ?>

				</div>

			<?php 
        }
        ?>

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