hed ) { return $cached; } $custom = apply_filters( 'the_content', $content ); // Save the result because expensive to compute. update_post_meta( $post->ID, '_et_pb_truncate_post', $custom ); update_post_meta( $post->ID, '_et_pb_truncate_post_date', date( 'Y-m-d H:i:s' ) ); return $custom; } endif; add_filter( 'et_truncate_post_use_custom_content', 'et_divi_truncate_post_use_custom_content', 10, 3 ); /** * Caches expensive generation of et_first_image * * @since 3.17.3 * * @param bool $custom * @param string $content * @param WP_Post $post * * @return string */ if ( ! function_exists( 'et_divi_first_image_use_custom_content' ) ) : function et_divi_first_image_use_custom_content( $custom, $content, $post ) { // If post doesn't use builder, no need to compute a custom value if ( ! et_pb_is_pagebuilder_used( $post->ID ) ) { return false; } $cached = get_post_meta( $post->ID, '_et_pb_first_image', true ); if ( $cached ) { return $cached; } $custom = apply_filters( 'the_content', $content ); // Save the result because expensive to compute. update_post_meta( $post->ID, '_et_pb_first_image', $custom ); return $custom; } endif; add_filter( 'et_first_image_use_custom_content', 'et_divi_first_image_use_custom_content', 10, 3 ); /** * Fired when post is saved in VB / BFB / BB * * @since 3.17.3 * * @param integer $post_id * * @return void */ if ( ! function_exists( 'et_divi_save_post' ) ) : function et_divi_save_post( $post_id ) { if ( ! $post_id ) { return; } // Unset cache update_post_meta( $post_id, '_et_pb_first_image', false ); update_post_meta( $post_id, '_et_pb_truncate_post', false ); update_post_meta( $post_id, '_et_pb_truncate_post_date', '' ); } endif; add_action( 'et_save_post', 'et_divi_save_post', 1 ); if ( ! function_exists( 'et_divi_footer_active_sidebars' ) ): function et_divi_footer_active_sidebars() { $et_active_sidebar = array( 2, 3, 4, 5, 6, 7 ); if ( ! is_active_sidebar( 2 ) && ! is_active_sidebar( 3 ) && ! is_active_sidebar( 4 ) && ! is_active_sidebar( 5 ) && ! is_active_sidebar( 6 ) && ! is_active_sidebar( 7 ) ) { return false; } $footer_columns = et_get_option( 'footer_columns', '4' ); switch ( $footer_columns ) { case '1': case '2': case '3': case '4': case '5': case '6': $et_active_sidebar = array(); for ( $i = 1; $i <= $footer_columns; $i++ ) { array_push( $et_active_sidebar, ( $i + 1 ) ); } break; case '_1_4__3_4': case '_3_4__1_4': case '_1_3__2_3': case '_2_3__1_3': case '_3_5__2_5': case '_2_5__3_5': $et_active_sidebar = array( 2, 3 ); break; case '_1_4__1_2': case '_1_2__1_4': case '_1_5__3_5': case '_3_5__1_5': case '_1_4_1_2_1_4': case '_1_5_3_5_1_5': $et_active_sidebar = array( 2, 3, 4 ); break; case '_1_2__1_6': case '_1_6__1_2': $et_active_sidebar = array( 2, 3, 4, 5 ); break; } return $et_active_sidebar; } endif; /** * Check if the theme has boxed layout enabled * * @return bool */ function et_divi_is_boxed_layout() { return true === et_get_option( 'boxed_layout', false ); } /** * Get current theme content container width * * @return int */ function et_divi_get_content_width() { $value = absint( et_get_option( 'content_width', 1080 ) ); return ( 1080 === $value && et_divi_is_boxed_layout() ) ? 1200 : $value; } /** * Disable Theme Builder header and footer layouts, if any, on the blank page template. * * @since ?? * * @param array $layouts * * @return array */ function et_divi_disable_theme_builder_header_footer_on_blank_template( $layouts ) { if ( ! is_page_template('page-template-blank.php') || empty( $layouts ) ) { return $layouts; } $layouts[ ET_THEME_BUILDER_HEADER_LAYOUT_POST_TYPE ]['id'] = 0; $layouts[ ET_THEME_BUILDER_HEADER_LAYOUT_POST_TYPE ]['enabled'] = false; $layouts[ ET_THEME_BUILDER_HEADER_LAYOUT_POST_TYPE ]['override'] = false; $layouts[ ET_THEME_BUILDER_FOOTER_LAYOUT_POST_TYPE ]['id'] = 0; $layouts[ ET_THEME_BUILDER_FOOTER_LAYOUT_POST_TYPE ]['enabled'] = false; $layouts[ ET_THEME_BUILDER_FOOTER_LAYOUT_POST_TYPE ]['override'] = false; return $layouts; } add_filter( 'et_theme_builder_template_layouts', 'et_divi_disable_theme_builder_header_footer_on_blank_template' ); /** * Remove invalid `frameborder` attribute from YouTube oEmbed iframe tags. * * @since ?.? * * @param string $html HTML string returned from oEmbed process. * @param object $data Payload returned for oEmded processing. * @param string $url URL originally passed to oEmbed process. * @return string The iframe HTML snippet (modified or unmodified). */ function et_divi_oembed_dataparse_remove_yt_frameborder( $html, $data, $url ) { // Array of possible matches for known YouTube domain names. $matches = array( 'youtube.com', 'youtu.be', 'youtube-nocookie.com', '.youtube.', ); foreach ( $matches as $match ) { // If we find a matching domain, strip out any frameborder attr before returning. if ( false !== strpos( $url, $match ) ) { return str_replace( 'frameborder="0"', '', $html ); } } // If there's no URL match, return the HTML string without modification. return $html; } add_filter( 'oembed_dataparse', 'et_divi_oembed_dataparse_remove_yt_frameborder', 10, 3 );