function foundation_featured_get_slides()
{
    global $post;
    $settings = foundation_get_settings();
    $foundation_featured_posts = array();
    $foundation_featured_data = array();
    $args = foundation_featured_get_args();
    $new_posts = false;
    switch ($settings->featured_type) {
        case 'tag':
            $new_posts = new WP_Query('tag=' . $settings->featured_tag . '&posts_per_page=' . $args['max_search']);
            break;
        case 'category':
            $new_posts = new WP_Query('category_name=' . $settings->featured_category . '&posts_per_page=' . $args['max_search']);
            break;
        case 'posts':
            if (function_exists('wptouch_custom_posts_add_to_search')) {
                $post_types = wptouch_custom_posts_add_to_search(array('post', 'page'));
            } else {
                $post_types = array('post', 'page');
            }
            $post_ids = explode(',', str_replace(' ', '', $settings->featured_post_ids));
            if (is_array($post_ids) && count($post_ids)) {
                $new_posts = new WP_Query(array('post__in' => $post_ids, 'posts_per_page' => $args['max_search'], 'post_type' => $post_types, 'orderby' => 'post__in'));
            }
            break;
        case 'post_type':
            $new_posts = new WP_Query('post_type=' . $settings->featured_post_type . '&posts_per_page=' . $args['max_search']);
            break;
        case 'latest':
        default:
            break;
    }
    if (!$new_posts) {
        $new_posts = new WP_Query('posts_per_page=' . $args['max_search']);
    }
    return $new_posts;
    add_filter('parse_query', 'foundation_featured_modify_query');
}
function foundation_featured_slider()
{
    global $foundation_featured_posts;
    $settings = foundation_get_settings();
    $args = foundation_featured_get_args();
    if (featured_should_show_slider()) {
        if (function_exists('wptouch_custom_posts_add_to_search')) {
            $post_types = wptouch_custom_posts_add_to_search(array('post', 'page'));
        } else {
            $post_types = array('post', 'page');
        }
        $slides = new WP_Query(array('ignore_sticky_posts' => 1, 'post__in' => $foundation_featured_posts, 'post_type' => $post_types, 'posts_per_page' => $settings->featured_max_number_of_posts));
        if ($slides->post_count > 0) {
            foundation_featured_prefix($args);
            while ($slides->have_posts()) {
                $slides->the_post();
                $image = foundation_featured_has_image();
                if (apply_filters('wptouch_has_post_thumbnail', $image)) {
                    get_template_part('featured-slider');
                }
            }
            foundation_featured_postfix($args);
        }
    }
}
Example #3
0
function foundation_featured_slider($manual = false, $manual_html = false)
{
    global $foundation_featured_posts;
    $args = foundation_featured_get_args();
    if (featured_should_show_slider()) {
        if ($manual == false) {
            if (function_exists('wptouch_custom_posts_add_to_search')) {
                $post_types = wptouch_custom_posts_add_to_search(array('post', 'page'));
            } else {
                $post_types = array('post', 'page');
            }
            $slides = new WP_Query(array('ignore_sticky_posts' => 1, 'post__in' => $foundation_featured_posts, 'post_type' => $post_types));
            if ($slides->post_count > 0) {
                echo $args['before'];
                echo "<div id='slider' class='" . implode(' ', foundation_featured_get_slider_classes()) . "'>\n";
                echo "<div class='swipe-wrap'>\n";
                while ($slides->have_posts()) {
                    $slides->the_post();
                    $image = foundation_featured_has_image();
                    if (apply_filters('wptouch_has_post_thumbnail', $image)) {
                        get_template_part('featured-slider');
                    }
                }
                echo "</div>\n";
                echo "</div>\n";
                echo $args['after'];
            }
        } else {
            // Private for now, we'll improve manual mode for customer use in 3.2
            echo $args['before'];
            echo "<div id='slider' class='" . implode(' ', foundation_featured_get_slider_classes()) . "'>\n";
            echo "<div class='swipe-wrap'>\n";
            echo $manual_html;
            echo "</div>\n";
            echo "</div>\n";
            echo $args['after'];
        }
        wp_reset_query();
    }
}
Example #4
0
function foundation_determine_images()
{
    global $foundation_featured_posts;
    global $foundation_featured_data;
    global $post;
    $settings = foundation_get_settings();
    $foundation_featured_posts = array();
    $foundation_featured_data = array();
    $args = foundation_featured_get_args();
    $new_posts = false;
    switch ($settings->featured_type) {
        case 'tag':
            $new_posts = new WP_Query('tag=' . $settings->featured_tag . '&posts_per_page=' . $args['max_search']);
            break;
        case 'category':
            $new_posts = new WP_Query('category_name=' . $settings->featured_category . '&posts_per_page=' . $args['max_search']);
            break;
        case 'posts':
            if (function_exists('wptouch_custom_posts_add_to_search')) {
                $post_types = wptouch_custom_posts_add_to_search(array('post', 'page'));
            } else {
                $post_types = array('post', 'page');
            }
            $post_ids = explode(',', str_replace(' ', '', $settings->featured_post_ids));
            if (is_array($post_ids) && count($post_ids)) {
                $new_posts = new WP_Query(array('post__in' => $post_ids, 'posts_per_page' => $args['max_search'], 'post_type' => $post_types, 'orderby' => 'post__in'));
            }
            break;
        case 'post_type':
            $new_posts = new WP_Query('post_type=' . $settings->featured_post_type . '&posts_per_page=' . $args['max_search']);
            break;
        case 'latest':
        default:
            break;
    }
    if (!$new_posts) {
        $new_posts = new WP_Query('posts_per_page=' . $args['max_search']);
    }
    while ($new_posts->have_posts()) {
        $new_posts->the_post();
        $image = get_the_post_thumbnail($post->ID, 'foundation-featured-image');
        if (preg_match('#src=\\"(.*)\\"#iU', $image, $matches)) {
            $image = $matches[1];
            $our_size = sprintf("%d", WPTOUCH_FEATURED_SIZE);
            if (strpos($image, $our_size) === false) {
                // It's not our image, so just use the WP medium size
                $image = get_the_post_thumbnail($post->ID, 'large');
                if (preg_match('#src=\\"(.*)\\"#iU', $image, $matches)) {
                    $image = $matches[1];
                }
            }
        }
        if ($image) {
            $results = new stdClass();
            $results->image = $matches[1];
            $results->date = get_the_date();
            $results->title = get_the_title();
            $results->link = get_permalink();
            $results->comments_number = wptouch_get_comment_count();
            $foundation_featured_data[] = $results;
            $foundation_featured_posts[] = $post->ID;
        }
        // Break out if we have enough images
        if (count($foundation_featured_data) == $args['num']) {
            break;
        }
    }
    add_filter('parse_query', 'foundation_featured_modify_query');
}