return preg_replace( '/\t+/', '', $output );
add_filter( 'the_password_form', 'et_password_form' );
function et_add_wp_version( $classes ) {
$is_admin_body_class = 'admin_body_class' === current_filter();
// add 'et-wp-pre-3_8' class if the current WordPress version is less than 3.8
if ( version_compare( $wp_version, '3.7.2', '<=' ) ) {
if ( 'body_class' === current_filter() ) {
$classes[] = 'et-wp-pre-3_8';
$classes .= ' et-wp-pre-3_8';
} else if ( $is_admin_body_class ) {
$classes .= ' et-wp-after-3_8';
if ( $is_admin_body_class ) {
$classes = ltrim( $classes );
add_filter( 'body_class', 'et_add_wp_version' );
add_filter( 'admin_body_class', 'et_add_wp_version' );
* Determine whether current primary nav uses transparent nav or not based on primary nav background
function et_divi_is_transparent_primary_nav() {
return 'rgba' == substr( et_get_option( 'primary_nav_bg', '#ffffff' ), 0, 4 );
function et_layout_body_class( $classes ) {
$has_tb_header = in_array( 'et-tb-has-header', $classes );
$has_tb_footer = in_array( 'et-tb-has-footer', $classes );
$is_blank_page_tpl = is_page_template( 'page-template-blank.php' );
do_action( 'et_layout_body_class_before', $classes );
if ( 'on' === get_post_meta( get_the_ID(), '_et_pb_side_nav', true ) && et_pb_is_pagebuilder_used( get_the_ID() ) ) {
$classes[] = 'et_pb_side_nav_page';
if ( ! $has_tb_header && ! $is_blank_page_tpl ) {
$vertical_nav = et_get_option( 'vertical_nav', false );
if ( et_divi_is_transparent_primary_nav() && ( false === $vertical_nav || '' === $vertical_nav ) ) {
$classes[] = 'et_transparent_nav';
if ( true === et_get_option( 'nav_fullwidth', false ) ) {
if ( true === et_get_option( 'vertical_nav', false ) ) {
$classes[] = 'et_fullwidth_nav_temp';
$classes[] = 'et_fullwidth_nav';
if ( true === et_get_option( 'secondary_nav_fullwidth', false ) ) {
$classes[] = 'et_fullwidth_secondary_nav';
if ( true === et_get_option( 'vertical_nav', false ) ) {
$classes[] = 'et_vertical_nav';
if ( 'right' === et_get_option( 'vertical_nav_orientation', 'left' ) ) {
$classes[] = 'et_vertical_right';
} else if ( 'on' === et_get_option( 'divi_fixed_nav', 'on' ) ) {
$classes[] = 'et_fixed_nav';
} else if ( 'on' !== et_get_option( 'divi_fixed_nav', 'on' ) ) {
$classes[] = 'et_non_fixed_nav';
if ( true === et_get_option( 'vertical_nav', false ) && 'on' === et_get_option( 'divi_fixed_nav', 'on' ) ) {
$classes[] = 'et_vertical_fixed';
if ( true === et_get_option( 'hide_nav', false ) && ( ! is_singular() || is_singular() && 'no' !== get_post_meta( get_the_ID(), '_et_pb_post_hide_nav', true ) ) ) {
$classes[] = 'et_hide_nav';
$classes[] = 'et_show_nav';
if ( is_singular() && 'on' === get_post_meta( get_the_ID(), '_et_pb_show_title', true ) ) {
$classes[] = 'et_pb_show_title';
if ( true === et_get_option( 'hide_primary_logo', false ) ) {
$classes[] = 'et_hide_primary_logo';
if ( true === et_get_option( 'hide_fixed_logo', false ) ) {
$classes[] = 'et_hide_fixed_logo';
if ( true === et_get_option( 'hide_mobile_logo', false ) ) {
$classes[] = 'et_hide_mobile_logo';
$et_secondary_nav_items = et_divi_get_top_nav_items();
if ( $et_secondary_nav_items->top_info_defined && 'slide' !== et_get_option( 'header_style', 'left' ) && 'fullscreen' !== et_get_option( 'header_style', 'left' ) ) {
$classes[] = 'et_secondary_nav_enabled';
if ( $et_secondary_nav_items->two_info_panels && 'slide' !== et_get_option( 'header_style', 'left' ) && 'fullscreen' !== et_get_option( 'header_style', 'left' ) ) {
$classes[] = 'et_secondary_nav_two_panels';
if ( $et_secondary_nav_items->secondary_nav && ! ( $et_secondary_nav_items->contact_info_defined || $et_secondary_nav_items->show_header_social_icons ) && 'slide' !== et_get_option( 'header_style', 'left' ) && 'fullscreen' !== et_get_option( 'header_style', 'left' ) ) {
$classes[] = 'et_secondary_nav_only_menu';
if ( is_singular() && et_builder_enabled_for_post( get_the_ID() ) && 'on' == get_post_meta( get_the_ID(), '_et_pb_post_hide_nav', true ) ) {
$classes[] = 'et_hide_nav';
$primary_dropdown_animation = et_get_option( 'primary_nav_dropdown_animation', 'fade' );
$classes[] = esc_attr( "et_primary_nav_dropdown_animation_{$primary_dropdown_animation}" );
$secondary_dropdown_animation = et_get_option( 'secondary_nav_dropdown_animation', 'fade' );
$classes[] = esc_attr( "et_secondary_nav_dropdown_animation_{$secondary_dropdown_animation}" );
$header_style = et_get_option( 'header_style', 'left' );
$classes[] = esc_attr( "et_header_style_{$header_style}" );
if ( 'slide' === $header_style || 'fullscreen' === $header_style ) {
$classes[] = esc_attr( "et_header_style_left" );
if ( 'fullscreen' === $header_style && ! et_get_option( 'slide_nav_show_top_bar', true ) ) {
// additional class if top bar disabled in Fullscreen menu
$classes[] = esc_attr( "et_pb_no_top_bar_fullscreen" );
$logo = et_get_option( 'divi_logo', '' );
if ( '.svg' === substr( $logo, -4, 4 ) ) {
$classes[] = 'et_pb_svg_logo';
if ( ! $has_tb_footer && ! $is_blank_page_tpl ) {
$footer_columns = et_get_option( 'footer_columns', '4' );
$classes[] = esc_attr( "et_pb_footer_columns{$footer_columns}" );
// home-posts class is used by customizer > blog to work. It modifies post title and meta
// of WP default layout (home, archive, single), but should not modify post title and meta of blog module (page as home)
if ( in_array( 'home', $classes ) && ! in_array( 'page', $classes ) ) {
$classes[] = 'home-posts';
if ( true === et_get_option( 'boxed_layout', false ) ) {
$classes[] = 'et_boxed_layout';
if ( false !== et_get_option( 'cover_background', true ) ) {
$classes[] = 'et_cover_background';
if ( ! et_get_option( 'use_sidebar_width', false ) ) {
$classes[] = 'et_pb_gutter';
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
if ( stristr( $_SERVER['HTTP_USER_AGENT'], "mac" ) ) {
} elseif ( stristr( $_SERVER['HTTP_USER_AGENT'], "linux" ) ) {
} elseif ( stristr( $_SERVER['HTTP_USER_AGENT'], "windows" ) ) {
$page_custom_gutter = get_post_meta( get_the_ID(), '_et_pb_gutter_width', true );
$gutter_width = ! empty( $page_custom_gutter ) && is_singular() ? $page_custom_gutter : (string) et_get_option( 'gutter_width', '3' );
$classes[] = esc_attr( "et_pb_gutters{$gutter_width}" );
// Add the page builder class.
if ( et_pb_is_pagebuilder_used( get_the_ID() ) && ! ET_GB_Block_Layout::is_layout_block_preview() ) {
$classes[] = 'et_pb_pagebuilder_layout';
// Add smooth scroll class name
if ( 'on' === et_get_option( 'divi_smooth_scroll', false ) ) {
$classes[] = 'et_smooth_scroll';
do_action( 'et_layout_body_class_after', $classes );
add_filter( 'body_class', 'et_layout_body_class' );
if ( ! function_exists( 'et_layout_post_class' ) ):
function et_layout_post_class( $classes ) {
$post_type = get_post_type( $post_id );
$template_name = basename( $template );
if ( 'page' === $post_type ) {
// Don't add the class to pages.
if ( in_array( $template_name, array( 'index.php', 'single.php' ) ) ) {
// The class has already been added by one of the theme's templates.
// Since the theme's templates are not being used, we don't add the class on CPT archive pages.
if ( is_single() && et_pb_is_pagebuilder_used( $post_id ) ) {
$classes[] = 'et_pb_post';
add_filter( 'post_class', 'et_layout_post_class' );
if ( ! function_exists( 'et_show_cart_total' ) ) {
function et_show_cart_total( $args = array() ) {
if ( ! class_exists( 'woocommerce' ) || ! WC()->cart ) {
$args = wp_parse_args( $args, $defaults );
$items_number = WC()->cart->get_cart_contents_count();
$url = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : WC()->cart->get_cart_url();
'<a href="%1$s" class="et-cart-info">
_nx( '%1$s Item', '%1$s Items', $items_number, 'WooCommerce items number', 'Divi' ),
number_format_i18n( $items_number )
if ( ! function_exists( 'et_divi_get_top_nav_items' ) ) {
function et_divi_get_top_nav_items() {
$items->phone_number = trim( et_get_option( 'phone_number' ) );
$items->email = trim( et_get_option( 'header_email' ) );
$items->contact_info_defined = $items->phone_number || $items->email;
$items->show_header_social_icons = et_get_option( 'show_header_social_icons', false );
$items->secondary_nav = wp_nav_menu( array(
'theme_location' => 'secondary-menu',
'menu_id' => 'et-secondary-nav',
$items->top_info_defined = $items->contact_info_defined || $items->show_header_social_icons || $items->secondary_nav;
$items->two_info_panels = $items->contact_info_defined && ( $items->show_header_social_icons || $items->secondary_nav );
function et_divi_activate_features(){
define( 'ET_SHORTCODES_VERSION', et_get_theme_version() );
/* activate shortcodes */
require_once( get_template_directory() . '/epanel/shortcodes/shortcodes.php' );
add_action( 'init', 'et_divi_activate_features' );
require_once( get_template_directory() . '/et-pagebuilder/et-pagebuilder.php' );
require_once get_template_directory() . '/includes/theme-builder.php';
require_once( get_template_directory() . '/includes/block-editor-integration.php' );
* Custom body classes for sidebar location in different places
function et_divi_sidebar_class( $classes ) {
if ( in_array( 'et-tb-has-body', $classes ) ) {
// TB has taken over the body area so there is no sidebar.
$is_product = function_exists( 'is_product' ) && is_product();
$default_sidebar_class = $is_product ? et_get_option( 'et_pb_woocommerce_product_layout' ) : et_get_option( 'divi_sidebar' );
$post_id = get_queried_object_id();
$is_builder_active = 'on' === get_post_meta( $post_id, '_et_pb_use_builder', true ) || et_core_is_fb_enabled();
$is_blank_page_tpl = is_page_template( 'page-template-blank.php' );
if ( ! $default_sidebar_class ) {
$default_sidebar_class = is_rtl() ? 'et_left_sidebar' : 'et_right_sidebar';
// Set Woo shop and taxonomies layout.
if ( class_exists( 'woocommerce' ) && ( is_woocommerce() && ( is_shop() || is_tax() || $is_product ) ) ) {
$saved_page_layout = get_post_meta( $post_id, '_et_pb_page_layout', true );
$page_layout = ! $saved_page_layout || ( 'et_full_width_page' === $saved_page_layout && ! $is_builder_active ) ? $default_sidebar_class : $saved_page_layout;
$page_layout = et_get_option( 'divi_shop_page_sidebar', $default_sidebar_class );
} elseif ( ! is_singular() || ( ! ( $page_layout = get_post_meta( $post_id, '_et_pb_page_layout', true ) ) && ! $is_builder_active ) ) { // check for the falsy value not for boolean `false`
// Set post meta layout which will work for all third party plugins.
$page_layout = $default_sidebar_class;
} elseif ( $is_builder_active && ($is_blank_page_tpl || ! $page_layout || is_page() ) ) {
$page_layout = 'et_no_sidebar';
// Handle et_no_sidebar class. It should be no_sidebar for all custom post types, or any post type if builder active.
// otherwise apply 'et_full_width_page' class for backward compatibility
if ( 'et_no_sidebar' === $page_layout && is_singular() ) {
if ( et_builder_post_is_of_custom_post_type( $post_id ) || $is_builder_active ) {
$classes[] = 'et_no_sidebar';
$classes[] = 'et_full_width_page';
// Add the page layout class.
$classes[] = $page_layout;
// Maybe add the full width portfolio class.
if ( is_singular( 'project' ) && ( in_array( $page_layout, array( 'et_full_width_page', 'et_no_sidebar' ) ) ) ) {
$classes[] = 'et_full_width_portfolio_page';
add_filter( 'body_class', 'et_divi_sidebar_class' );
* Custom body classes for handling customizer preview screen
function et_divi_customize_preview_class( $classes ) {
if ( is_customize_preview() ) {
// Customizer class name for customizer specific stuff
$classes[] = 'et_is_customize_preview';
if ( ! et_get_option( 'show_search_icon', true ) ) {
$classes[] = 'et_hide_search_icon';
add_filter( 'body_class', 'et_divi_customize_preview_class' );
function et_modify_shop_page_columns_num( $columns_num ) {
if ( ! et_is_woocommerce_plugin_active() ) {
// WooCommerce plugin active check ensures that archive function can be used.
$is_archive_page = is_shop() || is_product_category() || is_product_tag();
if ( ! $is_archive_page ) {
$default_sidebar_class = is_rtl() ? 'et_left_sidebar' : 'et_right_sidebar';
$divi_shop_page_sidebar = et_get_option( 'divi_shop_page_sidebar', $default_sidebar_class );
// Assignment is intentional for readability.
$columns_num = 'et_full_width_page' === $divi_shop_page_sidebar ? 4 : 3;
add_filter( 'loop_shop_columns', 'et_modify_shop_page_columns_num' );
if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) {
// Prevent Cache Warning From Being Displayed On First Install
$current_theme_version[ et_get_theme_version() ] = 'ignore' ;
update_option( 'et_pb_cache_notice', $current_theme_version );
add_action( 'init', 'et_divi_woocommerce_image_dimensions', 1 );
* Default values for WooCommerce images changed in version 1.3
* Checks if WooCommerce image dimensions have been updated already.
function et_divi_check_woocommerce_images() {
if ( 'checked' === et_get_option( 'divi_1_3_images' ) ) return;
et_divi_woocommerce_image_dimensions();
et_update_option( 'divi_1_3_images', 'checked' );
add_action( 'admin_init', 'et_divi_check_woocommerce_images' );
function et_divi_woocommerce_image_dimensions() {
update_option( 'shop_catalog_image_size', $catalog );
update_option( 'shop_single_image_size', $single );
update_option( 'shop_thumbnail_image_size', $thumbnail );
if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ):
function woocommerce_template_loop_product_thumbnail() {
printf( '<span class="et_shop_image">%1$s<span class="et_overlay"></span></span>',
woocommerce_get_product_thumbnail()
function et_divi_output_product_wrapper() {
echo '<div class="clearfix">';
function et_divi_output_product_wrapper_end() {
echo '</div><!-- #end wrapper -->';
function et_review_gravatar_size( $size ) {
add_filter( 'woocommerce_review_gravatar_size', 'et_review_gravatar_size' );
function et_divi_output_content_wrapper() {
<div id="content-area" class="clearfix">
function et_divi_output_content_wrapper_end() {
$default_sidebar_class = is_rtl() ? 'et_left_sidebar' : 'et_right_sidebar';
$fullwidth_post = is_singular() && 'et_full_width_page' === get_post_meta( get_the_ID(), '_et_pb_page_layout', true );
echo '</div> <!-- #left-area -->';
if ( function_exists( 'woocommerce_get_sidebar' ) ) {
$woo_fullwidth_page = ( is_shop() || is_product_category() || is_product_tag() || is_tax() ) && 'et_full_width_page' === et_get_option( 'divi_shop_page_sidebar', $default_sidebar_class );
if ( ! $fullwidth_post && ! $woo_fullwidth_page ) {
woocommerce_get_sidebar();
} else if ( ! $fullwidth_post ) {
</div> <!-- #content-area -->
</div> <!-- .container -->
</div> <!-- #main-content -->';