Advertisement
Guest User

Untitled

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