vc-portfolios.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /*------------------------------------------------------*/
  3. /* taskereasy Heading
  4. /*------------------------------------------------------*/
  5. vc_map(array(
  6. "name" => esc_html__("Portfolio Filter", 'taskereasy'),
  7. "base" => "taskereasy_portfolios",
  8. 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
  9. "class" => "",
  10. "description" => esc_html__("Add taskereasy portfolio grid", 'taskereasy'),
  11. "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
  12. "params" => array(
  13. array(
  14. "type" => "dropdown",
  15. "heading" => esc_html__("Type", 'taskereasy'),
  16. "param_name" => "portfolio_type",
  17. "value" => array('Two Columns' => 'col-two', 'Three Columns' => 'col-three')
  18. ),
  19. array(
  20. "type" => "checkbox",
  21. "heading" => esc_html__("Hide Filter", 'taskereasy'),
  22. "param_name" => "hide_filter",
  23. ),
  24. array(
  25. 'type' => 'css_editor',
  26. 'heading' => esc_html__( 'CSS', 'taskereasy' ),
  27. 'param_name' => 'custom_design',
  28. 'group' => esc_html__( 'Design options', 'taskereasy' ),
  29. )
  30. )
  31. ));
  32. add_shortcode( 'taskereasy_portfolios', function($atts, $content = null) {
  33. extract(shortcode_atts(array(
  34. 'blog_post' => '',
  35. 'portfolio_type' => 'col-two',
  36. 'hide_filter' => 'false',
  37. 'port_style' => 'v1',
  38. 'custom_design' => '',
  39. ), $atts));
  40. $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
  41. $portfoliotype = html_entity_decode(vc_value_from_safe($portfolio_type, true));
  42. $poststyle = html_entity_decode(vc_value_from_safe($post_style, true));
  43. $blogpost = html_entity_decode(vc_value_from_safe($blog_post, true));
  44. $output = '';
  45. $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
  46. $loop = new WP_Query( array(
  47. 'post_type' => 'portfolios',
  48. 'orderby' => 'title',
  49. 'order' => 'ASC',
  50. 'paged' => $paged,
  51. ) );
  52. $output = '';
  53. $output .= '<section id="portfolio" class="section-padding">';
  54. if($hide_filter != 'true'){
  55. $output.=
  56. '<div class="portfolioFilter">
  57. <ul>
  58. <li><a href="#" data-filter="*" class="current">All</a></li>';
  59. $terms = get_terms( 'portfoliocategories', 'orderby=asc&hide_empty=0' );
  60. foreach($terms as $term){
  61. //print_r($term->name);
  62. $output .= '<li><a href="#" data-filter=".'.$term->name.'">'.$term->name.'</a></li>';
  63. }
  64. $output .= '</ul>
  65. </div>';
  66. }
  67. if($portfoliotype == 'col-three') {
  68. $output .= '</div>'; //container close on col-three
  69. }
  70. $output .= '<div class="portfolioContainer '.$portfoliotype.' ">';
  71. if( ! $loop->have_posts() ) {
  72. return false;
  73. }
  74. while( $loop->have_posts() ) {
  75. $loop->the_post();
  76. $termname = array();
  77. $terms = get_the_terms( '', 'portfoliocategories' );
  78. if ( !empty( $terms ) ) {
  79. foreach ($terms as $term) {
  80. $termname[] = $term->name;
  81. }
  82. }
  83. $output .= '<div class="portfolio-grid '. implode(' ', $termname) .'">
  84. <a href="'.get_the_permalink().'" class="link">
  85. <img src="'.get_the_post_thumbnail_url().'">
  86. <span class="img-mask lt"></span>
  87. <span class="img-mask rt"></span>
  88. <span class="img-mask lb"></span>
  89. <span class="img-mask rb"></span>
  90. <span class="title">'.get_the_title().'</span>
  91. <span class="description">'.get_the_excerpt().'</span>
  92. <span class="more">More <i class="fa fa-angle-right"></i></span>
  93. </a>
  94. </div>';
  95. }
  96. //$output .= '</div>';
  97. if($portfoliotype == 'col-three') {
  98. //$output .= '</div>';
  99. }
  100. $output .= '</section>';
  101. wp_reset_postdata();
  102. return $output;
  103. });