: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( $third_party_plugins_active ) {
'%1$s <a href="%3$s" class="et_builder_modal_action_button" target="_blank">%2$s</a>',
esc_html__( 'You are using third party plugins. Try disabling each plugin to see if one is causing a conflict.', 'et_builder' ),
esc_html__( 'Manage Your Plugins', 'et_builder' ),
esc_url( admin_url( 'plugins.php' ) )
// WordPress update check
require_once( ABSPATH . 'wp-admin/includes/update.php' );
$updates = get_core_updates();
if ( isset( $updates[0]->response ) && 'latest' !== $updates[0]->response ) {
'%1$s <a href="%3$s" class="et_builder_modal_action_button" target="_blank">%2$s</a>',
esc_html__( 'You are using an outdated version of WordPress. Please upgrade.', 'et_builder' ),
esc_html__( 'Upgrade WordPress', 'et_builder' ),
esc_url( admin_url( 'update-core.php' ) )
global $et_current_memory_limit;
if ( ! empty( $et_current_memory_limit ) && intval( $et_current_memory_limit ) < 128 ) {
$class = ' et_builder_increase_memory';
'%1$s. <a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" class="et_builder_modal_action_button%3$s" target="_blank">%2$s</a>',
esc_html__( 'Please increase your PHP Memory Limit. You can return the value to default via the Divi Theme Options in the future', 'et_builder' ),
esc_html__( 'Increase Your Memory Limit Now', 'et_builder' ),
$et_update_themes = get_site_transient( 'et_update_themes' );
if ( is_object( $et_update_themes ) && isset( $et_update_themes->response ) ) {
$theme_info = wp_get_theme();
if ( is_child_theme() ) {
$theme_info = wp_get_theme( $theme_info->parent_theme );
$name = $theme_info->get( 'Name' );
$version = $theme_info->get( 'Version' );
if ( isset( $et_update_themes->response[ $name ] ) && isset( $et_update_themes->response[ $name ]['new_version'] ) && version_compare( $version, $et_update_themes->response[ $name ]['new_version'], '<' ) ) {
'%1$s <a href="%3$s" class="et_builder_modal_action_button" target="_blank">%2$s</a>',
esc_html__( 'You are using an outdated version of the theme. The latest version is %1$s', 'et_builder' ),
esc_html( $et_update_themes->response[ $name ]['new_version'] )
esc_html__( 'Upgrade', 'et_builder' ),
esc_url( admin_url( 'themes.php' ) )
if ( empty( $warnings ) ) {
if ( ! function_exists( 'et_increase_memory_limit' ) ) :
function et_increase_memory_limit() {
if ( ! current_user_can( 'edit_posts' ) ) {
// proceed only if current memory limit < 256
if ( et_core_get_memory_limit() >= 256 ) {
$result = @ini_set( 'memory_limit', '256M' );
return ! empty( $result );
if ( ! function_exists( 'et_maybe_increase_memory_limit' ) ) :
function et_maybe_increase_memory_limit() {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
if ( ! current_user_can( 'edit_posts' ) ) {
if ( empty( $pagenow ) ) {
// increase memory limit on Edit Post page only
if ( ! in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) {
* check if a user clicked "Increase Memory Limit" button
* in the "Failure Notification" modal window
if ( ! et_should_memory_limit_increase() ) {
et_increase_memory_limit();
add_action( 'admin_init', 'et_maybe_increase_memory_limit' );
if ( ! function_exists( 'et_should_memory_limit_increase' ) ) :
function et_should_memory_limit_increase() {
if ( '1' === ( $memory_limit = et_get_option( 'set_memory_limit' ) ) ) {
if ( ! function_exists( 'et_reset_memory_limit_increase_setting' ) ) :
function et_reset_memory_limit_increase_setting() {
wp_enqueue_script( 'et-builder-reset-memory-limit-increase', ET_BUILDER_URI . '/scripts/reset_memory_limit_increase_setting.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
wp_localize_script( 'et-builder-reset-memory-limit-increase', 'et_reset_memory_limit_increase', array(
'et_builder_reset_memory_limit_nonce' => wp_create_nonce( 'et_builder_reset_memory_limit_nonce' ),
'<button class="et_disable_memory_limit_increase button button-primary button-large">%1$s</button>',
esc_html__( 'Disable Memory Limit Increase' )
if ( ! function_exists( 'et_pb_detect_cache_plugins' ) ) :
* Detect the activated cache plugins and return the link to plugin options and return its page link or false
function et_pb_detect_cache_plugins() {
if ( function_exists( 'edd_w3edge_w3tc_activate_license' ) ) {
'name' => 'W3 Total Cache',
'page' => 'admin.php?page=w3tc_pgcache',
if ( function_exists( 'wpsupercache_activate' ) ) {
'name' => 'WP Super Cache',
'page' => 'options-general.php?page=wpsupercache',
if ( class_exists( 'HyperCache' ) ) {
'page' => 'options-general.php?page=hyper-cache%2Foptions.php',
if ( class_exists( '\zencache\plugin' ) ) {
'page' => 'admin.php?page=zencache',
if ( class_exists( 'WpFastestCache' ) ) {
'name' => 'WP Fastest Cache',
'page' => 'admin.php?page=WpFastestCacheOptions',
if ( '1' === get_option( 'wordfenceActivated' ) ) {
// Wordfence removed their support of Falcon cache in v6.2.8, so we'll
// just check against their `cacheType` setting (if it exists).
if ( class_exists( 'wfConfig' ) && 'falcon' === wfConfig::get( 'cacheType' ) ) {
'page' => 'admin.php?page=WordfenceSitePerf',
if ( function_exists( 'cachify_autoload' ) ) {
'page' => 'options-general.php?page=cachify',
if ( class_exists( 'FlexiCache' ) ) {
'page' => 'options-general.php?page=flexicache',
if ( function_exists( 'rocket_init' ) ) {
'page' => 'options-general.php?page=wprocket',
if ( function_exists( 'cloudflare_init' ) ) {
'page' => 'options-general.php?page=cloudflare',
if ( class_exists( 'Hummingbird\\WP_Hummingbird' ) ) {
'page' => 'admin.php?page=wphb',
function et_pb_force_regenerate_templates() {
// add option to indicate that templates cache should be updated in case of term added/removed/updated
et_update_option( 'et_pb_clear_templates_cache', true );
// Delete cached definitions / helpers
et_fb_delete_builder_assets();
add_action( 'created_term', 'et_pb_force_regenerate_templates' );
add_action( 'edited_term', 'et_pb_force_regenerate_templates' );
add_action( 'delete_term', 'et_pb_force_regenerate_templates' );
//@Todo we should remove this hook after BB is retired
//purge BB microtemplates cache after Theme Customizer changes
add_action( 'customize_save_after', 'et_pb_force_regenerate_templates' );
function et_pb_ab_get_current_ab_module_id( $test_id, $subject_index = false ) {
$all_subjects = false !== ( $all_subjects_raw = get_post_meta( $test_id, '_et_pb_ab_subjects' , true ) ) ? explode( ',', $all_subjects_raw ) : array();
if ( false === $subject_index ) {
$current_subject_index = false !== ( $saved_next_subject = get_post_meta( $test_id, '_et_pb_ab_next_subject' , true ) ) ? (int) $saved_next_subject : 0;
$current_subject_index = $subject_index;
if ( empty( $all_subjects ) ) {
if ( ! isset( $all_subjects[ $current_subject_index ] ) ) {
return $all_subjects[ $current_subject_index ];
* Increment current subject index value on post meta
function et_pb_ab_increment_current_ab_module_id( $test_id ) {
// Get subjects and current subject index
$all_subjects_raw = get_post_meta( $test_id, '_et_pb_ab_subjects' , true );
$all_subjects = false !== $all_subjects_raw ? explode( ',', $all_subjects_raw ) : array();
$saved_next_subject = get_post_meta( $test_id, '_et_pb_ab_next_subject' , true );
$current_subject_index = false !== $saved_next_subject ? (int) $saved_next_subject : 0;
if ( empty( $all_subjects ) ) {
// increment the index of next subject, set to 0 if it's a last subject in the list
$next_subject_index = ( count( $all_subjects ) - 1 ) < ( $current_subject_index + 1 ) ? 0 : $current_subject_index + 1;
update_post_meta( $test_id, '_et_pb_ab_next_subject' , $next_subject_index );
* Add the record into AB Testing log table
function et_pb_add_stats_record( $stats_data_array ) {
$table_name = $wpdb->prefix . 'et_divi_ab_testing_stats';
$record_date = current_time( 'mysql' );
$test_id = intval( $stats_data_array['test_id'] );
$subject_id = intval( $stats_data_array['subject_id'] );
$record_type = sanitize_text_field( $stats_data_array['record_type'] );
$record_date = sanitize_text_field( $record_date );
// Check visitor cookie and do not proceed if event already logged for current visitor
if ( et_pb_ab_get_visitor_cookie( $test_id, $record_date ) ) {
'record_date' => $record_date,
'subject_id' => $subject_id,
* Set AB Testing formatted cookie
* @since 4.4.3 Set cookie path, so the cookie will be available on overall site.
* @param string record type
* @param mixed cookie value
function et_pb_ab_set_visitor_cookie( $post_id, $record_type, $value = true ) {
$unique_test_id = get_post_meta( $post_id, '_et_pb_ab_testing_id', true );
$cookie_name = sanitize_text_field( "et_pb_ab_{$record_type}_{$post_id}{$unique_test_id}" );
return setcookie( $cookie_name, $value, 0, SITECOOKIEPATH );
* Get AB Testing formatted cookie
* @param string record type
function et_pb_ab_get_visitor_cookie( $post_id, $record_type ) {
$unique_test_id = get_post_meta( $post_id, '_et_pb_ab_testing_id', true );
$cookie_name = "et_pb_ab_{$record_type}_{$post_id}{$unique_test_id}";
return isset( $_COOKIE[ $cookie_name ] ) ? $_COOKIE[ $cookie_name ] : false;
* Get subjects of particular post / AB Testing
* @param string array|string type of output
* @param mixed string|bool prefix that should be prepended
function et_pb_ab_get_subjects( $post_id, $type = 'array', $prefix = false, $is_cron_task = false ) {
$subjects_data = get_post_meta( $post_id, '_et_pb_ab_subjects', true );
$fb_enabled = function_exists( 'et_fb_enabled' ) ? et_fb_enabled() : false;
// Get autosave/draft subjects if post hasn't been published
if ( ! $is_cron_task && ! $subjects_data && $fb_enabled && 'publish' !== get_post_status() ) {
$subjects_data = get_post_meta( $post_id, '_et_pb_ab_subjects_draft', true );
if ( 'string' === $type ) {
$subjects = explode(',', $subjects_data );
if ( ! empty( $subjects ) && $prefix ) {
$prefixed_subjects = array();
// Loop subject, add prefix
foreach ( $subjects as $subject ) {
$prefixed_subjects[] = $prefix . (string) $subject;
return $prefixed_subjects;
* Unhashed hashed subject id
* @param string hashed subject id
* @return string subject ID
function et_pb_ab_unhashed_subject_id( $post_id, $hashed_subject_id ) {
if ( ! $post_id || ! $hashed_subject_id ) {
$ab_subjects = et_pb_ab_get_subjects( $post_id );
$ab_hash_key = defined( 'NONCE_SALT' ) ? NONCE_SALT : 'default-divi-hash-key';
// Compare subjects against hashed subject id found on cookie to verify whether cookie value is valid or not
foreach ( $ab_subjects as $ab_subject ) {
// Valid subject_id is found
if ( hash_hmac( 'md5', $ab_subject, $ab_hash_key ) === $hashed_subject_id ) {
$subject_id = $ab_subject;
// If no valid subject found, get the first one
if ( ! $subject_id && isset( $ab_subjects[0] ) ) {
$subject_id = $ab_subjects[0];
function et_pb_ab_get_subject_id() {
if ( ! isset( $_POST['et_frontend_nonce'] ) || ! wp_verify_nonce( $_POST['et_frontend_nonce'], 'et_frontend_nonce' ) ) {
$test_id = intval( $_POST['et_pb_ab_test_id'] );
$hashed_subject_id = et_pb_ab_get_visitor_cookie( $test_id, 'view_page' );
$current_ab_module_id = et_pb_ab_unhashed_subject_id( $test_id, $hashed_subject_id );
// retrieve the cached subjects HTML
$subjects_cache = get_post_meta( $test_id, 'et_pb_subjects_cache', true );
'id' => $current_ab_module_id,
'content' => isset( $subjects_cache[ $current_ab_module_id ] ) ? $subjects_cache[ $current_ab_module_id ] : '',
die( wp_json_encode( $result ) );
add_action( 'wp_ajax_et_pb_ab_get_subject_id', 'et_pb_ab_get_subject_id' );
add_action( 'wp_ajax_nopriv_et_pb_ab_get_subject_id', 'et_pb_ab_get_subject_id' );
* Register Builder Portability.
function et_pb_register_builder_portabilities() {
// Don't overwrite global.
$_shortname = empty( $shortname ) ? 'divi' : $shortname;
// Make sure the Portability is loaded.
et_core_load_component( 'portability' );
if ( current_user_can( 'edit_theme_options' ) ) {
// Register the Roles Editor portability.
et_core_portability_register( 'et_pb_roles', array(
'name' => esc_html__( 'Divi Role Editor Settings', 'et_builder' ),