*/ class ACME_Builder_Module_Portfolio extends ET_Builder_Module { public $plugin_name; public $abmp_options; public $presets; function init() { $this->name = 'ACME Custom Portfolio'; $this->slug = 'et_pb_portfolio_acme'; //$this->fb_support = true; $plugin_data = apply_filters( 'acme_drop_data', null ); $this->plugin_name = $plugin_data['plugin_name']; $this->abmp_options = $plugin_data['abmp_options']; if ( isset( $this->abmp_options['abmp_preset'] ) && is_array( $this->abmp_options['abmp_preset'] ) ) { foreach ( $this->abmp_options['abmp_preset'] as $key => $ar ) { $this->presets[ $key ] = $ar['name']; } } $this->whitelisted_fields = array( 'fullwidth', 'posts_number', 'abmp_select_preset', 'show_title', 'show_excerpt', 'show_categories', 'show_pagination', 'background_layout', 'admin_label', 'module_id', 'module_class', 'zoom_icon_color', 'hover_overlay_color', 'hover_icon', ); $this->fields_defaults = array( 'fullwidth' => array( 'on' ), 'abmp_select_preset' => array( 'k0' ), 'posts_number' => array( 10, 'add_default_setting' ), 'show_title' => array( 'on' ), 'show_excerpt' => array( 'off' ), 'show_categories' => array( 'on' ), 'show_pagination' => array( 'on' ), 'background_layout' => array( 'light' ), ); $this->main_css_element = '%%order_class%% .et_pb_portfolio_item'; $this->advanced_options = array( 'fonts' => array( 'title' => array( 'label' => esc_html__( 'Title', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} h2", 'important' => 'all', ), ), 'caption' => array( 'label' => esc_html__( 'Meta', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} .post-meta, {$this->main_css_element} .post-meta a", ), ), ), 'background' => array( 'settings' => array( 'color' => 'alpha', ), ), 'border' => array(), ); $this->custom_css_options = array( 'portfolio_image' => array( 'label' => esc_html__( 'Portfolio Image', 'et_builder' ), 'selector' => '.et_portfolio_image', ), 'overlay' => array( 'label' => esc_html__( 'Overlay', 'et_builder' ), 'selector' => '.et_overlay', ), 'overlay_icon' => array( 'label' => esc_html__( 'Overlay Icon', 'et_builder' ), 'selector' => '.et_overlay:before', ), 'portfolio_title' => array( 'label' => esc_html__( 'Portfolio Title', 'et_builder' ), 'selector' => '.et_pb_portfolio_item h2', ), 'portfolio_post_meta' => array( 'label' => esc_html__( 'Portfolio Post Meta', 'et_builder' ), 'selector' => '.et_pb_portfolio_item .post-meta', ), ); } function get_fields() { $fields = array( 'fullwidth' => array( 'label' => esc_html__( 'Layout', 'et_builder' ), 'type' => 'select', 'option_category' => 'layout', 'options' => array( 'on' => esc_html__( 'Fullwidth', 'et_builder' ), 'off' => esc_html__( 'Grid', 'et_builder' ), ), 'description' => esc_html__( 'Choose your desired portfolio layout style.', 'et_builder' ), 'computed_affects' => array( '__projects', ), ), 'posts_number' => array( 'label' => esc_html__( 'Posts Number', 'et_builder' ), 'type' => 'text', 'option_category' => 'configuration', 'description' => esc_html__( 'Define the number of projects that should be displayed per page.', 'et_builder' ), 'computed_affects' => array( '__projects', ), ), 'abmp_select_preset' => array( 'label' => esc_html__( 'Select Preset', $this->plugin_name ), 'type' => 'select', 'option_category' => 'configuration', 'options' => $this->presets, 'description' => esc_html__( 'Choose your presets for this module.', $this->plugin_name ), 'computed_affects' => array( '__projects', ), ), 'show_title' => array( 'label' => esc_html__( 'Show Title', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'configuration', 'options' => array( 'on' => esc_html__( 'Yes', 'et_builder' ), 'off' => esc_html__( 'No', 'et_builder' ), ), 'description' => esc_html__( 'Turn project titles on or off.', 'et_builder' ), ), 'show_excerpt' => array(//mb 'label' => esc_html__( 'Show Excerpt', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'configuration', 'options' => array( 'on' => esc_html__( 'Yes', 'et_builder' ), 'off' => esc_html__( 'No', 'et_builder' ), ), 'description' => esc_html__( 'Turn display excerpt on or off.', 'et_builder' ), ), 'show_categories' => array( 'label' => esc_html__( 'Show Categories', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'configuration', 'options' => array( 'on' => esc_html__( 'Yes', 'et_builder' ), 'off' => esc_html__( 'No', 'et_builder' ), ), 'description' => esc_html__( 'Turn the category links on or off.', 'et_builder' ), ), 'show_pagination' => array( 'label' => esc_html__( 'Show Pagination', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'configuration', 'options' => array( 'on' => esc_html__( 'Yes', 'et_builder' ), 'off' => esc_html__( 'No', 'et_builder' ), ), 'description' => esc_html__( 'Enable or disable pagination for this feed.', 'et_builder' ), ), 'background_layout' => array( 'label' => esc_html__( 'Text Color', 'et_builder' ), 'type' => 'select', 'option_category' => 'color_option', 'options' => array( 'light' => esc_html__( 'Dark', 'et_builder' ), 'dark' => esc_html__( 'Light', 'et_builder' ), ), 'description' => esc_html__( 'Here you can choose whether your text should be light or dark. If you are working with a dark background, then your text should be light. If your background is light, then your text should be set to dark.', 'et_builder' ), ), 'zoom_icon_color' => array( 'label' => esc_html__( 'Zoom Icon Color', 'et_builder' ), 'type' => 'color', 'custom_color' => true, 'tab_slug' => 'advanced', ), 'hover_overlay_color' => array( 'label' => esc_html__( 'Hover Overlay Color', 'et_builder' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', ), 'hover_icon' => array( 'label' => esc_html__( 'Hover Icon Picker', 'et_builder' ), 'type' => 'text', 'option_category' => 'configuration', 'class' => array( 'et-pb-font-icon' ), 'renderer' => 'et_pb_get_font_icon_list', 'renderer_with_field' => true, 'tab_slug' => 'advanced', ), 'disabled_on' => array( 'label' => esc_html__( 'Disable on', 'et_builder' ), 'type' => 'multiple_checkboxes', 'options' => array( 'phone' => esc_html__( 'Phone', 'et_builder' ), 'tablet' => esc_html__( 'Tablet', 'et_builder' ), 'desktop' => esc_html__( 'Desktop', 'et_builder' ), ), 'additional_att' => 'disable_on', 'option_category' => 'configuration', 'description' => esc_html__( 'This will disable the module on selected devices', 'et_builder' ), ), 'admin_label' => array( 'label' => esc_html__( 'Admin Label', 'et_builder' ), 'type' => 'text', 'description' => esc_html__( 'This will change the label of the module in the builder for easy identification.', 'et_builder' ), ), 'module_id' => array( 'label' => esc_html__( 'CSS ID', 'et_builder' ), 'type' => 'text', 'option_category' => 'configuration', 'tab_slug' => 'custom_css', 'option_class' => 'et_pb_custom_css_regular', ), 'module_class' => array( 'label' => esc_html__( 'CSS Class', 'et_builder' ), 'type' => 'text', 'option_category' => 'configuration', 'tab_slug' => 'custom_css', 'option_class' => 'et_pb_custom_css_regular', ), '__projects' => array( 'type' => 'computed', 'computed_callback' => array( 'ET_Builder_Module_Portfolio', 'get_portfolio_item' ), 'computed_depends_on' => array( 'abmp_select_preset', 'posts_number', 'include_categories', 'fullwidth', ), ), ); return $fields; } /** * Get portfolio objects for portfolio module * * @param array arguments that affect et_pb_portfolio query * @param array passed conditional tag for update process * @param array passed current page params * @return array portfolio item data */ static function get_portfolio_item( $args = array(), $conditional_tags = array(), $current_page = array() ) { $defaults = array( 'posts_number' => 10, 'include_categories' => 0, 'fullwidth' => 'on', ); $args = wp_parse_args( $args, $defaults ); // Native conditional tag only works on page load. Data update needs $conditional_tags data $is_front_page = et_fb_conditional_tag( 'is_front_page', $conditional_tags ); $is_search = et_fb_conditional_tag( 'is_search', $conditional_tags ); // Prepare query arguments $query_args = array( 'posts_per_page' => (int) $args['posts_number'], 'post_type' => $args['abmp_post_type'], 'post_status' => 'publish', 'order' => $args['abmp_order'], 'orderby' => $args['abmp_orderby'] ); // Conditionally get paged data if ( defined( 'DOING_AJAX' ) && isset( $current_page[ 'paged'] ) ) { $et_paged = intval( $current_page[ 'paged' ] ); } else { $et_paged = $is_front_page ? get_query_var( 'page' ) : get_query_var( 'paged' ); } if ( $is_front_page ) { $paged = $et_paged; } if ( ! is_search() ) { $query_args['paged'] = $et_paged; } // Passed categories parameter if ( '' !== $args['include_categories'] ) { $query_args['tax_query'] = array( array( 'taxonomy' => $args['abmp_taxonomy'], 'field' => 'id', 'terms' => explode( ',', $args['include_categories'] ), 'operator' => 'IN', ) ); } // Get portfolio query $query = new WP_Query( $query_args ); // Format portfolio output, and add supplementary data $width = 'on' === $args['fullwidth'] ? 1080 : 400; $width = (int) apply_filters( 'et_pb_portfolio_image_width', $width ); $height = 'on' === $args['fullwidth'] ? 9999 : 284; $height = (int) apply_filters( 'et_pb_portfolio_image_height', $height ); $classtext = 'on' === $args['fullwidth'] ? 'et_pb_post_main_image' : ''; $titletext = get_the_title(); // Loop portfolio item data and add supplementary data if ( $query->have_posts() ) { $post_index = 0; while( $query->have_posts() ) { $query->the_post(); $categories = array(); $categories_object = get_the_terms( get_the_ID(), 'product_cat' ); if ( ! empty( $categories_object ) ) { foreach ( $categories_object as $category ) { if ( is_object( $category ) ) { $categories[] = array( 'id' => $category->term_id, 'label' => $category->name, 'permalink' => get_term_link( $category ), ); } } } // Get thumbnail $thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' ); // Append value to query post $query->posts[ $post_index ]->post_permalink = get_permalink(); $query->posts[ $post_index ]->post_thumbnail = print_thumbnail( $thumbnail['thumb'], $thumbnail['use_timthumb'], $titletext, $width, $height, '', false, true ); $query->posts[ $post_index ]->post_categories = $categories; $query->posts[ $post_index ]->post_class_name = get_post_class( '', get_the_ID() ); $post_index++; } $query->posts_next = array( 'label' => esc_html__( '« Older Entries', 'et_builder' ), 'url' => next_posts( $query->max_num_pages, false ), ); $query->posts_prev = array( 'label' => esc_html__( 'Next Entries »', 'et_builder' ), 'url' => ( $et_paged > 1 ) ? previous_posts( false ) : '', ); // Added wp_pagenavi support $query->wp_pagenavi = function_exists( 'wp_pagenavi' ) ? wp_pagenavi( array( 'query' => $query, 'echo' => false ) ) : false; } wp_reset_postdata(); return $query; } function shortcode_callback( $atts, $content = null, $function_name ) { $module_id = $this->shortcode_atts['module_id']; $module_class = $this->shortcode_atts['module_class']; $fullwidth = $this->shortcode_atts['fullwidth']; $posts_number = $this->shortcode_atts['posts_number']; $abmp_select_preset = $this->shortcode_atts['abmp_select_preset']; $include_categories = implode(',',array_keys($this->abmp_options['abmp_preset'][$abmp_select_preset]['terms'])); $show_title = $this->shortcode_atts['show_title']; $show_excerpt = $this->shortcode_atts['show_excerpt'];//mb $show_categories = $this->shortcode_atts['show_categories']; $show_pagination = $this->shortcode_atts['show_pagination']; $background_layout = $this->shortcode_atts['background_layout']; $zoom_icon_color = $this->shortcode_atts['zoom_icon_color']; $hover_overlay_color = $this->shortcode_atts['hover_overlay_color']; $hover_icon = $this->shortcode_atts['hover_icon']; $abmp_post_type = $this->abmp_options['abmp_preset'][ $abmp_select_preset ]['post_type']; $abmp_taxonomy = $this->abmp_options['abmp_preset'][ $abmp_select_preset ]['taxonomy']; $abmp_order =$this->abmp_options['abmp_preset'][ $abmp_select_preset ]['abmp_order']; $abmp_orderby =$this->abmp_options['abmp_preset'][ $abmp_select_preset ]['abmp_orderby']; global $paged; $module_class = ET_Builder_Element::add_module_order_class( $module_class, $function_name ); // Set inline style if ( '' !== $zoom_icon_color ) { ET_Builder_Element::set_style( $function_name, array( 'selector' => '%%order_class%% .et_overlay:before', 'declaration' => sprintf( 'color: %1$s !important;', esc_html( $zoom_icon_color ) ), ) ); } if ( '' !== $hover_overlay_color ) { ET_Builder_Element::set_style( $function_name, array( 'selector' => '%%order_class%% .et_overlay', 'declaration' => sprintf( 'background-color: %1$s; border-color: %1$s;', esc_html( $hover_overlay_color ) ), ) ); } $container_is_closed = false; // Get loop data $portfolio = self::get_portfolio_item( array( 'posts_number' => $posts_number, 'include_categories' => $include_categories, 'abmp_select_preset' => $abmp_select_preset, 'abmp_post_type' => $abmp_post_type, 'abmp_taxonomy' => $abmp_taxonomy, 'fullwidth' => $fullwidth, 'abmp_order' => $abmp_order, 'abmp_orderby' => $abmp_orderby ) ); // setup overlay if ( 'on' !== $fullwidth ) { $data_icon = '' !== $hover_icon ? sprintf( ' data-icon="%1$s"', esc_attr( et_pb_process_font_icon( $hover_icon ) ) ) : ''; $overlay = sprintf( '', ( '' !== $hover_icon ? ' et_pb_inline_icon' : '' ), $data_icon ); } ob_start(); if ( $portfolio->have_posts() ) { while( $portfolio->have_posts() ) { $portfolio->the_post(); // Get $post data of current loop global $post; array_push( $post->post_class_name, 'et_pb_portfolio_item' ); if ( 'on' !== $fullwidth ) { array_push( $post->post_class_name, 'et_pb_grid_item' ); } ?>
$portfolio ) ); } else { if ( et_is_builder_plugin_active() ) { include( ET_BUILDER_PLUGIN_DIR . 'includes/navigation.php' ); } else { $next_posts_link_html = $prev_posts_link_html = ''; if ( ! empty( $portfolio->posts_next['url'] ) ) { $next_posts_link_html = sprintf( '', esc_url( $portfolio->posts_next['url'] ), esc_html( $portfolio->posts_next['label'] ) ); } if ( ! empty( $portfolio->posts_prev['url'] ) ) { $prev_posts_link_html = sprintf( '', esc_url( $portfolio->posts_prev['url'] ), esc_html( $portfolio->posts_prev['label'] ) ); } printf( '