PluginProbe
Form Maker by 10Web – Mobile-Friendly Drag & Drop Contact Form Builder / 1.15.47
Form Maker by 10Web – Mobile-Friendly Drag & Drop Contact Form Builder v1.15.47
1.15.47 1.15.46 1.15.45 1.15.44 1.15.43 1.13.45 1.13.46 1.13.47 1.13.48 1.13.49 1.13.5 1.13.50 1.13.51 1.13.52 1.13.53 1.13.54 1.13.55 1.13.56 1.13.57 1.13.58 1.13.59 1.13.60 1.13.7 1.13.8 1.13.9 All 351 releases
form-maker / form-maker.php

form-maker.php in Form Maker by 10Web – Mobile-Friendly Drag & Drop Contact Form Builder 1.15.47, at form-maker.php

1,865 lines 97.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Form Maker
4 * Plugin URI: https://10web.io/plugins/wordpress-form-maker/?utm_source=form_maker&utm_medium=free_plugin
5 * Description: This plugin is a modern and advanced tool for easy and fast creating of a WordPress Form. The backend interface is intuitive and user friendly which allows users far from scripting and programming to create WordPress Forms.
6 * Version: 1.15.47
7 * Author: 10Web Form Builder Team
8 * Author URI: https://10web.io/plugins/?utm_source=form_maker&utm_medium=free_plugin
9 * License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
10 */
11
12 defined('ABSPATH') || die('Access Denied');
13 #[\AllowDynamicProperties]
14 final class WDFM {
15 /**
16 * PLUGIN = 2 points to Contact Form Maker
17 */
18 const PLUGIN = 1;
19
20 /**
21 * The single instance of the class.
22 */
23 protected static $_instance = null;
24 public $abspath;
25 public $plugin_dir = '';
26 public $plugin_url = '';
27 public $front_urls = array();
28 public $main_file = '';
29 public $plugin_version = '1.15.47';
30 public $db_version = '2.15.47';
31 public $menu_postfix = '_fm';
32 public $plugin_postfix = '';
33 public $handle_prefix = 'fm';
34 public $slug = 'form-maker';
35 public $nicename = 'Form Maker';
36 public $menu_slug = '';
37 public $prefix = '';
38 public $nonce = 'nonce_fm';
39 public $fm_form_nonce = 'fm_form_nonce';
40 public $is_free = 1;
41 public $is_demo = false;
42 public $fm_settings = array();
43
44 /**
45 * Main WDFM Instance.
46 *
47 * Ensures only one instance is loaded or can be loaded.
48 *
49 * @static
50 * @return WDFM - Main instance.
51 */
52 public static function instance() {
53 if ( is_null( self::$_instance ) ) {
54 self::$_instance = new self();
55 }
56 return self::$_instance;
57 }
58
59 public function __construct() {
60 $this->define_constants();
61 require_once( $this->plugin_dir . '/framework/WDW_FM_Library.php' );
62 if ( get_option( 'wd_form_maker_version', FALSE ) ) {
63 require_once( $this->plugin_dir . '/framework/Cookie.php' );
64 }
65 if ( is_admin() ) {
66 require_once( wp_normalize_path( $this->plugin_dir . '/admin/controllers/controller.php' ) );
67 require_once( wp_normalize_path( $this->plugin_dir . '/admin/models/model.php' ) );
68 require_once( wp_normalize_path( $this->plugin_dir . '/admin/views/view.php' ) );
69 }
70 $this->add_actions();
71 }
72
73 /**
74 * Define Constants.
75 */
76 private function define_constants() {
77 $this->abspath = $this->fm_get_abspath();
78 $this->plugin_dir = WP_PLUGIN_DIR . "/" . plugin_basename(dirname(__FILE__));
79 $this->plugin_url = plugins_url(plugin_basename(dirname(__FILE__)));
80 $this->front_urls = $this->get_front_urls();
81 $this->main_file = plugin_basename(__FILE__);
82 if ( $this->is_free == 2 ) {
83 $this->menu_postfix = '_fmc';
84 $this->plugin_postfix = $this->menu_postfix;
85 $this->handle_prefix = 'fmc';
86 $this->slug = 'contact-form-maker';
87 $this->nicename = 'Contact Form';
88 }
89
90 $this->menu_slug = 'manage' . $this->menu_postfix;
91 $this->prefix = 'form_maker' . $this->plugin_postfix;
92 $this->fm_settings = get_option( $this->handle_prefix . '_settings' );
93 if ( empty($this->fm_settings['fm_advanced_layout']) ) {
94 $this->fm_settings['fm_advanced_layout'] = 0;
95 }
96 if ( empty($this->fm_settings['fm_antispam_referer']) ) {
97 $this->fm_settings['fm_antispam_referer'] = 0;
98 }
99 if ( empty($this->fm_settings['fm_antispam_bot_validation']) ) {
100 $this->fm_settings['fm_antispam_bot_validation'] = 0;
101 }
102 if ( empty($this->fm_settings['fm_antispam_nonce']) ) {
103 $this->fm_settings['fm_antispam_nonce'] = 0;
104 }
105 if ( empty($this->fm_settings['fm_block_ip_exceeded_limit']) ) {
106 $this->fm_settings['fm_block_ip_exceeded_limit'] = 0;
107 }
108 if ( empty($this->fm_settings['fm_developer_mode']) ) {
109 $this->fm_settings['fm_developer_mode'] = 0;
110 }
111 if ( empty($this->fm_settings['fm_file_read']) ) {
112 $this->fm_settings['fm_file_read'] = 0;
113 }
114 if ( empty($this->fm_settings['fm_ajax_submit']) ) {
115 $this->fm_settings['fm_ajax_submit'] = 0;
116 }
117 }
118
119 /**
120 * Get ABSPATH from WP_CONTENT_DIR.
121 *
122 * @return string
123 */
124 public static function fm_get_abspath() {
125 $dirpath = defined( 'WP_CONTENT_DIR' ) ? WP_CONTENT_DIR : ABSPATH;
126 $array = explode( "wp-content", $dirpath );
127 if( isset( $array[0] ) && $array[0] != "" ) {
128 return $array[0];
129 }
130 return ABSPATH;
131 }
132
133 /**
134 * Add actions.
135 */
136 private function add_actions() {
137 add_action('init', array($this, 'init'), 9);
138 add_action('admin_menu', array( $this, 'form_maker_options_panel' ) );
139
140 add_action('wp_ajax_manage' . $this->menu_postfix, array($this, 'form_maker_ajax')); //Post/page search on display options pages.
141 add_action('wp_ajax_get_stats' . $this->plugin_postfix, array($this, 'form_maker')); //Show statistics
142 add_action('wp_ajax_generete_csv' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Export csv.
143 add_action('wp_ajax_generete_xml' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Export xml.
144 add_action('wp_ajax_formmakerwdcaptcha' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Generete captcha image and save it code in session.
145 add_action('wp_ajax_nopriv_formmakerwdcaptcha' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Generete captcha image and save it code in session for all users.
146 add_action('wp_ajax_formmakerwdmathcaptcha' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Generete math captcha image and save it code in session.
147 add_action('wp_ajax_nopriv_formmakerwdmathcaptcha' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Generete math captcha image and save it code in session for all users.
148 add_action('wp_ajax_product_option' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Open product options on add paypal field.
149 add_action('wp_ajax_FormMakerEditCountryinPopup' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Open country list.
150 add_action('wp_ajax_FormMakerMapEditinPopup' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Open map in submissions.
151 add_action('wp_ajax_FormMakerIpinfoinPopup' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Open ip in submissions.
152 add_action('wp_ajax_show_matrix' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Edit matrix in submissions.
153 add_action('wp_ajax_FormMakerSubmits' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Open submissions in submissions.
154
155 if ( !$this->is_demo ) {
156 add_action('wp_ajax_FormMakerSQLMapping' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Add/Edit SQLMaping from form options.
157 add_action('wp_ajax_select_data_from_db' . $this->plugin_postfix, array( $this, 'form_maker_ajax' )); // select data from db.
158 }
159
160 add_action('wp_ajax_manage' . $this->plugin_postfix, array($this, 'form_maker_ajax')); //Show statistics
161
162 if ( !$this->is_free ) {
163 add_action('wp_ajax_paypal_info', array($this, 'form_maker_ajax')); // Paypal info in submissions page.
164 add_action('wp_ajax_checkpaypal', array($this, 'form_maker_ajax')); // Notify url from Paypal Sandbox.
165 add_action('wp_ajax_nopriv_checkpaypal', array($this, 'form_maker_ajax')); // Notify url from Paypal Sandbox for all users.
166 add_action('wp_ajax_get_frontend_stats', array($this, 'form_maker_ajax_frontend')); //Show statistics frontend
167 add_action('wp_ajax_nopriv_get_frontend_stats', array($this, 'form_maker_ajax_frontend')); //Show statistics frontend
168 add_action('wp_ajax_frontend_show_map', array($this, 'form_maker_ajax_frontend')); //Show map frontend
169 add_action('wp_ajax_nopriv_frontend_show_map', array($this, 'form_maker_ajax_frontend')); //Show map frontend
170 add_action('wp_ajax_frontend_show_matrix', array($this, 'form_maker_ajax_frontend')); //Show matrix frontend
171 add_action('wp_ajax_nopriv_frontend_show_matrix', array($this, 'form_maker_ajax_frontend')); //Show matrix frontend
172 add_action('wp_ajax_frontend_paypal_info', array($this, 'form_maker_ajax_frontend')); //Show paypal info frontend
173 add_action('wp_ajax_nopriv_frontend_paypal_info', array($this, 'form_maker_ajax_frontend')); //Show paypal info frontend
174 add_action('wp_ajax_frontend_generate_csv', array($this, 'form_maker_ajax_frontend')); //generate csv frontend
175 add_action('wp_ajax_nopriv_frontend_generate_csv', array($this, 'form_maker_ajax_frontend')); //generate csv frontend
176 add_action('wp_ajax_frontend_generate_xml', array($this, 'form_maker_ajax_frontend')); //generate xml frontend
177 add_action('wp_ajax_nopriv_frontend_generate_xml', array($this, 'form_maker_ajax_frontend')); //generate xml frontend
178 }
179 add_action('wp_ajax_fm_reload_input', array($this, 'form_maker_ajax_frontend'));
180 add_action('wp_ajax_nopriv_fm_reload_input', array($this, 'form_maker_ajax_frontend'));
181 add_action('wp_ajax_fm_submit_form', array($this, 'FM_front_end_main')); //Show statistics
182 add_action( 'wp_ajax_nopriv_fm_submit_form', array($this, 'FM_front_end_main') );
183 // Add media button to WP editor.
184 add_action('wp_ajax_FMShortocde' . $this->plugin_postfix, array($this, 'form_maker_ajax'));
185 add_action('media_buttons', array($this, 'media_button'));
186
187 add_action('wp_ajax_fm_init_cookies', array($this, 'FM_front_end_init_cookies'));
188 add_action( 'wp_ajax_nopriv_fm_init_cookies', array($this, 'FM_front_end_init_cookies') );
189
190 add_action('admin_head', array($this, 'form_maker_admin_ajax'));//js variables for admin.
191
192 // Form maker shortcodes.
193 if ( !is_admin() ) {
194 add_shortcode('FormPreview' . $this->plugin_postfix, array($this, 'fm_form_preview_shortcode'));
195 if ($this->is_free != 2) {
196 add_shortcode('Form', array($this, 'fm_shortcode'));
197 }
198 if (!($this->is_free == 1)) {
199 add_shortcode('contact_form', array($this, 'fm_shortcode'));
200 add_shortcode('wd_contact_form', array($this, 'fm_shortcode'));
201 }
202 add_shortcode('email_verification' . $this->plugin_postfix, array($this, 'fm_email_verification_shortcode'));
203 }
204 // Action to display not emedded type forms.
205 global $pagenow;
206 if (!is_admin() || !in_array($pagenow, array('wp-login.php', 'wp-register.php'))) {
207 add_action('wp_footer', array($this, 'FM_front_end_main'));
208 }
209
210 // Form Maker Widget.
211 if (class_exists('WP_Widget')) {
212 add_action('widgets_init', array($this, 'register_widgets'));
213 }
214
215 // Plugin activation.
216 register_activation_hook(__FILE__, array($this, 'global_activate'));
217 // Plugin deactivate.
218 register_deactivation_hook( __FILE__, array($this, 'global_deactivate'));
219 add_action('wpmu_new_blog', array($this, 'new_blog_added'), 10, 6);
220
221 if ( (!isset($_GET['action']) || $_GET['action'] != 'deactivate')
222 && (!isset($_GET['page']) || $_GET['page'] != 'uninstall' . $this->menu_postfix) ) {
223 add_action('admin_init', array($this, 'form_maker_activate'));
224 }
225
226 // Register scripts/styles.
227 add_action('wp_enqueue_scripts', array($this, 'register_frontend_scripts'));
228 add_action('admin_enqueue_scripts', array($this, 'register_admin_scripts'));
229
230 // Set per_page option for submissions.
231 add_filter('set-screen-option', array($this, 'set_option_submissions'), 10, 3);
232
233 // Check extensions versions.
234 if ( $this->is_free != 2 && isset( $_GET[ 'page' ] ) && strpos( esc_html( $_GET[ 'page' ] ), '_' . $this->handle_prefix ) !== FALSE ) {
235 add_action('admin_notices', array($this, 'fm_check_addons_compatibility'));
236 }
237
238 add_action('plugins_loaded', array($this, 'plugins_loaded'), 9);
239
240 add_filter('wpseo_whitelist_permalink_vars', array($this, 'add_query_vars_seo'));
241
242 // Enqueue block editor assets for Gutenberg.
243 add_filter('tw_get_block_editor_assets', array($this, 'register_block_editor_assets'));
244 add_filter('tw_get_plugin_blocks', array($this, 'register_plugin_block'));
245 add_action( 'enqueue_block_editor_assets', array($this, 'enqueue_block_editor_assets') );
246
247 // Privacy policy.
248 add_action( 'admin_init', array($this, 'add_privacy_policy_content') );
249
250 // Personal data export.
251 add_filter( 'wp_privacy_personal_data_exporters', array($this, 'register_privacy_personal_data_exporter') );
252 // Personal data erase.
253 add_filter( 'wp_privacy_personal_data_erasers', array($this, 'register_privacy_personal_data_eraser') );
254
255 // Register widget for Elementor builder.
256 add_action('elementor/widgets/widgets_registered', array($this, 'register_elementor_widget'));
257 // Register 10Web category for Elementor widget if 10Web builder doesn't installed.
258 add_action('elementor/elements/categories_registered', array($this, 'register_widget_category'), 1, 1);
259 //fires after elementor editor styles and scripts are enqueued.
260 add_action('elementor/editor/after_enqueue_styles', array($this, 'enqueue_editor_styles'), 11);
261 add_action('elementor/editor/after_enqueue_scripts', array($this, 'enqueue_elementor_widget_scripts'));
262
263 // Divi frontend builder assets.
264 add_action('et_fb_enqueue_assets', array($this, 'enqueue_divi_bulder_assets'));
265 add_action('et_fb_enqueue_assets', array($this, 'form_maker_admin_ajax'));
266 add_action('fm_admin_container_ready', array($this, 'check_db_full_privileged'), 99);
267 add_action( 'wp_ajax_dismiss_db_full_privileged_notice', array($this, 'dismiss_db_full_privileged_notice_callback') );
268 if ( $this->is_free == 1 ) {
269 /* Add wordpress.org support custom link in plugin page */
270 add_filter('plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'add_ask_question_links' ));
271 }
272 if (!$this->is_free) {
273 add_action('rest_api_init', array($this,'register_endpoint_for_stripe_events'));
274 }
275 }
276
277 /* Init cookies and get response new key for fm_empty_field_validation which js added to form */
278 public function FM_front_end_init_cookies() {
279 if ( get_option('wd_form_maker_version', FALSE) ) {
280 if ( !class_exists('Cookie_fm') ) {
281 require_once(WDFMInstance(self::PLUGIN)->plugin_dir . '/framework/Cookie.php');
282 }
283 $form_ids = WDW_FM_Library::get('form_ids', '');
284 if( empty($form_ids) || gettype($form_ids) != 'array' ) {
285 die();
286 }
287 new Cookie_fm();
288 $new_values = array();
289 foreach ( $form_ids as $id ) {
290 $value = md5('uniqid(rand(), TRUE)');
291 $new_values[] = array( 'form_id' => $id, 'field_validation_value' => $value );
292 Cookie_fm::saveCookieValueByKey( $id, 'fm_empty_field_validation', $value );
293 }
294 echo json_encode($new_values);
295 die();
296 }
297 }
298
299 public function check_db_full_privileged() {
300 $version = substr_replace(get_option("wd_form_maker_version"), '1.', 0, 2);
301 if ( get_option('fm_db_full_privileged', FALSE ) === '0' ) {
302 require_once $this->plugin_dir . "/form_maker_update.php";
303 if ( $this->is_free == 2 ) {
304 WDCFMUpdate::form_maker_update($version);
305 }
306 else {
307 WDFMUpdate::form_maker_update($version);
308 }
309 }
310 if ( get_option('fm_db_full_privileged', FALSE ) === '0' ) {
311 if ( get_option('fm_db_full_privileged_notice', FALSE ) === '1' ) {
312 echo WDW_FM_Library(self::PLUGIN)->message_id(17, '', 'error', array(WDW_FM_Library(self::PLUGIN),'notice_dismiss_button'));
313 } else if ( get_option('fm_db_full_privileged_notice', FALSE ) == '2' ) {
314 echo WDW_FM_Library(self::PLUGIN)->message_id(18, '', 'error', array(WDW_FM_Library(self::PLUGIN),'notice_dismiss_button'));
315 }
316 }
317 }
318
319 function dismiss_db_full_privileged_notice_callback() {
320 $db_full_privileged_notice = intval( WDW_FM_Library(self::PLUGIN)->get('db_full_privileged_notice') );
321 update_option('fm_db_full_privileged_notice', $db_full_privileged_notice);
322 wp_die();
323 }
324
325
326 public function enqueue_divi_bulder_assets() {
327 wp_enqueue_style('thickbox');
328 wp_enqueue_script('thickbox');
329 }
330
331 /**
332 * Add plugin action links.
333 *
334 * Add a link to the settings page on the plugins.php page.
335 *
336 * @since 1.0.0
337 *
338 * @param array $links List of existing plugin action links.
339 * @return array List of modified plugin action links.
340 */
341 function add_ask_question_links ( $links ) {
342 $url = 'https://wordpress.org/support/plugin/' . (WDFMInstance(self::PLUGIN)->is_free == 2 ? 'contact-form-maker' : 'form-maker') . '/#new-post';
343 $fm_ask_question_link = array('<a href="' . $url . '" target="_blank">' . __('Help', $this->prefix) . '</a>');
344 return array_merge( $links, $fm_ask_question_link );
345 }
346
347 public function enqueue_editor_styles() {
348 wp_enqueue_style($this->handle_prefix . '-icons', $this->plugin_url . '/css/fonts.css', array(), '1.0.1');
349 }
350
351 public function enqueue_elementor_widget_scripts(){
352 wp_enqueue_script($this->handle_prefix . 'elementor_widget_js', $this->plugin_url.'/js/fm_elementor_widget.js', array('jquery'));
353 }
354
355 /**
356 * Register widget for Elementor builder.
357 */
358 public function register_elementor_widget() {
359 if ( defined('ELEMENTOR_PATH') && class_exists('Elementor\Widget_Base') ) {
360 require_once ($this->plugin_dir . '/admin/controllers/elementorWidget.php');
361 }
362 }
363
364 /**
365 * Register 10Web category for Elementor widget if 10Web builder doesn't installed.
366 *
367 * @param $elements_manager
368 */
369 public function register_widget_category( $elements_manager ) {
370 $elements_manager->add_category('tenweb-plugins-widgets', array(
371 'title' => __('10WEB Plugins', 'tenweb-builder'),
372 'icon' => 'fa fa-plug',
373 ));
374 }
375
376 function add_privacy_policy_content() {
377 if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) {
378 return;
379 }
380
381 $content = __( 'When you leave a comment on this site, we send your name, email
382 address, IP address and comment text to example.com. Example.com does
383 not retain your personal data.', $this->prefix );
384
385 wp_add_privacy_policy_content(
386 $this->nicename,
387 wp_kses_post( wpautop( $content, false ) )
388 );
389 }
390
391 public function register_privacy_personal_data_exporter( $exporters ) {
392 $exporters[ $this->slug ] = array(
393 'exporter_friendly_name' => $this->nicename,
394 'callback' => array( WDW_FM_Library(self::PLUGIN), 'privacy_personal_data_export' ),
395 );
396 return $exporters;
397 }
398
399 public function register_privacy_personal_data_eraser( $erasers ) {
400 $erasers[ $this->slug ] = array(
401 'eraser_friendly_name' => $this->nicename,
402 'callback' => array( WDW_FM_Library(self::PLUGIN), 'privacy_personal_data_erase' ),
403 );
404 return $erasers;
405 }
406
407 public function register_block_editor_assets($assets) {
408 $version = '2.0.3';
409 $js_path = $this->plugin_url . '/js/tw-gb/block.js';
410 $css_path = $this->plugin_url . '/css/tw-gb/block.css';
411 if (!isset($assets['version']) || version_compare($assets['version'], $version) === -1) {
412 $assets['version'] = $version;
413 $assets['js_path'] = $js_path;
414 $assets['css_path'] = $css_path;
415 }
416 return $assets;
417 }
418
419 public function register_plugin_block($blocks) {
420 if ($this->is_free == 2) {
421 $key = 'tw/contact-form-maker';
422 $key_submissions = 'tw/cfm-submissions';
423 }
424 else {
425 $key = 'tw/form-maker';
426 $key_submissions = 'tw/fm-submissions';
427 }
428 $fm_nonce = wp_create_nonce('fm_ajax_nonce');
429 $plugin_name = $this->nicename;
430 $plugin_name_submissions = __('Submissions', $this->prefix);
431 $icon_url = $this->plugin_url . '/images/tw-gb/icon_colored.svg';
432 $icon_svg = $this->plugin_url . '/images/tw-gb/icon.svg';
433 $url = add_query_arg(array('action' => 'FMShortocde' . $this->plugin_postfix, 'task' => 'submissions', 'nonce' => $fm_nonce), admin_url('admin-ajax.php'));
434 $data = WDW_FM_Library(self::PLUGIN)->get_shortcode_data();
435 $blocks[$key] = array(
436 'title' => $plugin_name,
437 'titleSelect' => sprintf(__('Select %s', $this->prefix), $plugin_name),
438 'iconUrl' => $icon_url,
439 'iconSvg' => array('width' => 20, 'height' => 20, 'src' => $icon_svg),
440 'isPopup' => false,
441 'data' => $data,
442 );
443 $blocks[$key_submissions] = array(
444 'title' => $plugin_name_submissions,
445 'titleSelect' => sprintf(__('Select %s', $this->prefix), $plugin_name),
446 'iconUrl' => $icon_url,
447 'iconSvg' => array('width' => 20, 'height' => 20, 'src' => $icon_svg),
448 'isPopup' => true,
449 'containerClass' => 'tw-container-wrap-520-400',
450 'data' => array('shortcodeUrl' => $url),
451 );
452 return $blocks;
453 }
454
455 public function enqueue_block_editor_assets() {
456 // Remove previously registered or enqueued versions
457 $wp_scripts = wp_scripts();
458 foreach ($wp_scripts->registered as $key => $value) {
459 // Check for an older versions with prefix.
460 if (strpos($key, 'tw-gb-block') > 0) {
461 wp_deregister_script( $key );
462 wp_deregister_style( $key );
463 }
464 }
465 // Get plugin blocks from all 10Web plugins.
466 $blocks = apply_filters('tw_get_plugin_blocks', array());
467 // Get the last version from all 10Web plugins.
468 $assets = apply_filters('tw_get_block_editor_assets', array());
469 // Not performing unregister or unenqueue as in old versions all are with prefixes.
470 wp_enqueue_script('tw-gb-block', $assets['js_path'], array( 'wp-blocks', 'wp-element' ), $assets['version']);
471 wp_localize_script('tw-gb-block', 'tw_obj_translate', array(
472 'nothing_selected' => __('Nothing selected.', $this->prefix),
473 'empty_item' => __('- Select -', $this->prefix),
474 'blocks' => json_encode($blocks)
475 ));
476 wp_enqueue_style('tw-gb-block', $assets['css_path'], array( 'wp-edit-blocks' ), $assets['version']);
477 }
478
479 /**
480 * Wordpress init actions.
481 */
482 public function init() {
483 ob_start();
484 $this->fm_overview();
485
486 // Register fmemailverification post type
487 $this->register_fmemailverification_cpt();
488
489 // Register fmformpreview post type
490 $this->register_form_preview_cpt();
491 }
492
493 /**
494 * Plugins loaded actions.
495 */
496 public function plugins_loaded() {
497 // Languages localization.
498 load_plugin_textdomain($this->prefix, FALSE, basename(dirname(__FILE__)) . '/languages');
499
500 if ($this->is_free != 2 && !function_exists('WDFM')) {
501 require_once($this->plugin_dir . '/WDFM.php');
502 }
503
504 // Initialize extensions.
505 if ($this->is_free != 2) {
506 do_action('fm_init_addons');
507 }
508 // Prevent adding shortcode conflict with some builders.
509 $this->before_shortcode_add_builder_editor();
510 }
511
512 /**
513 * Plugin menu.
514 */
515 public function form_maker_options_panel() {
516 $parent_slug = $this->menu_slug;
517 add_menu_page($this->nicename, $this->nicename, 'manage_options', $this->menu_slug, array( $this, 'form_maker' ), $this->plugin_url . '/images/FormMakerLogo-16.png');
518 add_submenu_page($parent_slug, __('Forms', $this->prefix), __('Forms', $this->prefix), 'manage_options', $this->menu_slug, array($this, 'form_maker'));
519 $submissions_page = add_submenu_page($parent_slug, __('Submissions', $this->prefix), __('Submissions', $this->prefix), 'manage_options', 'submissions' . $this->menu_postfix, array($this, 'form_maker'));
520 add_action('load-' . $submissions_page, array($this, 'submissions_per_page'));
521
522 add_submenu_page('', __('Blocked IPs', $this->prefix), __('Blocked IPs', $this->prefix), 'manage_options', 'blocked_ips' . $this->menu_postfix, array($this, 'form_maker'));
523 add_submenu_page($parent_slug, __('Themes', $this->prefix), __('Themes', $this->prefix), 'manage_options', 'themes' . $this->menu_postfix, array($this, 'form_maker'));
524 add_submenu_page($parent_slug, __('Options', $this->prefix), __('Options', $this->prefix), 'manage_options', 'options' . $this->menu_postfix, array($this, 'form_maker'));
525 add_submenu_page('', __('Uninstall', $this->prefix), __('Uninstall', $this->prefix), 'manage_options', 'uninstall' . $this->menu_postfix, array($this, 'form_maker'));
526
527 if ( current_user_can('manage_options') && $this->is_free ) {
528 /* Custom link to wordpress.org*/
529 global $submenu;
530 $url = 'https://wordpress.org/support/plugin/' . (WDFMInstance(self::PLUGIN)->is_free == 2 ? 'contact-form-maker' : 'form-maker') . '/#new-post';
531 $submenu[$parent_slug][] = array(
532 '<div id="fm_ask_question">' . __('Ask a question', $this->prefix) . '</div>',
533 'manage_options',
534 $url
535 );
536 }
537 }
538
539 /**
540 * Set front plugin url.
541 *
542 * return string $plugin_url
543 */
544 private function set_front_plugin_url() {
545 $plugin_url = plugins_url(plugin_basename(dirname(__FILE__)));
546
547 return $plugin_url;
548 }
549
550 /**
551 * Set front upload url.
552 *
553 * return string $upload_url
554 */
555 private function set_front_upload_url() {
556 $wp_upload_dir = wp_upload_dir();
557 $upload_url = $wp_upload_dir['baseurl'];
558 $http = 'http://';
559 $https = 'https://';
560 if ( (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) || strpos(get_option('home'), $https) > -1 ) {
561 $upload_url = str_replace($http, $https, $wp_upload_dir['baseurl']);
562 }
563
564 return $upload_url;
565 }
566
567 /**
568 * Get front urls.
569 *
570 * return array $urls
571 */
572 public function get_front_urls() {
573 $urls = array();
574 $urls['plugin_url'] = $this->set_front_plugin_url();
575 $urls['upload_url'] = $this->set_front_upload_url();
576
577 return $urls;
578 }
579
580 /**
581 * Add per_page screen option for submissions page.
582 */
583 function submissions_per_page() {
584 $option = 'per_page';
585 $args_rates = array(
586 'label' => __('Number of items per page:', $this->prefix),
587 'default' => 20,
588 'option' => 'fm_submissions_per_page'
589 );
590 add_screen_option( $option, $args_rates );
591 }
592
593 /**
594 * Set per_page option for submissions page.
595 *
596 * @param $status
597 * @param $option
598 * @param $value
599 * @return mixed
600 */
601 function set_option_submissions($status, $option, $value) {
602 if ( 'fm_submissions_per_page' == $option ) return $value;
603 return $status;
604 }
605
606 /**
607 * Output for admin pages.
608 */
609 public function form_maker() {
610 if (function_exists('current_user_can')) {
611 if (!current_user_can('manage_options')) {
612 die('Access Denied');
613 }
614 }
615 else {
616 die('Access Denied');
617 }
618 $page = WDW_FM_Library(self::PLUGIN)->get('page');
619 if (($page != '') && (($page == 'manage' . $this->menu_postfix) || ($page == 'options' . $this->menu_postfix) || ($page == 'submissions' . $this->menu_postfix) || ($page == 'blocked_ips' . $this->menu_postfix) || ($page == 'themes' . $this->menu_postfix) || ($page == 'uninstall' . $this->menu_postfix))) {
620
621 $page = ucfirst(substr($page, 0, strlen($page) - strlen($this->menu_postfix)));
622 echo '<div id="fm_loading"></div>';
623 echo '<div id="fm_admin_container" class="fm-form-container" style="display: none;">';
624 do_action( 'fm_admin_container_ready' );
625 try {
626 require_once ($this->plugin_dir . '/admin/controllers/' . $page . '_fm.php');
627 $controller_class = 'FMController' . $page . $this->menu_postfix;
628 $controller = new $controller_class();
629 $controller->execute();
630 } catch (Exception $e) {
631 ob_start();
632 debug_print_backtrace();
633 error_log(ob_get_clean());
634 }
635 echo '</div>';
636 }
637 }
638
639 /**
640 * Register widgets.
641 */
642 public function register_widgets() {
643 require_once($this->plugin_dir . '/admin/controllers/Widget.php');
644 register_widget('FMControllerWidget' . $this->plugin_postfix);
645 }
646
647 /**
648 * Register Admin styles/scripts.
649 */
650 public function register_admin_scripts() {
651 $current_screen = get_current_screen();
652 if ( $this->is_free && !empty($current_screen->id) && $current_screen->id == "toplevel_page_fm_subscribe" ) {
653 wp_enqueue_style($this->handle_prefix . '_subscribe', $this->plugin_url . '/css/fm_subscribe.css', array(), $this->plugin_version);
654 }
655 $fm_settings = $this->fm_settings;
656 // Admin styles.
657 wp_register_style($this->handle_prefix . '-tables', $this->plugin_url . '/css/form_maker_tables.css', array(), $this->plugin_version);
658 wp_register_style($this->handle_prefix . '-phone_field_css', $this->plugin_url . '/css/intlTelInput.min.css', array(), '17.0.13');
659 wp_register_style($this->handle_prefix . '-jquery-ui', $this->plugin_url . '/css/jquery-ui.custom.css', array(), $this->plugin_version);
660 wp_register_style($this->handle_prefix . '-codemirror', $this->plugin_url . '/css/codemirror.min.css', array(), '5.63.0');
661 wp_register_style($this->handle_prefix . '-layout', $this->plugin_url . '/css/form_maker_layout.css', array(), $this->plugin_version);
662 wp_register_style($this->handle_prefix . '-bootstrap', $this->plugin_url . '/css/fm-bootstrap.css', array(), $this->plugin_version);
663 wp_register_style($this->handle_prefix . '-colorpicker', $this->plugin_url . '/css/spectrum.min.css', array(), '1.8.1');
664 // Roboto font for top bar.
665 wp_register_style($this->handle_prefix . '-roboto', 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap');
666
667 // Admin scripts.
668 $localize_key_all = $this->handle_prefix . '-admin';
669 $localize_key_manage = $this->handle_prefix . '-manage';
670 $localize_key_add_fields = $this->handle_prefix . '-add-fields';
671 $localize_key_formmaker_div = $this->handle_prefix . '-formmaker_div';
672
673 if (!$fm_settings['fm_developer_mode']) {
674 $localize_key_all = $this->handle_prefix . '-scripts';
675 if (WDW_FM_Library(self::PLUGIN)->get('page') == 'submissions_' . $this->handle_prefix) {
676 $localize_key_all = $this->handle_prefix . '-submission';
677 }
678 if (WDW_FM_Library(self::PLUGIN)->get('page') == 'manage_' . $this->handle_prefix) {
679 $localize_key_all = $this->handle_prefix . '-manage';
680 }
681 $localize_key_manage .= '-edit';
682 $localize_key_add_fields = $localize_key_manage;
683 $localize_key_formmaker_div = $localize_key_manage;
684 wp_register_style($this->handle_prefix . '-styles', $this->plugin_url . '/css/fm-styles.min.css', array(), $this->plugin_version);
685 wp_register_script($this->handle_prefix . '-scripts', $this->plugin_url . '/js/fm-scripts.min.js', array(), $this->plugin_version);
686
687 wp_register_style($this->handle_prefix . '-manage', $this->plugin_url . '/css/manage-styles.min.css', array(), $this->plugin_version);
688 wp_register_script($this->handle_prefix . '-manage', $this->plugin_url . '/js/manage-scripts.min.js', array(), $this->plugin_version);
689
690 wp_register_style($this->handle_prefix . '-manage-edit', $this->plugin_url . '/css/manage-edit-styles.min.css', array(), $this->plugin_version);
691 wp_register_script($this->handle_prefix . '-manage-edit', $this->plugin_url . '/js/manage-edit-scripts.min.js', array(), $this->plugin_version);
692
693 wp_register_style($this->handle_prefix . '-submission', $this->plugin_url . '/css/submission-styles.min.css', array(), $this->plugin_version);
694 wp_register_script($this->handle_prefix . '-submission', $this->plugin_url . '/js/submission-scripts.min.js', array(), $this->plugin_version);
695
696 wp_register_style($this->handle_prefix . '-theme-edit', $this->plugin_url . '/css/theme-edit-styles.min.css', array(), $this->plugin_version);
697 wp_register_script($this->handle_prefix . '-theme-edit', $this->plugin_url . '/js/theme-edit-scripts.min.js', array(), $this->plugin_version);
698 }
699
700 $google_map_key = !empty($fm_settings['map_key']) ? '&key=' . $fm_settings['map_key'] : '';
701 wp_register_script('google-maps', 'https://maps.google.com/maps/api/js?v=3.exp' . $google_map_key);
702 wp_register_script($this->handle_prefix . '-gmap_form', $this->plugin_url . '/js/if_gmap_back_end.js', array(), $this->plugin_version);
703
704 wp_register_script($this->handle_prefix . '-signaturepad', $this->plugin_url . '/js/jquery.signaturepad.min.js', array(), '2.5.2');
705 wp_register_script($this->handle_prefix . '-phone_field', $this->plugin_url . '/js/intlTelInput.min.js', array(), '17.0.13');
706
707 // For drag and drop on mobiles.
708 wp_register_script($this->handle_prefix . '_jquery.ui.touch-punch.min', $this->plugin_url . '/js/jquery.ui.touch-punch.min.js', array('jquery'), '0.2.3');
709
710 wp_register_script($this->handle_prefix . '-admin', $this->plugin_url . '/js/form_maker_admin.js', array(), $this->plugin_version);
711 wp_register_script($localize_key_manage, $this->plugin_url . '/js/form_maker_manage.js', array(), $this->plugin_version);
712 wp_register_script($this->handle_prefix . '-manage-edit', $this->plugin_url . '/js/form_maker_manage_edit.js', array(), $this->plugin_version);
713 wp_register_script($localize_key_formmaker_div, $this->plugin_url . '/js/formmaker_div.js', array(), $this->plugin_version);
714 wp_register_script($this->handle_prefix . '-form-options', $this->plugin_url . '/js/form_maker_form_options.js', array(), $this->plugin_version);
715 wp_register_script($this->handle_prefix . '-form-advanced-layout', $this->plugin_url . '/js/form_maker_form_advanced_layout.js', array(), $this->plugin_version);
716 wp_register_script($localize_key_add_fields, $this->plugin_url . '/js/add_field.js', array($this->handle_prefix . '-formmaker_div'), $this->plugin_version);
717
718 wp_localize_script($localize_key_manage, 'form_maker_manage', array(
719 'add_new_field' => __('Add Field', $this->prefix),
720 'add_column' => __('Add Column', $this->prefix),
721 'required_field' => __('Field is required.', $this->prefix),
722 'not_valid_value' => __('Enter a valid value.', $this->prefix),
723 'not_valid_email' => __('Enter a valid email address.', $this->prefix),
724 'succeeded' => __('Succeeded', $this->prefix),
725 'failed' => __('Failed', $this->prefix),
726 ));
727
728 wp_localize_script($localize_key_all, 'form_maker', array(
729 'countries' => WDW_FM_Library(self::PLUGIN)->get_countries(),
730 'delete_confirmation' => __('Do you want to delete selected items?', $this->prefix),
731 'select_at_least_one_item' => __('You must select at least one item.', $this->prefix),
732 'add_placeholder' => __('Add placeholder', $this->prefix),
733 ));
734
735 wp_localize_script($localize_key_all, 'form_maker_stripe_statuses', array(
736 'succeeded' => __( 'Succeeded', $this->prefix ),
737 'already_succeeded' => __( 'Already succeeded', $this->prefix ),
738 'failed' => __( 'Failed', $this->prefix ),
739 'add_new_field' => __( 'Add Field', $this->prefix ),
740 ) );
741
742 wp_localize_script($localize_key_add_fields, 'form_maker', array(
743 'countries' => WDW_FM_Library(self::PLUGIN)->get_countries(),
744 'states' => WDW_FM_Library(self::PLUGIN)->get_states(),
745 'provinces' => WDW_FM_Library(self::PLUGIN)->get_provinces_canada(),
746 'plugin_url' => $this->plugin_url,
747 'nothing_found' => __('Nothing found.', $this->prefix),
748 'captcha_created' => __('The captcha already has been created.', $this->prefix),
749 'update' => __('Update', $this->prefix),
750 'add' => __('Add', $this->prefix),
751 'add_field' => __('Add Field', $this->prefix),
752 'edit_field' => __('Edit Field', $this->prefix),
753 'stripe3' => __('To use this feature, please go to Settings > Payment Options and select "Stripe" as the Payment Method.', $this->prefix),
754 'sunday' => __('Sunday', $this->prefix),
755 'monday' => __('Monday', $this->prefix),
756 'tuesday' => __('Tuesday', $this->prefix),
757 'wednesday' => __('Wednesday', $this->prefix),
758 'thursday' => __('Thursday', $this->prefix),
759 'friday' => __('Friday', $this->prefix),
760 'saturday' => __('Saturday', $this->prefix),
761 'leave_empty' => __('Leave empty to set the width to 100%.', $this->prefix),
762 'is_demo' => $this->is_demo,
763 'important_message' => __('The free version is limited up to 7 fields to add. If you need this functionality, you need to buy the commercial version.', $this->prefix),
764 'no_preview' => __('No preview available for reCAPTCHA.', $this->prefix),
765 'invisible_recaptcha_error' => sprintf(__('%s Old reCAPTCHA keys will not work for %s. Please make sure to enable the API keys for Invisible reCAPTCHA.', $this->prefix), '<b>' . __('Note:', $this->prefix) . '</b>', '<b>' . __('Invisible reCAPTCHA', $this->prefix) . '</b>'),
766 'type_text_description' => __('This field is a single line text input.', $this->prefix) . '<br><br>' . __('To set a default value, just fill the field above.', $this->prefix) . '<br><br>' . __('You can set the text input as Required, making sure the submitter provides a value for it.', $this->prefix) . '<br><br>' . __('Validation (RegExp.) option in Advanced options lets you configure Regular Expression for your Single Line Text field. Use Common Regular Expressions select box to use built-in validation patterns. For instance, in case you can add a validation for decimal number, IP address or zip code by selecting corresponding options of Common Regular Expressions drop-down.', $this->prefix) . '<br><br>' . __('Additionally, you can add HTML attributes to your form fields with Additional Attributes.', $this->prefix),
767 'type_textarea_description' => __('This field adds a textarea box to your form. Users can write alphanumeric text, special characters and line breaks.', $this->prefix) . '<br><br>' . __('You can set the text input as Required, making sure the submitter provides a value for it.', $this->prefix) . '<br><br>' . __('Set the width and height of the textarea box using Size(px) option.', $this->prefix),
768 'type_number_description' => __('This is an input text that accepts only numbers. Users can type a number directly, or use the spinner arrows to specify it.', $this->prefix) . '<br><br>' . __('Step option defines the number to increment/decrement the spinner value, when the users press up or down arrows.', $this->prefix) . '<br><br>' . __('Use Min Value and Max Value options to set lower and upper limitation for the value of this Number field.', $this->prefix) . '<br><br>' . __('To set a default value, just fill the field above.', $this->prefix),
769 'type_select_description' => __('This field allows the submitter to choose values from select box. Just click (+) Option button and fill in all options you will need or click (+) From Database to fill the options from a database table.', $this->prefix) . '<br><br>' . __('In case you need to have option values to be different from option names, mark Enable option\'s value from Advanced options as checked.', $this->prefix),
770 'type_radio_description' => __('Using this field you can add a list of Radio buttons to your form. Just click (+) Option button and fill in all options you will need or click (+) From Database to fill the options from a database table.', $this->prefix) . '<br><br>' . __('Relative Position lets you choose the position of options in relation to each other. Whereas Option Label Position lets you select the position of radio button label.', $this->prefix) . '<br><br>' . __('In case you need to have option values to be different from option names, mark Enable option\'s value from Advanced options as checked.', $this->prefix) . '<br><br>' . __('And by enabling Allow other, you can let the user to write their own specific value.', $this->prefix),
771 'type_checkbox_description' => __('Multiple Choice field lets you have a list of Checkboxes. This field allows the submitter to choose more than one values.', $this->prefix) . '<br><br>' . __('Just click (+) Option button and fill in all options you will need or click (+) From Database to fill the options from a database table.', $this->prefix) . '<br><br>' . __('Relative Position lets you choose the position of options in relation to each other. Whereas Option Label Position lets you select the position of radio button label.', $this->prefix) . '<br><br>' . __('In case you need to have option values to be different from option names, mark Enable option\'s value from Advanced options as checked.', $this->prefix) . '<br><br>' . __('And by enabling Allow other, you can let the user to write their own specific value.', $this->prefix),
772 'type_recaptcha_description' => sprintf(__('Form Maker is integrated with Google ReCaptcha, which protects your forms from spam bots. Before adding ReCaptcha to your form, you need to configure Site and Secret Keys by registering your website on %s', $this->prefix), '<a href="https://www.google.com/recaptcha/intro/" target="_blank">' . __('Google ReCaptcha website', $this->prefix) . '</a>') . '<br><br>' . __('After registering and creating the keys, copy them to Form Maker > Options page.', $this->prefix),
773 'type_submit_description' => __('The Submit button validates all form field values, saves them on MySQL database of your website, sends emails and performs other actions configured in Form Options. You can have more than one submit button in your form.', $this->prefix),
774 'type_captcha_description' => __('You can use this field as an alternative to ReCaptcha to protect your forms against spambots. It’s a random combination of numbers and letters, and users need to type them in correctly to submit the form.', $this->prefix) . '<br><br>' . __('You can specify the number of symbols in Simple Captcha using Symbols (3 - 9) option.', $this->prefix),
775 'type_name_description' => __('This field lets the user write their name.', $this->prefix) . '<br><br>' . __('To set a default value, just fill the field above.', $this->prefix) . '<br><br>' . __('Enabling Autofill with user name setting will automatically fill in Name field with the name of the logged in user.', $this->prefix) . '<br><br>' . __('In case you do not wish to receive the same data for the same Name field twice, activate Allow only unique values option.', $this->prefix),
776 'type_email_description' => __('This field is an input field that accepts an email address.', $this->prefix) . '<br><br>' . __('To set a default value, just fill the field above.', $this->prefix) . '<br><br>' . __('Using Confirmation Email setting in Advanced Options you can require the submitter to re-type their email address.', $this->prefix) . '<br><br>' . __('Autofill with user email will autofill Email field with the email address of the logged in user.', $this->prefix) . '<br><br>' . __('Upon successful submission of the Form, you have the option to send the submitted data (or just a confirmation message) to the email address entered here. To do this you need to set the corresponding options on Form Options > Email Options page.', $this->prefix),
777 'type_phone_description' => __('This field is an input for a phone number. It provides a list of country flags, which users can select and have their country code automatically added to the phone number.', $this->prefix) . '<br><br>' . __('In case you do not wish to receive the same data for the same Phone field more than once, activate Allow only unique values setting from Advanced options.', $this->prefix),
778 'type_address_description' => __('This field lets you skip a few steps and quickly add one set for requesting the address of the submitter. Use Overall size(px) option to set the width of Address field.', $this->prefix) . '<br><br>' . __('You can enable or disable elements of Address field using Disable Field(s) setting in Advanced Options.', $this->prefix) . '<br><br>' . __('You can turn State/Province/Region field into a list of US states by activating Use list for US states setting from Advanced Options. Note: This only works in case United States is selected for Country select box.', $this->prefix),
779 'type_mark_on_map_description' => __('Mark on Map field lets users to drag the map pin and drop it on their selected location. You can specify a default address for the location pin with Address option.', $this->prefix) . '<br><br>' . __('In addition, Marker Info setting allows you to provide additional details about the location. It will appear after users click on the location pin.', $this->prefix),
780 'type_country_list_description' => __('Country List is a select box which provides a list of all countries in alphabetical order.', $this->prefix) . '<br><br>' . __('You can include/exclude specific countries from the list using the Edit country list setting in Advanced Options.', $this->prefix),
781 'type_date_of_birth_description' => __('Users can specify their birthday or any date with this field.', $this->prefix) . '<br><br>' . __('Use Fields separator setting in Advanced options to change the divider between day, month and year boxes.', $this->prefix) . '<br><br>' . __('You can set the fields to be text inputs or select boxes using Day field type, Month field type and Year field type options.', $this->prefix) . '<br><br>' . __('In addition, you can specify the width of day, month and year fields using Day field size(px), Month field size(px) and Year field size(px) settings.', $this->prefix) . '<br><br>' . __('Min Value of Date: Use the date format dd/m/yy, e.g. 05/07/2020". The range of Year field from 1901 to the current year.', $this->prefix),
782 'type_file_upload_description' => __('You can allow users to upload single or multiple documents, images and various files through your form.', $this->prefix) . '<br><br>' . __('Use Allowed file extensions option to specify all acceptable file formats. Make sure to separate them with commas.', $this->prefix) . '<br><br>' . __('Mark Allow Uploading Multiple Files option in Advanced Options to allow users to select and upload multiple files.', $this->prefix),
783 'type_map_description' => __('Map field can be used for pinning one or more locations on Google Map and displaying them on your form.', $this->prefix) . '<br><br>' . __('Press the small Plus icon to add a location pin.', $this->prefix),
784 'type_time_description' => __('Time field of Form Maker plugin will allow users to specify time value. Set the time format of the field to 24-hour or 12-hour using Time Format option.', $this->prefix),
785 'type_send_copy_description' => __('When users fill in an email address using Email Field, this checkbox will allow them to choose if they wish to receive a copy of the submission email.', $this->prefix) . '<br><br>' . __('Note: Make sure to configure Form Options > Email Options of your form.', $this->prefix),
786 'type_stars_description' => __('Add Star rating field to your form with this field. You can display as many stars, as you will need, set the number using Number of Stars option.', $this->prefix),
787 'type_rating_description' => __('Place Rating field on your form to have radio buttons, which indicate rating from worst to best. You can set many radio buttons to display using Scale Range option.', $this->prefix),
788 'type_slider_description' => __('Slider field lets users specify the field value by dragging its handle from Min Value to Max Value.', $this->prefix),
789 'type_range_description' => __('You can use this field to let users choose a numeric range by providing values for 2 number inputs. Its Step option allows to set the increment/decrement of spinners’ values, when users click on up or down arrows.', $this->prefix),
790 'type_grades_description' => __('Users will be able to grade specified items with this field. The sum of all values will appear below the field with Total parameter.', $this->prefix) . '<br><br>' . __('Items option allows you to add multiple options to your Grades field.', $this->prefix),
791 'type_matrix_description' => __('Table of Fields lets you place a matrix on your form, which will let the submitter to answer a few questions with one field.', $this->prefix) . '<br><br>' . __('It allows you to configure the matrix with radio buttons, checkboxes, text boxes or drop-downs. Use Input Type option to set this.', $this->prefix),
792 'type_hidden_description' => __('Hidden Input field is similar to Single Line Text field, but it is not visible to users. Hidden Fields are handy, in case you need to run a custom Javascript and submit the result with the info on your form.', $this->prefix) . '<br><br>' . __('Name option of this field is mandatory. Note: we highly recommend you to avoid using spaces or special characters in Hidden Input name. You can write the custom Javascript code using the editor on Form Options > Javascript page.', $this->prefix),
793 'type_button_description' => __('In case you wish to run custom Javascript on your form, you can place Custom Button on your form. Its lets you call the script with its OnClick function.', $this->prefix) . '<br><br>' . __('You can write the custom Javascript code using the editor on Form Options > Javascript page.', $this->prefix),
794 'type_password_description' => __('Password input can be used to allow users provide secret text, such as passwords. All symbols written in this field are replaced with dots.', $this->prefix) . '<br><br>' . __('You can activate Password Confirmation option to ask users to repeat the password.', $this->prefix),
795 'type_phone_area_code_description' => __('Phone-Area Code is a Phone type field, which allows users to write Area Code and Phone Number into separate inputs.', $this->prefix),
796 'type_arithmetic_captcha_description' => __('Arithmetic Captcha is quite similar to Simple Captcha. However, instead of showing random symbols, it displays arithmetic operations.', $this->prefix) . '<br><br>' . __('You can set the operations using Operations option. The field can use addition (+), subtraction (-), multiplication (*) and division (/).', $this->prefix) . '<br><br>' . __('Make sure to separate the operations with commas.', $this->prefix),
797 'type_price_description' => __('Users can set a payment amount of their choice with Price field. Assigns minimum and maximum limits on its value using Range option.', $this->prefix) . '<br><br>' . __('To set a default value, just fill the field above.', $this->prefix) . '<br><br>' . __('Additionally, you can activate Readonly attribute. This way, users will not be able to edit the value of Price.', $this->prefix) . '<br><br>' . __('Note: Make sure to configure Form Options > Payment Options of your form.', $this->prefix),
798 'type_payment_select_description' => __('Payment Select field lets you create lists of products, one of which the submitter can choose to buy through your form. Add or edit list items using Options setting of the fields.', $this->prefix) . '<br><br>' . __('Enable Quantity property from Advanced Options, in case you would like the users to mention the quantity of items they purchase.', $this->prefix) . '<br><br>' . __('Also, you can configure custom or built-in Product Properties for your products, such as Color, T-Shirt Size or Print Size.', $this->prefix) . '<br><br>' . __('Note: Make sure to configure Form Options > Payment Options of your form.', $this->prefix),
799 'type_payment_radio_description' => __('Payment Single Choice field lets you create lists of products, one of which the submitter can choose to buy through your form. Add or edit list items using Options setting of the fields.', $this->prefix) . '<br><br>' . __('Enable Quantity property from Advanced Options, in case you would like the users to mention the quantity of items they purchase.', $this->prefix) . '<br><br>' . __('Also, you can configure custom or built-in Product Properties for your products, such as Color, T-Shirt Size or Print Size.', $this->prefix) . '<br><br>' . __('Note: Make sure to configure Form Options > Payment Options of your form.', $this->prefix),
800 'type_payment_checkbox_description' => __('Payment Multiple Choice field lets you create lists of products, which the submitter can choose to buy through your form. Add or edit list items using Options setting of the fields.', $this->prefix) . '<br><br>' . __('Enable Quantity property from Advanced Options, in case you would like the users to mention the quantity of items they purchase.', $this->prefix) . '<br><br>' . __('Also, you can configure custom or built-in Product Properties for your products, such as Color, T-Shirt Size or Print Size.', $this->prefix) . '<br><br>' . __('Note: Make sure to configure Form Options > Payment Options of your form.', $this->prefix),
801 'type_shipping_description' => __('Shipping allows you to configure shipping types, set price for each of them and display them on your form as radio buttons.', $this->prefix),
802 'type_total_description' => __('Please Total field to your payment form to sum up the values of Payment fields. ', $this->prefix),
803 'type_stripe_description' => __('This field adds the credit card details inputs (card number, expiration date, etc.) and allows you to accept direct payments made by credit cards.', $this->prefix),
804 'upload_max_size' => __('Your upload_max_filesize directive in php.ini is ' . intval(ini_get('upload_max_filesize')) * 1024 . 'KB', $this->prefix),
805 ));
806
807 wp_register_script($this->handle_prefix . '-codemirror', $this->plugin_url . '/js/layout/codemirror.min.js', array(), '5.63.3');
808 wp_register_script($this->handle_prefix . '-clike', $this->plugin_url . '/js/layout/clike.min.js', array(), '5.63.3');
809 wp_register_script($this->handle_prefix . '-formatting', $this->plugin_url . '/js/layout/formatting.js', array(), '1.0.0');
810 wp_register_script($this->handle_prefix . '-css', $this->plugin_url . '/js/layout/css.min.js', array(), '5.63.3');
811 wp_register_script($this->handle_prefix . '-javascript', $this->plugin_url . '/js/layout/javascript.min.js', array(), '5.63.3');
812 wp_register_script($this->handle_prefix . '-xml', $this->plugin_url . '/js/layout/xml.min.js', array(), '5.63.3');
813 wp_register_script($this->handle_prefix . '-php', $this->plugin_url . '/js/layout/php.min.js', array(), '5.63.3');
814 wp_register_script($this->handle_prefix . '-htmlmixed', $this->plugin_url . '/js/layout/htmlmixed.min.js', array(), '5.63.3');
815
816 wp_register_script($this->handle_prefix . '-colorpicker', $this->plugin_url . '/js/spectrum.min.js', array(), '1.8.1');
817 wp_register_script($this->handle_prefix . '-themes', $this->plugin_url . '/js/themes.js', array(), $this->plugin_version);
818 wp_register_script($this->handle_prefix . '-submissions', $this->plugin_url . '/js/form_maker_submissions.js', array(), $this->plugin_version);
819 wp_register_script($this->handle_prefix . '-ng-js', 'https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js', array(), '1.5.0');
820 wp_register_script($this->handle_prefix . '-theme-edit-ng', $this->plugin_url . '/js/fm-theme-edit-ng.js', array(), $this->plugin_version);
821
822
823 wp_register_style($this->handle_prefix . '-deactivate-css', $this->plugin_url . '/wd/assets/css/deactivate_popup.css', array(), $this->plugin_version);
824 wp_register_script($this->handle_prefix . '-deactivate-popup', $this->plugin_url . '/wd/assets/js/deactivate_popup.js', array(), $this->plugin_version, true);
825 $admin_data = wp_get_current_user();
826 wp_localize_script($this->handle_prefix . '-deactivate-popup', ($this->is_free == 2 ? 'cfmWDDeactivateVars' : 'fmWDDeactivateVars'), array(
827 "prefix" => "fm",
828 "deactivate_class" => 'fm_deactivate_link',
829 "email" => $admin_data->data->user_email,
830 "plugin_wd_url" => "https://10web.io/plugins/wordpress-form-maker/?utm_source=form_maker&utm_medium=free_plugin",
831 ));
832
833 wp_register_style($this->handle_prefix . '-topbar', $this->plugin_url . '/css/topbar.css', array(), $this->plugin_version);
834 wp_register_style($this->handle_prefix . '-icons', $this->plugin_url . '/css/fonts.css', array(), '1.0.1');
835
836 wp_localize_script($localize_key_all, 'fm_ajax', array(
837 'ajaxnonce' => wp_create_nonce('fm_ajax_nonce'),
838 ));
839 wp_localize_script($localize_key_add_fields, 'fm_ajax', array(
840 'ajaxnonce' => wp_create_nonce('fm_ajax_nonce'),
841 ));
842 wp_localize_script($localize_key_formmaker_div, 'fm_ajax', array(
843 'ajaxnonce' => wp_create_nonce('fm_ajax_nonce'),
844 ));
845 }
846
847 /**
848 * Admin ajax scripts.
849 */
850 public function register_admin_ajax_scripts() {
851 $fm_settings = $this->fm_settings;
852 wp_register_style($this->handle_prefix . '-tables', $this->plugin_url . '/css/form_maker_tables.css', array(), $this->plugin_version);
853 wp_register_style($this->handle_prefix . '-jquery-ui', $this->plugin_url . '/css/jquery-ui.custom.css', array(), $this->plugin_version);
854
855 wp_register_script($this->handle_prefix . '-shortcode' . $this->menu_postfix, $this->plugin_url . '/js/shortcode.js', array('jquery'), $this->plugin_version);
856 $google_map_key = !empty($fm_settings['map_key']) ? '&key=' . $fm_settings['map_key'] : '';
857
858 wp_register_script('google-maps', 'https://maps.google.com/maps/api/js?v=3.exp' . $google_map_key);
859 wp_register_script($this->handle_prefix . '-gmap_form', $this->plugin_url . '/js/if_gmap_back_end.js', array(), $this->plugin_version);
860
861 wp_localize_script($this->handle_prefix . '-shortcode' . $this->menu_postfix, 'form_maker', array(
862 'insert_form' => __('You must select a form', $this->prefix),
863 'update' => __('Update', $this->prefix),
864 ));
865 wp_register_style($this->handle_prefix . '-topbar', $this->plugin_url . '/css/topbar.css', array(), $this->plugin_version);
866 // Roboto font for submissions shortcode.
867 wp_register_style($this->handle_prefix . '-roboto', 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap');
868 }
869
870 /**
871 * admin-ajax actions for admin.
872 */
873 public function form_maker_ajax() {
874 $page = WDW_FM_Library(self::PLUGIN)->get('action');
875 $ajax_nonce = WDW_FM_Library(self::PLUGIN)->get('nonce');
876
877 $allowed_pages = array(
878 'manage' . $this->menu_postfix,
879 'manage' . $this->plugin_postfix,
880 'generete_csv' . $this->plugin_postfix,
881 'generete_xml' . $this->plugin_postfix,
882 'formmakerwdcaptcha' . $this->plugin_postfix,
883 'formmakerwdmathcaptcha' . $this->plugin_postfix,
884 'product_option' . $this->plugin_postfix,
885 'FormMakerEditCountryinPopup' . $this->plugin_postfix,
886 'FormMakerMapEditinPopup' . $this->plugin_postfix,
887 'FormMakerIpinfoinPopup' . $this->plugin_postfix,
888 'show_matrix' . $this->plugin_postfix,
889 'FormMakerSubmits' . $this->plugin_postfix,
890 'FMShortocde' . $this->plugin_postfix,
891 );
892 if ( !$this->is_demo ) {
893 $allowed_pages[] = 'FormMakerSQLMapping' . $this->plugin_postfix;
894 $allowed_pages[] = 'select_data_from_db' . $this->plugin_postfix;
895 }
896 if ( !$this->is_free ) {
897 $allowed_pages[] = 'paypal_info';
898 $allowed_pages[] = 'checkpaypal';
899 }
900 $allowed_nonce_pages = array('checkpaypal', 'formmakerwdcaptcha' . $this->plugin_postfix, 'formmakerwdmathcaptcha' . $this->plugin_postfix);
901
902 if ( !in_array($page, $allowed_nonce_pages) && wp_verify_nonce($ajax_nonce , 'fm_ajax_nonce') == FALSE ) {
903 die(-1);
904 }
905
906 if ( !empty($page) && in_array($page, $allowed_pages) ) {
907 if ( $page != 'formmakerwdcaptcha' . $this->plugin_postfix
908 && $page != 'formmakerwdmathcaptcha' . $this->plugin_postfix
909 && $page != 'checkpaypal' ) {
910 if ( function_exists('current_user_can') ) {
911 if ( !current_user_can('manage_options') ) {
912 die('Access Denied');
913 }
914 }
915 else {
916 die('Access Denied');
917 }
918 }
919 $page = ucfirst(substr($page, 0, strlen($page) - strlen($this->plugin_postfix)));
920 $this->register_admin_ajax_scripts();
921 require_once($this->plugin_dir . '/admin/controllers/' . $page . '.php');
922 $controller_class = 'FMController' . $page . $this->plugin_postfix;
923 $controller = new $controller_class();
924 $controller->execute();
925 }
926 }
927
928 /**
929 * admin-ajax actions for site.
930 */
931 public function form_maker_ajax_frontend() {
932 $page = WDW_FM_Library(self::PLUGIN)->get('page');
933 $action = WDW_FM_Library(self::PLUGIN)->get('action');
934 $ajax_nonce = WDW_FM_Library(self::PLUGIN)->get('nonce');
935
936 $allowed_pages = array(
937 'form_submissions',
938 'form_maker',
939 );
940 $allowed_actions = array(
941 'frontend_generate_xml',
942 'frontend_generate_csv',
943 'frontend_paypal_info',
944 'frontend_show_matrix',
945 'frontend_show_map',
946 'get_frontend_stats',
947 'fm_reload_input',
948 );
949
950 if ( wp_verify_nonce($ajax_nonce , 'fm_ajax_nonce') == FALSE ) {
951 die(-1);
952 }
953 if ( !empty($page) && in_array($page, $allowed_pages)
954 && !empty($action) && in_array($action, $allowed_actions) ) {
955 $this->register_frontend_ajax_scripts();
956 require_once ($this->plugin_dir . '/frontend/controllers/' . $page . '.php');
957 $controller_class = 'FMController' . ucfirst($page) . $this->plugin_postfix;
958 $controller = new $controller_class();
959 $controller->execute();
960 }
961 }
962
963 /**
964 * Javascript variables for admin.
965 * todo: change to array.
966 */
967 public function form_maker_admin_ajax() {
968 $upload_dir = wp_upload_dir();
969 ?>
970 <script>
971 var fm_site_url = '<?php echo site_url() .'/'; ?>';
972 var admin_url = '<?php echo admin_url('admin.php'); ?>';
973 var plugin_url = '<?php echo $this->plugin_url; ?>';
974 var upload_url = '<?php echo $upload_dir['baseurl']; ?>';
975 var nonce_fm = '<?php echo wp_create_nonce($this->nonce); ?>';
976 // Set shortcode popup dimensions.
977 function fm_set_shortcode_popup_dimensions(tbWidth, tbHeight) {
978 var tbWindow = jQuery('#TB_window'), H = jQuery(window).height(), W = jQuery(window).width(), w, h;
979 w = (tbWidth && tbWidth < W - 90) ? tbWidth : W - 40;
980 h = (tbHeight && tbHeight < H - 60) ? tbHeight : H - 40;
981 if (tbWindow.length) {
982 tbWindow.width(w).height(h);
983 jQuery('#TB_iframeContent').width(w).height(h - 27);
984 tbWindow.css({'margin-left': '-' + parseInt((w / 2), 10) + 'px'});
985 if (typeof document.body.style.maxWidth != 'undefined') {
986 tbWindow.css({'top': (H - h) / 2, 'margin-top': '0'});
987 }
988 }
989 }
990 </script>
991 <?php
992 }
993
994 /**
995 * Form maker preview shortcode output.
996 *
997 * @return mixed|string
998 */
999 public function fm_form_preview_shortcode() {
1000 // check is adminstrator
1001 if ( !current_user_can('manage_options') ) {
1002 echo __('Sorry, you are not allowed to access this page.', $this->prefix);
1003 }
1004 else {
1005 $id = WDW_FM_Library(self::PLUGIN)->get('wdform_id', 0);
1006 $display_options_row = WDW_FM_Library(self::PLUGIN)->display_options($id);
1007 $display_options_row = WDW_FM_Library::convert_json_options_to_old($display_options_row, 'display_options');
1008 $type = $display_options_row->type;
1009 $attrs = array( 'id' => $id );
1010 if ( $type == "embedded" ) {
1011 ob_start();
1012 $this->FM_front_end_main($attrs, $type); // embedded popover topbar scrollbox
1013
1014 return str_replace(array( "\r\n", "\n", "\r" ), '', ob_get_clean());
1015 }
1016 }
1017 }
1018
1019 /**
1020 * Form maker shortcode output.
1021 *
1022 * @param $attrs
1023 * @return mixed|string
1024 */
1025 public function fm_shortcode($attrs) {
1026 ob_start();
1027 $this->FM_front_end_main($attrs, 'embedded');
1028
1029 return str_replace(array("\r\n", "\n", "\r"), '', ob_get_clean());
1030 }
1031
1032 /**
1033 * Form maker output.
1034 *
1035 * @param array $params
1036 * @param string $type
1037 */
1038 public function FM_front_end_main($params = array(), $type = '') {
1039 $form_id = isset($params['id']) ? (int) $params['id'] : 0;
1040 if ( !isset($params['type']) ) {
1041 if ($this->is_free == 2) {
1042 wd_contact_form_maker($form_id, $type);
1043 }
1044 else {
1045 wd_form_maker( $form_id, $type );
1046 }
1047 }
1048 else if (!$this->is_free) {
1049 $shortcode_deafults = array(
1050 'id' => 0,
1051 'startdate' => '',
1052 'enddate' => '',
1053 'submit_date' => '',
1054 'submitter_ip' => '',
1055 'username' => '',
1056 'useremail' => '',
1057 'form_fields' => '1',
1058 'show' => '1,1,1,1,1,1,1,1,1,1',
1059 );
1060 shortcode_atts($shortcode_deafults, $params);
1061
1062 require_once($this->plugin_dir . '/frontend/controllers/form_submissions.php');
1063 $controller = new FMControllerForm_submissions();
1064
1065 $submissions = $controller->execute($params);
1066
1067 echo $submissions;
1068 }
1069 return;
1070 }
1071
1072 /**
1073 * Email verification output.
1074 */
1075 public function fm_email_verification_shortcode() {
1076 require_once($this->plugin_dir . '/frontend/controllers/verify_email.php');
1077 $controller_class = 'FMControllerVerify_email' . $this->plugin_postfix;
1078 $controller = new $controller_class();
1079 $controller->execute();
1080 }
1081
1082 /**
1083 * Register email verification custom post type.
1084 */
1085 public function register_fmemailverification_cpt() {
1086 $args = array(
1087 'label' => 'FM Mail Verification',
1088 'public' => true,
1089 'exclude_from_search' => true,
1090 'show_in_menu' => false,
1091 'show_in_nav_menus' => false,
1092 'create_posts' => 'do_not_allow',
1093 'capabilities' => array(
1094 'create_posts' => FALSE,
1095 'edit_post' => 'edit_posts',
1096 'read_post' => 'edit_posts',
1097 'delete_posts' => FALSE,
1098 )
1099 );
1100 register_post_type(($this->is_free == 2 ? 'cfmemailverification' : 'fmemailverification'), $args);
1101 }
1102
1103 /**
1104 * Register form preview custom post type.
1105 */
1106 public function register_form_preview_cpt() {
1107 $args = array(
1108 'label' => 'FM Preview',
1109 'public' => true,
1110 'exclude_from_search' => true,
1111 'show_in_menu' => false,
1112 'show_in_nav_menus' => false,
1113 'create_posts' => 'do_not_allow',
1114 'capabilities' => array(
1115 'create_posts' => FALSE,
1116 'edit_post' => 'edit_posts',
1117 'read_post' => 'edit_posts',
1118 'delete_posts' => FALSE,
1119 )
1120 );
1121
1122 register_post_type('form-maker' . $this->plugin_postfix, $args);
1123 }
1124
1125 /**
1126 * Frontend scripts/styles.
1127 */
1128 public function register_frontend_scripts() {
1129 $fm_settings = $this->fm_settings;
1130 $front_plugin_url = $this->front_urls['plugin_url'];
1131
1132 $required_scripts = array(
1133 'jquery',
1134 'jquery-ui-widget',
1135 'jquery-effects-shake',
1136 );
1137 $required_styles = array(
1138 $this->handle_prefix . '-googlefonts'
1139 );
1140 if ($fm_settings['fm_developer_mode']) {
1141 array_push($required_styles, $this->handle_prefix . '-jquery-ui', $this->handle_prefix . '-animate');
1142 }
1143 // For drag and drop on mobiles.
1144 wp_register_script($this->handle_prefix . '-jquery-ui-touch-punch', $this->plugin_url . '/js/jquery.ui.touch-punch.min.js', array('jquery'), '0.2.3');
1145
1146 wp_register_style($this->handle_prefix . '-jquery-ui', $front_plugin_url . '/css/jquery-ui.custom.css', array(), $this->plugin_version);
1147 wp_register_style($this->handle_prefix . '-animate', $front_plugin_url . '/css/fm-animate.css', array(), $this->plugin_version);
1148
1149 $google_map_key = !empty($fm_settings['map_key']) ? '&key=' . $fm_settings['map_key'] : '';
1150 wp_register_script('google-maps', 'https://maps.google.com/maps/api/js?v=3.exp' . $google_map_key);
1151
1152 wp_register_script($this->handle_prefix . '-phone_field', $front_plugin_url . '/js/intlTelInput.min.js', array(), '17.0.13');
1153 wp_register_style($this->handle_prefix . '-phone_field_css', $front_plugin_url . '/css/intlTelInput.min.css', array(), '17.0.13');
1154
1155 wp_register_script($this->handle_prefix . '-gmap_form', $front_plugin_url . '/js/if_gmap_front_end.js', array('google-maps'), $this->plugin_version);
1156 wp_register_style($this->handle_prefix . '-googlefonts', WDW_FM_Library(self::PLUGIN)->get_all_used_google_fonts(), null, null);
1157 wp_register_script($this->handle_prefix . '-signaturepad', $this->plugin_url . '/js/jquery.signaturepad.min.js', array(), '2.5.2');
1158
1159 /* Getting admin language to show recaptcha language */
1160 $lng = get_locale();
1161 wp_register_script($this->handle_prefix . '-g-recaptcha', 'https://www.google.com/recaptcha/api.js?hl='.$lng.'&onload=fmRecaptchaInit&render=explicit');
1162 if ( isset($fm_settings['public_key']) ) {
1163 wp_register_script($this->handle_prefix . '-g-recaptcha-v3', 'https://www.google.com/recaptcha/api.js?hl='.$lng.'&onload=fmRecaptchaInit&render=' . $fm_settings['public_key']);
1164 }
1165 // Register admin styles to use in frontend submissions.
1166 wp_register_script('gmap_form_back', $front_plugin_url . '/js/if_gmap_back_end.js', array(), $this->plugin_version);
1167
1168 if (!$this->is_free) {
1169 wp_register_script($this->handle_prefix . '-file-upload', $front_plugin_url . '/js/file-upload.js', array(), $this->plugin_version);
1170 wp_register_style($this->handle_prefix . '-submissions_css', $front_plugin_url . '/css/style_submissions.css', array(), $this->plugin_version);
1171
1172 if (WDW_FM_Library(self::PLUGIN)->elementor_is_active() && $fm_settings['fm_developer_mode']) {
1173 array_push($required_styles, $this->handle_prefix . '-submissions_css');
1174 array_push($required_scripts, $this->handle_prefix . '-file-upload', 'gmap_form_back');
1175 }
1176 }
1177
1178 if (WDW_FM_Library(self::PLUGIN)->elementor_is_active()) {
1179 array_push($required_scripts,
1180 'jquery-ui-spinner',
1181 'jquery-ui-datepicker',
1182 'jquery-ui-slider'
1183 );
1184
1185 if ($fm_settings['fm_developer_mode']) {
1186 array_push($required_scripts, $this->handle_prefix . '-phone_field', $this->handle_prefix . '-gmap_form', $this->handle_prefix . '-signaturepad');
1187 array_push($required_styles, $this->handle_prefix . '-phone_field_css');
1188 }
1189 }
1190
1191 $style_file = '/css/styles.min.css';
1192 $script_file = '/js/scripts.min.js';
1193 if ($fm_settings['fm_developer_mode']) {
1194 $style_file = '/css/form_maker_frontend.css';
1195 $script_file = '/js/main_div_front_end.js';
1196 }
1197
1198 wp_register_style($this->handle_prefix . '-frontend', $front_plugin_url . $style_file, $required_styles, $this->plugin_version);
1199 wp_register_script($this->handle_prefix . '-frontend', $front_plugin_url . $script_file, $required_scripts, $this->plugin_version);
1200
1201 wp_register_script($this->handle_prefix . '-frontend-momentjs', $front_plugin_url . '/js/moment.min.js', array(), '2.29.2');
1202
1203 if (WDW_FM_Library(self::PLUGIN)->elementor_is_active()) {
1204 wp_enqueue_style($this->handle_prefix . '-frontend');
1205 wp_enqueue_script($this->handle_prefix . '-frontend');
1206 }
1207
1208 wp_localize_script($this->handle_prefix . '-frontend', 'fm_objectL10n', array(
1209 'states' => WDW_FM_Library(self::PLUGIN)->get_states(),
1210 'provinces' => WDW_FM_Library(self::PLUGIN)->get_provinces_canada(),
1211 'plugin_url' => $front_plugin_url,
1212 'form_maker_admin_ajax' => admin_url('admin-ajax.php'),
1213 'fm_file_type_error' => addslashes(__('Can not upload this type of file', $this->prefix)),
1214 'fm_file_type_allowed_size_error' => addslashes(__('The file exceeds the allowed size of %s KB.', $this->prefix)),
1215 'fm_field_is_required' => addslashes(__('Field is required', $this->prefix)),
1216 'fm_min_max_check_1' => addslashes((__('The ', $this->prefix))),
1217 'fm_min_max_check_2' => addslashes((__(' value must be between ', $this->prefix))),
1218 'fm_spinner_check' => addslashes((__('Value must be between ', $this->prefix))),
1219 'fm_clear_data' => addslashes((__('Are you sure you want to clear saved data?', $this->prefix))),
1220 'fm_grading_text' => addslashes(__('Your score should be less than', $this->prefix)),
1221 'time_validation' => addslashes(__('This is not a valid time value.', $this->prefix)),
1222 'number_validation' => addslashes(__('This is not a valid number value.', $this->prefix)),
1223 'date_validation' => addslashes(__('This is not a valid date value.', $this->prefix)),
1224 'year_validation' => addslashes(sprintf(__('The year must be between %s and %s', $this->prefix), '%%start%%', '%%end%%')),
1225 'fm_frontend_ajax_url' => admin_url( 'admin-ajax.php' ),
1226 ));
1227
1228 wp_localize_script($this->handle_prefix . '-frontend', 'fm_ajax', array(
1229 'ajaxnonce' => wp_create_nonce('fm_ajax_nonce'),
1230 ));
1231 }
1232
1233 /**
1234 * Frontend ajax scripts.
1235 */
1236 public function register_frontend_ajax_scripts() {
1237 $fm_settings = $this->fm_settings;
1238 $front_plugin_url = $this->front_urls['plugin_url'];
1239 $google_map_key = !empty($fm_settings['map_key']) ? '&key=' . $fm_settings['map_key'] : '';
1240 wp_register_script('google-maps', 'https://maps.google.com/maps/api/js?v=3.exp' . $google_map_key);
1241 wp_register_script($this->handle_prefix . '-gmap_form_back', $front_plugin_url . '/js/if_gmap_back_end.js', array(), $this->plugin_version);
1242 }
1243
1244 /*
1245 * Global activate.
1246 *
1247 * @param $networkwide
1248 */
1249 public function global_activate($networkwide) {
1250 if ( function_exists('is_multisite') && is_multisite() ) {
1251 // Check if it is a network activation - if so, run the activation function for each blog id.
1252 if ( $networkwide ) {
1253 global $wpdb;
1254 // Get all blog ids.
1255 $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
1256 foreach ( $blogids as $blog_id ) {
1257 switch_to_blog($blog_id);
1258 $this->form_maker_on_activate();
1259 restore_current_blog();
1260 }
1261
1262 return;
1263 }
1264 }
1265 $this->form_maker_on_activate();
1266 }
1267
1268 public function new_blog_added( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
1269 if ( is_plugin_active_for_network( $this->main_file ) ) {
1270 switch_to_blog($blog_id);
1271 $this->form_maker_on_activate();
1272 restore_current_blog();
1273 }
1274 }
1275
1276 /**
1277 * Activate plugin.
1278 */
1279 public function form_maker_on_activate() {
1280 $this->form_maker_activate();
1281 if ($this->is_free == 2) {
1282 WDCFMInsert::install_demo_forms();
1283 }
1284 else {
1285 WDFMInsert::install_demo_forms();
1286 }
1287 $this->init();
1288 // Using this insted of flush_rewrite_rule() for better performance with multisite.
1289 global $wp_rewrite;
1290 $wp_rewrite->init();
1291 $wp_rewrite->flush_rules();
1292 }
1293
1294 /**
1295 * Global deactivate.
1296 *
1297 * @param $networkwide
1298 */
1299 public function global_deactivate($networkwide) {
1300 if ( function_exists('is_multisite') && is_multisite() ) {
1301 if ( $networkwide ) {
1302 global $wpdb;
1303 // Check if it is a network activation - if so, run the activation function for each blog id.
1304 // Get all blog ids.
1305 $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
1306 foreach ( $blogids as $blog_id ) {
1307 switch_to_blog($blog_id);
1308 $this->deactivate();
1309 restore_current_blog();
1310 }
1311
1312 return;
1313 }
1314 }
1315 $this->deactivate();
1316 }
1317
1318 /**
1319 * Deactivate.
1320 */
1321 public function deactivate() {
1322 // Using this insted of flush_rewrite_rule() for better performance with multisite.
1323 global $wp_rewrite;
1324 $wp_rewrite->init();
1325 $wp_rewrite->flush_rules();
1326 }
1327
1328 /**
1329 * Activate plugin.
1330 */
1331 public function form_maker_activate() {
1332 global $wpdb;
1333 if (!$this->is_free) {
1334 deactivate_plugins("contact-form-maker/contact-form-maker.php");
1335 delete_transient('fm_update_check');
1336 }
1337 $version = get_option("wd_form_maker_version");
1338 $new_version = $this->db_version;
1339 $option_key = ($this->is_free == 2 ? 'fmc_settings' : 'fm_settings');
1340 require_once $this->plugin_dir . "/form_maker_insert.php";
1341
1342 if (!$version) {
1343 if ($wpdb->get_var("SHOW TABLES LIKE '" . $wpdb->prefix . "formmaker'") == $wpdb->prefix . "formmaker") {
1344 deactivate_plugins($this->main_file);
1345 wp_die(__("Oops! Seems like you installed the update over a quite old version of Form Maker. Unfortunately, this version is deprecated.<br />Please contact 10Web support team at support@10web.io. We will take care of this issue as soon as possible.", $this->prefix));
1346 }
1347 else {
1348 add_option("wd_form_maker_version", $new_version, '', 'no');
1349 if ($this->is_free == 2) {
1350 WDCFMInsert::form_maker_insert();
1351 }
1352 else {
1353 WDFMInsert::form_maker_insert();
1354 }
1355 add_option($option_key, array('public_key' => '', 'private_key' => '', 'csv_delimiter' => ',', 'map_key' => '', 'fm_file_read' => 0, 'ajax_export_per_page' => 1000));
1356 }
1357 }
1358 elseif (version_compare($version, $new_version, '<')) {
1359 $version = substr_replace($version, '1.', 0, 2);
1360 require_once $this->plugin_dir . "/form_maker_update.php";
1361 $mail_verification_post_ids = $wpdb->get_results($wpdb->prepare('SELECT mail_verification_post_id FROM ' . $wpdb->prefix . 'formmaker WHERE mail_verification_post_id != %d', 0));
1362 if ( !empty($mail_verification_post_ids) ) {
1363 foreach ($mail_verification_post_ids as $mail_verification_post_id) {
1364 $update_email_ver_post_type = array(
1365 'ID' => (int) $mail_verification_post_id->mail_verification_post_id,
1366 'post_type' => ($this->is_free == 2 ? 'cfmemailverification' : 'fmemailverification'),
1367 );
1368 wp_update_post($update_email_ver_post_type);
1369 }
1370 }
1371 if ($this->is_free == 2) {
1372 WDCFMUpdate::form_maker_update($version);
1373 }
1374 else {
1375 WDFMUpdate::form_maker_update($version);
1376 }
1377 update_option("wd_form_maker_version", $new_version);
1378 $fm_settings = get_option($option_key);
1379 if ( $fm_settings === FALSE ) {
1380 $recaptcha_keys = $wpdb->get_row('SELECT `public_key`, `private_key` FROM ' . $wpdb->prefix . 'formmaker WHERE public_key!="" and private_key!=""', ARRAY_A);
1381 $public_key = isset($recaptcha_keys['public_key']) ? $recaptcha_keys['public_key'] : '';
1382 $private_key = isset($recaptcha_keys['private_key']) ? $recaptcha_keys['private_key'] : '';
1383 $option_value = array(
1384 'public_key' => $public_key,
1385 'private_key' => $private_key,
1386 'csv_delimiter' => ',',
1387 'map_key' => '',
1388 'fm_advanced_layout' => 0,
1389 'fm_enable_wp_editor' => 1,
1390 'fm_antispam_referer' => 0,
1391 'fm_antispam_bot_validation' => 0,
1392 'fm_antispam_nonce' => 0,
1393 'fm_block_ip_exceeded_limit' => 0,
1394 'fm_developer_mode' => 0,
1395 'fm_file_read' => 0,
1396 'ajax_export_per_page' => 1000);
1397 add_option($option_key, $option_value);
1398 }
1399 if ( !isset($fm_settings['fm_enable_wp_editor']) ) {
1400 $fm_settings['fm_enable_wp_editor'] = 1;
1401 update_option( $option_key, $fm_settings );
1402 }
1403 if ( !isset($fm_settings['fm_antispam_referer']) ) {
1404 $fm_settings['fm_antispam_referer'] = 0;
1405 update_option( $option_key, $fm_settings );
1406 }
1407 if ( !isset($fm_settings['fm_antispam_bot_validation']) ) {
1408 $fm_settings['fm_antispam_bot_validation'] = 0;
1409 update_option( $option_key, $fm_settings );
1410 }
1411 if ( !isset($fm_settings['fm_antispam_nonce']) ) {
1412 $fm_settings['fm_antispam_nonce'] = 0;
1413 update_option( $option_key, $fm_settings );
1414 }
1415 if ( !isset($fm_settings['fm_block_ip_exceeded_limit']) ) {
1416 $fm_settings['fm_block_ip_exceeded_limit'] = 0;
1417 update_option( $option_key, $fm_settings );
1418 }
1419 if ( !isset($fm_settings['fm_developer_mode']) ) {
1420 $fm_settings['fm_developer_mode'] = 0;
1421 update_option( $option_key, $fm_settings );
1422 }
1423 if ( !isset($fm_settings['fm_file_read']) ) {
1424 $fm_settings['fm_file_read'] = 0;
1425 update_option( $option_key, $fm_settings );
1426 }
1427 }
1428 }
1429
1430 /**
1431 * Form maker overview.
1432 */
1433 public function fm_overview() {
1434 if (is_admin() && !isset($_REQUEST['ajax'])) {
1435 if (!class_exists("TenWebLibNew")) {
1436 $plugin_dir = apply_filters('tenweb_free_users_lib_path', array('version' => '1.1.1', 'path' => $this->plugin_dir));
1437 require_once($plugin_dir['path'] . '/wd/start.php');
1438 }
1439 global $fm_options;
1440 $fm_options = array(
1441 "prefix" => ($this->is_free == 2 ? 'cfm' : 'fm'),
1442 "wd_plugin_id" => ($this->is_free == 2 ? 183 : 31),
1443 "plugin_id" => ($this->is_free == 2 ? 95 : 95),
1444 "plugin_title" => ($this->is_free == 2 ? 'Contact Form Maker' : 'Form Maker'),
1445 "plugin_wordpress_slug" => ($this->is_free == 2 ? 'contact-form-maker' : 'form-maker'),
1446 "plugin_dir" => $this->plugin_dir,
1447 "plugin_main_file" => __FILE__,
1448 "description" => ($this->is_free == 2 ? __('WordPress Contact Form Maker is a simple contact form builder, which allows the user with almost no knowledge of programming to create and edit different type of contact forms.', $this->prefix) : __('Form Maker plugin is a modern and advanced tool for easy and fast creating of a WordPress Form. The backend interface is intuitive and user friendly which allows users far from scripting and programming to create WordPress Forms.', $this->prefix)),
1449 "plugin_features" => array(
1450 0 => array(
1451 "title" => __("Easy to Use", $this->prefix),
1452 "description" => __("This responsive form maker plugin is one of the most easy-to-use form builder solutions available on the market. Simple, yet powerful plugin allows you to quickly and easily build any complex forms.", $this->prefix),
1453 ),
1454 1 => array(
1455 "title" => __("Customizable Fields", $this->prefix),
1456 "description" => __("All the fields of Form Maker plugin are highly customizable, which allows you to change almost every detail in the form and make it look exactly like you want it to be.", $this->prefix),
1457 ),
1458 2 => array(
1459 "title" => __("Submissions", $this->prefix),
1460 "description" => __("You can view the submissions for each form you have. The plugin allows to view submissions statistics, filter submission data and export in csv or xml formats.", $this->prefix),
1461 ),
1462 3 => array(
1463 "title" => __("Multi-Page Forms", $this->prefix),
1464 "description" => __("With the form builder plugin you can create muilti-page forms. Simply use the page break field to separate the pages in your forms.", $this->prefix),
1465 ),
1466 4 => array(
1467 "title" => __("Themes", $this->prefix),
1468 "description" => __("The WordPress Form Maker plugin comes with a wide range of customizable themes. You can choose from a list of existing themes or simply create the one that better fits your brand and website.", $this->prefix),
1469 )
1470 ),
1471 "user_guide" => array(
1472 0 => array(
1473 "main_title" => __("Installing", $this->prefix),
1474 "url" => "https://help.10web.io/hc/en-us/articles/360015435831-Introducing-Form-Maker-Plugin?utm_source=form_maker&utm_medium=free_plugin",
1475 "titles" => array()
1476 ),
1477 1 => array(
1478 "main_title" => __("Creating a new Form", $this->prefix),
1479 "url" => "https://help.10web.io/hc/en-us/articles/360015244232-Creating-a-Form-on-WordPress?utm_source=form_maker&utm_medium=free_plugin",
1480 "titles" => array()
1481 ),
1482 2 => array(
1483 "main_title" => __("Configuring Form Options", $this->prefix),
1484 "url" => "https://help.10web.io/hc/en-us/articles/360015862812-Settings-General-Options?utm_source=form_maker&utm_medium=free_plugin",
1485 "titles" => array()
1486 ),
1487 3 => array(
1488 "main_title" => __("Description of The Form Fields", $this->prefix),
1489 "url" => "https://help.10web.io/hc/en-us/articles/360016081951-Form-Fields-Basic?utm_source=form_maker&utm_medium=free_plugin",
1490 "titles" => array(
1491 array(
1492 "title" => __("Selecting Options from Database", $this->prefix),
1493 "url" => "https://help.10web.io/hc/en-us/articles/360015862632-Selecting-Options-from-Database?utm_source=form_maker&utm_medium=free_plugin",
1494 ),
1495 )
1496 ),
1497 4 => array(
1498 "main_title" => __("Publishing the Created Form", $this->prefix),
1499 "url" => "https://help.10web.io/hc/en-us/articles/360016083211-Additional-Publishing-Options?utm_source=form_maker&utm_medium=free_plugin",
1500 "titles" => array()
1501 ),
1502 5 => array(
1503 "main_title" => __("Blocking IPs", $this->prefix),
1504 "url" => "https://help.10web.io/hc/en-us/articles/360015863292-Managing-Form-Submissions?utm_source=form_maker&utm_medium=free_plugin",
1505 "titles" => array()
1506 ),
1507 6 => array(
1508 "main_title" => __("Managing Submissions", $this->prefix),
1509 "url" => "https://help.10web.io/hc/en-us/articles/360015863292-Managing-Form-Submissions?utm_source=form_maker&utm_medium=free_plugin",
1510 "titles" => array()
1511 ),
1512 7 => array(
1513 "main_title" => __("Publishing Submissions", $this->prefix),
1514 "url" => "https://help.10web.io/hc/en-us/articles/360016083211-Additional-Publishing-Options?utm_source=form_maker&utm_medium=free_plugin",
1515 "titles" => array()
1516 ),
1517 ),
1518 "video_youtube_id" => "tN3_c6MhqFk",
1519 "plugin_wd_url" => "https://10web.io/plugins/wordpress-form-maker/?utm_source=form_maker&utm_medium=free_plugin",
1520 "plugin_wd_demo_link" => "https://demo.10web.io/form-maker?utm_source=form_maker&utm_medium=free_plugin",
1521 "plugin_wd_addons_link" => "https://10web.io/plugins/wordpress-form-maker/?utm_source=form_maker&utm_medium=free_plugin#plugin_extensions",
1522 "plugin_wd_docs_link" => "https://help.10web.io/hc/en-us/sections/360002133951-Form-Maker-Documentation/?utm_source=form_maker&utm_medium=free_plugin",
1523 "after_subscribe" => admin_url('admin.php?page=manage_' . ($this->is_free == 2 ? 'cfm' : 'fm')), // this can be plagin overview page or set up page
1524 "plugin_wizard_link" => '',
1525 "plugin_menu_title" => $this->nicename,
1526 "plugin_menu_icon" => $this->plugin_url . '/images/FormMakerLogo-16.png',
1527 "deactivate" => ($this->is_free ? true : false),
1528 "subscribe" => false,
1529 "custom_post" => 'manage' . $this->menu_postfix,
1530 "menu_position" => null,
1531 "display_overview" => false,
1532 );
1533
1534 ten_web_new_lib_init($fm_options);
1535 }
1536 }
1537
1538 /**
1539 * Add media button to Wp editor.
1540 *
1541 * @param $context
1542 *
1543 * @return string
1544 */
1545 function media_button() {
1546 $fm_nonce = wp_create_nonce('fm_ajax_nonce');
1547 ob_start();
1548 $url = add_query_arg(array('action' => 'FMShortocde' . $this->plugin_postfix, 'task' => 'forms', 'nonce' => $fm_nonce, 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
1549 ?>
1550 <a onclick="tb_click.call(this); fm_set_shortcode_popup_dimensions(400, 140); return false;" href="<?php echo $url; ?>" class="button" title="<?php _e('Insert Form', $this->prefix); ?>">
1551 <span class="wp-media-buttons-icon" style="background: url('<?php echo $this->plugin_url; ?>/images/fm-media-form-button.png') no-repeat scroll left top rgba(0, 0, 0, 0);"></span>
1552 <?php _e('Add Form', $this->prefix); ?>
1553 </a>
1554 <?php
1555 $url = add_query_arg(array('action' => 'FMShortocde' . $this->plugin_postfix, 'task' => 'submissions', 'nonce' => $fm_nonce, 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
1556 ?>
1557 <a onclick="tb_click.call(this); fm_set_shortcode_popup_dimensions(520, 570); return false;" href="<?php echo $url; ?>" class="button" title="<?php _e('Insert submissions', $this->prefix); ?>">
1558 <span class="wp-media-buttons-icon" style="background: url(<?php echo $this->plugin_url; ?>/images/fm-media-submissions-button.png) no-repeat scroll left top rgba(0, 0, 0, 0);"></span>
1559 <?php _e('Add Submissions', $this->prefix); ?>
1560 </a>
1561 <?php
1562 echo ob_get_clean();
1563 }
1564
1565
1566 /**
1567 * Check extensions version compatibility with FM.
1568 *
1569 */
1570 function fm_check_addons_compatibility() {
1571 // version - addon maximal version which is compatible with current version of form maker.
1572 // fm_version - form maker minimal version which is compatible with current version of addon.
1573 $add_ons = array(
1574 'form-maker-calculator' => array(
1575 'version' => '1.1.8',
1576 'fm_version' => '2.13.0',
1577 'file' => 'fm_calculator.php',
1578 ),
1579 'form-maker-conditional-emails' => array(
1580 'version' => '1.1.6',
1581 'fm_version' => '2.13.0',
1582 'file' => 'fm_conditional_emails.php',
1583 ),
1584 'form-maker-dropbox-integration' => array(
1585 'version' => '1.2.8',
1586 'fm_version' => '2.14.0',
1587 'file' => 'fm_dropbox_integration.php',
1588 ),
1589 'form-maker-export-import' => array(
1590 'version' => '2.1.11',
1591 'fm_version' => '2.14.0',
1592 'file' => 'fm_exp_imp.php',
1593 ),
1594 'form-maker-gdrive-integration' => array(
1595 'version' => '1.1.7',
1596 'fm_version' => '2.14.0',
1597 'file' => 'fm_gdrive_integration.php',
1598 ),
1599 'form-maker-mailchimp' => array(
1600 'version' => '1.1.11',
1601 'fm_version' => '2.14.0',
1602 'file' => 'fm_mailchimp.php',
1603 ),
1604 'form-maker-pdf-integration' => array(
1605 'version' => '1.1.7',
1606 'fm_version' => '2.13.0',
1607 'file' => 'fm_pdf_integration.php',
1608 ),
1609 'form-maker-post-generation' => array(
1610 'version' => '1.1.10',
1611 'fm_version' => '2.14.0',
1612 'file' => 'fm_post_generation.php',
1613 ),
1614 'form-maker-pushover' => array(
1615 'version' => '1.1.7',
1616 'fm_version' => '2.14.0',
1617 'file' => 'fm_pushover.php',
1618 ),
1619 'form-maker-reg' => array(
1620 'version' => '1.2.11',
1621 'fm_version' => '2.14.0',
1622 'file' => 'fm_reg.php',
1623 ),
1624 'form-maker-save-progress' => array(
1625 'version' => '1.1.14',
1626 'fm_version' => '2.14.10',
1627 'file' => 'fm_save.php',
1628 ),
1629 'form-maker-stripe' => array(
1630 'version' => '1.2.11',
1631 'fm_version' => '2.15.5',
1632 'file' => 'fm_stripe.php',
1633 ),
1634 'form-maker-webhooks' => array(
1635 'version' => '1.0.5',
1636 'fm_version' => '2.14.0',
1637 'file' => 'fm_webhooks.php',
1638 ),
1639 );
1640
1641 $add_ons_notice = array();
1642 $add_ons_need_higher_version = array();
1643 $max_required_version = $this->db_version;
1644 include_once($this->abspath . 'wp-admin/includes/plugin.php');
1645
1646 foreach ( $add_ons as $add_on_key => $add_on_value ) {
1647 $addon_path = plugin_dir_path(dirname(__FILE__)) . $add_on_key . '/' . $add_on_value['file'];
1648 if ( is_plugin_active($add_on_key . '/' . $add_on_value['file']) ) {
1649 $addon = get_plugin_data($addon_path); // array
1650 if ( version_compare($addon['Version'], $add_on_value['version'], '<') ) {
1651 // deactivate_plugins($addon_path);
1652 array_push($add_ons_notice, $addon['Name']);
1653 }
1654 }
1655 if ( version_compare($this->db_version, $add_on_value['fm_version']) == -1 ) {
1656 array_push($add_ons_need_higher_version, $add_on_key);
1657 }
1658 if ( version_compare($max_required_version, $add_on_value['fm_version']) == -1 ) {
1659 $max_required_version = $add_on_value['fm_version'];
1660 }
1661 }
1662
1663 if ( !empty($add_ons_notice) ) {
1664 $this->fm_addons_compatibility_notice($add_ons_notice);
1665 }
1666 if ( !empty($add_ons_need_higher_version) ) {
1667 $this->fm_compatibility_notice($max_required_version);
1668 }
1669 }
1670
1671 /**
1672 * Incompatibility message.
1673 *
1674 * @param $add_ons_notice
1675 */
1676 function fm_addons_compatibility_notice( $add_ons_notice ) {
1677 $addon_names = implode(', ', $add_ons_notice);
1678 $count = count($add_ons_notice);
1679 $single = __('The current version of %s extension is not compatible with Form Maker. Some functions may not work correctly. Please update the extension to fully use its features.', $this->prefix);
1680 $plural = __('The current version of %s extensions are not compatible with Form Maker. Some functions may not work correctly. Please update the extensions to fully use its features.', $this->prefix);
1681 echo '<div class="error"><p>' . sprintf(_n($single, $plural, $count, $this->prefix), $addon_names) . '</p></div>';
1682 }
1683
1684 function fm_compatibility_notice( $max_required_version ) {
1685 $message = __('Please install %s plugin version %s and higher to start using add-on.', 'form_maker');
1686 echo '<div class="error"><p>' . sprintf($message, 'Form Maker', $max_required_version) . '</p></div>';
1687 }
1688
1689 public function add_query_vars_seo( $vars ) {
1690 $vars[] = 'form_id';
1691
1692 return $vars;
1693 }
1694
1695 /**
1696 * Prevent adding shortcode conflict with some builders.
1697 */
1698 private function before_shortcode_add_builder_editor() {
1699 if ( defined('ELEMENTOR_VERSION') ) {
1700 add_action('elementor/editor/before_enqueue_scripts', array( $this, 'form_maker_admin_ajax' ));
1701 }
1702 if ( class_exists('FLBuilder') ) {
1703 add_action('wp_enqueue_scripts', array( $this, 'form_maker_admin_ajax' ));
1704 }
1705 }
1706
1707 public function webinar_banner() {
1708 // Webinar banner
1709 if ( !class_exists('TWFMWebinar') ) {
1710 require_once($this->plugin_dir . '/framework/TWWebinar.php');
1711 }
1712 new TWFMWebinar(array(
1713 'menu_postfix' => $this->menu_postfix,
1714 'title' => 'Join the Webinar',
1715 'description' => 'How to Create a Fully Functional WP Website with Various Forms in Just an Hour + SPECIAL GIFT FOR WEBINAR ATTENDEES',
1716 'preview_type' => 'youtube',
1717 'preview_url' => 'Ry2hDk3LtPk',
1718 'button_text' => 'SIGN UP',
1719 'button_link' => 'https://my.demio.com/ref/qWIW655LXhVTdRoY',
1720 ));
1721 }
1722
1723 /**
1724 * Stripe events processing logic.
1725 */
1726 public function stripe_events_processing_logic() {
1727 if ( !class_exists('Stripe\Stripe') ) {
1728 require_once WD_FM_STRIPE_DIR . '/stripe/init.php';
1729 }
1730 $payload = @file_get_contents('php://input');
1731 $event = NULL;
1732 try {
1733 $event = \Stripe\Event::constructFrom(json_decode($payload, TRUE));
1734 }
1735 catch ( \UnexpectedValueException $e ) {
1736 // Invalid payload
1737 http_response_code(400);
1738 exit();
1739 }
1740 switch ( $event->type ) {
1741 case 'charge.captured':
1742 $endpoint_object = $event->data->object;
1743 if ( $endpoint_object->captured ) {
1744 global $wpdb;
1745 $group_id = $wpdb->get_var($wpdb->prepare("SELECT group_id FROM " . $wpdb->prefix . "formmaker_submits WHERE element_value = '%s'", $event->data->object->payment_intent));
1746 if ( !class_exists('WD_FM_STRIPE_model') ) {
1747 require_once WD_FM_STRIPE_DIR . '/model.php';
1748 }
1749 $model = new WD_FM_STRIPE_model();
1750 if ( $endpoint_object->amount !== $endpoint_object->amount_captured ) {
1751 $capture_less_data = array(
1752 'amount' => strtoupper($endpoint_object->currency) . " " . $endpoint_object->amount / 100,
1753 'amount_captured' => strtoupper($endpoint_object->currency) . " " . $endpoint_object->amount_captured / 100,
1754 );
1755 }
1756 else {
1757 $capture_less_data = array();
1758 }
1759 $model->update_stripe_status($group_id, $capture_less_data);
1760 }
1761 break;
1762 default:
1763 error_log('Some other event');
1764 }
1765 }
1766
1767 /**
1768 * Register endpoint for stripe events
1769 */
1770 public function register_endpoint_for_stripe_events() {
1771 register_rest_route('form_maker/v1', 'stripe_events', array(
1772 'methods' => "POST",
1773 'callback' => array( $this, 'stripe_events_processing_logic' ),
1774 'permission_callback' => '__return_true',
1775 ));
1776 }
1777 }
1778
1779 /**
1780 * Main instance of WDFM.
1781 *
1782 * @return WDFM The main instance to prevent the need to use globals.
1783 */
1784 if ( !function_exists('WDFMInstance') ) {
1785 function WDFMInstance( $version ) {
1786 if ( $version == 2 ) {
1787 return WDCFM::instance();
1788 }
1789
1790 return WDFM::instance();
1791 }
1792 }
1793 WDFMInstance(1);
1794 if ( !function_exists('WDW_FM_Library') ) {
1795 function WDW_FM_Library( $version = 1 ) {
1796 if ( $version == 2 ) {
1797 return WDW_FMC_Library::instance();
1798 }
1799
1800 return WDW_FM_Library::instance();
1801 }
1802 }
1803 /**
1804 * Form maker output.
1805 *
1806 * @param $id
1807 * @param string $type
1808 */
1809 function wd_form_maker( $id, $type = 'embedded' ) {
1810 require_once(WDFMInstance(1)->plugin_dir . '/frontend/controllers/form_maker.php');
1811 $controller = new FMControllerForm_maker();
1812 $form = $controller->execute($id, $type);
1813 echo $form;
1814 }
1815
1816 function fm_add_plugin_meta_links( $meta_fields, $file ) {
1817 if ( plugin_basename(__FILE__) == $file ) {
1818 $plugin_url = "https://wordpress.org/support/plugin/form-maker";
1819 $prefix = WDFMInstance(1)->prefix;
1820 $meta_fields[] = "<a href='" . $plugin_url . "/#new-post' target='_blank'>" . __('Ask a question', $prefix) . "</a>";
1821 $meta_fields[] = "<a href='" . $plugin_url . "/reviews#new-post' target='_blank' title='" . __('Rate', $prefix) . "'>
1822 <i class='wdi-rate-stars'>"
1823 . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
1824 . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
1825 . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
1826 . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
1827 . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
1828 . "</i></a>";
1829
1830 $stars_color = "#ffb900";
1831
1832 echo "<style>"
1833 . ".wdi-rate-stars{display:inline-block;color:" . $stars_color . ";position:relative;top:3px;}"
1834 . ".wdi-rate-stars svg{fill:" . $stars_color . ";}"
1835 . ".wdi-rate-stars svg:hover{fill:" . $stars_color . "}"
1836 . ".wdi-rate-stars svg:hover ~ svg{fill:none;}"
1837 . "</style>";
1838 }
1839
1840 return $meta_fields;
1841 }
1842
1843 if ( WDFMInstance(1)->is_free ) {
1844 add_filter("plugin_row_meta", 'fm_add_plugin_meta_links', 10, 2);
1845 }
1846
1847 require_once(WP_PLUGIN_DIR . "/" . plugin_basename(dirname(__FILE__)) . '/booster/init.php');
1848 add_action('init', function() {
1849 TWB(array(
1850 'submenu' => array(
1851 'parent_slug' => 'manage_fm',
1852 'title' => 'Speed Optimization',
1853 ),
1854 'page' => array(
1855 'slug' => 'form-maker',
1856 'section_booster_title' => 'Optimize forms and increase your conversions',
1857 'section_booster_desc' => 'Use the free 10Web Booster plugin to automatically optimize pages with forms and boost performance.',
1858 'section_booster_success_title' => 'Optimize pages with forms',
1859 'section_booster_success_desc' => 'Improve website performance',
1860 'section_optimize_images' => FALSE,
1861 'section_analyze_desc' => 'Speed up your website and increase conversions by optimizing all pages that include forms.',
1862 ),
1863 ));
1864 }, 11);
1865