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' );
// 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' );
// Block editor supports.
add_theme_support( 'wp-block-styles' );
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');
// Load editor styling
add_editor_style( 'css/editor-style.css' );
add_editor_style( 'css/editor-blocks.css' );
et_divi_version_rollback()->enable();
if ( wp_doing_cron() ) {
et_register_updates_component();
}
// Remove WordPress emojis
add_action( 'init', 'et_disable_emojis' );
// Defer Gutenberg block stylesheet to the footer.
add_action( 'wp_enqueue_scripts', 'et_dequeue_block_css', 100 );
add_action( 'get_footer', 'et_enqueue_block_css', 100 );
}
add_action( 'after_setup_theme', 'et_setup_theme' );
add_action( 'et_do_legacy_shortcode', 'et_add_legacy_shortcode_css' );
add_action( 'et_do_legacy_shortcode', 'et_add_legacy_shortcode_js' );
/**
* Load un-minified and un-combined scripts.
*
* @param string $load check if loading unminified scripts.
* @return string
* @deprecated ??
*/
function et_divi_load_unminified_scripts( $load ) {
/** @see ET_Core_SupportCenter::toggle_safe_mode */
if ( et_core_is_safe_mode_active() ) {
return true;
}
if ( 'false' === et_get_option( 'divi_minify_combine_scripts' ) ) {
return true;
}
return $load;
}
/**
* Load un-minified and un-combined styles.
*
* @param string $load check if loading unminified styles.
* @return string
* @deprecated ??
*/
function et_divi_load_unminified_styles( $load ) {
/** @see ET_Core_SupportCenter::toggle_safe_mode */
if ( et_core_is_safe_mode_active() ) {
return true;
}
if ( 'false' === et_get_option( 'divi_minify_combine_styles' ) ) {
return true;
}
return $load;
}
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 ) ) {
$message = sprintf(
et_get_safe_localization( __( 'Welcome to Divi! Before diving in to your new theme, please visit the Divi Documentation page for access to dozens of in-depth tutorials.', $themename ) ),
esc_url( $documentation_url )
);
printf(
'
',
$message
);
et_update_option( $documentation_option_name, 'triggered' );
}
}
add_action( 'admin_notices', 'et_theme_epanel_reminder' );
if ( ! function_exists( 'et_divi_fonts_url' ) ) :
/**
* Print Google fonts style for Divi Theme base fonts.
*/
function et_divi_fonts_url() {
if ( ! et_core_use_google_fonts() ) {
return '';
}
$fonts_url = '';
/**
* 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';
}
$fonts = et_builder_get_fonts();
$full_character_set = ! empty( $fonts['Open Sans'] ) && ! empty( $fonts['Open Sans']['character_set'] ) ? $fonts['Open Sans']['character_set'] : 'cyrillic,cyrillic-ext,greek,greek-ext,latin,latin-ext,vietnamese';
// By default, only latin and latin-ext subsets are loaded, all available subsets can be enabled in ePanel.
$subset = 'false' === et_get_option( 'divi_gf_enable_all_character_sets', 'false' )
? 'latin,latin-ext'
: $full_character_set;
$query_args = array(
'family' => implode( '%7C', $font_families ),
'subset' => $subset,
'display' => 'swap',
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
}
return $fonts_url;
}
endif;
function et_divi_load_fonts() {
$google_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( $google_fonts_url ) && ! $no_open_sans ) {
$feature_manager = ET_Builder_Google_Fonts_Feature::instance();
$output_inline = $feature_manager->is_option_enabled( 'google_fonts_inline' );
if ( $output_inline ) {
$contents = $feature_manager->get(
'google-fonts',
function() use ( $feature_manager, $google_fonts_url ) {
return $feature_manager->fetch( $google_fonts_url );
},
sanitize_text_field( et_core_esc_previously( $google_fonts_url ) )
);
// if something went wrong fetching the contents
if ( false === $contents ) {
// phpcs:ignore WordPress.WP.EnqueuedResourceParameters -- Google fonts api does not have versions
wp_enqueue_style( 'et-divi-open-sans', et_core_esc_previously( $google_fonts_url ), array(), null );
} else {
echo '';
}
} else {
// phpcs:ignore WordPress.WP.EnqueuedResourceParameters -- Google fonts api does not have versions.
wp_enqueue_style( 'et-divi-open-sans', et_core_esc_previously( $google_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;
return $args;
}
add_filter( 'wp_page_menu_args', 'et_add_home_link' );
function et_divi_load_scripts_styles(){
global $wp_styles, $et_user_fonts_queue;
// $dynamic_js_suffix = et_use_dynamic_js() ? '' : '-static'; // @temp-disabled-dynamic-assets-js
$template_dir = get_template_directory_uri();
$theme_version = et_get_theme_version();
$post_id = get_the_id();
$is_page_builder_used = et_pb_is_pagebuilder_used( $post_id );
$page_comments_disabled = et_get_option( 'divi_show_pagescomments', 'off' );
$post_with_comments = is_single() && comments_open() && get_option( 'thread_comments' );
$page_width_comments = is_page() && ! $is_page_builder_used && comments_open() && get_option( 'thread_comments' ) && $page_comments_disabled === 'on';
if ( $post_with_comments || $page_width_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( 'divi-custom-script', $template_dir . '/js/scripts.min.js', $dependencies_array, $theme_version, true );
$divi_data = array(
'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 );
$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 );
continue;
}
}
et_builder_enqueue_font( $single_font );
}
if ( function_exists( 'et_builder_enqueue_user_fonts' ) && ! empty( $et_user_fonts_queue ) ) {
printf( '', et_core_esc_previously( et_builder_enqueue_user_fonts( $et_user_fonts_queue ) ) );
}
}
}
add_action( 'wp_enqueue_scripts', 'et_divi_load_scripts_styles' );
/**
* Enqueue the main style.css file.
* If a child theme is active and the child theme has not enqueued
* the Divi stylsheet, enqueue it for them. Otherwise -rtl, -cpt and -static
* stylesheet versions will never be enqueued properly. Some child themes
* import the Divi style.css file in their child theme .css file, which won't work.
*/
function et_divi_enqueue_stylesheet() {
$theme_version = et_get_theme_version();
$styles = wp_styles();
// Filter the $styles array and determine if the Divi stylesheet is enqueued.
$divi_style_enqueued = ! empty(
array_filter(
$styles->registered,
function( $style ) {
$template_directory_uri = preg_quote( get_template_directory_uri(), '/' );
return preg_match( '/' . $template_directory_uri . '\/style.*\.css/', $style->src );
}
)
);
if ( ! is_child_theme() ) {
// If no child theme is active, we enqueue the Divi style.css located in the template dir.
wp_enqueue_style( 'divi-style', get_template_directory_uri() . '/style.css', array(), $theme_version );
} elseif ( $divi_style_enqueued ) {
// If a child theme is used and the child theme already enqueued the Divi style.css in their functions.php,
// then we enqueue the child theme style.css file via the stylesheet dir.
wp_enqueue_style( 'divi-style', get_stylesheet_directory_uri() . '/style.css', array(), $theme_version );
} else {
// If a child theme is used and they do not enqueue the Divi style.css file,
// we need to enqueue it for them before their child theme style.css file.
wp_enqueue_style( 'divi-style-parent', get_template_directory_uri() . '/style.css', array(), $theme_version );
wp_enqueue_style( 'divi-style', get_stylesheet_directory_uri() . '/style.css', array(), $theme_version );
}
}
add_action( 'wp_enqueue_scripts', 'et_divi_enqueue_stylesheet' );
/**
* Replace the enqueued Divi style.css file with the applicable version.
* If Dynamic CSS is disabled, we load the -static file. If RTL is enabled, we load the -rtl file.
* If on a custom post type, we load the -cpt file. This is also necessary for child themes,
* which typically enqueue the standard style.css without the logic below.
*/
function et_divi_replace_parent_stylesheet() {
$theme_version = et_get_theme_version();
$post_id = get_the_ID();
$cpt_suffix = et_builder_should_wrap_styles() ? '-cpt' : '';
$dynamic_css_suffix = et_use_dynamic_css() ? '' : '-static';
$rtl_suffix = is_rtl() ? '-rtl' : '';
$template_directory_uri = preg_quote( get_template_directory_uri(), '/' );
$style_handle = is_child_theme() ? 'divi-style-parent' : 'divi-style';
// We check for .dev in case child themes enqueued this legacy stylesheet.
$theme_style = '/^(' . $template_directory_uri . '\/style)(\.dev)?(\.min)?(\.css)$/';
$theme_style_replaced = '$1' . $dynamic_css_suffix . $cpt_suffix . $rtl_suffix . '.min.css';
et_core_replace_enqueued_style( $theme_style, $theme_style_replaced, $theme_version, $style_handle, '', true );
}
add_action( 'wp_enqueue_scripts', 'et_divi_replace_parent_stylesheet', 99999998 );
/**
* If Load Dynamic Stylesheet In-line is enabled in the Divi Theme Options,
* we print stylesheet contents in-line. We must grab the correct base stylesheet
* depending on RTl and CPT.
*/
function et_divi_print_stylesheet() {
$enable_inline_stylesheet = et_get_option( 'divi_inline_stylesheet', 'on' );
if ( 'on' === $enable_inline_stylesheet && et_use_dynamic_css() ) {
$post_id = get_the_ID();
$cpt_suffix = et_builder_should_wrap_styles() ? '-cpt' : '';
$rtl_suffix = is_rtl() ? '-rtl' : '';
$stylesheet_src = get_template_directory_uri() . '/style' . $cpt_suffix . $rtl_suffix . '.min.css';
$stylesheet_path = get_template_directory() . '/style' . $cpt_suffix . $rtl_suffix . '.min.css';
$stylesheet_path = str_replace( '..', '', $stylesheet_path );
$stylesheet_contents = file_get_contents( $stylesheet_path );
$theme_version = et_get_theme_version();
$url_match = '/url\(/i';
$url_replace = 'url(' . get_template_directory_uri() . '/';
$stylesheet_contents_replaced = preg_replace( $url_match, $url_replace, $stylesheet_contents );
$child_theme_suffix = is_child_theme() ? '-parent' : '';
$styles = wp_styles();
foreach ( $styles->registered as $handle => $style ) {
if ( $style->src === $stylesheet_src ) {
$existing_inline_styles = $styles->get_data( $handle, 'after' );
break;
}
}
if ( false !== $stylesheet_contents ) {
wp_register_style( 'divi-style' . $child_theme_suffix . '-inline', false, array(), $theme_version );
wp_enqueue_style( 'divi-style' . $child_theme_suffix . '-inline' );
wp_add_inline_style( 'divi-style' . $child_theme_suffix . '-inline', $stylesheet_contents_replaced );
if ( ! empty( $existing_inline_styles ) ) {
wp_add_inline_style( 'divi-style' . $child_theme_suffix . '-inline', implode( "\n", $existing_inline_styles ) );
}
add_action( 'wp_enqueue_scripts', 'et_divi_dequeue_stylesheet', 99999999 );
}
}
}
add_action( 'wp_enqueue_scripts', 'et_divi_print_stylesheet', 99999998 );
/**
* If Load Dynamic Stylesheet In-line is enabled, we need to dequeue the Divi stylesheet,
* since it's now being enqueued in-line.
*/
function et_divi_dequeue_stylesheet() {
$post_id = get_the_ID();
$cpt_suffix = et_builder_should_wrap_styles() ? '-cpt' : '';
$rtl_suffix = is_rtl() ? '-rtl' : '';
$styles = wp_styles();
$stylesheet = get_template_directory_uri() . '/style' . $cpt_suffix . $rtl_suffix . '.min.css';
if ( empty( $styles->registered ) ) {
return;
}
foreach ( $styles->registered as $handle => $style ) {
if ( $style->src === $stylesheet ) {
wp_dequeue_style( $handle );
break;
}
}
}
/**
* All Child Theme .css files must be dequeued and re-queued so that we can control their order.
* They must be queued below the parent stylesheet, which we have dequeued and re-queued in et_divi_replace_parent_stylesheet().
*/
add_action( 'wp_enqueue_scripts', 'et_requeue_child_theme_styles', 99999999 );
/**
* Enqueue smoothscroll if it's enabled.
*/
function et_enqueue_smoothscroll() {
$theme_version = et_get_theme_version();
if ( 'on' === et_get_option( 'divi_smooth_scroll', 'off' ) ) {
wp_enqueue_script( 'smoothscroll', get_template_directory_uri() . '/js/smoothscroll.js', array(), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_smoothscroll' );
/**
* Enqueue magnific popup when needed.
*
* @since ??
*/
function et_enqueue_magnific_popup() {
$theme_version = et_get_theme_version();
if ( 'on' === et_get_option( 'divi_gallery_layout_enable', 'off' ) && ( is_active_widget( false, false, 'media_gallery', true ) || et_is_active_block_widget( 'core/gallery' ) ) ) {
wp_enqueue_script( 'magnific-popup', get_template_directory_uri() . '/includes/builder/feature/dynamic-assets/assets/js/magnific-popup.js', array( 'jquery' ), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_magnific_popup' );
function et_add_mobile_navigation(){
if ( is_customize_preview() || ( 'slide' !== et_get_option( 'header_style', 'left' ) && 'fullscreen' !== et_get_option( 'header_style', 'left' ) ) ) {
printf(
'',
esc_html__( 'Select Page', 'Divi' )
);
}
}
add_action( 'et_header_top', 'et_add_mobile_navigation' );
function et_add_viewport_meta(){
echo '';
}
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; ?>