PluginProbe
RTMForm Builder / trunk
RTMForm Builder vtrunk
1.2.7 trunk 1.0.0 1.0.1 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6
romethemeform / plugin.php

plugin.php in RTMForm Builder trunk, at plugin.php

212 lines 11.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace RomethemeFormPlugin;
4
5 use RForm;
6 use RomeThemeForm;
7 use RomethemeForm\Autoloader;
8 use RomethemeForm\Form\Form;
9
10 class Plugin
11 {
12 public static function register_autoloader()
13 {
14 require_once \RomeThemeForm::plugin_dir() . '/autoloader.php';
15 Autoloader::run();
16 }
17
18 public static function load_romethemeform_form()
19 {
20 require_once \RomethemeForm::module_dir() . 'form/form.php';
21 new Form();
22 }
23
24 public static function register_widget($widgets_manager)
25 {
26 require_once(RomeThemeForm::widget_dir() . 'rtform-text.php');
27 require_once(RomeThemeForm::widget_dir() . 'rtform.php');
28 require_once(RomeThemeForm::widget_dir() . 'rform-button-submit.php');
29 require_once(RomeThemeForm::widget_dir() . 'rtform-email.php');
30 require_once(RomeThemeForm::widget_dir() . 'rtform-text-area.php');
31 require_once(RomeThemeForm::widget_dir() . 'rtform-date.php');
32 require_once(RomeThemeForm::widget_dir() . 'rtform-time.php');
33 require_once(RomeThemeForm::widget_dir() . 'rtform-radio-btn.php');
34 require_once(RomeThemeForm::widget_dir() . 'rform-select.php');
35 require_once(RomeThemeForm::widget_dir() . 'rform-checkbox.php');
36 require_once(RomeThemeForm::widget_dir() . 'rform-input-number.php');
37 require_once(RomeThemeForm::widget_dir() . 'rform-input-tel.php');
38 require_once(RomeThemeForm::widget_dir() . 'rtform-gdpr.php');
39 require_once(RomeThemeForm::widget_dir() . 'rform-recaptcha.php');
40 $widgets_manager->register(new RForm());
41
42 $activeWidgets = \RTMKit\Modules\Widgets\WidgetStorage::instance()->get_active_widgets("form");
43
44 if (is_array($activeWidgets)) {
45 foreach ($activeWidgets as $widget) {
46 $classname = $widget['class_name'];
47 $widgets_manager->register(new $classname());
48 }
49 }
50 }
51
52 public static function register_widget_styles()
53 {
54 wp_enqueue_style('rtform-text-style', \RomeThemeForm::widget_url() . 'assets/css/rtform_text.css', [], \RomethemeForm::rform_version());
55 wp_enqueue_style('rform-style', \RomeThemeForm::widget_url() . 'assets/css/rform.css', [], \RomethemeForm::rform_version());
56 wp_enqueue_style('spinner-style', \RomeThemeForm::widget_url() . 'assets/css/spinner-loading.css', [], \RomethemeForm::rform_version());
57 wp_enqueue_style('rform-btn-style', \RomeThemeForm::widget_url() . 'assets/css/rform-button.css', [], \RomethemeForm::rform_version());
58 wp_enqueue_style('rform-select-style', \RomeThemeForm::widget_url() . 'assets/css/rform-select.css', [], \RomethemeForm::rform_version());
59 wp_enqueue_style('rform-radiobutton-style', \RomeThemeForm::widget_url() . 'assets/css/rform-radiobutton.css', [], \RomethemeForm::rform_version());
60 wp_enqueue_style('rform-checkbox-style', \RomeThemeForm::widget_url() . 'assets/css/rform-checkbox.css', [], \RomethemeForm::rform_version());
61 wp_enqueue_style('rform-gdpr-style', \RomeThemeForm::widget_url() . 'assets/css/rform-gdpr.css', [], \RomethemeForm::rform_version());
62 wp_enqueue_style('intlTelInput', \RomeThemeForm::widget_url() . 'assets/css/intlTelInput.css', [], \RomethemeForm::rform_version());
63 wp_enqueue_style('rform-date-style', \RomeThemeForm::widget_url() . 'assets/css/rform-date.css', [], \RomethemeForm::rform_version());
64 wp_enqueue_style('rform-time-style', \RomeThemeForm::widget_url() . 'assets/css/rform-time.css', [], \RomethemeForm::rform_version());
65 wp_enqueue_style('rform-recaptcha-style', \RomeThemeForm::widget_url() . 'assets/css/recaptcha.css', [], \RomethemeForm::rform_version());
66 }
67
68 public static function register_widget_scripts()
69 {
70 $rform_nonce = wp_create_nonce('rform_entries_nonce');
71
72 if (get_option('rform_recaptcha_version', 'v2') === 'v3') {
73 $recaptcha_site_key_v3 = get_option('rform_recaptcha_site_key_v3', '');
74 if ($recaptcha_site_key_v3) {
75 $recaptcha_script_url = 'https://www.google.com/recaptcha/api.js?render=' . esc_attr($recaptcha_site_key_v3);
76 }
77 } else {
78 $recaptcha_script_url = 'https://www.google.com/recaptcha/api.js';
79 }
80
81 wp_enqueue_script('rtform-text-js', \RomeThemeForm::widget_url() . 'assets/js/rtform_text.js', ['jquery'], \RomeThemeForm::rform_version());
82 wp_enqueue_script('rform-select-js', \RomeThemeForm::widget_url() . 'assets/js/rform_select.js', ['jquery'], \RomeThemeForm::rform_version());
83 wp_enqueue_script('rform-phone-js', \RomeThemeForm::widget_url() . 'assets/js/rform_tel_input.js', ['jquery'], \RomeThemeForm::rform_version());
84 wp_enqueue_script('rform-gdpr-js', \RomeThemeForm::widget_url() . 'assets/js/rform-gdpr.js', ['jquery'], \RomeThemeForm::rform_version());
85 wp_enqueue_script('rform-recaptcha-script', \RomeThemeForm::widget_url() . 'assets/js/recaptcha.js', ['jquery'], \RomeThemeForm::rform_version());
86 wp_enqueue_script('rform-script', \RomeThemeForm::widget_url() . 'assets/js/rform.js', ['jquery'], \RomeThemeForm::rform_version());
87 wp_enqueue_script('google-recaptcha', $recaptcha_script_url , [], \RomeThemeForm::rform_version(), true);
88 wp_localize_script('rform-script', 'romethemeform_ajax_url', array(
89 'ajax_url' => admin_url('admin-ajax.php'),
90 'nonce' => $rform_nonce
91 ));
92 wp_enqueue_script('intl-tel-input', \RomeThemeForm::widget_url() . 'assets/js/intl_tel_input.min.js', ['jquery'], \RomeThemeForm::rform_version());
93 wp_localize_script('intl-tel-input', 'intl_tel_input_script', [
94 'url' => \RomeThemeForm::widget_url() . 'assets/js/intl_tel_input_utils.js'
95 ]);
96 }
97
98 public static function add_elementor_widget_categories($elements_manager)
99 {
100 $categories = [];
101 $categories['romethemeform_form_fields'] = [
102 'title' => 'RTMForm',
103 ];
104
105 $old_categories = $elements_manager->get_categories();
106 $categories = array_merge($categories, $old_categories);
107
108 $set_categories = function ($categories) {
109 $this->categories = $categories;
110 };
111
112 $set_categories->call($elements_manager, $categories);
113 }
114 public static function add_controls($controls_manager)
115 {
116 require_once(RomeThemeForm::controls_dir() . 'form_controls.php');
117 $controls_manager->register(new \RFormControls());
118 }
119
120 public static function enqueue_frontend()
121 {
122 wp_enqueue_style('rform-admin-style', RomeThemeForm::plugin_url() . 'assets/css/style.css', '', RomeThemeForm::rform_version());
123 }
124
125 public static function rform_notice_raw()
126 {
127 $btn1 = [
128 'default_class' => 'button',
129 'class' => 'button-primary',
130 'text' => esc_html__('Yes, I Deserve it', 'romethemeform'),
131 'url' => sanitize_url('https://wordpress.org/support/plugin/romethemeform/reviews/')
132 ];
133
134 $btn2 = [
135 'default_class' => 'button',
136 'class' => 'rform-button-link',
137 'target' => '_blank',
138 'text' => esc_html__('I Need Help', 'romethemeform'),
139 'url' => sanitize_url('https://rometheme.net/contact-us/')
140 ];
141 $message = sprintf(
142 '%1$s',
143 "Hey there! If you've been enjoying RomethemeForm for Elementor, we'd be grateful for a 5-star rating to help us improve and reach more users. We also welcome any feedback you have to help us better serve you and the RomethemeForm community."
144 );
145 $logo = \RomeThemeForm::plugin_url() . 'assets/images/rform.png';
146 ?>
147 <div id="rform-notices" class="notice rform-notice notice-info is-dismissible">
148 <img src="<?php echo esc_attr($logo) ?>" style="width:5rem;height:5rem;" alt="">
149 <div>
150 <div class="rform-notice-body">
151 <?php echo esc_html($message) ?>
152 </div>
153 <div class="rform-notice-footer">
154 <button type="button" class="button rform-deserve-btn <?php echo esc_attr($btn1['class']) ?> "><?php echo esc_html($btn1['text']) ?></button>
155 <a type="button" href="<?php echo esc_attr($btn2['url']) ?>" class="button <?php echo esc_attr($btn2['class']) ?>">
156 <svg fill="#2271b1" height="16px" width="16px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 485 485" xml:space="preserve">
157 <g>
158 <path d="M413.974,71.027C368.171,25.224,307.274,0,242.5,0S116.829,25.224,71.026,71.027C25.225,116.829,0,177.726,0,242.5
159 s25.225,125.671,71.026,171.473C116.829,459.776,177.726,485,242.5,485s125.671-25.224,171.474-71.027
160 C459.775,368.171,485,307.274,485,242.5S459.775,116.829,413.974,71.027z M242.5,347.5c-57.897,0-105-47.103-105-105
161 s47.103-105,105-105s105,47.103,105,105S300.397,347.5,242.5,347.5z M368.425,193.845l68.997-35.926
162 C448.719,183.853,455,212.455,455,242.5s-6.281,58.647-17.578,84.58l-68.997-35.926c5.855-15.103,9.075-31.509,9.075-48.655
163 S374.28,208.948,368.425,193.845z M423.528,131.332l-68.995,35.924c-9.773-14.504-22.285-27.016-36.789-36.789l35.924-68.995
164 C382.054,78.968,406.032,102.946,423.528,131.332z M327.08,47.578l-35.926,68.997c-15.103-5.855-31.509-9.075-48.654-9.075
165 s-33.552,3.22-48.654,9.075L157.92,47.578C183.854,36.281,212.455,30,242.5,30S301.146,36.281,327.08,47.578z M131.331,61.472
166 l35.924,68.995c-14.504,9.773-27.016,22.285-36.789,36.789l-68.995-35.924C78.968,102.946,102.946,78.968,131.331,61.472z
167 M47.578,157.92l68.997,35.926c-5.855,15.103-9.075,31.509-9.075,48.655s3.22,33.552,9.075,48.655L47.578,327.08
168 C36.281,301.147,30,272.545,30,242.5S36.281,183.853,47.578,157.92z M61.472,353.668l68.995-35.924
169 c9.773,14.504,22.285,27.016,36.789,36.789l-35.924,68.995C102.946,406.032,78.968,382.054,61.472,353.668z M157.92,437.422
170 l35.926-68.997c15.103,5.855,31.509,9.075,48.654,9.075s33.552-3.22,48.654-9.075l35.926,68.997
171 C301.146,448.719,272.545,455,242.5,455S183.854,448.719,157.92,437.422z M353.669,423.528l-35.924-68.995
172 c14.504-9.773,27.016-22.285,36.789-36.789l68.995,35.924C406.032,382.054,382.054,406.032,353.669,423.528z" />
173 </g>
174 </svg>
175 <?php echo esc_html($btn2['text']) ?>
176 </a>
177 </div>
178 </div>
179 </div>
180 <style>
181 .rform-notice {
182 display: flex !important;
183 flex-direction: row !important;
184 padding: .5rem;
185 gap: 1rem;
186 align-items: center;
187 }
188
189 .rform-notice-body {
190 margin-bottom: 0.8rem;
191 }
192
193 .rform-notice-footer {
194 display: flex;
195 flex-direction: row;
196 gap: .5rem;
197 }
198
199 .rform-button-link {
200 text-decoration: none !important;
201 border: none !important;
202 background-color: transparent !important;
203 display: flex !important;
204 align-items: center;
205 justify-content: center;
206 gap: .2rem;
207 }
208 </style>
209 <?php
210 }
211 }
212