: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$filtered_shortcuts = array();
foreach ($shortcuts as $group_key => $group) {
foreach ($group as $shortcut_key => $shortcut) {
if ( in_array( $on, $shortcut['on'] ) ) {
$filtered_shortcuts[ $group_key ][ $shortcut_key ] = $shortcut;
return $filtered_shortcuts;
* Parsed *_last_edited value and determine wheter the passed string means it has responsive value or not
* *_last_edited holds two values (responsive status and last opened tabs) in the following format: status|last_opened_tab
* @param string last_edited data
if ( ! function_exists( 'et_pb_get_responsive_status' ) ) :
function et_pb_get_responsive_status( $last_edited ) {
$parsed_last_edited = is_string( $last_edited ) ? explode( '|', $last_edited ) : array( 'off', 'desktop' );
return isset( $parsed_last_edited[0] ) ? $parsed_last_edited[0] === 'on' : false;
* Get unit of given value
* @param string string with unit
* @return string unit name
if ( ! function_exists( 'et_pb_get_value_unit' ) ) :
function et_pb_get_value_unit( $value, $default_unit = 'px' ) {
$value = isset( $value ) ? $value : '';
$valid_one_char_units = array( "%", 'x' );
$valid_two_chars_units = array( "em", "px", "cm", "mm", "in", "pt", "pc", "ex", "vh", "vw", "ms" );
$valid_three_chars_units = array( 'deg', 'rem' );
$important = "!important";
$important_length = strlen( $important );
$value_length = strlen( $value );
if ( $value === '' || is_numeric( $value ) ) {
if ( substr( $value, ( 0 - $important_length ), $important_length ) === $important ) {
$value_length = $value_length - $important_length;
$value = substr( $value, 0, $value_length ).trim();
if ( in_array( substr( $value, -3, 3 ), $valid_three_chars_units ) ) {
return substr( $value, -3, 3 );
if ( in_array( substr( $value, -2, 2 ), $valid_two_chars_units ) ) {
return substr( $value, -2, 2 );
if ( in_array( substr( $value, -1, 1 ), $valid_one_char_units ) ) {
return substr( $value, -1, 1 );
* Sanitized value and its unit
* @return string sanitized input and its unit
if ( ! function_exists( 'et_sanitize_input_unit' ) ) :
function et_sanitize_input_unit( $value = '', $auto_important = false, $default_unit = false ) {
$value = (string) $value;
$valid_one_char_units = array( '%', 'x' );
$valid_two_chars_units = array( 'em', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw', 'ms' );
$valid_three_chars_units = array( 'deg', 'rem' );
$important = '!important';
$important_length = strlen( $important );
$value_length = strlen( $value );
if ( substr( $value, ( 0 - $important_length ), $important_length ) === $important ) {
$value_length = $value_length - $important_length;
$value = trim( substr( $value, 0, $value_length ) );
if ( in_array( substr( $value, -3, 3 ), $valid_three_chars_units ) ) {
$unit_value = floatval( $value ) . substr( $value, -3, 3 );
if ( $has_important && ! $auto_important ) {
$unit_value = $unit_value . ' ' . $important;
if ( in_array( substr( $value, -2, 2 ), $valid_two_chars_units ) ) {
$unit_value = floatval( $value ) . substr( $value, -2, 2 );
if ( $has_important && ! $auto_important ) {
$unit_value = $unit_value . ' ' . $important;
if ( in_array( substr( $value, -1, 1 ), $valid_one_char_units ) ) {
$unit_value = floatval( $value ) . substr( $value, -1, 1 );
if ( $has_important && ! $auto_important ) {
$unit_value = $unit_value . ' ' . $important;
$result = floatval( $value );
if ( 'no_default_unit' === $default_unit ) {
return $result . $default_unit;
// Return and automatically append px (default value)
* Get taxonomies for modules
* @return array Array of WP taxonomies splitted into the taxonomy types
if ( ! function_exists( 'et_builder_get_taxonomies' ) ) :
function et_builder_get_shop_categories( $args = array() ) {
$defaults = apply_filters( 'et_builder_include_categories_shop_defaults', array (
'term_name' => 'product_cat',
$term_args = apply_filters( 'et_builder_include_categories_shop_args', array( 'hide_empty' => false, ) );
$args = wp_parse_args( $args, $defaults );
$product_categories = $args['use_terms'] ? get_terms( $args['term_name'], $term_args ) : get_categories( apply_filters( 'et_builder_get_categories_shop_args', 'hide_empty=0' ) );
return $product_categories;
if ( ! function_exists( 'et_pb_get_spacing' ) ):
function et_pb_get_spacing( $spacing, $corner, $default = '0px' ) {
$corners = array( 'top', 'right', 'bottom', 'left' );
$corner_index = array_search( $corner, $corners );
$spacing_array = explode( '|', $spacing );
return isset( $spacing_array[ $corner_index ] ) && '' !== $spacing_array[ $corner_index ] ? $spacing_array[ $corner_index ] : $default;
if ( ! function_exists( 'et_fb_enqueue_bundle' ) ) :
function et_fb_enqueue_bundle( $id, $resource, $deps, $ver = false ) {
$DEBUG = defined( 'ET_DEBUG' ) && ET_DEBUG;
$ver = false === $ver ? ET_BUILDER_VERSION : $ver;
$build = 'frontend-builder/build';
$bundle = sprintf( '%s/%s/%s', ET_BUILDER_URI, $build, $resource );
$type = pathinfo( $resource, PATHINFO_EXTENSION );
if ( file_exists( sprintf( '%s%s/%s', ET_BUILDER_DIR, $build, $resource ) ) || ! $DEBUG ) {
wp_enqueue_style( $id, $bundle, $deps, $ver );
// Style is already embedded in the bundle but we still need to enqueue its deps.
foreach ( $deps as $dep ) {
wp_enqueue_style( $dep );
if ( file_exists( sprintf( '%s%s/%s', ET_BUILDER_DIR, $build, $resource ) ) || ! $DEBUG ) {
// If the file exists on disk, enqueue it
wp_enqueue_script( $id, $bundle, $deps, $ver, true );
// Otherwise load `hot` from webpack-dev-server
$site_url = wp_parse_url( get_site_url() );
$hot_bundle_url = "{$site_url['scheme']}://{$site_url['host']}:31495/$resource";
wp_enqueue_script( $id, $hot_bundle_url, $deps, $ver, true );
wp_add_inline_script( $id, 'window.et_gb = (window.top && window.top.Cypress && window.parent === window.top && window) || (window.top && window.top.Cypress && window.parent !== window.top && window.parent) || window.top || window;', 'before' );
* Get list of all active plugins (single, network active, and mu)
* @return array active plugins
if ( ! function_exists( 'et_builder_get_active_plugins' ) ):
function et_builder_get_active_plugins() {
$active_plugins = get_option( 'active_plugins' );
// Returned format must be array
if ( ! is_array( $active_plugins ) ) {
$active_plugins = array();
// Get mu-plugins (must-use)
// mu-plugins data is returned in array( "plugin/name.php" => array( 'data' => 'value' ) ) format.
$mu_plugins = get_mu_plugins();
if ( is_array( $mu_plugins ) ) {
$active_plugins = array_merge( $active_plugins, array_keys( $mu_plugins ) );
// Get network active plugins
// Network active plugin data is returned in array( "plugin/name.php" => active_timestamp_int format.
$network_active_plugins = get_site_option( 'active_sitewide_plugins' );
if ( is_array( $network_active_plugins ) ) {
$active_plugins = array_merge( $active_plugins, array_keys( $network_active_plugins ) );
return apply_filters( 'et_builder_get_active_plugins', $active_plugins );
if ( ! function_exists( 'et_has_hover_enabled' ) ) :
function et_has_hover_enabled( $props ) {
$et_has_hover_enabled = false;
$prop_names = array_keys( $props );
$suffix = et_pb_hover_options()->get_enabled_suffix();
foreach ( $prop_names as $prop_name ) {
if ( preg_match( "~{$suffix}$~", $prop_name ) && 'on' === $props[ $prop_name ] ) {
$et_has_hover_enabled = true;
return $et_has_hover_enabled;
if ( ! function_exists( 'et_builder_is_hover_enabled' ) ) :
function et_builder_is_hover_enabled( $setting, $props ) {
return et_pb_hover_options()->is_enabled( $setting, $props );
if ( ! function_exists( 'et_builder_add_prefix' ) ) {
* Prefixes a string key with a prefix string using the provided delimiter
* In case the prefix is empty, original key is returned
* @param string $delimiter
function et_builder_add_prefix( $prefix, $key, $delimiter = '_' ) {
return $prefix === '' ? $key : $prefix . $delimiter . $key;
if ( ! function_exists( 'et_builder_has_value' ) ) {
* Check if value is not an empty value
* Empty values are considered:
function et_builder_has_value( $value ) {
return null !== $value && '' !== $value && false !== $value;
if ( ! function_exists( 'et_builder_get_or' ) ) {
* Returns the value in case it is not empty
* Otherwise, return the default value
function et_builder_get_or( $value, $default = '' ) {
return et_builder_has_value( $value ) ? $value : $default;
if ( ! function_exists( 'et_builder_module_prop' ) ) {
* Returns props value by provided key, if the value is empty, returns the default value
function et_builder_module_prop( $prop, $props, $default ) {
return et_builder_get_or( et_()->array_get( $props, $prop ), $default );
if ( ! function_exists( 'et_pb_get_column_svg' ) ) {
* Returns svg which represents the requried columns type
* @return string svg code.
function et_pb_get_column_svg( $type ) {
$svg = '<rect width="100%" height="20" y="5" rx="5" ry="5" />';
$svg = '<rect width="48.5%" height="20" y="5" rx="5" ry="5" />
<rect width="48.5%" height="20" y="5" rx="5" ry="5" x="51.5%" />';
$svg = '<rect width="31.3%" height="20" y="5" rx="5" ry="5" />
<rect width="31.3%" height="20" y="5" rx="5" ry="5" x="34.3%" />
<rect width="31.3%" height="20" y="5" rx="5" ry="5" x="68.6%" />';
$svg = '<rect width="22.75%" height="20" y="5" rx="5" ry="5" />
<rect width="22.75%" height="20" y="5" rx="5" ry="5" x="25.75%" />
<rect width="22.75%" height="20" y="5" rx="5" ry="5" x="51.5%" />
<rect width="22.75%" height="20" y="5" rx="5" ry="5" x="77.25%" />';
case '1_5,1_5,1_5,1_5,1_5':
$svg = '<rect width="17.6%" height="20" y="5" rx="5" ry="5" />
<rect width="17.6%" height="20" y="5" rx="5" ry="5" x="20.6%" />
<rect width="17.6%" height="20" y="5" rx="5" ry="5" x="41.2%" />
<rect width="17.6%" height="20" y="5" rx="5" ry="5" x="61.8%" />
<rect width="17.6%" height="20" y="5" rx="5" ry="5" x="82.4%" />';
case '1_6,1_6,1_6,1_6,1_6,1_6':
$svg = '<rect width="14.16%" height="20" y="5" rx="5" ry="5" />
<rect width="14.16%" height="20" y="5" rx="5" ry="5" x="17.16%" />
<rect width="14.16%" height="20" y="5" rx="5" ry="5" x="34.32%" />
<rect width="14.16%" height="20" y="5" rx="5" ry="5" x="51.48%" />
<rect width="14.16%" height="20" y="5" rx="5" ry="5" x="68.64%" />
<rect width="14.16%" height="20" y="5" rx="5" ry="5" x="85.8%" />';
$svg = '<rect width="38.5%" height="20" y="5" rx="5" ry="5" />
<rect width="58.5%" height="20" y="5" rx="5" ry="5" x="41.5%" />';
$svg = '<rect width="58.5%" height="20" y="5" rx="5" ry="5" />
<rect width="38.5%" height="20" y="5" rx="5" ry="5" x="61.5%" />';
$svg = '<rect width="31.5%" height="20" y="5" rx="5" ry="5" />
<rect width="65.5%" height="20" y="5" rx="5" ry="5" x="34.5%" />';
$svg = '<rect width="65.5%" height="20" y="5" rx="5" ry="5" />
<rect width="31.5%" height="20" y="5" rx="5" ry="5" x="68.5%" />';
$svg = '<rect width="23.5%" height="20" y="5" rx="5" ry="5" />
<rect width="73.5%" height="20" y="5" rx="5" ry="5" x="26.5%" />';
$svg = '<rect width="73.5%" height="20" y="5" rx="5" ry="5" />
<rect width="23.5%" height="20" y="5" rx="5" ry="5" x="76.5%" />';
$svg = '<rect width="23.5%" height="20" y="5" rx="5" ry="5" />
<rect width="47%" height="20" y="5" rx="5" ry="5" x="26.5%" />
<rect width="23.5%" height="20" y="5" rx="5" ry="5" x="76.5%" />';
$svg = '<rect width="18.5%" height="20" y="5" rx="5" ry="5" />
<rect width="57%" height="20" y="5" rx="5" ry="5" x="21.5%" />
<rect width="18.5%" height="20" y="5" rx="5" ry="5" x="81.5%" />';
$svg = '<rect width="23.5%" height="20" y="5" rx="5" ry="5" />
<rect width="23.5%" height="20" y="5" rx="5" ry="5" x="26.5%" />
<rect width="47%" height="20" y="5" rx="5" ry="5" x="53%" />';
$svg = '<rect width="47%" height="20" y="5" rx="5" ry="5" />
<rect width="23.5%" height="20" y="5" rx="5" ry="5" x="50%" />
<rect width="23.5%" height="20" y="5" rx="5" ry="5" x="76.5%" />';
$svg = '<rect width="18.5%" height="20" y="5" rx="5" ry="5" />
<rect width="18.5%" height="20" y="5" rx="5" ry="5" x="21.5%" />
<rect width="57%" height="20" y="5" rx="5" ry="5" x="43%" />';
$svg = '<rect width="57%" height="20" y="5" rx="5" ry="5" />
<rect width="18.5%" height="20" y="5" rx="5" ry="5" x="60%" />
<rect width="18.5%" height="20" y="5" rx="5" ry="5" x="81.5%" />';
$svg = '<rect width="14.6%" height="20" y="5" rx="5" ry="5" />
<rect width="14.6%" height="20" y="5" rx="5" ry="5" x="18.1%" />
<rect width="14.6%" height="20" y="5" rx="5" ry="5" x="36.2%" />
<rect width="45.7%" height="20" y="5" rx="5" ry="5" x="54.3%" />';
$svg = '<rect width="47%" height="20" y="5" rx="5" ry="5" />
<rect width="14.6%" height="20" y="5" rx="5" ry="5" x="50%" />
<rect width="14.6%" height="20" y="5" rx="5" ry="5" x="67.6%" />
<rect width="14.6%" height="20" y="5" rx="5" ry="5" x="85.2%" />';
* Get image metadata responsive sizes
* @param string $image_src The 'src' of the image.
* @param array $image_meta The image meta data as returned by 'wp_get_attachment_metadata()'.
* @param array $size Array of width and height values in pixels (in that order).
function et_builder_responsive_image_metadata( $image_src, $image_meta = null, $size = null ) {
$cache = ET_Core_Cache_File::get( 'image_responsive_metadata' );
$normalized_url = et_attachment_normalize_url( $image_src );
if ( isset( $cache[ $normalized_url ] ) ) {
if ( et_core_is_uploads_dir_url( $normalized_url ) ) {
return $cache[ $normalized_url ];
unset( $cache[ $normalized_url ] );
ET_Core_Cache_File::set( 'image_responsive_metadata', $cache );
$responsive_sizes = array();
$image_id = is_numeric( $image_src ) ? intval( $image_src ) : et_get_attachment_id_by_url( $image_src );
if ( is_null( $image_meta ) ) {
$image_meta = wp_get_attachment_metadata( $image_id );
if ( ! $image_meta || empty( $image_meta['sizes'] ) ) {