/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { if ($this->get_cached_widget($args)) { return; } global $job_manager, $post; extract($args); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $icon = isset($instance['icon']) ? $instance['icon'] : null; $gallery = Listify_WP_Job_Manager_Gallery::get(get_post()->ID); $limit = isset($instance['limit']) ? $instance['limit'] : 8; $has_more = count($gallery) > $limit; if (empty($gallery) && !current_user_can('upload_files')) { return; } if ($icon) { $before_title = sprintf($before_title, 'ion-' . $icon); } ob_start(); if ($has_more) { $before_widget = str_replace('widget-job_listing', 'widget-job_listing has-more', $before_widget); } echo $before_widget; if ($title) { echo $before_title . sprintf('<a href="%s" class="image-gallery-link">%s</a>', Listify_WP_Job_Manager_Gallery::url(), $title) . $after_title; } include locate_template(array('content-single-job_listing-gallery-overview.php')); if ($has_more) { printf('<a href="%s" class="go-to-gallery"><i class="ion-ios7-more"></i></a>', Listify_WP_Job_Manager_Gallery::url()); } echo $after_widget; $content = ob_get_clean(); echo apply_filters($this->widget_id, $content); $this->cache_widget($args, $content); }
</span> <?php _e('Click to upload...', 'listify'); ?> </a> <ul id="listify-new-gallery-additions" class="listify-gallery-images"> </ul> <form action="" method="post" class="listify-add-to-gallery"> <input type="hidden" name="listify_gallery_images" id="listify-new-gallery-images" value="" /> <input type="submit" name="submit" value="<?php esc_attr_e('Add Images to Gallery', 'listify'); ?> " /> <input type="hidden" name="post_id" id="post_id" value="<?php echo get_post()->ID; ?> " /> <input type="hidden" name="redirect" id="gallery-redirect" value="<?php echo esc_url(Listify_WP_Job_Manager_Gallery::url(get_post()->ID)); ?> " /> <?php wp_nonce_field('listify_add_to_gallery'); ?> </form> </div> </div>
/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { if ($this->get_cached_widget($args)) { return; } global $job_manager, $job_preview, $post; extract($args); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $icon = isset($instance['icon']) ? $instance['icon'] : null; $gallery = Listify_WP_Job_Manager_Gallery::get(get_post()->ID); if (empty($gallery)) { return; } $limit = isset($instance['limit']) ? $instance['limit'] : 8; $gallery = array_splice($gallery, 0, $limit); if ($icon) { $before_title = sprintf($before_title, 'ion-' . $icon); } ob_start(); echo $before_widget; if ($title) { echo $before_title . sprintf('<a href="%s" class="image-gallery-link">%s</a>', Listify_WP_Job_Manager_Gallery::url(), $title) . $after_title; } do_action('listify_widget_job_listing_gallery_slider_before'); ?> <div class="listing-gallery"> <?php foreach ($gallery as $item) { ?> <?php $image = wp_get_attachment_image_src($item, 'fullsize'); ?> <?php $link = $job_preview || !listify_theme_mod('gallery-comments') ? $image[0] : get_attachment_link($item); ?> <div class="listing-gallery__item"><a href="<?php echo esc_url($link); ?> " class="listing-gallery__item-trigger"> <?php echo wp_get_attachment_image($item, 'large'); ?> </a></div> <?php } ?> </div> <div class="listing-gallery-nav"> <?php foreach ($gallery as $item) { ?> <div class="listing-gallery-nav__item"> <div class="item__wrapper"><?php echo wp_get_attachment_image($item, 'thumbnail'); ?> </div> </div> <?php } ?> </div> <?php do_action('listify_widget_job_listing_gallery_slider_after'); echo $after_widget; $content = ob_get_clean(); echo apply_filters($this->widget_id, $content); $this->cache_widget($args, $content); }
public static function get($post_id) { self::$post_id = $post_id; $gallery = get_post_meta($post_id, '_gallery', true); if (!$gallery) { return; } if (is_string($gallery)) { $gallery = self::parse_shortcode($gallery); } foreach ($gallery as $key => $item) { if (!is_numeric($item)) { unset($gallery[$key]); } } return $gallery; }
<?php } ?> <p class="back-to-listing"> <a href="<?php the_permalink(); ?> " class="ion-chevron-left"><?php printf(__('Back to %s', 'listify'), get_the_title()); ?> </a> </p> <?php $gallery = Listify_WP_Job_Manager_Gallery::get(get_post()->ID, false); if (empty($gallery)) { $gallery = array(0); } $gallery = new WP_Query(array('post__in' => $gallery, 'post_type' => 'attachment', 'post_status' => 'inherit', 'nopaging' => true)); ?> <?php if ($gallery->have_posts()) { ?> <div class="content-single-job_listing-gallery-wrapper row" data-columns> <?php while ($gallery->have_posts()) { $gallery->the_post();
/** * "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); }
public static function get($post_id) { self::$post_id = $post_id; $gallery = get_post_meta($post_id, '_gallery', true); if (!$gallery) { return; } if (is_string($gallery)) { $gallery = self::parse_shortcode($gallery); } return $gallery; }