function shortcode_callback($atts, $content = null, $function_name) { $module_id = $this->shortcode_atts['module_id']; $module_class = $this->shortcode_atts['module_class']; $src = $this->shortcode_atts['src']; $alt = $this->shortcode_atts['alt']; $title_text = $this->shortcode_atts['title_text']; $animation = $this->shortcode_atts['animation']; $url = $this->shortcode_atts['url']; $url_new_window = $this->shortcode_atts['url_new_window']; $show_in_lightbox = $this->shortcode_atts['show_in_lightbox']; $sticky = $this->shortcode_atts['sticky']; $align = $this->shortcode_atts['align']; $max_width = $this->shortcode_atts['max_width']; $force_fullwidth = $this->shortcode_atts['force_fullwidth']; $always_center_on_mobile = $this->shortcode_atts['always_center_on_mobile']; $module_class = ET_Builder_Element::add_module_order_class($module_class, $function_name); if ('on' === $always_center_on_mobile) { $module_class .= ' et_always_center_on_mobile'; } if ('' !== $max_width) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%', 'declaration' => sprintf('max-width: %1$s;', esc_html(et_builder_process_range_value($max_width))))); } if ('on' === $force_fullwidth) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%% img', 'declaration' => 'width: 100%;')); } if ($this->fields_defaults['align'][0] !== $align) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%', 'declaration' => sprintf('text-align: %1$s;', esc_html($align)))); } if ('center' !== $align) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%', 'declaration' => sprintf('margin-%1$s: 0;', esc_html($align)))); } $output = sprintf('<img src="%1$s" alt="%2$s"%3$s />', esc_attr($src), esc_attr($alt), '' !== $title_text ? sprintf(' title="%1$s"', esc_attr($title_text)) : ''); if ('on' === $show_in_lightbox) { $output = sprintf('<a href="%1$s" class="et_pb_lightbox_image" title="%3$s">%2$s</a>', esc_url($src), $output, esc_attr($alt)); } else { if ('' !== $url) { $output = sprintf('<a href="%1$s"%3$s>%2$s</a>', esc_url($url), $output, 'on' === $url_new_window ? ' target="_blank"' : ''); } } $animation = '' === $animation ? ET_Global_Settings::get_value('et_pb_image-animation') : $animation; $output = sprintf('<div%5$s class="et_pb_module et-waypoint et_pb_image%2$s%3$s%4$s"> %1$s </div>', $output, esc_attr(" et_pb_animation_{$animation}"), '' !== $module_class ? sprintf(' %1$s', esc_attr(ltrim($module_class))) : '', 'on' === $sticky ? esc_attr(' et_pb_image_sticky') : '', '' !== $module_id ? sprintf(' id="%1$s"', esc_attr($module_id)) : ''); return $output; }
/** * Outputting saved module styles settings. DRY * * @return void */ function et_pb_print_module_styles_css($section = '', $settings = array()) { // Verify settings if (is_array($settings) && !empty($settings)) { // Loop settings foreach ($settings as $setting) { // settings must have these elements: key, selector, default, and type if (!isset($setting['key']) || !isset($setting['selector']) || !isset($setting['type'])) { continue; } // Some attributes such as shop requires !important tag if (isset($setting['important']) && true === $setting['important']) { $important = ' !important'; } else { $important = ''; } // Prepare the setting key $key = "{$section}-{$setting['key']}"; // Get the value $value = ET_Global_Settings::get_value($key); $default_value = ET_Global_Settings::get_value($key, 'default'); // Output CSS based on its type if (false !== $value && $default_value !== $value) { switch ($setting['type']) { case 'font-size': printf("%s { font-size: %spx%s; }\n", esc_html($setting['selector']), esc_html($value), $important); // Option with specific adjustment for smaller columns $smaller_title_sections = array('et_pb_audio-title_font_size', 'et_pb_blog-header_font_size', 'et_pb_cta-header_font_size', 'et_pb_contact_form-title_font_size', 'et_pb_login-header_font_size', 'et_pb_signup-header_font_size', 'et_pb_slider-header_font_size', 'et_pb_slider-body_font_size', 'et_pb_countdown_timer-header_font_size'); if (in_array($key, $smaller_title_sections)) { // font size coefficient switch ($key) { case 'et_pb_slider-header_font_size': $font_size_coefficient = 0.565217391; // 26/46 break; case 'et_pb_slider-body_font_size': $font_size_coefficient = 0.777777778; // 14/16 break; default: $font_size_coefficient = 0.846153846; // 22/26 break; } printf('.et_pb_column_1_3 %1$s, .et_pb_column_1_4 %1$s { font-size: %2$spx%3$s; }', esc_html($setting['selector']), esc_html($value * $font_size_coefficient), $important); } break; case 'font-size': $value = intval($value); printf(".et_pb_countdown_timer .title { font-size: %spx; }", esc_html($value)); printf(".et_pb_column_3_8 .et_pb_countdown_timer .title, .et_pb_column_1_3 .et_pb_countdown_timer .title, .et_pb_column_1_4 .et_pb_countdown_timer .title { font-size: %spx; }", esc_html($value * (18 / 22))); break; case 'font-style': printf("%s { %s }\n", esc_html($setting['selector']), et_pb_print_font_style($value, $important)); break; case 'color': printf("%s { color: %s%s; }\n", esc_html($setting['selector']), esc_html($value), $important); break; case 'background-color': printf("%s { background-color: %s%s; }\n", esc_html($setting['selector']), esc_html($value), $important); break; case 'border-radius': printf("%s { -moz-border-radius: %spx; -webkit-border-radius: %spx; border-radius: %spx; }\n", esc_html($setting['selector']), esc_html($value), esc_html($value), esc_html($value)); break; case 'width': printf("%s { width: %spx; }\n", esc_html($setting['selector']), esc_html($value)); break; case 'height': printf("%s { height: %spx; }\n", esc_html($setting['selector']), esc_html($value)); break; case 'padding': printf("%s { padding: %spx; }\n", esc_html($setting['selector']), esc_html($value)); break; case 'padding-top-bottom': printf("%s { padding: %spx 0; }\n", esc_html($setting['selector']), esc_html($value)); break; case 'padding-tabs': $padding_tab_top_bottom = intval($value) * 0.133333333; $padding_tab_active_top = $padding_tab_top_bottom + 1; $padding_tab_active_bottom = $padding_tab_top_bottom - 1; $padding_tab_content = intval($value) * 0.8; // negative result will cause layout issue if ($padding_tab_active_bottom < 0) { $padding_tab_active_bottom = 0; } printf(".et_pb_tabs_controls li{ padding: %spx %spx %spx; } .et_pb_tabs_controls li.et_pb_tab_active{ padding: %spx %spx; } .et_pb_all_tabs { padding: %spx %spx; }\n", esc_html($padding_tab_active_top), esc_html($value), esc_html($padding_tab_active_bottom), esc_html($padding_tab_top_bottom), esc_html($value), esc_html($padding_tab_content), esc_html($value)); break; case 'padding-slider': printf("%s { padding-top: %s; padding-bottom: %s }\n", esc_html($setting['selector']), esc_html($value) . '%', esc_html($value) . '%'); if ('et_pagebuilder_slider_padding' === $key) { printf('@media only screen and ( max-width: 767px ) { %1$s { padding-top: %2$s; padding-bottom: %2$s; } }', esc_html($setting['selector']), '16%'); } break; case 'padding-call-to-action': $value = intval($value); printf(".et_pb_promo { padding: %spx %spx !important; }", esc_html($value), esc_html($value * (60 / 40))); printf(".et_pb_column_1_2 .et_pb_promo, .et_pb_column_1_3 .et_pb_promo, .et_pb_column_1_4 .et_pb_promo { padding: %spx; }", esc_html($value)); break; case 'social-icon-size': $icon_margin = intval($value) * 0.57; $icon_dimension = intval($value) * 2; ?> .et_pb_social_media_follow li a.icon{ margin-right: <?php echo esc_html($icon_margin); ?> px; width: <?php echo esc_html($icon_dimension); ?> px; height: <?php echo esc_html($icon_dimension); ?> px; } .et_pb_social_media_follow li a.icon::before{ width: <?php echo esc_html($icon_dimension); ?> px; height: <?php echo esc_html($icon_dimension); ?> px; font-size: <?php echo esc_html($value); ?> px; line-height: <?php echo esc_html($icon_dimension); ?> px; } .et_pb_social_media_follow li a.follow_button{ font-size: <?php echo esc_html($value); ?> px; } <?php break; case 'border-top-style': printf("%s { border-top-style: %s; }\n", esc_html($setting['selector']), esc_html($value)); break; case 'border-top-width': printf("%s { border-top-width: %spx; }\n", esc_html($setting['selector']), esc_html($value)); break; } } } } }
private function _add_additional_button_fields() { if (!isset($this->advanced_options['button'])) { return; } $additional_options = array(); foreach ($this->advanced_options['button'] as $option_name => $option_settings) { $additional_options["custom_{$option_name}"] = array('label' => sprintf(__('Use Custom Styles for %1$s ', 'et_builder'), $option_settings['label']), 'type' => 'yes_no_button', 'option_category' => 'button', 'options' => array('off' => __('No', 'et_builder'), 'on' => __('Yes', 'et_builder')), 'affects' => array("#et_pb_{$option_name}_text_color", "#et_pb_{$option_name}_text_size", "#et_pb_{$option_name}_border_width", "#et_pb_{$option_name}_border_radius", "#et_pb_{$option_name}_letter_spacing", "#et_pb_{$option_name}_spacing", "#et_pb_{$option_name}_bg_color", "#et_pb_{$option_name}_border_color", "#et_pb_{$option_name}_use_icon", "#et_pb_{$option_name}_font", "#et_pb_{$option_name}_text_color_hover", "#et_pb_{$option_name}_bg_color_hover", "#et_pb_{$option_name}_border_color_hover", "#et_pb_{$option_name}_border_radius_hover", "#et_pb_{$option_name}_letter_spacing_hover"), 'shortcode_default' => 'off', 'tab_slug' => 'advanced'); $additional_options["{$option_name}_text_size"] = array('label' => sprintf(__('%1$s Text Size', 'et_builder'), $option_settings['label']), 'type' => 'range', 'option_category' => 'button', 'default' => ET_Global_Settings::get_value('all_buttons_font_size'), 'tab_slug' => 'advanced', 'depends_default' => true); $additional_options["{$option_name}_text_color"] = array('label' => sprintf(__('%1$s Text Color', 'et_builder'), $option_settings['label']), 'type' => 'color-alpha', 'option_category' => 'button', 'custom_color' => true, 'default' => '', 'shortcode_default' => '', 'tab_slug' => 'advanced', 'depends_default' => true); $additional_options["{$option_name}_bg_color"] = array('label' => sprintf(__('%1$s Background Color', 'et_builder'), $option_settings['label']), 'type' => 'color-alpha', 'option_category' => 'button', 'custom_color' => true, 'default' => ET_Global_Settings::get_value('all_buttons_bg_color'), 'shortcode_default' => '', 'tab_slug' => 'advanced', 'depends_default' => true); $additional_options["{$option_name}_border_width"] = array('label' => sprintf(__('%1$s Border Width', 'et_builder'), $option_settings['label']), 'type' => 'range', 'option_category' => 'button', 'default' => ET_Global_Settings::get_value('all_buttons_border_width'), 'shortcode_default' => '', 'tab_slug' => 'advanced', 'depends_default' => true); $additional_options["{$option_name}_border_color"] = array('label' => sprintf(__('%1$s Border Color', 'et_builder'), $option_settings['label']), 'type' => 'color-alpha', 'option_category' => 'button', 'custom_color' => true, 'default' => '', 'shortcode_default' => '', 'tab_slug' => 'advanced', 'depends_default' => true); $additional_options["{$option_name}_border_radius"] = array('label' => sprintf(__('%1$s Border Radius', 'et_builder'), $option_settings['label']), 'type' => 'range', 'option_category' => 'button', 'default' => ET_Global_Settings::get_value('all_buttons_border_radius'), 'shortcode_default' => '', 'tab_slug' => 'advanced', 'depends_default' => true); $additional_options["{$option_name}_letter_spacing"] = array('label' => sprintf(__('%1$s Letter Spacing', 'et_builder'), $option_settings['label']), 'type' => 'range', 'option_category' => 'button', 'default' => ET_Global_Settings::get_value('all_buttons_spacing'), 'shortcode_default' => '', 'tab_slug' => 'advanced', 'depends_default' => true); $additional_options["{$option_name}_font"] = array('label' => sprintf(__('%1$s Font', 'et_builder'), $option_settings['label']), 'type' => 'font', 'option_category' => 'button', 'tab_slug' => 'advanced', 'depends_default' => true); $additional_options["{$option_name}_use_icon"] = array('label' => sprintf(__('Add %1$s Icon', 'et_builder'), $option_settings['label']), 'type' => 'select', 'option_category' => 'button', 'options' => array('default' => __('Default', 'et_builder'), 'on' => __('Yes', 'et_builder'), 'off' => __('No', 'et_builder')), 'affects' => array("#et_pb_{$option_name}_icon_color", "#et_pb_{$option_name}_icon_placement", "#et_pb_{$option_name}_on_hover", "#et_pb_{$option_name}_icon"), 'shortcode_default' => 'on', 'tab_slug' => 'advanced', 'depends_default' => true); $additional_options["{$option_name}_icon"] = array('label' => sprintf(__('%1$s Icon', 'et_builder'), $option_settings['label']), 'type' => 'text', 'option_category' => 'button', 'class' => array('et-pb-font-icon'), 'renderer' => 'et_pb_get_font_icon_list', 'renderer_with_field' => true, 'default' => '', 'tab_slug' => 'advanced', 'depends_show_if_not' => 'off'); $additional_options["{$option_name}_icon_color"] = array('label' => sprintf(__('%1$s Icon Color', 'et_builder'), $option_settings['label']), 'type' => 'color-alpha', 'option_category' => 'button', 'custom_color' => true, 'default' => '', 'shortcode_default' => '', 'tab_slug' => 'advanced', 'depends_show_if_not' => 'off'); $additional_options["{$option_name}_icon_placement"] = array('label' => sprintf(__('%1$s Icon Placement', 'et_builder'), $option_settings['label']), 'type' => 'select', 'option_category' => 'button', 'options' => array('right' => __('Right', 'et_builder'), 'left' => __('Left', 'et_builder')), 'shortcode_default' => 'right', 'tab_slug' => 'advanced', 'depends_show_if_not' => 'off'); $additional_options["{$option_name}_on_hover"] = array('label' => sprintf(__('Only Show Icon On Hover for %1$s', 'et_builder'), $option_settings['label']), 'type' => 'yes_no_button', 'option_category' => 'button', 'options' => array('on' => __('Yes', 'et_builder'), 'off' => __('No', 'et_builder')), 'shortcode_default' => 'on', 'tab_slug' => 'advanced', 'depends_show_if_not' => 'off'); $additional_options["{$option_name}_text_color_hover"] = array('label' => sprintf(__('%1$s Hover Text Color', 'et_builder'), $option_settings['label']), 'type' => 'color-alpha', 'option_category' => 'button', 'custom_color' => true, 'default' => '', 'shortcode_default' => '', 'tab_slug' => 'advanced', 'depends_default' => true); $additional_options["{$option_name}_bg_color_hover"] = array('label' => sprintf(__('%1$s Hover Background Color', 'et_builder'), $option_settings['label']), 'type' => 'color-alpha', 'option_category' => 'button', 'custom_color' => true, 'default' => '', 'shortcode_default' => '', 'tab_slug' => 'advanced', 'depends_default' => true); $additional_options["{$option_name}_border_color_hover"] = array('label' => sprintf(__('%1$s Hover Border Color', 'et_builder'), $option_settings['label']), 'type' => 'color-alpha', 'option_category' => 'button', 'custom_color' => true, 'default' => '', 'shortcode_default' => '', 'tab_slug' => 'advanced', 'depends_default' => true); $additional_options["{$option_name}_border_radius_hover"] = array('label' => sprintf(__('%1$s Hover Border Radius', 'et_builder'), $option_settings['label']), 'type' => 'range', 'option_category' => 'button', 'default' => ET_Global_Settings::get_value('all_buttons_border_radius_hover'), 'shortcode_default' => '', 'tab_slug' => 'advanced', 'depends_default' => true); $additional_options["{$option_name}_letter_spacing_hover"] = array('label' => sprintf(__('%1$s Hover Letter Spacing', 'et_builder'), $option_settings['label']), 'type' => 'range', 'option_category' => 'button', 'default' => ET_Global_Settings::get_value('all_buttons_spacing_hover'), 'tab_slug' => 'advanced', 'depends_default' => true); } $this->_additional_fields_options = array_merge($this->_additional_fields_options, $additional_options); }
function shortcode_callback($atts, $content = null, $function_name) { $module_id = $this->shortcode_atts['module_id']; $module_class = $this->shortcode_atts['module_class']; $src = $this->shortcode_atts['src']; $alt = $this->shortcode_atts['alt']; $title_text = $this->shortcode_atts['title_text']; $animation = $this->shortcode_atts['animation']; $url = $this->shortcode_atts['url']; $url_new_window = $this->shortcode_atts['url_new_window']; $show_in_lightbox = $this->shortcode_atts['show_in_lightbox']; $sticky = $this->shortcode_atts['sticky']; $align = $this->shortcode_atts['align']; $max_width = $this->shortcode_atts['max_width']; $max_width_tablet = $this->shortcode_atts['max_width_tablet']; $max_width_phone = $this->shortcode_atts['max_width_phone']; $force_fullwidth = $this->shortcode_atts['force_fullwidth']; $always_center_on_mobile = $this->shortcode_atts['always_center_on_mobile']; $overlay_icon_color = $this->shortcode_atts['overlay_icon_color']; $hover_overlay_color = $this->shortcode_atts['hover_overlay_color']; $hover_icon = $this->shortcode_atts['hover_icon']; $use_overlay = $this->shortcode_atts['use_overlay']; $module_class = ET_Builder_Element::add_module_order_class($module_class, $function_name); if ('on' === $always_center_on_mobile) { $module_class .= ' et_always_center_on_mobile'; } // overlay can be applied only if image has link or if lightbox enabled $is_overlay_applied = 'on' === $use_overlay && ('on' === $show_in_lightbox || 'off' === $show_in_lightbox && '' !== $url) ? 'on' : 'off'; if ('' !== $max_width_tablet || '' !== $max_width_phone || '' !== $max_width) { $max_width_values = array('desktop' => $max_width, 'tablet' => $max_width_tablet, 'phone' => $max_width_phone); et_pb_generate_responsive_css($max_width_values, '%%order_class%%', 'max-width', $function_name); } if ('on' === $force_fullwidth) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%% img', 'declaration' => 'width: 100%;')); } if ($this->fields_defaults['align'][0] !== $align) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%', 'declaration' => sprintf('text-align: %1$s;', esc_html($align)))); } if ('center' !== $align) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%', 'declaration' => sprintf('margin-%1$s: 0;', esc_html($align)))); } if ('on' === $is_overlay_applied) { if ('' !== $overlay_icon_color) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%% .et_overlay:before', 'declaration' => sprintf('color: %1$s !important;', esc_html($overlay_icon_color)))); } if ('' !== $hover_overlay_color) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%% .et_overlay', 'declaration' => sprintf('background-color: %1$s;', esc_html($hover_overlay_color)))); } $data_icon = '' !== $hover_icon ? sprintf(' data-icon="%1$s"', esc_attr(et_pb_process_font_icon($hover_icon))) : ''; $overlay_output = sprintf('<span class="et_overlay%1$s"%2$s></span>', '' !== $hover_icon ? ' et_pb_inline_icon' : '', $data_icon); } $output = sprintf('<img src="%1$s" alt="%2$s"%3$s /> %4$s', esc_url($src), esc_attr($alt), '' !== $title_text ? sprintf(' title="%1$s"', esc_attr($title_text)) : '', 'on' === $is_overlay_applied ? $overlay_output : ''); if ('on' === $show_in_lightbox) { $output = sprintf('<a href="%1$s" class="et_pb_lightbox_image" title="%3$s">%2$s</a>', esc_url($src), $output, esc_attr($alt)); } else { if ('' !== $url) { $output = sprintf('<a href="%1$s"%3$s>%2$s</a>', esc_url($url), $output, 'on' === $url_new_window ? ' target="_blank"' : ''); } } $animation = '' === $animation ? ET_Global_Settings::get_value('et_pb_image-animation') : $animation; $output = sprintf('<div%5$s class="et_pb_module et-waypoint et_pb_image%2$s%3$s%4$s%6$s"> %1$s </div>', $output, esc_attr(" et_pb_animation_{$animation}"), '' !== $module_class ? sprintf(' %1$s', esc_attr(ltrim($module_class))) : '', 'on' === $sticky ? esc_attr(' et_pb_image_sticky') : '', '' !== $module_id ? sprintf(' id="%1$s"', esc_attr($module_id)) : '', 'on' === $is_overlay_applied ? ' et_pb_has_overlay' : ''); return $output; }
function process_advanced_fonts_options($function_name) { if (!isset($this->advanced_options['fonts'])) { return; } $font_options = array(); $slugs = array('font', 'font_size', 'text_color', 'letter_spacing', 'line_height'); foreach ($this->advanced_options['fonts'] as $option_name => $option_settings) { $style = ''; $important_options = array(); $is_important_set = isset($option_settings['css']['important']); $use_global_important = $is_important_set && 'all' === $option_settings['css']['important']; if ($is_important_set && is_array($option_settings['css']['important'])) { $important_options = $option_settings['css']['important']; } foreach ($slugs as $font_option_slug) { if (isset($this->shortcode_atts["{$option_name}_{$font_option_slug}"])) { $font_options["{$option_name}_{$font_option_slug}"] = $this->shortcode_atts["{$option_name}_{$font_option_slug}"]; } } $field_key = "{$option_name}_{$slugs[0]}"; $global_setting_name = $this->get_global_setting_name($field_key); $global_setting_value = ET_Global_Settings::get_value($global_setting_name); if ('' !== $font_options["{$option_name}_{$slugs[0]}"] || !$global_setting_value) { $important = in_array('font', $important_options) || $use_global_important ? ' !important' : ''; $style .= et_builder_set_element_font($font_options["{$option_name}_{$slugs[0]}"], '' !== $important, $global_setting_value); } $size_option_name = "{$option_name}_{$slugs[1]}"; $default_size = isset($this->fields_unprocessed[$size_option_name]['default']) ? $this->fields_unprocessed[$size_option_name]['default'] : ''; if (!in_array(trim($font_options[$size_option_name]), array('', 'px', $default_size))) { $important = in_array('size', $important_options) || $use_global_important ? ' !important' : ''; $style .= sprintf('font-size: %1$s%2$s; ', esc_html(et_builder_process_range_value($font_options[$size_option_name])), esc_html($important)); } $text_color_option_name = "{$option_name}_{$slugs[2]}"; if ('' !== $font_options[$text_color_option_name]) { $important = ' !important'; if (isset($option_settings['css']['color'])) { self::set_style($function_name, array('selector' => $option_settings['css']['color'], 'declaration' => sprintf('color: %1$s%2$s;', esc_html($font_options[$text_color_option_name]), esc_html($important)), 'priority' => $this->_style_priority)); } else { $style .= sprintf('color: %1$s%2$s; ', esc_html($font_options[$text_color_option_name]), esc_html($important)); } } $letter_spacing_option_name = "{$option_name}_{$slugs[3]}"; $default_letter_spacing = isset($this->fields_unprocessed[$letter_spacing_option_name]['default']) ? $this->fields_unprocessed[$letter_spacing_option_name]['default'] : ''; if (!in_array(trim($font_options[$letter_spacing_option_name]), array('', 'px', $default_letter_spacing))) { $important = in_array('letter-spacing', $important_options) || $use_global_important ? ' !important' : ''; $style .= sprintf('letter-spacing: %1$s%2$s; ', esc_html(et_builder_process_range_value($font_options[$letter_spacing_option_name])), esc_html($important)); } $line_height_option_name = "{$option_name}_{$slugs[4]}"; if (isset($font_options[$line_height_option_name])) { $default_line_height = isset($this->fields_unprocessed[$line_height_option_name]['default']) ? $this->fields_unprocessed[$line_height_option_name]['default'] : ''; if (!in_array(trim($font_options[$line_height_option_name]), array('', 'px', $default_line_height))) { $important = in_array('line-height', $important_options) || $use_global_important ? ' !important' : ''; $style .= sprintf('line-height: %1$s%2$s; ', esc_html(et_builder_process_range_value($font_options[$line_height_option_name], 'line_height')), esc_html($important)); if (isset($option_settings['css']['line_height'])) { self::set_style($function_name, array('selector' => $option_settings['css']['line_height'], 'declaration' => sprintf('line-height: %1$s%2$s;', esc_html(et_builder_process_range_value($font_options[$line_height_option_name], 'line_height')), esc_html($important)), 'priority' => $this->_style_priority)); } } } if (isset($option_settings['use_all_caps']) && $option_settings['use_all_caps'] && 'on' === $this->shortcode_atts["{$option_name}_all_caps"]) { $important = in_array('all_caps', $important_options) || $use_global_important ? ' !important' : ''; $style .= sprintf('text-transform: uppercase%1$s; ', esc_html($important)); } if ('' !== $style) { $css_element = !empty($option_settings['css']['main']) ? $option_settings['css']['main'] : $this->main_css_element; self::set_style($function_name, array('selector' => $css_element, 'declaration' => rtrim($style), 'priority' => $this->_style_priority)); } } }
function extra_customizer_register_module_fullwidth_slider_settings() { $settings = array('et_pb_fullwidth_slider-padding' => array('label' => __('Top & Bottom Padding', 'extra'), 'type' => 'range', 'default' => ET_Global_Settings::get_value('et_pb_fullwidth_slider-padding', 'default'), 'input_attrs' => array('min' => 5, 'max' => 50, 'step' => 1), 'value_bind' => array('style' => 'dynamic_selectors_value_format', 'use_only_formatted_value' => true, 'property_selectors' => array(array('property' => 'padding-top-bottom', 'format' => 'padding-top: %value%%; padding-bottom: %value%%;', 'selectors' => array('.et_pb_fullwidth_section .et_pb_slide_description')))))); $settings = $settings + extra_customizer_font_size_setting(array('setting' => 'et_pb_fullwidth_slider-header_font_size', 'label' => __('Header Font Size', 'extra'), 'type' => 'range', 'min' => 10, 'max' => 72, 'selectors' => array('.et_pb_fullwidth_section .et_pb_slide_description h2'))) + extra_customizer_font_style_setting(array('setting' => 'et_pb_fullwidth_slider-header_font_style', 'label' => __('Header Font Style', 'extra'), 'type' => 'font_style', 'selectors' => array('.et_pb_fullwidth_section .et_pb_slide_description h2'))); return $settings; }
function process_advanced_fonts_options($function_name) { if (!isset($this->advanced_options['fonts'])) { return; } $font_options = array(); $slugs = array('font', 'font_size', 'text_color', 'letter_spacing', 'line_height'); $mobile_options_slugs = array('font_size_tablet', 'font_size_phone', 'line_height_tablet', 'line_height_phone', 'letter_spacing_tablet', 'letter_spacing_phone'); $slugs = array_merge($slugs, $mobile_options_slugs); // merge all slugs into single array to define them in one place foreach ($this->advanced_options['fonts'] as $option_name => $option_settings) { $style = ''; $important_options = array(); $is_important_set = isset($option_settings['css']['important']); $is_placeholder = isset($option_settings['css']['placeholder']); $use_global_important = $is_important_set && 'all' === $option_settings['css']['important']; if ($is_important_set && is_array($option_settings['css']['important'])) { $important_options = $option_settings['css']['important']; } foreach ($slugs as $font_option_slug) { if (isset($this->shortcode_atts["{$option_name}_{$font_option_slug}"])) { $font_options["{$option_name}_{$font_option_slug}"] = $this->shortcode_atts["{$option_name}_{$font_option_slug}"]; } } $field_key = "{$option_name}_{$slugs[0]}"; $global_setting_name = $this->get_global_setting_name($field_key); $global_setting_value = ET_Global_Settings::get_value($global_setting_name); if ('' !== $font_options["{$option_name}_{$slugs[0]}"] || !$global_setting_value) { $important = in_array('font', $important_options) || $use_global_important ? ' !important' : ''; $style .= et_builder_set_element_font($font_options["{$option_name}_{$slugs[0]}"], '' !== $important, $global_setting_value); } $size_option_name = "{$option_name}_{$slugs[1]}"; $default_size = isset($this->fields_unprocessed[$size_option_name]['default']) ? $this->fields_unprocessed[$size_option_name]['default'] : ''; if (!in_array(trim($font_options[$size_option_name]), array('', 'px', $default_size))) { $important = in_array('size', $important_options) || $use_global_important ? ' !important' : ''; $style .= sprintf('font-size: %1$s%2$s; ', esc_html(et_builder_process_range_value($font_options[$size_option_name])), esc_html($important)); } $text_color_option_name = "{$option_name}_{$slugs[2]}"; if (isset($font_options[$text_color_option_name]) && '' !== $font_options[$text_color_option_name]) { $important = ' !important'; if (isset($option_settings['css']['color'])) { self::set_style($function_name, array('selector' => $option_settings['css']['color'], 'declaration' => sprintf('color: %1$s%2$s;', esc_html($font_options[$text_color_option_name]), esc_html($important)), 'priority' => $this->_style_priority)); } else { $style .= sprintf('color: %1$s%2$s; ', esc_html($font_options[$text_color_option_name]), esc_html($important)); } } $letter_spacing_option_name = "{$option_name}_{$slugs[3]}"; $default_letter_spacing = isset($this->fields_unprocessed[$letter_spacing_option_name]['default']) ? $this->fields_unprocessed[$letter_spacing_option_name]['default'] : ''; if (isset($font_options[$letter_spacing_option_name]) && !in_array(trim($font_options[$letter_spacing_option_name]), array('', 'px', $default_letter_spacing))) { $important = in_array('letter-spacing', $important_options) || $use_global_important ? ' !important' : ''; $style .= sprintf('letter-spacing: %1$s%2$s; ', esc_html(et_builder_process_range_value($font_options[$letter_spacing_option_name])), esc_html($important)); } $line_height_option_name = "{$option_name}_{$slugs[4]}"; if (isset($font_options[$line_height_option_name])) { $default_line_height = isset($this->fields_unprocessed[$line_height_option_name]['default']) ? $this->fields_unprocessed[$line_height_option_name]['default'] : ''; if (!in_array(trim($font_options[$line_height_option_name]), array('', 'px', $default_line_height))) { $important = in_array('line-height', $important_options) || $use_global_important ? ' !important' : ''; $style .= sprintf('line-height: %1$s%2$s; ', esc_html(et_builder_process_range_value($font_options[$line_height_option_name], 'line_height')), esc_html($important)); if (isset($option_settings['css']['line_height'])) { self::set_style($function_name, array('selector' => $option_settings['css']['line_height'], 'declaration' => sprintf('line-height: %1$s%2$s;', esc_html(et_builder_process_range_value($font_options[$line_height_option_name], 'line_height')), esc_html($important)), 'priority' => $this->_style_priority)); } } } if (isset($option_settings['use_all_caps']) && $option_settings['use_all_caps'] && 'on' === $this->shortcode_atts["{$option_name}_all_caps"]) { $important = in_array('all_caps', $important_options) || $use_global_important ? ' !important' : ''; $style .= sprintf('text-transform: uppercase%1$s; ', esc_html($important)); } if ('' !== $style) { $css_element = !empty($option_settings['css']['main']) ? $option_settings['css']['main'] : $this->main_css_element; // $css_element might be an array, for example to apply the css for placeholders if (is_array($css_element)) { foreach ($css_element as $selector) { self::set_style($function_name, array('selector' => $selector, 'declaration' => rtrim($style), 'priority' => $this->_style_priority)); } } else { self::set_style($function_name, array('selector' => $css_element, 'declaration' => rtrim($style), 'priority' => $this->_style_priority)); if ($is_placeholder) { self::set_style($function_name, array('selector' => $css_element . '::-webkit-input-placeholder', 'declaration' => rtrim($style), 'priority' => $this->_style_priority)); self::set_style($function_name, array('selector' => $css_element . '::-moz-placeholder', 'declaration' => rtrim($style), 'priority' => $this->_style_priority)); self::set_style($function_name, array('selector' => $css_element . '::-ms-input-placeholder', 'declaration' => rtrim($style), 'priority' => $this->_style_priority)); } } } // process mobile options foreach ($mobile_options_slugs as $mobile_option) { $current_option_name = "{$option_name}_{$mobile_option}"; if (isset($font_options[$current_option_name]) && '' !== $font_options[$current_option_name]) { $current_media_query = false === strpos($mobile_option, 'phone') ? 'max_width_980' : 'max_width_767'; $main_option_name = str_replace(array('_tablet', '_phone'), '', $mobile_option); $css_property = str_replace('_', '-', $main_option_name); $important = in_array($css_property, $important_options) || $use_global_important ? ' !important' : ''; // Allow specific selector tablet and mobile, simply add _tablet or _phone suffix if (isset($option_settings['css'][$mobile_option]) && "" !== $option_settings['css'][$mobile_option]) { $selector = $option_settings['css'][$mobile_option]; } elseif (isset($option_settings['css'][$main_option_name]) || isset($option_settings['css']['main'])) { $selector = isset($option_settings['css'][$main_option_name]) ? $option_settings['css'][$main_option_name] : $option_settings['css']['main']; } else { $selector = $this->main_css_element; } self::set_style($function_name, array('selector' => $selector, 'declaration' => sprintf('%1$s: %2$s%3$s;', esc_html($css_property), esc_html(et_builder_process_range_value($font_options[$current_option_name])), esc_html($important)), 'priority' => $this->_style_priority, 'media_query' => ET_Builder_Element::get_media_query($current_media_query))); if ($is_placeholder) { self::set_style($function_name, array('selector' => $selector . '::-webkit-input-placeholder', 'declaration' => sprintf('%1$s: %2$s%3$s;', esc_html($css_property), esc_html(et_builder_process_range_value($font_options[$current_option_name])), esc_html($important)), 'priority' => $this->_style_priority, 'media_query' => ET_Builder_Element::get_media_query($current_media_query))); self::set_style($function_name, array('selector' => $selector . '::-moz-placeholder', 'declaration' => sprintf('%1$s: %2$s%3$s;', esc_html($css_property), esc_html(et_builder_process_range_value($font_options[$current_option_name])), esc_html($important)), 'priority' => $this->_style_priority, 'media_query' => ET_Builder_Element::get_media_query($current_media_query))); self::set_style($function_name, array('selector' => $selector . '::-ms-input-placeholder', 'declaration' => sprintf('%1$s: %2$s%3$s;', esc_html($css_property), esc_html(et_builder_process_range_value($font_options[$current_option_name])), esc_html($important)), 'priority' => $this->_style_priority, 'media_query' => ET_Builder_Element::get_media_query($current_media_query))); } } } } }
function shortcode_callback($atts, $content = null, $function_name) { $module_id = $this->shortcode_atts['module_id']; $module_class = $this->shortcode_atts['module_class']; $title = $this->shortcode_atts['title']; $subhead = $this->shortcode_atts['subhead']; $background_layout = $this->shortcode_atts['background_layout']; $text_orientation = $this->shortcode_atts['text_orientation']; $title_font = $this->shortcode_atts['title_font']; $title_font_color = $this->shortcode_atts['title_font_color']; $title_font_size = $this->shortcode_atts['title_font_size']; $subhead_font = $this->shortcode_atts['subhead_font']; $subhead_font_color = $this->shortcode_atts['subhead_font_color']; $subhead_font_size = $this->shortcode_atts['subhead_font_size']; $content_font = $this->shortcode_atts['content_font']; $content_font_color = $this->shortcode_atts['content_font_color']; $content_font_size = $this->shortcode_atts['content_font_size']; $button_one_text = $this->shortcode_atts['button_one_text']; $button_one_url = $this->shortcode_atts['button_one_url']; $button_two_text = $this->shortcode_atts['button_two_text']; $button_two_url = $this->shortcode_atts['button_two_url']; $header_fullscreen = $this->shortcode_atts['header_fullscreen']; $header_scroll_down = $this->shortcode_atts['header_scroll_down']; $scroll_down_icon = $this->shortcode_atts['scroll_down_icon']; $scroll_down_icon_color = $this->shortcode_atts['scroll_down_icon_color']; $scroll_down_icon_size = $this->shortcode_atts['scroll_down_icon_size']; $background_url = $this->shortcode_atts['background_url']; $background_color = $this->shortcode_atts['background_color']; $background_overlay_color = $this->shortcode_atts['background_overlay_color']; $parallax = $this->shortcode_atts['parallax']; $parallax_method = $this->shortcode_atts['parallax_method']; $logo_image_url = $this->shortcode_atts['logo_image_url']; $header_image_url = $this->shortcode_atts['header_image_url']; $content_orientation = $this->shortcode_atts['content_orientation']; $image_orientation = $this->shortcode_atts['image_orientation']; $custom_icon_1 = $this->shortcode_atts['button_one_icon']; $button_custom_1 = $this->shortcode_atts['custom_button_one']; $custom_icon_2 = $this->shortcode_atts['button_two_icon']; $button_custom_2 = $this->shortcode_atts['custom_button_two']; $max_width = $this->shortcode_atts['max_width']; $logo_title = $this->shortcode_atts['logo_title']; $logo_alt_text = $this->shortcode_atts['logo_alt_text']; if (is_rtl() && 'left' === $text_orientation) { $text_orientation = 'right'; } $module_class = ET_Builder_Element::add_module_order_class($module_class, $function_name); if ('' !== $max_width) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%% .header-content', 'declaration' => sprintf('max-width: %1$s !important;', esc_html(et_builder_process_range_value($max_width))))); } if ('' !== $title_font) { $global_setting_name_title_font = $this->get_global_setting_name('title_font'); $global_setting_value_title_font = ET_Global_Settings::get_value($global_setting_name_title_font); ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header .header-content h1', 'declaration' => sprintf('%1$s', et_builder_set_element_font($title_font, false, $global_setting_value_title_font)))); } if ('' !== $title_font_color) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header .header-content h1', 'declaration' => sprintf('color: %1$s !important;', esc_html($title_font_color)))); } if ('' !== $title_font_size) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header .header-content h1', 'declaration' => sprintf('font-size: %1$s;', esc_html(et_builder_process_range_value($title_font_size))))); } if ('' !== $subhead_font) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header .et_pb_fullwidth_header_subhead', 'declaration' => sprintf('%1$s', et_builder_set_element_font($subhead_font)))); } if ('' !== $subhead_font_color) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header .et_pb_fullwidth_header_subhead', 'declaration' => sprintf('color: %1$s !important;', esc_html($subhead_font_color)))); } if ('' !== $subhead_font_size) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header .et_pb_fullwidth_header_subhead', 'declaration' => sprintf('font-size: %1$s;', esc_html(et_builder_process_range_value($subhead_font_size))))); } if ('' !== $content_font) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header p', 'declaration' => sprintf('%1$s', et_builder_set_element_font($content_font)))); } if ('' !== $content_font_color) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header p', 'declaration' => sprintf('color: %1$s !important;', esc_html($content_font_color)))); } if ('' !== $content_font_size) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header p', 'declaration' => sprintf('font-size: %1$s;', esc_html(et_builder_process_range_value($content_font_size))))); } if ('' !== $scroll_down_icon_color) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header .et_pb_fullwidth_header_scroll a .et-pb-icon', 'declaration' => sprintf('color: %1$s;', esc_html($scroll_down_icon_color)))); } if ('' !== $scroll_down_icon_size) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header .et_pb_fullwidth_header_scroll a .et-pb-icon', 'declaration' => sprintf('font-size: %1$s;', esc_html(et_builder_process_range_value($scroll_down_icon_size))))); } if ('' !== $background_color) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header', 'declaration' => sprintf('background-color: %1$s;', esc_html($background_color)))); } if ('' !== $background_overlay_color) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header .et_pb_fullwidth_header_overlay', 'declaration' => sprintf('background-color: %1$s;', esc_html($background_overlay_color)))); } if ('' !== $background_url && 'off' === $parallax) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%.et_pb_fullwidth_header', 'declaration' => sprintf('background-image: url(%1$s);', esc_html($background_url)))); } $button_output = ''; if ('' !== $button_one_text) { $button_output .= sprintf('<a href="%2$s" class="et_pb_more_button et_pb_button et_pb_button_one%4$s"%3$s>%1$s</a>', '' !== $button_one_text ? esc_attr($button_one_text) : '', '' !== $button_one_url ? esc_attr($button_one_url) : '#', '' !== $custom_icon_1 && 'on' === $button_custom_1 ? sprintf(' data-icon="%1$s"', esc_attr(et_pb_process_font_icon($custom_icon_1))) : '', '' !== $custom_icon_1 && 'on' === $button_custom_1 ? ' et_pb_custom_button_icon' : ''); } if ('' !== $button_two_text) { $button_output .= sprintf('<a href="%2$s" class="et_pb_more_button et_pb_button et_pb_button_two%4$s"%3$s>%1$s</a>', '' !== $button_two_text ? esc_attr($button_two_text) : '', '' !== $button_two_url ? esc_attr($button_two_url) : '#', '' !== $custom_icon_2 && 'on' === $button_custom_2 ? sprintf(' data-icon="%1$s"', esc_attr(et_pb_process_font_icon($custom_icon_2))) : '', '' !== $custom_icon_2 && 'on' === $button_custom_2 ? ' et_pb_custom_button_icon' : ''); } $class = " et_pb_module et_pb_bg_layout_{$background_layout} et_pb_text_align_{$text_orientation}"; $header_content = ''; if ('' !== $title || '' !== $subhead || '' !== $content || '' !== $button_output || '' !== $logo_image_url) { $logo_image = ''; if ('' !== $logo_image_url) { $logo_image = sprintf('<img src="%1$s" alt="%2$s"%3$s />', esc_attr($logo_image_url), esc_attr($logo_alt_text), '' !== $logo_title ? sprintf(' title="%1$s"', esc_attr($logo_title)) : ''); } $header_content = sprintf('<div class="header-content-container%6$s"> <div class="header-content"> %3$s %1$s %2$s %4$s %5$s </div> </div>', $title ? sprintf('<h1>%1$s</h1>', $title) : '', $subhead ? sprintf('<span class="et_pb_fullwidth_header_subhead">%1$s</span>', $subhead) : '', $logo_image, '' !== $content ? sprintf('<p>%1$s</p>', $this->shortcode_content) : '', '' !== $button_output ? $button_output : '', '' !== $content_orientation ? sprintf(' %1$s', $content_orientation) : ''); } $header_image = ''; if ('' !== $header_image_url) { $header_image = sprintf('<div class="header-image-container%2$s"> <div class="header-image"> <img src="%1$s" /> </div> </div>', '' !== $header_image_url ? esc_attr($header_image_url) : '', '' !== $image_orientation ? sprintf(' %1$s', $image_orientation) : ''); $module_class .= ' et_pb_header_with_image'; } $scroll_down_output = ''; if ('off' !== $header_scroll_down || '' !== $scroll_down_icon) { $scroll_down_output .= sprintf('<a href="#"><span class="scroll-down et-pb-icon">%1$s</span></a>', esc_html(et_pb_process_font_icon($scroll_down_icon, 'et_pb_get_font_down_icon_symbols'))); } $output = sprintf('<section%9$s class="et_pb_fullwidth_header%1$s%7$s%8$s%10$s"> %6$s <div class="et_pb_fullwidth_header_container%5$s"> %2$s %3$s </div> <div class="et_pb_fullwidth_header_overlay"></div> <div class="et_pb_fullwidth_header_scroll">%4$s</div> </section>', 'off' !== $header_fullscreen ? ' et_pb_fullscreen' : '', '' !== $header_content ? $header_content : '', '' !== $header_image ? $header_image : '', 'off' !== $header_scroll_down ? $scroll_down_output : '', '' !== $text_orientation ? sprintf(' %1$s', esc_attr($text_orientation)) : '', '' !== $background_url && 'on' === $parallax ? sprintf('<div class="et_parallax_bg%2$s" style="background-image: url(%1$s);"></div>', esc_attr($background_url), 'off' === $parallax_method ? ' et_pb_parallax_css' : '') : '', '' !== $background_url && 'on' === $parallax ? ' et_pb_section_parallax' : '', esc_attr($class), '' !== $module_id ? sprintf(' id="%1$s"', esc_attr($module_id)) : '', '' !== $module_class ? sprintf(' %1$s', esc_attr($module_class)) : ''); return $output; }