PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | WpInit/ElementorForm.php +0 -118 10.2.2 → 11.1.1 View file →
@@ -1,118 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\WpInit;
4 -
5 -use AcyMailing\Classes\UserClass;
6 -use AcyMailing\Classes\ListClass;
7 -
8 -class ElementorForm extends \ElementorPro\Modules\Forms\Classes\Action_Base
9 -{
10 - public function get_name()
11 - {
12 - return 'acymailing';
13 - }
14 -
15 - public function get_label()
16 - {
17 - return 'AcyMailing';
18 - }
19 -
20 - public function register_settings_section($widget)
21 - {
22 - if ($widget->get_id()) {
23 - $fields = ['' => ''];
24 - foreach ($widget->get_data('settings')['form_fields'] as $field) {
25 - if (!isset($field['custom_id']) || !isset($field['field_label'])) {
26 - continue;
27 - }
28 - $fields[$field['custom_id']] = $field['field_label'];
29 - }
30 -
31 - $widget->start_controls_section('section_acymailing', [
32 - 'label' => 'AcyMailing',
33 - 'condition' => [
34 - 'submit_actions' => $this->get_name(),
35 - ],
36 - ]);
37 -
38 - $listsClass = new ListClass();
39 - $lists = $listsClass->getAllWithIdName();
40 -
41 - $widget->add_control('acym_selectLists', [
42 - 'label' => acym_translation('ACYM_LISTS_SUMMARY'),
43 - 'label_block' => true,
44 - 'description' => acym_translation('ACYM_SELECT_LISTS_USERS_SUBSCRIBE'),
45 - 'type' => \Elementor\Controls_Manager::SELECT2,
46 - 'options' => $lists,
47 - 'multiple' => true,
48 - 'default' => '',
49 - ]);
50 -
51 - $widget->add_control('acym_nameField', [
52 - 'label' => acym_translation('ACYM_NAME_SUMMARY'),
53 - 'type' => \Elementor\Controls_Manager::SELECT,
54 - 'default' => '',
55 - 'options' => $fields,
56 - ]);
57 -
58 - $widget->add_control('acym_emailField', [
59 - 'label' => acym_translation('ACYM_EMAIL'),
60 - 'type' => \Elementor\Controls_Manager::SELECT,
61 - 'default' => '',
62 - 'options' => $fields,
63 - 'description' => acym_translation('ACYM_RELOAD_PAGE_TO_SEE_NEW_FIELDS'),
64 - ]);
65 -
66 - $widget->add_control('acym_confirmUsers', [
67 - 'label' => acym_translation('ACYM_IMPORT_USERS_AS_CONFIRMED'),
68 - 'type' => \Elementor\Controls_Manager::SWITCHER,
69 - 'label_on' => acym_translation('ACYM_YES'),
70 - 'label_off' => acym_translation('ACYM_NO'),
71 - 'default' => true,
72 - ]);
73 -
74 - $widget->end_controls_section();
75 - }
76 - }
77 -
78 - public function on_export($element)
79 - {
80 - unset(
81 - $element['acym_confirmUsers'], $element['acym_selectLists'], $element['acym_nameField'], $element['acym_emailField']
82 - );
83 - }
84 -
85 - public function run($record, $ajax_handler)
86 - {
87 - $settings = $record->get('form_settings');
88 - $data = $record->get('sent_data');
89 -
90 - if (empty($data[$settings['acym_emailField']])) {
91 - return;
92 - }
93 -
94 - $userClass = new UserClass();
95 - $newUser = new \stdClass();
96 -
97 - $newUser->name = $data[$settings['acym_nameField']];
98 - $newUser->email = $data[$settings['acym_emailField']];
99 - $newUser->creation_date = date('Y-m-d H:i:s');
100 - $newUser->confirmed = $settings['acym_confirmUsers'] === 'yes';
101 -
102 - $user = $userClass->getOneByEmail($newUser->email);
103 - if (!empty($user)) {
104 - $newUser->id = $user->id;
105 - }
106 -
107 - $config = acym_config();
108 - if ($config->get('require_confirmation', 1) == 1) {
109 - $userClass->forceConfAdmin = true;
110 - }
111 -
112 - $userId = $userClass->save($newUser);
113 -
114 - if (!empty($settings['acym_selectLists'])) {
115 - $userClass->subscribe($userId, $settings['acym_selectLists'], true, true);
116 - }
117 - }
118 -}