Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/includes/builder/module/field
File: MarginPadding.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Module Margin and Padding class.
[3] Fix | Delete
*
[4] Fix | Delete
* This is not how main module margin and padding is generated. Mostly used by other custom options
[5] Fix | Delete
* group such as Button and Field Input. Doesn't support selective padding yet.
[6] Fix | Delete
*
[7] Fix | Delete
* Copy of ET_Builder_Element::process_advanced_custom_margin_options().
[8] Fix | Delete
*
[9] Fix | Delete
* @since 3.23
[10] Fix | Delete
* @since 4.6.0 Add sticky style support
[11] Fix | Delete
*/
[12] Fix | Delete
class ET_Builder_Module_Field_MarginPadding extends ET_Builder_Module_Field_Base {
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* True when Divi plugin is active.
[16] Fix | Delete
*
[17] Fix | Delete
* @since 3.23
[18] Fix | Delete
*
[19] Fix | Delete
* @var bool
[20] Fix | Delete
*/
[21] Fix | Delete
public $is_plugin_active = false;
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Margin padding properties.
[25] Fix | Delete
*
[26] Fix | Delete
* @since 3.23
[27] Fix | Delete
*
[28] Fix | Delete
* @var array
[29] Fix | Delete
*/
[30] Fix | Delete
public $properties;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Margin padding config.
[34] Fix | Delete
*
[35] Fix | Delete
* @since 3.23
[36] Fix | Delete
*
[37] Fix | Delete
* @var array
[38] Fix | Delete
*/
[39] Fix | Delete
public $config;
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Constructor.
[43] Fix | Delete
*/
[44] Fix | Delete
public function __construct() {
[45] Fix | Delete
$this->is_plugin_active = et_is_builder_plugin_active();
[46] Fix | Delete
$this->properties = array(
[47] Fix | Delete
'custom_padding',
[48] Fix | Delete
'custom_padding_tablet',
[49] Fix | Delete
'custom_padding_phone',
[50] Fix | Delete
'custom_padding_last_edited',
[51] Fix | Delete
'custom_margin',
[52] Fix | Delete
'custom_margin_tablet',
[53] Fix | Delete
'custom_margin_phone',
[54] Fix | Delete
'custom_margin_last_edited',
[55] Fix | Delete
'padding_1_last_edited',
[56] Fix | Delete
'padding_2_last_edited',
[57] Fix | Delete
'padding_3_last_edited',
[58] Fix | Delete
'padding_4_last_edited',
[59] Fix | Delete
);
[60] Fix | Delete
$this->config = array(
[61] Fix | Delete
'label' => '',
[62] Fix | Delete
'prefix' => '',
[63] Fix | Delete
'tab_slug' => 'advanced',
[64] Fix | Delete
'toggle_slug' => 'margin_padding',
[65] Fix | Delete
'option_category' => 'layout',
[66] Fix | Delete
'depends_show_if' => '',
[67] Fix | Delete
'depends_show_if_not' => '',
[68] Fix | Delete
'use_padding' => true,
[69] Fix | Delete
'use_margin' => true,
[70] Fix | Delete
'mobile_options' => true,
[71] Fix | Delete
'sticky' => true,
[72] Fix | Delete
'hover' => 'tabs',
[73] Fix | Delete
'custom_padding' => '',
[74] Fix | Delete
'custom_margin' => '',
[75] Fix | Delete
'depends_show_if' => 'on',
[76] Fix | Delete
'priority' => 90,
[77] Fix | Delete
);
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
/**
[81] Fix | Delete
* Returns prefixed field names.
[82] Fix | Delete
*
[83] Fix | Delete
* @since 3.23
[84] Fix | Delete
*
[85] Fix | Delete
* @param string $prefix Prefix.
[86] Fix | Delete
*
[87] Fix | Delete
* @return array
[88] Fix | Delete
*/
[89] Fix | Delete
public function get_prefixed_field_names( $prefix ) {
[90] Fix | Delete
$prefix = $prefix ? "{$prefix}_" : '';
[91] Fix | Delete
[92] Fix | Delete
return array(
[93] Fix | Delete
"{$prefix}custom_padding",
[94] Fix | Delete
"{$prefix}custom_padding_tablet",
[95] Fix | Delete
"{$prefix}custom_padding_phone",
[96] Fix | Delete
"{$prefix}custom_padding_last_edited",
[97] Fix | Delete
"{$prefix}custom_margin",
[98] Fix | Delete
"{$prefix}custom_margin_tablet",
[99] Fix | Delete
"{$prefix}custom_margin_phone",
[100] Fix | Delete
"{$prefix}custom_margin_last_edited",
[101] Fix | Delete
"{$prefix}padding_1_last_edited",
[102] Fix | Delete
"{$prefix}padding_2_last_edited",
[103] Fix | Delete
"{$prefix}padding_3_last_edited",
[104] Fix | Delete
"{$prefix}padding_4_last_edited",
[105] Fix | Delete
);
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Add selector prefix if needed.
[110] Fix | Delete
*
[111] Fix | Delete
* @since 3.23
[112] Fix | Delete
*
[113] Fix | Delete
* Custom margin & padding selector for button element. This is custom selector exist on
[114] Fix | Delete
* ET_Builder_Element. We should do the samething to override hardcoded padding generated
[115] Fix | Delete
* by button element.
[116] Fix | Delete
*
[117] Fix | Delete
* @see ET_Builder_Element::process_advanced_button_options
[118] Fix | Delete
*/
[119] Fix | Delete
public function get_prefixed_selector( $css_element, $type = '', $is_divi_builder_plugin = false ) {
[120] Fix | Delete
// See ET_Builder_Element->process_advanced_button_options() on generating $css_element_processed
[121] Fix | Delete
// for non Divi Builder Plugin. Explicitly add '.et_pb_section' to the selector so selector
[122] Fix | Delete
// splitting during prefixing does not incorrectly add third party classes before #et-boc.
[123] Fix | Delete
if ( 'button' === $type && ! $is_divi_builder_plugin ) {
[124] Fix | Delete
$css_element = "body #page-container .et_pb_section {$css_element}";
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
return $css_element;
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
/**
[131] Fix | Delete
* Returns fields definition.
[132] Fix | Delete
*
[133] Fix | Delete
* @since 3.23
[134] Fix | Delete
*
[135] Fix | Delete
* @param array $args Field configuration.
[136] Fix | Delete
*
[137] Fix | Delete
* @return array
[138] Fix | Delete
*/
[139] Fix | Delete
public function get_fields( array $args = array() ) {
[140] Fix | Delete
$fields = array();
[141] Fix | Delete
$config = wp_parse_args( $args, $this->config );
[142] Fix | Delete
[143] Fix | Delete
// Config details.
[144] Fix | Delete
$tab_slug = $config['tab_slug'];
[145] Fix | Delete
$toggle_slug = $config['toggle_slug'];
[146] Fix | Delete
[147] Fix | Delete
list(
[148] Fix | Delete
$custom_padding,
[149] Fix | Delete
$custom_padding_tablet,
[150] Fix | Delete
$custom_padding_phone,
[151] Fix | Delete
$custom_padding_last_edited,
[152] Fix | Delete
$custom_margin,
[153] Fix | Delete
$custom_margin_tablet,
[154] Fix | Delete
$custom_margin_phone,
[155] Fix | Delete
$custom_margin_last_edited,
[156] Fix | Delete
$padding_1_last_edited,
[157] Fix | Delete
$padding_2_last_edited,
[158] Fix | Delete
$padding_3_last_edited,
[159] Fix | Delete
$padding_4_last_edited,
[160] Fix | Delete
) = $this->get_prefixed_field_names( $config['prefix'] );
[161] Fix | Delete
[162] Fix | Delete
// Custom margin.
[163] Fix | Delete
if ( $config['use_margin'] ) {
[164] Fix | Delete
$fields[ $custom_margin ] = array(
[165] Fix | Delete
'label' => sprintf( esc_html__( '%1$s Margin', 'et_builder' ), $config['label'] ),
[166] Fix | Delete
'description' => esc_html__( 'Margin adds extra space to the outside of the element, increasing the distance between the element and other items on the page.', 'et_builder' ),
[167] Fix | Delete
'type' => 'custom_margin',
[168] Fix | Delete
'option_category' => $config['option_category'],
[169] Fix | Delete
'mobile_options' => $config['mobile_options'],
[170] Fix | Delete
'hover' => $config['hover'],
[171] Fix | Delete
'sticky' => $config['sticky'],
[172] Fix | Delete
'depends_show_if' => $config['depends_show_if'],
[173] Fix | Delete
'tab_slug' => $tab_slug,
[174] Fix | Delete
'toggle_slug' => $toggle_slug,
[175] Fix | Delete
'priority' => $config['priority'],
[176] Fix | Delete
);
[177] Fix | Delete
$fields[ $custom_margin_tablet ] = array(
[178] Fix | Delete
'type' => 'skip',
[179] Fix | Delete
'tab_slug' => $tab_slug,
[180] Fix | Delete
);
[181] Fix | Delete
$fields[ $custom_margin_phone ] = array(
[182] Fix | Delete
'type' => 'skip',
[183] Fix | Delete
'tab_slug' => $tab_slug,
[184] Fix | Delete
'toggle_slug' => $toggle_slug,
[185] Fix | Delete
);
[186] Fix | Delete
[187] Fix | Delete
// Make it possible to override/add options.
[188] Fix | Delete
if ( ! empty( $config['custom_margin'] ) ) {
[189] Fix | Delete
$fields[ $custom_margin ] = array_merge( $fields[ $custom_margin ], $config['custom_margin'] );
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
$fields[ $custom_margin_last_edited ] = array(
[193] Fix | Delete
'type' => 'skip',
[194] Fix | Delete
'tab_slug' => $tab_slug,
[195] Fix | Delete
'toggle_slug' => $toggle_slug,
[196] Fix | Delete
);
[197] Fix | Delete
[198] Fix | Delete
$fields[ $padding_1_last_edited ] = array(
[199] Fix | Delete
'type' => 'skip',
[200] Fix | Delete
'tab_slug' => $tab_slug,
[201] Fix | Delete
'toggle_slug' => $toggle_slug,
[202] Fix | Delete
);
[203] Fix | Delete
[204] Fix | Delete
$fields[ $padding_2_last_edited ] = array(
[205] Fix | Delete
'type' => 'skip',
[206] Fix | Delete
'tab_slug' => $tab_slug,
[207] Fix | Delete
'toggle_slug' => $toggle_slug,
[208] Fix | Delete
);
[209] Fix | Delete
[210] Fix | Delete
$fields[ $padding_3_last_edited ] = array(
[211] Fix | Delete
'type' => 'skip',
[212] Fix | Delete
'tab_slug' => $tab_slug,
[213] Fix | Delete
'toggle_slug' => $toggle_slug,
[214] Fix | Delete
);
[215] Fix | Delete
[216] Fix | Delete
$fields[ $padding_4_last_edited ] = array(
[217] Fix | Delete
'type' => 'skip',
[218] Fix | Delete
'tab_slug' => $tab_slug,
[219] Fix | Delete
'toggle_slug' => $toggle_slug,
[220] Fix | Delete
);
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
// Custom padding.
[224] Fix | Delete
if ( $config['use_padding'] ) {
[225] Fix | Delete
$fields[ $custom_padding ] = array(
[226] Fix | Delete
'label' => sprintf( esc_html__( '%1$s Padding', 'et_builder' ), $config['label'] ),
[227] Fix | Delete
'description' => esc_html__( 'Padding adds extra space to the inside of the element, increasing the distance between the edge of the element and its inner contents.', 'et_builder' ),
[228] Fix | Delete
'type' => 'custom_padding',
[229] Fix | Delete
'option_category' => $config['option_category'],
[230] Fix | Delete
'mobile_options' => $config['mobile_options'],
[231] Fix | Delete
'hover' => $config['hover'],
[232] Fix | Delete
'sticky' => $config['sticky'],
[233] Fix | Delete
'depends_show_if' => $config['depends_show_if'],
[234] Fix | Delete
'tab_slug' => $tab_slug,
[235] Fix | Delete
'toggle_slug' => $toggle_slug,
[236] Fix | Delete
'priority' => $config['priority'],
[237] Fix | Delete
);
[238] Fix | Delete
$fields[ $custom_padding_tablet ] = array(
[239] Fix | Delete
'type' => 'skip',
[240] Fix | Delete
'tab_slug' => $tab_slug,
[241] Fix | Delete
'toggle_slug' => $toggle_slug,
[242] Fix | Delete
);
[243] Fix | Delete
$fields[ $custom_padding_phone ] = array(
[244] Fix | Delete
'type' => 'skip',
[245] Fix | Delete
'tab_slug' => $tab_slug,
[246] Fix | Delete
'toggle_slug' => $toggle_slug,
[247] Fix | Delete
);
[248] Fix | Delete
[249] Fix | Delete
// Make it possible to override/add options.
[250] Fix | Delete
if ( ! empty( $config['custom_padding'] ) ) {
[251] Fix | Delete
$fields[ $custom_padding ] = array_merge( $fields[ $custom_padding ], $config['custom_padding'] );
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
$fields[ $custom_padding_last_edited ] = array(
[255] Fix | Delete
'type' => 'skip',
[256] Fix | Delete
'tab_slug' => $tab_slug,
[257] Fix | Delete
'toggle_slug' => $toggle_slug,
[258] Fix | Delete
);
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
return $fields;
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
/**
[265] Fix | Delete
* Adds CSS rule.
[266] Fix | Delete
*
[267] Fix | Delete
* @since 3.23
[268] Fix | Delete
* @since 4.6.0 Add sticky style support
[269] Fix | Delete
*
[270] Fix | Delete
* @see ET_Builder_Element->process_advanced_custom_margin_options()
[271] Fix | Delete
*
[272] Fix | Delete
* @param ET_Builder_Element $module Module object.
[273] Fix | Delete
* @param string $prefix Label.
[274] Fix | Delete
* @param array $options Field settings.
[275] Fix | Delete
* @param string $function_name Shortcode function.
[276] Fix | Delete
* @param string $type Margin padding type.
[277] Fix | Delete
*/
[278] Fix | Delete
public function update_styles( $module, $prefix, $options, $function_name, $type ) {
[279] Fix | Delete
$utils = ET_Core_Data_Utils::instance();
[280] Fix | Delete
$all_values = $module->props;
[281] Fix | Delete
$hover = et_pb_hover_options();
[282] Fix | Delete
$sticky = et_pb_sticky_options();
[283] Fix | Delete
$responsive = ET_Builder_Module_Helper_ResponsiveOptions::instance();
[284] Fix | Delete
$advanced_fields = $module->advanced_fields;
[285] Fix | Delete
$css = isset( $this->advanced_fields['margin_padding']['css'] ) ? $this->advanced_fields['margin_padding']['css'] : array();
[286] Fix | Delete
[287] Fix | Delete
// Conditional status.
[288] Fix | Delete
$is_divi_builder_plugin = et_is_builder_plugin_active();
[289] Fix | Delete
$is_important_set = isset( $options['css']['important'] );
[290] Fix | Delete
$is_global_important = $is_important_set && 'all' === $options['css']['important'];
[291] Fix | Delete
$is_use_padding = $utils->array_get( $options, 'use_padding', true );
[292] Fix | Delete
$is_use_margin = $utils->array_get( $options, 'use_margin', true );
[293] Fix | Delete
$is_sticky_module = $sticky->is_sticky_module( $all_values );
[294] Fix | Delete
[295] Fix | Delete
// Selectors.
[296] Fix | Delete
$main_selector = ! empty( $options['css']['main'] ) ? $options['css']['main'] : $module->main_css_element;
[297] Fix | Delete
$limited_selector = ! empty( $options['css']['limited_main'] ) ? $options['css']['limited_main'] : '';
[298] Fix | Delete
$default_selector = $is_divi_builder_plugin && ! empty( $limited_selector ) ? $limited_selector : $main_selector;
[299] Fix | Delete
[300] Fix | Delete
// Get important CSS list.
[301] Fix | Delete
$important_options = array();
[302] Fix | Delete
if ( $is_important_set && is_array( $options['css']['important'] ) ) {
[303] Fix | Delete
$important_options = $options['css']['important'];
[304] Fix | Delete
}
[305] Fix | Delete
[306] Fix | Delete
// A. Padding.
[307] Fix | Delete
if ( $is_use_padding ) {
[308] Fix | Delete
// Padding Selectors.
[309] Fix | Delete
$padding_selector = ! empty( $options['css']['padding'] ) ? $options['css']['padding'] : $default_selector;
[310] Fix | Delete
[311] Fix | Delete
$padding_selector_processed = $this->get_prefixed_selector( $padding_selector, $type, $is_divi_builder_plugin );
[312] Fix | Delete
if ( $is_divi_builder_plugin && ! empty( $limited_selector ) ) {
[313] Fix | Delete
$padding_selector_processed = $padding_selector;
[314] Fix | Delete
}
[315] Fix | Delete
[316] Fix | Delete
// A.1. Responsive Padding.
[317] Fix | Delete
$is_padding_responsive = $responsive->is_responsive_enabled( $all_values, "{$prefix}_custom_padding" );
[318] Fix | Delete
[319] Fix | Delete
$padding_desktop = $responsive->get_any_value( $all_values, "{$prefix}_custom_padding" );
[320] Fix | Delete
$padding_tablet = $is_padding_responsive ? $responsive->get_any_value( $all_values, "{$prefix}_custom_padding_tablet" ) : '';
[321] Fix | Delete
$padding_phone = $is_padding_responsive ? $responsive->get_any_value( $all_values, "{$prefix}_custom_padding_phone" ) : '';
[322] Fix | Delete
[323] Fix | Delete
$important = in_array( 'custom_padding', $important_options ) || $is_global_important ? true : false;
[324] Fix | Delete
[325] Fix | Delete
$padding_styles = array(
[326] Fix | Delete
'desktop' => '' !== $padding_desktop ? rtrim( et_builder_get_element_style_css( $padding_desktop, 'padding', $important ) ) : '',
[327] Fix | Delete
'tablet' => '' !== $padding_tablet ? rtrim( et_builder_get_element_style_css( $padding_tablet, 'padding', $important ) ) : '',
[328] Fix | Delete
'phone' => '' !== $padding_phone ? rtrim( et_builder_get_element_style_css( $padding_phone, 'padding', $important ) ) : '',
[329] Fix | Delete
);
[330] Fix | Delete
[331] Fix | Delete
$responsive->declare_responsive_css( $padding_styles, $padding_selector_processed, $function_name, $module->get_style_priority() );
[332] Fix | Delete
[333] Fix | Delete
// A.2. Hover Padding.
[334] Fix | Delete
$custom_padding_hover = $hover->get_value( "{$prefix}_custom_padding", $all_values, '' );
[335] Fix | Delete
[336] Fix | Delete
if ( '' !== $custom_padding_hover && et_builder_is_hover_enabled( "{$prefix}_custom_padding", $all_values ) ) {
[337] Fix | Delete
[338] Fix | Delete
$padding_hover_selector = $utils->array_get( $options, 'css.hover', $hover->add_hover_to_selectors( $padding_selector ) );
[339] Fix | Delete
[340] Fix | Delete
$padding_hover_selector_processed = $this->get_prefixed_selector( $padding_hover_selector, $type, $is_divi_builder_plugin );
[341] Fix | Delete
if ( $is_divi_builder_plugin && ! empty( $limited_selector ) ) {
[342] Fix | Delete
$padding_hover_selector_processed = $padding_hover_selector;
[343] Fix | Delete
}
[344] Fix | Delete
[345] Fix | Delete
$el_style = array(
[346] Fix | Delete
'selector' => $padding_hover_selector_processed,
[347] Fix | Delete
'declaration' => rtrim( et_builder_get_element_style_css( $custom_padding_hover, 'padding', true ) ),
[348] Fix | Delete
'priority' => 20,
[349] Fix | Delete
);
[350] Fix | Delete
ET_Builder_Element::set_style( $function_name, $el_style );
[351] Fix | Delete
}
[352] Fix | Delete
[353] Fix | Delete
// A.3. Sticky Padding.
[354] Fix | Delete
$custom_padding_sticky = $sticky->get_value( "{$prefix}_custom_padding", $all_values, '' );
[355] Fix | Delete
[356] Fix | Delete
if ( '' !== $custom_padding_sticky && $sticky->is_enabled( "{$prefix}_custom_padding", $all_values ) ) {
[357] Fix | Delete
$padding_sticky_selector = $sticky->add_sticky_to_order_class(
[358] Fix | Delete
$padding_selector,
[359] Fix | Delete
$is_sticky_module
[360] Fix | Delete
);
[361] Fix | Delete
[362] Fix | Delete
$padding_sticky_selector_processed = $this->get_prefixed_selector(
[363] Fix | Delete
$padding_sticky_selector,
[364] Fix | Delete
$type,
[365] Fix | Delete
$is_divi_builder_plugin
[366] Fix | Delete
);
[367] Fix | Delete
[368] Fix | Delete
if ( $is_divi_builder_plugin && ! empty( $limited_selector ) ) {
[369] Fix | Delete
$padding_sticky_selector_processed = $padding_sticky_selector;
[370] Fix | Delete
}
[371] Fix | Delete
[372] Fix | Delete
ET_Builder_Element::set_style(
[373] Fix | Delete
$function_name,
[374] Fix | Delete
array(
[375] Fix | Delete
'selector' => $padding_sticky_selector_processed,
[376] Fix | Delete
'declaration' => rtrim(
[377] Fix | Delete
et_builder_get_element_style_css(
[378] Fix | Delete
$custom_padding_sticky,
[379] Fix | Delete
'padding',
[380] Fix | Delete
true
[381] Fix | Delete
)
[382] Fix | Delete
),
[383] Fix | Delete
'priority' => 20,
[384] Fix | Delete
)
[385] Fix | Delete
);
[386] Fix | Delete
}
[387] Fix | Delete
}
[388] Fix | Delete
[389] Fix | Delete
// B. Margin.
[390] Fix | Delete
if ( $is_use_margin ) {
[391] Fix | Delete
// Margin Selectors.
[392] Fix | Delete
$margin_selector = ! empty( $options['css']['margin'] ) ? $options['css']['margin'] : $default_selector;
[393] Fix | Delete
[394] Fix | Delete
$margin_selector_processed = $this->get_prefixed_selector( $margin_selector, $type, $is_divi_builder_plugin );
[395] Fix | Delete
if ( $is_divi_builder_plugin && ! empty( $limited_selector ) ) {
[396] Fix | Delete
$margin_selector_processed = $margin_selector;
[397] Fix | Delete
}
[398] Fix | Delete
[399] Fix | Delete
// A.1. Responsive margin.
[400] Fix | Delete
$is_margin_responsive = $responsive->is_responsive_enabled( $all_values, "{$prefix}_custom_margin" );
[401] Fix | Delete
[402] Fix | Delete
$margin_desktop = $responsive->get_any_value( $all_values, "{$prefix}_custom_margin" );
[403] Fix | Delete
$margin_tablet = $is_margin_responsive ? $responsive->get_any_value( $all_values, "{$prefix}_custom_margin_tablet" ) : '';
[404] Fix | Delete
$margin_phone = $is_margin_responsive ? $responsive->get_any_value( $all_values, "{$prefix}_custom_margin_phone" ) : '';
[405] Fix | Delete
[406] Fix | Delete
$important = in_array( 'custom_margin', $important_options ) || $is_global_important ? true : false;
[407] Fix | Delete
[408] Fix | Delete
$margin_styles = array(
[409] Fix | Delete
'desktop' => '' !== $margin_desktop ? rtrim( et_builder_get_element_style_css( $margin_desktop, 'margin', $important ) ) : '',
[410] Fix | Delete
'tablet' => '' !== $margin_tablet ? rtrim( et_builder_get_element_style_css( $margin_tablet, 'margin', $important ) ) : '',
[411] Fix | Delete
'phone' => '' !== $margin_phone ? rtrim( et_builder_get_element_style_css( $margin_phone, 'margin', $important ) ) : '',
[412] Fix | Delete
);
[413] Fix | Delete
[414] Fix | Delete
$responsive->declare_responsive_css( $margin_styles, $margin_selector_processed, $function_name, $module->get_style_priority() );
[415] Fix | Delete
[416] Fix | Delete
// A.2. Hover margin.
[417] Fix | Delete
$custom_margin_hover = $hover->get_value( "{$prefix}_custom_margin", $all_values, '' );
[418] Fix | Delete
[419] Fix | Delete
if ( '' !== $custom_margin_hover && et_builder_is_hover_enabled( "{$prefix}_custom_margin", $all_values ) ) {
[420] Fix | Delete
[421] Fix | Delete
$margin_hover_selector = $utils->array_get( $options, 'css.hover', $hover->add_hover_to_selectors( $margin_selector ) );
[422] Fix | Delete
[423] Fix | Delete
$margin_hover_selector_processed = $this->get_prefixed_selector( $margin_hover_selector, $type, $is_divi_builder_plugin );
[424] Fix | Delete
if ( $is_divi_builder_plugin && ! empty( $limited_selector ) ) {
[425] Fix | Delete
$margin_hover_selector_processed = $margin_hover_selector;
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
$el_style = array(
[429] Fix | Delete
'selector' => $margin_hover_selector_processed,
[430] Fix | Delete
'declaration' => rtrim( et_builder_get_element_style_css( $custom_margin_hover, 'margin', true ) ),
[431] Fix | Delete
'priority' => 20,
[432] Fix | Delete
);
[433] Fix | Delete
ET_Builder_Element::set_style( $function_name, $el_style );
[434] Fix | Delete
}
[435] Fix | Delete
[436] Fix | Delete
// A.3. Hover margin.
[437] Fix | Delete
$custom_margin_sticky = $sticky->get_value( "{$prefix}_custom_margin", $all_values, '' );
[438] Fix | Delete
[439] Fix | Delete
if ( '' !== $custom_margin_sticky && $sticky->is_enabled( "{$prefix}_custom_margin", $all_values ) ) {
[440] Fix | Delete
[441] Fix | Delete
$margin_sticky_selector = $sticky->add_sticky_to_order_class(
[442] Fix | Delete
$margin_selector,
[443] Fix | Delete
$is_sticky_module
[444] Fix | Delete
);
[445] Fix | Delete
[446] Fix | Delete
$margin_sticky_selector_processed = $this->get_prefixed_selector(
[447] Fix | Delete
$margin_sticky_selector,
[448] Fix | Delete
$type,
[449] Fix | Delete
$is_divi_builder_plugin
[450] Fix | Delete
);
[451] Fix | Delete
[452] Fix | Delete
if ( $is_divi_builder_plugin && ! empty( $limited_selector ) ) {
[453] Fix | Delete
$margin_sticky_selector_processed = $margin_sticky_selector;
[454] Fix | Delete
}
[455] Fix | Delete
[456] Fix | Delete
ET_Builder_Element::set_style(
[457] Fix | Delete
$function_name,
[458] Fix | Delete
array(
[459] Fix | Delete
'selector' => $margin_sticky_selector_processed,
[460] Fix | Delete
'declaration' => rtrim(
[461] Fix | Delete
et_builder_get_element_style_css(
[462] Fix | Delete
$custom_margin_sticky,
[463] Fix | Delete
'margin',
[464] Fix | Delete
true
[465] Fix | Delete
)
[466] Fix | Delete
),
[467] Fix | Delete
'priority' => 20,
[468] Fix | Delete
)
[469] Fix | Delete
);
[470] Fix | Delete
}
[471] Fix | Delete
}
[472] Fix | Delete
}
[473] Fix | Delete
[474] Fix | Delete
/**
[475] Fix | Delete
* Process Margin & Padding options and adds CSS rules.
[476] Fix | Delete
*
[477] Fix | Delete
* @since 3.23
[478] Fix | Delete
*
[479] Fix | Delete
* @param ET_Builder_Element $module Module object.
[480] Fix | Delete
* @param string $function_name Shortcode function.
[481] Fix | Delete
*/
[482] Fix | Delete
public function process_advanced_css( $module, $function_name ) {
[483] Fix | Delete
$utils = ET_Core_Data_Utils::instance();
[484] Fix | Delete
$all_values = $module->props;
[485] Fix | Delete
$advanced_fields = $module->advanced_fields;
[486] Fix | Delete
[487] Fix | Delete
// Disable if module doesn't set advanced_fields property and has no VB support.
[488] Fix | Delete
if ( ! $module->has_vb_support() && ! $module->has_advanced_fields ) {
[489] Fix | Delete
return;
[490] Fix | Delete
}
[491] Fix | Delete
[492] Fix | Delete
$allowed_advanced_fields = array( 'form_field', 'button' );
[493] Fix | Delete
foreach ( $allowed_advanced_fields as $advanced_field ) {
[494] Fix | Delete
if ( empty( $advanced_fields[ $advanced_field ] ) ) {
[495] Fix | Delete
continue;
[496] Fix | Delete
}
[497] Fix | Delete
[498] Fix | Delete
foreach ( $advanced_fields[ $advanced_field ] as $label => $form_field ) {
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function