: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( isset( $this->advanced_fields ) ) {
$this->advanced_fields = apply_filters(
"{$this->slug}_advanced_fields",
if ( isset( $this->custom_css_fields ) ) {
$this->custom_css_fields = apply_filters(
"{$this->slug}_custom_css_fields",
$this->custom_css_fields,
function disable_wptexturize( $shortcodes ) {
$shortcodes[] = $this->slug;
function fix_wptexturized_script( $matches ) {
return str_replace( '&', '&', $matches[0] );
function fix_wptexturized_scripts( $content ) {
return preg_replace_callback(
'/<script.*?>(.*?)<\/script>/mis',
array( $this, 'fix_wptexturized_script' ),
static function compare_by_priority( $a, $b ) {
$a_priority = ! empty( $a['priority'] ) ? (int) $a['priority'] : self::DEFAULT_PRIORITY;
$b_priority = ! empty( $b['priority'] ) ? (int) $b['priority'] : self::DEFAULT_PRIORITY;
if ( isset( $a['_order_number'], $b['_order_number'] ) && ( $a_priority === $b_priority ) ) {
return $a['_order_number'] - $b['_order_number'];
return $a_priority - $b_priority;
* Reorder toggles based on the priority with respect to manually ordered items with no priority
static function et_pb_order_toggles_by_priority( $toggles_array ) {
if ( empty( $toggles_array ) ) {
$high_priority_toggles = array();
$low_priority_toggles = array();
$manually_ordered_toggles = array();
// fill 3 arrays based on priority
foreach ( $toggles_array as $toggle_id => $toggle_data ) {
if ( isset( $toggle_data['priority'] ) ) {
if ( $toggle_data['priority'] < 10 ) {
$high_priority_toggles[ $toggle_id ] = $toggle_data;
$low_priority_toggles[ $toggle_id ] = $toggle_data;
// keep the original order of options without priority defined
$manually_ordered_toggles[ $toggle_id ] = $toggle_data;
// order high and low priority toggles
uasort( $high_priority_toggles, array( 'self', 'compare_by_priority' ) );
uasort( $low_priority_toggles, array( 'self', 'compare_by_priority' ) );
// merge 3 arrays to get the correct order of toggles.
return array_merge( $high_priority_toggles, $manually_ordered_toggles, $low_priority_toggles );
static function compare_by_name( $a, $b ) {
return strcasecmp( $a->name, $b->name );
static function get_modules_count( $post_type ) {
$parent_modules = self::get_parent_modules( $post_type );
$child_modules = self::get_child_modules( $post_type );
$overall_count = count( $parent_modules ) + count( $child_modules );
static function get_modules_js_array( $post_type ) {
$parent_modules = self::get_parent_modules( $post_type );
if ( ! empty( $parent_modules ) ) {
* Sort modules alphabetically by name.
$sorted_modules = $parent_modules;
uasort( $sorted_modules, array( 'self', 'compare_by_name' ) );
foreach( $sorted_modules as $module ) {
* Replace single and double quotes with %% and || respectively
$module_name = str_replace( array( '"', '"', '"', '"' ) , '%%', $module->name );
$module_name = str_replace( array( "'", ''', ''' ) , '||', $module_name );
'{ "title" : "%1$s", "label" : "%2$s"%3$s}',
( isset( $module->fullwidth ) && $module->fullwidth ? ', "fullwidth_only" : "on"' : '' )
return '[' . implode( ',', $modules ) . ']';
static function get_modules_array( $post_type = '', $include_child = false ) {
$module_icons = self::get_module_icons();
if ( ! empty( $post_type ) ) {
$parent_modules = self::get_parent_modules( $post_type );
$parent_modules = array_merge( $parent_modules, self::get_child_modules( $post_type ));
if ( ! empty( $parent_modules ) ) {
$sorted_modules = $parent_modules;
$parent_modules = self::get_parent_modules();
$parent_modules = array_merge( $parent_modules, self::get_child_modules());
if ( ! empty( $parent_modules ) ) {
foreach( $parent_modules as $post_type => $post_type_modules ) {
foreach ( $post_type_modules as $module_slug => $module ) {
$all_modules[ $module_slug ] = $module;
$sorted_modules = $all_modules;
if ( ! empty( $sorted_modules ) ) {
* Sort modules alphabetically by name.
uasort( $sorted_modules, array( 'self', 'compare_by_name' ) );
foreach( $sorted_modules as $module ) {
* Replace single and double quotes with %% and || respectively
$module_name = str_replace( '"', '%%', $module->name );
$module_name = str_replace( "'", '||', $module_name );
$module_name_plural = str_replace( '"', '%%', empty( $module->plural ) ? $module->name : $module->plural );
$module_name_plural = str_replace( "'", '||', $module_name_plural );
'title' => esc_attr( $module_name ),
'plural' => esc_attr( $module_name_plural ),
'label' => esc_attr( $module->slug ),
'is_parent' => $module->type === 'child' ? 'off' : 'on',
'is_official_module' => $module->_is_official_module,
'vb_support' => isset( $module->vb_support ) ? $module->vb_support : 'off',
if ( isset( $module->fullwidth ) && $module->fullwidth ) {
$_module['fullwidth_only'] = 'on';
// Get module icon character (font-icon)
$icon = self::$_->array_get( $module_icons, "{$module->slug}.icon");
$_module['icon'] = $icon;
// Get module icon svg from fetched svg content
$icon_svg = self::$_->array_get( $module_icons, "{$module->slug}.icon_svg");
$_module['icon_svg'] = $icon_svg;
static function get_fb_unsupported_modules() {
$parent_modules = self::get_parent_modules();
$unsupported_modules_array = array();
foreach( $parent_modules as $post_type => $post_type_modules ) {
foreach ( $post_type_modules as $module_slug => $module ) {
if ( ! isset( $module->vb_support ) || 'off' === $module->vb_support ) {
$unsupported_modules_array[] = $module_slug;
return array_unique( $unsupported_modules_array );
* Get list of modules that has rich content option
static function get_has_content_modules() {
return self::$has_content_modules;
* Returns a regex pattern that includes all parent module slugs.
* @since 3.1 Renamed from `get_parent_shortcodes()` to `get_parent_slugs_regex()`
* @param string $post_type
public static function get_parent_slugs_regex( $post_type = 'page' ) {
$parent_modules = self::get_parent_modules( $post_type );
if ( ! empty( $parent_modules ) ) {
foreach( $parent_modules as $module ) {
$slugs[] = $module->slug;
return implode( '|', $slugs );
* Returns a regex pattern that includes all child module slugs.
* @since 3.1 Renamed from `get_child_shortcodes()` to `get_child_slugs_regex()`
* @param string $post_type
public static function get_child_slugs_regex( $post_type = 'page' ) {
$child_modules = self::get_child_modules( $post_type );
if ( ! empty( $child_modules ) ) {
foreach( $child_modules as $slug => $module ) {
if ( ! empty( $slug ) ) {
return implode( '|', $slugs );
static function get_child_slugs( $post_type ) {
$child_modules = self::get_parent_modules( $post_type );
if ( ! empty( $child_modules ) ) {
foreach( $child_modules as $module ) {
if ( ! empty( $module->child_slug ) ) {
$child_slugs[ $module->slug ] = $module->child_slug;
public static function get_raw_content_slugs( $post_type ) {
$parent_modules = self::get_parent_modules( $post_type );
if ( ! empty( $parent_modules ) ) {
foreach( $parent_modules as $module ) {
if ( isset( $module->use_raw_content ) && $module->use_raw_content ) {
$shortcodes[] = $module->slug;
$child_modules = self::get_child_modules( $post_type );
if ( ! empty( $child_modules ) ) {
foreach( $child_modules as $module ) {
if ( isset( $module->use_raw_content ) && $module->use_raw_content ) {
$shortcodes[] = $module->slug;
return implode( '|', $shortcodes );
static function get_modules_templates( $post_type, $slugs_array ) {
$all_modules = self::get_parent_and_child_modules( $post_type );
$templates_array = array();
if ( empty( $slugs_array ) ) {
foreach ( $slugs_array as $slug ) {
if ( ! isset( $all_modules[ $slug ] ) ) {
$module = $all_modules[ $slug ];
$templates_array[] = array(
'template' => $module->build_microtemplate(),
if ( ET_BUILDER_OPTIMIZE_TEMPLATES ) {
$templates_array = array(
'templates' => $templates_array,
'unique' => self::$_unique_bb_keys_values,
static function output_templates( $post_type = '', $start_from = 0, $amount = 999 ) {
$all_modules = self::get_parent_and_child_modules( $post_type );
$modules_names = array_keys( $all_modules );
$output['templates'] = array();
if ( ! empty( $all_modules ) ) {
for ( $i = 0; $i < ET_BUILDER_AJAX_TEMPLATES_AMOUNT; $i++ ) {
if ( isset( $modules_names[ $i ] ) ) {
$module = $all_modules[ $modules_names[ $i ] ];
$output['templates'][ $module->slug ] = self::optimize_bb_chunk( $module->build_microtemplate() );
if ( ET_BUILDER_OPTIMIZE_TEMPLATES ) {
$output['unique'] = self::$_unique_bb_keys_values;
static function get_structure_module_slugs() {
if ( ! empty( self::$structure_module_slugs ) ) {
return self::$structure_module_slugs;
$structure_modules = self::get_structure_modules();
self::$structure_module_slugs = array();
foreach( $structure_modules as $structural_module ) {
self::$structure_module_slugs[] = $structural_module->slug;
return self::$structure_module_slugs;
static function get_structure_modules() {
if ( ! empty( self::$structure_modules ) ) {
return self::$structure_modules;
$parent_modules = self::get_parent_modules( 'et_pb_layout' );
self::$structure_modules = array();
foreach ( $parent_modules as $parent_module ) {
if ( isset( $parent_module->is_structure_element ) && $parent_module->is_structure_element ) {
$parent_module->plural = empty( $parent_module->plural ) ? $parent_module->name : $parent_module->plural;
self::$structure_modules[] = $parent_module;
return self::$structure_modules;
* Get a filtered list of modules.
* @param string $post_type Leave empty for any.
* @param string $type 'parent' or 'child'. Leave empty for any.
* @return ET_Builder_Element[]
static function get_modules( $post_type = '', $type = '' ) {
foreach ( self::$modules as $slug => $module ) {
if ( '' !== $post_type && ! in_array( $post_type, $module->post_types ) ) {
if ( '' !== $type && ! $module->type !== $type ) {
$modules[ $slug ] = $module;
static function get_custom_post_type_fallback_modules( $type = 'parent' ) {
$modules = 'child' === $type ? self::$child_modules : self::$parent_modules;
// Most of the time, page module is expected to be used as disabled post type fallback
if ( isset( $modules['page'] ) ) {
// Post module is also expected to be used
if ( isset( $modules['post'] ) ) {
// If Divi Builder is disabled for all post types use layout modules as fallback
if ( isset( $modules['et_pb_layout'] ) ) {
return $modules['et_pb_layout'];
// If all else fail, use all modules
return self::get_modules();
static function get_parent_modules( $post_type = '' ) {
if ( ! empty( $post_type ) ) {
// We get all modules when post type is not enabled so that posts that have
// had their post type support disabled still load all necessary modules.
$parent_modules = ! empty( self::$parent_modules[ $post_type ] )
? self::$parent_modules[ $post_type ]
: self::get_custom_post_type_fallback_modules( 'parent' );
$parent_modules = self::$parent_modules;
return apply_filters( 'et_builder_get_parent_modules', $parent_modules, $post_type );
static function get_child_modules( $post_type = '' ) {
if ( ! empty( $post_type ) ) {
// We get all modules when post type is not enabled so that posts that have
// had their post type support disabled still load all necessary modules.
$child_modules = ! empty( self::$child_modules[ $post_type ] )
? self::$child_modules[ $post_type ]
: self::get_custom_post_type_fallback_modules( 'child' );
$child_modules = self::$child_modules;
return apply_filters( 'et_builder_get_child_modules', $child_modules, $post_type );
static function get_woocommerce_modules() {
return apply_filters( 'et_builder_get_woocommerce_modules', self::$woocommerce_modules );
* Get registered module icons