*/
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'];
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'],
'order_by' => $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 ) {
$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' );
}
?>
post_thumbnail ) { ?>
post_categories ) ) : ?>
post_categories as $category ) {
$category_index++;
$separator = $category_index < count( $post->post_categories ) ? ', ' : '';
echo '' . esc_html( $category['label'] ) . '' . $separator;
}
?>
$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(
'',
$next_posts_link_html,
$prev_posts_link_html
);
}
}
}
} else {
if ( et_is_builder_plugin_active() ) {
include( ET_BUILDER_PLUGIN_DIR . 'includes/no-results.php' );
} else {
get_template_part( 'includes/no-results', 'index' );
}
}
// Reset post data
wp_reset_postdata();
$posts = ob_get_contents();
ob_end_clean();
$class = " et_pb_module et_pb_bg_layout_{$background_layout}";
$output = sprintf(
'
%2$s
%4$s',
( 'on' === $fullwidth ? 'et_pb_portfolio' : 'et_pb_portfolio_grid clearfix' ),
$posts,
esc_attr( $class ),
( ! $container_is_closed ? '
' : '' ),
( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
);
return $output;
}
}
/**
* ACME_Builder_Module_Fullwidth_Portfolio
*
* Extended functionalities:
* - added option to show excerpt in results
* - Portfolio works with any post_type and taxonomies (via presets)
* - ACME Carousel Style will show excerpt and custom fields (via preset)
* - ACME Carousel Style can replace default premalink with any url in custom fileds (via preset)
* - Change default columns number output for ACME Carousel Style
*
* presets are setup from Acme Panel
*
* @since 1.0.0
* @package Acme_Divi_Modules
* @subpackage Acme_Divi_Modules/admin
* @author Mirko Bianco
*/
class ACME_Builder_Module_Fullwidth_Portfolio extends ET_Builder_Module {
public $plugin_name;
public $abmp_options;
public $presets;
function init() {
$this->name = 'ACME FW Portfolio';
$this->slug = 'et_pb_portfolio_fw_acme';
//$this->fb_support = true;
$this->fullwidth = true;
$plugin_data = apply_filters( 'acme_drop_data', null );
$this->plugin_name = $plugin_data['plugin_name'];
$this->abmp_options = $plugin_data['abmp_options'];
foreach ( $this->abmp_options['abmp_preset'] as $key => $ar ) {
$this->presets[ $key ] = $ar['name'];
}
// need to use global settings from the slider module
$this->global_settings_slug = 'et_pb_portfolio';
$this->whitelisted_fields = array(
'title',
'abmp_select_preset',
'max_columns',
'posts_number',
'show_title',
'show_excerpt',//mb
'show_date',
'background_layout',
'auto',
'auto_speed',
'hover_icon',
'hover_overlay_color',
'zoom_icon_color',
'admin_label',
'module_id',
'module_class',
);
$this->main_css_element = '%%order_class%%';
$this->advanced_options = array(
'fonts' => array(
'title' => array(
'label' => esc_html__( 'Title', 'et_builder' ),
'css' => array(
'main' => "{$this->main_css_element} h3",
'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(
'css' => array(
'main' => "{$this->main_css_element} .et_pb_portfolio_item",
),
),
);
$this->custom_css_options = array(
'portfolio_title' => array(
'label' => esc_html__( 'Portfolio Title', 'et_builder' ),
'selector' => '> h2',
),
'portfolio_item' => array(
'label' => esc_html__( 'Portfolio Item', 'et_builder' ),
'selector' => '.et_pb_portfolio_item',
),
'portfolio_overlay' => array(
'label' => esc_html__( 'Item Overlay', 'et_builder' ),
'selector' => 'span.et_overlay',
),
'portfolio_item_title' => array(
'label' => esc_html__( 'Item Title', 'et_builder' ),
'selector' => '.meta h3',
),
'portfolio_meta' => array(
'label' => esc_html__( 'Meta', 'et_builder' ),
'selector' => '.meta p',
),
'portfolio_arrows' => array(
'label' => esc_html__( 'Navigation Arrows', 'et_builder' ),
'selector' => '.et-pb-slider-arrows a',
),
);
$this->fields_defaults = array(
'abmp_select_preset' => array( 'k0' ),
'show_title' => array( 'on' ),
'show_excerpt' => array( 'off' ),
'max_columns' => array( 5,4,3,2,1 ),
'show_date' => array( 'on' ),
'background_layout' => array( 'light' ),
'auto' => array( 'off' ),
'auto_speed' => array( '7000' ),
);
}
function get_fields() {
$fields = array(
'title' => array(
'label' => esc_html__( 'Portfolio Title', 'et_builder' ),
'type' => 'text',
'option_category' => 'basic_option',
'description' => esc_html__( 'Title displayed above the portfolio.', 'et_builder' ),
),
'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',
),
),
'max_columns' => array(
'label' => esc_html__( 'Display Max Columns', $this->plugin_name ),
'type' => 'text',
'option_category' => 'configuration',
'description' => esc_html__( 'Comma Separated Values for responsive breakpoints: 1600|1024|768|480|320. This will affect the number of columns per row.', $this->plugin_name )
),
'posts_number' => array(
'label' => esc_html__( 'Posts Number', 'et_builder' ),
'type' => 'text',
'option_category' => 'configuration',
'description' => esc_html__( 'Control how many projects are displayed. Leave blank or use 0 to not limit the amount.', 'et_builder' )
),
'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_date' => array(
'label' => esc_html__( 'Show Date', '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 date display on or off.', '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' ),
),
'auto' => array(
'label' => esc_html__( 'Automatic Carousel Rotation', 'et_builder' ),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'options' => array(
'off' => esc_html__( 'Off', 'et_builder' ),
'on' => esc_html__( 'On', 'et_builder' ),
),
'affects' => array(
'auto_speed',
),
'depends_show_if' => 'on',
'description' => esc_html__( 'If the carousel layout option is chosen and you would like the carousel to slide automatically, without the visitor having to click the next button, enable this option and then adjust the rotation speed below if desired.', 'et_builder' ),
),
'auto_speed' => array(
'label' => esc_html__( 'Automatic Carousel Rotation Speed (in ms)', 'et_builder' ),
'type' => 'text',
'option_category' => 'configuration',
'depends_default' => true,
'description' => esc_html__( "Here you can designate how fast the carousel rotates, if 'Automatic Carousel Rotation' option is enabled above. The higher the number the longer the pause between each rotation. (Ex. 1000 = 1 sec)", '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_Fullwidth_Portfolio', 'get_portfolio_item' ),
'computed_depends_on' => array(
'posts_number',
),
),
);
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' => '',
'include_categories' => '',
);
$args = wp_parse_args( $args, $defaults );
$query_args = array(
'post_type' => $args['abmp_post_type'],
'post_status' => 'publish',
'order' => $args['abmp_order'],
'order_by' => $args['abmp_orderby']
);
if ( is_numeric( $args['posts_number'] ) && $args['posts_number'] > 0 ) {
$query_args['posts_per_page'] = $args['posts_number'];
} else {
$query_args['nopaging'] = true;
}
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, add supplementary data
$width = (int) apply_filters( 'et_pb_portfolio_image_width', 510 );
$height = (int) apply_filters( 'et_pb_portfolio_image_height', 382 );
if( $query->post_count > 0 ) {
$post_index = 0;
while ( $query->have_posts() ) {
$query->the_post();
// Get thumbnail
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), array( $width, $height ) );
if ( isset( $thumbnail[2] ) && isset( $thumbnail[1] ) ) {
$orientation = ( $thumbnail[2] > $thumbnail[1] ) ? 'portrait' : 'landscape';
} else {
$orientation = false;
}
$href = null;
//inspect meta
if ($args['href'] ) {
$href = get_post_meta( get_the_ID(), $args['href'], true );
}
// Append value to query post
$query->posts[ $post_index ]->post_permalink = $href ? $href : get_permalink();
$query->posts[ $post_index ]->post_thumbnail = isset( $thumbnail[0] ) ? $thumbnail[0] : false;
$query->posts[ $post_index ]->post_thumbnail_orientation = $orientation;
$query->posts[ $post_index ]->post_date_readable = get_the_date();
$query->posts[ $post_index ]->post_class_name = get_post_class( 'et_pb_portfolio_item et_pb_grid_item acme_portfolio_item' );
$post_index++;
}
}
wp_reset_postdata();
return $query;
}
function shortcode_callback( $atts, $content = null, $function_name ) {
$fullwidth = 'on';
$title = $this->shortcode_atts['title'];
$module_id = $this->shortcode_atts['module_id'];
$module_class = $this->shortcode_atts['module_class'];
$abmp_select_preset = $this->shortcode_atts['abmp_select_preset'];
$max_columns = $this->shortcode_atts['max_columns'];
$posts_number = $this->shortcode_atts['posts_number'];
$show_title = $this->shortcode_atts['show_title'];
$show_date = $this->shortcode_atts['show_date'];
$background_layout = $this->shortcode_atts['background_layout'];
$auto = $this->shortcode_atts['auto'];
$auto_speed = $this->shortcode_atts['auto_speed'];
$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'];
$show_excerpt = $this->shortcode_atts['show_excerpt'];
$abmp_order =$this->abmp_options['abmp_preset'][ $abmp_select_preset ]['abmp_order'];
$abmp_orderby =$this->abmp_options['abmp_preset'][ $abmp_select_preset ]['abmp_orderby'];
$include_categories = implode(',',array_keys($this->abmp_options['abmp_preset'][$abmp_select_preset]['terms']));
$abmp_post_meta = $this->abmp_options['abmp_preset'][ $abmp_select_preset ]['post_meta'];
$abmp_href = $this->abmp_options['abmp_preset'][ $abmp_select_preset ]['href'];
//apply_filters('acme_debug',$this->abmp_options['abmp_preset'][$abmp_select_preset]['fw_style'],'Valore Indice preset');
$module_class = ET_Builder_Element::add_module_order_class( $module_class, $function_name );
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 )
),
) );
}
$args = array();
if ( is_numeric( $posts_number ) && $posts_number > 0 ) {
$args['posts_per_page'] = $posts_number;
} else {
$args['nopaging'] = true;
}
if ( '' !== $include_categories ) {
$args['tax_query'] = array(
array(
'taxonomy' => 'project_category',
'field' => 'id',
'terms' => explode( ',', $include_categories ),
'operator' => 'IN'
)
);
}
$projects = 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,
'href' => $abmp_href,
'abmp_order' => $abmp_order,
'abmp_orderby' => $abmp_orderby
) );
// take some settings from standard portfolio module if acme style is set
// 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 )
),
) );
}
$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( $projects->post_count > 0 ) {
while ( $projects->have_posts() ) {
$projects->the_post();
?>
post_class_name, 'et_pb_portfolio_item' );
/*if ( 'on' !== $fullwidth ) {
array_push( $post->post_class_name, 'et_pb_grid_item' );
}*/
?>
post_thumbnail ) { ?>
ID );
if($abmp_post_meta) {
if(is_array($all_meta)) {
foreach ( explode(',',$abmp_post_meta) as $meta ) {
echo sprintf( '
%2$s',
$meta,
$all_meta[$meta][0] );
}
}
}
?>
%8$s
%2$s
',
( 'on' === $fullwidth ? 'et_pb_fullwidth_portfolio_carousel' : 'et_pb_fullwidth_portfolio_grid clearfix' ),
$posts,
esc_attr( $class ),
( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
( '' !== $auto && in_array( $auto, array( 'on', 'off' ) ) ? esc_attr( $auto ) : 'off' ),
( '' !== $auto_speed && is_numeric( $auto_speed ) ? esc_attr( $auto_speed ) : '7000' ),
( '' !== $title ? sprintf( '%s
', esc_html( $title ) ) : '' ),
( '1' == $this->abmp_options['abmp_preset'][ $abmp_select_preset ]['fw_style'] ? ' acme_carousel' : 'placeholder' ),
( '1' == $this->abmp_options['abmp_preset'][ $abmp_select_preset ]['fw_style'] ? 'acme_portfolio_items' : 'placeholder' ),
( $max_columns )
);
return $output;
}
}
/**
* ACME_Builder_Module_Blog
*
* Extended functionalities:
* - added option to change post order and sorting
* - added Masonry support, you can change how many columns display for your grid
*
*
* @since 1.1.0
* @package Acme_Divi_Modules
* @subpackage Acme_Divi_Modules/admin
* @author Mirko Bianco
*/
class ACME_Builder_Module_Blog extends ET_Builder_Module {
public $plugin_name;
public $abmb_options;
function init() {
$this->name = 'ACME Blog';
$this->slug = 'et_pb_blog_acme';
//$this->fb_support = true;
$plugin_data = apply_filters( 'acme_drop_data', null );
$this->plugin_name = $plugin_data['plugin_name'];
//$this->abmb_options = $plugin_data['abmb_options'];
$this->whitelisted_fields = array(
'fullwidth',
'posts_number',
'use_masonry',
'columns',
'random_size',
'ds_field',
'include_categories',
'meta_date',
'show_thumbnail',
'show_content',
'show_more',
'orderby',
'order',
'show_author',
'show_date',
'show_categories',
'show_comments',
'show_pagination',
'offset_number',
'background_layout',
'admin_label',
'module_id',
'module_class',
'masonry_tile_background_color',
'use_dropshadow',
'use_overlay',
'overlay_icon_color',
'hover_overlay_color',
'hover_icon',
);
$this->fields_defaults = array(
'fullwidth' => array( 'on' ),
'posts_number' => array( 10, 'add_default_setting' ),
'use_masonry' => array( 'off', 'add_default_setting' ),
'columns' => array( 1, 'add_default_setting' ),
'random_size' => array( 'off', 'add_default_setting' ),
//'ds_field' => array( null ),
'meta_date' => array( 'M j, Y', 'add_default_setting' ),
'show_thumbnail' => array( 'on' ),
'show_content' => array( 'off' ),
'orderby' => array( 'date' ),
'order' => array( 'on' ),
'show_more' => array( 'off' ),
'show_author' => array( 'on' ),
'show_date' => array( 'on' ),
'show_categories' => array( 'on' ),
'show_comments' => array( 'off' ),
'show_pagination' => array( 'on' ),
'offset_number' => array( 0, 'only_default_setting' ),
'background_layout' => array( 'light' ),
'use_dropshadow' => array( 'off' ),
'use_overlay' => array( 'off' ),
);
$this->main_css_element = '%%order_class%% .et_pb_post';
$this->advanced_options = array(
'fonts' => array(
'header' => array(
'label' => esc_html__( 'Header', 'et_builder' ),
'css' => array(
'main' => "{$this->main_css_element} .entry-title",
'important' => 'all',
),
),
'meta' => array(
'label' => esc_html__( 'Meta', 'et_builder' ),
'css' => array(
'main' => "{$this->main_css_element} .post-meta",
),
),
'body' => array(
'label' => esc_html__( 'Body', 'et_builder' ),
'css' => array(
'color' => "{$this->main_css_element}, {$this->main_css_element} .post-content *",
'line_height' => "{$this->main_css_element} p",
),
),
),
'border' => array(
'css' => array(
'main' => "%%order_class%%.et_pb_module .et_pb_post",
'important' => 'plugin_only',
),
),
);
$this->custom_css_options = array(
'title' => array(
'label' => esc_html__( 'Title', 'et_builder' ),
'selector' => '.et_pb_post .entry-title',
),
'post_meta' => array(
'label' => esc_html__( 'Post Meta', 'et_builder' ),
'selector' => '.et_pb_post .post-meta',
),
'pagenavi' => array(
'label' => esc_html__( 'Pagenavi', 'et_builder' ),
'selector' => '.wp_pagenavi',
),
'featured_image' => array(
'label' => esc_html__( 'Featured Image', 'et_builder' ),
'selector' => '.et_pb_image_container',
),
'read_more' => array(
'label' => esc_html__( 'Read More Button', 'et_builder' ),
'selector' => '.et_pb_post .more-link',
),
);
}
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' ),
),
'affects' => array(
'background_layout',
'use_dropshadow',
'masonry_tile_background_color',
),
'description' => esc_html__( 'Toggle between the various blog layout types.', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'posts_number' => array(
'label' => esc_html__( 'Posts Number', 'et_builder' ),
'type' => 'text',
'option_category' => 'configuration',
'description' => esc_html__( 'Choose how much posts you would like to display per page.', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'use_masonry' => array(
'label' => esc_html__( 'Use Masonry', $this->plugin_name ),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'options' => array(
'on' => esc_html__( 'Yes', 'et_builder' ),
'off' => esc_html__( 'No', 'et_builder' ),
),
'affects' => array('columns','random_size'),
'description' => esc_html__( 'Apply a nice masonry effect and choose how many columns to display.', $this->plugin_name )
),
'columns' => array(
'label' => esc_html__( 'Masonry Columns', $this->plugin_name ),
'type' => 'text',
'option_category' => 'configuration',
'depends_show_if' => 'on',
'description' => esc_html__( 'Choose how many columns you want to display. Comma Separated Values for element widths: 1600|1024|768|480|320. This will affect the number of columns per row.', $this->plugin_name )
),
'random_size' => array(
'label' => esc_html__( 'Random Size', $this->plugin_name ),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'options' => array(
'on' => esc_html__( 'Yes', 'et_builder' ),
'off' => esc_html__( 'No', 'et_builder' ),
),
'affects' => array( 'ds_field' ),
'depends_show_if' => 'on',
'description' => esc_html__( 'Some items will display double sized. Set to No if you want to set double size elements manually or leave all the elements at the same size', $this->plugin_name )
),
'ds_field' => array(
'label' => esc_html__( 'Double Size Field', $this->plugin_name ),
'type' => 'text',
'option_category' => 'configuration',
'depends_show_if' => 'off',
'description' => esc_html__( 'If you want to display specific post in double size, define the Custom Field name you want to use. In your post you must this very Custom Field and assign a non empty value to it. For instance fill the value `divi-ds` here and add the same custom field `divi-ds` with value `1` to the posts you want to display double size. Leave blank if you want to keep all elements at the same size.', $this->plugin_name )
),
'include_categories' => array(
'label' => esc_html__( 'Include Categories', 'et_builder' ),
'renderer' => 'et_builder_include_categories_option',
'option_category' => 'basic_option',
'renderer_options' => array(
'use_terms' => false,
),
'description' => esc_html__( 'Choose which categories you would like to include in the feed.', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'meta_date' => array(
'label' => esc_html__( 'Meta Date Format', 'et_builder' ),
'type' => 'text',
'option_category' => 'configuration',
'description' => esc_html__( 'If you would like to adjust the date format, input the appropriate PHP date format here.', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'show_thumbnail' => array(
'label' => esc_html__( 'Show Featured Image', '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__( 'This will turn thumbnails on and off.', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'show_content' => array(
'label' => esc_html__( 'Content', 'et_builder' ),
'type' => 'select',
'option_category' => 'configuration',
'options' => array(
'off' => esc_html__( 'Show Excerpt', 'et_builder' ),
'on' => esc_html__( 'Show Content', 'et_builder' ),
),
'affects' => array(
'show_more',
),
'description' => esc_html__( 'Showing the full content will not truncate your posts on the index page. Showing the excerpt will only display your excerpt text.', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'show_more' => array(
'label' => esc_html__( 'Read More Button', 'et_builder' ),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'options' => array(
'off' => esc_html__( 'Off', 'et_builder' ),
'on' => esc_html__( 'On', 'et_builder' ),
),
'depends_show_if' => 'off',
'description' => esc_html__( 'Here you can define whether to show "read more" link after the excerpts or not.', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'orderby' => array(
'label' => esc_html__( 'Order By', $this->plugin_name ),
'type' => 'select',
'option_category' => 'configuration',
'options' => array(
'date' => __( 'Date', $this->plugin_name ),
'modified' => __( 'Modified Date', $this->plugin_name ),
'title' => __( 'Title', $this->plugin_name ),
'name' => __( 'Name', $this->plugin_name ),
'ID' => 'ID',
'rand' => __( 'Random Order', $this->plugin_name ),
'author' => __( 'Author', $this->plugin_name ),
),
'affects' => array(
'oreder_reverse',
),
'description' => esc_html__( 'Apply custom order to Blog Module', $this->plugin_name ),
'computed_affects' => array(
'__posts',
),
),
'order' => array(
'label' => esc_html__( 'Reverse Order', $this->plugin_name ),
'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 on or off the reverse order of posts.', $this->plugin_name ),
'computed_affects' => array(
'__posts',
),
),
'show_author' => array(
'label' => esc_html__( 'Show Author', '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 on or off the author link.', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'show_date' => array(
'label' => esc_html__( 'Show Date', '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 date on or off.', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'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' ),
'computed_affects' => array(
'__posts',
),
),
'show_comments' => array(
'label' => esc_html__( 'Show Comment Count', '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 comment count on and off.', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'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__( 'Turn pagination on and off.', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'offset_number' => array(
'label' => esc_html__( 'Offset Number', 'et_builder' ),
'type' => 'text',
'option_category' => 'configuration',
'description' => esc_html__( 'Choose how many posts you would like to offset by', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'use_overlay' => array(
'label' => esc_html__( 'Featured Image Overlay', 'et_builder' ),
'type' => 'yes_no_button',
'option_category' => 'layout',
'options' => array(
'off' => esc_html__( 'Off', 'et_builder' ),
'on' => esc_html__( 'On', 'et_builder' ),
),
'affects' => array(
'overlay_icon_color',
'hover_overlay_color',
'hover_icon',
),
'description' => esc_html__( 'If enabled, an overlay color and icon will be displayed when a visitors hovers over the featured image of a post.', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'overlay_icon_color' => array(
'label' => esc_html__( 'Overlay Icon Color', 'et_builder' ),
'type' => 'color',
'custom_color' => true,
'depends_show_if' => 'on',
'description' => esc_html__( 'Here you can define a custom color for the overlay icon', 'et_builder' ),
),
'hover_overlay_color' => array(
'label' => esc_html__( 'Hover Overlay Color', 'et_builder' ),
'type' => 'color-alpha',
'custom_color' => true,
'depends_show_if' => 'on',
'description' => esc_html__( 'Here you can define a custom color for the overlay', 'et_builder' ),
),
'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,
'depends_show_if' => 'on',
'description' => esc_html__( 'Here you can define a custom icon for the overlay', 'et_builder' ),
'computed_affects' => array(
'__posts',
),
),
'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' ),
),
'depends_default' => true,
'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' ),
),
'masonry_tile_background_color' => array(
'label' => esc_html__( 'Grid Tile Background Color', 'et_builder' ),
'type' => 'color-alpha',
'custom_color' => true,
'tab_slug' => 'advanced',
'depends_show_if' => 'off',
'depends_to' => array(
'fullwidth'
),
),
'use_dropshadow' => array(
'label' => esc_html__( 'Use Dropshadow', 'et_builder' ),
'type' => 'yes_no_button',
'option_category' => 'layout',
'options' => array(
'off' => esc_html__( 'Off', 'et_builder' ),
'on' => esc_html__( 'On', 'et_builder' ),
),
'tab_slug' => 'advanced',
'depends_show_if' => 'off',
'depends_to' => array(
'fullwidth'
),
),
'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',
),
'__posts' => array(
'type' => 'computed',
'computed_callback' => array( 'ET_Builder_Module_Blog', 'get_blog_posts' ),
'computed_depends_on' => array(
'fullwidth',
'posts_number',
'include_categories',
'meta_date',
'show_thumbnail',
'show_content',
'show_more',
'orderby',
'order',
'show_author',
'show_date',
'show_categories',
'show_comments',
'show_pagination',
'offset_number',
'use_overlay',
'hover_icon',
),
),
);
return $fields;
}
/**
* Get blog posts for blog module
*
* @param array arguments that is being used by et_pb_blog
* @return string blog post markup
*/
static function get_blog_posts( $args = array(), $conditional_tags = array(), $current_page = array() ) {
global $paged, $post, $wp_query, $et_fb_processing_shortcode_object, $et_pb_rendering_column_content;
$global_processing_original_value = $et_fb_processing_shortcode_object;
// Default params are combination of attributes that is used by et_pb_blog and
// conditional tags that need to be simulated (due to AJAX nature) by passing args
$defaults = array(
'fullwidth' => '',
'posts_number' => '',
'include_categories' => '',
'meta_date' => '',
'show_thumbnail' => '',
'show_content' => '',
'show_author' => '',
'orderby' => '',
'order' => '',
'show_date' => '',
'show_categories' => '',
'show_comments' => '',
'show_pagination' => '',
'background_layout' => '',
'show_more' => '',
'offset_number' => '',
'masonry_tile_background_color' => '',
'use_dropshadow' => '',
'overlay_icon_color' => '',
'hover_overlay_color' => '',
'hover_icon' => '',
'use_overlay' => '',
);
// WordPress' native conditional tag is only available during page load. It'll fail during component update because
// et_pb_process_computed_property() is loaded in admin-ajax.php. Thus, use WordPress' conditional tags on page load and
// rely to passed $conditional_tags for AJAX call
$is_front_page = et_fb_conditional_tag( 'is_front_page', $conditional_tags );
$is_search = et_fb_conditional_tag( 'is_search', $conditional_tags );
$is_single = et_fb_conditional_tag( 'is_single', $conditional_tags );
$et_is_builder_plugin_active = et_fb_conditional_tag( 'et_is_builder_plugin_active', $conditional_tags );
$container_is_closed = false;
// remove all filters from WP audio shortcode to make sure current theme doesn't add any elements into audio module
remove_all_filters( 'wp_audio_shortcode_library' );
remove_all_filters( 'wp_audio_shortcode' );
remove_all_filters( 'wp_audio_shortcode_class');
$args = wp_parse_args( $args, $defaults );
$overlay_output = '';
$hover_icon = '';
if ( 'on' === $args['use_overlay'] ) {
$data_icon = '' !== $args['hover_icon']
? sprintf(
' data-icon="%1$s"',
esc_attr( et_pb_process_font_icon( $args['hover_icon'] ) )
)
: '';
$overlay_output = sprintf(
'',
( '' !== $args['hover_icon'] ? ' et_pb_inline_icon' : '' ),
$data_icon
);
}
$overlay_class = 'on' === $args['use_overlay'] ? ' et_pb_has_overlay' : '';
$query_args = array(
'posts_per_page' => intval( $args['posts_number'] ),
'post_status' => 'publish',
'order' => $args['order'],
'orderby' => $args['orderby']
);
if ( defined( 'DOING_AJAX' ) && isset( $current_page[ 'paged'] ) ) {
$paged = intval( $current_page[ 'paged' ] );
} else {
$paged = $is_front_page ? get_query_var( 'page' ) : get_query_var( 'paged' );
}
if ( '' !== $args['include_categories'] ) {
$query_args['cat'] = $args['include_categories'];
}
if ( ! $is_search ) {
$query_args['paged'] = $paged;
}
if ( '' !== $args['offset_number'] && ! empty( $args['offset_number'] ) ) {
/**
* Offset + pagination don't play well. Manual offset calculation required
* @see: https://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination
*/
if ( $paged > 1 ) {
$query_args['offset'] = ( ( $paged - 1 ) * intval( $args['posts_number'] ) ) + intval( $args['offset_number'] );
} else {
$query_args['offset'] = intval( $args['offset_number'] );
}
/**
* If no category selected and it is ajax request, the offset starts from zero instead of one. Adjust accordingly.
*/
if ( ! isset( $query_args['cat'] ) && defined( 'DOING_AJAX' ) ) {
$query_args['offset'] = intval( $query_args['offset'] ) + 1;
}
}
if ( $is_single ) {
$query_args['post__not_in'][] = get_the_ID();
}
// Get query
$query = new WP_Query( $query_args );
// Keep page's $wp_query global
$wp_query_page = $wp_query;
// Turn page's $wp_query into this module's query
$wp_query = $query;
ob_start();
if ( $query->have_posts() ) {
while( $query->have_posts() ) {
$query->the_post();
global $et_fb_processing_shortcode_object;
$global_processing_original_value = $et_fb_processing_shortcode_object;
// reset the fb processing flag
$et_fb_processing_shortcode_object = false;
$thumb = '';
$width = 'on' === $args['fullwidth'] ? 1080 : 400;
$width = (int) apply_filters( 'et_pb_blog_image_width', $width );
$height = 'on' === $args['fullwidth'] ? 675 : 250;
$height = (int) apply_filters( 'et_pb_blog_image_height', $height );
$classtext = 'on' === $args['fullwidth'] ? 'et_pb_post_main_image' : '';
$titletext = get_the_title();
$thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
$thumb = $thumbnail["thumb"];
$no_thumb_class = '' === $thumb || 'off' === $args['show_thumbnail'] ? ' et_pb_no_thumb' : '';
$post_format = et_pb_post_format();
if ( in_array( $post_format, array( 'video', 'gallery' ) ) ) {
$no_thumb_class = '';
}
// Print output
?>
>
',
$thumb
) : '';
printf(
'
%1$s
%2$s
',
$video_overlay,
$first_video
);
elseif ( 'gallery' === $post_format ) :
et_pb_gallery_images( 'slider' );
elseif ( '' !== $thumb && 'on' === $args['show_thumbnail'] ) :
if ( 'on' !== $args['fullwidth'] ) echo ''; ?>
';
endif;
}
?>
%1$s %2$s %3$s %4$s %5$s %6$s %7$s',
(
'on' === $args['show_author']
? et_get_safe_localization( sprintf( __( 'by %s', 'et_builder' ), '
' . et_pb_get_the_author_posts_link() . '' ) )
: ''
),
(
( 'on' === $args['show_author'] && 'on' === $args['show_date'] )
? ' | '
: ''
),
(
'on' === $args['show_date']
? et_get_safe_localization( sprintf( __( '%s', 'et_builder' ), '
' . esc_html( get_the_date( $args['meta_date'] ) ) . '' ) )
: ''
),
(
(( 'on' === $args['show_author'] || 'on' === $args['show_date'] ) && 'on' === $args['show_categories'] )
? ' | '
: ''
),
(
'on' === $args['show_categories']
? get_the_category_list(', ')
: ''
),
(
(( 'on' === $args['show_author'] || 'on' === $args['show_date'] || 'on' === $args['show_categories'] ) && 'on' === $args['show_comments'])
? ' | '
: ''
),
(
'on' === $args['show_comments']
? sprintf( esc_html( _nx( '1 Comment', '%s Comments', get_comments_number(), 'number of comments', 'et_builder' ) ), number_format_i18n( get_comments_number() ) )
: ''
)
);
}
$post_content = et_strip_shortcodes( et_delete_post_first_video( get_the_content() ), true );
// reset the fb processing flag
$et_fb_processing_shortcode_object = false;
// set the flag to indicate that we're processing internal content
$et_pb_rendering_column_content = true;
// reset all the attributes required to properly generate the internal styles
ET_Builder_Element::clean_internal_modules_styles();
echo '
';
if ( 'on' === $args['show_content'] ) {
global $more;
// page builder doesn't support more tag, so display the_content() in case of post made with page builder
if ( et_pb_is_pagebuilder_used( get_the_ID() ) ) {
$more = 1;
echo apply_filters( 'the_content', $post_content );
} else {
$more = null;
echo apply_filters( 'the_content', et_delete_post_first_video( get_the_content( esc_html__( 'read more...', 'et_builder' ) ) ) );
}
} else {
if ( has_excerpt() ) {
the_excerpt();
} else {
if ( '' !== $post_content ) {
// set the $et_fb_processing_shortcode_object to false, to retrieve the content inside truncate_post() correctly
$et_fb_processing_shortcode_object = false;
echo wpautop( et_delete_post_first_video( truncate_post( 270, false, '', true ) ) );
// reset the $et_fb_processing_shortcode_object to its original value
$et_fb_processing_shortcode_object = $global_processing_original_value;
} else {
echo '';
}
}
}
$et_fb_processing_shortcode_object = $global_processing_original_value;
// retrieve the styles for the modules inside Blog content
$internal_style = ET_Builder_Element::get_style( true );
// reset all the attributes after we retrieved styles
ET_Builder_Element::clean_internal_modules_styles( false );
$et_pb_rendering_column_content = false;
// append styles to the blog content
if ( $internal_style ) {
printf(
'',
$internal_style
);
}
echo '
';
if ( 'on' !== $args['show_content'] ) {
$more = 'on' == $args['show_more'] ? sprintf( '
%2$s' , esc_url( get_permalink() ), esc_html__( 'read more', 'et_builder' ) ) : '';
echo $more;
}
?>
'; // @todo this causes closing tag issue
$container_is_closed = true;
if ( function_exists( 'wp_pagenavi' ) ) {
wp_pagenavi( array(
'query' => $query
) );
} else {
if ( $et_is_builder_plugin_active ) {
include( ET_BUILDER_PLUGIN_DIR . 'includes/navigation.php' );
} else {
get_template_part( 'includes/navigation', 'index' );
}
}
}
wp_reset_query();
} else {
if ( $et_is_builder_plugin_active ) {
include( ET_BUILDER_PLUGIN_DIR . 'includes/no-results.php' );
} else {
get_template_part( 'includes/no-results', 'index' );
}
}
wp_reset_postdata();
// Reset $wp_query to its origin
$wp_query = $wp_query_page;
$posts = ob_get_contents();
ob_end_clean();
return $posts;
}
function shortcode_callback( $atts, $content = null, $function_name ) {
/**
* Cached $wp_filter so it can be restored at the end of the callback.
* This is needed because this callback uses the_content filter / calls a function
* which uses the_content filter. WordPress doesn't support nested filter
*/
global $wp_filter;
$wp_filter_cache = $wp_filter;
$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'];
$use_masonry = $this->shortcode_atts['use_masonry'];
$columns = $this->shortcode_atts['columns'];
$random_size = $this->shortcode_atts['random_size'];
$ds_field = $this->shortcode_atts['ds_field'];
$include_categories = $this->shortcode_atts['include_categories'];
$meta_date = $this->shortcode_atts['meta_date'];
$show_thumbnail = $this->shortcode_atts['show_thumbnail'];
$show_content = $this->shortcode_atts['show_content'];
$orderby = $this->shortcode_atts['orderby'];
$order = 'on' == $this->shortcode_atts['order'] ? 'DESC' : 'ASC';
$show_author = $this->shortcode_atts['show_author'];
$show_date = $this->shortcode_atts['show_date'];
$show_categories = $this->shortcode_atts['show_categories'];
$show_comments = $this->shortcode_atts['show_comments'];
$show_pagination = $this->shortcode_atts['show_pagination'];
$background_layout = $this->shortcode_atts['background_layout'];
$show_more = $this->shortcode_atts['show_more'];
$offset_number = $this->shortcode_atts['offset_number'];
$masonry_tile_background_color = $this->shortcode_atts['masonry_tile_background_color'];
$use_dropshadow = $this->shortcode_atts['use_dropshadow'];
$overlay_icon_color = $this->shortcode_atts['overlay_icon_color'];
$hover_overlay_color = $this->shortcode_atts['hover_overlay_color'];
$hover_icon = $this->shortcode_atts['hover_icon'];
$use_overlay = $this->shortcode_atts['use_overlay'];
/**
* Masonry setting will override grid layout
*/
if ( 'on' === $use_masonry ) {
$fullwidth = 'on';
}
global $paged;
$module_class = ET_Builder_Element::add_module_order_class( $module_class, $function_name );
$container_is_closed = false;
// remove all filters from WP audio shortcode to make sure current theme doesn't add any elements into audio module
remove_all_filters( 'wp_audio_shortcode_library' );
remove_all_filters( 'wp_audio_shortcode' );
remove_all_filters( 'wp_audio_shortcode_class');
if ( '' !== $masonry_tile_background_color ) {
ET_Builder_Element::set_style( $function_name, array(
'selector' => '%%order_class%%.et_pb_blog_grid .et_pb_post',
'declaration' => sprintf(
'background-color: %1$s;',
esc_html( $masonry_tile_background_color )
),
) );
}
if ( '' !== $overlay_icon_color ) {
ET_Builder_Element::set_style( $function_name, array(
'selector' => '%%order_class%% .et_overlay:before',
'declaration' => sprintf(
'color: %1$s !important;',
esc_html( $overlay_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;',
esc_html( $hover_overlay_color )
),
) );
}
if ( 'on' === $use_overlay ) {
$data_icon = '' !== $hover_icon
? sprintf(
' data-icon="%1$s"',
esc_attr( et_pb_process_font_icon( $hover_icon ) )
)
: '';
$overlay_output = sprintf(
'
',
( '' !== $hover_icon ? ' et_pb_inline_icon' : '' ),
$data_icon
);
}
$overlay_class = 'on' === $use_overlay ? ' et_pb_has_overlay' : '';
if ( 'on' !== $fullwidth ){
if ( 'on' === $use_dropshadow ) {
$module_class .= ' et_pb_blog_grid_dropshadow';
}
wp_enqueue_script( 'salvattore' );
$background_layout = 'light';
}
$args = array( 'posts_per_page' => (int) $posts_number );
$et_paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' );
if ( is_front_page() ) {
$paged = $et_paged;
}
if ( '' !== $include_categories )
$args['cat'] = $include_categories;
if ( ! is_search() ) {
$args['paged'] = $et_paged;
}
if ( '' !== $offset_number && ! empty( $offset_number ) ) {
/**
* Offset + pagination don't play well. Manual offset calculation required
* @see: https://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination
*/
if ( $paged > 1 ) {
$args['offset'] = ( ( $et_paged - 1 ) * intval( $posts_number ) ) + intval( $offset_number );
} else {
$args['offset'] = intval( $offset_number );
}
}
if ( is_single() && ! isset( $args['post__not_in'] ) ) {
$args['post__not_in'] = array( get_the_ID() );
}
$args['order'] = $order;
$args['orderby'] = $orderby;
ob_start();
query_posts( $args );/**
* Masonry injection
*/
$firstColumn = explode( ',', $columns );
$fColVal = intval( trim( $firstColumn[0] ) ) > 0 ? intval( 100 / intval( trim( $firstColumn[0] ) ) ) : 100;
if ( have_posts() ) {
while ( have_posts() ): ?>
0 ? ' acme_grid-item--width2' : null;
}
}
}
}
if ( in_array( $post_format, array( 'video', 'gallery' ) ) ) {
$no_thumb_class = '';
} ?>
>
',
$thumb
) : '';
printf(
'
%1$s
%2$s
',
$video_overlay,
$first_video
);
elseif ( 'gallery' === $post_format ) :
et_pb_gallery_images( 'slider' );
elseif ( '' !== $thumb && 'on' === $show_thumbnail ) :
if ( 'on' !== $fullwidth ) echo ''; ?>
';
endif;
} ?>
%1$s %2$s %3$s %4$s %5$s %6$s %7$s',
(
'on' === $show_author
? et_get_safe_localization( sprintf( __( 'by %s', 'et_builder' ), '
' . et_pb_get_the_author_posts_link() . '' ) )
: ''
),
(
( 'on' === $show_author && 'on' === $show_date )
? ' | '
: ''
),
(
'on' === $show_date
? et_get_safe_localization( sprintf( __( '%s', 'et_builder' ), '
' . esc_html( get_the_date( $meta_date ) ) . '' ) )
: ''
),
(
(( 'on' === $show_author || 'on' === $show_date ) && 'on' === $show_categories)
? ' | '
: ''
),
(
'on' === $show_categories
? get_the_category_list(', ')
: ''
),
(
(( 'on' === $show_author || 'on' === $show_date || 'on' === $show_categories ) && 'on' === $show_comments)
? ' | '
: ''
),
(
'on' === $show_comments
? sprintf( esc_html( _nx( '1 Comment', '%s Comments', get_comments_number(), 'number of comments', 'et_builder' ) ), number_format_i18n( get_comments_number() ) )
: ''
)
);
}
echo '
';
global $et_pb_rendering_column_content;
$post_content = et_strip_shortcodes( et_delete_post_first_video( get_the_content() ), true );
$et_pb_rendering_column_content = true;
if ( 'on' === $show_content ) {
global $more;
// page builder doesn't support more tag, so display the_content() in case of post made with page builder
if ( et_pb_is_pagebuilder_used( get_the_ID() ) ) {
$more = 1;
echo apply_filters( 'the_content', $post_content );
} else {
$more = null;
echo apply_filters( 'the_content', et_delete_post_first_video( get_the_content( esc_html__( 'read more...', 'et_builder' ) ) ) );
}
} else {
if ( has_excerpt() ) {
the_excerpt();
} else {
echo wpautop( et_delete_post_first_video( truncate_post( 270, false, '', true ) ) );
}
}
$et_pb_rendering_column_content = false;
if ( 'on' !== $show_content ) {
$more = 'on' == $show_more ? sprintf( '
%2$s' , esc_url( get_permalink() ), esc_html__( 'read more', 'et_builder' ) ) : '';
echo $more;
}
echo '
';
?>
';
$container_is_closed = true;
if ( function_exists( 'wp_pagenavi' ) ) {
wp_pagenavi();
} else {
if ( et_is_builder_plugin_active() ) {
include( ET_BUILDER_PLUGIN_DIR . 'includes/navigation.php' );
} else {
get_template_part( 'includes/navigation', 'index' );
}
}
}
wp_reset_query();
} else {
if ( et_is_builder_plugin_active() ) {
include( ET_BUILDER_PLUGIN_DIR . 'includes/no-results.php' );
} else {
get_template_part( 'includes/no-results', 'index' );
}
}
$posts = ob_get_contents();
ob_end_clean();
$class = " et_pb_module et_pb_bg_layout_{$background_layout}";
$output = sprintf(
'
%2$s
%4$s',
( 'on' === $fullwidth ? 'et_pb_posts' : 'et_pb_blog_grid clearfix' ),
$posts,
esc_attr( $class ),
( ! $container_is_closed ? '
' : '' ),
( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
( 'on' !== $fullwidth ? ' data-columns' : '' )
);
if ( 'on' !== $fullwidth )
$output = sprintf( '
%1$s
', $output );
if('on'===$use_masonry) {
$output = sprintf( '
',
$output,
'data-acme-columns="' . $columns . '"',
$fColVal . '%'
);
}
// Restore $wp_filter
$wp_filter = $wp_filter_cache;
unset($wp_filter_cache);
return $output;
}
}