Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.42 KB | None | 0 0
  1. <?php
  2.  
  3. class ET_Builder_Module_Filterable_Portfolio extends ET_Builder_Module_Type_PostBased {
  4.     function init() {
  5.         $this->name       = esc_html__( 'Filterable Portfolio', 'et_builder' );
  6.         $this->slug       = 'et_pb_filterable_portfolio';
  7.         $this->vb_support = 'on';
  8.  
  9.         $this->main_css_element = '%%order_class%%.et_pb_filterable_portfolio';
  10.  
  11.         $this->settings_modal_toggles = array(
  12.             'general'  => array(
  13.                 'toggles' => array(
  14.                     'main_content' => esc_html__( 'Content', 'et_builder' ),
  15.                     'elements'     => esc_html__( 'Elements', 'et_builder' ),
  16.                 ),
  17.             ),
  18.             'advanced' => array(
  19.                 'toggles' => array(
  20.                     'layout'  => esc_html__( 'Layout', 'et_builder' ),
  21.                     'overlay' => esc_html__( 'Overlay', 'et_builder' ),
  22.                     'text'    => array(
  23.                         'title'    => esc_html__( 'Text', 'et_builder' ),
  24.                         'priority' => 49,
  25.                     ),
  26.                     'image' => esc_html__( 'Image', 'et_builder' ),
  27.                 ),
  28.             ),
  29.         );
  30.  
  31.         $this->advanced_fields = array(
  32.             'fonts'                 => array(
  33.                 'title'   => array(
  34.                     'label'    => esc_html__( 'Title', 'et_builder' ),
  35.                     'css'      => array(
  36.                         'main' => "{$this->main_css_element} h2, {$this->main_css_element} .et_pb_module_header",
  37.                         'plugin_main' => "{$this->main_css_element} h2, {$this->main_css_element} h2 a, {$this->main_css_element} h1.et_pb_module_header, {$this->main_css_element} h1.et_pb_module_header a, {$this->main_css_element} h3.et_pb_module_header, {$this->main_css_element} h3.et_pb_module_header a, {$this->main_css_element} h4.et_pb_module_header, {$this->main_css_element} h4.et_pb_module_header a, {$this->main_css_element} h5.et_pb_module_header, {$this->main_css_element} h5.et_pb_module_header a, {$this->main_css_element} h6.et_pb_module_header, {$this->main_css_element} h6.et_pb_module_header a",
  38.                         'important' => 'all',
  39.                     ),
  40.                     'header_level' => array(
  41.                         'default' => 'h2',
  42.                     ),
  43.                 ),
  44.                 'filter' => array(
  45.                     'label'    => esc_html__( 'Filter Criteria', 'et_builder' ),
  46.                     'hide_text_align' => true,
  47.                     'css'      => array(
  48.                         'main' => "{$this->main_css_element} .et_pb_portfolio_filter",
  49.                         'plugin_main' => "{$this->main_css_element} .et_pb_portfolio_filter, {$this->main_css_element} .et_pb_portfolio_filter a",
  50.                         'color' => "{$this->main_css_element} .et_pb_portfolio_filter a",
  51.                     ),
  52.                 ),
  53.                 'caption' => array(
  54.                     'label'    => esc_html__( 'Meta', 'et_builder' ),
  55.                     'css'      => array(
  56.                         'main' => "{$this->main_css_element} .post-meta, {$this->main_css_element} .post-meta a",
  57.                     ),
  58.                 ),
  59.                 'pagination' => array(
  60.                     'label'    => esc_html__( 'Pagination', 'et_builder' ),
  61.                     'css'      => array(
  62.                         'main' => "{$this->main_css_element} .et_pb_portofolio_pagination a",
  63.                         'text_align' => "{$this->main_css_element} .et_pb_portofolio_pagination ul",
  64.                     ),
  65.                     'text_align' => array(
  66.                         'options' => et_builder_get_text_orientation_options( array( 'justified' ), array() ),
  67.                     ),
  68.                 ),
  69.             ),
  70.             'background'            => array(
  71.                 'settings' => array(
  72.                     'color' => 'alpha',
  73.                 ),
  74.             ),
  75.             'borders'               => array(
  76.                 'default' => array(
  77.                     'css' => array(
  78.                         'main' => array(
  79.                             'border_radii' => "{$this->main_css_element} .et_pb_portfolio_item",
  80.                             'border_styles' => "{$this->main_css_element} .et_pb_portfolio_item",
  81.                         ),
  82.                     ),
  83.                 ),
  84.                 'image' => array(
  85.                     'css'          => array(
  86.                         'main' => array(
  87.                             'border_radii'  => "{$this->main_css_element} .et_portfolio_image",
  88.                             'border_styles' => "{$this->main_css_element} .et_portfolio_image",
  89.                         ),
  90.                     ),
  91.                     'label_prefix' => esc_html__( 'Image', 'et_builder' ),
  92.                     'tab_slug'      => 'advanced',
  93.                     'toggle_slug'   => 'image',
  94.                 ),
  95.             ),
  96.             'box_shadow'            => array(
  97.                 'default' => array(),
  98.                 'image'   => array(
  99.                     'label'           => esc_html__( 'Image Box Shadow', 'et_builder' ),
  100.                     'option_category' => 'layout',
  101.                     'tab_slug'        => 'advanced',
  102.                     'toggle_slug'     => 'image',
  103.                     'css'             => array(
  104.                         'main'         => '%%order_class%% .project .et_portfolio_image',
  105.                         'custom_style' => true,
  106.                     ),
  107.                     'default_on_fronts'  => array(
  108.                         'color'    => '',
  109.                         'position' => '',
  110.                     ),
  111.                 ),
  112.             ),
  113.             'margin_padding' => array(
  114.                 'css' => array(
  115.                     'important' => array( 'custom_margin' ), // needed to overwrite last module margin-bottom styling
  116.                 ),
  117.             ),
  118.             'max_width'             => array(
  119.                 'css' => array(
  120.                     'module_alignment' => '%%order_class%%.et_pb_filterable_portfolio.et_pb_module',
  121.                 ),
  122.             ),
  123.             'text'                  => array(
  124.                 'use_background_layout' => true,
  125.                 'options' => array(
  126.                     'background_layout' => array(
  127.                         'default' => 'light',
  128.                     ),
  129.                 ),
  130.             ),
  131.             'filters'               => array(
  132.                 'css' => array(
  133.                     'main' => '%%order_class%%',
  134.                 ),
  135.                 'child_filters_target' => array(
  136.                     'tab_slug' => 'advanced',
  137.                     'toggle_slug' => 'image',
  138.                 ),
  139.             ),
  140.             'image'                 => array(
  141.                 'css' => array(
  142.                     'main' => '%%order_class%% .et_portfolio_image',
  143.                 ),
  144.             ),
  145.             'button'                => false,
  146.         );
  147.  
  148.         $this->custom_css_fields = array(
  149.             'portfolio_filters' => array(
  150.                 'label'    => esc_html__( 'Portfolio Filters', 'et_builder' ),
  151.                 'selector' => '.et_pb_filterable_portfolio .et_pb_portfolio_filters',
  152.                 'no_space_before_selector' => true,
  153.             ),
  154.             'active_portfolio_filter' => array(
  155.                 'label'    => esc_html__( 'Active Portfolio Filter', 'et_builder' ),
  156.                 'selector' => '.et_pb_filterable_portfolio .et_pb_portfolio_filters li a.active',
  157.                 'no_space_before_selector' => true,
  158.             ),
  159.             'portfolio_image' => array(
  160.                 'label'    => esc_html__( 'Portfolio Image', 'et_builder' ),
  161.                 'selector' => '.et_portfolio_image',
  162.             ),
  163.             'overlay' => array(
  164.                 'label'    => esc_html__( 'Overlay', 'et_builder' ),
  165.                 'selector' => '.et_overlay',
  166.             ),
  167.             'overlay_icon' => array(
  168.                 'label'    => esc_html__( 'Overlay Icon', 'et_builder' ),
  169.                 'selector' => '.et_overlay:before',
  170.             ),
  171.             'portfolio_title' => array(
  172.                 'label'    => esc_html__( 'Portfolio Title', 'et_builder' ),
  173.                 'selector' => '.et_pb_portfolio_item h2',
  174.             ),
  175.             'portfolio_post_meta' => array(
  176.                 'label'    => esc_html__( 'Portfolio Post Meta', 'et_builder' ),
  177.                 'selector' => '.et_pb_portfolio_item .post-meta',
  178.             ),
  179.             'portfolio_pagination' => array(
  180.                 'label'    => esc_html__( 'Portfolio Pagination', 'et_builder' ),
  181.                 'selector' => '.et_pb_portofolio_pagination',
  182.             ),
  183.             'portfolio_pagination_active' => array(
  184.                 'label'    => esc_html__( 'Pagination Active Page', 'et_builder' ),
  185.                 'selector' => '.et_pb_portofolio_pagination a.active',
  186.             ),
  187.         );
  188.  
  189.         $this->help_videos = array(
  190.             array(
  191.                 'id'   => esc_html( 'AZheY1hVcJc' ),
  192.                 'name' => esc_html__( 'An introduction to the Filterable Portfolio module', 'et_builder' ),
  193.             ),
  194.         );
  195.     }
  196.  
  197.     function get_fields() {
  198.         $fields = array(
  199.             'fullwidth' => array(
  200.                 'label'           => esc_html__( 'Layout', 'et_builder' ),
  201.                 'type'            => 'select',
  202.                 'option_category' => 'layout',
  203.                 'options'         => array(
  204.                     'on'  => esc_html__( 'Fullwidth', 'et_builder' ),
  205.                     'off' => esc_html__( 'Grid', 'et_builder' ),
  206.                 ),
  207.                 'affects' => array(
  208.                     'hover_icon',
  209.                     'zoom_icon_color',
  210.                     'hover_overlay_color',
  211.                 ),
  212.                 'description'      => esc_html__( 'Choose your desired portfolio layout style.', 'et_builder' ),
  213.                 'computed_affects' => array(
  214.                     '__projects',
  215.                 ),
  216.                 'tab_slug'         => 'advanced',
  217.                 'toggle_slug'      => 'layout',
  218.                 'default_on_front' => 'on',
  219.             ),
  220.             'posts_number' => array(
  221.                 'default'          => 10,
  222.                 'label'            => esc_html__( 'Posts Number', 'et_builder' ),
  223.                 'type'             => 'text',
  224.                 'option_category'  => 'configuration',
  225.                 'description'      => esc_html__( 'Define the number of projects that should be displayed per page.', 'et_builder' ),
  226.                 'computed_affects' => array(
  227.                     '__projects',
  228.                 ),
  229.                 'toggle_slug'      => 'main_content',
  230.             ),
  231.             'include_categories' => array(
  232.                 'label'            => esc_html__( 'Include Categories', 'et_builder' ),
  233.                 'type'             => 'categories',
  234.                 'option_category'  => 'basic_option',
  235.                 'description'      => esc_html__( 'Select the categories that you would like to include in the feed.', 'et_builder' ),
  236.                 'computed_affects' => array(
  237.                     '__project_terms',
  238.                     '__projects',
  239.                 ),
  240.                 'taxonomy_name'    => 'project_category',
  241.                 'toggle_slug'      => 'main_content',
  242.             ),
  243.             'show_title' => array(
  244.                 'label'             => esc_html__( 'Show Title', 'et_builder' ),
  245.                 'type'              => 'yes_no_button',
  246.                 'option_category'   => 'configuration',
  247.                 'options'           => array(
  248.                     'on'  => esc_html__( 'Yes', 'et_builder' ),
  249.                     'off' => esc_html__( 'No', 'et_builder' ),
  250.                 ),
  251.                 'toggle_slug'       => 'elements',
  252.                 'description'       => esc_html__( 'Turn project titles on or off.', 'et_builder' ),
  253.                 'default_on_front'  => 'on',
  254.             ),
  255.             'show_categories' => array(
  256.                 'label'             => esc_html__( 'Show Categories', 'et_builder' ),
  257.                 'type'              => 'yes_no_button',
  258.                 'option_category'   => 'configuration',
  259.                 'options'           => array(
  260.                     'on'  => esc_html__( 'Yes', 'et_builder' ),
  261.                     'off' => esc_html__( 'No', 'et_builder' ),
  262.                 ),
  263.                 'toggle_slug'       => 'elements',
  264.                 'description'       => esc_html__( 'Turn the category links on or off.', 'et_builder' ),
  265.                 'default_on_front'  => 'on',
  266.             ),
  267.             'show_pagination' => array(
  268.                 'label'             => esc_html__( 'Show Pagination', 'et_builder' ),
  269.                 'type'              => 'yes_no_button',
  270.                 'option_category'   => 'configuration',
  271.                 'options'           => array(
  272.                     'on'  => esc_html__( 'Yes', 'et_builder' ),
  273.                     'off' => esc_html__( 'No', 'et_builder' ),
  274.                 ),
  275.                 'toggle_slug'       => 'elements',
  276.                 'description'       => esc_html__( 'Enable or disable pagination for this feed.', 'et_builder' ),
  277.                 'default_on_front'  => 'on',
  278.             ),
  279.             'hover_icon' => array(
  280.                 'label'               => esc_html__( 'Hover Icon Picker', 'et_builder' ),
  281.                 'type'                => 'select_icon',
  282.                 'option_category'     => 'configuration',
  283.                 'class'               => array( 'et-pb-font-icon' ),
  284.                 'depends_show_if'     => 'off',
  285.                 'tab_slug'            => 'advanced',
  286.                 'toggle_slug'         => 'overlay',
  287.             ),
  288.             'zoom_icon_color' => array(
  289.                 'label'             => esc_html__( 'Zoom Icon Color', 'et_builder' ),
  290.                 'type'              => 'color-alpha',
  291.                 'custom_color'      => true,
  292.                 'depends_show_if'   => 'off',
  293.                 'tab_slug'          => 'advanced',
  294.                 'toggle_slug'       => 'overlay',
  295.             ),
  296.             'hover_overlay_color' => array(
  297.                 'label'             => esc_html__( 'Hover Overlay Color', 'et_builder' ),
  298.                 'type'              => 'color-alpha',
  299.                 'custom_color'      => true,
  300.                 'depends_show_if'   => 'off',
  301.                 'tab_slug'          => 'advanced',
  302.                 'toggle_slug'       => 'overlay',
  303.             ),
  304.             '__project_terms' => array(
  305.                 'type'                => 'computed',
  306.                 'computed_callback'   => array( 'ET_Builder_Module_Filterable_Portfolio', 'get_portfolio_terms' ),
  307.                 'computed_depends_on' => array(
  308.                     'include_categories',
  309.                 ),
  310.             ),
  311.             '__projects' => array(
  312.                 'type'                => 'computed',
  313.                 'computed_callback'   => array( 'ET_Builder_Module_Filterable_Portfolio', 'get_portfolio_item' ),
  314.                 'computed_depends_on' => array(
  315.                     'show_pagination',
  316.                     'posts_number',
  317.                     'include_categories',
  318.                     'fullwidth',
  319.                 ),
  320.             ),
  321.         );
  322.  
  323.         return $fields;
  324.     }
  325.  
  326.     static function get_portfolio_item( $args = array(), $conditional_tags = array(), $current_page = array() ) {
  327.         global $et_fb_processing_shortcode_object;
  328.  
  329.         $global_processing_original_value = $et_fb_processing_shortcode_object;
  330.  
  331.         $defaults = array(
  332.             'show_pagination'    => 'on',
  333.             'include_categories' => '',
  334.             'fullwidth'          => 'on',
  335.             'nopaging'           => true,
  336.         );
  337.  
  338.         $query_args = array();
  339.  
  340.         $args = wp_parse_args( $args, $defaults );
  341.  
  342.         $include_categories = self::filter_invalid_term_ids( explode( ',', $args['include_categories'] ), 'project_category' );
  343.  
  344.         if ( ! empty( $include_categories ) ) {
  345.             $query_args['tax_query'] = array(
  346.                 array(
  347.                     'taxonomy' => 'project_category',
  348.                     'field'    => 'id',
  349.                     'terms'    => $include_categories,
  350.                     'operator' => 'IN',
  351.                 )
  352.             );
  353.         }
  354.  
  355.         $default_query_args = array(
  356.             'post_type'   => 'project',
  357.             'post_status' => 'publish',
  358.             'posts_per_page' => -1,
  359.         );
  360.  
  361.         $query_args = wp_parse_args( $query_args, $default_query_args );
  362.  
  363.         // Get portfolio query
  364.         $query = new WP_Query( $query_args );
  365.  
  366.         // Format portfolio output, and add supplementary data
  367.         $width     = 'on' === $args['fullwidth'] ?  1080 : 400;
  368.         $width     = (int) apply_filters( 'et_pb_portfolio_image_width', $width );
  369.         $height    = 'on' === $args['fullwidth'] ?  9999 : 284;
  370.         $height    = (int) apply_filters( 'et_pb_portfolio_image_height', $height );
  371.         $classtext = 'on' === $args['fullwidth'] ? 'et_pb_post_main_image' : '';
  372.         $titletext = get_the_title();
  373.  
  374.         // Loop portfolio item and add supplementary data
  375.         if( $query->have_posts() ) {
  376.             $post_index = 0;
  377.             while ( $query->have_posts() ) {
  378.                 $query->the_post();
  379.  
  380.                 $categories = array();
  381.  
  382.                 $category_classes = array( 'et_pb_portfolio_item' );
  383.  
  384.                 if ( 'on' !== $args['fullwidth'] ) {
  385.                     $category_classes[] = 'et_pb_grid_item';
  386.                 }
  387.  
  388.                 $categories_object = get_the_terms( get_the_ID(), 'project_category' );
  389.                 if ( ! empty( $categories_object ) ) {
  390.                     foreach ( $categories_object as $category ) {
  391.                         // Update category classes which will be used for post_class
  392.                         $category_classes[] = 'project_category_' . urldecode( $category->slug );
  393.  
  394.                         // Push category data
  395.                         $categories[] = array(
  396.                             'id'        => $category->term_id,
  397.                             'slug'      => $category->slug,
  398.                             'label'     => $category->name,
  399.                             'permalink' => get_term_link( $category ),
  400.                         );
  401.                     }
  402.                 }
  403.  
  404.                 // need to disable processnig to make sure get_thumbnail() doesn't generate errors
  405.                 $et_fb_processing_shortcode_object = false;
  406.  
  407.                 // Get thumbnail
  408.                 $thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
  409.  
  410.                 $et_fb_processing_shortcode_object = $global_processing_original_value;
  411.  
  412.                 // Append value to query post
  413.                 $query->posts[ $post_index ]->post_permalink    = get_permalink();
  414.                 $query->posts[ $post_index ]->post_thumbnail    = print_thumbnail( $thumbnail['thumb'], $thumbnail['use_timthumb'], $titletext, $width, $height, '', false, true );
  415.                 $query->posts[ $post_index ]->post_categories   = $categories;
  416.                 $query->posts[ $post_index ]->post_class_name   = array_merge( get_post_class( '', get_the_ID() ), $category_classes );
  417.  
  418.                 // Append category classes
  419.                 $category_classes = implode( ' ', $category_classes );
  420.  
  421.                 $post_index++;
  422.             }
  423.         } else if ( wp_doing_ajax() ) {
  424.             // This is for the VB
  425.             $query = array( 'posts' => self::get_no_results_template() );
  426.         }
  427.  
  428.         wp_reset_postdata();
  429.  
  430.         return $query;
  431.     }
  432.  
  433.     static function get_portfolio_terms( $args = array(), $conditional_tags = array(), $current_page = array() ) {
  434.         $portfolio = self::get_portfolio_item( $args, $conditional_tags, $current_page );
  435.  
  436.         $terms = array();
  437.  
  438.         if ( ! empty( $portfolio->posts ) ) {
  439.             foreach ( $portfolio->posts as $post ) {
  440.                 if ( ! empty( $post->post_categories ) ) {
  441.                     foreach ( $post->post_categories as $category ) {
  442.                         $terms[ $category['slug'] ] = $category;
  443.                     }
  444.                 }
  445.             }
  446.         }
  447.  
  448.         return $terms;
  449.     }
  450.  
  451.     function render( $attrs, $content = null, $render_slug ) {
  452.         $fullwidth          = $this->props['fullwidth'];
  453.         $posts_number       = $this->props['posts_number'];
  454.         $include_categories = $this->props['include_categories'];
  455.         $show_title         = $this->props['show_title'];
  456.         $show_categories    = $this->props['show_categories'];
  457.         $show_pagination    = $this->props['show_pagination'];
  458.         $background_layout  = $this->props['background_layout'];
  459.         $hover_icon          = $this->props['hover_icon'];
  460.         $zoom_icon_color     = $this->props['zoom_icon_color'];
  461.         $hover_overlay_color = $this->props['hover_overlay_color'];
  462.         $header_level        = $this->props['title_level'];
  463.  
  464.         wp_enqueue_script( 'hashchange' );
  465.  
  466.         if ( '' !== $zoom_icon_color ) {
  467.             ET_Builder_Element::set_style( $render_slug, array(
  468.                 'selector'    => '%%order_class%% .et_overlay:before',
  469.                 'declaration' => sprintf(
  470.                     'color: %1$s !important;',
  471.                     esc_html( $zoom_icon_color )
  472.                 ),
  473.             ) );
  474.         }
  475.  
  476.         if ( '' !== $hover_overlay_color ) {
  477.             ET_Builder_Element::set_style( $render_slug, array(
  478.                 'selector'    => '%%order_class%% .et_overlay',
  479.                 'declaration' => sprintf(
  480.                     'background-color: %1$s;
  481.                     border-color: %1$s;',
  482.                     esc_html( $hover_overlay_color )
  483.                 ),
  484.             ) );
  485.         }
  486.  
  487.         $projects = self::get_portfolio_item( array(
  488.             'show_pagination'    => $show_pagination,
  489.             'posts_number'       => $posts_number,
  490.             'include_categories' => $include_categories,
  491.             'fullwidth'          => $fullwidth,
  492.         ) );
  493.  
  494.         $categories_included = array();
  495.         ob_start();
  496.         if( $projects->post_count > 0 ) {
  497.             while ( $projects->have_posts() ) {
  498.                 $projects->the_post();
  499.  
  500.                 $category_classes = array();
  501.                 $categories = get_the_terms( get_the_ID(), 'project_category' );
  502.                 if ( $categories ) {
  503.                     foreach ( $categories as $category ) {
  504.                         $category_classes[] = 'project_category_' . urldecode( $category->slug );
  505.                         $categories_included[] = $category->term_id;
  506.                     }
  507.                 }
  508.  
  509.                 $category_classes = implode( ' ', $category_classes );
  510.  
  511.                 $main_post_class = sprintf(
  512.                     'et_pb_portfolio_item%1$s %2$s',
  513.                     ( 'on' !== $fullwidth ? ' et_pb_grid_item' : '' ),
  514.                     $category_classes
  515.                 );
  516.  
  517.                 ?>
  518.                 <div id="post-<?php the_ID(); ?>" <?php post_class( $main_post_class ); ?>>
  519.                 <?php
  520.                     $thumb = '';
  521.  
  522.                     $width = 'on' === $fullwidth ?  1080 : 400;
  523.                     $width = (int) apply_filters( 'et_pb_portfolio_image_width', $width );
  524.  
  525.                     $height = 'on' === $fullwidth ?  9999 : 284;
  526.                     $height = (int) apply_filters( 'et_pb_portfolio_image_height', $height );
  527.                     $classtext = 'on' === $fullwidth ? 'et_pb_post_main_image' : '';
  528.                     $titletext = get_the_title();
  529.                     $permalink = get_permalink();
  530.                     $post_meta = get_the_term_list( get_the_ID(), 'project_category', '', ', ' );
  531.                     $thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
  532.                     $thumb = $thumbnail["thumb"];
  533.  
  534.  
  535.                     if ( '' !== $thumb ) : ?>
  536.                         <a href="<?php echo esc_url( $permalink ); ?>">
  537.                             <span class="et_portfolio_image">
  538.                                 <?php print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height ); ?>
  539.                         <?php if ( 'on' !== $fullwidth ) :
  540.  
  541.                                 $data_icon = '' !== $hover_icon
  542.                                     ? sprintf(
  543.                                         ' data-icon="%1$s"',
  544.                                         esc_attr( et_pb_process_font_icon( $hover_icon ) )
  545.                                     )
  546.                                     : '';
  547.  
  548.                                 printf( '<span class="et_overlay%1$s"%2$s></span>',
  549.                                     ( '' !== $hover_icon ? ' et_pb_inline_icon' : '' ),
  550.                                     $data_icon
  551.                                 );
  552.  
  553.                         ?>
  554.                         <?php endif; ?>
  555.                             </span>
  556.                         </a>
  557.                 <?php
  558.                     endif;
  559.                 ?>
  560.  
  561.                 <?php if ( 'on' === $show_title ) : ?>
  562.                     <<?php echo et_pb_process_header_level( $header_level, 'h2' ) ?> class="et_pb_module_header"><a href="<?php echo esc_url( $permalink ); ?>"><?php echo $titletext; ?></a></<?php echo et_pb_process_header_level( $header_level, 'h2' ) ?>>
  563.                 <?php endif; ?>
  564.  
  565.                 <?php if ( 'on' === $show_categories ) : ?>
  566.                     <p class="post-meta"><?php echo $post_meta; ?></p>
  567.                 <?php endif; ?>
  568.  
  569.                 </div><!-- .et_pb_portfolio_item -->
  570.                 <?php
  571.             }
  572.         }
  573.  
  574.         wp_reset_postdata();
  575.  
  576.         if ( ! $posts = ob_get_clean() ) {
  577.             $posts            = self::get_no_results_template();
  578.             $category_filters = '';
  579.         } else {
  580.             $categories_included = explode ( ',', $include_categories );
  581.             $terms_args = array(
  582.                 'include' => $categories_included,
  583.                 'orderby' => 'name',
  584.                 'order' => 'ASC',
  585.             );
  586.             $terms = get_terms( 'project_category', $terms_args );
  587.  
  588.             $category_filters = '<ul class="clearfix">';
  589.             $category_filters .= sprintf( '<li class="et_pb_portfolio_filter et_pb_portfolio_filter_all"><a href="#" class="active" data-category-slug="all">%1$s</a></li>',
  590.                 esc_html__( 'All', 'et_builder' )
  591.             );
  592.             foreach ( $terms as $term  ) {
  593.                 $category_filters .= sprintf( '<li class="et_pb_portfolio_filter"><a href="#" data-category-slug="%1$s">%2$s</a></li>',
  594.                     esc_attr( urldecode( $term->slug ) ),
  595.                     esc_html( $term->name )
  596.                 );
  597.             }
  598.             $category_filters .= '</ul>';
  599.         }
  600.  
  601.         $video_background = $this->video_background();
  602.         $parallax_image_background = $this->get_parallax_image_background();
  603.  
  604.         // Images: Add CSS Filters and Mix Blend Mode rules (if set)
  605.         if ( isset( $this->advanced_fields['image']['css'] ) ) {
  606.             $this->add_classname( $this->generate_css_filters(
  607.                 $render_slug,
  608.                 'child_',
  609.                 self::$data_utils->array_get( $this->advanced_fields['image']['css'], 'main', '%%order_class%%' )
  610.             ) );
  611.         }
  612.  
  613.         // Module classnames
  614.         $this->add_classname( array(
  615.             'et_pb_portfolio',
  616.             "et_pb_bg_layout_{$background_layout}",
  617.             $this->get_text_orientation_classname(),
  618.         ) );
  619.  
  620.         if ( 'on' === $fullwidth ) {
  621.             $this->add_classname( 'et_pb_filterable_portfolio_fullwidth' );
  622.         } else {
  623.             $this->add_classname( array(
  624.                 'et_pb_filterable_portfolio_grid',
  625.                 'clearfix',
  626.             ) );
  627.         }
  628.  
  629.         $output = sprintf(
  630.             '<div%4$s class="%1$s" data-posts-number="%5$d"%8$s>
  631.                 %10$s
  632.                 %9$s
  633.                 <div class="et_pb_portfolio_filters clearfix">%2$s</div><!-- .et_pb_portfolio_filters -->
  634.  
  635.                 <div class="et_pb_portfolio_items_wrapper %6$s">
  636.                     <div class="et_pb_portfolio_items">%3$s</div><!-- .et_pb_portfolio_items -->
  637.                 </div>
  638.                 %7$s
  639.             </div> <!-- .et_pb_filterable_portfolio -->',
  640.             $this->module_classname( $render_slug ),
  641.             $category_filters,
  642.             $posts,
  643.             $this->module_id(),
  644.             esc_attr( $posts_number),
  645.             ('on' === $show_pagination ? 'clearfix' : 'no_pagination' ),
  646.             ('on' === $show_pagination ? '<div class="et_pb_portofolio_pagination"></div>' : '' ),
  647.             is_rtl() ? ' data-rtl="true"' : '',
  648.             $video_background,
  649.             $parallax_image_background
  650.         );
  651.  
  652.         return $output;
  653.     }
  654. }
  655.  
  656. new ET_Builder_Module_Filterable_Portfolio;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement