/** * Get the slides for the "slides" slideshow type. * @since 1.0.0 * @param array $args Array of arguments to determine which slides to return. * @return array An array of slides to render for the slideshow. */ private function slideshow_type_slides($args = array()) { global $post; $slides = array(); $defaults = array('limit' => '5', 'slide_page' => '', 'thumbnails' => ''); $args = wp_parse_args($args, $defaults); $query_args = array('post_type' => 'slide', 'numberposts' => intval($args['limit'])); if ($args['slide_page'] != '') { $cats_split = explode(',', $args['slide_page']); $query_args['tax_query'] = array(); foreach ($cats_split as $k => $v) { $query_args['tax_query'][] = array('taxonomy' => 'slide-page', 'field' => 'slug', 'terms' => esc_attr(trim(rtrim($v)))); } } $posts = get_posts($query_args); if (!is_wp_error($posts) && count($posts) > 0) { foreach ($posts as $k => $post) { setup_postdata($post); $content = get_the_content(); $data = array('content' => '<div class="slide-content">' . "\n" . apply_filters('wooslider_slide_content_slides', $content, $args) . "\n" . '</div>' . "\n"); if ('true' == $args['thumbnails'] || 1 == $args['thumbnails']) { $thumb_url = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'medium'); if (!is_bool($thumb_url) && isset($thumb_url[0])) { $data['attributes'] = array('data-thumb' => esc_url($thumb_url[0])); } else { $data['attributes'] = array('data-thumb' => esc_url(WooSlider_Utils::get_placeholder_image())); } } $slides[] = $data; } wp_reset_postdata(); } return $slides; }
/** * Add data for our newly-added custom columns. * @access public * @since 1.0.0 * @param string $column_name * @param int $id * @return void */ public function add_column_data($column_name, $id) { global $wpdb, $post; switch ($column_name) { case 'id': echo $id; break; case 'slide-page': $value = __('No Slide Groups Specified', 'wooslider'); $terms = get_the_terms($id, 'slide-page'); if ($terms && !is_wp_error($terms)) { $term_links = array(); foreach ($terms as $term) { $term_links[] = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('post_type' => 'slide', 'tag_ID' => $term->term_id, 'taxonomy' => 'slide-page', 'action' => 'edit'), 'edit-tags.php')), esc_html(sanitize_term_field('name', $term->name, $term->term_id, 'slide-page', 'display'))); } $value = join(', ', $term_links); } echo $value; break; case 'slide-thumbnail': echo '<a href="' . esc_url(admin_url(add_query_arg(array('post' => intval($id), 'action' => 'edit'), 'post.php'))) . '">' . "\n"; if (has_post_thumbnail($id)) { the_post_thumbnail(array(75, 75)); } else { echo '<img src="' . esc_url(WooSlider_Utils::get_placeholder_image()) . '" width="75" />' . "\n"; } echo '</a>' . "\n"; break; default: break; } }
/** * Get the slides for the "slides" slideshow type. * @since 1.0.0 * @param array $args Array of arguments to determine which slides to return. * @return array An array of slides to render for the slideshow. */ private function slideshow_type_slides($args = array(), $settings = array()) { global $post; $slides = array(); $has_video = array('youtube' => false, 'vimeo' => false, 'wistia' => false); $defaults = array('limit' => '5', 'slide_page' => '', 'carousel' => '', 'thumbnails' => '', 'layout' => 'text-left', 'imageslide' => 'false', 'size' => 'large', 'display_title' => '', 'overlay' => 'none', 'display_content' => 'true', 'order' => 'DESC', 'order_by' => 'date', 'link_slide' => 'false'); $args = wp_parse_args($args, $defaults); $query_args = array('post_type' => 'slide', 'numberposts' => intval($args['limit']), 'orderby' => $args['order_by'], 'order' => $args['order']); if (true == $settings['randomize']) { $query_args['orderby'] = 'rand'; } if ('' != $args['slide_page']) { $cats_split = explode(',', $args['slide_page']); $query_args['tax_query'] = array(array('taxonomy' => 'slide-page', 'field' => 'slug', 'terms' => $cats_split)); } $posts = get_posts($query_args); if (!is_wp_error($posts) && count($posts) > 0) { foreach ($posts as $k => $post) { setup_postdata($post); $class = ''; if (isset($args['carousel']) && 'true' == $args['carousel']) { $image = get_the_post_thumbnail(get_the_ID()); $wooslider_url = get_post_meta(get_the_ID(), '_wooslider_url', true); if (('true' == $args['link_slide'] || 1 == $args['link_slide']) && '' != $wooslider_url) { $image = '<a href="' . esc_url($wooslider_url) . '">' . $image . '</a>'; } $data = array('content' => '<div class="slide-content">' . "\n" . apply_filters('wooslider_slide_carousel_slides', $image, $args) . "\n" . '</div>' . "\n"); } else { if ((isset($args['imageslide']) && 'true' == $args['imageslide'] || 1 == $args['imageslide']) && '' != get_the_post_thumbnail(get_the_ID())) { // Determine and validate the layout type. $supported_layouts = WooSlider_Utils::get_posts_layout_types(); if (!in_array($args['layout'], array_keys($supported_layouts))) { $args['layout'] = $defaults['layout']; } // Determine and validate the overlay setting. if (!in_array($args['overlay'], array('none', 'full', 'natural'))) { $args['overlay'] = $defaults['overlay']; } if ($args['display_content'] == 'true' || $args['display_content'] == 1 || ($args['display_title'] == 'true' || $args['display_title'] == 1)) { $class = 'layout-' . esc_attr($args['layout']) . ' overlay-' . esc_attr($args['overlay']); } $image = get_the_post_thumbnail(get_the_ID(), $args['size']); $wooslider_url = get_post_meta(get_the_ID(), '_wooslider_url', true); if (('true' == $args['link_slide'] || 1 == $args['link_slide']) && '' != $wooslider_url) { $image = '<a href="' . esc_url($wooslider_url) . '">' . $image . '</a>'; } $title = ''; if ('true' == $args['display_title'] || 1 == $args['display_title']) { $title = get_the_title(get_the_ID()); if (('true' == $args['link_slide'] || 1 == $args['link_slide']) && '' != $wooslider_url) { $title = '<a href="' . esc_url($wooslider_url) . '">' . $title . '</a>'; } $title = '<h2 class="slide-title">' . $title . '</h2>'; } $content = ''; if ('true' == $args['display_content'] || 1 == $args['display_content']) { $content = wpautop(apply_filters('wooslider_slides_excerpt', get_the_content())); } if ('true' == $args['display_content'] || 1 == $args['display_content'] || ('true' == $args['display_title'] || 1 == $args['display_title'])) { $content = '<div class="slide-excerpt">' . $title . $content . '</div>'; if ($args['layout'] == 'text-top') { $content = $content . $image; } else { $content = $image . $content; } } else { $content = $image; } $layed_out_content = apply_filters('wooslider_slides_layout_html', $content, $args, $post); // If there is an image, add "has-featured-image" class if ('' != $image) { $class .= ' has-featured-image'; } $content = '<div class="slide-content ' . esc_attr($class) . '">' . $layed_out_content . '</div>'; $data = array('content' => $content); } else { $content = apply_filters('wooslider_slides_content', get_the_content()); $data = array('content' => '<div class="slide-content">' . "\n" . apply_filters('wooslider_slide_content_slides', $content, $args) . "\n" . '</div>' . "\n"); } } if ('true' == $args['thumbnails'] || 1 == $args['thumbnails'] || 2 == $args['thumbnails'] || 'carousel' == $args['thumbnails'] || 'thumbnails' == $args['thumbnails']) { $thumb_url = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'medium'); if (!is_bool($thumb_url) && isset($thumb_url[0])) { $data['attributes'] = array('data-thumb' => esc_url($thumb_url[0])); } else { $data['attributes'] = array('data-thumb' => esc_url(WooSlider_Utils::get_placeholder_image())); } } $post_meta = get_post_custom(get_the_ID()); foreach ($post_meta as $meta => $value) { if ('_oembed' == substr(trim($meta), 0, 7)) { if (preg_match('%(?:youtube(?:-nocookie)?\\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\\.be/)([^"&?/ ]{11})%i', $value[0], $match)) { $has_video['youtube'] = true; add_filter('wooslider_callback_start_' . $settings['id'], array('WooSlider_Frontend', 'wooslider_youtube_start')); add_filter('wooslider_callback_before_' . $settings['id'], array('WooSlider_Frontend', 'wooslider_youtube_before')); } if (preg_match('#(?:https?:\\/\\/(?:[\\w]+\\.)*vimeo\\.com(?:[\\/\\w]*\\/videos?)?\\/([0-9]+)[^\\s]*)#i', $value[0], $match)) { $has_video['vimeo'] = true; add_filter('wooslider_callback_start_' . $settings['id'], array('WooSlider_Frontend', 'wooslider_vimeo_start')); add_filter('wooslider_callback_before_' . $settings['id'], array('WooSlider_Frontend', 'wooslider_vimeo_before')); } if (preg_match('%(?:https?:\\/\\/(?:.+)?(?:wistia.com|wi.st|wistia.net)\\/(?:medias|embed)?\\/)(.*)%i', $value[0], $match)) { $has_video['wistia'] = true; add_filter('wooslider_callback_before_' . $settings['id'], array('WooSlider_Frontend', 'wooslider_wistia_before')); } } } $data['video'] = $has_video; // add the post id to the list the slide $data['ID'] = $post->ID; $slides[] = $data; } wp_reset_postdata(); } return $slides; }