: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( ! function_exists( 'et_builder_email_maybe_migrate_accounts') ):
function et_builder_email_maybe_migrate_accounts() {
$divi_migrated_key = 'divi_email_provider_credentials_migrated';
$builder_migrated_key = 'email_provider_credentials_migrated';
$builder_options = (array) get_option( 'et_pb_builder_options' );
$builder_migrated = isset( $builder_options[ $builder_migrated_key ] );
$divi_migrated = false !== et_get_option( $divi_migrated_key, false );
$data_utils = ET_Core_Data_Utils::instance();
$migrations = array( 'builder' => $builder_migrated, 'divi' => $divi_migrated );
$providers = new ET_Core_API_Email_Providers(); // Ensure the email component group is loaded.
if ( $data_utils->all( $migrations, true ) ) {
// We've already migrated accounts data
foreach ( $migrations as $product => $completed ) {
if ( 'builder' === $product ) {
$account_name = 'Divi Builder Plugin';
$mailchimp_api_key = isset( $builder_options['newsletter_main_mailchimp_key'] ) ? $builder_options['newsletter_main_mailchimp_key'] : '';
$consumer_key = isset( $builder_options['aweber_consumer_key'] ) ? $builder_options['aweber_consumer_key'] : '';
$consumer_secret = isset( $builder_options['aweber_consumer_secret'] ) ? $builder_options['aweber_consumer_secret'] : '';
$access_key = isset( $builder_options['aweber_access_key'] ) ? $builder_options['aweber_access_key'] : '';
$access_secret = isset( $builder_options['aweber_access_secret'] ) ? $builder_options['aweber_access_secret'] : '';
} else if ( 'divi' === $product ) {
$account_name = 'Divi Builder';
$mailchimp_api_key = et_get_option( 'divi_mailchimp_api_key' );
$consumer_key = et_get_option( 'divi_aweber_consumer_key' );
$consumer_secret = et_get_option( 'divi_aweber_consumer_secret' );
$access_key = et_get_option( 'divi_aweber_access_key' );
$access_secret = et_get_option( 'divi_aweber_access_secret' );
continue; // Satisfy code linter.
$aweber_key_parts = array( $consumer_key, $consumer_secret, $access_key, $access_secret );
if ( $data_utils->all( $aweber_key_parts ) ) {
// Typically AWeber tokens have five parts. We don't have the last part (the verifier token) because
// we didn't save it at the time it was originally input by the user. Thus, we add an additional separator
// (|) so that the token passes the processing performed by ET_Core_API_Email_Aweber::_parse_ID().
$aweber_api_key = implode( '|', array( $consumer_key, $consumer_secret, $access_key, $access_secret, '|' ) );
if ( ! empty( $mailchimp_api_key ) ) {
et_core_api_email_fetch_lists( 'MailChimp', "{$account_name} MailChimp", $mailchimp_api_key );
if ( ! empty( $aweber_api_key ) ) {
$aweber = $providers->get( 'Aweber', "{$account_name} Aweber", 'builder' );
$aweber->data['api_key'] = $aweber_api_key;
$aweber->data['consumer_key'] = $consumer_key;
$aweber->data['consumer_secret'] = $consumer_secret;
$aweber->data['access_key'] = $access_key;
$aweber->data['access_secret'] = $access_secret;
$aweber->data['is_authorized'] = true;
$aweber->fetch_subscriber_lists();
// Make sure the BB updates its cached templates
et_pb_force_regenerate_templates();
$builder_options[ $builder_migrated_key ] = true;
update_option( 'et_pb_builder_options', $builder_options );
et_update_option( $divi_migrated_key, true );
if ( ! function_exists( 'et_builder_email_remove_account' ) ):
* Ajax handler for the Email Opt-in Module's "Remove Account" action.
function et_builder_email_remove_account() {
et_core_security_check( 'manage_options', 'et_builder_email_remove_account_nonce' );
$provider_slug = sanitize_text_field( $_POST['et_provider'] );
$account_name = sanitize_text_field( $_POST['et_account'] );
if ( isset( $_POST['module_class'] ) && in_array( $_POST['module_class'], array( 'Signup', 'Contact_Form' ) ) ) {
$module_class = sanitize_text_field( $_POST['module_class'] );
$module_class = 'Signup';
$is_BB = isset( $_POST['et_bb'] );
$is_spam_account = isset( $_POST['is_spam_account'] );
if ( empty( $provider_slug ) || empty( $account_name ) ) {
if ( $is_spam_account ) {
et_core_api_spam_remove_account( $provider_slug, $account_name );
et_core_api_email_remove_account( $provider_slug, $account_name );
$_ = ET_Core_Data_Utils::instance();
// Get data in builder format
$list_data = et_builder_email_get_lists_field_data( $provider_slug, $is_BB, $module_class );
'accounts_list' => $_->array_get( $list_data, 'accounts_list', $list_data ),
'custom_fields' => $_->array_get( $list_data, 'custom_fields', array() ),
'predefined_custom_fields' => ET_Core_API_Email_Providers::instance()->custom_fields_data(),
die( wp_json_encode( $result ) );
add_action( 'wp_ajax_et_builder_email_remove_account', 'et_builder_email_remove_account' );
if ( ! function_exists( 'et_pb_submit_subscribe_form' ) ):
* Ajax handler for Email Opt-in Module form submissions.
function et_pb_submit_subscribe_form() {
et_core_security_check( '', 'et_frontend_nonce' );
$providers = ET_Core_API_Email_Providers::instance();
$utils = ET_Core_Data_Utils::instance();
$checksum = $utils->array_get_sanitized( $_POST, 'et_checksum' );
$use_spam_service = get_option( 'et_pb_signup_' . $checksum );
$provider_slug = $utils->array_get_sanitized( $_POST, 'et_provider' );
$account_name = $utils->array_get_sanitized( $_POST, 'et_account' );
$custom_fields = $utils->array_get( $_POST, 'et_custom_fields', array() );
$provider = $providers->get( $provider_slug, $account_name, 'builder' );
if ( ! $provider || ! $use_spam_service ) {
et_core_die( esc_html__( 'Configuration Error: Invalid data.', 'et_builder' ) );
'list_id' => $utils->array_get_sanitized( $_POST, 'et_list_id' ),
'email' => $utils->array_get_sanitized( $_POST, 'et_email' ),
'name' => $utils->array_get_sanitized( $_POST, 'et_firstname' ),
'last_name' => $utils->array_get_sanitized( $_POST, 'et_lastname' ),
'ip_address' => $utils->array_get_sanitized( $_POST, 'et_ip_address' ),
'custom_fields' => $utils->sanitize_text_fields( $custom_fields ),
if ( ! is_email( $args['email'] ) ) {
et_core_die( esc_html__( 'Please input a valid email address.', 'et_builder' ) );
if ( '' === (string) $args['list_id'] ) {
et_core_die( esc_html__( 'Configuration Error: No list has been selected for this form.', 'et_builder' ) );
$signup = ET_Builder_Element::get_module( 'et_pb_signup' );
if ( $signup && 'on' === $use_spam_service && $signup->is_spam_submission() ) {
et_core_die( esc_html__( 'You must be a human to submit this form.', 'et_builder' ) );
et_builder_email_maybe_migrate_accounts();
$result = $provider->subscribe( $args );
if ( 'success' === $result ) {
$result = array( 'success' => true );
$message = esc_html__( 'Subscription Error: ', 'et_builder' );
$result = array( 'error' => $message . $result );
die( wp_json_encode( $result ) );
add_action( 'wp_ajax_et_pb_submit_subscribe_form', 'et_pb_submit_subscribe_form' );
add_action( 'wp_ajax_nopriv_et_pb_submit_subscribe_form', 'et_pb_submit_subscribe_form' );
if ( ! function_exists( 'et_builder_has_limitation' ) ):
* Whether or not the builder currently has a certain limitation.
function et_builder_has_limitation( $limit ) {
if ( 'use_wrapped_styles' === $limit && et_builder_is_post_type_custom( get_post_type() ) ) {
if ( ! et_builder_is_limited_mode() ) {
$limited_builder = et_get_limited_builder();
$limited_builder_limits = et_get_limited_builder_defaults();
switch ( $limited_builder ) {
case 'divi-builder-plugin':
$limited_builder_limits = array_merge( $limited_builder_limits, array(
'force_use_global_important',
'use_additional_limiting_styles',
'forced_icon_color_default',
'register_fittext_script',
return in_array( $limit, $limited_builder_limits );
* Get the defaults for limited builder limitations.
function et_get_limited_builder_defaults() {
return apply_filters( 'et_builder_get_limited_builder_defaults', array(
'force_enqueue_theme_style',
* Get the slug name of the current limited builder.
* @return string The slug name of the current limited builder.
function et_get_limited_builder() {
$bfb = '1' === et_()->array_get( $get, 'et_bfb', '0' );
$dbp = et_is_builder_plugin_active();
return 'divi-builder-plugin';
if ( ! function_exists( 'et_builder_is_limited_mode' ) ):
* Is Builder in limited mode?
* @return bool True - if the builder is in limited mode.
function et_builder_is_limited_mode() {
return '' !== et_get_limited_builder();
if ( ! function_exists( 'et_is_builder_plugin_active' ) ):
* Is Builder plugin active?
* @return bool True - if the plugin is active.
function et_is_builder_plugin_active() {
return (bool) defined( 'ET_BUILDER_PLUGIN_ACTIVE' );
if ( ! function_exists( 'et_is_shortcodes_plugin_active' ) ):
* Is ET Shortcodes plugin active?
* @return bool True - if the plugin is active
function et_is_shortcodes_plugin_active() {
return (bool) defined( 'ET_SHORTCODES_PLUGIN_VERSION' );
* Saves the Role Settings into WP database
function et_pb_save_role_settings() {
if ( ! wp_verify_nonce( $_POST['et_pb_save_roles_nonce'] , 'et_roles_nonce' ) ) {
if ( ! current_user_can( 'manage_options' ) ) {
// handle received data and convert json string to array
$data_json = str_replace( '\\', '' , $_POST['et_pb_options_all'] );
$data = json_decode( $data_json, true );
$processed_options = array();
// convert settings string for each role into array and save it into et_pb_role_settings option
if ( ! empty( $data ) ) {
$role_capabilities = array();
foreach( $data as $role => $settings ) {
parse_str( $data[ $role ], $role_capabilities );
foreach ( $role_capabilities as $capability => $value ) {
$processed_options[ $role ][ $capability ] = $value;
update_option( 'et_pb_role_settings', $processed_options );
// set the flag to reload backbone templates and make sure all the role settings applied correctly right away
et_update_option( 'et_pb_clear_templates_cache', true );
// Delete cached definitions / helpers
et_fb_delete_builder_assets();
add_action( 'wp_ajax_et_pb_save_role_settings', 'et_pb_save_role_settings' );
* Filter callback to determine what shortcodes tags are to be removed.
* Stips all non-builder shortcodes.
* @see strip_shortcodes_tagnames
* @param array $tags_to_remove An array of tags to be removed during strip_shortcodes() call.
* @return array An array of tags to be removed during strip_shortcodes() call.
function et_pb_strip_non_builder_shortcodes_tagnames( $tags_to_remove ) {
$valid_tags = ET_Builder_Element::get_module_slugs_by_post_type();
* What shortcode tags are valid (and safe) builder shortcodes,
* all other shortcodes will be stripped.
* @param array $valid_tags Array of valid shortcode tags.
$valid_tags = apply_filters( 'et_pb_valid_builder_shortcodes', $valid_tags );
// Generate a blocklist, by subtracting the allowlist from all registered shortcodes.
$tags_to_remove = array_diff( $tags_to_remove, $valid_tags );
* Is Yoast SEO plugin active?
* @return bool True - if the plugin is active
if ( ! function_exists( 'et_is_yoast_seo_plugin_active' ) ) :
function et_is_yoast_seo_plugin_active() {
return class_exists( 'WPSEO_Options' );
* Remove all non-builder shortcodes from builder built post content.
* @param string $content Builder built post content.
* @return string Sanitized builder built post content.
function et_pb_enforce_builder_shortcode( $content ) {
add_filter( 'strip_shortcodes_tagnames', 'et_pb_strip_non_builder_shortcodes_tagnames' );
$content = strip_shortcodes( $content );
remove_filter( 'strip_shortcodes_tagnames', 'et_pb_strip_non_builder_shortcodes_tagnames' );
// this will parse the shortcode to an array, then run it back through some sanity check and sanitization and reform into a shortcode again.
$content = et_pb_sanitize_shortcode( $content, true );
if ( ! function_exists( 'et_pb_register_posttypes' ) ) :
function et_pb_register_posttypes() {
'name' => esc_html__( 'Projects', 'et_builder' ),
'singular_name' => esc_html__( 'Project', 'et_builder' ),
'add_new' => esc_html__( 'Add New', 'et_builder' ),
'add_new_item' => esc_html__( 'Add New Project', 'et_builder' ),
'edit_item' => esc_html__( 'Edit Project', 'et_builder' ),
'new_item' => esc_html__( 'New Project', 'et_builder' ),
'all_items' => esc_html__( 'All Projects', 'et_builder' ),
'view_item' => esc_html__( 'View Project', 'et_builder' ),
'search_items' => esc_html__( 'Search Projects', 'et_builder' ),
'not_found' => esc_html__( 'Nothing found', 'et_builder' ),
'not_found_in_trash' => esc_html__( 'Nothing found in Trash', 'et_builder' ),
'parent_item_colon' => '',
'publicly_queryable' => true,
'show_in_nav_menus' => true,
'rewrite' => apply_filters( 'et_project_posttype_rewrite_args', array(
'capability_type' => 'post',
'supports' => array( 'title', 'author', 'editor', 'thumbnail', 'excerpt', 'comments', 'revisions', 'custom-fields' ),
register_post_type( 'project', apply_filters( 'et_project_posttype_args', $args ) );
'name' => esc_html__( 'Project Categories', 'et_builder' ),
'singular_name' => esc_html__( 'Project Category', 'et_builder' ),
'search_items' => esc_html__( 'Search Categories', 'et_builder' ),
'all_items' => esc_html__( 'All Categories', 'et_builder' ),
'parent_item' => esc_html__( 'Parent Category', 'et_builder' ),
'parent_item_colon' => esc_html__( 'Parent Category:', 'et_builder' ),
'edit_item' => esc_html__( 'Edit Category', 'et_builder' ),
'update_item' => esc_html__( 'Update Category', 'et_builder' ),
'add_new_item' => esc_html__( 'Add New Category', 'et_builder' ),
'new_item_name' => esc_html__( 'New Category Name', 'et_builder' ),
'menu_name' => esc_html__( 'Categories', 'et_builder' ),
'not_found' => esc_html__( "You currently don't have any project categories.", 'et_builder' ),
register_taxonomy( 'project_category', array( 'project' ), array(
'show_admin_column' => true,
'name' => esc_html__( 'Project Tags', 'et_builder' ),
'singular_name' => esc_html__( 'Project Tag', 'et_builder' ),
'search_items' => esc_html__( 'Search Tags', 'et_builder' ),
'all_items' => esc_html__( 'All Tags', 'et_builder' ),
'parent_item' => esc_html__( 'Parent Tag', 'et_builder' ),
'parent_item_colon' => esc_html__( 'Parent Tag:', 'et_builder' ),
'edit_item' => esc_html__( 'Edit Tag', 'et_builder' ),
'update_item' => esc_html__( 'Update Tag', 'et_builder' ),
'add_new_item' => esc_html__( 'Add New Tag', 'et_builder' ),
'new_item_name' => esc_html__( 'New Tag Name', 'et_builder' ),
'menu_name' => esc_html__( 'Tags', 'et_builder' ),
register_taxonomy( 'project_tag', array( 'project' ), array(
'show_admin_column' => true,
function et_admin_backbone_templates_being_loaded() {
if ( ! et_core_security_check_passed( '', 'et_admin_load_nonce' ) ) {