name = esc_html__( 'Blog', 'et_builder' ); $this->plural = esc_html__( 'Blogs', 'et_builder' ); $this->slug = 'et_pb_blog'; $this->vb_support = 'on'; $this->main_css_element = '%%order_class%% .et_pb_post'; $this->settings_modal_toggles = array( 'general' => array( 'toggles' => array( 'main_content' => esc_html__( 'Content', 'et_builder' ), 'elements' => esc_html__( 'Elements', 'et_builder' ), ), ), 'advanced' => array( 'toggles' => array( 'layout' => esc_html__( 'Layout', 'et_builder' ), 'overlay' => esc_html__( 'Overlay', 'et_builder' ), 'image' => array( 'title' => esc_html__( 'Image', 'et_builder' ), 'priority' => 51, ), 'text' => array( 'title' => esc_html__( 'Text', 'et_builder' ), 'priority' => 49, ), ), ), ); $this->advanced_fields = array( 'fonts' => array( 'header' => array( 'label' => esc_html__( 'Title', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} .entry-title", 'font' => "{$this->main_css_element} .entry-title a", 'color' => "{$this->main_css_element} .entry-title a", 'plugin_main' => "{$this->main_css_element} .entry-title, {$this->main_css_element} .entry-title a", 'important' => 'all', ), 'header_level' => array( 'default' => 'h2', 'computed_affects' => array( '__posts', ), ), ), 'body' => array( 'label' => esc_html__( 'Body', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} .post-content, %%order_class%%.et_pb_bg_layout_light .et_pb_post .post-content p, %%order_class%%.et_pb_bg_layout_dark .et_pb_post .post-content p", 'color' => "{$this->main_css_element}, {$this->main_css_element} .post-content *", 'line_height' => "{$this->main_css_element} p", 'plugin_main' => "{$this->main_css_element}, %%order_class%%.et_pb_bg_layout_light .et_pb_post .post-content p, %%order_class%%.et_pb_bg_layout_dark .et_pb_post .post-content p, %%order_class%%.et_pb_bg_layout_light .et_pb_post a.more-link, %%order_class%%.et_pb_bg_layout_dark .et_pb_post a.more-link", ), ), 'meta' => array( 'label' => esc_html__( 'Meta', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} .post-meta, {$this->main_css_element} .post-meta a", 'plugin_main' => "{$this->main_css_element} .post-meta, {$this->main_css_element} .post-meta a, {$this->main_css_element} .post-meta span", ), ), 'pagination' => array( 'label' => esc_html__( 'Pagination', 'et_builder' ), 'css' => array( 'main' => function_exists( 'wp_pagenavi' ) ? '%%order_class%% .wp-pagenavi a, %%order_class%% .wp-pagenavi span' : '%%order_class%% .pagination a', 'important' => function_exists( 'wp_pagenavi' ) ? 'all' : array(), 'text_align' => '%%order_class%% .wp-pagenavi', ), 'hide_text_align' => ! function_exists( 'wp_pagenavi' ), 'text_align' => array( 'options' => et_builder_get_text_orientation_options( array( 'justified' ), array() ), ), ), ), 'background' => array( 'css' => array( 'main' => '%%order_class%%', ), ), 'borders' => array( 'default' => array( 'css' => array( 'main' => array( 'border_radii' => "%%order_class%% .et_pb_blog_grid .et_pb_post", 'border_styles' => "%%order_class%% .et_pb_blog_grid .et_pb_post", 'border_styles_hover' => "%%order_class%% .et_pb_blog_grid .et_pb_post:hover", ), ), 'depends_on' => array( 'fullwidth' ), 'depends_show_if' => 'off', 'defaults' => array( 'border_radii' => 'on||||', 'border_styles' => array( 'width' => '1px', 'color' => '#d8d8d8', 'style' => 'solid', ), ), ), 'fullwidth' => array( 'css' => array( 'main' => array( 'border_radii' => "%%order_class%%:not(.et_pb_blog_grid) .et_pb_post", 'border_styles' => "%%order_class%%:not(.et_pb_blog_grid) .et_pb_post", ), ), 'depends_on' => array( 'fullwidth' ), 'depends_show_if' => 'on', 'defaults' => array( 'border_radii' => 'on||||', 'border_styles' => array( 'width' => '0px', 'color' => '#333333', 'style' => 'solid', ), ), ), ), 'margin_padding' => array( 'css' => array( 'main' => '%%order_class%%', 'important' => array( 'custom_margin' ) ), ), 'text' => array( 'use_background_layout' => true, 'css' => array( 'text_shadow' => '%%order_class%%', ), 'options' => array( 'background_layout' => array( 'depends_show_if' => 'on', 'default_on_front' => 'light', 'hover' => 'tabs', ), ), ), 'filters' => array( 'css' => array( 'main' => '%%order_class%%', ), 'child_filters_target' => array( 'tab_slug' => 'advanced', 'toggle_slug' => 'image', ), ), 'image' => array( 'css' => array( 'main' => implode(', ', array( '%%order_class%% img', '%%order_class%% .et_pb_slides', '%%order_class%% .et_pb_video_overlay', )), ), ), 'button' => false, ); $this->custom_css_fields = array( 'title' => array( 'label' => esc_html__( 'Title', 'et_builder' ), 'selector' => '.entry-title', ), 'content' => array( 'label' => esc_html__( 'Content', 'et_builder' ), 'selector' => '.post-content', ), 'post_meta' => array( 'label' => esc_html__( 'Post Meta', 'et_builder' ), 'selector' => '.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' => '.more-link', ), ); $this->help_videos = array( array( 'id' => esc_html( 'PRaWaGI75wc' ), 'name' => esc_html__( 'An introduction to the Blog module', 'et_builder' ), ), array( 'id' => esc_html( 'jETCzKVv6P0' ), 'name' => esc_html__( 'How To Use Divi Blog Post Formats', 'et_builder' ), ), ); } 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', 'masonry_tile_background_color', 'border_radii_fullwidth', 'border_styles_fullwidth', 'border_radii', 'border_styles', ), 'description' => esc_html__( 'Toggle between the various blog layout types.', 'et_builder' ), 'computed_affects' => array( '__posts', ), 'tab_slug' => 'advanced', 'toggle_slug' => 'layout', 'default_on_front' => 'on', ), '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', ), 'toggle_slug' => 'main_content', 'default' => 10, ), 'include_categories' => array( 'label' => esc_html__( 'Include Categories', 'et_builder' ), 'type' => 'categories', 'meta_categories' => array( 'all' => esc_html__( 'All Categories', 'et_builder' ), 'current' => esc_html__( 'Current Category', 'et_builder' ), ), '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' ), 'toggle_slug' => 'main_content', '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' ), 'toggle_slug' => 'main_content', 'computed_affects' => array( '__posts', ), 'default' => 'M j, Y', ), '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', ), 'toggle_slug' => 'elements', 'default_on_front' => 'on', ), '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' ), 'toggle_slug' => 'main_content', 'computed_affects' => array( '__posts', ), 'default_on_front' => 'off', ), 'show_more' => array( 'label' => esc_html__( 'Show Read More Button', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'configuration', 'options' => array( 'off' => esc_html__( 'No', 'et_builder' ), 'on' => esc_html__( 'Yes', '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', ), 'toggle_slug' => 'elements', 'default_on_front' => 'off', ), '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', ), 'toggle_slug' => 'elements', 'default_on_front' => 'on', ), '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', ), 'toggle_slug' => 'elements', 'default_on_front' => 'on', ), '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', ), 'toggle_slug' => 'elements', 'default_on_front' => 'on', ), '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', ), 'toggle_slug' => 'elements', 'default_on_front' => 'off', ), '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', ), 'toggle_slug' => 'elements', 'default_on_front' => 'on', ), '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' ), 'toggle_slug' => 'main_content', 'computed_affects' => array( '__posts', ), 'default' => 0, ), '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', ), 'tab_slug' => 'advanced', 'toggle_slug' => 'overlay', 'default_on_front' => 'off', ), 'overlay_icon_color' => array( 'label' => esc_html__( 'Overlay Icon Color', 'et_builder' ), 'type' => 'color-alpha', 'custom_color' => true, 'depends_show_if' => 'on', 'tab_slug' => 'advanced', 'toggle_slug' => 'overlay', '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', 'tab_slug' => 'advanced', 'toggle_slug' => 'overlay', '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' => 'select_icon', 'option_category' => 'configuration', 'class' => array( 'et-pb-font-icon' ), 'depends_show_if' => 'on', 'description' => esc_html__( 'Here you can define a custom icon for the overlay', 'et_builder' ), 'tab_slug' => 'advanced', 'toggle_slug' => 'overlay', 'computed_affects' => array( '__posts', ), ), 'masonry_tile_background_color' => array( 'label' => esc_html__( 'Grid Tile Background Color', 'et_builder' ), 'type' => 'color-alpha', 'custom_color' => true, 'toggle_slug' => 'background', 'depends_show_if' => 'off', 'depends_on' => array( 'fullwidth', ), 'hover' => 'tabs', ), '__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', 'show_author', 'show_date', 'show_categories', 'show_comments', 'show_pagination', 'offset_number', 'use_overlay', 'hover_icon', 'header_level', '__page', ), 'computed_minimum' => array( 'posts_number', ), ), '__page' => array( 'type' => 'computed', 'computed_callback' => array( 'ET_Builder_Module_Blog', 'get_blog_posts' ), 'computed_affects' => array( '__posts', ), ), ); return $fields; } public function get_transition_fields_css_props() { $fields = parent::get_transition_fields_css_props(); $fields['background_layout'] = array( 'color' => implode( ', ', array( '%%order_class%% .entry-title', '%%order_class%% .post-meta', '%%order_class%% .post-content' ) ) ); $fields['border_radii'] = array( 'border-radius' => self::$_->array_get( $this->advanced_fields, 'borders.default.css.main.border_radii' ) ); $fields['border_styles'] = array( 'border' => self::$_->array_get( $this->advanced_fields, 'borders.default.css.main.border_styles' ) ); $fields['border_radii_fullwidth'] = array( 'border-radius' => self::$_->array_get( $this->advanced_fields, 'borders.fullwidth.css.main.border_radii' ) ); $fields['border_styles_fullwidth'] = array( 'border' => self::$_->array_get( $this->advanced_fields, 'borders.fullwidth.css.main.border_styles' ) ); $fields['max_width'] = array( 'max-width' => '%%order_class%%'); 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' => '', 'show_date' => '', 'show_categories' => '', 'show_comments' => '', 'show_pagination' => '', 'background_layout' => '', 'show_more' => '', 'offset_number' => '', 'masonry_tile_background_color' => '', 'overlay_icon_color' => '', 'hover_overlay_color' => '', 'hover_icon' => '', 'use_overlay' => '', 'header_level' => 'h2', ); // 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 ); $post_id = isset( $current_page['id'] ) ? (int) $current_page['id'] : 0; $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 ); $processed_header_level = et_pb_process_header_level( $args['header_level'], 'h2' ); $processed_header_level = esc_html( $processed_header_level ); $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', ); if ( defined( 'DOING_AJAX' ) && isset( $current_page['paged'] ) ) { $paged = intval( $current_page['paged'] ); //phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited } else { $paged = $is_front_page ? get_query_var( 'page' ) : get_query_var( 'paged' ); //phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited } // support pagination in VB if ( isset( $args['__page'] ) ) { $paged = $args['__page']; //phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited } if ( '' !== $args['include_categories'] ) { $query_args['cat'] = implode( ',', self::filter_meta_categories( $args['include_categories'], $post_id ) ); } 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 ( $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; //phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited ob_start(); if ( $query->have_posts() ) { if ( 'on' !== $args['fullwidth'] ) { echo '