function blox_blog_row_parse_hook($atts) { extract(shortcode_atts(array('categories' => '', 'column' => '4', 'count' => '8', 'bgcolor' => '#34495e', 'ratio' => '4x3', 'filter' => '1', 'order' => '', 'exclude' => '', 'extra_class' => '', 'visibility' => ''), $atts)); $visibility = str_replace(',', ' ', $visibility); global $query, $post, $paged; $temp_qry = $query; $temp_post = $post; wp_reset_query(); wp_reset_postdata(); /* Build queries ================================================*/ $args = array('post__not_in' => explode(',', $exclude), 'posts_per_page' => (int) $count); if ($categories != '') { $args['cat'] = explode(',', $categories); } if ($order == 'dateasc') { $args['orderby'] = 'date'; $args['order'] = 'ASC'; } elseif ($order == 'titleasc') { $args['orderby'] = 'title'; $args['order'] = 'ASC'; } elseif ($order == 'titledes') { $args['orderby'] = 'title'; $args['order'] = 'DESC'; } elseif ($order == 'comment') { $args['orderby'] = 'comment_count'; } elseif ($order == 'postid') { $args['orderby'] = 'ID'; } elseif ($order == 'random') { $args['orderby'] = 'rand'; add_action('posts_orderby', 'edit_posts_orderby'); } $result = ''; $query = new WP_Query($args); if ($query->have_posts()) { $cats_filter = array(); $item_number = 0; while ($query->have_posts()) { $query->the_post(); $item_number++; $image_width = 539; $current_filter_classes = ''; $terms = wp_get_post_categories(get_the_ID()); foreach ($terms as $term) { $term = get_category($term); $current_filter_classes .= 'filter-' . $term->slug . ' '; $temp_cat = array('id' => $term->term_id, 'title' => $term->name, 'slug' => $term->slug); if (!in_array($temp_cat, $cats_filter)) { $cats_filter[] = $temp_cat; } } $thumb = ''; if (has_post_thumbnail(get_the_ID())) { $fimage = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full'); $thumb = $fimage[0]; } else { $gallery_field = tt_getmeta('blog_gallery'); $gimages = explode(',', $gallery_field); if (isset($gimages[0]) && $gimages[0] != '') { $thumb = wp_get_attachment_url($gimages[0]); $thumb = $thumb !== false ? $thumb : THEME_NOIMAGE; } } $iwidth = 600; $iheight = 450; if ($ratio == '1x1') { $iwidth = 600; $iheight = 600; } else { if ($ratio == '16x9') { $iwidth = 600; $iheight = 337; } } $thumb = $thumb != '' ? blox_aq_resize($thumb, $iwidth, $iheight, true) : ''; $folio_arg = array('item_style' => 'alternative', 'thumb' => $thumb, 'class' => ' ' . $current_filter_classes); $result .= blox_loop_portfolio($folio_arg); } $filter_html = ''; if ($filter == '1') { $cat_filter_html = ''; foreach ($cats_filter as $cat) { $cat_filter_html .= '<li><a href="javascript:;" title="' . $cat['title'] . '" data-filter="filter-' . $cat['slug'] . '">' . $cat['title'] . '</a></li>'; } if ($cat_filter_html != '') { $filter_html = '<div class="row"> <div class="col-md-12"> <div class="portfolio-filter"> <div class="pull-left"> <h3>' . __('All', 'themeton') . '</h3> </div> <div class="pull-right"> <ul class="nav nav-pills"> <li class="dropdown active"> <a class="dropdown-toggle navInst" data-toggle="dropdown" href="#"> ' . __('Sort Blog', 'themeton') . ' <span class="caret"></span> </a> <ul class="dropdown-menu" role="menu"> <li><a href="javascript:;" title="All" data-filter="all" class="active">' . __('All', 'themeton') . '</a></li> <li class="divider"></li> ' . $cat_filter_html . ' </ul> </li> </ul> </div> <div class="clearfix"></div> </div> </div> </div>'; } } // Grid container $masonry_class = ''; $result = '<div class="blox-element grid-loop blog fullwidth-portfolio ' . $extra_class . ' ' . $visibility . '" style="opacity:0;" data-column="' . $column . '"> ' . $filter_html . ' <div class="row masonry-container" style="background-color:' . $bgcolor . ';">' . $result . '</div> <div class="clearfix"></div> </div>'; } wp_reset_query(); wp_reset_postdata(); $query = $temp_qry; $post = $temp_post; return $result; }
function blox_parse_carouselrow_hook($atts, $content = null) { extract(shortcode_atts(array('post_type' => 'post', 'category' => '0', 'count' => '6', 'slideseconds' => 5, 'ratio' => '1x1', 'extra_class' => '', 'visibility' => ''), $atts)); $visibility = str_replace(',', ' ', $visibility); $extra_class = $extra_class . ' ' . $visibility; global $post, $product, $woocommerce, $woocommerce_loop; global $the_query; $temp_post = $post; $temp_query = $the_query; $args = array('post_type' => $post_type, 'posts_per_page' => (int) $count, 'ignore_sticky_posts' => 1); if ($category != '' && $category != '0') { $taxonomies = get_object_taxonomies($post_type); $args['tax_query'] = array(array('taxonomy' => $taxonomies[0], 'terms' => $category)); } $i = 0; $html = ''; $the_query = new WP_Query($args); while ($the_query->have_posts()) { $the_query->the_post(); $thumb = wp_get_attachment_url(get_post_thumbnail_id($post->ID)); //$image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); //$thumb = $image[0]; $iwidth = 600; $iheight = 450; if ($ratio == '1x1') { $iwidth = 600; $iheight = 600; } else { if ($ratio == '16x9') { $iwidth = 600; $iheight = 337; } } $thumb = $thumb != '' ? blox_aq_resize($thumb, $iwidth, $iheight, true) : ''; $folio_arg = array('item_style' => 'alternative', 'overlay' => '', 'thumb' => $thumb, 'class' => 'swiper-slide'); $html .= blox_loop_portfolio($folio_arg); } $the_query = $temp_query; $post = $temp_post; $autoplay = 'data-duration="' . (int) $slideseconds * 1000 . '"'; return "<div class='fullwidth-carousel swiper-container {$extra_class}' style='opacity:0;' {$autoplay}>\n <div class='blox-element grid-loop portfolio swiper-wrapper'>\n " . $html . "\n </div>\n </div>"; }
function blox_parse_carousel_hook($atts, $content = null) { extract(shortcode_atts(array('title' => '', 'post_type' => 'post', 'category' => '0', 'count' => '6', 'item_style' => 'default', 'overlay' => 'none', 'slideseconds' => 0, 'animation' => '', 'extra_class' => '', 'skin' => '', 'visibility' => ''), $atts)); $visibility = str_replace(',', ' ', $visibility); $extra_class = $extra_class . ' ' . $visibility; global $post, $product, $woocommerce, $woocommerce_loop; global $the_query; $temp_post = $post; $temp_query = $the_query; $args = array('post_type' => $post_type, 'posts_per_page' => (int) $count, 'ignore_sticky_posts' => 1); if ($category != '' && $category != '0') { $taxonomies = get_object_taxonomies($post_type); $args['tax_query'] = array(array('taxonomy' => $taxonomies[0], 'terms' => $category)); } $i = 0; $html = ''; $title = $title != '' ? '<h3 class="element-title">' . $title . '</h3>' : ''; $the_query = new WP_Query($args); while ($the_query->have_posts()) { $the_query->the_post(); if ($post_type == 'product') { $product = get_product(get_the_Id()); ob_start(); woocommerce_get_template_part('content', 'product'); $html .= ob_get_clean(); } else { $thumb = wp_get_attachment_url(get_post_thumbnail_id($post->ID)); $image = $thumb != '' ? blox_aq_resize($thumb, 400, 300, true) : ''; $i++; $folio_arg = array('item_style' => $item_style, 'overlay' => $overlay, 'thumb' => $image, 'class' => 'col-md-3 col-sm-6 col-xs-12 swiper-slide', 'width' => '400', 'height' => '300'); $html .= blox_loop_portfolio($folio_arg); } } $the_query = $temp_query; $post = $temp_post; $autoplay = 'data-duration="' . (int) $slideseconds * 1000 . '"'; if ($post_type == 'product') { return "<div class='blox-element blox-carousel woocommerce swiper-container' {$autoplay}>\n {$title}\n <ul class='blox-element products swiper-wrapper'>\n " . $html . "\n </ul>\n <div class='carousel-control-prev'><i class='fa-angle-left'></i></div>\n <div class='carousel-control-next'><i class='fa-angle-right'></i></div>\n </div>"; } $skin = $item_style != 'alternative' ? $skin : ''; return "<div class='blox-element blox-carousel swiper-container {$extra_class}' {$autoplay}>\n {$title}\n <div class='blox-element grid-loop portfolio swiper-wrapper {$skin}'>\n " . $html . "\n </div>\n <div class='carousel-control-prev'><i class='fa-angle-left'></i></div>\n <div class='carousel-control-next'><i class='fa-angle-right'></i></div>\n </div>"; }
function blox_portfolio_parse_hook($atts) { extract(shortcode_atts(array('title' => '', 'style' => 'default', 'categories' => '', 'count' => '5', 'pager' => '0', 'height' => '', 'readmore' => __('Read more', 'themeton'), 'ignoresticky' => 'yes', 'filter' => '1', 'content_type' => 'default', 'overlay' => 'none', 'exclude' => '', 'order' => '', 'extra_class' => '', 'element_style' => 'default', 'skin' => '', 'visibility' => ''), $atts)); $visibility = str_replace(',', ' ', $visibility); global $query, $post, $paged; $temp_qry = $query; $temp_post = $post; wp_reset_query(); wp_reset_postdata(); if (is_front_page()) { $paged = get_query_var('page') ? get_query_var('page') : 1; } /* Build queries ================================================*/ $args = array('post_type' => 'portfolio', 'post__not_in' => explode(',', $exclude), 'posts_per_page' => (int) $count, 'paged' => $paged, 'ignore_sticky_posts' => $ignoresticky == 'yes' ? 1 : 0); $cats_filter = array(); if ($categories != '') { $format_array = explode(',', $categories); $args['tax_query'] = array(array('taxonomy' => 'portfolio_entries', 'field' => 'id', 'terms' => $format_array)); foreach ($format_array as $term) { $the_term = get_term($term, 'portfolio_entries'); $temp_cat = array('id' => $the_term->term_id, 'title' => $the_term->name, 'slug' => $the_term->slug); if (!in_array($temp_cat, $cats_filter)) { $cats_filter[] = $temp_cat; } } } if ($order == 'dateasc') { $args['orderby'] = 'date'; $args['order'] = 'ASC'; } elseif ($order == 'titleasc') { $args['orderby'] = 'title'; $args['order'] = 'ASC'; } elseif ($order == 'titledes') { $args['orderby'] = 'title'; $args['order'] = 'DESC'; } elseif ($order == 'comment') { $args['orderby'] = 'comment_count'; } elseif ($order == 'postid') { $args['orderby'] = 'ID'; } elseif ($order == 'random') { $args['orderby'] = 'rand'; add_action('posts_orderby', 'edit_posts_orderby'); } $result = ''; $title = $title != '' ? '<h3 class="element-title">' . $title . '</h3>' : ''; $query = new WP_Query($args); if ($query->have_posts()) { $item_number = 0; while ($query->have_posts()) { $query->the_post(); // If it is grid style, there don't need image scaled cropping $image_height = 0; if (strpos($style, 'grid') !== false) { $image_height = $height != '' ? (int) $height : 0; } $item_number++; $class = 'col-md-3 col-sm-6 col-xs-12'; $image_width = 539; if ($style == 'masonry3' || $style == 'grid3') { $class = 'col-md-4 col-sm-6 col-xs-12'; $image_width = 344; } else { if ($style == 'masonry4' || $style == 'grid4') { $class = 'col-md-3 col-sm-6 col-xs-12'; $image_width = 247; } else { if ($style == 'masonry2' || $style == 'grid2') { $class = 'col-md-6 col-sm-6 col-xs-12'; $image_width = 0; } } } // If it is centered style, there don't need image overlay if ($style == 'centered') { $overlay = 'nothing'; } $current_filter_classes = ''; $terms = wp_get_post_terms(get_the_ID(), 'portfolio_entries'); foreach ($terms as $term) { $current_filter_classes .= 'filter-' . $term->slug . ' '; if (empty($format_array)) { $temp_cat = array('id' => $term->term_id, 'title' => $term->name, 'slug' => $term->slug); if (!in_array($temp_cat, $cats_filter)) { $cats_filter[] = $temp_cat; } } } $thumb = ''; if (has_post_thumbnail(get_the_ID())) { $fimage = wp_get_attachment_url(get_post_thumbnail_id(get_the_ID())); $thumb = $fimage !== false ? $fimage : THEME_NOIMAGE; } else { $gallery_field = tt_getmeta('portfolio_gallery'); $gimages = explode(',', $gallery_field); if (isset($gimages[0]) && $gimages[0] != '') { $thumb = wp_get_attachment_url($gimages[0]); $thumb = $thumb !== false ? $thumb : THEME_NOIMAGE; } } $cols = (int) str_replace('grid', '', str_replace('masonry', '', $style)); $img_w = 520; $img_w = $cols == 3 ? 337 : $img_w; $img_w = $cols == 4 ? 245 : $img_w; $height = $height != '' ? $height : '0'; $thumb = $thumb != '' ? blox_aq_resize($thumb, $img_w, $height, true) : ''; $folio_arg = array('item_style' => $content_type, 'overlay' => $overlay, 'thumb' => $thumb, 'class' => $class . ' ' . $current_filter_classes, 'width' => $img_w, 'height' => $height); $result .= blox_loop_portfolio($folio_arg); } $pager_html = ''; if ($pager == '1') { ob_start(); themeton_pager($query); $pager_html .= ob_get_contents(); ob_end_clean(); } $filter_html = ''; if ($filter == '1') { $cat_filter_html = ''; foreach ($cats_filter as $cat) { $cat_filter_html .= '<li><a href="javascript:;" title="' . $cat['title'] . '" data-filter="filter-' . $cat['slug'] . '">' . $cat['title'] . '</a></li>'; } if ($cat_filter_html != '') { $filter_html = '<div class="row"> <div class="col-md-12"> <div class="portfolio-filter"> <div class="pull-left"> <h3>' . __('All', 'themeton') . '</h3> </div> <div class="pull-right"> <ul class="nav nav-pills"> <li class="dropdown active"> <a class="dropdown-toggle navInst" data-toggle="dropdown" href="#"> ' . __('Sort Portfolio', 'themeton') . ' <span class="caret"></span> </a> <ul class="dropdown-menu" role="menu"> <li><a href="javascript:;" title="All" data-filter="all" class="active">' . __('All', 'themeton') . '</a></li> <li class="divider"></li> ' . $cat_filter_html . ' </ul> </li> </ul> </div> <div class="clearfix"></div> </div> </div> </div>'; } } // Grid container $masonry_class = ''; if (strpos($style, 'masonry') !== false) { $masonry_class = 'portfolio-masonry'; } $result = '<div class="blox-element grid-loop portfolio ' . $element_style . ' ' . $masonry_class . ' ' . $extra_class . ' ' . $visibility . '"> ' . $filter_html . ' <div class="row masonry-container">' . $result . '</div> ' . $pager_html . ' </div>'; } wp_reset_query(); wp_reset_postdata(); $query = $temp_qry; $post = $temp_post; return $result; }