From ff8f3e914273017e55dc250540f5b2b78214c6f7 Mon Sep 17 00:00:00 2001 From: Sapayth Hossain Date: Tue, 20 Jan 2026 16:11:50 +0600 Subject: [PATCH 01/17] initial form rendering in elementor builder --- includes/Integrations.php | 4 + includes/Integrations/Elementor/Elementor.php | 28 ++ includes/Integrations/Elementor/Widget.php | 405 ++++++++++++++++++ wpuf.php | 13 + 4 files changed, 450 insertions(+) create mode 100644 includes/Integrations/Elementor/Elementor.php create mode 100644 includes/Integrations/Elementor/Widget.php diff --git a/includes/Integrations.php b/includes/Integrations.php index 99bb8ea77..eca318303 100644 --- a/includes/Integrations.php +++ b/includes/Integrations.php @@ -45,6 +45,10 @@ public function __construct() { } } } + + add_action('elementor/init', function() { + $this->container['elementor'] = new Integrations\Elementor\Elementor(); + }); } /** diff --git a/includes/Integrations/Elementor/Elementor.php b/includes/Integrations/Elementor/Elementor.php new file mode 100644 index 000000000..c1a1009cf --- /dev/null +++ b/includes/Integrations/Elementor/Elementor.php @@ -0,0 +1,28 @@ +register( new Widget() ); + } +} diff --git a/includes/Integrations/Elementor/Widget.php b/includes/Integrations/Elementor/Widget.php new file mode 100644 index 000000000..b20bdbd9a --- /dev/null +++ b/includes/Integrations/Elementor/Widget.php @@ -0,0 +1,405 @@ +start_controls_section( + 'section_content', + [ + 'label' => __( 'Content', 'wp-user-frontend' ), + ] + ); + + $this->add_control( + 'form_id', + [ + 'label' => __( 'Select Form', 'wp-user-frontend' ), + 'type' => Controls_Manager::SELECT, + 'default' => '', + 'options' => $this->get_wpuf_forms(), + ] + ); + + $this->end_controls_section(); + + // Style Tab + $this->register_container_style_controls(); + $this->register_label_style_controls(); + $this->register_input_style_controls(); + $this->register_submit_button_style_controls(); + } + + protected function get_wpuf_forms() { + $forms = get_posts( [ + 'post_type' => 'wpuf_forms', + 'posts_per_page' => -1, + 'post_status' => 'publish', + ] ); + + $options = [ '' => __( 'Select a Form', 'wp-user-frontend' ) ]; + + if ( ! empty( $forms ) ) { + foreach ( $forms as $form ) { + $options[ $form->ID ] = $form->post_title; + } + } + + return $options; + } + + protected function register_container_style_controls() { + $this->start_controls_section( + 'section_container_style', + [ + 'label' => __( 'Form Container', 'wp-user-frontend' ), + 'tab' => Controls_Manager::TAB_STYLE, + ] + ); + + $this->add_group_control( + Group_Control_Background::get_type(), + [ + 'name' => 'container_background', + 'label' => __( 'Background', 'wp-user-frontend' ), + 'types' => [ 'classic', 'gradient' ], + 'selector' => '{{WRAPPER}} .wpuf-elementor-widget-wrapper', + ] + ); + + $this->add_responsive_control( + 'container_padding', + [ + 'label' => __( 'Padding', 'wp-user-frontend' ), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => [ 'px', 'em', '%' ], + 'selectors' => [ + '{{WRAPPER}} .wpuf-elementor-widget-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ], + ] + ); + + $this->add_responsive_control( + 'container_margin', + [ + 'label' => __( 'Margin', 'wp-user-frontend' ), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => [ 'px', 'em', '%' ], + 'selectors' => [ + '{{WRAPPER}} .wpuf-elementor-widget-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ], + ] + ); + + $this->add_group_control( + Group_Control_Border::get_type(), + [ + 'name' => 'container_border', + 'selector' => '{{WRAPPER}} .wpuf-elementor-widget-wrapper', + ] + ); + + $this->add_control( + 'container_border_radius', + [ + 'label' => __( 'Border Radius', 'wp-user-frontend' ), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => [ 'px', '%' ], + 'selectors' => [ + '{{WRAPPER}} .wpuf-elementor-widget-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ], + ] + ); + + $this->add_group_control( + Group_Control_Box_Shadow::get_type(), + [ + 'name' => 'container_box_shadow', + 'selector' => '{{WRAPPER}} .wpuf-elementor-widget-wrapper', + ] + ); + + $this->end_controls_section(); + } + + protected function register_label_style_controls() { + $this->start_controls_section( + 'section_label_style', + [ + 'label' => __( 'Labels', 'wp-user-frontend' ), + 'tab' => Controls_Manager::TAB_STYLE, + ] + ); + + $this->add_control( + 'label_color', + [ + 'label' => __( 'Text Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} .wpuf-form .wpuf-label' => 'color: {{VALUE}};', + ], + ] + ); + + $this->add_group_control( + Group_Control_Typography::get_type(), + [ + 'name' => 'label_typography', + 'selector' => '{{WRAPPER}} .wpuf-form .wpuf-label', + ] + ); + + $this->end_controls_section(); + } + + protected function register_input_style_controls() { + $this->start_controls_section( + 'section_input_style', + [ + 'label' => __( 'Input Fields', 'wp-user-frontend' ), + 'tab' => Controls_Manager::TAB_STYLE, + ] + ); + + $this->add_control( + 'input_bg_color', + [ + 'label' => __( 'Background Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} .wpuf-form input[type="text"], {{WRAPPER}} .wpuf-form input[type="email"], {{WRAPPER}} .wpuf-form input[type="url"], {{WRAPPER}} .wpuf-form input[type="password"], {{WRAPPER}} .wpuf-form textarea, {{WRAPPER}} .wpuf-form select' => 'background-color: {{VALUE}};', + ], + ] + ); + + $this->add_control( + 'input_text_color', + [ + 'label' => __( 'Text Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} .wpuf-form input[type="text"], {{WRAPPER}} .wpuf-form input[type="email"], {{WRAPPER}} .wpuf-form input[type="url"], {{WRAPPER}} .wpuf-form input[type="password"], {{WRAPPER}} .wpuf-form textarea, {{WRAPPER}} .wpuf-form select' => 'color: {{VALUE}};', + ], + ] + ); + + $this->add_group_control( + Group_Control_Typography::get_type(), + [ + 'name' => 'input_typography', + 'selector' => '{{WRAPPER}} .wpuf-form input[type="text"], {{WRAPPER}} .wpuf-form input[type="email"], {{WRAPPER}} .wpuf-form input[type="url"], {{WRAPPER}} .wpuf-form input[type="password"], {{WRAPPER}} .wpuf-form textarea, {{WRAPPER}} .wpuf-form select', + ] + ); + + $this->add_group_control( + Group_Control_Border::get_type(), + [ + 'name' => 'input_border', + 'selector' => '{{WRAPPER}} .wpuf-form input[type="text"], {{WRAPPER}} .wpuf-form input[type="email"], {{WRAPPER}} .wpuf-form input[type="url"], {{WRAPPER}} .wpuf-form input[type="password"], {{WRAPPER}} .wpuf-form textarea, {{WRAPPER}} .wpuf-form select', + ] + ); + + $this->add_control( + 'input_border_radius', + [ + 'label' => __( 'Border Radius', 'wp-user-frontend' ), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => [ 'px', '%' ], + 'selectors' => [ + '{{WRAPPER}} .wpuf-form input[type="text"], {{WRAPPER}} .wpuf-form input[type="email"], {{WRAPPER}} .wpuf-form input[type="url"], {{WRAPPER}} .wpuf-form input[type="password"], {{WRAPPER}} .wpuf-form textarea, {{WRAPPER}} .wpuf-form select' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ], + ] + ); + + $this->add_responsive_control( + 'input_padding', + [ + 'label' => __( 'Padding', 'wp-user-frontend' ), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => [ 'px', 'em', '%' ], + 'selectors' => [ + '{{WRAPPER}} .wpuf-form input[type="text"], {{WRAPPER}} .wpuf-form input[type="email"], {{WRAPPER}} .wpuf-form input[type="url"], {{WRAPPER}} .wpuf-form input[type="password"], {{WRAPPER}} .wpuf-form textarea, {{WRAPPER}} .wpuf-form select' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ], + ] + ); + + $this->end_controls_section(); + } + + protected function register_submit_button_style_controls() { + $this->start_controls_section( + 'section_submit_button_style', + [ + 'label' => __( 'Submit Button', 'wp-user-frontend' ), + 'tab' => Controls_Manager::TAB_STYLE, + ] + ); + + $this->start_controls_tabs( 'tabs_submit_button_style' ); + + $this->start_controls_tab( + 'tab_submit_button_normal', + [ + 'label' => __( 'Normal', 'wp-user-frontend' ), + ] + ); + + $this->add_control( + 'submit_button_bg_color', + [ + 'label' => __( 'Background Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} .wpuf-form .wpuf-submit-button' => 'background-color: {{VALUE}};', + ], + ] + ); + + $this->add_control( + 'submit_button_text_color', + [ + 'label' => __( 'Text Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} .wpuf-form .wpuf-submit-button' => 'color: {{VALUE}};', + ], + ] + ); + + $this->add_group_control( + Group_Control_Typography::get_type(), + [ + 'name' => 'submit_button_typography', + 'selector' => '{{WRAPPER}} .wpuf-form .wpuf-submit-button', + ] + ); + + $this->end_controls_tab(); + + $this->start_controls_tab( + 'tab_submit_button_hover', + [ + 'label' => __( 'Hover', 'wp-user-frontend' ), + ] + ); + + $this->add_control( + 'submit_button_hover_bg_color', + [ + 'label' => __( 'Background Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} .wpuf-form .wpuf-submit-button:hover' => 'background-color: {{VALUE}};', + ], + ] + ); + + $this->add_control( + 'submit_button_hover_text_color', + [ + 'label' => __( 'Text Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} .wpuf-form .wpuf-submit-button:hover' => 'color: {{VALUE}};', + ], + ] + ); + + $this->end_controls_tab(); + + $this->end_controls_tabs(); + + $this->add_group_control( + Group_Control_Border::get_type(), + [ + 'name' => 'submit_button_border', + 'selector' => '{{WRAPPER}} .wpuf-form .wpuf-submit-button', + 'separator' => 'before', + ] + ); + + $this->add_control( + 'submit_button_border_radius', + [ + 'label' => __( 'Border Radius', 'wp-user-frontend' ), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => [ 'px', '%' ], + 'selectors' => [ + '{{WRAPPER}} .wpuf-form .wpuf-submit-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ], + ] + ); + + $this->add_responsive_control( + 'submit_button_padding', + [ + 'label' => __( 'Padding', 'wp-user-frontend' ), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => [ 'px', 'em', '%' ], + 'selectors' => [ + '{{WRAPPER}} .wpuf-form .wpuf-submit-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ], + ] + ); + + $this->end_controls_section(); + } + + protected function render() { + $settings = $this->get_settings_for_display(); + $form_id = isset( $settings['form_id'] ) ? $settings['form_id'] : null; + + if ( empty( $form_id ) ) { + return; + } + + $shortcode_str = '[wpuf_form id="' . $form_id . '"]'; + $output = do_shortcode( $shortcode_str ); + + echo '
'; + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- shortcode output + echo '
'; + } + + /** + * Render the widget output in the editor. + * + * Written as a Backbone JavaScript template. When empty, Elementor + * will fall back to using the render() method for both frontend + * and editor preview. + * + * @since 4.2.7 + * + * @access protected + */ + protected function content_template() {} +} diff --git a/wpuf.php b/wpuf.php index aa14c9782..339e90a66 100644 --- a/wpuf.php +++ b/wpuf.php @@ -187,6 +187,19 @@ public function instantiate() { $this->container['setup_wizard'] = new WeDevs\Wpuf\Setup_Wizard(); $this->container['pro_upgrades'] = new WeDevs\Wpuf\Pro_Upgrades(); $this->container['privacy'] = new WeDevs\Wpuf\WPUF_Privacy(); + + // Load Frontend when in Elementor editor or Elementor AJAX so the wpuf_form + // shortcode is registered and the WPUF widget can render the form. Without + // this, is_admin() is true and Frontend is skipped, so do_shortcode() + // returns the raw shortcode. Covers: (1) editor page ?action=elementor, + // (2) render_widget AJAX when changing "Select Form" (action=elementor_ajax). + $get_action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; + $request_act = isset( $_REQUEST['action'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) : ''; + $is_elementor = ( $get_action === 'elementor' ) + || ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) && $request_act === 'elementor_ajax' ); + if ( $is_elementor ) { + $this->container['frontend'] = new WeDevs\Wpuf\Frontend(); + } } else { $this->container['frontend'] = new WeDevs\Wpuf\Frontend(); } From b88043492522a3ff8d2288c2da32b928d477d411 Mon Sep 17 00:00:00 2001 From: Sapayth Hossain Date: Wed, 21 Jan 2026 16:02:28 +0600 Subject: [PATCH 02/17] added css for elementor editor --- Gruntfile.js | 3 +- assets/css/elementor-frontend-forms.css | 187 ++++++ assets/less/elementor-frontend-forms.less | 241 +++++++ includes/Assets.php | 3 + includes/Integrations/Elementor/Elementor.php | 20 + includes/Integrations/Elementor/Widget.php | 592 ++++++++++++++++-- languages/wp-user-frontend.pot | 189 +++++- 7 files changed, 1162 insertions(+), 73 deletions(-) create mode 100644 assets/css/elementor-frontend-forms.css create mode 100644 assets/less/elementor-frontend-forms.less diff --git a/Gruntfile.js b/Gruntfile.js index 5077e0d95..7e0a2bb33 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -27,7 +27,8 @@ module.exports = function( grunt) { // one to one front: { files: { - '<%= dirs.css %>/frontend-forms.css': '<%= dirs.less %>/frontend-forms.less' + '<%= dirs.css %>/frontend-forms.css': '<%= dirs.less %>/frontend-forms.less', + '<%= dirs.css %>/elementor-frontend-forms.css': '<%= dirs.less %>/elementor-frontend-forms.less' } }, diff --git a/assets/css/elementor-frontend-forms.css b/assets/css/elementor-frontend-forms.css new file mode 100644 index 000000000..aee195ca6 --- /dev/null +++ b/assets/css/elementor-frontend-forms.css @@ -0,0 +1,187 @@ +/** + * DESCRIPTION: Elementor-specific WPUF frontend form styles + * + * This file contains form styles scoped to the Elementor widget wrapper + * to avoid conflicts with the theme and provide better Elementor integration. + * + * @package WPUF\Elementor + */ +.wpuf-elementor-widget-wrapper { + --wpuf-border-color: #dadbdd; + --wpuf-border-radius: 7px; + --wpuf-text-color: #606266; + --wpuf-primary-color: #1a7efb; + --wpuf-danger-color: #F56C6C; +} +.wpuf-elementor-widget-wrapper .wpuf-fields input[type="text"], +.wpuf-elementor-widget-wrapper .wpuf-fields input[type="email"], +.wpuf-elementor-widget-wrapper .wpuf-fields input[type="url"], +.wpuf-elementor-widget-wrapper .wpuf-fields input[type="password"], +.wpuf-elementor-widget-wrapper .wpuf-fields input[type="number"], +.wpuf-elementor-widget-wrapper .wpuf-fields input[type="tel"], +.wpuf-elementor-widget-wrapper .wpuf-fields textarea, +.wpuf-elementor-widget-wrapper .wpuf-fields select { + padding: 12px 15px; + color: var(--wpuf-text-color); + border: 1px solid var(--wpuf-border-color); + border-radius: var(--wpuf-border-radius); + transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; + margin-bottom: 0; + width: 100%; +} +.wpuf-elementor-widget-wrapper .wpuf-fields input[type="text"]:focus, +.wpuf-elementor-widget-wrapper .wpuf-fields input[type="email"]:focus, +.wpuf-elementor-widget-wrapper .wpuf-fields input[type="url"]:focus, +.wpuf-elementor-widget-wrapper .wpuf-fields input[type="password"]:focus, +.wpuf-elementor-widget-wrapper .wpuf-fields input[type="number"]:focus, +.wpuf-elementor-widget-wrapper .wpuf-fields input[type="tel"]:focus, +.wpuf-elementor-widget-wrapper .wpuf-fields textarea:focus, +.wpuf-elementor-widget-wrapper .wpuf-fields select:focus { + color: var(--wpuf-text-color); + background-color: #fff; + border-color: var(--wpuf-primary-color); + outline: none; + box-shadow: 0 0 0 2px rgba(26, 126, 251, 0.1); +} +.wpuf-elementor-widget-wrapper ul.wpuf-form { + list-style: none; +} +.wpuf-elementor-widget-wrapper ul.wpuf-form li:not(:first-child) { + margin-top: 2rem; +} +.wpuf-elementor-widget-wrapper ul.wpuf-form li.wpuf-el .wpuf-label { + margin-bottom: 1rem; +} +.wpuf-elementor-widget-wrapper[data-align="left"] { + margin: 0 auto 0 0; +} +.wpuf-elementor-widget-wrapper[data-align="center"] { + margin: 0 auto; +} +.wpuf-elementor-widget-wrapper[data-align="right"] { + margin: 0 0 0 auto; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-submit-full .wpuf-submit .wpuf-submit-button { + width: 100%; + display: block; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-hide-labels .wpuf-label { + display: none !important; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-hide-errors .wpuf-error, +.wpuf-elementor-widget-wrapper.wpuf-elementor-hide-errors .error { + display: none; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-hide-placeholder input::-webkit-input-placeholder, +.wpuf-elementor-widget-wrapper.wpuf-elementor-hide-placeholder textarea::-webkit-input-placeholder { + opacity: 0; + visibility: hidden; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-hide-placeholder input::-moz-placeholder, +.wpuf-elementor-widget-wrapper.wpuf-elementor-hide-placeholder textarea::-moz-placeholder { + opacity: 0; + visibility: hidden; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-hide-placeholder input:-moz-placeholder, +.wpuf-elementor-widget-wrapper.wpuf-elementor-hide-placeholder textarea:-moz-placeholder { + opacity: 0; + visibility: hidden; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-hide-placeholder input:-ms-input-placeholder, +.wpuf-elementor-widget-wrapper.wpuf-elementor-hide-placeholder textarea:-ms-input-placeholder { + opacity: 0; + visibility: hidden; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-hide-placeholder input::-ms-input-placeholder, +.wpuf-elementor-widget-wrapper.wpuf-elementor-hide-placeholder textarea::-ms-input-placeholder { + opacity: 0; + visibility: hidden; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-custom-radio-checkbox input[type="checkbox"], +.wpuf-elementor-widget-wrapper.wpuf-elementor-custom-radio-checkbox input[type="radio"] { + outline: none; + min-width: 1px; + width: 15px; + height: 15px; + background: #ddd; + padding: 3px; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-custom-radio-checkbox input[type="radio"] { + border-radius: 50%; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-submit-center .wpuf-submit { + text-align: center; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-submit-center .wpuf-submit .wpuf-submit-button { + margin: 0 auto; + display: inline-flex; + align-items: center; + justify-content: center; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-submit-right .wpuf-submit { + text-align: right; +} +.wpuf-elementor-widget-wrapper.wpuf-elementor-submit-left .wpuf-submit { + text-align: left; +} +.wpuf-elementor-widget-wrapper .wpuf-math-captcha .captcha { + display: flex; + align-items: center; + gap: 10px; + flex-wrap: wrap; +} +.wpuf-elementor-widget-wrapper .wpuf-math-captcha .captcha .refresh { + cursor: pointer; + transition: opacity 0.2s ease; +} +.wpuf-elementor-widget-wrapper .wpuf-math-captcha .captcha .refresh:hover { + opacity: 0.7; +} +.wpuf-elementor-widget-wrapper .wpuf-math-captcha .captcha .refresh svg { + display: block; +} +.wpuf-elementor-widget-wrapper .wpuf-math-captcha .captcha .captcha-number-area .captcha-number { + display: flex; + align-items: center; + gap: 5px; + margin: 0; + font-size: 16px; + font-weight: 500; + color: var(--wpuf-text-color); +} +.wpuf-elementor-widget-wrapper .wpuf-math-captcha .captcha .captcha-equal { + font-size: 18px; + font-weight: 600; + color: var(--wpuf-text-color); +} +.wpuf-elementor-widget-wrapper .wpuf-math-captcha .captcha .wpuf-captcha-input-wrapper { + flex: 1; + min-width: 80px; + position: relative; +} +.wpuf-elementor-widget-wrapper .wpuf-math-captcha .captcha .wpuf-captcha-input-wrapper .wpuf-captcha-input { + padding: 11px 15px; + color: var(--wpuf-text-color); + border: 1px solid var(--wpuf-border-color); + border-radius: var(--wpuf-border-radius); + transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; + margin-bottom: 0; + width: 100%; + font-family: -apple-system, system-ui, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; +} +.wpuf-elementor-widget-wrapper .wpuf-math-captcha .captcha .wpuf-captcha-input-wrapper .wpuf-captcha-input:focus { + color: var(--wpuf-text-color); + background-color: #fff; + border-color: var(--wpuf-primary-color); + outline: none; + box-shadow: 0 0 0 2px rgba(26, 126, 251, 0.1); +} +.wpuf-elementor-widget-wrapper .wpuf-math-captcha .captcha .wpuf-captcha-input-wrapper .wpuf-captcha-error { + display: block; + margin-top: 5px; + font-size: 13px; + color: var(--wpuf-danger-color); +} +.lity { + z-index: 9999 !important; +} diff --git a/assets/less/elementor-frontend-forms.less b/assets/less/elementor-frontend-forms.less new file mode 100644 index 000000000..24e7e8ec1 --- /dev/null +++ b/assets/less/elementor-frontend-forms.less @@ -0,0 +1,241 @@ +/** + * DESCRIPTION: Elementor-specific WPUF frontend form styles + * + * This file contains form styles scoped to the Elementor widget wrapper + * to avoid conflicts with the theme and provide better Elementor integration. + * + * @package WPUF\Elementor + */ + +// ============================================ +// CSS Custom Properties (Variables) +// ============================================ + +.wpuf-elementor-widget-wrapper { + --wpuf-border-color: #dadbdd; + --wpuf-border-radius: 7px; + --wpuf-text-color: #606266; + --wpuf-primary-color: #1a7efb; + --wpuf-danger-color: #F56C6C; + + // ============================================ + // Base Input Styles + // ============================================ + + .wpuf-fields input[type="text"], + .wpuf-fields input[type="email"], + .wpuf-fields input[type="url"], + .wpuf-fields input[type="password"], + .wpuf-fields input[type="number"], + .wpuf-fields input[type="tel"], + .wpuf-fields textarea, + .wpuf-fields select { + padding: 12px 15px; + color: var(--wpuf-text-color); + border: 1px solid var(--wpuf-border-color); + border-radius: var(--wpuf-border-radius); + transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; + margin-bottom: 0; + width: 100%; + + &:focus { + color: var(--wpuf-text-color); + background-color: #fff; + border-color: var(--wpuf-primary-color); + outline: none; + box-shadow: 0 0 0 2px rgba(26, 126, 251, 0.1); + } + } + + ul.wpuf-form { + list-style: none; + + li:not(:first-child) { + margin-top: 2rem; + } + + li.wpuf-el { + .wpuf-label { + margin-bottom: 1rem; + } + + } + } + + // Container alignment based on data-align attribute + &[data-align="left"] { + margin: 0 auto 0 0; + } + + &[data-align="center"] { + margin: 0 auto; + } + + &[data-align="right"] { + margin: 0 0 0 auto; + } + + // Full width submit button + &.wpuf-elementor-submit-full .wpuf-submit .wpuf-submit-button { + width: 100%; + display: block; + } + + // Hide labels option + &.wpuf-elementor-hide-labels .wpuf-label { + display: none !important; + } + + // Hide error messages option + &.wpuf-elementor-hide-errors .wpuf-error, + &.wpuf-elementor-hide-errors .error { + display: none; + } + + // Hide placeholder option + &.wpuf-elementor-hide-placeholder input::-webkit-input-placeholder, + &.wpuf-elementor-hide-placeholder textarea::-webkit-input-placeholder { + opacity: 0; + visibility: hidden; + } + + &.wpuf-elementor-hide-placeholder input::-moz-placeholder, + &.wpuf-elementor-hide-placeholder textarea::-moz-placeholder { + opacity: 0; + visibility: hidden; + } + + &.wpuf-elementor-hide-placeholder input:-moz-placeholder, + &.wpuf-elementor-hide-placeholder textarea:-moz-placeholder { + opacity: 0; + visibility: hidden; + } + + &.wpuf-elementor-hide-placeholder input:-ms-input-placeholder, + &.wpuf-elementor-hide-placeholder textarea:-ms-input-placeholder { + opacity: 0; + visibility: hidden; + } + + &.wpuf-elementor-hide-placeholder input::-ms-input-placeholder, + &.wpuf-elementor-hide-placeholder textarea::-ms-input-placeholder { + opacity: 0; + visibility: hidden; + } + + // Custom radio/checkbox styling + &.wpuf-elementor-custom-radio-checkbox input[type="checkbox"], + &.wpuf-elementor-custom-radio-checkbox input[type="radio"] { + outline: none; + min-width: 1px; + width: 15px; + height: 15px; + background: #ddd; + padding: 3px; + } + + &.wpuf-elementor-custom-radio-checkbox input[type="radio"] { + border-radius: 50%; + } + + // Submit button alignment + &.wpuf-elementor-submit-center .wpuf-submit { + text-align: center; + + .wpuf-submit-button { + margin: 0 auto; + display: inline-flex; + align-items: center; + justify-content: center; + } + } + + &.wpuf-elementor-submit-right .wpuf-submit { + text-align: right; + } + + &.wpuf-elementor-submit-left .wpuf-submit { + text-align: left; + } + + // ============================================ + // Math Captcha Styles + // ============================================ + + .wpuf-math-captcha { + .captcha { + display: flex; + align-items: center; + gap: 10px; + flex-wrap: wrap; + + .refresh { + cursor: pointer; + transition: opacity 0.2s ease; + + &:hover { + opacity: 0.7; + } + + svg { + display: block; + } + } + + .captcha-number-area { + .captcha-number { + display: flex; + align-items: center; + gap: 5px; + margin: 0; + font-size: 16px; + font-weight: 500; + color: var(--wpuf-text-color); + } + } + + .captcha-equal { + font-size: 18px; + font-weight: 600; + color: var(--wpuf-text-color); + } + + .wpuf-captcha-input-wrapper { + flex: 1; + min-width: 80px; + position: relative; + + .wpuf-captcha-input { + padding: 11px 15px; + color: var(--wpuf-text-color); + border: 1px solid var(--wpuf-border-color); + border-radius: var(--wpuf-border-radius); + transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; + margin-bottom: 0; + width: 100%; + font-family: -apple-system, system-ui, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + + &:focus { + color: var(--wpuf-text-color); + background-color: #fff; + border-color: var(--wpuf-primary-color); + outline: none; + box-shadow: 0 0 0 2px rgba(26, 126, 251, 0.1); + } + } + + .wpuf-captcha-error { + display: block; + margin-top: 5px; + font-size: 13px; + color: var(--wpuf-danger-color); + } + } + } + } +} + +// Ensure lity popup appears above Elementor popup +.lity { + z-index: 9999 !important; +} \ No newline at end of file diff --git a/includes/Assets.php b/includes/Assets.php index d287540b3..18fae1096 100644 --- a/includes/Assets.php +++ b/includes/Assets.php @@ -109,6 +109,9 @@ public function get_styles() { 'frontend-forms' => [ 'src' => WPUF_ASSET_URI . '/css/frontend-forms.css', ], + 'elementor-frontend-forms' => [ + 'src' => WPUF_ASSET_URI . '/css/elementor-frontend-forms.css', + ], 'frontend-subscriptions' => [ 'src' => WPUF_ASSET_URI . '/css/frontend-subscriptions.min.css', ], diff --git a/includes/Integrations/Elementor/Elementor.php b/includes/Integrations/Elementor/Elementor.php index c1a1009cf..84a418982 100644 --- a/includes/Integrations/Elementor/Elementor.php +++ b/includes/Integrations/Elementor/Elementor.php @@ -11,6 +11,26 @@ class Elementor { public function __construct() { add_action( 'elementor/widgets/register', [ $this, 'register_widgets' ] ); + + add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'enqueue_styles' ] ); + add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_styles' ] ); + } + + /** + * Enqueue Elementor Specific Styles for both frontend and editor + * + * @since WPUF_SINCE + * + * @return void + */ + public function enqueue_styles() { + wp_dequeue_style('wpuf-frontend-forms'); + wp_dequeue_style('wpuf-layout1'); + wp_dequeue_style('wpuf-layout2'); + wp_dequeue_style('wpuf-layout3'); + wp_dequeue_style('wpuf-layout4'); + wp_dequeue_style('wpuf-layout5'); + wp_enqueue_style( 'wpuf-elementor-frontend-forms' ); } /** diff --git a/includes/Integrations/Elementor/Widget.php b/includes/Integrations/Elementor/Widget.php index b20bdbd9a..a50905115 100644 --- a/includes/Integrations/Elementor/Widget.php +++ b/includes/Integrations/Elementor/Widget.php @@ -1,4 +1,9 @@ start_controls_section( 'section_content', @@ -55,9 +106,20 @@ protected function register_controls() { $this->register_container_style_controls(); $this->register_label_style_controls(); $this->register_input_style_controls(); + $this->register_placeholder_style_controls(); + $this->register_radio_checkbox_style_controls(); $this->register_submit_button_style_controls(); + $this->register_success_message_style_controls(); + $this->register_error_message_style_controls(); } + /** + * Retrieve all published WPUF forms + * + * @since WPUF_SINCE + * + * @return array Array of forms formatted as select options + */ protected function get_wpuf_forms() { $forms = get_posts( [ 'post_type' => 'wpuf_forms', @@ -76,6 +138,13 @@ protected function get_wpuf_forms() { return $options; } + /** + * Register container style controls + * + * @since WPUF_SINCE + * + * @return void + */ protected function register_container_style_controls() { $this->start_controls_section( 'section_container_style', @@ -95,6 +164,60 @@ protected function register_container_style_controls() { ] ); + $this->add_control( + 'container_link_color', + [ + 'label' => __( 'Link Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} .wpuf-elementor-widget-wrapper .wpuf-form a' => 'color: {{VALUE}};', + ], + ] + ); + + $this->add_responsive_control( + 'container_max_width', + [ + 'label' => __( 'Max Width', 'wp-user-frontend' ), + 'type' => Controls_Manager::SLIDER, + 'size_units' => [ 'px', 'em', '%' ], + 'range' => [ + 'px' => [ 'min' => 10, 'max' => 1500 ], + 'em' => [ 'min' => 1, 'max' => 80 ], + ], + 'selectors' => [ + '{{WRAPPER}} .wpuf-elementor-widget-wrapper' => 'width: {{SIZE}}{{UNIT}};', + ], + ] + ); + + $this->add_control( + 'container_alignment', + [ + 'label' => __( 'Alignment', 'wp-user-frontend' ), + 'type' => Controls_Manager::CHOOSE, + 'options' => [ + 'default' => [ + 'title' => __( 'Default', 'wp-user-frontend' ), + 'icon' => 'eicon-ban', + ], + 'left' => [ + 'title' => __( 'Left', 'wp-user-frontend' ), + 'icon' => 'eicon-h-align-left', + ], + 'center' => [ + 'title' => __( 'Center', 'wp-user-frontend' ), + 'icon' => 'eicon-h-align-center', + ], + 'right' => [ + 'title' => __( 'Right', 'wp-user-frontend' ), + 'icon' => 'eicon-h-align-right', + ], + ], + 'default' => 'default', + ] + ); + $this->add_responsive_control( 'container_padding', [ @@ -150,6 +273,13 @@ protected function register_container_style_controls() { $this->end_controls_section(); } + /** + * Register label style controls + * + * @since WPUF_SINCE + * + * @return void + */ protected function register_label_style_controls() { $this->start_controls_section( 'section_label_style', @@ -178,26 +308,79 @@ protected function register_label_style_controls() { ] ); + $this->add_control( + 'label_asterisk_color', + [ + 'label' => __( 'Asterisk Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} .wpuf-form .wpuf-label .required' => 'color: {{VALUE}};', + ], + 'separator' => 'before', + ] + ); + + $this->add_control( + 'label_asterisk_size', + [ + 'label' => __( 'Asterisk Size', 'wp-user-frontend' ), + 'type' => Controls_Manager::SLIDER, + 'size_units' => [ 'px', 'em', '%' ], + 'range' => [ + 'px' => [ 'min' => 0, 'max' => 30, 'step' => 1 ], + '%' => [ 'min' => 0, 'max' => 30, 'step' => 1 ], + ], + 'selectors' => [ + '{{WRAPPER}} .wpuf-form .wpuf-label .required' => 'font-size: {{SIZE}}{{UNIT}};', + ], + ] + ); + $this->end_controls_section(); } + /** + * Register input field style controls + * + * @since WPUF_SINCE + * + * @return void + */ protected function register_input_style_controls() { + $input_selector = '{{WRAPPER}} .wpuf-form input[type="text"], {{WRAPPER}} .wpuf-form input[type="email"], {{WRAPPER}} .wpuf-form input[type="url"], {{WRAPPER}} .wpuf-form input[type="password"], {{WRAPPER}} .wpuf-form input[type="number"], {{WRAPPER}} .wpuf-form textarea, {{WRAPPER}} .wpuf-form select'; + $this->start_controls_section( 'section_input_style', [ - 'label' => __( 'Input Fields', 'wp-user-frontend' ), + 'label' => __( 'Input & Textarea', 'wp-user-frontend' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); + $this->add_responsive_control( + 'input_alignment', + [ + 'label' => __( 'Alignment', 'wp-user-frontend' ), + 'type' => Controls_Manager::CHOOSE, + 'options' => [ + 'left' => [ 'title' => __( 'Left', 'wp-user-frontend' ), 'icon' => 'eicon-text-align-left' ], + 'center' => [ 'title' => __( 'Center', 'wp-user-frontend' ), 'icon' => 'eicon-text-align-center' ], + 'right' => [ 'title' => __( 'Right', 'wp-user-frontend' ), 'icon' => 'eicon-text-align-right' ], + ], + 'selectors' => [ $input_selector => 'text-align: {{VALUE}};' ], + ] + ); + + $this->start_controls_tabs( 'tabs_input_style' ); + + $this->start_controls_tab( 'tab_input_normal', [ 'label' => __( 'Normal', 'wp-user-frontend' ) ] ); + $this->add_control( 'input_bg_color', [ 'label' => __( 'Background Color', 'wp-user-frontend' ), 'type' => Controls_Manager::COLOR, - 'selectors' => [ - '{{WRAPPER}} .wpuf-form input[type="text"], {{WRAPPER}} .wpuf-form input[type="email"], {{WRAPPER}} .wpuf-form input[type="url"], {{WRAPPER}} .wpuf-form input[type="password"], {{WRAPPER}} .wpuf-form textarea, {{WRAPPER}} .wpuf-form select' => 'background-color: {{VALUE}};', - ], + 'selectors' => [ $input_selector => 'background-color: {{VALUE}};' ], ] ); @@ -206,26 +389,18 @@ protected function register_input_style_controls() { [ 'label' => __( 'Text Color', 'wp-user-frontend' ), 'type' => Controls_Manager::COLOR, - 'selectors' => [ - '{{WRAPPER}} .wpuf-form input[type="text"], {{WRAPPER}} .wpuf-form input[type="email"], {{WRAPPER}} .wpuf-form input[type="url"], {{WRAPPER}} .wpuf-form input[type="password"], {{WRAPPER}} .wpuf-form textarea, {{WRAPPER}} .wpuf-form select' => 'color: {{VALUE}};', - ], + 'selectors' => [ $input_selector => 'color: {{VALUE}};' ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), - [ - 'name' => 'input_typography', - 'selector' => '{{WRAPPER}} .wpuf-form input[type="text"], {{WRAPPER}} .wpuf-form input[type="email"], {{WRAPPER}} .wpuf-form input[type="url"], {{WRAPPER}} .wpuf-form input[type="password"], {{WRAPPER}} .wpuf-form textarea, {{WRAPPER}} .wpuf-form select', - ] + [ 'name' => 'input_typography', 'selector' => $input_selector ] ); $this->add_group_control( Group_Control_Border::get_type(), - [ - 'name' => 'input_border', - 'selector' => '{{WRAPPER}} .wpuf-form input[type="text"], {{WRAPPER}} .wpuf-form input[type="email"], {{WRAPPER}} .wpuf-form input[type="url"], {{WRAPPER}} .wpuf-form input[type="password"], {{WRAPPER}} .wpuf-form textarea, {{WRAPPER}} .wpuf-form select', - ] + [ 'name' => 'input_border', 'selector' => $input_selector ] ); $this->add_control( @@ -234,9 +409,7 @@ protected function register_input_style_controls() { 'label' => __( 'Border Radius', 'wp-user-frontend' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], - 'selectors' => [ - '{{WRAPPER}} .wpuf-form input[type="text"], {{WRAPPER}} .wpuf-form input[type="email"], {{WRAPPER}} .wpuf-form input[type="url"], {{WRAPPER}} .wpuf-form input[type="password"], {{WRAPPER}} .wpuf-form textarea, {{WRAPPER}} .wpuf-form select' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', - ], + 'selectors' => [ $input_selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); @@ -246,8 +419,140 @@ protected function register_input_style_controls() { 'label' => __( 'Padding', 'wp-user-frontend' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], + 'selectors' => [ $input_selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], + ] + ); + + $this->add_group_control( + Group_Control_Box_Shadow::get_type(), + [ + 'name' => 'input_box_shadow', + 'selector' => $input_selector, + 'separator' => 'before', + ] + ); + + $this->end_controls_tab(); + + $this->start_controls_tab( 'tab_input_focus', [ 'label' => __( 'Focus', 'wp-user-frontend' ) ] ); + + $this->add_control( + 'input_focus_bg_color', + [ + 'label' => __( 'Background Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} .wpuf-form input[type="text"]:focus, {{WRAPPER}} .wpuf-form input[type="email"]:focus, {{WRAPPER}} .wpuf-form input[type="url"]:focus, {{WRAPPER}} .wpuf-form input[type="password"]:focus, {{WRAPPER}} .wpuf-form input[type="number"]:focus, {{WRAPPER}} .wpuf-form textarea:focus, {{WRAPPER}} .wpuf-form select:focus' => 'background-color: {{VALUE}};', + ], + ] + ); + + $this->add_group_control( + Group_Control_Border::get_type(), + [ + 'name' => 'input_focus_border', + 'selector' => '{{WRAPPER}} .wpuf-form input[type="text"]:focus, {{WRAPPER}} .wpuf-form input[type="email"]:focus, {{WRAPPER}} .wpuf-form input[type="url"]:focus, {{WRAPPER}} .wpuf-form input[type="password"]:focus, {{WRAPPER}} .wpuf-form input[type="number"]:focus, {{WRAPPER}} .wpuf-form textarea:focus, {{WRAPPER}} .wpuf-form select:focus', + ] + ); + + $this->add_group_control( + Group_Control_Box_Shadow::get_type(), + [ + 'name' => 'input_focus_box_shadow', + 'selector' => '{{WRAPPER}} .wpuf-form input[type="text"]:focus, {{WRAPPER}} .wpuf-form input[type="email"]:focus, {{WRAPPER}} .wpuf-form input[type="url"]:focus, {{WRAPPER}} .wpuf-form input[type="password"]:focus, {{WRAPPER}} .wpuf-form input[type="number"]:focus, {{WRAPPER}} .wpuf-form textarea:focus, {{WRAPPER}} .wpuf-form select:focus', + ] + ); + + $this->end_controls_tab(); + + $this->end_controls_tabs(); + + $this->add_responsive_control( + 'input_field_spacing', + [ + 'label' => __( 'Field Spacing', 'wp-user-frontend' ), + 'type' => Controls_Manager::SLIDER, + 'size_units' => [ 'px', 'em' ], + 'range' => [ 'px' => [ 'min' => 0, 'max' => 100, 'step' => 1 ] ], + 'selectors' => [ + '{{WRAPPER}} .wpuf-form .field-items' => 'margin-bottom: {{SIZE}}{{UNIT}};', + ], + 'separator' => 'before', + ] + ); + + $this->end_controls_section(); + } + + /** + * Register placeholder style controls. + * + * @since WPUF_SINCE + * + * @return void + */ + protected function register_placeholder_style_controls() { + $this->start_controls_section( + 'section_placeholder_style', + [ + 'label' => __( 'Placeholder', 'wp-user-frontend' ), + 'tab' => Controls_Manager::TAB_STYLE, + ] + ); + + $placeholder_selector = '{{WRAPPER}} .wpuf-form input::placeholder, {{WRAPPER}} .wpuf-form textarea::placeholder, {{WRAPPER}} .wpuf-form input::-webkit-input-placeholder, {{WRAPPER}} .wpuf-form textarea::-webkit-input-placeholder, {{WRAPPER}} .wpuf-form input::-moz-placeholder, {{WRAPPER}} .wpuf-form textarea::-moz-placeholder, {{WRAPPER}} .wpuf-form input:-ms-input-placeholder, {{WRAPPER}} .wpuf-form textarea:-ms-input-placeholder'; + + $this->add_control( + 'placeholder_color', + [ + 'label' => __( 'Text Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ $placeholder_selector => 'color: {{VALUE}};' ], + ] + ); + + $this->end_controls_section(); + } + + /** + * Register radio and checkbox style controls. + * + * @since WPUF_SINCE + * + * @return void + */ + protected function register_radio_checkbox_style_controls() { + $this->start_controls_section( + 'section_radio_checkbox_style', + [ + 'label' => __( 'Radio & Checkbox', 'wp-user-frontend' ), + 'tab' => Controls_Manager::TAB_STYLE, + ] + ); + + $this->add_responsive_control( + 'radio_checkbox_size', + [ + 'label' => __( 'Size', 'wp-user-frontend' ), + 'type' => Controls_Manager::SLIDER, + 'size_units' => [ 'px' ], + 'range' => [ 'px' => [ 'min' => 0, 'max' => 80, 'step' => 1 ] ], + 'default' => [ 'size' => 18, 'unit' => 'px' ], 'selectors' => [ - '{{WRAPPER}} .wpuf-form input[type="text"], {{WRAPPER}} .wpuf-form input[type="email"], {{WRAPPER}} .wpuf-form input[type="url"], {{WRAPPER}} .wpuf-form input[type="password"], {{WRAPPER}} .wpuf-form textarea, {{WRAPPER}} .wpuf-form select' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + '{{WRAPPER}} .wpuf-form input[type="radio"], {{WRAPPER}} .wpuf-form input[type="checkbox"]' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', + ], + ] + ); + + $this->add_responsive_control( + 'radio_checkbox_spacing', + [ + 'label' => __( 'Spacing', 'wp-user-frontend' ), + 'type' => Controls_Manager::SLIDER, + 'size_units' => [ 'px', 'em' ], + 'range' => [ 'px' => [ 'min' => 0, 'max' => 30, 'step' => 1 ] ], + 'selectors' => [ + '{{WRAPPER}} .wpuf-form input[type="radio"], {{WRAPPER}} .wpuf-form input[type="checkbox"]' => 'margin-right: {{SIZE}}{{UNIT}};', ], ] ); @@ -255,7 +560,16 @@ protected function register_input_style_controls() { $this->end_controls_section(); } + /** + * Register submit button style controls + * + * @since WPUF_SINCE + * + * @return void + */ protected function register_submit_button_style_controls() { + $btn_selector = '{{WRAPPER}} .wpuf-form .wpuf-submit-button'; + $this->start_controls_section( 'section_submit_button_style', [ @@ -264,23 +578,56 @@ protected function register_submit_button_style_controls() { ] ); - $this->start_controls_tabs( 'tabs_submit_button_style' ); + $this->add_control( + 'submit_button_width_type', + [ + 'label' => __( 'Width', 'wp-user-frontend' ), + 'type' => Controls_Manager::SELECT, + 'default' => 'custom', + 'options' => [ + 'full-width' => __( 'Full Width', 'wp-user-frontend' ), + 'custom' => __( 'Custom', 'wp-user-frontend' ), + ], + ] + ); - $this->start_controls_tab( - 'tab_submit_button_normal', + $this->add_responsive_control( + 'submit_button_align', + [ + 'label' => __( 'Alignment', 'wp-user-frontend' ), + 'type' => Controls_Manager::CHOOSE, + 'options' => [ + 'left' => [ 'title' => __( 'Left', 'wp-user-frontend' ), 'icon' => 'eicon-h-align-left' ], + 'center' => [ 'title' => __( 'Center', 'wp-user-frontend' ), 'icon' => 'eicon-h-align-center' ], + 'right' => [ 'title' => __( 'Right', 'wp-user-frontend' ), 'icon' => 'eicon-h-align-right' ], + ], + 'selectors' => [ '{{WRAPPER}} .wpuf-form .wpuf-submit' => 'text-align: {{VALUE}};' ], + 'condition' => [ 'submit_button_width_type' => 'custom' ], + ] + ); + + $this->add_responsive_control( + 'submit_button_width', [ - 'label' => __( 'Normal', 'wp-user-frontend' ), + 'label' => __( 'Width', 'wp-user-frontend' ), + 'type' => Controls_Manager::SLIDER, + 'size_units' => [ 'px', '%' ], + 'range' => [ 'px' => [ 'min' => 0, 'max' => 1200, 'step' => 1 ] ], + 'selectors' => [ $btn_selector => 'width: {{SIZE}}{{UNIT}};' ], + 'condition' => [ 'submit_button_width_type' => 'custom' ], ] ); + $this->start_controls_tabs( 'tabs_submit_button_style' ); + + $this->start_controls_tab( 'tab_submit_button_normal', [ 'label' => __( 'Normal', 'wp-user-frontend' ) ] ); + $this->add_control( 'submit_button_bg_color', [ 'label' => __( 'Background Color', 'wp-user-frontend' ), 'type' => Controls_Manager::COLOR, - 'selectors' => [ - '{{WRAPPER}} .wpuf-form .wpuf-submit-button' => 'background-color: {{VALUE}};', - ], + 'selectors' => [ $btn_selector => 'background-color: {{VALUE}};' ], ] ); @@ -289,37 +636,59 @@ protected function register_submit_button_style_controls() { [ 'label' => __( 'Text Color', 'wp-user-frontend' ), 'type' => Controls_Manager::COLOR, - 'selectors' => [ - '{{WRAPPER}} .wpuf-form .wpuf-submit-button' => 'color: {{VALUE}};', - ], + 'selectors' => [ $btn_selector => 'color: {{VALUE}};' ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), + [ 'name' => 'submit_button_typography', 'selector' => $btn_selector ] + ); + + $this->add_group_control( + Group_Control_Border::get_type(), + [ 'name' => 'submit_button_border', 'selector' => $btn_selector ] + ); + + $this->add_control( + 'submit_button_border_radius', [ - 'name' => 'submit_button_typography', - 'selector' => '{{WRAPPER}} .wpuf-form .wpuf-submit-button', + 'label' => __( 'Border Radius', 'wp-user-frontend' ), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => [ 'px', '%' ], + 'selectors' => [ $btn_selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); - $this->end_controls_tab(); + $this->add_responsive_control( + 'submit_button_padding', + [ + 'label' => __( 'Padding', 'wp-user-frontend' ), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => [ 'px', 'em', '%' ], + 'selectors' => [ $btn_selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], + ] + ); - $this->start_controls_tab( - 'tab_submit_button_hover', + $this->add_group_control( + Group_Control_Box_Shadow::get_type(), [ - 'label' => __( 'Hover', 'wp-user-frontend' ), + 'name' => 'submit_button_box_shadow', + 'selector' => $btn_selector, + 'separator' => 'before', ] ); + $this->end_controls_tab(); + + $this->start_controls_tab( 'tab_submit_button_hover', [ 'label' => __( 'Hover', 'wp-user-frontend' ) ] ); + $this->add_control( 'submit_button_hover_bg_color', [ 'label' => __( 'Background Color', 'wp-user-frontend' ), 'type' => Controls_Manager::COLOR, - 'selectors' => [ - '{{WRAPPER}} .wpuf-form .wpuf-submit-button:hover' => 'background-color: {{VALUE}};', - ], + 'selectors' => [ $btn_selector . ':hover' => 'background-color: {{VALUE}};' ], ] ); @@ -328,9 +697,16 @@ protected function register_submit_button_style_controls() { [ 'label' => __( 'Text Color', 'wp-user-frontend' ), 'type' => Controls_Manager::COLOR, - 'selectors' => [ - '{{WRAPPER}} .wpuf-form .wpuf-submit-button:hover' => 'color: {{VALUE}};', - ], + 'selectors' => [ $btn_selector . ':hover' => 'color: {{VALUE}};' ], + ] + ); + + $this->add_control( + 'submit_button_hover_border_color', + [ + 'label' => __( 'Border Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ $btn_selector . ':hover' => 'border-color: {{VALUE}};' ], ] ); @@ -338,42 +714,131 @@ protected function register_submit_button_style_controls() { $this->end_controls_tabs(); + $this->end_controls_section(); + } + + /** + * Register success message style controls. + * + * @since WPUF_SINCE + * + * @return void + */ + protected function register_success_message_style_controls() { + $this->start_controls_section( + 'section_success_message_style', + [ + 'label' => __( 'Success Message', 'wp-user-frontend' ), + 'tab' => Controls_Manager::TAB_STYLE, + ] + ); + + $this->add_control( + 'success_message_bg_color', + [ + 'label' => __( 'Background Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} .wpuf-elementor-widget-wrapper .wpuf-success' => 'background-color: {{VALUE}};', + ], + ] + ); + + $this->add_control( + 'success_message_text_color', + [ + 'label' => __( 'Text Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ + '{{WRAPPER}} .wpuf-elementor-widget-wrapper .wpuf-success' => 'color: {{VALUE}};', + ], + ] + ); + + $this->add_group_control( + Group_Control_Typography::get_type(), + [ + 'name' => 'success_message_typography', + 'selector' => '{{WRAPPER}} .wpuf-elementor-widget-wrapper .wpuf-success', + ] + ); + $this->add_group_control( Group_Control_Border::get_type(), [ - 'name' => 'submit_button_border', - 'selector' => '{{WRAPPER}} .wpuf-form .wpuf-submit-button', - 'separator' => 'before', + 'name' => 'success_message_border', + 'selector' => '{{WRAPPER}} .wpuf-elementor-widget-wrapper .wpuf-success', ] ); + $this->end_controls_section(); + } + + /** + * Register error message style controls. + * + * @since WPUF_SINCE + * + * @return void + */ + protected function register_error_message_style_controls() { + $this->start_controls_section( + 'section_error_message_style', + [ + 'label' => __( 'Error Message', 'wp-user-frontend' ), + 'tab' => Controls_Manager::TAB_STYLE, + ] + ); + + $error_selector = '{{WRAPPER}} .wpuf-elementor-widget-wrapper .wpuf-form .wpuf-error, {{WRAPPER}} .wpuf-elementor-widget-wrapper .wpuf-form .error'; + $this->add_control( - 'submit_button_border_radius', + 'error_message_color', [ - 'label' => __( 'Border Radius', 'wp-user-frontend' ), - 'type' => Controls_Manager::DIMENSIONS, - 'size_units' => [ 'px', '%' ], - 'selectors' => [ - '{{WRAPPER}} .wpuf-form .wpuf-submit-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', - ], + 'label' => __( 'Color', 'wp-user-frontend' ), + 'type' => Controls_Manager::COLOR, + 'selectors' => [ $error_selector => 'color: {{VALUE}};' ], + ] + ); + + $this->add_group_control( + Group_Control_Typography::get_type(), + [ + 'name' => 'error_message_typography', + 'selector' => $error_selector, ] ); $this->add_responsive_control( - 'submit_button_padding', + 'error_message_padding', [ 'label' => __( 'Padding', 'wp-user-frontend' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], - 'selectors' => [ - '{{WRAPPER}} .wpuf-form .wpuf-submit-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', - ], + 'selectors' => [ $error_selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], + ] + ); + + $this->add_responsive_control( + 'error_message_margin', + [ + 'label' => __( 'Margin', 'wp-user-frontend' ), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => [ 'px', 'em', '%' ], + 'selectors' => [ $error_selector => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); $this->end_controls_section(); } + /** + * Render the widget output on the frontend + * + * @since WPUF_SINCE + * + * @return void + */ protected function render() { $settings = $this->get_settings_for_display(); $form_id = isset( $settings['form_id'] ) ? $settings['form_id'] : null; @@ -382,10 +847,23 @@ protected function render() { return; } + $wrapper_classes = [ 'wpuf-elementor-widget-wrapper' ]; + + if ( ! empty( $settings['submit_button_width_type'] ) && 'full-width' === $settings['submit_button_width_type'] ) { + $wrapper_classes[] = 'wpuf-elementor-submit-full'; + } + + $this->add_render_attribute( 'wrapper', 'class', $wrapper_classes ); + + // Set alignment attribute if not default + if ( ! empty( $settings['container_alignment'] ) && 'default' !== $settings['container_alignment'] ) { + $this->add_render_attribute( 'wrapper', 'data-align', $settings['container_alignment'] ); + } + $shortcode_str = '[wpuf_form id="' . $form_id . '"]'; $output = do_shortcode( $shortcode_str ); - echo '
'; + echo '
get_render_attribute_string( 'wrapper' ) ) . '>'; echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- shortcode output echo '
'; } @@ -397,7 +875,7 @@ protected function render() { * will fall back to using the render() method for both frontend * and editor preview. * - * @since 4.2.7 + * @since WPUF_SINCE * * @access protected */ diff --git a/languages/wp-user-frontend.pot b/languages/wp-user-frontend.pot index 2c22c9d95..37011cb0b 100644 --- a/languages/wp-user-frontend.pot +++ b/languages/wp-user-frontend.pot @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: WP User Frontend 4.2.6\n" "Report-Msgid-Bugs-To: https://wedevs.com/contact/\n" -"POT-Creation-Date: 2026-01-14 08:50:52+00:00\n" +"POT-Creation-Date: 2026-01-21 05:31:58+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -1564,6 +1564,7 @@ msgstr "" #: admin/template.php:127 includes/Admin/Forms/Admin_Template.php:146 #: includes/Fields/Field_Contract.php:652 +#: includes/Integrations/Elementor/Widget.php:536 msgid "Size" msgstr "" @@ -1604,6 +1605,8 @@ msgstr "" #: admin/template.php:188 includes/Admin/Forms/Admin_Template.php:217 #: includes/Fields/Field_Contract.php:740 +#: includes/Integrations/Elementor/Widget.php:376 +#: includes/Integrations/Elementor/Widget.php:623 msgid "Normal" msgstr "" @@ -6250,6 +6253,11 @@ msgid "Background color for progressbar or active step." msgstr "" #: includes/Free/Free_Loader.php:1609 +#: includes/Integrations/Elementor/Widget.php:381 +#: includes/Integrations/Elementor/Widget.php:442 +#: includes/Integrations/Elementor/Widget.php:628 +#: includes/Integrations/Elementor/Widget.php:689 +#: includes/Integrations/Elementor/Widget.php:739 msgid "Background Color" msgstr "" @@ -7090,6 +7098,169 @@ msgstr "" msgid "Mark the %1$s as featured (remaining %2$d)" msgstr "" +#: includes/Integrations/Elementor/Widget.php:42 +msgid "User Frontend Form" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:89 +msgid "Content" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:96 +msgid "Select Form" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:130 +msgid "Select a Form" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:152 +msgid "Form Container" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:161 +msgid "Background" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:170 +msgid "Link Color" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:181 +msgid "Max Width" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:197 +#: includes/Integrations/Elementor/Widget.php:363 +#: includes/Integrations/Elementor/Widget.php:597 +msgid "Alignment" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:201 +#: includes/functions/settings-options.php:116 +msgid "Default" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:205 +#: includes/Integrations/Elementor/Widget.php:366 +#: includes/Integrations/Elementor/Widget.php:600 +#: includes/functions/settings-options.php:595 +msgid "Left" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:209 +#: includes/Integrations/Elementor/Widget.php:367 +#: includes/Integrations/Elementor/Widget.php:601 +msgid "Center" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:213 +#: includes/Integrations/Elementor/Widget.php:368 +#: includes/Integrations/Elementor/Widget.php:602 +#: includes/functions/settings-options.php:597 +msgid "Right" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:224 +#: includes/Integrations/Elementor/Widget.php:419 +#: includes/Integrations/Elementor/Widget.php:666 +#: includes/Integrations/Elementor/Widget.php:815 +msgid "Padding" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:236 +#: includes/Integrations/Elementor/Widget.php:825 +msgid "Margin" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:256 +#: includes/Integrations/Elementor/Widget.php:409 +#: includes/Integrations/Elementor/Widget.php:656 +msgid "Border Radius" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:287 +msgid "Labels" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:295 +#: includes/Integrations/Elementor/Widget.php:390 +#: includes/Integrations/Elementor/Widget.php:508 +#: includes/Integrations/Elementor/Widget.php:637 +#: includes/Integrations/Elementor/Widget.php:698 +#: includes/Integrations/Elementor/Widget.php:750 +msgid "Text Color" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:314 +msgid "Asterisk Color" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:326 +msgid "Asterisk Size" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:355 +msgid "Input & Textarea" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:437 +msgid "Focus" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:473 +msgid "Field Spacing" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:498 +msgid "Placeholder" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:528 +msgid "Radio & Checkbox" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:550 +msgid "Spacing" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:576 +msgid "Submit Button" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:584 +#: includes/Integrations/Elementor/Widget.php:612 +msgid "Width" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:588 +msgid "Full Width" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:589 +msgid "Custom" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:684 +msgid "Hover" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:707 +msgid "Border Color" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:731 +msgid "Success Message" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:788 +msgid "Error Message" +msgstr "" + +#: includes/Integrations/Elementor/Widget.php:798 +msgid "Color" +msgstr "" + #: includes/Integrations/Events_Calendar/Templates/Event_Form_Template.php:23 msgid "The Events Calendar" msgstr "" @@ -8121,10 +8292,6 @@ msgstr "" msgid "Admins, Editors, Authors, Contributors" msgstr "" -#: includes/functions/settings-options.php:116 -msgid "Default" -msgstr "" - #: includes/functions/settings-options.php:121 msgid "Override the post edit link" msgstr "" @@ -8536,14 +8703,6 @@ msgstr "" msgid "Currency Position" msgstr "" -#: includes/functions/settings-options.php:595 -msgid "Left" -msgstr "" - -#: includes/functions/settings-options.php:597 -msgid "Right" -msgstr "" - #: includes/functions/settings-options.php:599 msgid "Left with space" msgstr "" @@ -9883,11 +10042,11 @@ msgstr "" msgid " or greater." msgstr "" -#: wpuf.php:260 +#: wpuf.php:273 msgid "Your WP User Frontend Pro is almost ready!" msgstr "" -#: wpuf.php:264 +#: wpuf.php:277 #. translators: 1: opening anchor tag, 2: closing anchor tag. msgid "" "We've pushed a major update on both WP User Frontend Free and WP " From 75f31de5f339629c733b324b5299f4ab532b4209 Mon Sep 17 00:00:00 2001 From: Sapayth Hossain Date: Mon, 26 Jan 2026 14:46:44 +0600 Subject: [PATCH 03/17] fix radio, checkbox fields in elementor builder --- includes/Fields/Field_Contract.php | 31 ++++++++++++++++++++-- includes/Integrations/Elementor/Widget.php | 5 ++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/includes/Fields/Field_Contract.php b/includes/Fields/Field_Contract.php index cd714f454..7535fb11c 100755 --- a/includes/Fields/Field_Contract.php +++ b/includes/Fields/Field_Contract.php @@ -763,6 +763,33 @@ public function get_default_textarea_option_settings() { ]; } + /** + * Check if we should render admin-style markup + * + * Returns true for admin dashboard, but false for Elementor editor + * since Elementor editor needs frontend-style markup for proper preview. + * + * @since WPUF_SINCE + * + * @return bool + */ + protected function use_admin_markup() { + if ( ! is_admin() ) { + return false; + } + + // Check if we're in Elementor editor mode + // Elementor editor needs frontend markup for proper preview + if ( class_exists( '\Elementor\Plugin' ) ) { + $elementor = \Elementor\Plugin::$instance; + if ( $elementor && $elementor->editor && $elementor->editor->is_edit_mode() ) { + return false; + } + } + + return true; + } + /** * Prints form input label for admin * @@ -770,7 +797,7 @@ public function get_default_textarea_option_settings() { * @param int $form_id */ public function field_print_label( $field, $form_id = 0 ) { - if ( is_admin() ) { ?> + if ( $this->use_admin_markup() ) { ?> print_list_attributes( $field ); ?>> required_mark( $field ) ); ?> @@ -782,7 +809,7 @@ public function field_print_label( $field, $form_id = 0 ) { } public function after_field_print_label() { - if ( is_admin() ) { + if ( $this->use_admin_markup() ) { ?> Date: Tue, 27 Jan 2026 11:45:32 +0600 Subject: [PATCH 04/17] tinymce preview in elementor builder --- includes/Fields/Form_Field_Post_Content.php | 2 + includes/Fields/Form_Field_Post_Excerpt.php | 2 + includes/Integrations/Elementor/Elementor.php | 33 ++++ includes/Integrations/Elementor/Widget.php | 157 ++++++++++++++++++ wpuf-functions.php | 5 + 5 files changed, 199 insertions(+) diff --git a/includes/Fields/Form_Field_Post_Content.php b/includes/Fields/Form_Field_Post_Content.php index 8a922d4c3..7f0b2061b 100755 --- a/includes/Fields/Form_Field_Post_Content.php +++ b/includes/Fields/Form_Field_Post_Content.php @@ -99,6 +99,7 @@ public function render( $field_settings, $form_id, $type = 'post', $post_id = nu } $editor_settings = apply_filters( 'wpuf_textarea_editor_args', $editor_settings ); + wp_editor( $value, $textarea_id, $editor_settings ); } elseif ( isset( $field_settings['rich'] ) && $field_settings['rich'] === 'teeny' ) { $editor_settings = [ @@ -115,6 +116,7 @@ public function render( $field_settings, $form_id, $type = 'post', $post_id = nu } $editor_settings = apply_filters( 'wpuf_textarea_editor_args', $editor_settings ); + wp_editor( $value, $textarea_id, $editor_settings ); } else { ?> diff --git a/includes/Fields/Form_Field_Post_Excerpt.php b/includes/Fields/Form_Field_Post_Excerpt.php index 66a558670..89b14f697 100755 --- a/includes/Fields/Form_Field_Post_Excerpt.php +++ b/includes/Fields/Form_Field_Post_Excerpt.php @@ -56,6 +56,7 @@ public function render( $field_settings, $form_id, $type = 'post', $post_id = nu ]; $editor_settings = apply_filters( 'wpuf_textarea_editor_args', $editor_settings ); + wp_editor( $value, $textarea_id, $editor_settings ); } elseif ( $field_settings['rich'] == 'teeny' ) { $editor_settings = [ @@ -68,6 +69,7 @@ public function render( $field_settings, $form_id, $type = 'post', $post_id = nu ]; $editor_settings = apply_filters( 'wpuf_textarea_editor_args', $editor_settings ); + wp_editor( $value, $textarea_id, $editor_settings ); } else { ?> diff --git a/includes/Integrations/Elementor/Elementor.php b/includes/Integrations/Elementor/Elementor.php index 84a418982..945b1f384 100644 --- a/includes/Integrations/Elementor/Elementor.php +++ b/includes/Integrations/Elementor/Elementor.php @@ -14,6 +14,10 @@ public function __construct() { add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'enqueue_styles' ] ); add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_styles' ] ); + + // Ensure editor scripts are enqueued for TinyMCE in Elementor preview + add_action( 'elementor/frontend/after_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); + add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); } /** @@ -33,6 +37,35 @@ public function enqueue_styles() { wp_enqueue_style( 'wpuf-elementor-frontend-forms' ); } + /** + * Enqueue Elementor Specific Scripts for both frontend and editor + * + * Ensures TinyMCE editor scripts are loaded when WPUF forms with rich text + * fields are rendered in Elementor preview. + * + * @since WPUF_SINCE + * + * @return void + */ + public function enqueue_scripts() { + // Ensure editor scripts are loaded for TinyMCE in Elementor preview + if ( function_exists( 'wp_enqueue_editor' ) ) { + wp_enqueue_editor(); + + // Also explicitly enqueue TinyMCE scripts if available + if ( function_exists( 'wp_enqueue_script' ) ) { + // Check if these scripts exist and enqueue them + global $wp_scripts; + if ( isset( $wp_scripts->registered['tinymce'] ) ) { + wp_enqueue_script( 'tinymce' ); + } + if ( isset( $wp_scripts->registered['wp-tinymce'] ) ) { + wp_enqueue_script( 'wp-tinymce' ); + } + } + } + } + /** * Register Elementor Widgets * diff --git a/includes/Integrations/Elementor/Widget.php b/includes/Integrations/Elementor/Widget.php index 26b91712d..0328a54cf 100644 --- a/includes/Integrations/Elementor/Widget.php +++ b/includes/Integrations/Elementor/Widget.php @@ -75,6 +75,19 @@ public function get_style_depends() { return [ 'wpuf-elementor-frontend-forms' ]; } + /** + * Retrieve the list of scripts the widget depends on. + * + * @since WPUF_SINCE + * + * @return array + */ + public function get_script_depends() { + // Note: wp_enqueue_editor() is called in Elementor::enqueue_scripts() + // to ensure TinyMCE scripts are loaded in Elementor preview + return []; + } + /** * Register widget controls * @@ -863,8 +876,152 @@ protected function render() { $shortcode_str = '[wpuf_form id="' . $form_id . '"]'; $output = do_shortcode( $shortcode_str ); + $is_elementor = class_exists( '\Elementor\Plugin' ) && ( + ( isset( \Elementor\Plugin::$instance->editor ) && \Elementor\Plugin::$instance->editor->is_edit_mode() ) + || ( isset( \Elementor\Plugin::$instance->preview ) && \Elementor\Plugin::$instance->preview->is_preview_mode() ) + ); + echo '
get_render_attribute_string( 'wrapper' ) ) . '>'; echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- shortcode output + + // Initialize TinyMCE in Elementor preview + if ( $is_elementor ) { + ?> + + '; } diff --git a/wpuf-functions.php b/wpuf-functions.php index 2abeea5af..c8de8a864 100644 --- a/wpuf-functions.php +++ b/wpuf-functions.php @@ -1412,6 +1412,11 @@ function wpuf_shortcode_map( $location, $post_id = null, $args = [], $meta_key =