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() { $catalog = array( 'width' => '400', 'height' => '400', 'crop' => 1, ); $single = array( 'width' => '510', 'height' => '9999', 'crop' => 0, ); $thumbnail = array( 'width' => '157', 'height' => '157', 'crop' => 1, ); 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( '%1$s', woocommerce_get_product_thumbnail() ); } endif; function et_divi_output_product_wrapper() { echo '
'; } function et_divi_output_product_wrapper_end() { echo '
'; } function et_review_gravatar_size( $size ) { return '80'; } add_filter( 'woocommerce_review_gravatar_size', 'et_review_gravatar_size' ); function et_divi_output_content_wrapper() { echo '
'; } 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 '
'; 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 ) { get_sidebar(); } echo '
'; } function et_add_divi_menu() { $core_page = add_menu_page( 'Divi', 'Divi', 'switch_themes', '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'] ) ) { if ( ( 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' ); } // 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 Module Customizer menu only if it's enabled for current user if ( et_pb_is_allowed( 'module_customizer' ) ) { add_submenu_page( 'et_divi_options', esc_html__( 'Module Customizer', 'Divi' ), esc_html__( 'Module Customizer', 'Divi' ), 'manage_options', 'customize.php?et_customizer_option_set=module' ); } 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' ) ) { return; } global $wp_admin_bar; $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', 'meta' => array( 'class' => 'hide-if-no-customize', ), ) ); } // add Module Customizer admin menu only if it's enabled for current user if ( et_pb_is_allowed( 'module_customizer' ) ) { $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'customize-divi-module', 'title' => esc_html__( 'Module Customizer', 'Divi' ), 'href' => $customize_url . '&et_customizer_option_set=module', 'meta' => array( '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' ) ) { return; } $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' ) ); } } /** * 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 ) { global $post; $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; break; } } // 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 ) ) { return $requested_url; } return $redirect_url; } 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; return $args; } 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 ) { return 'en_US'; } return $locale; } add_filter( 'locale', 'et_divi_maybe_change_frontend_locale' ); /** * Enable Divi gallery override if user activates it * @return bool */ 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' ); /** * Register theme and modules Customizer portability. * * @since 2.7.0 */ function et_divi_register_customizer_portability() { global $options; // Make sure the Portability is loaded. et_core_load_component( 'portability' ); // Load ePanel options. et_load_core_options(); // Exclude ePanel options. $exclude = array(); 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' ), 'type' => 'options', 'target' => 'et_divi', 'exclude' => $exclude, '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' ); /** * Register theme and modules Customizer portability link. * * @since 2.7.0 * * @return bool Always return true. */ function et_divi_customizer_link() { if ( is_customize_preview() ) { echo et_core_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 * @return array */ function et_divi_theme_body_class( $classes ) { $classes[] = 'et_divi_theme'; return $classes; } add_filter( 'body_class', 'et_divi_theme_body_class' ); 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' ), 'Elegant Themes', 'WordPress' ); } endif; 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 ) { return ''; } $credits_format = '<%2$s id="footer-info">%1$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' ) ); } endif; 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' ); } return $is_builder_used; } add_filter( 'et_core_is_builder_used_on_current_request', 'et_divi_filter_et_core_is_builder_used_on_current_request' ); endif; if ( ! function_exists( 'et_divi_version_rollback' ) ) : function et_divi_version_rollback() { global $themename, $shortname; static $instance = null; if ( null === $instance ) { $instance = new ET_Core_VersionRollback( $themename, $shortname, et_get_theme_version() ); } return $instance; } endif; /** * Filter the list of post types the Divi Builder is enabled on based on theme options. * * @since 3.10 * * @param array $options * * @return array */ if ( ! function_exists( 'et_divi_filter_enabled_builder_post_type_options' ) ) : function et_divi_filter_enabled_builder_post_type_options( $options ) { // Cache results to avoid unnecessary option fetching multiple times per request. static $stored_options = null; if ( null === $stored_options ) { $stored_options = et_get_option( 'et_pb_post_type_integration', array() ); } return $stored_options; } endif; add_filter( 'et_builder_enabled_builder_post_type_options', 'et_divi_filter_enabled_builder_post_type_options' );