/** * Sets up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which runs * before the init hook. The init hook is too late for some features, such as indicating * support post thumbnails. * * To override tfuse_slider_type() in a child theme, add your own tfuse_slider_type to your child theme's * functions.php file. */ function tfuse_get_header_content() { global $TFUSE, $post, $header_image, $is_tf_front_page, $is_tf_blog_page; $posts = $header_element = $header_image = $slider = null; if ($is_tf_blog_page) { $header_element = tfuse_options('header_element_blog'); if ('slider' == $header_element) { $slider = tfuse_options('select_slider_blog'); } elseif ('image' == $header_element) { $header_image = tfuse_options('header_image_blog'); } } elseif ($is_tf_front_page) { if (tfuse_options('use_page_options') && tfuse_options('homepage_category') == 'page') { $page_id = $post->ID; $header_element = tfuse_page_options('header_element', '', $page_id); if ('slider' == $header_element) { $slider = tfuse_page_options('select_slider', '', $page_id); } elseif ('image' == $header_element) { $header_image = tfuse_page_options('header_image', '', $page_id); } } else { $header_element = tfuse_options('header_element'); if ('slider' == $header_element) { $slider = tfuse_options('select_slider'); } elseif ('image' == $header_element) { $header_image = tfuse_options('header_image'); } } } elseif (is_singular()) { $ID = $post->ID; $header_element = tfuse_page_options('header_element'); if ('slider' == $header_element) { $slider = tfuse_page_options('select_slider'); } elseif ('image' == $header_element) { $header_image = tfuse_page_options('header_image'); } } elseif (is_category()) { $ID = get_query_var('cat'); $header_element = tfuse_options('header_element', null, $ID); if ('slider' == $header_element) { $slider = tfuse_options('select_slider', null, $ID); } elseif ('image' == $header_element) { $header_image = tfuse_options('header_image', null, $ID); } } elseif (is_tax()) { $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); $ID = $term->term_id; $header_element = tfuse_options('header_element', null, $ID); if ('slider' == $header_element) { $slider = tfuse_options('select_slider', null, $ID); } elseif ('image' == $header_element) { $header_image = tfuse_options('header_image', null, $ID); } } if ($header_element != 'slider') { get_template_part('header', 'image'); return; } elseif (!$slider) { return; } $slider = $TFUSE->ext->slider->model->get_slider($slider); switch ($slider['type']) { case 'custom': if (is_array($slider['slides'])) { $slider_image_resize = isset($slider['general']['slider_image_resize']) && $slider['general']['slider_image_resize'] == 'true' ? true : false; foreach ($slider['slides'] as $k => $slide) { $image = new TF_GET_IMAGE(); $slider['slides'][$k]['slide_src'] = $image->width(960)->height(444)->src($slide['slide_src'])->resize($slider_image_resize)->get_src(); } } break; case 'posts': $args = array('post__in' => explode(',', $slider['general']['posts_select'])); $slides_posts = array(); $slides_posts = explode(',', $slider['general']['posts_select']); foreach ($slides_posts as $slide_posts) { $posts[] = get_post($slide_posts); } $posts = array_reverse($posts); $args = apply_filters('tfuse_slider_posts_args', $args, $slider); $args = apply_filters('tfuse_slider_posts_args_' . $ID, $args, $slider); break; case 'tags': $args = array('tag__in' => explode(',', $slider['general']['tags_select'])); $args = apply_filters('tfuse_slider_tags_args', $args, $slider); $args = apply_filters('tfuse_slider_tags_args_' . $ID, $args, $slider); $posts = get_posts($args); break; case 'categories': $args = 'cat=' . $slider['general']['categories_select'] . '&posts_per_page=' . $slider['general']['sliders_posts_number']; $args = apply_filters('tfuse_slider_categories_args', $args, $slider); $args = apply_filters('tfuse_slider_categories_args_' . $ID, $args, $slider); $posts = get_posts($args); break; } if (is_array($posts)) { $slider['slides'] = tfuse_get_slides_from_posts($posts, $slider); } if (!is_array($slider['slides'])) { return; } include_once locate_template('/theme_config/extensions/slider/designs/' . $slider['design'] . '/template.php'); }
function tfuse_sliders($atts) { global $TFUSE; extract(shortcode_atts(array('slider_id' => ''), $atts)); $output = ''; if ($slider_id != '-1') { $slider = $TFUSE->ext->slider->model->get_slider($slider_id); $posts = ''; switch ($slider['type']) { case 'custom': if (is_array($slider['slides'])) { $slider_image_resize = isset($slider['general']['slider_image_resize']) && $slider['general']['slider_image_resize'] == 'true' ? true : false; foreach ($slider['slides'] as $k => $slide) { $image = new TF_GET_IMAGE(); if ($slider['design'] == 'carousel_medium') { $slider['slides'][$k]['slide_src'] = $image->width(360)->height(240)->src($slide['slide_src'])->resize($slider_image_resize)->get_src(); } elseif ($slider['design'] == 'content') { $slider['slides'][$k]['slide_src'] = $image->width(430)->height(287)->src($slide['slide_src'])->resize($slider_image_resize)->get_src(); } elseif ($slider['design'] == 'home') { $slider['slides'][$k]['slide_src'] = $image->width(1349)->height(430)->src($slide['slide_src'])->resize($slider_image_resize)->get_src(); } } } break; case 'posts': $slides_posts = array(); if (isset($slider['general']['sliders_posts_from']) && $slider['general']['sliders_posts_from'] == 'game') { $from = $slider['general']['posts_select']; } elseif (isset($slider['general']['sliders_posts_from']) && $slider['general']['sliders_posts_from'] == 'review') { $from = $slider['general']['posts_select_review']; } elseif (isset($slider['general']['sliders_posts_from']) && $slider['general']['sliders_posts_from'] == 'video') { $from = $slider['general']['posts_select_video']; } elseif (isset($slider['general']['sliders_posts_from']) && $slider['general']['sliders_posts_from'] == 'post') { $from = $slider['general']['posts_select_post']; } else { $from = $slider['general']['posts_select_home']; } $args = array('post__in' => explode(',', $from)); $slides_posts = explode(',', $from); foreach ($slides_posts as $slide_posts) { $posts[] = get_post($slide_posts); } $posts = array_reverse($posts); // $args = apply_filters('tfuse_slider_posts_args', $args, $slider); // $args = apply_filters('tfuse_slider_posts_args_'.$ID, $args, $slider); break; case 'categories': // $args = 'cat='.$slider['general']['categories_select']. // '&posts_per_page='.$slider['general']['sliders_posts_number']; // $args = apply_filters('tfuse_slider_categories_args', $args, $slider); // $args = apply_filters('tfuse_slider_categories_args_'.$ID, $args, $slider); if (isset($slider['general']['sliders_posts_from']) && $slider['general']['sliders_posts_from'] == 'game') { $slides_posts = explode(',', $slider['general']['categories_select_game']); $args = array('posts_per_page' => $slider['general']['sliders_posts_number'], 'tax_query' => array(array('taxonomy' => 'games', 'field' => 'id', 'terms' => $slides_posts))); } elseif (isset($slider['general']['sliders_posts_from']) && $slider['general']['sliders_posts_from'] == 'review') { $slides_posts = explode(',', $slider['general']['categories_select_review']); $args = array('posts_per_page' => $slider['general']['sliders_posts_number'], 'tax_query' => array(array('taxonomy' => 'reviews', 'field' => 'id', 'terms' => $slides_posts))); } elseif (isset($slider['general']['sliders_posts_from']) && $slider['general']['sliders_posts_from'] == 'video') { $slides_posts = explode(',', $slider['general']['categories_select_video']); $args = array('posts_per_page' => $slider['general']['sliders_posts_number'], 'tax_query' => array(array('taxonomy' => 'videos', 'field' => 'id', 'terms' => $slides_posts))); } elseif (isset($slider['general']['sliders_posts_from']) && $slider['general']['sliders_posts_from'] == 'post') { $slides_posts = explode(',', $slider['general']['categories_select_category']); $args = array('posts_per_page' => $slider['general']['sliders_posts_number'], 'tax_query' => array(array('taxonomy' => 'category', 'field' => 'id', 'terms' => $slides_posts))); } else { $slides_posts = explode(',', $slider['general']['categories_select_game_home']); $args = array('posts_per_page' => $slider['general']['sliders_posts_number'], 'tax_query' => array(array('taxonomy' => 'games', 'field' => 'id', 'terms' => $slides_posts))); } $query = new WP_Query($args); $posts = $query->get_posts(); break; } if (is_array($posts)) { $slider['slides'] = tfuse_get_slides_from_posts($posts, $slider); } if (!is_array($slider['slides'])) { return; } $output .= tfuse_render_view(locate_template('/theme_config/extensions/slider/designs/' . $slider['design'] . '/template.php'), $slider); } $output .= ''; return $output; }