: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
'epanel' => 'epanel_portability',
$cap = et_()->array_get( $context_caps, $context, '' );
if ( ! empty( $cap ) && ! et_pb_is_allowed( $cap ) ) {
return et_core_portability_link( $context, $attributes );
* Get the list of all public post types.
function et_builder_get_public_post_types() {
$cache_key = 'et_builder_get_public_post_types';
if ( ! et_core_cache_has( $cache_key ) ) {
$blocklist = array_merge( array(
ET_THEME_BUILDER_TEMPLATE_POST_TYPE,
), et_theme_builder_get_layout_post_types() );
$all_post_types = get_post_types( array(), 'objects' );
foreach ( $all_post_types as $post_type ) {
if ( ! in_array( $post_type->name, $blocklist, true ) && et_builder_is_post_type_public( $post_type->name ) ) {
$post_types[ $post_type->name ] = $post_type;
et_core_cache_add( $cache_key, $post_types );
* Filter array of public post types.
return apply_filters( 'et_builder_get_public_post_types', et_core_cache_get( $cache_key ) );
* Clear public post type cache whenever a custom post type is registered.
function et_builder_clear_get_public_post_types_cache() {
et_core_cache_delete( 'et_builder_get_public_post_types' );
add_action( 'registered_post_type', 'et_builder_clear_get_public_post_types_cache' );
if ( ! function_exists( 'et_filter_intermediate_image_sizes_advanced' ) ):
* Filters the image sizes to calculate responsive image height.
* @param array $sizes An associative array of image sizes.
* @param array $metadata An associative array of image metadata: width, height, file.
function et_filter_intermediate_image_sizes_advanced( $sizes, $metadata = array() ) {
// Bail early when the attachment metadata is empty.
foreach ( array_keys( $sizes ) as $size_key ) {
if ( strpos( $size_key, 'et-pb-image--responsive--' ) !== 0 ) {
$breakpoint = str_replace( 'et-pb-image--responsive--', '', $size_key );
$responsive_size = et_image_get_responsive_size( $metadata['width'], $metadata['height'], $breakpoint );
if ( $responsive_size && isset( $responsive_size['width'] ) && isset( $responsive_size['height'] ) ) {
$sizes[ $size_key ]['width'] = $responsive_size['width'];
$sizes[ $size_key ]['height'] = $responsive_size['height'];
unset( $sizes[ $size_key ] );
add_filter( 'intermediate_image_sizes_advanced', 'et_filter_intermediate_image_sizes_advanced', 10, 2 );
if ( ! function_exists( 'et_action_sync_attachment_data_cache' ) ) :
* @param int $attachment_id Attachment ID.
* @param array $metadata Image metadata.
function et_action_sync_attachment_data_cache( $attachment_id, $metadata = null ) {
if ( ! $attachment_id ) {
$url_full = wp_get_attachment_url( $attachment_id );
// Normalize image URL to remove the HTTP/S protocol.
$normalized_url_full = et_attachment_normalize_url( $url_full );
if ( ! $normalized_url_full ) {
$normalized_urls = array(
$normalized_url_full => $normalized_url_full,
if ( is_null( $metadata ) ) {
$metadata = wp_get_attachment_metadata( $attachment_id );
if ( ! empty( $metadata ) ) {
foreach( $metadata['sizes'] as $image_size ) {
$normalized_url = str_replace( basename( $normalized_url_full ), $image_size['file'], $normalized_url_full );
if ( ! isset( $normalized_urls[ $normalized_url ] ) ) {
$normalized_urls[ $normalized_url ] = $normalized_url;
'attachment_size_by_url',
'image_responsive_metadata',
foreach ( $cache_keys as $cache_key ) {
$cache = ET_Core_Cache_File::get( $cache_key );
// Skip if the cache data is empty.
foreach ( $normalized_urls as $normalized_url ) {
unset( $cache[ $normalized_url ] );
ET_Core_Cache_File::set( $cache_key, $cache );
add_action( 'delete_attachment', 'et_action_sync_attachment_data_cache' );
if ( ! function_exists( 'et_filter_wp_generate_attachment_metadata' ) ):
* Sync the cached srcset data when attachment meta data generated/updated.
* @param array $metadata An array of attachment meta data.
* @param int $attachment_id Current attachment ID.
function et_filter_wp_generate_attachment_metadata( $metadata, $attachment_id = 0 ) {
et_action_sync_attachment_data_cache( $attachment_id, $metadata );
add_filter( 'wp_generate_attachment_metadata', 'et_filter_wp_generate_attachment_metadata', 10, 2 );
* Filter the main query paged arg to avoid pagination clashes with the Blog module pagination.
function et_builder_filter_main_query_paged_for_blog_module( $query ) {
* Utility which holds the current page number for the Blog module.
* Necessary to avoid clashes with the main query pagination.
global $__et_blog_module_paged;
if ( isset( $_GET['et_blog'] ) && $query->is_main_query() ) {
$__et_blog_module_paged = $query->get( 'paged' );
$query->set( 'paged', 0 );
add_filter( 'pre_get_posts', 'et_builder_filter_main_query_paged_for_blog_module' );
if ( ! function_exists( 'et_maybe_enable_embed_shortcode' ) ):
* Maybe enable [embed] shortcode at the content.
* @param boolean $is_content
function et_maybe_enable_embed_shortcode( $content, $is_content ) {
if ( $is_content && has_shortcode( $content, 'embed' ) ) {
$content = $wp_embed->run_shortcode( $content );
* Register custom sidebars.
* @since 4.4.8 Moved from builder/functions.php, so it can be loaded on wp_ajax_save_widget()
function et_builder_widgets_init() {
$et_pb_widgets = get_theme_mod( 'et_pb_widgets' );
$widget_areas = et_()->array_get( $et_pb_widgets, 'areas', array() );
if ( ! empty( $widget_areas ) ) {
foreach ( $widget_areas as $id => $name ) {
'name' => sanitize_text_field( $name ),
'id' => sanitize_text_field( $id ),
'before_widget' => '<div id="%1$s" class="et_pb_widget %2$s">',
'after_widget' => '</div> <!-- end .et_pb_widget -->',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>',
// Disable built-in's recent comments widget link styling because ET Themes don't need it.
if ( ! et_is_builder_plugin_active() ) {
add_filter( 'show_recent_comments_widget_style', '__return_false' );
// Call the widgets init at 'init' hook if Divi Builder plugin active because plugin
// loads the Divi builder at 'init' hook and 'widgets_init' is too early.
if ( et_is_builder_plugin_active() ) {
add_action( 'init', 'et_builder_widgets_init', 20 );
add_action( 'widgets_init', 'et_builder_widgets_init' );