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; } /** Featured */ $data['featured'] = $post->_featured ? 'featured' : ''; foreach ($data as $key => $value) { $data[$key] = esc_attr(strip_tags($value)); } return $data; }
/** * "Cover" images for pages and other content. * * If on an archive the current query will be used. Otherwise it will * look for a single item's featured image or an image from its gallery. * * @since Listify 1.0.0 * * @param string $class * @return string $atts */ function listify_cover($class, $args = array()) { $defaults = apply_filters('listify_cover_defaults', array('images' => false, 'object_ids' => false, 'size' => 'large')); $args = wp_parse_args($args, $defaults); $image = false; $atts = array(); global $post, $wp_query; // special for WooCommerce if (function_exists('is_shop') && is_shop() || is_singular('product')) { $image = wp_get_attachment_image_src(get_post_thumbnail_id(wc_get_page_id('shop')), $args['size']); } else { if (is_home() && !in_the_loop()) { $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_option('page_for_posts')), $args['size']); } else { if (!did_action('loop_start') && is_archive() || ($args['images'] || $args['object_ids'])) { $image = listify_get_cover_from_group($args); } else { if (is_a($post, 'WP_Post')) { if (!listify_has_integration('wp-job-manager') || has_post_thumbnail($post->ID)) { $image = wp_get_attachment_image_src(get_post_thumbnail_id(), $args['size']); } else { $gallery = Listify_WP_Job_Manager_Gallery::get($post->ID); $args['images'] = $gallery; unset($args['object_ids']); if ($gallery) { $image = listify_get_cover_from_group($args); } } } } } } $image = apply_filters('listify_cover_image', $image, $args); if (!$image) { $class .= ' no-image'; return sprintf('class="%s"', $class); } $class .= ' has-image'; $atts[] = sprintf('style="background-image: url(%s);"', $image[0]); $atts[] = sprintf('class="%s"', $class); return implode(' ', $atts); }