Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi
File: functions.php
}
[8000] Fix | Delete
[8001] Fix | Delete
function et_add_divi_menu() {
[8002] Fix | Delete
$core_page = add_menu_page( 'Divi', 'Divi', 'edit_theme_options', 'et_divi_options', 'et_build_epanel' );
[8003] Fix | Delete
[8004] Fix | Delete
// Add Theme Options menu only if it's enabled for current user
[8005] Fix | Delete
if ( et_pb_is_allowed( 'theme_options' ) ) {
[8006] Fix | Delete
[8007] Fix | Delete
if ( isset( $_GET['page'] ) && 'et_divi_options' === $_GET['page'] && isset( $_POST['action'] ) ) {
[8008] Fix | Delete
if (
[8009] Fix | Delete
( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'epanel_nonce' ) )
[8010] Fix | Delete
||
[8011] Fix | Delete
( 'reset' === $_POST['action'] && isset( $_POST['_wpnonce_reset'] ) && wp_verify_nonce( $_POST['_wpnonce_reset'], 'et-nojs-reset_epanel' ) )
[8012] Fix | Delete
) {
[8013] Fix | Delete
epanel_save_data( 'js_disabled' ); //saves data when javascript is disabled
[8014] Fix | Delete
}
[8015] Fix | Delete
}
[8016] Fix | Delete
[8017] Fix | Delete
add_submenu_page( 'et_divi_options', esc_html__( 'Theme Options', 'Divi' ), esc_html__( 'Theme Options', 'Divi' ), 'manage_options', 'et_divi_options' );
[8018] Fix | Delete
}
[8019] Fix | Delete
[8020] Fix | Delete
et_theme_builder_add_admin_page( 'et_divi_options' );
[8021] Fix | Delete
[8022] Fix | Delete
// Add Theme Customizer menu only if it's enabled for current user
[8023] Fix | Delete
if ( et_pb_is_allowed( 'theme_customizer' ) ) {
[8024] Fix | Delete
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' );
[8025] Fix | Delete
}
[8026] Fix | Delete
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' );
[8027] Fix | Delete
// Add Divi Library menu only if it's enabled for current user
[8028] Fix | Delete
if ( et_pb_is_allowed( 'divi_library' ) ) {
[8029] Fix | Delete
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' );
[8030] Fix | Delete
}
[8031] Fix | Delete
[8032] Fix | Delete
add_action( "load-{$core_page}", 'et_pb_check_options_access' ); // load function to check the permissions of current user
[8033] Fix | Delete
add_action( "load-{$core_page}", 'et_epanel_hook_scripts' );
[8034] Fix | Delete
add_action( "admin_print_scripts-{$core_page}", 'et_epanel_admin_js' );
[8035] Fix | Delete
add_action( "admin_head-{$core_page}", 'et_epanel_css_admin');
[8036] Fix | Delete
add_action( "admin_print_scripts-{$core_page}", 'et_epanel_media_upload_scripts');
[8037] Fix | Delete
add_action( "admin_head-{$core_page}", 'et_epanel_media_upload_styles');
[8038] Fix | Delete
}
[8039] Fix | Delete
add_action('admin_menu', 'et_add_divi_menu');
[8040] Fix | Delete
[8041] Fix | Delete
function add_divi_customizer_admin_menu() {
[8042] Fix | Delete
if ( ! current_user_can( 'customize' ) ) {
[8043] Fix | Delete
return;
[8044] Fix | Delete
}
[8045] Fix | Delete
[8046] Fix | Delete
global $wp_admin_bar;
[8047] Fix | Delete
[8048] Fix | Delete
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
[8049] Fix | Delete
$customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() );
[8050] Fix | Delete
[8051] Fix | Delete
// add Theme Customizer admin menu only if it's enabled for current user
[8052] Fix | Delete
if ( et_pb_is_allowed( 'theme_customizer' ) ) {
[8053] Fix | Delete
$wp_admin_bar->add_menu( array(
[8054] Fix | Delete
'parent' => 'appearance',
[8055] Fix | Delete
'id' => 'customize-divi-theme',
[8056] Fix | Delete
'title' => esc_html__( 'Theme Customizer', 'Divi' ),
[8057] Fix | Delete
'href' => $customize_url . '&et_customizer_option_set=theme',
[8058] Fix | Delete
'meta' => array(
[8059] Fix | Delete
'class' => 'hide-if-no-customize',
[8060] Fix | Delete
),
[8061] Fix | Delete
) );
[8062] Fix | Delete
}
[8063] Fix | Delete
[8064] Fix | Delete
$wp_admin_bar->remove_menu( 'customize' );
[8065] Fix | Delete
}
[8066] Fix | Delete
add_action( 'admin_bar_menu', 'add_divi_customizer_admin_menu', 999 );
[8067] Fix | Delete
[8068] Fix | Delete
function et_pb_hide_options_menu() {
[8069] Fix | Delete
// do nothing if theme options should be displayed in the menu
[8070] Fix | Delete
if ( et_pb_is_allowed( 'theme_options' ) ) {
[8071] Fix | Delete
return;
[8072] Fix | Delete
}
[8073] Fix | Delete
[8074] Fix | Delete
$theme_version = et_get_theme_version();
[8075] Fix | Delete
[8076] Fix | Delete
wp_enqueue_script( 'divi-custom-admin-menu', get_template_directory_uri() . '/js/menu_fix.js', array( 'jquery' ), $theme_version, true );
[8077] Fix | Delete
}
[8078] Fix | Delete
add_action( 'admin_enqueue_scripts', 'et_pb_hide_options_menu' );
[8079] Fix | Delete
[8080] Fix | Delete
function et_pb_check_options_access() {
[8081] Fix | Delete
// display wp error screen if theme customizer disabled for current user
[8082] Fix | Delete
if ( ! et_pb_is_allowed( 'theme_options' ) ) {
[8083] Fix | Delete
wp_die( esc_html__( "you don't have sufficient permissions to access this page", 'Divi' ) );
[8084] Fix | Delete
}
[8085] Fix | Delete
}
[8086] Fix | Delete
[8087] Fix | Delete
/**
[8088] Fix | Delete
* Divi Support Center
[8089] Fix | Delete
*
[8090] Fix | Delete
* @since ??
[8091] Fix | Delete
*/
[8092] Fix | Delete
function et_add_divi_support_center() {
[8093] Fix | Delete
$support_center = new ET_Core_SupportCenter( 'divi_theme' );
[8094] Fix | Delete
$support_center->init();
[8095] Fix | Delete
}
[8096] Fix | Delete
add_action( 'init', 'et_add_divi_support_center' );
[8097] Fix | Delete
[8098] Fix | Delete
/**
[8099] Fix | Delete
* Allowing blog and portfolio module pagination to work in non-hierarchical singular page.
[8100] Fix | Delete
* Normally, WP_Query based modules wouldn't work in non-hierarchical single post type page
[8101] Fix | Delete
* due to canonical redirect to prevent page duplication which could lead to SEO penalty.
[8102] Fix | Delete
*
[8103] Fix | Delete
* @see redirect_canonical()
[8104] Fix | Delete
*
[8105] Fix | Delete
* @return mixed string|bool
[8106] Fix | Delete
*/
[8107] Fix | Delete
function et_modify_canonical_redirect( $redirect_url, $requested_url ) {
[8108] Fix | Delete
global $post;
[8109] Fix | Delete
[8110] Fix | Delete
$allowed_shortcodes = array( 'et_pb_blog', 'et_pb_portfolio' );
[8111] Fix | Delete
$is_overwrite_canonical_redirect = false;
[8112] Fix | Delete
[8113] Fix | Delete
// Look for $allowed_shortcodes in content. Once detected, set $is_overwrite_canonical_redirect to true
[8114] Fix | Delete
foreach ( $allowed_shortcodes as $shortcode ) {
[8115] Fix | Delete
if ( !empty( $post ) && has_shortcode( $post->post_content, $shortcode ) ) {
[8116] Fix | Delete
$is_overwrite_canonical_redirect = true;
[8117] Fix | Delete
break;
[8118] Fix | Delete
}
[8119] Fix | Delete
}
[8120] Fix | Delete
[8121] Fix | Delete
// Only alter canonical redirect in 2 cases:
[8122] Fix | Delete
// 1) If current page is singular, has paged and $allowed_shortcodes
[8123] Fix | Delete
// 2) If current page is front_page, has page and $allowed_shortcodes
[8124] Fix | Delete
if ( ( is_singular() & ! is_home() && get_query_var( 'paged' ) && $is_overwrite_canonical_redirect ) || ( is_front_page() && get_query_var( 'page' ) && $is_overwrite_canonical_redirect ) ) {
[8125] Fix | Delete
return $requested_url;
[8126] Fix | Delete
}
[8127] Fix | Delete
[8128] Fix | Delete
return $redirect_url;
[8129] Fix | Delete
}
[8130] Fix | Delete
add_filter( 'redirect_canonical', 'et_modify_canonical_redirect', 10, 2 );
[8131] Fix | Delete
[8132] Fix | Delete
/**
[8133] Fix | Delete
* Determines how many related products should be displayed on single product page
[8134] Fix | Delete
* @param array related products arguments
[8135] Fix | Delete
* @return array modified related products arguments
[8136] Fix | Delete
*/
[8137] Fix | Delete
function et_divi_woocommerce_output_related_products_args( $args ) {
[8138] Fix | Delete
$related_posts = 4; // default number
[8139] Fix | Delete
[8140] Fix | Delete
if ( is_singular( 'product' ) ) {
[8141] Fix | Delete
$page_layout = get_post_meta( get_the_ID(), '_et_pb_page_layout', true );
[8142] Fix | Delete
[8143] Fix | Delete
if ( 'et_full_width_page' !== $page_layout ) {
[8144] Fix | Delete
$related_posts = 3; // set to 3 if page has sidebar
[8145] Fix | Delete
}
[8146] Fix | Delete
}
[8147] Fix | Delete
[8148] Fix | Delete
// Modify related and up-sell products args
[8149] Fix | Delete
$args['posts_per_page'] = $related_posts;
[8150] Fix | Delete
$args['columns'] = $related_posts;
[8151] Fix | Delete
[8152] Fix | Delete
return $args;
[8153] Fix | Delete
}
[8154] Fix | Delete
add_filter( 'woocommerce_upsell_display_args', 'et_divi_woocommerce_output_related_products_args' );
[8155] Fix | Delete
add_filter( 'woocommerce_output_related_products_args', 'et_divi_woocommerce_output_related_products_args' );
[8156] Fix | Delete
[8157] Fix | Delete
function et_divi_maybe_change_frontend_locale( $locale ) {
[8158] Fix | Delete
$option_name = 'divi_disable_translations';
[8159] Fix | Delete
$theme_options = get_option( 'et_divi' );
[8160] Fix | Delete
[8161] Fix | Delete
$disable_translations = isset ( $theme_options[ $option_name ] ) ? $theme_options[ $option_name ] : false;
[8162] Fix | Delete
[8163] Fix | Delete
if ( 'on' === $disable_translations ) {
[8164] Fix | Delete
return 'en_US';
[8165] Fix | Delete
}
[8166] Fix | Delete
[8167] Fix | Delete
return $locale;
[8168] Fix | Delete
}
[8169] Fix | Delete
add_filter( 'locale', 'et_divi_maybe_change_frontend_locale' );
[8170] Fix | Delete
[8171] Fix | Delete
/**
[8172] Fix | Delete
* Enable Divi gallery override if user activates it
[8173] Fix | Delete
* @return bool
[8174] Fix | Delete
*/
[8175] Fix | Delete
function et_divi_gallery_layout_enable( $option ) {
[8176] Fix | Delete
$setting = et_get_option( 'divi_gallery_layout_enable' );
[8177] Fix | Delete
[8178] Fix | Delete
return ( 'on' === $setting ) ? true : $option;
[8179] Fix | Delete
}
[8180] Fix | Delete
add_filter( 'et_gallery_layout_enable', 'et_divi_gallery_layout_enable' );
[8181] Fix | Delete
[8182] Fix | Delete
/**
[8183] Fix | Delete
* Enable GB gallery to shortcode conversion
[8184] Fix | Delete
*
[8185] Fix | Delete
* @return bool
[8186] Fix | Delete
*/
[8187] Fix | Delete
function et_divi_gb_gallery_to_shortcode() {
[8188] Fix | Delete
return et_divi_gallery_layout_enable( false );
[8189] Fix | Delete
}
[8190] Fix | Delete
add_filter( 'et_gb_gallery_to_shortcode', 'et_divi_gb_gallery_to_shortcode' );
[8191] Fix | Delete
[8192] Fix | Delete
/**
[8193] Fix | Delete
* Register theme and modules Customizer portability.
[8194] Fix | Delete
*
[8195] Fix | Delete
* @since 2.7.0
[8196] Fix | Delete
*/
[8197] Fix | Delete
function et_divi_register_customizer_portability() {
[8198] Fix | Delete
global $options;
[8199] Fix | Delete
[8200] Fix | Delete
// Make sure the Portability is loaded.
[8201] Fix | Delete
et_core_load_component( 'portability' );
[8202] Fix | Delete
[8203] Fix | Delete
// Load ePanel options.
[8204] Fix | Delete
et_load_core_options();
[8205] Fix | Delete
[8206] Fix | Delete
// Exclude ePanel options.
[8207] Fix | Delete
$exclude = array();
[8208] Fix | Delete
[8209] Fix | Delete
foreach ( $options as $option ) {
[8210] Fix | Delete
if ( isset( $option['id'] ) ) {
[8211] Fix | Delete
$exclude[ $option['id'] ] = true;
[8212] Fix | Delete
}
[8213] Fix | Delete
}
[8214] Fix | Delete
[8215] Fix | Delete
// Register the portability.
[8216] Fix | Delete
et_core_portability_register( 'et_divi_mods', array(
[8217] Fix | Delete
'name' => esc_html__( 'Divi Customizer Settings', 'Divi' ),
[8218] Fix | Delete
'type' => 'options',
[8219] Fix | Delete
'target' => 'et_divi',
[8220] Fix | Delete
'exclude' => $exclude,
[8221] Fix | Delete
'view' => is_customize_preview(),
[8222] Fix | Delete
) );
[8223] Fix | Delete
}
[8224] Fix | Delete
add_action( 'admin_init', 'et_divi_register_customizer_portability' );
[8225] Fix | Delete
[8226] Fix | Delete
function et_register_updates_component() {
[8227] Fix | Delete
et_core_enable_automatic_updates( get_template_directory_uri(), ET_CORE_VERSION );
[8228] Fix | Delete
}
[8229] Fix | Delete
add_action( 'admin_init', 'et_register_updates_component', 9 );
[8230] Fix | Delete
[8231] Fix | Delete
/**
[8232] Fix | Delete
* Register theme and modules Customizer portability link.
[8233] Fix | Delete
*
[8234] Fix | Delete
* @since 2.7.0
[8235] Fix | Delete
*
[8236] Fix | Delete
* @return bool Always return true.
[8237] Fix | Delete
*/
[8238] Fix | Delete
function et_divi_customizer_link() {
[8239] Fix | Delete
if ( is_customize_preview() ) {
[8240] Fix | Delete
echo et_builder_portability_link( 'et_divi_mods', array( 'class' => 'et-core-customize-controls-close' ) );
[8241] Fix | Delete
}
[8242] Fix | Delete
}
[8243] Fix | Delete
add_action( 'customize_controls_print_footer_scripts', 'et_divi_customizer_link' );
[8244] Fix | Delete
[8245] Fix | Delete
/**
[8246] Fix | Delete
* Added body class to make it possible to identify the Divi theme on frontend
[8247] Fix | Delete
* @return array
[8248] Fix | Delete
*/
[8249] Fix | Delete
function et_divi_theme_body_class( $classes ) {
[8250] Fix | Delete
$classes[] = 'et_divi_theme';
[8251] Fix | Delete
[8252] Fix | Delete
return $classes;
[8253] Fix | Delete
}
[8254] Fix | Delete
add_filter( 'body_class', 'et_divi_theme_body_class' );
[8255] Fix | Delete
[8256] Fix | Delete
/**
[8257] Fix | Delete
* Determine if it's a fresh Divi install by checking for the existence of 'divi_logo' key in 'et_divi' options array.
[8258] Fix | Delete
*
[8259] Fix | Delete
* @since ??
[8260] Fix | Delete
*
[8261] Fix | Delete
* @return bool
[8262] Fix | Delete
*/
[8263] Fix | Delete
if ( ! function_exists( 'et_divi_is_fresh_install' ) ):
[8264] Fix | Delete
function et_divi_is_fresh_install() {
[8265] Fix | Delete
return false === et_get_option( 'divi_logo' );
[8266] Fix | Delete
}
[8267] Fix | Delete
endif;
[8268] Fix | Delete
[8269] Fix | Delete
if ( ! function_exists( 'et_get_original_footer_credits' ) ) :
[8270] Fix | Delete
function et_get_original_footer_credits() {
[8271] Fix | Delete
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>' );
[8272] Fix | Delete
}
[8273] Fix | Delete
endif;
[8274] Fix | Delete
[8275] Fix | Delete
if ( ! function_exists( 'et_get_footer_credits' ) ) :
[8276] Fix | Delete
function et_get_footer_credits() {
[8277] Fix | Delete
$original_footer_credits = et_get_original_footer_credits();
[8278] Fix | Delete
[8279] Fix | Delete
$disable_custom_credits = et_get_option( 'disable_custom_footer_credits', false );
[8280] Fix | Delete
[8281] Fix | Delete
if ( $disable_custom_credits ) {
[8282] Fix | Delete
return '';
[8283] Fix | Delete
}
[8284] Fix | Delete
[8285] Fix | Delete
$credits_format = '<%2$s id="footer-info">%1$s</%2$s>';
[8286] Fix | Delete
[8287] Fix | Delete
$footer_credits = et_get_option( 'custom_footer_credits', '' );
[8288] Fix | Delete
[8289] Fix | Delete
if ( '' === trim( $footer_credits ) ) {
[8290] Fix | Delete
return et_get_safe_localization( sprintf( $credits_format, $original_footer_credits, 'p' ) );
[8291] Fix | Delete
}
[8292] Fix | Delete
[8293] Fix | Delete
return et_get_safe_localization( sprintf( $credits_format, $footer_credits, 'div' ) );
[8294] Fix | Delete
}
[8295] Fix | Delete
endif;
[8296] Fix | Delete
[8297] Fix | Delete
if ( ! function_exists( 'et_divi_filter_et_core_is_builder_used_on_current_request' ) ):
[8298] Fix | Delete
function et_divi_filter_et_core_is_builder_used_on_current_request( $is_builder_used ) {
[8299] Fix | Delete
if ( $is_builder_used && ! is_singular() ) {
[8300] Fix | Delete
$is_builder_used = 'on' === et_get_option( 'divi_blog_style', 'false' );
[8301] Fix | Delete
}
[8302] Fix | Delete
[8303] Fix | Delete
return $is_builder_used;
[8304] Fix | Delete
}
[8305] Fix | Delete
add_filter( 'et_core_is_builder_used_on_current_request', 'et_divi_filter_et_core_is_builder_used_on_current_request' );
[8306] Fix | Delete
endif;
[8307] Fix | Delete
[8308] Fix | Delete
if ( ! function_exists( 'et_divi_version_rollback' ) ) :
[8309] Fix | Delete
function et_divi_version_rollback() {
[8310] Fix | Delete
global $themename, $shortname;
[8311] Fix | Delete
static $instance = null;
[8312] Fix | Delete
[8313] Fix | Delete
if ( null === $instance ) {
[8314] Fix | Delete
$instance = new ET_Core_VersionRollback( $themename, $shortname, et_get_theme_version() );
[8315] Fix | Delete
}
[8316] Fix | Delete
[8317] Fix | Delete
return $instance;
[8318] Fix | Delete
}
[8319] Fix | Delete
endif;
[8320] Fix | Delete
[8321] Fix | Delete
/**
[8322] Fix | Delete
* Filter the list of post types the Divi Builder is enabled on based on theme options.
[8323] Fix | Delete
*
[8324] Fix | Delete
* @since 3.10
[8325] Fix | Delete
*
[8326] Fix | Delete
* @param array<string, string> $options
[8327] Fix | Delete
*
[8328] Fix | Delete
* @return array<string, string>
[8329] Fix | Delete
*/
[8330] Fix | Delete
if ( ! function_exists( 'et_divi_filter_enabled_builder_post_type_options' ) ) :
[8331] Fix | Delete
function et_divi_filter_enabled_builder_post_type_options( $options ) {
[8332] Fix | Delete
// Cache results to avoid unnecessary option fetching multiple times per request.
[8333] Fix | Delete
static $stored_options = null;
[8334] Fix | Delete
[8335] Fix | Delete
if ( null === $stored_options ) {
[8336] Fix | Delete
$stored_options = et_get_option( 'et_pb_post_type_integration', array() );
[8337] Fix | Delete
}
[8338] Fix | Delete
[8339] Fix | Delete
return $stored_options;
[8340] Fix | Delete
}
[8341] Fix | Delete
endif;
[8342] Fix | Delete
add_filter( 'et_builder_enabled_builder_post_type_options', 'et_divi_filter_enabled_builder_post_type_options' );
[8343] Fix | Delete
[8344] Fix | Delete
/**
[8345] Fix | Delete
* Caches expensive generation of truncate_post content
[8346] Fix | Delete
*
[8347] Fix | Delete
* @since 3.17.3
[8348] Fix | Delete
*
[8349] Fix | Delete
* @param bool $custom
[8350] Fix | Delete
* @param string $content
[8351] Fix | Delete
* @param WP_Post $post
[8352] Fix | Delete
*
[8353] Fix | Delete
* @return string
[8354] Fix | Delete
*/
[8355] Fix | Delete
if ( ! function_exists( 'et_divi_truncate_post_use_custom_content' ) ) :
[8356] Fix | Delete
function et_divi_truncate_post_use_custom_content( $custom, $content, $post ) {
[8357] Fix | Delete
// If post doesn't use builder, no need to compute a custom value
[8358] Fix | Delete
if ( ! et_pb_is_pagebuilder_used( $post->ID ) ) {
[8359] Fix | Delete
return false;
[8360] Fix | Delete
}
[8361] Fix | Delete
[8362] Fix | Delete
$cached = get_post_meta( $post->ID, '_et_pb_truncate_post', true );
[8363] Fix | Delete
[8364] Fix | Delete
if ( $cached ) {
[8365] Fix | Delete
$cached_date = get_post_meta( $post->ID, '_et_pb_truncate_post_date', true );
[8366] Fix | Delete
$cached_date = $cached_date ? $cached_date : get_post_field( 'post_modified', $post->ID );
[8367] Fix | Delete
$global_modules = array();
[8368] Fix | Delete
[8369] Fix | Delete
$shortcodes = array();
[8370] Fix | Delete
preg_match_all( '/'. get_shortcode_regex() .'/s', $content, $shortcodes );
[8371] Fix | Delete
[8372] Fix | Delete
if ( is_array( $shortcodes ) && isset( $shortcodes[3] ) ) {
[8373] Fix | Delete
foreach ( $shortcodes[3] as $raw_attributes ) {
[8374] Fix | Delete
$attributes = shortcode_parse_atts( $raw_attributes );
[8375] Fix | Delete
$attributes = is_array( $attributes ) ? $attributes : array();
[8376] Fix | Delete
$global_id = (int) et_()->array_get( $attributes, 'global_module', 0 );
[8377] Fix | Delete
[8378] Fix | Delete
if ( $global_id > 0 ) {
[8379] Fix | Delete
$global_modules[] = $global_id;
[8380] Fix | Delete
}
[8381] Fix | Delete
}
[8382] Fix | Delete
}
[8383] Fix | Delete
[8384] Fix | Delete
foreach ( $global_modules as $module_post_id ) {
[8385] Fix | Delete
// Dates are using the Y-m-d H:i:s format so we can compare them as strings for simplicity.
[8386] Fix | Delete
if ( strcmp( get_post_field( 'post_modified', $module_post_id ), $cached_date ) > 0 ) {
[8387] Fix | Delete
// A global module used in the post has been updated more recently than
[8388] Fix | Delete
// the post's cached excerpt so we need to invalidate the cache.
[8389] Fix | Delete
$cached = '';
[8390] Fix | Delete
break;
[8391] Fix | Delete
}
[8392] Fix | Delete
}
[8393] Fix | Delete
}
[8394] Fix | Delete
[8395] Fix | Delete
if ( $cached ) {
[8396] Fix | Delete
return $cached;
[8397] Fix | Delete
}
[8398] Fix | Delete
[8399] Fix | Delete
$custom = apply_filters( 'the_content', $content );
[8400] Fix | Delete
// Save the result because expensive to compute.
[8401] Fix | Delete
update_post_meta( $post->ID, '_et_pb_truncate_post', $custom );
[8402] Fix | Delete
update_post_meta( $post->ID, '_et_pb_truncate_post_date', date( 'Y-m-d H:i:s' ) );
[8403] Fix | Delete
[8404] Fix | Delete
return $custom;
[8405] Fix | Delete
}
[8406] Fix | Delete
endif;
[8407] Fix | Delete
add_filter( 'et_truncate_post_use_custom_content', 'et_divi_truncate_post_use_custom_content', 10, 3 );
[8408] Fix | Delete
[8409] Fix | Delete
/**
[8410] Fix | Delete
* Caches expensive generation of et_first_image
[8411] Fix | Delete
*
[8412] Fix | Delete
* @since 3.17.3
[8413] Fix | Delete
*
[8414] Fix | Delete
* @param bool $custom
[8415] Fix | Delete
* @param string $content
[8416] Fix | Delete
* @param WP_Post $post
[8417] Fix | Delete
*
[8418] Fix | Delete
* @return string
[8419] Fix | Delete
*/
[8420] Fix | Delete
if ( ! function_exists( 'et_divi_first_image_use_custom_content' ) ) :
[8421] Fix | Delete
function et_divi_first_image_use_custom_content( $custom, $content, $post ) {
[8422] Fix | Delete
// If post doesn't use builder, no need to compute a custom value
[8423] Fix | Delete
if ( ! et_pb_is_pagebuilder_used( $post->ID ) ) {
[8424] Fix | Delete
return false;
[8425] Fix | Delete
}
[8426] Fix | Delete
[8427] Fix | Delete
$cached = get_post_meta( $post->ID, '_et_pb_first_image', true );
[8428] Fix | Delete
[8429] Fix | Delete
if ( $cached ) {
[8430] Fix | Delete
return $cached;
[8431] Fix | Delete
}
[8432] Fix | Delete
[8433] Fix | Delete
$custom = apply_filters( 'the_content', $content );
[8434] Fix | Delete
// Save the result because expensive to compute.
[8435] Fix | Delete
update_post_meta( $post->ID, '_et_pb_first_image', $custom );
[8436] Fix | Delete
[8437] Fix | Delete
return $custom;
[8438] Fix | Delete
}
[8439] Fix | Delete
endif;
[8440] Fix | Delete
add_filter( 'et_first_image_use_custom_content', 'et_divi_first_image_use_custom_content', 10, 3 );
[8441] Fix | Delete
[8442] Fix | Delete
/**
[8443] Fix | Delete
* Fired when post is saved in VB / BFB / BB
[8444] Fix | Delete
*
[8445] Fix | Delete
* @since 3.17.3
[8446] Fix | Delete
*
[8447] Fix | Delete
* @param integer $post_id
[8448] Fix | Delete
*
[8449] Fix | Delete
* @return void
[8450] Fix | Delete
*/
[8451] Fix | Delete
if ( ! function_exists( 'et_divi_save_post' ) ) :
[8452] Fix | Delete
function et_divi_save_post( $post_id ) {
[8453] Fix | Delete
if ( ! $post_id ) {
[8454] Fix | Delete
return;
[8455] Fix | Delete
}
[8456] Fix | Delete
[8457] Fix | Delete
// Unset cache
[8458] Fix | Delete
update_post_meta( $post_id, '_et_pb_first_image', false );
[8459] Fix | Delete
update_post_meta( $post_id, '_et_pb_truncate_post', false );
[8460] Fix | Delete
update_post_meta( $post_id, '_et_pb_truncate_post_date', '' );
[8461] Fix | Delete
}
[8462] Fix | Delete
endif;
[8463] Fix | Delete
add_action( 'et_save_post', 'et_divi_save_post', 1 );
[8464] Fix | Delete
[8465] Fix | Delete
if ( ! function_exists( 'et_divi_footer_active_sidebars' ) ):
[8466] Fix | Delete
function et_divi_footer_active_sidebars() {
[8467] Fix | Delete
$et_active_sidebar = array( 2, 3, 4, 5, 6, 7 );
[8468] Fix | Delete
if ( ! is_customize_preview() ) {
[8469] Fix | Delete
if ( ! is_active_sidebar( 2 )
[8470] Fix | Delete
&& ! is_active_sidebar( 3 )
[8471] Fix | Delete
&& ! is_active_sidebar( 4 )
[8472] Fix | Delete
&& ! is_active_sidebar( 5 )
[8473] Fix | Delete
&& ! is_active_sidebar( 6 )
[8474] Fix | Delete
&& ! is_active_sidebar( 7 ) ) {
[8475] Fix | Delete
return false;
[8476] Fix | Delete
}
[8477] Fix | Delete
$footer_columns = et_get_option( 'footer_columns', '4' );
[8478] Fix | Delete
switch ( $footer_columns ) {
[8479] Fix | Delete
case '1':
[8480] Fix | Delete
case '2':
[8481] Fix | Delete
case '3':
[8482] Fix | Delete
case '4':
[8483] Fix | Delete
case '5':
[8484] Fix | Delete
case '6':
[8485] Fix | Delete
$et_active_sidebar = array();
[8486] Fix | Delete
for ( $i = 1; $i <= $footer_columns; $i++ ) {
[8487] Fix | Delete
array_push( $et_active_sidebar, ( $i + 1 ) );
[8488] Fix | Delete
}
[8489] Fix | Delete
break;
[8490] Fix | Delete
case '_1_4__3_4':
[8491] Fix | Delete
case '_3_4__1_4':
[8492] Fix | Delete
case '_1_3__2_3':
[8493] Fix | Delete
case '_2_3__1_3':
[8494] Fix | Delete
case '_3_5__2_5':
[8495] Fix | Delete
case '_2_5__3_5':
[8496] Fix | Delete
$et_active_sidebar = array( 2, 3 );
[8497] Fix | Delete
break;
[8498] Fix | Delete
case '_1_4__1_2':
[8499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function