urrent style settings will be overwritten.', 'wpforms-lite' ), 'ai' => [ 'active' => false, ], ] ); $this->add_control( 'CPDivider', [ 'type' => Controls_Manager::DIVIDER, ] ); $this->add_control( 'resetStyleSettings', [ 'type' => Controls_Manager::BUTTON, 'button_type' => 'default', 'show_label' => false, 'text' => esc_html__( 'Reset Style Settings', 'wpforms-lite' ), 'event' => 'elementorWPFormsResetStyleSettings', 'classes' => 'wpforms-reset-style-settings', ] ); $this->end_controls_section(); } /** * Render widget output on the frontend. * * @since 1.8.3 * * @noinspection PhpUndefinedMethodInspection */ protected function render_frontend() { if ( empty( $this->css_vars_obj ) ) { return; } $widget_id = $this->get_id(); $attr = $this->get_settings_for_display(); $css_vars = $this->css_vars_obj->get_customized_css_vars( $attr ); $custom_classes = ! empty( $attr['className'] ) ? trim( $attr['className'] ) : ''; if ( ! empty( $css_vars ) ) { $style_id = 'wpforms-css-vars-elementor-widget-' . $widget_id; /** * Filter the CSS selector for output CSS variables for styling the form in Elementor widget. * * @since 1.8.3 * * @param string $selector The CSS selector for output CSS variables for styling the Elementor Widget. * @param array $attr Attributes passed by Elementor Widget. * @param array $css_vars CSS variables data. */ $vars_selector = apply_filters( 'wpforms_integrations_elementor_widget_modern_output_css_vars_selector', ".elementor-widget-wpforms.elementor-element-{$widget_id}", $attr, $css_vars ); $this->css_vars_obj->output_selector_vars( $vars_selector, $css_vars, $style_id ); } // Add custom classes. if ( $custom_classes ) { $this->add_render_attribute( '_wrapper', [ 'class' => [ $custom_classes, ], ] ); } // Render selected form. $this->render_form(); } /** * Get settings for display. * * @since 1.8.3 * * @param string $setting_key Optional. The key of the requested setting. Default is null. * * @return mixed The settings. * @noinspection PhpUndefinedMethodInspection */ public function get_settings_for_display( $setting_key = null ) { $settings = parent::get_settings_for_display( $setting_key ); if ( ! empty( $setting_key ) ) { return $settings; } $settings['fieldBorderRadius'] = isset( $settings['fieldBorderRadius'] ) ? $settings['fieldBorderRadius'] . 'px' : CSSVars::ROOT_VARS['field-border-radius']; $settings['buttonBorderRadius'] = isset( $settings['buttonBorderRadius'] ) ? $settings['buttonBorderRadius'] . 'px' : CSSVars::ROOT_VARS['button-border-radius']; if ( isset( $settings['__globals__'] ) ) { $settings = $this->check_global_styles( $settings ); } return $settings; } /** * Check if global styles are used in colors controls and update its values with the real ones. * * @since 1.8.3 * * @param array $settings Widget settings. * * @return array Updated settings. * @noinspection PhpUndefinedFieldInspection */ private function check_global_styles( $settings ) { $global_settings = $settings['__globals__']; $kit = Plugin::$instance->kits_manager->get_active_kit_for_frontend(); $system_colors = $kit->get_settings_for_display( 'system_colors' ); $custom_colors = $kit->get_settings_for_display( 'custom_colors' ); $global_colors = array_merge( $system_colors, $custom_colors ); foreach ( $global_settings as $key => $value ) { if ( empty( $value ) ) { continue; } $color_id = str_replace( 'globals/colors?id=', '', $value ); foreach ( $global_colors as $color ) { if ( $color['_id'] === $color_id ) { $settings[ $key ] = $color['color']; } } } return $settings; } }