Skip to content

Commit

Permalink
Fix form submission [TMZ-142] (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoladj77 authored Nov 24, 2024
1 parent 1997302 commit 551a1da
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions modules/forms/actions/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

use Elementor\Controls_Manager;

use HelloPlus\Includes\Utils;
use HelloPlus\Modules\Forms\Classes\Ajax_Handler;
use HelloPlus\Modules\Forms\Classes\Action_Base;
use HelloPlus\Modules\Forms\Classes\Form_Record;
use HelloPlus\Modules\Forms\Module;

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
Expand Down Expand Up @@ -96,7 +96,7 @@ public function register_settings_section( $widget ) {
]
);

$site_domain = Utils::get_site_domain();
$site_domain = Module::get_site_domain();

$widget->add_control(
$this->get_control_id( 'email_from' ),
Expand Down Expand Up @@ -256,7 +256,7 @@ public function run( $record, $ajax_handler ) {
'email_content' => '[all-fields]',
'email_from_name' => get_bloginfo( 'name' ),
'email_from' => get_bloginfo( 'admin_email' ),
'email_reply_to' => 'noreply@' . Utils::get_site_domain(),
'email_reply_to' => 'noreply@' . Module::get_site_domain(),
'email_to_cc' => '',
'email_to_bcc' => '',
];
Expand Down
1 change: 1 addition & 0 deletions modules/forms/assets/js/frontend/frontend.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export default class Forms extends elementorModules.Module {
constructor() {
super();

elementorFrontend.elementsHandler.attachHandler( 'ehp-form', [
() => import( /* webpackChunkName: 'form-lite' */ './handlers/form-sender' ),
() => import( /* webpackChunkName: 'form-lite' */ './handlers/form-redirect' ),
Expand Down
2 changes: 1 addition & 1 deletion modules/forms/assets/js/frontend/handlers/form-redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default elementorModules.frontend.handlers.Base.extend( {
getDefaultSettings() {
return {
selectors: {
form: '.elementor-form-lite',
form: '.ehp-form',
},
};
},
Expand Down
13 changes: 9 additions & 4 deletions modules/forms/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ public function register_scripts() {
);
}

protected function get_component_ids(): array {
return [];
}

public static function get_site_domain() {
return str_ireplace( 'www.', '', wp_parse_url( home_url(), PHP_URL_HOST ) );
}

/**
* Module constructor.
*/
Expand All @@ -123,6 +131,7 @@ public function __construct() {
$this->actions_registrar = new Form_Actions_Registrar();
$this->fields_registrar = new Form_Fields_Registrar();

// TODO: refactor & move to components:
// Ajax Handler
if ( Classes\Ajax_Handler::is_form_submitted() ) {
$this->add_component( 'ajax_handler', new Classes\Ajax_Handler() );
Expand All @@ -141,8 +150,4 @@ public function __construct() {
do_action( 'hello_plus/forms/form_submitted', $this );
}
}

protected function get_component_ids(): array {
return [];
}
}
10 changes: 3 additions & 7 deletions modules/forms/widgets/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Typography;
use Elementor\Modules\DynamicTags\Module as TagsModule;
use Elementor\Repeater;
Expand All @@ -15,6 +14,7 @@
use HelloPlus\Modules\Forms\Classes\Render\Widget_Form_Render;
use HelloPlus\Modules\Forms\Controls\Fields_Repeater;
use HelloPlus\Includes\Utils;
use HelloPlus\Modules\Forms\Module;

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
Expand Down Expand Up @@ -42,7 +42,7 @@ protected function is_dynamic_content(): bool {
return false;
}

protected function get_upsale_data() {
protected function get_upsale_data(): array {
return [
'condition' => ! Utils::has_pro(),
'image' => esc_url( HELLO_PLUS_URL . '/assets/images/go-pro.svg' ),
Expand All @@ -68,10 +68,6 @@ public function get_style_depends(): array {
return [ 'ehp-form' ];
}

public static function get_site_domain() {
return str_ireplace( 'www.', '', wp_parse_url( home_url(), PHP_URL_HOST ) );
}

protected function render(): void {
$render_strategy = new Widget_Form_Render( $this );

Expand Down Expand Up @@ -680,7 +676,7 @@ protected function add_content_actions_after_submit_section(): void {
]
);

$site_domain = $this->get_site_domain();
$site_domain = Module::get_site_domain();

$this->add_control(
'email_from',
Expand Down

0 comments on commit 551a1da

Please sign in to comment.