示例#1
0
function wptouch_custom_posts_pre_get_posts($query)
{
    // Only modify the custom post type information when a mobile theme is showing
    $settings = foundation_get_settings();
    if (!$settings->enable_custom_post_types) {
        return $query;
    }
    if (is_attachment()) {
        return $query;
    }
    // Right now only support custom post types on the home page and single post pages
    if (is_single() && !is_page() || is_home()) {
        // Only employ this logic for when the mobile theme is showing
        if (wptouch_is_mobile_theme_showing()) {
            $settings = foundation_get_settings();
            $post_types = wptouch_custom_posts_get_list(true);
            if ($post_types && count($post_types)) {
                $post_type_array = array();
                foreach ($post_types as $post_type) {
                    $setting_name = wptouch_custom_posts_get_name_for_post_type($post_type);
                    if (isset($settings->{$setting_name}) && $settings->{$setting_name}) {
                        $post_type_array[] = $post_type;
                    }
                }
            }
            if (count($post_type_array)) {
                // Determine the original post type in the query
                $original_post_type = false;
                if (isset($query->queried_object)) {
                    $original_post_type = $query->queried_object->post_type;
                } else {
                    if (isset($query->query_vars['post_type'])) {
                        $original_post_type = $query->query_vars['post_type'];
                    }
                }
                if ($original_post_type) {
                    $page_for_posts = get_option('page_for_posts');
                    if (isset($query->queried_object_id) && $query->queried_object_id == $page_for_posts) {
                        // we're on the posts page
                        $custom_post_types = apply_filters('wptouch_custom_posts_pre_get', array_merge(array('post'), $post_type_array));
                    } else {
                        if (!is_array($original_post_type)) {
                            $original_post_type = array($original_post_type);
                        }
                        $custom_post_types = apply_filters('wptouch_custom_posts_pre_get', array_merge($original_post_type, $post_type_array));
                    }
                    $query->set('post_type', $custom_post_types);
                } else {
                    // We're on the home page or possibly another page for a normal site
                    $custom_post_types = apply_filters('wptouch_custom_posts_pre_get', array_merge(array('post'), $post_type_array));
                    $query->set('post_type', $custom_post_types);
                }
            }
        }
    }
    return $query;
}
示例#2
0
function foundation_exclude_categories_tags($query)
{
    if (wptouch_is_mobile_theme_showing()) {
        $settings = foundation_get_settings();
        if ($settings->excluded_categories) {
            $new_cats = _foundation_explode_and_trim_taxonomy($settings->excluded_categories, 'category');
            if (!$query->is_single()) {
                $query->set('category__not_in', $new_cats);
            }
        }
        if ($settings->excluded_tags) {
            $new_tags = _foundation_explode_and_trim_taxonomy($settings->excluded_tags, 'post_tag');
            if (!$query->is_single()) {
                $query->set('tag__not_in', $new_tags);
            }
        }
    }
    return $query;
}
function __deactivate_rocket_lazyload_with_wptouch()
{
    if (function_exists('wptouch_is_mobile_theme_showing') && wptouch_is_mobile_theme_showing() || function_exists('bnc_wptouch_is_mobile') && bnc_wptouch_is_mobile()) {
        add_filter('do_rocket_lazyload', '__return_false');
    }
}