: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$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 -->';
function et_add_divi_menu() {
$core_page = add_menu_page( 'Divi', 'Divi', 'edit_theme_options', 'et_divi_options', 'et_build_epanel' );
// Add Theme Options menu only if it's enabled for current user
if ( et_pb_is_allowed( 'theme_options' ) ) {
if ( isset( $_GET['page'] ) && 'et_divi_options' === $_GET['page'] && isset( $_POST['action'] ) ) {
( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'epanel_nonce' ) )
( 'reset' === $_POST['action'] && isset( $_POST['_wpnonce_reset'] ) && wp_verify_nonce( $_POST['_wpnonce_reset'], 'et-nojs-reset_epanel' ) )
epanel_save_data( 'js_disabled' ); //saves data when javascript is disabled
add_submenu_page( 'et_divi_options', esc_html__( 'Theme Options', 'Divi' ), esc_html__( 'Theme Options', 'Divi' ), 'manage_options', 'et_divi_options' );
et_theme_builder_add_admin_page( 'et_divi_options' );
// Add Theme Customizer menu only if it's enabled for current user
if ( et_pb_is_allowed( 'theme_customizer' ) ) {
add_submenu_page( 'et_divi_options', esc_html__( 'Theme Customizer', 'Divi' ), esc_html__( 'Theme Customizer', 'Divi' ), 'manage_options', 'customize.php?et_customizer_option_set=theme' );
add_submenu_page( 'et_divi_options', esc_html__( 'Role Editor', 'Divi' ), esc_html__( 'Role Editor', 'Divi' ), 'manage_options', 'et_divi_role_editor', 'et_pb_display_role_editor' );
// Add Divi Library menu only if it's enabled for current user
if ( et_pb_is_allowed( 'divi_library' ) ) {
add_submenu_page( 'et_divi_options', esc_html__( 'Divi Library', 'Divi' ), esc_html__( 'Divi Library', 'Divi' ), 'manage_options', 'edit.php?post_type=et_pb_layout' );
add_action( "load-{$core_page}", 'et_pb_check_options_access' ); // load function to check the permissions of current user
add_action( "load-{$core_page}", 'et_epanel_hook_scripts' );
add_action( "admin_print_scripts-{$core_page}", 'et_epanel_admin_js' );
add_action( "admin_head-{$core_page}", 'et_epanel_css_admin');
add_action( "admin_print_scripts-{$core_page}", 'et_epanel_media_upload_scripts');
add_action( "admin_head-{$core_page}", 'et_epanel_media_upload_styles');
add_action('admin_menu', 'et_add_divi_menu');
function add_divi_customizer_admin_menu() {
if ( ! current_user_can( 'customize' ) ) {
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() );
// add Theme Customizer admin menu only if it's enabled for current user
if ( et_pb_is_allowed( 'theme_customizer' ) ) {
$wp_admin_bar->add_menu( array(
'parent' => 'appearance',
'id' => 'customize-divi-theme',
'title' => esc_html__( 'Theme Customizer', 'Divi' ),
'href' => $customize_url . '&et_customizer_option_set=theme',
'class' => 'hide-if-no-customize',
$wp_admin_bar->remove_menu( 'customize' );
add_action( 'admin_bar_menu', 'add_divi_customizer_admin_menu', 999 );
function et_pb_hide_options_menu() {
// do nothing if theme options should be displayed in the menu
if ( et_pb_is_allowed( 'theme_options' ) ) {
$theme_version = et_get_theme_version();
wp_enqueue_script( 'divi-custom-admin-menu', get_template_directory_uri() . '/js/menu_fix.js', array( 'jquery' ), $theme_version, true );
add_action( 'admin_enqueue_scripts', 'et_pb_hide_options_menu' );
function et_pb_check_options_access() {
// display wp error screen if theme customizer disabled for current user
if ( ! et_pb_is_allowed( 'theme_options' ) ) {
wp_die( esc_html__( "you don't have sufficient permissions to access this page", 'Divi' ) );
function et_add_divi_support_center() {
$support_center = new ET_Core_SupportCenter( 'divi_theme' );
add_action( 'init', 'et_add_divi_support_center' );
* Allowing blog and portfolio module pagination to work in non-hierarchical singular page.
* Normally, WP_Query based modules wouldn't work in non-hierarchical single post type page
* due to canonical redirect to prevent page duplication which could lead to SEO penalty.
* @see redirect_canonical()
* @return mixed string|bool
function et_modify_canonical_redirect( $redirect_url, $requested_url ) {
$allowed_shortcodes = array( 'et_pb_blog', 'et_pb_portfolio' );
$is_overwrite_canonical_redirect = false;
// Look for $allowed_shortcodes in content. Once detected, set $is_overwrite_canonical_redirect to true
foreach ( $allowed_shortcodes as $shortcode ) {
if ( !empty( $post ) && has_shortcode( $post->post_content, $shortcode ) ) {
$is_overwrite_canonical_redirect = true;
// Only alter canonical redirect in 2 cases:
// 1) If current page is singular, has paged and $allowed_shortcodes
// 2) If current page is front_page, has page and $allowed_shortcodes
if ( ( is_singular() & ! is_home() && get_query_var( 'paged' ) && $is_overwrite_canonical_redirect ) || ( is_front_page() && get_query_var( 'page' ) && $is_overwrite_canonical_redirect ) ) {
add_filter( 'redirect_canonical', 'et_modify_canonical_redirect', 10, 2 );
* Determines how many related products should be displayed on single product page
* @param array related products arguments
* @return array modified related products arguments
function et_divi_woocommerce_output_related_products_args( $args ) {
$related_posts = 4; // default number
if ( is_singular( 'product' ) ) {
$page_layout = get_post_meta( get_the_ID(), '_et_pb_page_layout', true );
if ( 'et_full_width_page' !== $page_layout ) {
$related_posts = 3; // set to 3 if page has sidebar
// Modify related and up-sell products args
$args['posts_per_page'] = $related_posts;
$args['columns'] = $related_posts;
add_filter( 'woocommerce_upsell_display_args', 'et_divi_woocommerce_output_related_products_args' );
add_filter( 'woocommerce_output_related_products_args', 'et_divi_woocommerce_output_related_products_args' );
function et_divi_maybe_change_frontend_locale( $locale ) {
$option_name = 'divi_disable_translations';
$theme_options = get_option( 'et_divi' );
$disable_translations = isset ( $theme_options[ $option_name ] ) ? $theme_options[ $option_name ] : false;
if ( 'on' === $disable_translations ) {
add_filter( 'locale', 'et_divi_maybe_change_frontend_locale' );
* Enable Divi gallery override if user activates it
function et_divi_gallery_layout_enable( $option ) {
$setting = et_get_option( 'divi_gallery_layout_enable' );
return ( 'on' === $setting ) ? true : $option;
add_filter( 'et_gallery_layout_enable', 'et_divi_gallery_layout_enable' );
* Enable GB gallery to shortcode conversion
function et_divi_gb_gallery_to_shortcode() {
return et_divi_gallery_layout_enable( false );
add_filter( 'et_gb_gallery_to_shortcode', 'et_divi_gb_gallery_to_shortcode' );
* Register theme and modules Customizer portability.
function et_divi_register_customizer_portability() {
// Make sure the Portability is loaded.
et_core_load_component( 'portability' );
// Exclude ePanel options.
foreach ( $options as $option ) {
if ( isset( $option['id'] ) ) {
$exclude[ $option['id'] ] = true;
// Register the portability.
et_core_portability_register( 'et_divi_mods', array(
'name' => esc_html__( 'Divi Customizer Settings', 'Divi' ),
'view' => is_customize_preview(),
add_action( 'admin_init', 'et_divi_register_customizer_portability' );
function et_register_updates_component() {
et_core_enable_automatic_updates( get_template_directory_uri(), ET_CORE_VERSION );
add_action( 'admin_init', 'et_register_updates_component', 9 );
* Register theme and modules Customizer portability link.
* @return bool Always return true.
function et_divi_customizer_link() {
if ( is_customize_preview() ) {
echo et_builder_portability_link( 'et_divi_mods', array( 'class' => 'et-core-customize-controls-close' ) );
add_action( 'customize_controls_print_footer_scripts', 'et_divi_customizer_link' );
* Added body class to make it possible to identify the Divi theme on frontend
function et_divi_theme_body_class( $classes ) {
$classes[] = 'et_divi_theme';
add_filter( 'body_class', 'et_divi_theme_body_class' );
* Determine if it's a fresh Divi install by checking for the existence of 'divi_logo' key in 'et_divi' options array.
if ( ! function_exists( 'et_divi_is_fresh_install' ) ):
function et_divi_is_fresh_install() {
return false === et_get_option( 'divi_logo' );
if ( ! function_exists( 'et_get_original_footer_credits' ) ) :
function et_get_original_footer_credits() {
return sprintf( __( 'Designed by %1$s | Powered by %2$s', 'Divi' ), '<a href="http://www.elegantthemes.com" title="Premium WordPress Themes">Elegant Themes</a>', '<a href="http://www.wordpress.org">WordPress</a>' );
if ( ! function_exists( 'et_get_footer_credits' ) ) :
function et_get_footer_credits() {
$original_footer_credits = et_get_original_footer_credits();
$disable_custom_credits = et_get_option( 'disable_custom_footer_credits', false );
if ( $disable_custom_credits ) {
$credits_format = '<%2$s id="footer-info">%1$s</%2$s>';
$footer_credits = et_get_option( 'custom_footer_credits', '' );
if ( '' === trim( $footer_credits ) ) {
return et_get_safe_localization( sprintf( $credits_format, $original_footer_credits, 'p' ) );
return et_get_safe_localization( sprintf( $credits_format, $footer_credits, 'div' ) );
if ( ! function_exists( 'et_divi_filter_et_core_is_builder_used_on_current_request' ) ):
function et_divi_filter_et_core_is_builder_used_on_current_request( $is_builder_used ) {
if ( $is_builder_used && ! is_singular() ) {
$is_builder_used = 'on' === et_get_option( 'divi_blog_style', 'false' );
add_filter( 'et_core_is_builder_used_on_current_request', 'et_divi_filter_et_core_is_builder_used_on_current_request' );
if ( ! function_exists( 'et_divi_version_rollback' ) ) :
function et_divi_version_rollback() {
global $themename, $shortname;
if ( null === $instance ) {
$instance = new ET_Core_VersionRollback( $themename, $shortname, et_get_theme_version() );