: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( ! function_exists( 'et_allow_ampersand' ) ) :
* Escaped ampersand by wp_kses() which is used by et_get_safe_localization()
* can be a troublesome in some cases, ie.: when string is sent in an email.
* @param string $string original string
* @return string modified string
function et_allow_ampersand( $string ) {
return str_replace('&', '&', $string);
if ( ! function_exists( 'et_core_autoloader' ) ):
* Callback for {@link spl_autoload_register()}.
function et_core_autoloader( $class_name ) {
if ( 0 !== strpos( $class_name, 'ET_Core' ) ) {
static $components = null;
static $groups_loaded = array();
if ( null === $components ) {
$components = et_core_get_components_metadata();
if ( ! isset( $components[ $class_name ] ) ) {
$file = ET_CORE_PATH . $components[ $class_name ]['file'];
$groups = $components[ $class_name ]['groups'];
$slug = $components[ $class_name ]['slug'];
if ( ! file_exists( $file ) ) {
* Fires when a Core Component is loaded.
* The dynamic portion of the hook name, $slug, refers to the slug of the Core Component that was loaded.
do_action( "et_core_component_{$slug}_loaded" );
if ( empty( $groups ) ) {
foreach( $groups as $group_name ) {
if ( in_array( $group_name, $groups_loaded ) ) {
$groups_loaded[] = $group_name;
$slug = $components['groups'][ $group_name ]['slug'];
$init_file = $components['groups'][ $group_name ]['init'];
$init_file = empty( $init_file ) ? null : ET_CORE_PATH . $init_file;
et_core_initialize_component_group( $slug, $init_file );
if ( ! function_exists( 'et_core_clear_transients' ) ):
function et_core_clear_transients() {
delete_transient( 'et_core_path' );
delete_transient( 'et_core_version' );
delete_transient( 'et_core_needs_old_theme_patch' );
add_action( 'upgrader_process_complete', 'et_core_clear_transients', 10, 0 );
add_action( 'switch_theme', 'et_core_clear_transients' );
add_action( 'update_option_active_plugins', 'et_core_clear_transients', 10, 0 );
add_action( 'update_site_option_active_plugins', 'et_core_clear_transients', 10, 0 );
if ( ! function_exists( 'et_core_cron_schedules_cb' ) ):
function et_core_cron_schedules_cb( $schedules ) {
if ( isset( $schedules['monthly'] ) ) {
$schedules['monthly'] = array(
'interval' => MONTH_IN_SECONDS,
'display' => __( 'Once Monthly' )
add_action( 'cron_schedules', 'et_core_cron_schedules_cb' );
if ( ! function_exists( 'et_core_die' ) ):
function et_core_die( $message = '' ) {
$message = '' !== $message ? $message : esc_html__( 'Configuration Error', 'et_core' );
wp_send_json_error( array( 'error' => $message ) );
if ( ! function_exists( 'et_core_get_components_metadata' ) ):
function et_core_get_components_metadata() {
if ( null === $metadata ) {
require_once '_metadata.php';
$metadata = json_decode( $metadata, true );
if ( ! function_exists( 'et_core_get_component_names' ) ):
* Returns the names of all available components, optionally filtered by type and/or group.
* @param string $include The type of components to include (official|third-party|all). Default is 'official'.
* @param string $group Only include components in $group. Optional.
function et_core_get_component_names( $include = 'official', $group = '' ) {
static $official_components = null;
if ( null === $official_components ) {
$official_components = et_core_get_components_metadata();
if ( 'official' === $include ) {
return empty( $group ) ? $official_components['names'] : $official_components['groups'][ $group ]['members'];
$third_party_components = et_core_get_third_party_components();
if ( 'third-party' === $include ) {
return array_keys( $third_party_components );
array_keys( $third_party_components ),
empty( $group ) ? $official_components['names'] : $official_components['groups'][ $group ]['members']
if ( ! function_exists( 'et_core_get_ip_address' ) ):
* Returns the IP address of the client that initiated the current HTTP request.
function et_core_get_ip_address() {
// Array of headers that could contain a valid IP address.
'HTTP_X_SUCURI_CLIENTIP',
'HTTP_X_CLUSTER_CLIENT_IP',
foreach ( $headers as $header ) {
// Skip if the header is not set.
if ( empty( $_SERVER[ $header ] ) ) {
$header = $_SERVER[ $header ];
if ( et_()->includes( $header, ',' ) ) {
$header = explode( ',', $header );
// Break if valid IP address is found.
if ( filter_var( $header, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE ) ) {
$ip = sanitize_text_field( $header );
if ( ! function_exists( 'et_core_use_google_fonts' ) ) :
function et_core_use_google_fonts() {
$utils = ET_Core_Data_Utils::instance();
$google_api_options = get_option( 'et_google_api_settings' );
return 'on' === $utils->array_get( $google_api_options, 'use_google_fonts', 'on' );
if ( ! function_exists( 'et_core_get_main_fonts' ) ) :
function et_core_get_main_fonts() {
if ( version_compare( $wp_version, '4.6', '<' ) || ( ! is_admin() && ! et_core_use_google_fonts() ) ) {
/* 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';
$protocol = is_ssl() ? 'https' : 'http';
'family' => implode( '%7C', $font_families ),
'subset' => 'latin,latin-ext',
$fonts_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" );
if ( ! function_exists( 'et_core_get_theme_info' ) ):
function et_core_get_theme_info( $key ) {
static $theme_info = null;
$theme_info = wp_get_theme();
if ( defined( 'STYLESHEETPATH' ) && is_child_theme() ) {
$theme_info = wp_get_theme( $theme_info->parent_theme );
return $theme_info->display( $key );
if ( ! function_exists( 'et_core_get_third_party_components' ) ):
function et_core_get_third_party_components( $group = '' ) {
static $third_party_components = null;
if ( null !== $third_party_components ) {
return $third_party_components;
* 3rd-party components can be registered by adding the class instance to this array using it's name as the key.
* @param array $third_party {
* An array mapping third party component names to a class instance reference.
* @type ET_Core_3rdPartyComponent $name The component class instance.
* @param string $group If not empty, only components classified under this group should be included.
return $third_party_components = apply_filters( 'et_core_get_third_party_components', array(), $group );
if ( ! function_exists( 'et_core_get_memory_limit' ) ):
* Returns the current php memory limit in megabytes as an int.
function et_core_get_memory_limit() {
// Do NOT convert value to the integer, because wp_convert_hr_to_bytes() expects raw value from php_ini like 128M, 256M, 512M, etc
$limit = @ini_get( 'memory_limit' );
$mb_in_bytes = 1024*1024;
$bytes = max( wp_convert_hr_to_bytes( $limit ), $mb_in_bytes );
return ceil( $bytes / $mb_in_bytes );
if ( ! function_exists( 'et_core_initialize_component_group' ) ):
function et_core_initialize_component_group( $slug, $init_file = null ) {
$slug = strtolower( $slug );
if ( null !== $init_file && file_exists( $init_file ) ) {
// Load and run component group's init function
$init = "et_core_{$slug}_init";
* Fires when a Core Component Group is loaded.
* The dynamic portion of the hook name, `$group`, refers to the name of the Core Component Group that was loaded.
do_action( "et_core_{$slug}_loaded" );
if ( ! function_exists( 'et_core_is_builder_used_on_current_request' ) ) :
function et_core_is_builder_used_on_current_request() {
static $builder_used = null;
if ( null !== $builder_used ) {
ET_Core_Logger::error( 'Called too early! $wp_query is not available.' );
if ( ! empty( $wp_query->posts ) ) {
foreach ( $wp_query->posts as $post ) {
if ( 'on' === get_post_meta( $post->ID, '_et_pb_use_builder', true ) ) {
} else if ( ! empty( $wp_query->post ) ) {
if ( 'on' === get_post_meta( $wp_query->post->ID, '_et_pb_use_builder', true ) ) {
return $builder_used = apply_filters( 'et_core_is_builder_used_on_current_request', $builder_used );
if ( ! function_exists( 'et_core_is_fb_enabled' ) ):
function et_core_is_fb_enabled() {
if ( function_exists( 'et_fb_is_enabled' ) ) {
return et_fb_is_enabled();
return isset( $_GET['et_fb'] ) && current_user_can( 'edit-posts' );
if ( ! function_exists( 'et_core_is_saving_builder_modules_cache' ) ):
function et_core_is_saving_builder_modules_cache() {
// This filter is set when Modules Cache is being saved.
return apply_filters( 'et_builder_modules_is_saving_cache', false );
* @since 3.19.2 Renamed from {@see et_is_gutenberg_active()} and moved to core.
* @return bool True - if the plugin is active
if ( ! function_exists( 'et_core_is_gutenberg_active' ) ):
function et_core_is_gutenberg_active() {
static $has_wp5_plus = null;
if ( is_null( $has_wp5_plus ) ) {
$has_wp5_plus = version_compare( $wp_version, '5.0-alpha1', '>=' );
return $has_wp5_plus || function_exists( 'is_gutenberg_page' );
* Is Gutenberg active and enabled for the current post
* WP 5.0 WARNING - don't use before global post has been set
* @since 3.19.2 Renamed from {@see et_is_gutenberg_enabled()} and moved to core.
* @return bool True - if the plugin is active and enabled.
if ( ! function_exists( 'et_core_is_gutenberg_enabled' ) ):
function et_core_is_gutenberg_enabled() {
if ( function_exists( 'is_gutenberg_page' ) ) {
return et_core_is_gutenberg_active() && is_gutenberg_page() && has_filter( 'replace_editor', 'gutenberg_init' );
return et_core_is_gutenberg_active() && function_exists( 'use_block_editor_for_post' ) && use_block_editor_for_post( null );
if ( ! function_exists( 'et_core_load_main_fonts' ) ) :
function et_core_load_main_fonts() {
$fonts_url = et_core_get_main_fonts();
if ( empty( $fonts_url ) ) {
wp_enqueue_style( 'et-core-main-fonts', esc_url_raw( $fonts_url ), array(), null );
if ( ! function_exists( 'et_core_load_main_styles' ) ) :
function et_core_load_main_styles( $hook ) {
if ( ! in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
wp_enqueue_style( 'et-core-admin' );
if ( ! function_exists( 'et_core_maybe_set_updated' ) ):
function et_core_maybe_set_updated() {
// TODO: Move et_{*}_option() functions to core.
$last_core_version = get_option( 'et_core_version', '' );
if ( ET_CORE_VERSION === $last_core_version ) {
update_option( 'et_core_version', ET_CORE_VERSION );
define( 'ET_CORE_UPDATED', true );
if ( ! function_exists( 'et_core_maybe_patch_old_theme' ) ):
function et_core_maybe_patch_old_theme() {
if ( ! ET_Core_Logger::php_notices_enabled() ) {
if ( get_transient( 'et_core_needs_old_theme_patch' ) ) {
add_action( 'after_setup_theme', 'ET_Core_Logger::disable_php_notices', 9 );
add_action( 'after_setup_theme', 'ET_Core_Logger::enable_php_notices', 11 );
$themes = array( 'Divi' => '3.0.41', 'Extra' => '2.0.40' );