Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../themes/Divi/includes/builder/module/field
File: TextShadow.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class ET_Builder_Module_Field_TextShadow extends ET_Builder_Module_Field_Base {
[2] Fix | Delete
[3] Fix | Delete
[4] Fix | Delete
/**
[5] Fix | Delete
* True when Divi plugin is active.
[6] Fix | Delete
*
[7] Fix | Delete
* @var bool
[8] Fix | Delete
*/
[9] Fix | Delete
public $is_plugin_active = false;
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Text shadow properties.
[13] Fix | Delete
*
[14] Fix | Delete
* @var array
[15] Fix | Delete
*/
[16] Fix | Delete
public $properties;
[17] Fix | Delete
[18] Fix | Delete
protected $template;
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Constructor.
[22] Fix | Delete
*/
[23] Fix | Delete
public function __construct() {
[24] Fix | Delete
$this->template = et_pb_option_template();
[25] Fix | Delete
$this->is_plugin_active = et_is_builder_plugin_active();
[26] Fix | Delete
$this->properties = array(
[27] Fix | Delete
'horizontal_length',
[28] Fix | Delete
'vertical_length',
[29] Fix | Delete
'blur_strength',
[30] Fix | Delete
'color',
[31] Fix | Delete
);
[32] Fix | Delete
$this->set_template();
[33] Fix | Delete
}//end __construct()
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Returns prefixed field names.
[37] Fix | Delete
*
[38] Fix | Delete
* @param string $prefix Prefix.
[39] Fix | Delete
*
[40] Fix | Delete
* @return array
[41] Fix | Delete
*/
[42] Fix | Delete
public function get_prefixed_field_names( $prefix ) {
[43] Fix | Delete
$prefix = $prefix ? "{$prefix}_" : '';
[44] Fix | Delete
[45] Fix | Delete
return array(
[46] Fix | Delete
"{$prefix}text_shadow_style",
[47] Fix | Delete
"{$prefix}text_shadow_horizontal_length",
[48] Fix | Delete
"{$prefix}text_shadow_vertical_length",
[49] Fix | Delete
"{$prefix}text_shadow_blur_strength",
[50] Fix | Delete
"{$prefix}text_shadow_color",
[51] Fix | Delete
);
[52] Fix | Delete
}//end get_prefixed_names()
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Returns Text Shadow presets.
[56] Fix | Delete
*
[57] Fix | Delete
* @param string $prefix Prefix.
[58] Fix | Delete
*
[59] Fix | Delete
* @return array
[60] Fix | Delete
*/
[61] Fix | Delete
public function get_presets( $prefix, $suffix = '' ) {
[62] Fix | Delete
list(
[63] Fix | Delete
$text_shadow_style,
[64] Fix | Delete
$text_shadow_horizontal_length,
[65] Fix | Delete
$text_shadow_vertical_length,
[66] Fix | Delete
$text_shadow_blur_strength,
[67] Fix | Delete
$text_shadow_color
[68] Fix | Delete
) = $this->get_prefixed_field_names( $prefix );
[69] Fix | Delete
[70] Fix | Delete
return array(
[71] Fix | Delete
array(
[72] Fix | Delete
'icon' => 'none',
[73] Fix | Delete
'value' => 'none',
[74] Fix | Delete
),
[75] Fix | Delete
array(
[76] Fix | Delete
'value' => 'preset1',
[77] Fix | Delete
'content' => array(
[78] Fix | Delete
'content' => 'aA',
[79] Fix | Delete
'class' => 'preset preset1',
[80] Fix | Delete
),
[81] Fix | Delete
'fields' => array(
[82] Fix | Delete
$text_shadow_horizontal_length => '0em',
[83] Fix | Delete
$text_shadow_vertical_length => '0.1em',
[84] Fix | Delete
$text_shadow_blur_strength => '0.1em',
[85] Fix | Delete
),
[86] Fix | Delete
),
[87] Fix | Delete
array(
[88] Fix | Delete
'value' => 'preset2',
[89] Fix | Delete
'content' => array(
[90] Fix | Delete
'content' => 'aA',
[91] Fix | Delete
'class' => 'preset preset2',
[92] Fix | Delete
),
[93] Fix | Delete
'fields' => array(
[94] Fix | Delete
$text_shadow_horizontal_length => '0.08em',
[95] Fix | Delete
$text_shadow_vertical_length => '0.08em',
[96] Fix | Delete
$text_shadow_blur_strength => '0.08em',
[97] Fix | Delete
),
[98] Fix | Delete
),
[99] Fix | Delete
array(
[100] Fix | Delete
'value' => 'preset3',
[101] Fix | Delete
'content' => array(
[102] Fix | Delete
'content' => 'aA',
[103] Fix | Delete
'class' => 'preset preset3',
[104] Fix | Delete
),
[105] Fix | Delete
'fields' => array(
[106] Fix | Delete
$text_shadow_horizontal_length => '0em',
[107] Fix | Delete
$text_shadow_vertical_length => '0em',
[108] Fix | Delete
$text_shadow_blur_strength => '0.3em',
[109] Fix | Delete
),
[110] Fix | Delete
),
[111] Fix | Delete
array(
[112] Fix | Delete
'value' => 'preset4',
[113] Fix | Delete
'content' => array(
[114] Fix | Delete
'content' => 'aA',
[115] Fix | Delete
'class' => 'preset preset4',
[116] Fix | Delete
),
[117] Fix | Delete
'fields' => array(
[118] Fix | Delete
$text_shadow_horizontal_length => '0em',
[119] Fix | Delete
$text_shadow_vertical_length => '0.08em',
[120] Fix | Delete
$text_shadow_blur_strength => '0em',
[121] Fix | Delete
),
[122] Fix | Delete
),
[123] Fix | Delete
array(
[124] Fix | Delete
'value' => 'preset5',
[125] Fix | Delete
'content' => array(
[126] Fix | Delete
'content' => 'aA',
[127] Fix | Delete
'class' => 'preset preset5',
[128] Fix | Delete
),
[129] Fix | Delete
'fields' => array(
[130] Fix | Delete
$text_shadow_horizontal_length => '0.08em',
[131] Fix | Delete
$text_shadow_vertical_length => '0.08em',
[132] Fix | Delete
$text_shadow_blur_strength => '0em',
[133] Fix | Delete
),
[134] Fix | Delete
),
[135] Fix | Delete
);
[136] Fix | Delete
}//end get_presets()
[137] Fix | Delete
[138] Fix | Delete
/**
[139] Fix | Delete
* Returns conditional defaults array.
[140] Fix | Delete
*
[141] Fix | Delete
* @param string $prefix Prefix.
[142] Fix | Delete
* @param string $depend Field whose value controls which default should be used.
[143] Fix | Delete
* @param string $field Field for which we're generating the defaults array.
[144] Fix | Delete
* @param string $default Default value to be used when a Preset doesn't include a value for $field.
[145] Fix | Delete
*
[146] Fix | Delete
* @return array
[147] Fix | Delete
*/
[148] Fix | Delete
public function get_defaults( $prefix, $depend, $field, $default ) {
[149] Fix | Delete
$presets = $this->get_presets( $prefix );
[150] Fix | Delete
$defaults = array();
[151] Fix | Delete
foreach ( $presets as $preset ) {
[152] Fix | Delete
$value = $preset['value'];
[153] Fix | Delete
$defaults[ $value ] = isset( $preset['fields'][ $field ] ) ? $preset['fields'][ $field ] : $default;
[154] Fix | Delete
}
[155] Fix | Delete
return array(
[156] Fix | Delete
$depend,
[157] Fix | Delete
$defaults,
[158] Fix | Delete
);
[159] Fix | Delete
}//end get_defaults()
[160] Fix | Delete
[161] Fix | Delete
/**
[162] Fix | Delete
* Set option template for Text Shadow
[163] Fix | Delete
*
[164] Fix | Delete
* @since 3.28
[165] Fix | Delete
*
[166] Fix | Delete
* @return void
[167] Fix | Delete
*/
[168] Fix | Delete
public function set_template() {
[169] Fix | Delete
$template = $this->template;
[170] Fix | Delete
if ( $template->is_enabled() && ! $template->has( 'text_shadow' ) ) {
[171] Fix | Delete
$template->add(
[172] Fix | Delete
'text_shadow',
[173] Fix | Delete
$this->get_fields( $template->placeholders( array(
[174] Fix | Delete
'label' => null,
[175] Fix | Delete
'prefix' => null,
[176] Fix | Delete
'tab_slug' => null,
[177] Fix | Delete
'toggle_slug' => null,
[178] Fix | Delete
'sub_toggle' => null,
[179] Fix | Delete
'option_category' => null,
[180] Fix | Delete
'depends_show_if' => null,
[181] Fix | Delete
'depends_show_if_not' => null,
[182] Fix | Delete
'show_if' => null,
[183] Fix | Delete
'show_if_not' => null,
[184] Fix | Delete
) ) )
[185] Fix | Delete
);
[186] Fix | Delete
}
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
/**
[190] Fix | Delete
* Returns fields definition.
[191] Fix | Delete
*
[192] Fix | Delete
* @since 3.23 Add mobile_options attributes for all fields to support responsive settings, except
[193] Fix | Delete
* text_shadow_style. Add allowed units for some fields with range type.
[194] Fix | Delete
*
[195] Fix | Delete
* @param array $args Field configuration.
[196] Fix | Delete
*
[197] Fix | Delete
* @return array
[198] Fix | Delete
*/
[199] Fix | Delete
public function get_fields( array $args = array() ) {
[200] Fix | Delete
[201] Fix | Delete
$config = shortcode_atts(
[202] Fix | Delete
array(
[203] Fix | Delete
'label' => '',
[204] Fix | Delete
'prefix' => '',
[205] Fix | Delete
'tab_slug' => 'advanced',
[206] Fix | Delete
'toggle_slug' => 'text',
[207] Fix | Delete
'sub_toggle' => false,
[208] Fix | Delete
'option_category' => 'configuration',
[209] Fix | Delete
'depends_show_if' => '',
[210] Fix | Delete
'depends_show_if_not' => '',
[211] Fix | Delete
'show_if' => '',
[212] Fix | Delete
'show_if_not' => '',
[213] Fix | Delete
),
[214] Fix | Delete
$args
[215] Fix | Delete
);
[216] Fix | Delete
[217] Fix | Delete
if ( $this->template->is_enabled() && $this->template->has( 'text_shadow' ) ) {
[218] Fix | Delete
return $this->template->create( 'text_shadow', $config );
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
$prefix = $config['prefix'];
[222] Fix | Delete
[223] Fix | Delete
list(
[224] Fix | Delete
$text_shadow_style,
[225] Fix | Delete
$text_shadow_horizontal_length,
[226] Fix | Delete
$text_shadow_vertical_length,
[227] Fix | Delete
$text_shadow_blur_strength,
[228] Fix | Delete
$text_shadow_color
[229] Fix | Delete
) = $this->get_prefixed_field_names( $prefix );
[230] Fix | Delete
[231] Fix | Delete
$tab_slug = $config['tab_slug'];
[232] Fix | Delete
$toggle_slug = $config['toggle_slug'];
[233] Fix | Delete
$sub_toggle = $config['sub_toggle'];
[234] Fix | Delete
$option_category = $config['option_category'];
[235] Fix | Delete
// 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.
[236] Fix | Delete
$option_category = 'configuration';
[237] Fix | Delete
[238] Fix | Delete
$label = $config['label'];
[239] Fix | Delete
if ( $label ) {
[240] Fix | Delete
$labels = array(
[241] Fix | Delete
// translators: text shadow group label
[242] Fix | Delete
sprintf( esc_html__( '%1$s Text Shadow', 'et_builder' ), $label ),
[243] Fix | Delete
// translators: text shadow group label
[244] Fix | Delete
sprintf( esc_html__( '%1$s Text Shadow Horizontal Length', 'et_builder' ), $label ),
[245] Fix | Delete
// translators: text shadow group label
[246] Fix | Delete
sprintf( esc_html__( '%1$s Text Shadow Vertical Length', 'et_builder' ), $label ),
[247] Fix | Delete
// translators: text shadow group label
[248] Fix | Delete
sprintf( esc_html__( '%1$s Text Shadow Blur Strength', 'et_builder' ), $label ),
[249] Fix | Delete
// translators: text shadow group label
[250] Fix | Delete
sprintf( esc_html__( '%1$s Text Shadow Color', 'et_builder' ), $label ),
[251] Fix | Delete
);
[252] Fix | Delete
} else {
[253] Fix | Delete
$labels = array(
[254] Fix | Delete
esc_html__( 'Text Shadow', 'et_builder' ),
[255] Fix | Delete
esc_html__( 'Text Shadow Horizontal Length', 'et_builder' ),
[256] Fix | Delete
esc_html__( 'Text Shadow Vertical Length', 'et_builder' ),
[257] Fix | Delete
esc_html__( 'Text Shadow Blur Strength', 'et_builder' ),
[258] Fix | Delete
esc_html__( 'Text Shadow Color', 'et_builder' ),
[259] Fix | Delete
);
[260] Fix | Delete
}
[261] Fix | Delete
$fields = array(
[262] Fix | Delete
$text_shadow_style => array(
[263] Fix | Delete
'label' => $labels[0],
[264] Fix | Delete
'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' ),
[265] Fix | Delete
'type' => 'presets_shadow',
[266] Fix | Delete
'option_category' => $option_category,
[267] Fix | Delete
'default' => 'none',
[268] Fix | Delete
'default_on_child' => true,
[269] Fix | Delete
'presets' => $this->get_presets( $prefix ),
[270] Fix | Delete
'tab_slug' => $tab_slug,
[271] Fix | Delete
'toggle_slug' => $toggle_slug,
[272] Fix | Delete
'sync_affects' => array(
[273] Fix | Delete
$text_shadow_horizontal_length,
[274] Fix | Delete
$text_shadow_vertical_length,
[275] Fix | Delete
$text_shadow_blur_strength,
[276] Fix | Delete
$text_shadow_color,
[277] Fix | Delete
),
[278] Fix | Delete
'affects' => array(
[279] Fix | Delete
$text_shadow_horizontal_length,
[280] Fix | Delete
$text_shadow_vertical_length,
[281] Fix | Delete
$text_shadow_blur_strength,
[282] Fix | Delete
$text_shadow_color,
[283] Fix | Delete
),
[284] Fix | Delete
'copy_with' => array(
[285] Fix | Delete
$text_shadow_horizontal_length,
[286] Fix | Delete
$text_shadow_vertical_length,
[287] Fix | Delete
$text_shadow_blur_strength,
[288] Fix | Delete
$text_shadow_color,
[289] Fix | Delete
),
[290] Fix | Delete
),
[291] Fix | Delete
$text_shadow_horizontal_length => array(
[292] Fix | Delete
'label' => $labels[1],
[293] Fix | Delete
'description' => esc_html__( 'Shadow\'s horizontal distance from the text. A negative value places the shadow to the left of the text.', 'et_builder' ),
[294] Fix | Delete
'type' => 'range',
[295] Fix | Delete
'hover' => 'tabs',
[296] Fix | Delete
'option_category' => $option_category,
[297] Fix | Delete
'range_settings' => array(
[298] Fix | Delete
'min' => -2,
[299] Fix | Delete
'max' => 2,
[300] Fix | Delete
'step' => 0.01,
[301] Fix | Delete
),
[302] Fix | Delete
'default' => $this->get_defaults( $prefix, $text_shadow_style, $text_shadow_horizontal_length, '0em' ),
[303] Fix | Delete
'default_on_child' => true,
[304] Fix | Delete
'hide_sync' => true,
[305] Fix | Delete
'validate_unit' => true,
[306] Fix | Delete
'allowed_units' => array( 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ),
[307] Fix | Delete
'default_unit' => 'em',
[308] Fix | Delete
'fixed_range' => true,
[309] Fix | Delete
'tab_slug' => $tab_slug,
[310] Fix | Delete
'toggle_slug' => $toggle_slug,
[311] Fix | Delete
'depends_show_if_not' => 'none',
[312] Fix | Delete
'mobile_options' => true,
[313] Fix | Delete
),
[314] Fix | Delete
$text_shadow_vertical_length => array(
[315] Fix | Delete
'label' => $labels[2],
[316] Fix | Delete
'description' => esc_html__( 'Shadow\'s vertical distance from the text. A negative value places the shadow above the text.', 'et_builder' ),
[317] Fix | Delete
'type' => 'range',
[318] Fix | Delete
'hover' => 'tabs',
[319] Fix | Delete
'option_category' => $option_category,
[320] Fix | Delete
'range_settings' => array(
[321] Fix | Delete
'min' => -2,
[322] Fix | Delete
'max' => 2,
[323] Fix | Delete
'step' => 0.01,
[324] Fix | Delete
),
[325] Fix | Delete
'default' => $this->get_defaults( $prefix, $text_shadow_style, $text_shadow_vertical_length, '0em' ),
[326] Fix | Delete
'default_on_child' => true,
[327] Fix | Delete
'hide_sync' => true,
[328] Fix | Delete
'validate_unit' => true,
[329] Fix | Delete
'allowed_units' => array( 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ),
[330] Fix | Delete
'default_unit' => 'em',
[331] Fix | Delete
'fixed_range' => true,
[332] Fix | Delete
'tab_slug' => $tab_slug,
[333] Fix | Delete
'toggle_slug' => $toggle_slug,
[334] Fix | Delete
'depends_show_if_not' => 'none',
[335] Fix | Delete
'mobile_options' => true,
[336] Fix | Delete
),
[337] Fix | Delete
$text_shadow_blur_strength => array(
[338] Fix | Delete
'label' => $labels[3],
[339] Fix | Delete
'description' => esc_html__( 'The higher the value, the bigger the blur, the shadow becomes wider and lighter.', 'et_builder' ),
[340] Fix | Delete
'type' => 'range',
[341] Fix | Delete
'hover' => 'tabs',
[342] Fix | Delete
'option_category' => $option_category,
[343] Fix | Delete
'range_settings' => array(
[344] Fix | Delete
'min' => 0,
[345] Fix | Delete
'max' => 2,
[346] Fix | Delete
'step' => 0.01,
[347] Fix | Delete
),
[348] Fix | Delete
'default' => $this->get_defaults( $prefix, $text_shadow_style, $text_shadow_blur_strength, '0em' ),
[349] Fix | Delete
'default_on_child' => true,
[350] Fix | Delete
'hide_sync' => true,
[351] Fix | Delete
'validate_unit' => true,
[352] Fix | Delete
'allowed_units' => array( 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ),
[353] Fix | Delete
'default_unit' => 'em',
[354] Fix | Delete
'fixed_range' => true,
[355] Fix | Delete
'tab_slug' => $tab_slug,
[356] Fix | Delete
'toggle_slug' => $toggle_slug,
[357] Fix | Delete
'depends_show_if_not' => 'none',
[358] Fix | Delete
'mobile_options' => true,
[359] Fix | Delete
),
[360] Fix | Delete
$text_shadow_color => array(
[361] Fix | Delete
'label' => $labels[4],
[362] Fix | Delete
'description' => esc_html__( 'The color of the shadow.', 'et_builder' ),
[363] Fix | Delete
'type' => 'color-alpha',
[364] Fix | Delete
'hover' => 'tabs',
[365] Fix | Delete
'option_category' => $option_category,
[366] Fix | Delete
'default' => 'rgba(0,0,0,0.4)',
[367] Fix | Delete
'default_on_child' => true,
[368] Fix | Delete
'hide_sync' => true,
[369] Fix | Delete
'tab_slug' => $tab_slug,
[370] Fix | Delete
'toggle_slug' => $toggle_slug,
[371] Fix | Delete
'depends_show_if_not' => 'none',
[372] Fix | Delete
'mobile_options' => true,
[373] Fix | Delete
),
[374] Fix | Delete
);
[375] Fix | Delete
[376] Fix | Delete
// Only add sub_toggle to fields if defined
[377] Fix | Delete
if ( false !== $sub_toggle ) {
[378] Fix | Delete
$fields[ $text_shadow_style ]['sub_toggle'] = $sub_toggle;
[379] Fix | Delete
$fields[ $text_shadow_vertical_length ]['sub_toggle'] = $sub_toggle;
[380] Fix | Delete
$fields[ $text_shadow_horizontal_length ]['sub_toggle'] = $sub_toggle;
[381] Fix | Delete
$fields[ $text_shadow_blur_strength ]['sub_toggle'] = $sub_toggle;
[382] Fix | Delete
$fields[ $text_shadow_color ]['sub_toggle'] = $sub_toggle;
[383] Fix | Delete
}
[384] Fix | Delete
[385] Fix | Delete
// add conditional settings if defined
[386] Fix | Delete
if ( '' !== $config['show_if'] ) {
[387] Fix | Delete
$fields[ $text_shadow_style ]['show_if'] = $config['show_if'];
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
if ( '' !== $config['show_if_not'] ) {
[391] Fix | Delete
$fields[ $text_shadow_style ]['show_if_not'] = $config['show_if_not'];
[392] Fix | Delete
}
[393] Fix | Delete
[394] Fix | Delete
if ( '' !== $config['depends_show_if'] ) {
[395] Fix | Delete
$fields[ $text_shadow_style ]['depends_show_if'] = $config['depends_show_if'];
[396] Fix | Delete
}
[397] Fix | Delete
[398] Fix | Delete
if ( '' !== $config['depends_show_if_not'] ) {
[399] Fix | Delete
$fields[ $text_shadow_style ]['depends_show_if_not'] = $config['depends_show_if_not'];
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
return $fields;
[403] Fix | Delete
}//end get_fields()
[404] Fix | Delete
[405] Fix | Delete
/**
[406] Fix | Delete
* Returns whether a declaration should be added !important or not.
[407] Fix | Delete
*
[408] Fix | Delete
* @param array $options Field definition.
[409] Fix | Delete
* @param string $key Property name.
[410] Fix | Delete
*
[411] Fix | Delete
* @return bool
[412] Fix | Delete
*/
[413] Fix | Delete
public function get_important( $options, $key = false ) {
[414] Fix | Delete
if ( ! isset( $options['css']['important'] ) ) {
[415] Fix | Delete
// nothing to do, bye
[416] Fix | Delete
return false;
[417] Fix | Delete
}
[418] Fix | Delete
[419] Fix | Delete
$important = $options['css']['important'];
[420] Fix | Delete
if ( 'all' === $important || ($this->is_plugin_active && 'plugin_only' === $important) ) {
[421] Fix | Delete
return true;
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
if ( is_array( $important ) ) {
[425] Fix | Delete
if ( $this->is_plugin_active && in_array( 'plugin_all', $important ) ) {
[426] Fix | Delete
return true;
[427] Fix | Delete
}
[428] Fix | Delete
if ( false !== $key && in_array( $key, $important ) ) {
[429] Fix | Delete
return true;
[430] Fix | Delete
}
[431] Fix | Delete
}
[432] Fix | Delete
[433] Fix | Delete
return false;
[434] Fix | Delete
}//end get_important()
[435] Fix | Delete
[436] Fix | Delete
/**
[437] Fix | Delete
* Returns the text-shadow declaration
[438] Fix | Delete
*
[439] Fix | Delete
* @since 3.23 Add responsive settings support to get the correct tablet and phone values.
[440] Fix | Delete
*
[441] Fix | Delete
* @param string $label Prefix.
[442] Fix | Delete
* @param bool $important Whether to add !important or not.
[443] Fix | Delete
* @param array $all_values All shortcode values.
[444] Fix | Delete
* @param bool $is_hover Hover status.
[445] Fix | Delete
* @param string $device Current active device.
[446] Fix | Delete
*
[447] Fix | Delete
* @return string
[448] Fix | Delete
*/
[449] Fix | Delete
public function get_declaration( $label, $important, $all_values, $is_hover = false, $device = 'desktop' ) {
[450] Fix | Delete
$prefix = $label ? "{$label}_" : '';
[451] Fix | Delete
$hover = et_pb_hover_options();
[452] Fix | Delete
$utils = ET_Core_Data_Utils::instance();
[453] Fix | Delete
$responsive = ET_Builder_Module_Helper_ResponsiveOptions::instance();
[454] Fix | Delete
$is_desktop = 'desktop' === $device;
[455] Fix | Delete
$suffix = '';
[456] Fix | Delete
[457] Fix | Delete
// Responsive styles. Ensure to render when at least one of the fields activate responsive
[458] Fix | Delete
// settings to avoid unnecessary CSS styles rendered.
[459] Fix | Delete
$is_any_shadow_responsive = false;
[460] Fix | Delete
if ( ! $is_desktop && ! $is_hover ) {
[461] Fix | Delete
$is_any_shadow_responsive = $responsive->is_any_responsive_enabled( $all_values, array(
[462] Fix | Delete
"{$prefix}text_shadow_horizontal_length",
[463] Fix | Delete
"{$prefix}text_shadow_vertical_length",
[464] Fix | Delete
"{$prefix}text_shadow_blur_strength",
[465] Fix | Delete
"{$prefix}text_shadow_color",
[466] Fix | Delete
) );
[467] Fix | Delete
[468] Fix | Delete
// Bail early
[469] Fix | Delete
if ( ! $is_any_shadow_responsive ) {
[470] Fix | Delete
return '';
[471] Fix | Delete
}
[472] Fix | Delete
[473] Fix | Delete
$suffix = "_{$device}";
[474] Fix | Delete
}
[475] Fix | Delete
[476] Fix | Delete
$text_shadow = array();
[477] Fix | Delete
foreach ( $this->properties as $property ) {
[478] Fix | Delete
// As default, we will return desktop value.
[479] Fix | Delete
$prop = "{$prefix}text_shadow_{$property}";
[480] Fix | Delete
$value = $utils->array_get( $all_values, $prop, '' );
[481] Fix | Delete
[482] Fix | Delete
if ( $is_any_shadow_responsive ) {
[483] Fix | Delete
// If current device is mobile (responsive settings is enabled already checked above),
[484] Fix | Delete
// return any value exist.
[485] Fix | Delete
$value = $responsive->is_responsive_enabled( $all_values, $prop ) ? $responsive->get_any_value( $all_values, "{$prop}{$suffix}", '', true ) : $value;
[486] Fix | Delete
} else if ( $is_hover ) {
[487] Fix | Delete
$value = $hover->get_value( $prop, $all_values, $value );
[488] Fix | Delete
}
[489] Fix | Delete
[490] Fix | Delete
$text_shadow[] = $value;
[491] Fix | Delete
}
[492] Fix | Delete
[493] Fix | Delete
return sprintf(
[494] Fix | Delete
'text-shadow: %s%s;',
[495] Fix | Delete
et_core_esc_previously( join( ' ', array_filter( $text_shadow ) ) ),
[496] Fix | Delete
$important ? '!important' : ''
[497] Fix | Delete
);
[498] Fix | Delete
}//end get_declaration()
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function