if ( ! isset( $content_width ) ) $content_width = 1080;
function et_setup_theme() {
global $themename, $shortname, $et_store_options_in_one_row, $default_colorscheme;
$et_store_options_in_one_row = true;
$default_colorscheme = "Default";
$template_directory = get_template_directory();
require_once( $template_directory . '/core/init.php' );
et_core_setup( get_template_directory_uri() );
if ( '3.0.61' === ET_CORE_VERSION ) {
require_once $template_directory . '/core/functions.php';
require_once $template_directory . '/core/components/init.php';
et_core_patch_core_3061();
require_once( $template_directory . '/epanel/custom_functions.php' );
require_once( $template_directory . '/includes/functions/choices.php' );
require_once( $template_directory . '/includes/functions/sanitization.php' );
require_once( $template_directory . '/includes/functions/sidebars.php' );
load_theme_textdomain( 'Divi', $template_directory . '/lang' );
require_once( $template_directory . '/epanel/core_functions.php' );
require_once( $template_directory . '/post_thumbnails_divi.php' );
include_once( $template_directory . '/includes/widgets.php' );
register_nav_menus( array(
'primary-menu' => esc_html__( 'Primary Menu', 'Divi' ),
'secondary-menu' => esc_html__( 'Secondary Menu', 'Divi' ),
'footer-menu' => esc_html__( 'Footer Menu', 'Divi' ),
// don't display the empty title bar if the widget title is not set
remove_filter( 'widget_title', 'et_widget_force_title' );
remove_filter( 'body_class', 'et_add_fullwidth_body_class' );
add_action( 'wp_enqueue_scripts', 'et_add_responsive_shortcodes_css', 11 );
// Declare theme supports
add_theme_support( 'title-tag' );
add_theme_support( 'post-formats', array(
'video', 'audio', 'quote', 'gallery', 'link'
add_theme_support( 'woocommerce' );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'customize-selective-refresh-widgets' );
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
add_action( 'woocommerce_before_main_content', 'et_divi_output_content_wrapper', 10 );
add_action( 'eventon_before_main_content', 'et_divi_output_content_wrapper', 11 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
add_action( 'woocommerce_after_main_content', 'et_divi_output_content_wrapper_end', 10 );
add_action( 'eventon_after_main_content', 'et_divi_output_content_wrapper_end', 9 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
// add wrapper so we can clear things
add_action( 'woocommerce_before_single_product_summary', 'et_divi_output_product_wrapper', 0 );
add_action( 'woocommerce_after_single_product_summary', 'et_divi_output_product_wrapper_end', 0 );
// deactivate page templates and custom import functions
remove_action( 'init', 'et_activate_features' );
remove_action('admin_menu', 'et_add_epanel');
add_editor_style( 'css/editor-style.css' );
add_editor_style( 'css/editor-blocks.css' );
// Load unminified scripts based on selected theme options field
add_filter( 'et_load_unminified_scripts', 'et_divi_load_unminified_scripts' );
// Load unminified styles based on selected theme options field
add_filter( 'et_load_unminified_styles', 'et_divi_load_unminified_styles' );
et_divi_version_rollback()->enable();
et_register_updates_component();
add_action( 'after_setup_theme', 'et_setup_theme' );
function et_divi_load_unminified_scripts( $load ) {
/** @see ET_Core_SupportCenter::toggle_safe_mode */
if ( et_core_is_safe_mode_active() ) {
if ( 'false' === et_get_option( 'divi_minify_combine_scripts' ) ) {
function et_divi_load_unminified_styles( $load ) {
/** @see ET_Core_SupportCenter::toggle_safe_mode */
if ( et_core_is_safe_mode_active() ) {
if ( 'false' === et_get_option( 'divi_minify_combine_styles' ) ) {
function et_theme_epanel_reminder(){
global $shortname, $themename;
$documentation_url = 'http://www.elegantthemes.com/gallery/divi/readme.html';
$documentation_option_name = $shortname . '_2_4_documentation_message';
if ( false === et_get_option( $shortname . '_logo' ) && false === et_get_option( $documentation_option_name ) ) {
et_get_safe_localization( __( 'Welcome to Divi! Before diving in to your new theme, please visit the <a style="color: #fff; font-weight: bold;" href="%1$s" target="_blank">Divi Documentation</a> page for access to dozens of in-depth tutorials.', $themename ) ),
esc_url( $documentation_url )
'<div class="notice is-dismissible" style="background-color: #6C2EB9; color: #fff; border-left: none;">
et_update_option( $documentation_option_name, 'triggered' );
add_action( 'admin_notices', 'et_theme_epanel_reminder' );
if ( ! function_exists( 'et_divi_fonts_url' ) ) :
function et_divi_fonts_url() {
if ( ! et_core_use_google_fonts() ) {
/* Translators: If there are characters in your language that are not
* supported by Open Sans, translate this to 'off'. Do not translate
* into your own language.
$open_sans = _x( 'on', 'Open Sans font: on or off', 'Divi' );
if ( 'off' !== $open_sans ) {
$font_families = array();
if ( 'off' !== $open_sans )
$font_families[] = 'Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800';
$protocol = is_ssl() ? 'https' : 'http';
'family' => implode( '%7C', $font_families ),
'subset' => 'latin,latin-ext',
$fonts_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" );
function et_divi_load_fonts() {
$fonts_url = et_divi_fonts_url();
// Get user selected font defined on customizer
$et_gf_body_font = sanitize_text_field( et_get_option( 'body_font', 'none' ) );
$is_et_fb_enabled = function_exists( 'et_fb_enabled' ) && et_fb_enabled();
// Determine whether current page needs Open Sans or not
$no_open_sans = ! is_customize_preview() && 'none' !== $et_gf_body_font && '' !== $et_gf_body_font && ! $is_et_fb_enabled;
if ( ! empty( $fonts_url ) && ! $no_open_sans ) {
wp_enqueue_style( 'divi-fonts', esc_url_raw( $fonts_url ), array(), null );
add_action( 'wp_enqueue_scripts', 'et_divi_load_fonts' );
function et_add_home_link( $args ) {
// add Home link to the custom menu WP-Admin page
$args['show_home'] = true;
add_filter( 'wp_page_menu_args', 'et_add_home_link' );
function et_divi_load_scripts_styles(){
global $wp_styles, $et_user_fonts_queue;
$script_suffix = et_load_unminified_scripts() ? '' : '.unified';
$style_suffix = et_load_unminified_styles() && ! is_child_theme() ? '.dev' : '';
$template_dir = get_template_directory_uri();
$theme_version = et_get_theme_version();
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
if ( is_singular() && has_post_format( 'audio' ) ) {
wp_enqueue_style( 'wp-mediaelement' );
wp_enqueue_script( 'wp-mediaelement' );
$dependencies_array = array( 'jquery' );
// load 'jquery-effects-core' if SlideIn/Fullscreen header used or if customizer opened
if ( is_customize_preview() || 'slide' === et_get_option( 'header_style', 'left' ) || 'fullscreen' === et_get_option( 'header_style', 'left' ) ) {
$dependencies_array[] = 'jquery-effects-core';
wp_enqueue_script( 'et-jquery-touch-mobile', $template_dir . '/includes/builder/scripts/ext/jquery.mobile.custom.min.js', array( 'jquery' ), $theme_version, true );
if ( et_load_unminified_scripts() ) {
$dependencies_array[] = 'et-jquery-touch-mobile';
wp_enqueue_script( 'divi-custom-script', $template_dir . '/js/custom' . $script_suffix . '.js', $dependencies_array , $theme_version, true );
'item_count' => esc_html__( '%d Item', 'divi' ),
'items_count' => esc_html__( '%d Items', 'divi' ),
if ( et_core_is_fb_enabled() ) {
$divi_data['row_selector'] = et_divi_get_row_advanced_options_selector_replacement();
wp_localize_script( 'divi-custom-script', 'DIVI', $divi_data );
if ( 'on' === et_get_option( 'divi_smooth_scroll', false ) ) {
wp_enqueue_script( 'smooth-scroll', $template_dir . '/js/smoothscroll.js', array( 'jquery' ), $theme_version, true );
$et_gf_enqueue_fonts = array();
$et_gf_heading_font = sanitize_text_field( et_pb_get_specific_default_font( et_get_option( 'heading_font', 'none' ) ) );
$et_gf_body_font = sanitize_text_field( et_pb_get_specific_default_font( et_get_option( 'body_font', 'none' ) ) );
$et_gf_button_font = sanitize_text_field( et_pb_get_specific_default_font( et_get_option( 'all_buttons_font', 'none' ) ) );
$et_gf_primary_nav_font = sanitize_text_field( et_pb_get_specific_default_font( et_get_option( 'primary_nav_font', 'none' ) ) );
$et_gf_secondary_nav_font = sanitize_text_field( et_pb_get_specific_default_font( et_get_option( 'secondary_nav_font', 'none' ) ) );
$et_gf_slide_nav_font = sanitize_text_field( et_pb_get_specific_default_font( et_get_option( 'slide_nav_font', 'none' ) ) );
if ( 'none' != $et_gf_heading_font ) $et_gf_enqueue_fonts[] = $et_gf_heading_font;
if ( 'none' != $et_gf_body_font ) $et_gf_enqueue_fonts[] = $et_gf_body_font;
if ( 'none' != $et_gf_button_font ) $et_gf_enqueue_fonts[] = $et_gf_button_font;
if ( 'none' != $et_gf_primary_nav_font ) $et_gf_enqueue_fonts[] = $et_gf_primary_nav_font;
if ( 'none' != $et_gf_secondary_nav_font ) $et_gf_enqueue_fonts[] = $et_gf_secondary_nav_font;
if ( 'none' != $et_gf_slide_nav_font ) $et_gf_enqueue_fonts[] = $et_gf_slide_nav_font;
if ( ! empty( $et_gf_enqueue_fonts ) && function_exists( 'et_builder_enqueue_font' ) ) {
$site_domain = get_locale();
$et_old_one_font_languages = et_get_old_one_font_languages();
foreach ( $et_gf_enqueue_fonts as $single_font ) {
if ( isset( $et_old_one_font_languages[$site_domain] ) ) {
$font_custom_default_data = $et_old_one_font_languages[$site_domain];
// enqueue custom default font if needed
if ( $single_font === $font_custom_default_data['font_family'] ) {
$et_gf_font_name_slug = strtolower( str_replace( ' ', '-', $font_custom_default_data['language_name'] ) );
wp_enqueue_style( 'et-gf-' . $et_gf_font_name_slug, $font_custom_default_data['google_font_url'], array(), null );
et_builder_enqueue_font( $single_font );
if ( function_exists( 'et_builder_enqueue_user_fonts' ) && ! empty( $et_user_fonts_queue ) ) {
printf( '<style id="et-divi-userfonts">%1$s</style>', et_core_esc_previously( et_builder_enqueue_user_fonts( $et_user_fonts_queue ) ) );
* Loads the main stylesheet.
wp_enqueue_style( 'divi-style', get_stylesheet_directory_uri() . '/style' . $style_suffix . '.css', array(), $theme_version );
add_action( 'wp_enqueue_scripts', 'et_divi_load_scripts_styles' );
* Switch out the style.css for style-cpt.css when viewing the singular view of a custom post type.
* Necessary for child theme support so they don't have to implement this logic.
* Hooks at 99999998 so et_builder_dequeue_minifieds_styles() runs after this.
function et_divi_replace_stylesheet() {
// Apply to Custom Post Types when Builder used only.
if ( is_search() || ! et_builder_is_custom_post_type_archive() && ( ! et_builder_post_is_of_custom_post_type( get_the_ID() ) || ! et_pb_is_pagebuilder_used( get_the_ID() ) ) ) {
$template_directory_uri = preg_quote( get_template_directory_uri(), '/' );
$theme_style = '/^(' . $template_directory_uri . '\/style)(\.dev)?(\.css)$/';
$theme_style_cpt = '$1-cpt$2$3';
et_core_replace_enqueued_style( $theme_style, $theme_style_cpt, true );
add_action( 'wp_enqueue_scripts', 'et_divi_replace_stylesheet', 99999998 );
function et_divi_shortcodes_strings_handle( $handle ) {
return et_load_unminified_scripts() ? $handle : 'divi-custom-script';
add_filter( 'et_shortcodes_strings_handle', 'et_divi_shortcodes_strings_handle' );
function et_divi_builder_modules_script_handle( $handle ) {
return et_load_unminified_scripts() ? $handle : 'divi-custom-script';
add_filter( 'et_builder_modules_script_handle', 'et_divi_builder_modules_script_handle' );
function et_divi_builder_optimized_style_handle( $handle ) {
return et_load_unminified_styles() ? $handle : 'divi-style';
add_filter( 'et_builder_optimized_style_handle', 'et_divi_builder_optimized_style_handle' );
* Added theme specific scripts that are being minified
* @param array of scripts
* @return array of modified scripts
function et_divi_builder_get_minified_scripts( $scripts ) {
return array_merge( $scripts, array(
add_filter( 'et_builder_get_minified_scripts', 'et_divi_builder_get_minified_scripts' );
function et_add_mobile_navigation(){
if ( is_customize_preview() || ( 'slide' !== et_get_option( 'header_style', 'left' ) && 'fullscreen' !== et_get_option( 'header_style', 'left' ) ) ) {
'<div id="et_mobile_nav_menu">
<div class="mobile_nav closed">
<span class="select_page">%1$s</span>
<span class="mobile_menu_bar mobile_menu_bar_toggle"></span>
esc_html__( 'Select Page', 'Divi' )
add_action( 'et_header_top', 'et_add_mobile_navigation' );
function et_add_viewport_meta(){
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />';
add_action( 'wp_head', 'et_add_viewport_meta' );
function et_remove_additional_stylesheet( $stylesheet ){
global $default_colorscheme;
return $default_colorscheme;
add_filter( 'et_get_additional_color_scheme', 'et_remove_additional_stylesheet' );
if ( ! function_exists( 'et_list_pings' ) ) :
function et_list_pings($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li id="comment-<?php comment_ID(); ?>"><?php comment_author_link(); ?> - <?php comment_excerpt(); ?>
if ( ! function_exists( 'et_get_theme_version' ) ) :
function et_get_theme_version() {
$theme_info = wp_get_theme();
if ( is_child_theme() ) {
$theme_info = wp_get_theme( $theme_info->parent_theme );
$theme_version = $theme_info->display( 'Version' );
function et_add_post_meta_box( $post_type, $post ) {
$allowed = et_pb_is_allowed( 'page_options' );
$enabled = $post ? et_builder_enabled_for_post( $post->ID ) : et_builder_enabled_for_post_type( $post_type );
$enabled = in_array( $post_type, et_builder_get_default_post_types() ) ? true : $enabled;
$public = et_builder_is_post_type_public( $post_type );
if ( $allowed && $enabled && $public ) {
add_meta_box( 'et_settings_meta_box', esc_html__( 'Divi Page Settings', 'Divi' ), 'et_single_settings_meta_box', $post_type, 'side', 'high' );
add_action( 'add_meta_boxes', 'et_add_post_meta_box', 10, 2 );
if ( ! function_exists( 'et_pb_portfolio_meta_box' ) ) :
function et_pb_portfolio_meta_box() { ?>
<div class="et_project_meta">
<strong class="et_project_meta_title"><?php echo esc_html__( 'Skills', 'Divi' ); ?></strong>
<p><?php echo get_the_term_list( get_the_ID(), 'project_tag', '', ', ' ); ?></p>
<strong class="et_project_meta_title"><?php echo esc_html__( 'Posted on', 'Divi' ); ?></strong>
<p><?php echo get_the_date(); ?></p>
if ( ! function_exists( 'et_single_settings_meta_box' ) ) :
function et_single_settings_meta_box( $post ) {
wp_nonce_field( basename( __FILE__ ), 'et_settings_nonce' );
$page_layout = get_post_meta( $post_id, '_et_pb_page_layout', true );
if ( 'product' === $post->post_type && empty( $page_layout ) ) {
$page_layout = et_get_option( 'et_pb_woocommerce_product_layout' );
$side_nav = get_post_meta( $post_id, '_et_pb_side_nav', true );
$project_nav = get_post_meta( $post_id, '_et_pb_project_nav', true );
$post_hide_nav = get_post_meta( $post_id, '_et_pb_post_hide_nav', true );
$post_hide_nav = $post_hide_nav && 'off' === $post_hide_nav ? 'default' : $post_hide_nav;
$show_title = get_post_meta( $post_id, '_et_pb_show_title', true );
$is_builder_active = 'on' === get_post_meta( $post_id, '_et_pb_use_builder', true );
'et_left_sidebar' => esc_html__( 'Left Sidebar', 'Divi' ),
'et_right_sidebar' => esc_html__( 'Right Sidebar', 'Divi' ),
'et_no_sidebar' => esc_html__( 'No Sidebar', 'Divi' ),
'et_right_sidebar' => esc_html__( 'Right Sidebar', 'Divi' ),
'et_left_sidebar' => esc_html__( 'Left Sidebar', 'Divi' ),
'et_no_sidebar' => esc_html__( 'No Sidebar', 'Divi' ),
// Fullwidth option available for default post types only. Not available for custom post types.
if ( ! et_builder_is_post_type_custom( $post->post_type ) || 'product' === $post->post_type && $is_builder_active ) {
$page_layouts['et_full_width_page'] = esc_html__( 'Fullwidth', 'Divi' );
if ( 'et_full_width_page' === $page_layout && ( ! isset( $page_layouts['et_full_width_page'] ) || ! $is_builder_active ) ) {
$page_layout = 'et_no_sidebar';
'light' => esc_html__( 'Light', 'Divi' ),
'dark' => esc_html__( 'Dark', 'Divi' ),
$post_bg_color = ( $bg_color = get_post_meta( $post_id, '_et_post_bg_color', true ) ) && '' !== $bg_color
$post_use_bg_color = get_post_meta( $post_id, '_et_post_use_bg_color', true )
$post_bg_layout = ( $layout = get_post_meta( $post_id, '_et_post_bg_layout', true ) ) && '' !== $layout
$tb_layouts = et_theme_builder_get_template_layouts( ET_Theme_Builder_Request::from_post( $post_id ) );
$container = array( 'et_pb_page_settings_container' );
if ( ! empty( $tb_layouts ) ) {
$container[] = 'et_pb_page_settings_container--theme-builder';
if ( ! empty( $tb_layouts ) && $tb_layouts[ ET_THEME_BUILDER_HEADER_LAYOUT_POST_TYPE ]['override'] ) {
$container[] = 'et_pb_page_settings_container--tb-has-header';
if ( ! empty( $tb_layouts ) && $tb_layouts[ ET_THEME_BUILDER_BODY_LAYOUT_POST_TYPE ]['override'] ) {
$container[] = 'et_pb_page_settings_container--tb-has-body';
if ( ! empty( $tb_layouts ) && $tb_layouts[ ET_THEME_BUILDER_FOOTER_LAYOUT_POST_TYPE ]['override'] ) {
$container[] = 'et_pb_page_settings_container--tb-has-footer';