: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
class ET_Builder_Module_Field_TextShadow extends ET_Builder_Module_Field_Base {
* True when Divi plugin is active.
public $is_plugin_active = false;
* Text shadow properties.
public function __construct() {
$this->template = et_pb_option_template();
$this->is_plugin_active = et_is_builder_plugin_active();
$this->properties = array(
* Returns prefixed field names.
* @param string $prefix Prefix.
public function get_prefixed_field_names( $prefix ) {
$prefix = $prefix ? "{$prefix}_" : '';
"{$prefix}text_shadow_style",
"{$prefix}text_shadow_horizontal_length",
"{$prefix}text_shadow_vertical_length",
"{$prefix}text_shadow_blur_strength",
"{$prefix}text_shadow_color",
}//end get_prefixed_names()
* Returns Text Shadow presets.
* @param string $prefix Prefix.
public function get_presets( $prefix, $suffix = '' ) {
$text_shadow_horizontal_length,
$text_shadow_vertical_length,
$text_shadow_blur_strength,
) = $this->get_prefixed_field_names( $prefix );
'class' => 'preset preset1',
$text_shadow_horizontal_length => '0em',
$text_shadow_vertical_length => '0.1em',
$text_shadow_blur_strength => '0.1em',
'class' => 'preset preset2',
$text_shadow_horizontal_length => '0.08em',
$text_shadow_vertical_length => '0.08em',
$text_shadow_blur_strength => '0.08em',
'class' => 'preset preset3',
$text_shadow_horizontal_length => '0em',
$text_shadow_vertical_length => '0em',
$text_shadow_blur_strength => '0.3em',
'class' => 'preset preset4',
$text_shadow_horizontal_length => '0em',
$text_shadow_vertical_length => '0.08em',
$text_shadow_blur_strength => '0em',
'class' => 'preset preset5',
$text_shadow_horizontal_length => '0.08em',
$text_shadow_vertical_length => '0.08em',
$text_shadow_blur_strength => '0em',
* Returns conditional defaults array.
* @param string $prefix Prefix.
* @param string $depend Field whose value controls which default should be used.
* @param string $field Field for which we're generating the defaults array.
* @param string $default Default value to be used when a Preset doesn't include a value for $field.
public function get_defaults( $prefix, $depend, $field, $default ) {
$presets = $this->get_presets( $prefix );
foreach ( $presets as $preset ) {
$value = $preset['value'];
$defaults[ $value ] = isset( $preset['fields'][ $field ] ) ? $preset['fields'][ $field ] : $default;
* Set option template for Text Shadow
public function set_template() {
$template = $this->template;
if ( $template->is_enabled() && ! $template->has( 'text_shadow' ) ) {
$this->get_fields( $template->placeholders( array(
'option_category' => null,
'depends_show_if' => null,
'depends_show_if_not' => null,
* Returns fields definition.
* @since 3.23 Add mobile_options attributes for all fields to support responsive settings, except
* text_shadow_style. Add allowed units for some fields with range type.
* @param array $args Field configuration.
public function get_fields( array $args = array() ) {
$config = shortcode_atts(
'tab_slug' => 'advanced',
'option_category' => 'configuration',
'depends_show_if_not' => '',
if ( $this->template->is_enabled() && $this->template->has( 'text_shadow' ) ) {
return $this->template->create( 'text_shadow', $config );
$prefix = $config['prefix'];
$text_shadow_horizontal_length,
$text_shadow_vertical_length,
$text_shadow_blur_strength,
) = $this->get_prefixed_field_names( $prefix );
$tab_slug = $config['tab_slug'];
$toggle_slug = $config['toggle_slug'];
$sub_toggle = $config['sub_toggle'];
$option_category = $config['option_category'];
// Some option categories (like font) have custom logic that involves changing default values and we don't want that to interfere with conditional defaults. This might change in future so, for now, I'm just overriding the value while leaving the possibility to remove this line afterwards and provide custom option_category via $config.
$option_category = 'configuration';
$label = $config['label'];
// translators: text shadow group label
sprintf( esc_html__( '%1$s Text Shadow', 'et_builder' ), $label ),
// translators: text shadow group label
sprintf( esc_html__( '%1$s Text Shadow Horizontal Length', 'et_builder' ), $label ),
// translators: text shadow group label
sprintf( esc_html__( '%1$s Text Shadow Vertical Length', 'et_builder' ), $label ),
// translators: text shadow group label
sprintf( esc_html__( '%1$s Text Shadow Blur Strength', 'et_builder' ), $label ),
// translators: text shadow group label
sprintf( esc_html__( '%1$s Text Shadow Color', 'et_builder' ), $label ),
esc_html__( 'Text Shadow', 'et_builder' ),
esc_html__( 'Text Shadow Horizontal Length', 'et_builder' ),
esc_html__( 'Text Shadow Vertical Length', 'et_builder' ),
esc_html__( 'Text Shadow Blur Strength', 'et_builder' ),
esc_html__( 'Text Shadow Color', 'et_builder' ),
$text_shadow_style => array(
'description' => esc_html__( 'Pick a text shadow style to enable text shadow for this element. Once enabled, you will be able to customize your text shadow style further. To disable custom text shadow style, choose the None option.', 'et_builder' ),
'type' => 'presets_shadow',
'option_category' => $option_category,
'default_on_child' => true,
'presets' => $this->get_presets( $prefix ),
'toggle_slug' => $toggle_slug,
$text_shadow_horizontal_length,
$text_shadow_vertical_length,
$text_shadow_blur_strength,
$text_shadow_horizontal_length,
$text_shadow_vertical_length,
$text_shadow_blur_strength,
$text_shadow_horizontal_length,
$text_shadow_vertical_length,
$text_shadow_blur_strength,
$text_shadow_horizontal_length => array(
'description' => esc_html__( 'Shadow\'s horizontal distance from the text. A negative value places the shadow to the left of the text.', 'et_builder' ),
'option_category' => $option_category,
'range_settings' => array(
'default' => $this->get_defaults( $prefix, $text_shadow_style, $text_shadow_horizontal_length, '0em' ),
'default_on_child' => true,
'allowed_units' => array( 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ),
'toggle_slug' => $toggle_slug,
'depends_show_if_not' => 'none',
'mobile_options' => true,
$text_shadow_vertical_length => array(
'description' => esc_html__( 'Shadow\'s vertical distance from the text. A negative value places the shadow above the text.', 'et_builder' ),
'option_category' => $option_category,
'range_settings' => array(
'default' => $this->get_defaults( $prefix, $text_shadow_style, $text_shadow_vertical_length, '0em' ),
'default_on_child' => true,
'allowed_units' => array( 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ),
'toggle_slug' => $toggle_slug,
'depends_show_if_not' => 'none',
'mobile_options' => true,
$text_shadow_blur_strength => array(
'description' => esc_html__( 'The higher the value, the bigger the blur, the shadow becomes wider and lighter.', 'et_builder' ),
'option_category' => $option_category,
'range_settings' => array(
'default' => $this->get_defaults( $prefix, $text_shadow_style, $text_shadow_blur_strength, '0em' ),
'default_on_child' => true,
'allowed_units' => array( 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ),
'toggle_slug' => $toggle_slug,
'depends_show_if_not' => 'none',
'mobile_options' => true,
$text_shadow_color => array(
'description' => esc_html__( 'The color of the shadow.', 'et_builder' ),
'option_category' => $option_category,
'default' => 'rgba(0,0,0,0.4)',
'default_on_child' => true,
'toggle_slug' => $toggle_slug,
'depends_show_if_not' => 'none',
'mobile_options' => true,
// Only add sub_toggle to fields if defined
if ( false !== $sub_toggle ) {
$fields[ $text_shadow_style ]['sub_toggle'] = $sub_toggle;
$fields[ $text_shadow_vertical_length ]['sub_toggle'] = $sub_toggle;
$fields[ $text_shadow_horizontal_length ]['sub_toggle'] = $sub_toggle;
$fields[ $text_shadow_blur_strength ]['sub_toggle'] = $sub_toggle;
$fields[ $text_shadow_color ]['sub_toggle'] = $sub_toggle;
// add conditional settings if defined
if ( '' !== $config['show_if'] ) {
$fields[ $text_shadow_style ]['show_if'] = $config['show_if'];
if ( '' !== $config['show_if_not'] ) {
$fields[ $text_shadow_style ]['show_if_not'] = $config['show_if_not'];
if ( '' !== $config['depends_show_if'] ) {
$fields[ $text_shadow_style ]['depends_show_if'] = $config['depends_show_if'];
if ( '' !== $config['depends_show_if_not'] ) {
$fields[ $text_shadow_style ]['depends_show_if_not'] = $config['depends_show_if_not'];
* Returns whether a declaration should be added !important or not.
* @param array $options Field definition.
* @param string $key Property name.
public function get_important( $options, $key = false ) {
if ( ! isset( $options['css']['important'] ) ) {
$important = $options['css']['important'];
if ( 'all' === $important || ($this->is_plugin_active && 'plugin_only' === $important) ) {
if ( is_array( $important ) ) {
if ( $this->is_plugin_active && in_array( 'plugin_all', $important ) ) {
if ( false !== $key && in_array( $key, $important ) ) {
* Returns the text-shadow declaration
* @since 3.23 Add responsive settings support to get the correct tablet and phone values.
* @param string $label Prefix.
* @param bool $important Whether to add !important or not.
* @param array $all_values All shortcode values.
* @param bool $is_hover Hover status.
* @param string $device Current active device.
public function get_declaration( $label, $important, $all_values, $is_hover = false, $device = 'desktop' ) {
$prefix = $label ? "{$label}_" : '';
$hover = et_pb_hover_options();
$utils = ET_Core_Data_Utils::instance();
$responsive = ET_Builder_Module_Helper_ResponsiveOptions::instance();
$is_desktop = 'desktop' === $device;
// Responsive styles. Ensure to render when at least one of the fields activate responsive
// settings to avoid unnecessary CSS styles rendered.
$is_any_shadow_responsive = false;
if ( ! $is_desktop && ! $is_hover ) {
$is_any_shadow_responsive = $responsive->is_any_responsive_enabled( $all_values, array(
"{$prefix}text_shadow_horizontal_length",
"{$prefix}text_shadow_vertical_length",
"{$prefix}text_shadow_blur_strength",
"{$prefix}text_shadow_color",
if ( ! $is_any_shadow_responsive ) {
foreach ( $this->properties as $property ) {
// As default, we will return desktop value.
$prop = "{$prefix}text_shadow_{$property}";
$value = $utils->array_get( $all_values, $prop, '' );
if ( $is_any_shadow_responsive ) {
// If current device is mobile (responsive settings is enabled already checked above),
// return any value exist.
$value = $responsive->is_responsive_enabled( $all_values, $prop ) ? $responsive->get_any_value( $all_values, "{$prop}{$suffix}", '', true ) : $value;
} else if ( $is_hover ) {
$value = $hover->get_value( $prop, $all_values, $value );
et_core_esc_previously( join( ' ', array_filter( $text_shadow ) ) ),
$important ? '!important' : ''