| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- /*------------------------------------------------------*/
- /* taskereasy Heading
- /*------------------------------------------------------*/
- vc_map(array(
- "name" => esc_html__("Portfolio Filter", 'taskereasy'),
- "base" => "taskereasy_portfolios",
- 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
- "class" => "",
- "description" => esc_html__("Add taskereasy portfolio grid", 'taskereasy'),
- "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
- "params" => array(
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Type", 'taskereasy'),
- "param_name" => "portfolio_type",
- "value" => array('Two Columns' => 'col-two', 'Three Columns' => 'col-three')
- ),
- array(
- "type" => "checkbox",
- "heading" => esc_html__("Hide Filter", 'taskereasy'),
- "param_name" => "hide_filter",
- ),
- array(
- 'type' => 'css_editor',
- 'heading' => esc_html__( 'CSS', 'taskereasy' ),
- 'param_name' => 'custom_design',
- 'group' => esc_html__( 'Design options', 'taskereasy' ),
- )
- )
- ));
- add_shortcode( 'taskereasy_portfolios', function($atts, $content = null) {
- extract(shortcode_atts(array(
- 'blog_post' => '',
- 'portfolio_type' => 'col-two',
- 'hide_filter' => 'false',
- 'port_style' => 'v1',
- 'custom_design' => '',
- ), $atts));
- $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
- $portfoliotype = html_entity_decode(vc_value_from_safe($portfolio_type, true));
- $poststyle = html_entity_decode(vc_value_from_safe($post_style, true));
- $blogpost = html_entity_decode(vc_value_from_safe($blog_post, true));
- $output = '';
- $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
- $loop = new WP_Query( array(
- 'post_type' => 'portfolios',
- 'orderby' => 'title',
- 'order' => 'ASC',
- 'paged' => $paged,
- ) );
- $output = '';
- $output .= '<section id="portfolio" class="section-padding">';
- if($hide_filter != 'true'){
- $output.=
- '<div class="portfolioFilter">
- <ul>
- <li><a href="#" data-filter="*" class="current">All</a></li>';
- $terms = get_terms( 'portfoliocategories', 'orderby=asc&hide_empty=0' );
- foreach($terms as $term){
- //print_r($term->name);
- $output .= '<li><a href="#" data-filter=".'.$term->name.'">'.$term->name.'</a></li>';
- }
- $output .= '</ul>
- </div>';
- }
- if($portfoliotype == 'col-three') {
- $output .= '</div>'; //container close on col-three
- }
- $output .= '<div class="portfolioContainer '.$portfoliotype.' ">';
- if( ! $loop->have_posts() ) {
- return false;
- }
- while( $loop->have_posts() ) {
- $loop->the_post();
- $termname = array();
- $terms = get_the_terms( '', 'portfoliocategories' );
- if ( !empty( $terms ) ) {
- foreach ($terms as $term) {
- $termname[] = $term->name;
- }
- }
- $output .= '<div class="portfolio-grid '. implode(' ', $termname) .'">
- <a href="'.get_the_permalink().'" class="link">
- <img src="'.get_the_post_thumbnail_url().'">
- <span class="img-mask lt"></span>
- <span class="img-mask rt"></span>
- <span class="img-mask lb"></span>
- <span class="img-mask rb"></span>
- <span class="title">'.get_the_title().'</span>
- <span class="description">'.get_the_excerpt().'</span>
- <span class="more">More <i class="fa fa-angle-right"></i></span>
- </a>
- </div>';
- }
- //$output .= '</div>';
- if($portfoliotype == 'col-three') {
- //$output .= '</div>';
- }
- $output .= '</section>';
- wp_reset_postdata();
- return $output;
- });
|