PluginProbe
Form Maker by 10Web – Mobile-Friendly Drag & Drop Contact Form Builder / 1.13.7
Form Maker by 10Web – Mobile-Friendly Drag & Drop Contact Form Builder v1.13.7
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.13.7, at form-maker.php

1,830 lines 93.0 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/
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.13.7
7 * Author: 10Web Form Builder Team
8 * Author URI: https://10web.io/plugins/
9 * License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
10 */
11
12 defined('ABSPATH') || die('Access Denied');
13
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 /**
25 * Plugin directory path.
26 */
27 public $plugin_dir = '';
28 /**
29 * Plugin directory url.
30 */
31 public $plugin_url = '';
32 /**
33 * Plugin front urls.
34 */
35 public $front_urls = array();
36 /**
37 * Plugin main file.
38 */
39 public $main_file = '';
40 /**
41 * Plugin version.
42 */
43 public $plugin_version = '';
44 /**
45 * Plugin database version.
46 */
47 public $db_version = '';
48 /**
49 * Plugin menu slug.
50 */
51 public $menu_slug = '';
52 /**
53 * Plugin menu slug.
54 */
55 public $prefix = '';
56 public $css_prefix = '';
57 public $js_prefix = '';
58
59 public $nicename = '';
60 public $nonce = 'nonce_fm';
61 public $fm_form_nonce = 'fm_form_nonce%d';
62 public $is_free = 1;
63 public $is_demo = false;
64 public $fm_settings = array();
65
66 /**
67 * Main WDFM Instance.
68 *
69 * Ensures only one instance is loaded or can be loaded.
70 *
71 * @static
72 * @return WDFM - Main instance.
73 */
74 public static function instance() {
75 if ( is_null( self::$_instance ) ) {
76 self::$_instance = new self();
77 }
78 return self::$_instance;
79 }
80
81 public function __construct() {
82 $this->define_constants();
83 require_once($this->plugin_dir . '/framework/WDW_FM_Library.php');
84 if (is_admin()) {
85 require_once(wp_normalize_path($this->plugin_dir . '/admin/controllers/controller.php'));
86 require_once(wp_normalize_path($this->plugin_dir . '/admin/models/model.php'));
87 require_once(wp_normalize_path($this->plugin_dir . '/admin/views/view.php'));
88 }
89 $this->add_actions();
90 }
91
92 /**
93 * Define Constants.
94 */
95 private function define_constants() {
96 $this->plugin_dir = WP_PLUGIN_DIR . "/" . plugin_basename(dirname(__FILE__));
97 $this->plugin_url = plugins_url(plugin_basename(dirname(__FILE__)));
98 $this->front_urls = $this->get_front_urls();
99 $this->main_file = plugin_basename(__FILE__);
100 $this->plugin_version = '1.13.7';
101 $this->db_version = '2.13.7';
102 $this->menu_postfix = ($this->is_free == 2 ? '_fmc' : '_fm');
103 $this->plugin_postfix = ($this->is_free == 2 ? '_fmc' : '');
104 $this->menu_slug = 'manage' . $this->menu_postfix;
105 $this->prefix = 'form_maker' . $this->plugin_postfix;
106 $this->css_prefix = 'fm_';
107 $this->js_prefix = 'fm_';
108 $this->handle_prefix = ($this->is_free == 2 ? 'fmc' : 'fm');
109 $this->nicename = ($this->is_free == 2 ? __('Contact Form', $this->prefix) : __('Form Maker', $this->prefix));
110 $this->slug = ($this->is_free == 2 ? 'contact-form-maker' : 'form-maker');
111 $this->fm_settings = get_option( $this->handle_prefix . '_settings' );
112 if ( empty($this->fm_settings['fm_developer_mode']) ) {
113 $this->fm_settings['fm_developer_mode'] = 0;
114 }
115 }
116
117 /**
118 * Add actions.
119 */
120 private function add_actions() {
121 add_action('init', array($this, 'init'), 9);
122 add_action('admin_menu', array( $this, 'form_maker_options_panel' ) );
123
124 add_action('wp_ajax_manage' . $this->menu_postfix, array($this, 'form_maker_ajax')); //Post/page search on display options pages.
125 add_action('wp_ajax_get_stats' . $this->plugin_postfix, array($this, 'form_maker')); //Show statistics
126 add_action('wp_ajax_generete_csv' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Export csv.
127 add_action('wp_ajax_generete_xml' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Export xml.
128 add_action('wp_ajax_formmakerwdcaptcha' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Generete captcha image and save it code in session.
129 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.
130 add_action('wp_ajax_formmakerwdmathcaptcha' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Generete math captcha image and save it code in session.
131 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.
132 add_action('wp_ajax_product_option' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Open product options on add paypal field.
133 add_action('wp_ajax_FormMakerEditCountryinPopup' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Open country list.
134 add_action('wp_ajax_FormMakerMapEditinPopup' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Open map in submissions.
135 add_action('wp_ajax_FormMakerIpinfoinPopup' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Open ip in submissions.
136 add_action('wp_ajax_show_matrix' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Edit matrix in submissions.
137 add_action('wp_ajax_FormMakerSubmits' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Open submissions in submissions.
138
139 if ( !$this->is_demo ) {
140 add_action('wp_ajax_FormMakerSQLMapping' . $this->plugin_postfix, array($this, 'form_maker_ajax')); // Add/Edit SQLMaping from form options.
141 add_action('wp_ajax_select_data_from_db' . $this->plugin_postfix, array( $this, 'form_maker_ajax' )); // select data from db.
142 }
143
144 add_action('wp_ajax_manage' . $this->plugin_postfix, array($this, 'form_maker_ajax')); //Show statistics
145
146 if ( !$this->is_free ) {
147 add_action('wp_ajax_paypal_info', array($this, 'form_maker_ajax')); // Paypal info in submissions page.
148 add_action('wp_ajax_checkpaypal', array($this, 'form_maker_ajax')); // Notify url from Paypal Sandbox.
149 add_action('wp_ajax_nopriv_checkpaypal', array($this, 'form_maker_ajax')); // Notify url from Paypal Sandbox for all users.
150 add_action('wp_ajax_get_frontend_stats', array($this, 'form_maker_ajax_frontend')); //Show statistics frontend
151 add_action('wp_ajax_nopriv_get_frontend_stats', array($this, 'form_maker_ajax_frontend')); //Show statistics frontend
152 add_action('wp_ajax_frontend_show_map', array($this, 'form_maker_ajax_frontend')); //Show map frontend
153 add_action('wp_ajax_nopriv_frontend_show_map', array($this, 'form_maker_ajax_frontend')); //Show map frontend
154 add_action('wp_ajax_frontend_show_matrix', array($this, 'form_maker_ajax_frontend')); //Show matrix frontend
155 add_action('wp_ajax_nopriv_frontend_show_matrix', array($this, 'form_maker_ajax_frontend')); //Show matrix frontend
156 add_action('wp_ajax_frontend_paypal_info', array($this, 'form_maker_ajax_frontend')); //Show paypal info frontend
157 add_action('wp_ajax_nopriv_frontend_paypal_info', array($this, 'form_maker_ajax_frontend')); //Show paypal info frontend
158 add_action('wp_ajax_frontend_generate_csv', array($this, 'form_maker_ajax_frontend')); //generate csv frontend
159 add_action('wp_ajax_nopriv_frontend_generate_csv', array($this, 'form_maker_ajax_frontend')); //generate csv frontend
160 add_action('wp_ajax_frontend_generate_xml', array($this, 'form_maker_ajax_frontend')); //generate xml frontend
161 add_action('wp_ajax_nopriv_frontend_generate_xml', array($this, 'form_maker_ajax_frontend')); //generate xml frontend
162 }
163 add_action('wp_ajax_fm_reload_input', array($this, 'form_maker_ajax_frontend'));
164 add_action('wp_ajax_nopriv_fm_reload_input', array($this, 'form_maker_ajax_frontend'));
165
166 // Add media button to WP editor.
167 add_action('wp_ajax_FMShortocde' . $this->plugin_postfix, array($this, 'form_maker_ajax'));
168 add_filter('media_buttons_context', array($this, 'media_button'));
169
170 add_action('admin_head', array($this, 'form_maker_admin_ajax'));//js variables for admin.
171
172 // Form maker shortcodes.
173 if ( !is_admin() ) {
174 add_shortcode('FormPreview' . $this->plugin_postfix, array($this, 'fm_form_preview_shortcode'));
175 if ($this->is_free != 2) {
176 add_shortcode('Form', array($this, 'fm_shortcode'));
177 }
178 if (!($this->is_free == 1)) {
179 add_shortcode('contact_form', array($this, 'fm_shortcode'));
180 add_shortcode('wd_contact_form', array($this, 'fm_shortcode'));
181 }
182 add_shortcode('email_verification' . $this->plugin_postfix, array($this, 'fm_email_verification_shortcode'));
183 }
184 // Action to display not emedded type forms.
185 global $pagenow;
186 if (!is_admin() || !in_array($pagenow, array('wp-login.php', 'wp-register.php'))) {
187 add_action('wp_footer', array($this, 'FM_front_end_main'));
188 }
189
190 // Form Maker Widget.
191 if (class_exists('WP_Widget')) {
192 add_action('widgets_init', array($this, 'register_widgets'));
193 }
194
195 // Plugin activation.
196 register_activation_hook(__FILE__, array($this, 'global_activate'));
197 add_action('wpmu_new_blog', array($this, 'new_blog_added'), 10, 6);
198
199 if ( (!isset($_GET['action']) || $_GET['action'] != 'deactivate')
200 && (!isset($_GET['page']) || $_GET['page'] != 'uninstall' . $this->menu_postfix) ) {
201 add_action('admin_init', array($this, 'form_maker_activate'));
202 }
203
204 // Register scripts/styles.
205 add_action('wp_enqueue_scripts', array($this, 'register_frontend_scripts'));
206 add_action('admin_enqueue_scripts', array($this, 'register_admin_scripts'));
207
208 // Set per_page option for submissions.
209 add_filter('set-screen-option', array($this, 'set_option_submissions'), 10, 3);
210
211 // Check extensions versions.
212 if ( $this->is_free != 2 && isset( $_GET[ 'page' ] ) && strpos( esc_html( $_GET[ 'page' ] ), '_' . $this->handle_prefix ) !== FALSE ) {
213 add_action('admin_notices', array($this, 'fm_check_addons_compatibility'));
214 }
215
216 add_action('plugins_loaded', array($this, 'plugins_loaded'), 9);
217
218 add_filter('wpseo_whitelist_permalink_vars', array($this, 'add_query_vars_seo'));
219
220 // Enqueue block editor assets for Gutenberg.
221 add_filter('tw_get_block_editor_assets', array($this, 'register_block_editor_assets'));
222 add_filter('tw_get_plugin_blocks', array($this, 'register_plugin_block'));
223 add_action( 'enqueue_block_editor_assets', array($this, 'enqueue_block_editor_assets') );
224
225 // Privacy policy.
226 add_action( 'admin_init', array($this, 'add_privacy_policy_content') );
227
228 // Personal data export.
229 add_filter( 'wp_privacy_personal_data_exporters', array($this, 'register_privacy_personal_data_exporter') );
230 // Personal data erase.
231 add_filter( 'wp_privacy_personal_data_erasers', array($this, 'register_privacy_personal_data_eraser') );
232
233 // Register widget for Elementor builder.
234 add_action('elementor/widgets/widgets_registered', array($this, 'register_elementor_widget'));
235 // Register 10Web category for Elementor widget if 10Web builder doesn't installed.
236 add_action('elementor/elements/categories_registered', array($this, 'register_widget_category'), 1, 1);
237 //fires after elementor editor styles and scripts are enqueued.
238 add_action('elementor/editor/after_enqueue_styles', array($this, 'enqueue_editor_styles'), 11);
239 }
240
241 public function enqueue_editor_styles() {
242 wp_enqueue_style($this->handle_prefix . '-icons', $this->plugin_url . '/fonts/style.css', array(), '1.0.0');
243 }
244
245 /**
246 * Register widget for Elementor builder.
247 */
248 public function register_elementor_widget() {
249 if ( defined('ELEMENTOR_PATH') && class_exists('Elementor\Widget_Base') ) {
250 require_once ($this->plugin_dir . '/admin/controllers/elementorWidget.php');
251 }
252 }
253
254 /**
255 * Register 10Web category for Elementor widget if 10Web builder doesn't installed.
256 *
257 * @param $elements_manager
258 */
259 public function register_widget_category( $elements_manager ) {
260 $elements_manager->add_category('tenweb-plugins-widgets', array(
261 'title' => __('10WEB Plugins', 'tenweb-builder'),
262 'icon' => 'fa fa-plug',
263 ));
264 }
265
266 function add_privacy_policy_content() {
267 if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) {
268 return;
269 }
270
271 $content = __( 'When you leave a comment on this site, we send your name, email
272 address, IP address and comment text to example.com. Example.com does
273 not retain your personal data.', WDFMInstance(self::PLUGIN)->prefix );
274
275 wp_add_privacy_policy_content(
276 WDFMInstance(self::PLUGIN)->nicename,
277 wp_kses_post( wpautop( $content, false ) )
278 );
279 }
280
281 public function register_privacy_personal_data_exporter( $exporters ) {
282 $exporters[ $this->slug ] = array(
283 'exporter_friendly_name' => $this->nicename,
284 'callback' => array( WDW_FM_Library(self::PLUGIN), 'privacy_personal_data_export' ),
285 );
286 return $exporters;
287 }
288
289 public function register_privacy_personal_data_eraser( $erasers ) {
290 $erasers[ $this->slug ] = array(
291 'eraser_friendly_name' => $this->nicename,
292 'callback' => array( WDW_FM_Library(self::PLUGIN), 'privacy_personal_data_erase' ),
293 );
294 return $erasers;
295 }
296
297 public function register_block_editor_assets($assets) {
298 $version = '2.0.3';
299 $js_path = $this->plugin_url . '/js/tw-gb/block.js';
300 $css_path = $this->plugin_url . '/css/tw-gb/block.css';
301 if (!isset($assets['version']) || version_compare($assets['version'], $version) === -1) {
302 $assets['version'] = $version;
303 $assets['js_path'] = $js_path;
304 $assets['css_path'] = $css_path;
305 }
306 return $assets;
307 }
308
309 public function register_plugin_block($blocks) {
310 if ($this->is_free == 2) {
311 $key = 'tw/contact-form-maker';
312 $key_submissions = 'tw/cfm-submissions';
313 }
314 else {
315 $key = 'tw/form-maker';
316 $key_submissions = 'tw/fm-submissions';
317 }
318 $fm_nonce = wp_create_nonce('fm_ajax_nonce');
319 $plugin_name = $this->nicename;
320 $plugin_name_submissions = __('Submissions', WDFMInstance(self::PLUGIN)->prefix);
321 $icon_url = $this->plugin_url . '/images/tw-gb/icon_colored.svg';
322 $icon_svg = $this->plugin_url . '/images/tw-gb/icon.svg';
323 $url = add_query_arg(array('action' => 'FMShortocde' . $this->plugin_postfix, 'task' => 'submissions', 'nonce' => $fm_nonce), admin_url('admin-ajax.php'));
324 $data = WDW_FM_Library(self::PLUGIN)->get_shortcode_data();
325 $blocks[$key] = array(
326 'title' => $plugin_name,
327 'titleSelect' => sprintf(__('Select %s', $this->prefix), $plugin_name),
328 'iconUrl' => $icon_url,
329 'iconSvg' => array('width' => 20, 'height' => 20, 'src' => $icon_svg),
330 'isPopup' => false,
331 'data' => $data,
332 );
333 $blocks[$key_submissions] = array(
334 'title' => $plugin_name_submissions,
335 'titleSelect' => sprintf(__('Select %s', $this->prefix), $plugin_name),
336 'iconUrl' => $icon_url,
337 'iconSvg' => array('width' => 20, 'height' => 20, 'src' => $icon_svg),
338 'isPopup' => true,
339 'containerClass' => 'tw-container-wrap-520-400',
340 'data' => array('shortcodeUrl' => $url),
341 );
342 return $blocks;
343 }
344
345 public function enqueue_block_editor_assets() {
346 // Remove previously registered or enqueued versions
347 $wp_scripts = wp_scripts();
348 foreach ($wp_scripts->registered as $key => $value) {
349 // Check for an older versions with prefix.
350 if (strpos($key, 'tw-gb-block') > 0) {
351 wp_deregister_script( $key );
352 wp_deregister_style( $key );
353 }
354 }
355 // Get plugin blocks from all 10Web plugins.
356 $blocks = apply_filters('tw_get_plugin_blocks', array());
357 // Get the last version from all 10Web plugins.
358 $assets = apply_filters('tw_get_block_editor_assets', array());
359 // Not performing unregister or unenqueue as in old versions all are with prefixes.
360 wp_enqueue_script('tw-gb-block', $assets['js_path'], array( 'wp-blocks', 'wp-element' ), $assets['version']);
361 wp_localize_script('tw-gb-block', 'tw_obj_translate', array(
362 'nothing_selected' => __('Nothing selected.', $this->prefix),
363 'empty_item' => __('- Select -', $this->prefix),
364 'blocks' => json_encode($blocks)
365 ));
366 wp_enqueue_style('tw-gb-block', $assets['css_path'], array( 'wp-edit-blocks' ), $assets['version']);
367 }
368
369 /**
370 * Wordpress init actions.
371 */
372 public function init() {
373 ob_start();
374 $this->fm_overview();
375
376 // Register fmemailverification post type
377 $this->register_fmemailverification_cpt();
378
379 // Register fmformpreview post type
380 $this->register_form_preview_cpt();
381 }
382
383 /**
384 * Plugins loaded actions.
385 */
386 public function plugins_loaded() {
387 // Languages localization.
388 load_plugin_textdomain($this->prefix, FALSE, basename(dirname(__FILE__)) . '/languages');
389
390 if ($this->is_free != 2 && !function_exists('WDFM')) {
391 require_once($this->plugin_dir . '/WDFM.php');
392 }
393
394 // Initialize extensions.
395 if ($this->is_free != 2) {
396 do_action('fm_init_addons');
397 }
398 // Prevent adding shortcode conflict with some builders.
399 $this->before_shortcode_add_builder_editor();
400 }
401
402 /**
403 * Plugin menu.
404 */
405 public function form_maker_options_panel() {
406 $parent_slug = !$this->is_free ? $this->menu_slug : null;
407 if( !$this->is_free || ($this->is_free == 1 && get_option( "fm_subscribe_done" ) == 1) || ($this->is_free == 2 && get_option( "cfm_subscribe_done" ) == 1) ) {
408 add_menu_page($this->nicename, $this->nicename, 'manage_options', $this->menu_slug, array( $this, 'form_maker' ), $this->plugin_url . '/images/FormMakerLogo-16.png');
409 $parent_slug = $this->menu_slug;
410 }
411 add_submenu_page($parent_slug, __('Forms', $this->prefix), __('Forms', $this->prefix), 'manage_options', $this->menu_slug, array($this, 'form_maker'));
412 $submissions_page = add_submenu_page($parent_slug, __('Submissions', $this->prefix), __('Submissions', $this->prefix), 'manage_options', 'submissions' . $this->menu_postfix, array($this, 'form_maker'));
413 add_action('load-' . $submissions_page, array($this, 'submissions_per_page'));
414
415 add_submenu_page(null, __('Blocked IPs', $this->prefix), __('Blocked IPs', $this->prefix), 'manage_options', 'blocked_ips' . $this->menu_postfix, array($this, 'form_maker'));
416 add_submenu_page($parent_slug, __('Themes', $this->prefix), __('Themes', $this->prefix), 'manage_options', 'themes' . $this->menu_postfix, array($this, 'form_maker'));
417 add_submenu_page($parent_slug, __('Options', $this->prefix), __('Options', $this->prefix), 'manage_options', 'options' . $this->menu_postfix, array($this, 'form_maker'));
418 add_submenu_page(null, __('Uninstall', $this->prefix), __('Uninstall', $this->prefix), 'manage_options', 'uninstall' . $this->menu_postfix, array($this, 'form_maker'));
419 }
420
421 /**
422 * Set front plugin url.
423 *
424 * return string $plugin_url
425 */
426 private function set_front_plugin_url() {
427 $plugin_url = plugins_url(plugin_basename(dirname(__FILE__)));
428
429 return $plugin_url;
430 }
431
432 /**
433 * Set front upload url.
434 *
435 * return string $upload_url
436 */
437 private function set_front_upload_url() {
438 $wp_upload_dir = wp_upload_dir();
439 $upload_url = $wp_upload_dir['baseurl'];
440 $http = 'http://';
441 $https = 'https://';
442 if ( $_SERVER['SERVER_PORT'] == 443 || strpos(get_option('home'), $https) > -1 ) {
443 $upload_url = str_replace($http, $https, $wp_upload_dir['baseurl']);
444 }
445
446 return $upload_url;
447 }
448
449 /**
450 * Get front urls.
451 *
452 * return array $urls
453 */
454 public function get_front_urls() {
455 $urls = array();
456 $urls['plugin_url'] = $this->set_front_plugin_url();
457 $urls['upload_url'] = $this->set_front_upload_url();
458
459 return $urls;
460 }
461
462 /**
463 * Add per_page screen option for submissions page.
464 */
465 function submissions_per_page() {
466 $option = 'per_page';
467 $args_rates = array(
468 'label' => __('Number of items per page:', $this->prefix),
469 'default' => 20,
470 'option' => 'fm_submissions_per_page'
471 );
472 add_screen_option( $option, $args_rates );
473 }
474
475 /**
476 * Set per_page option for submissions page.
477 *
478 * @param $status
479 * @param $option
480 * @param $value
481 * @return mixed
482 */
483 function set_option_submissions($status, $option, $value) {
484 if ( 'fm_submissions_per_page' == $option ) return $value;
485 return $status;
486 }
487
488 /**
489 * Output for admin pages.
490 */
491 public function form_maker() {
492 if (function_exists('current_user_can')) {
493 if (!current_user_can('manage_options')) {
494 die('Access Denied');
495 }
496 }
497 else {
498 die('Access Denied');
499 }
500 $page = WDW_FM_Library(self::PLUGIN)->get('page');
501 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))) {
502 $page = ucfirst(substr($page, 0, strlen($page) - strlen($this->menu_postfix)));
503 echo '<div id="fm_loading"></div>';
504 echo '<div id="fm_admin_container" class="fm-form-container" style="display: none;">';
505 try {
506 require_once ($this->plugin_dir . '/admin/controllers/' . $page . '_fm.php');
507 $controller_class = 'FMController' . $page . $this->menu_postfix;
508 $controller = new $controller_class();
509 $controller->execute();
510 } catch (Exception $e) {
511 ob_start();
512 debug_print_backtrace();
513 error_log(ob_get_clean());
514 }
515 echo '</div>';
516 }
517 }
518
519 /**
520 * Register widgets.
521 */
522 public function register_widgets() {
523 require_once($this->plugin_dir . '/admin/controllers/Widget.php');
524 register_widget('FMControllerWidget' . $this->plugin_postfix);
525 }
526
527 /**
528 * Register Admin styles/scripts.
529 */
530 public function register_admin_scripts() {
531 $fm_settings = WDFMInstance(self::PLUGIN)->fm_settings;
532 // Admin styles.
533 wp_register_style($this->handle_prefix . '-tables', $this->plugin_url . '/css/form_maker_tables.css', array(), $this->plugin_version);
534 wp_register_style($this->handle_prefix . '-phone_field_css', $this->plugin_url . '/css/intlTelInput.css', array(), $this->plugin_version);
535 wp_register_style($this->handle_prefix . '-jquery-ui', $this->plugin_url . '/css/jquery-ui.custom.css', array(), $this->plugin_version);
536 wp_register_style($this->handle_prefix . '-codemirror', $this->plugin_url . '/css/codemirror.css', array(), $this->plugin_version);
537 wp_register_style($this->handle_prefix . '-layout', $this->plugin_url . '/css/form_maker_layout.css', array(), $this->plugin_version);
538 wp_register_style($this->handle_prefix . '-bootstrap', $this->plugin_url . '/css/fm-bootstrap.css', array(), $this->plugin_version);
539 wp_register_style($this->handle_prefix . '-colorpicker', $this->plugin_url . '/css/spectrum.css', array(), $this->plugin_version);
540 // Roboto font for top bar.
541 wp_register_style($this->handle_prefix . '-roboto', 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700');
542
543 if ( !$this->is_free ) {
544 wp_register_style('jquery.fancybox', $this->plugin_url . '/js/fancybox/jquery.fancybox.css', array(), '2.1.5');
545 }
546 // Admin scripts.
547 $localize_key_all = $this->handle_prefix . '-admin';
548 $localize_key_manage = $this->handle_prefix . '-manage';
549 $localize_key_add_fields = $this->handle_prefix . '-add-fields';
550 $localize_key_formmaker_div = $this->handle_prefix . '-formmaker_div';
551
552 if ( ! $fm_settings['fm_developer_mode'] ) {
553 $localize_key_all = $this->handle_prefix . ( ( WDW_FM_Library(self::PLUGIN)->get('page') == 'submissions_' . $this->handle_prefix ) ? '-submission' : '-scripts');
554 $localize_key_manage .= '-edit';
555 $localize_key_add_fields = $localize_key_manage;
556 $localize_key_formmaker_div = $localize_key_manage;
557 wp_register_style($this->handle_prefix . '-styles', $this->plugin_url . '/css/fm-styles.min.css', array(), $this->plugin_version);
558 wp_register_script($this->handle_prefix . '-scripts', $this->plugin_url . '/js/fm-scripts.min.js', array(), $this->plugin_version);
559
560 wp_register_style($this->handle_prefix . '-manage', $this->plugin_url . '/css/manage-styles.min.css', array(), $this->plugin_version);
561 wp_register_script($this->handle_prefix . '-manage', $this->plugin_url . '/js/manage-scripts.min.js', array(), $this->plugin_version);
562
563 wp_register_style($this->handle_prefix . '-manage-edit', $this->plugin_url . '/css/manage-edit-styles.min.css', array(), $this->plugin_version);
564 wp_register_script($this->handle_prefix . '-manage-edit', $this->plugin_url . '/js/manage-edit-scripts.min.js', array(), $this->plugin_version);
565
566 wp_register_style($this->handle_prefix . '-submission', $this->plugin_url . '/css/submission-styles.min.css', array(), $this->plugin_version);
567 wp_register_script($this->handle_prefix . '-submission', $this->plugin_url . '/js/submission-scripts.min.js', array(), $this->plugin_version);
568
569 wp_register_style($this->handle_prefix . '-theme-edit', $this->plugin_url . '/css/theme-edit-styles.min.css', array(), $this->plugin_version);
570 wp_register_script($this->handle_prefix . '-theme-edit', $this->plugin_url . '/js/theme-edit-scripts.min.js', array(), $this->plugin_version);
571 }
572
573 $google_map_key = !empty($fm_settings['map_key']) ? '&key=' . $fm_settings['map_key'] : '';
574 wp_register_script('google-maps', 'https://maps.google.com/maps/api/js?v=3.exp' . $google_map_key);
575 wp_register_script($this->handle_prefix . '-gmap_form', $this->plugin_url . '/js/if_gmap_back_end.js', array(), $this->plugin_version);
576
577 wp_register_script($this->handle_prefix . '-phone_field', $this->plugin_url . '/js/intlTelInput.js', array(), '11.0.0');
578
579 // For drag and drop on mobiles.
580 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');
581
582 wp_register_script($this->handle_prefix . '-admin', $this->plugin_url . '/js/form_maker_admin.js', array(), $this->plugin_version);
583 wp_register_script($localize_key_manage, $this->plugin_url . '/js/form_maker_manage.js', array(), $this->plugin_version);
584 wp_register_script($this->handle_prefix . '-manage-edit', $this->plugin_url . '/js/form_maker_manage_edit.js', array(), $this->plugin_version);
585 wp_register_script($localize_key_formmaker_div, $this->plugin_url . '/js/formmaker_div.js', array(), $this->plugin_version);
586 wp_register_script($this->handle_prefix . '-form-options', $this->plugin_url . '/js/form_maker_form_options.js', array(), $this->plugin_version);
587 wp_register_script($this->handle_prefix . '-form-advanced-layout', $this->plugin_url . '/js/form_maker_form_advanced_layout.js', array(), $this->plugin_version);
588 wp_register_script($localize_key_add_fields, $this->plugin_url . '/js/add_field.js', array($this->handle_prefix . '-formmaker_div'), $this->plugin_version);
589
590 wp_localize_script($localize_key_manage, 'form_maker_manage', array(
591 'add_new_field' => __('Add Field', $this->prefix),
592 'add_column' => __('Add Column', $this->prefix),
593 'required_field' => __('Field is required.', $this->prefix),
594 'not_valid_value' => __('Enter a valid value.', $this->prefix),
595 'not_valid_email' => __('Enter a valid email address.', $this->prefix),
596 ));
597
598 wp_localize_script($localize_key_all, 'form_maker', array(
599 'countries' => WDW_FM_Library(self::PLUGIN)->get_countries(),
600 'delete_confirmation' => __('Do you want to delete selected items?', $this->prefix),
601 'select_at_least_one_item' => __('You must select at least one item.', $this->prefix),
602 'add_placeholder' => __('Add placeholder', $this->prefix),
603 ));
604
605 wp_localize_script($localize_key_add_fields, 'form_maker', array(
606 'countries' => WDW_FM_Library(self::PLUGIN)->get_countries(),
607 'states' => WDW_FM_Library(self::PLUGIN)->get_states(),
608 'provinces' => WDW_FM_Library(self::PLUGIN)->get_provinces_canada(),
609 'plugin_url' => $this->plugin_url,
610 'nothing_found' => __('Nothing found.', $this->prefix),
611 'captcha_created' => __('The captcha already has been created.', $this->prefix),
612 'update' => __('Update', $this->prefix),
613 'add' => __('Add', $this->prefix),
614 'add_field' => __('Add Field', $this->prefix),
615 'edit_field' => __('Edit Field', $this->prefix),
616 'stripe3' => __('To use this feature, please go to Form Options > Payment Options and select "Stripe" as the Payment Method.', $this->prefix),
617 'sunday' => __('Sunday', $this->prefix),
618 'monday' => __('Monday', $this->prefix),
619 'tuesday' => __('Tuesday', $this->prefix),
620 'wednesday' => __('Wednesday', $this->prefix),
621 'thursday' => __('Thursday', $this->prefix),
622 'friday' => __('Friday', $this->prefix),
623 'saturday' => __('Saturday', $this->prefix),
624 'leave_empty' => __('Leave empty to set the width to 100%.', $this->prefix),
625 'is_demo' => $this->is_demo,
626 '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),
627 'no_preview' => __('No preview available for reCAPTCHA.', $this->prefix),
628 '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>' ),
629 '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),
630 '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),
631 '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),
632 '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),
633 '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),
634 '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),
635 '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),
636 '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),
637 '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),
638 '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),
639 '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),
640 '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),
641 '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),
642 '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),
643 '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),
644 '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),
645 '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),
646 '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),
647 '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),
648 '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),
649 '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),
650 '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),
651 'type_slider_description' => __('Slider field lets users specify the field value by dragging its handle from Min Value to Max Value.', $this->prefix),
652 '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),
653 '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),
654 '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),
655 '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),
656 '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),
657 '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),
658 '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),
659 '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),
660 '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),
661 '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),
662 '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),
663 '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),
664 '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),
665 'type_total_description' => __('Please Total field to your payment form to sum up the values of Payment fields. ', $this->prefix),
666 '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),
667 ));
668
669 wp_register_script($this->handle_prefix . '-codemirror', $this->plugin_url . '/js/layout/codemirror.js', array(), '2.3');
670 wp_register_script($this->handle_prefix . '-clike', $this->plugin_url . '/js/layout/clike.js', array(), '1.0.0');
671 wp_register_script($this->handle_prefix . '-formatting', $this->plugin_url . '/js/layout/formatting.js', array(), '1.0.0');
672 wp_register_script($this->handle_prefix . '-css', $this->plugin_url . '/js/layout/css.js', array(), '1.0.0');
673 wp_register_script($this->handle_prefix . '-javascript', $this->plugin_url . '/js/layout/javascript.js', array(), '1.0.0');
674 wp_register_script($this->handle_prefix . '-xml', $this->plugin_url . '/js/layout/xml.js', array(), '1.0.0');
675 wp_register_script($this->handle_prefix . '-php', $this->plugin_url . '/js/layout/php.js', array(), '1.0.0');
676 wp_register_script($this->handle_prefix . '-htmlmixed', $this->plugin_url . '/js/layout/htmlmixed.js', array(), '1.0.0');
677 wp_register_script($this->handle_prefix . '-colorpicker', $this->plugin_url . '/js/spectrum.js', array(), $this->plugin_version);
678 wp_register_script($this->handle_prefix . '-themes', $this->plugin_url . '/js/themes.js', array(), $this->plugin_version);
679 wp_register_script($this->handle_prefix . '-submissions', $this->plugin_url . '/js/form_maker_submissions.js', array(), $this->plugin_version);
680 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');
681 wp_register_script($this->handle_prefix . '-theme-edit-ng', $this->plugin_url . '/js/fm-theme-edit-ng.js', array(), $this->plugin_version);
682
683 if ( !$this->is_free ) {
684 wp_register_script('jquery.fancybox.pack', $this->plugin_url . '/js/fancybox/jquery.fancybox.pack.js', array(), '2.1.5');
685 }
686 else {
687 wp_register_style($this->handle_prefix . '-deactivate-css', $this->plugin_url . '/wd/assets/css/deactivate_popup.css', array(), $this->plugin_version);
688 wp_register_script($this->handle_prefix . '-deactivate-popup', $this->plugin_url . '/wd/assets/js/deactivate_popup.js', array(), $this->plugin_version, true );
689 $admin_data = wp_get_current_user();
690 wp_localize_script( $this->handle_prefix . '-deactivate-popup', ($this->is_free == 2 ? 'cfmWDDeactivateVars' : 'fmWDDeactivateVars'), array(
691 "prefix" => "fm" ,
692 "deactivate_class" => 'fm_deactivate_link',
693 "email" => $admin_data->data->user_email,
694 "plugin_wd_url" => "https://10web.io/plugins/wordpress-form-maker/?utm_source=form_maker&utm_medium=free_plugin",
695 ));
696 }
697 wp_register_style($this->handle_prefix . '-topbar', $this->plugin_url . '/css/topbar.css', array(), $this->plugin_version);
698 wp_register_style($this->handle_prefix . '-icons', $this->plugin_url . '/fonts/style.css', array(), '1.0.0');
699
700 wp_localize_script($localize_key_all, 'fm_ajax', array(
701 'ajaxnonce' => wp_create_nonce('fm_ajax_nonce'),
702 ));
703 wp_localize_script($localize_key_add_fields, 'fm_ajax', array(
704 'ajaxnonce' => wp_create_nonce('fm_ajax_nonce'),
705 ));
706 wp_localize_script($localize_key_formmaker_div, 'fm_ajax', array(
707 'ajaxnonce' => wp_create_nonce('fm_ajax_nonce'),
708 ));
709 }
710
711 /**
712 * Admin ajax scripts.
713 */
714 public function register_admin_ajax_scripts() {
715 $fm_settings = WDFMInstance(self::PLUGIN)->fm_settings;
716 wp_register_style($this->handle_prefix . '-tables', $this->plugin_url . '/css/form_maker_tables.css', array(), $this->plugin_version);
717 wp_register_style($this->handle_prefix . '-jquery-ui', $this->plugin_url . '/css/jquery-ui.custom.css', array(), $this->plugin_version);
718
719 wp_register_script($this->handle_prefix . '-shortcode' . $this->menu_postfix, $this->plugin_url . '/js/shortcode.js', array('jquery'), $this->plugin_version);
720 $google_map_key = !empty($fm_settings['map_key']) ? '&key=' . $fm_settings['map_key'] : '';
721
722 wp_register_script('google-maps', 'https://maps.google.com/maps/api/js?v=3.exp' . $google_map_key);
723 wp_register_script($this->handle_prefix . '-gmap_form', $this->plugin_url . '/js/if_gmap_back_end.js', array(), $this->plugin_version);
724
725 wp_localize_script($this->handle_prefix . '-shortcode' . $this->menu_postfix, 'form_maker', array(
726 'insert_form' => __('You must select a form', $this->prefix),
727 'update' => __('Update', $this->prefix),
728 ));
729 wp_register_style($this->handle_prefix . '-topbar', $this->plugin_url . '/css/topbar.css', array(), $this->plugin_version);
730 // Roboto font for submissions shortcode.
731 wp_register_style($this->handle_prefix . '-roboto', 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700');
732 }
733
734 /**
735 * admin-ajax actions for admin.
736 */
737 public function form_maker_ajax() {
738 $page = WDW_FM_Library(self::PLUGIN)->get('action');
739 $ajax_nonce = WDW_FM_Library(self::PLUGIN)->get('nonce');
740
741 $allowed_pages = array(
742 'manage' . $this->menu_postfix,
743 'manage' . $this->plugin_postfix,
744 'generete_csv' . $this->plugin_postfix,
745 'generete_xml' . $this->plugin_postfix,
746 'formmakerwdcaptcha' . $this->plugin_postfix,
747 'formmakerwdmathcaptcha' . $this->plugin_postfix,
748 'product_option' . $this->plugin_postfix,
749 'FormMakerEditCountryinPopup' . $this->plugin_postfix,
750 'FormMakerMapEditinPopup' . $this->plugin_postfix,
751 'FormMakerIpinfoinPopup' . $this->plugin_postfix,
752 'show_matrix' . $this->plugin_postfix,
753 'FormMakerSubmits' . $this->plugin_postfix,
754 'FMShortocde' . $this->plugin_postfix,
755 );
756 if ( !$this->is_demo ) {
757 $allowed_pages[] = 'FormMakerSQLMapping' . $this->plugin_postfix;
758 $allowed_pages[] = 'select_data_from_db' . $this->plugin_postfix;
759 }
760 if ( !$this->is_free ) {
761 $allowed_pages[] = 'paypal_info';
762 $allowed_pages[] = 'checkpaypal';
763 }
764 $allowed_nonce_pages = array('checkpaypal');
765
766 if ( !in_array($page, $allowed_nonce_pages) && wp_verify_nonce($ajax_nonce , 'fm_ajax_nonce') == FALSE ) {
767 die(-1);
768 }
769
770 if ( !empty($page) && in_array($page, $allowed_pages) ) {
771 if ( $page != 'formmakerwdcaptcha' . $this->plugin_postfix
772 && $page != 'formmakerwdmathcaptcha' . $this->plugin_postfix
773 && $page != 'checkpaypal' ) {
774 if ( function_exists('current_user_can') ) {
775 if ( !current_user_can('manage_options') ) {
776 die('Access Denied');
777 }
778 }
779 else {
780 die('Access Denied');
781 }
782 }
783 $page = ucfirst(substr($page, 0, strlen($page) - strlen($this->plugin_postfix)));
784 $this->register_admin_ajax_scripts();
785 require_once($this->plugin_dir . '/admin/controllers/' . $page . '.php');
786 $controller_class = 'FMController' . $page . $this->plugin_postfix;
787 $controller = new $controller_class();
788 $controller->execute();
789 }
790 }
791
792 /**
793 * admin-ajax actions for site.
794 */
795 public function form_maker_ajax_frontend() {
796 $page = WDW_FM_Library(self::PLUGIN)->get('page');
797 $action = WDW_FM_Library(self::PLUGIN)->get('action');
798 $ajax_nonce = WDW_FM_Library(self::PLUGIN)->get('nonce');
799
800 $allowed_pages = array(
801 'form_submissions',
802 'form_maker',
803 );
804 $allowed_actions = array(
805 'frontend_generate_xml',
806 'frontend_generate_csv',
807 'frontend_paypal_info',
808 'frontend_show_matrix',
809 'frontend_show_map',
810 'get_frontend_stats',
811 'fm_reload_input',
812 );
813
814 if ( wp_verify_nonce($ajax_nonce , 'fm_ajax_nonce') == FALSE ) {
815 die(-1);
816 }
817
818 if ( !empty($page) && in_array($page, $allowed_pages)
819 && !empty($action) && in_array($action, $allowed_actions) ) {
820 $this->register_frontend_ajax_scripts();
821 require_once ($this->plugin_dir . '/frontend/controllers/' . $page . '.php');
822 $controller_class = 'FMController' . ucfirst($page);
823 $controller = new $controller_class();
824 $controller->execute();
825 }
826 }
827
828 /**
829 * Javascript variables for admin.
830 * todo: change to array.
831 */
832 public function form_maker_admin_ajax() {
833 $upload_dir = wp_upload_dir();
834 ?>
835 <script>
836 var fm_site_url = '<?php echo site_url() .'/'; ?>';
837 var admin_url = '<?php echo admin_url('admin.php'); ?>';
838 var plugin_url = '<?php echo $this->plugin_url; ?>';
839 var upload_url = '<?php echo $upload_dir['baseurl']; ?>';
840 var nonce_fm = '<?php echo wp_create_nonce($this->nonce); ?>';
841 // Set shortcode popup dimensions.
842 function fm_set_shortcode_popup_dimensions(tbWidth, tbHeight) {
843 var tbWindow = jQuery('#TB_window'), H = jQuery(window).height(), W = jQuery(window).width(), w, h;
844 w = (tbWidth && tbWidth < W - 90) ? tbWidth : W - 40;
845 h = (tbHeight && tbHeight < H - 60) ? tbHeight : H - 40;
846 if (tbWindow.size()) {
847 tbWindow.width(w).height(h);
848 jQuery('#TB_iframeContent').width(w).height(h - 27);
849 tbWindow.css({'margin-left': '-' + parseInt((w / 2), 10) + 'px'});
850 if (typeof document.body.style.maxWidth != 'undefined') {
851 tbWindow.css({'top': (H - h) / 2, 'margin-top': '0'});
852 }
853 }
854 }
855 </script>
856 <?php
857 }
858
859 /**
860 * Form maker preview shortcode output.
861 *
862 * @return mixed|string
863 */
864 public function fm_form_preview_shortcode() {
865 // check is adminstrator
866 if ( !current_user_can('manage_options') ) {
867 echo __('Sorry, you are not allowed to access this page.', $this->prefix);
868 }
869 else {
870 $id = WDW_FM_Library(self::PLUGIN)->get('wdform_id', 0);
871 $display_options = WDW_FM_Library(self::PLUGIN)->display_options( $id );
872 $type = $display_options->type;
873 $attrs = array( 'id' => $id );
874 if ($type == "embedded") {
875 ob_start();
876 $this->FM_front_end_main($attrs, $type); // embedded popover topbar scrollbox
877 return str_replace(array("\r\n", "\n", "\r"), '', ob_get_clean());
878 }
879 }
880 }
881
882 /**
883 * Form maker shortcode output.
884 *
885 * @param $attrs
886 * @return mixed|string
887 */
888 public function fm_shortcode($attrs) {
889 ob_start();
890 $this->FM_front_end_main($attrs, 'embedded');
891
892 return str_replace(array("\r\n", "\n", "\r"), '', ob_get_clean());
893 }
894
895 /**
896 * Form maker output.
897 *
898 * @param array $params
899 * @param string $type
900 */
901 public function FM_front_end_main($params = array(), $type = '') {
902 if ( !isset($params['type']) ) {
903 $form_id = isset($params['id']) ? (int) $params['id'] : 0;
904 if ($this->is_free == 2) {
905 wd_contact_form_maker($form_id, $type);
906 }
907 else {
908 wd_form_maker( $form_id, $type );
909 }
910 }
911 else if (!$this->is_free) {
912 $shortcode_deafults = array(
913 'id' => 0,
914 'startdate' => '',
915 'enddate' => '',
916 'submit_date' => '',
917 'submitter_ip' => '',
918 'username' => '',
919 'useremail' => '',
920 'form_fields' => '1',
921 'show' => '1,1,1,1,1,1,1,1,1,1',
922 );
923 shortcode_atts($shortcode_deafults, $params);
924
925 require_once($this->plugin_dir . '/frontend/controllers/form_submissions.php');
926 $controller = new FMControllerForm_submissions();
927
928 $submissions = $controller->execute($params);
929
930 echo $submissions;
931 }
932 return;
933 }
934
935 /**
936 * Email verification output.
937 */
938 public function fm_email_verification_shortcode() {
939 require_once($this->plugin_dir . '/frontend/controllers/verify_email.php');
940 $controller_class = 'FMControllerVerify_email' . $this->plugin_postfix;
941 $controller = new $controller_class();
942 $controller->execute();
943 }
944
945 /**
946 * Register email verification custom post type.
947 */
948 public function register_fmemailverification_cpt() {
949 $args = array(
950 'label' => 'FM Mail Verification',
951 'public' => true,
952 'exclude_from_search' => true,
953 'show_in_menu' => false,
954 'show_in_nav_menus' => false,
955 'create_posts' => 'do_not_allow',
956 'capabilities' => array(
957 'create_posts' => FALSE,
958 'edit_post' => 'edit_posts',
959 'read_post' => 'edit_posts',
960 'delete_posts' => FALSE,
961 )
962 );
963
964 register_post_type(($this->is_free == 2 ? 'cfmemailverification' : 'fmemailverification'), $args);
965 }
966
967 /**
968 * Register form preview custom post type.
969 */
970 public function register_form_preview_cpt() {
971 $args = array(
972 'label' => 'FM Preview',
973 'public' => true,
974 'exclude_from_search' => true,
975 'show_in_menu' => false,
976 'show_in_nav_menus' => false,
977 'create_posts' => 'do_not_allow',
978 'capabilities' => array(
979 'create_posts' => FALSE,
980 'edit_post' => 'edit_posts',
981 'read_post' => 'edit_posts',
982 'delete_posts' => FALSE,
983 )
984 );
985
986 register_post_type('form-maker' . $this->plugin_postfix, $args);
987 }
988
989 /**
990 * Frontend scripts/styles.
991 */
992 public function register_frontend_scripts() {
993 $fm_settings = WDFMInstance(self::PLUGIN)->fm_settings;
994 $front_plugin_url = $this->front_urls['plugin_url'];
995
996 $required_scripts = array(
997 'jquery',
998 'jquery-ui-widget',
999 'jquery-effects-shake',
1000 );
1001 $required_styles = array(
1002 WDFMInstance(self::PLUGIN)->handle_prefix . '-googlefonts'
1003 );
1004 if ( $fm_settings['fm_developer_mode'] ) {
1005 array_push($required_styles, $this->handle_prefix . '-jquery-ui', $this->handle_prefix . '-animate');
1006 }
1007
1008 wp_register_style($this->handle_prefix . '-jquery-ui', $front_plugin_url . '/css/jquery-ui.custom.css', array(), $this->plugin_version);
1009 wp_register_style($this->handle_prefix . '-animate', $front_plugin_url . '/css/fm-animate.css', array(), $this->plugin_version);
1010
1011 $google_map_key = !empty($fm_settings['map_key']) ? '&key=' . $fm_settings['map_key'] : '';
1012 wp_register_script('google-maps', 'https://maps.google.com/maps/api/js?v=3.exp' . $google_map_key);
1013
1014 wp_register_script($this->handle_prefix . '-phone_field', $front_plugin_url . '/js/intlTelInput.js', array(), $this->plugin_version);
1015 wp_register_style($this->handle_prefix . '-phone_field_css', $front_plugin_url . '/css/intlTelInput.css', array(), $this->plugin_version);
1016
1017 wp_register_script($this->handle_prefix . '-gmap_form', $front_plugin_url . '/js/if_gmap_front_end.js', array('google-maps'), $this->plugin_version);
1018
1019 $google_fonts = WDW_FM_Library(self::PLUGIN)->get_google_fonts();
1020 $fonts = implode("|", str_replace(' ', '+', $google_fonts));
1021 wp_register_style($this->handle_prefix . '-googlefonts', 'https://fonts.googleapis.com/css?family=' . $fonts . '&subset=greek,latin,greek-ext,vietnamese,cyrillic-ext,latin-ext,cyrillic', null, null);
1022
1023 wp_register_script($this->handle_prefix . '-g-recaptcha', 'https://www.google.com/recaptcha/api.js?onload=fmRecaptchaInit&render=explicit');
1024
1025 // Register admin styles to use in frontend submissions.
1026 wp_register_script('gmap_form_back', $front_plugin_url . '/js/if_gmap_back_end.js', array(), $this->plugin_version);
1027
1028 if ( !$this->is_free ) {
1029 wp_register_script($this->handle_prefix . '-file-upload', $front_plugin_url . '/js/file-upload.js', array(), $this->plugin_version);
1030 wp_register_style($this->handle_prefix . '-submissions_css', $front_plugin_url . '/css/style_submissions.css', array(), $this->plugin_version);
1031
1032 if ( WDW_FM_Library(self::PLUGIN)->elementor_is_active() && $fm_settings['fm_developer_mode'] ) {
1033 array_push($required_styles, $this->handle_prefix . '-submissions_css');
1034 array_push($required_scripts, $this->handle_prefix . '-file-upload', 'gmap_form_back');
1035 }
1036 }
1037
1038 if ( WDW_FM_Library(self::PLUGIN)->elementor_is_active() ) {
1039 array_push($required_scripts,
1040 'jquery-ui-spinner',
1041 'jquery-ui-datepicker',
1042 'jquery-ui-slider'
1043 );
1044
1045 if ( $fm_settings['fm_developer_mode'] ) {
1046 array_push($required_styles, $this->handle_prefix . '-phone_field', WDFMInstance(self::PLUGIN)->handle_prefix . '-gmap_form', WDFMInstance(self::PLUGIN)->handle_prefix . '-phone_field_css');
1047 }
1048 }
1049
1050 $style_file = '/css/styles.min.css';
1051 $script_file = '/js/scripts.min.js';
1052 if ( $fm_settings['fm_developer_mode'] ) {
1053 $style_file = '/css/form_maker_frontend.css';
1054 $script_file = '/js/main_div_front_end.js';
1055 }
1056
1057 wp_register_style($this->handle_prefix . '-frontend', $front_plugin_url . $style_file, $required_styles, $this->plugin_version);
1058 wp_register_script($this->handle_prefix . '-frontend', $front_plugin_url . $script_file, $required_scripts, $this->plugin_version);
1059
1060 if ( WDW_FM_Library(self::PLUGIN)->elementor_is_active() ) {
1061 wp_enqueue_style(WDFMInstance(self::PLUGIN)->handle_prefix . '-frontend');
1062 wp_enqueue_script(WDFMInstance(self::PLUGIN)->handle_prefix . '-frontend');
1063 }
1064
1065 wp_localize_script($this->handle_prefix . '-frontend', 'fm_objectL10n', array(
1066 'states' => WDW_FM_Library(self::PLUGIN)->get_states(),
1067 'provinces' => WDW_FM_Library(self::PLUGIN)->get_provinces_canada(),
1068 'plugin_url' => $front_plugin_url,
1069 'form_maker_admin_ajax' => admin_url('admin-ajax.php'),
1070 'fm_file_type_error' => addslashes(__('Can not upload this type of file', $this->prefix)),
1071 'fm_field_is_required' => addslashes(__('Field is required', $this->prefix)),
1072 'fm_min_max_check_1' => addslashes((__('The ', $this->prefix))),
1073 'fm_min_max_check_2' => addslashes((__(' value must be between ', $this->prefix))),
1074 'fm_spinner_check' => addslashes((__('Value must be between ', $this->prefix))),
1075 'fm_clear_data' => addslashes((__('Are you sure you want to clear saved data?', $this->prefix))),
1076 'fm_grading_text' => addslashes(__('Your score should be less than', $this->prefix)),
1077 'time_validation' => addslashes(__('This is not a valid time value.', $this->prefix)),
1078 'number_validation' => addslashes(__('This is not a valid number value.', $this->prefix)),
1079 'date_validation' => addslashes(__('This is not a valid date value.', $this->prefix)),
1080 'year_validation' => addslashes(sprintf(__('The year must be between %s and %s', $this->prefix), '%%start%%', '%%end%%')),
1081 ));
1082
1083 wp_localize_script($this->handle_prefix . '-frontend', 'fm_ajax', array(
1084 'ajaxnonce' => wp_create_nonce('fm_ajax_nonce'),
1085 ));
1086 }
1087
1088 /**
1089 * Frontend ajax scripts.
1090 */
1091 public function register_frontend_ajax_scripts() {
1092 $fm_settings = WDFMInstance(self::PLUGIN)->fm_settings;
1093 $front_plugin_url = $this->front_urls['plugin_url'];
1094 $google_map_key = !empty($fm_settings['map_key']) ? '&key=' . $fm_settings['map_key'] : '';
1095 wp_register_script('google-maps', 'https://maps.google.com/maps/api/js?v=3.exp' . $google_map_key);
1096 wp_register_script($this->handle_prefix . '-gmap_form_back', $front_plugin_url . '/js/if_gmap_back_end.js', array(), $this->plugin_version);
1097 }
1098
1099 /*
1100 * Global activate.
1101 *
1102 * @param $networkwide
1103 */
1104 public function global_activate($networkwide) {
1105 if ( function_exists('is_multisite') && is_multisite() ) {
1106 // Check if it is a network activation - if so, run the activation function for each blog id.
1107 if ( $networkwide ) {
1108 global $wpdb;
1109 // Get all blog ids.
1110 $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
1111 foreach ( $blogids as $blog_id ) {
1112 switch_to_blog($blog_id);
1113 $this->form_maker_on_activate();
1114 restore_current_blog();
1115 }
1116
1117 return;
1118 }
1119 }
1120 $this->form_maker_on_activate();
1121 }
1122
1123 public function new_blog_added( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
1124 if ( is_plugin_active_for_network( $this->main_file ) ) {
1125 switch_to_blog($blog_id);
1126 $this->form_maker_on_activate();
1127 restore_current_blog();
1128 }
1129 }
1130
1131 /**
1132 * Activate plugin.
1133 */
1134 public function form_maker_on_activate() {
1135 $this->form_maker_activate();
1136 if ($this->is_free == 2) {
1137 WDCFMInsert::install_demo_forms();
1138 }
1139 else {
1140 WDFMInsert::install_demo_forms();
1141 }
1142 $this->init();
1143 flush_rewrite_rules();
1144 }
1145
1146 /**
1147 * Activate plugin.
1148 */
1149 public function form_maker_activate() {
1150 global $wpdb;
1151 if (!$this->is_free) {
1152 deactivate_plugins("contact-form-maker/contact-form-maker.php");
1153 delete_transient('fm_update_check');
1154 }
1155 $version = get_option("wd_form_maker_version");
1156 $new_version = $this->db_version;
1157 $option_key = ($this->is_free == 2 ? 'fmc_settings' : 'fm_settings');
1158 require_once $this->plugin_dir . "/form_maker_insert.php";
1159 if (!$version) {
1160 if ($wpdb->get_var("SHOW TABLES LIKE '" . $wpdb->prefix . "formmaker'") == $wpdb->prefix . "formmaker") {
1161 deactivate_plugins($this->main_file);
1162 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));
1163 }
1164 else {
1165 add_option("wd_form_maker_version", $new_version, '', 'no');
1166 if ($this->is_free == 2) {
1167 WDCFMInsert::form_maker_insert();
1168 }
1169 else {
1170 WDFMInsert::form_maker_insert();
1171 }
1172 $email_verification_post = array(
1173 'post_title' => 'Email Verification',
1174 'post_content' => '[email_verification]',
1175 'post_status' => 'publish',
1176 'post_author' => 1,
1177 'post_type' => ($this->is_free == 2 ? 'cfmemailverification' : 'fmemailverification'),
1178 );
1179 $mail_verification_post_id = wp_insert_post($email_verification_post);
1180 add_option($option_key, array('public_key' => '', 'private_key' => '', 'csv_delimiter' => ',', 'map_key' => '', 'ajax_export_per_page' => 1000));
1181 $wpdb->update($wpdb->prefix . "formmaker", array(
1182 'mail_verification_post_id' => $mail_verification_post_id,
1183 ), array('id' => 1), array(
1184 '%d',
1185 ), array('%d'));
1186 }
1187 }
1188 elseif (version_compare($version, $new_version, '<')) {
1189 $version = substr_replace($version, '1.', 0, 2);
1190 require_once $this->plugin_dir . "/form_maker_update.php";
1191 $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));
1192 if ($mail_verification_post_ids) {
1193 foreach ($mail_verification_post_ids as $mail_verification_post_id) {
1194 $update_email_ver_post_type = array(
1195 'ID' => (int)$mail_verification_post_id->mail_verification_post_id,
1196 'post_type' => ($this->is_free == 2 ? 'cfmemailverification' : 'fmemailverification'),
1197 );
1198 wp_update_post($update_email_ver_post_type);
1199 }
1200 }
1201 if ($this->is_free == 2) {
1202 WDCFMUpdate::form_maker_update($version);
1203 }
1204 else {
1205 WDFMUpdate::form_maker_update($version);
1206 }
1207 update_option("wd_form_maker_version", $new_version);
1208
1209 if ( FALSE === $fm_settings = get_option($option_key) ) {
1210 $recaptcha_keys = $wpdb->get_row('SELECT `public_key`, `private_key` FROM ' . $wpdb->prefix . 'formmaker WHERE public_key!="" and private_key!=""', ARRAY_A);
1211 $public_key = isset($recaptcha_keys['public_key']) ? $recaptcha_keys['public_key'] : '';
1212 $private_key = isset($recaptcha_keys['private_key']) ? $recaptcha_keys['private_key'] : '';
1213 add_option($option_key, array('public_key' => $public_key, 'private_key' => $private_key, 'csv_delimiter' => ',', 'map_key' => '', 'fm_advanced_layout' => 0, 'fm_enable_wp_editor' => 1, 'fm_developer_mode' => 0, 'ajax_export_per_page' => 1000));
1214 }
1215 elseif ( !isset($fm_settings['fm_enable_wp_editor']) ) {
1216 $fm_settings['fm_enable_wp_editor'] = 1;
1217 update_option( $option_key, $fm_settings );
1218 }
1219 if ( !isset($fm_settings['fm_developer_mode']) ) {
1220 $fm_settings['fm_developer_mode'] = 0;
1221 update_option( $option_key, $fm_settings );
1222 }
1223 }
1224 }
1225
1226 /**
1227 * Form maker overview.
1228 */
1229 public function fm_overview() {
1230 if (is_admin() && !isset($_REQUEST['ajax'])) {
1231 if (!class_exists("TenWebLib")) {
1232 $plugin_dir = apply_filters('tenweb_free_users_lib_path', array('version' => '1.1.1', 'path' => $this->plugin_dir));
1233 require_once($plugin_dir['path'] . '/wd/start.php');
1234 }
1235 global $fm_options;
1236 $fm_options = array(
1237 "prefix" => ($this->is_free == 2 ? 'cfm' : 'fm'),
1238 "wd_plugin_id" => ($this->is_free == 2 ? 183 : 31),
1239 "plugin_id" => ($this->is_free == 2 ? 95 : 95),
1240 "plugin_title" => ($this->is_free == 2 ? 'Contact Form Maker' : 'Form Maker'),
1241 "plugin_wordpress_slug" => ($this->is_free == 2 ? 'contact-form-maker' : 'form-maker'),
1242 "plugin_dir" => $this->plugin_dir,
1243 "plugin_main_file" => __FILE__,
1244 "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)),
1245 "plugin_features" => array(
1246 0 => array(
1247 "title" => __("Easy to Use", $this->prefix),
1248 "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),
1249 ),
1250 1 => array(
1251 "title" => __("Customizable Fields", $this->prefix),
1252 "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),
1253 ),
1254 2 => array(
1255 "title" => __("Submissions", $this->prefix),
1256 "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),
1257 ),
1258 3 => array(
1259 "title" => __("Multi-Page Forms", $this->prefix),
1260 "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),
1261 ),
1262 4 => array(
1263 "title" => __("Themes", $this->prefix),
1264 "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),
1265 )
1266 ),
1267 "user_guide" => array(
1268 0 => array(
1269 "main_title" => __("Installing", $this->prefix),
1270 "url" => "https://help.10web.io/hc/en-us/articles/360015435831-Introducing-Form-Maker-Plugin",
1271 "titles" => array()
1272 ),
1273 1 => array(
1274 "main_title" => __("Creating a new Form", $this->prefix),
1275 "url" => "https://help.10web.io/hc/en-us/articles/360015244232-Creating-a-Form-on-WordPress",
1276 "titles" => array()
1277 ),
1278 2 => array(
1279 "main_title" => __("Configuring Form Options", $this->prefix),
1280 "url" => "https://help.10web.io/hc/en-us/articles/360015862812-Settings-General-Options",
1281 "titles" => array()
1282 ),
1283 3 => array(
1284 "main_title" => __("Description of The Form Fields", $this->prefix),
1285 "url" => "https://help.10web.io/hc/en-us/articles/360016081951-Form-Fields-Basic",
1286 "titles" => array(
1287 array(
1288 "title" => __("Selecting Options from Database", $this->prefix),
1289 "url" => "https://help.10web.io/hc/en-us/articles/360015862632-Selecting-Options-from-Database",
1290 ),
1291 )
1292 ),
1293 4 => array(
1294 "main_title" => __("Publishing the Created Form", $this->prefix),
1295 "url" => "https://help.10web.io/hc/en-us/articles/360016083211-Additional-Publishing-Options",
1296 "titles" => array()
1297 ),
1298 5 => array(
1299 "main_title" => __("Blocking IPs", $this->prefix),
1300 "url" => "https://help.10web.io/hc/en-us/articles/360015863292-Managing-Form-Submissions",
1301 "titles" => array()
1302 ),
1303 6 => array(
1304 "main_title" => __("Managing Submissions", $this->prefix),
1305 "url" => "https://help.10web.io/hc/en-us/articles/360015863292-Managing-Form-Submissions",
1306 "titles" => array()
1307 ),
1308 7 => array(
1309 "main_title" => __("Publishing Submissions", $this->prefix),
1310 "url" => "https://help.10web.io/hc/en-us/articles/360016083211-Additional-Publishing-Options",
1311 "titles" => array()
1312 ),
1313 ),
1314 "video_youtube_id" => "vxxKfhxIS44",
1315 "plugin_wd_url" => "https://10web.io/plugins/wordpress-form-maker/?utm_source=form_maker&utm_medium=free_plugin",
1316 "plugin_wd_demo_link" => "https://demo.10web.io/form-maker",
1317 "plugin_wd_addons_link" => "https://10web.io/plugins/wordpress-form-maker/#plugin_extensions",
1318 "plugin_wd_docs_link" => "https://help.10web.io/hc/en-us/sections/360002133951-Form-Maker-Documentation/",
1319 "after_subscribe" => admin_url('admin.php?page=manage_' . ($this->is_free == 2 ? 'cfm' : 'fm')), // this can be plagin overview page or set up page
1320 "plugin_wizard_link" => '',
1321 "plugin_menu_title" => $this->nicename,
1322 "plugin_menu_icon" => $this->plugin_url . '/images/FormMakerLogo-16.png',
1323 "deactivate" => ($this->is_free ? true : false),
1324 "subscribe" => ($this->is_free ? true : false),
1325 "custom_post" => 'manage' . $this->menu_postfix,
1326 "menu_position" => null,
1327 "display_overview" => false,
1328 );
1329
1330 ten_web_lib_init($fm_options);
1331 }
1332 }
1333
1334 /**
1335 * Add media button to Wp editor.
1336 *
1337 * @param $context
1338 *
1339 * @return string
1340 */
1341 function media_button($context) {
1342 $fm_nonce = wp_create_nonce('fm_ajax_nonce');
1343 ob_start();
1344 $url = add_query_arg(array('action' => 'FMShortocde' . $this->plugin_postfix, 'task' => 'forms', 'nonce' => $fm_nonce, 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
1345 ?>
1346 <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); ?>">
1347 <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>
1348 <?php _e('Add Form', $this->prefix); ?>
1349 </a>
1350 <?php
1351 $url = add_query_arg(array('action' => 'FMShortocde' . $this->plugin_postfix, 'task' => 'submissions', 'nonce' => $fm_nonce, 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
1352 ?>
1353 <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); ?>">
1354 <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>
1355 <?php _e('Add Submissions', $this->prefix); ?>
1356 </a>
1357 <?php
1358 $context .= ob_get_clean();
1359
1360 return $context;
1361 }
1362
1363
1364 /**
1365 * Check extensions version compatibility with FM.
1366 *
1367 */
1368 function fm_check_addons_compatibility() {
1369 // Extension last version(version which is compatible with current version of form maker).
1370 $add_ons = array(
1371 'form-maker-calculator' => array('version' => '1.1.2', 'file' => 'fm_calculator.php'),
1372 'form-maker-conditional-emails' => array('version' => '1.1.6', 'file' => 'fm_conditional_emails.php'),
1373 'form-maker-dropbox-integration' => array('version' => '1.2.5', 'file' => 'fm_dropbox_integration.php'),
1374 'form-maker-export-import' => array('version' => '2.0.7', 'file' => 'fm_exp_imp.php'),
1375 'form-maker-gdrive-integration' => array('version' => '1.1.2', 'file' => 'fm_gdrive_integration.php'),
1376 'form-maker-mailchimp' => array('version' => '1.1.6', 'file' => 'fm_mailchimp.php'),
1377 'form-maker-pdf-integration' => array('version' => '1.1.7', 'file' => 'fm_pdf_integration.php'),
1378 'form-maker-post-generation' => array('version' => '1.1.5', 'file' => 'fm_post_generation.php'),
1379 'form-maker-pushover' => array('version' => '1.1.4', 'file' => 'fm_pushover.php'),
1380 'form-maker-reg' => array('version' => '1.2.5', 'file' => 'fm_reg.php'),
1381 'form-maker-save-progress' => array('version' => '1.1.6', 'file' => 'fm_save.php'),
1382 'form-maker-stripe' => array('version' => '1.1.6', 'file' => 'fm_stripe.php'),
1383 );
1384
1385 $add_ons_notice = array();
1386 include_once(ABSPATH . 'wp-admin/includes/plugin.php');
1387
1388 foreach ( $add_ons as $add_on_key => $add_on_value ) {
1389 $addon_path = plugin_dir_path(dirname(__FILE__)) . $add_on_key . '/' . $add_on_value['file'];
1390 if ( is_plugin_active($add_on_key . '/' . $add_on_value['file']) ) {
1391 $addon = get_plugin_data($addon_path); // array
1392 if ( version_compare($addon['Version'], $add_on_value['version'], '<') ) {
1393 // deactivate_plugins($addon_path);
1394 array_push($add_ons_notice, $addon['Name']);
1395 }
1396 }
1397 }
1398
1399 if ( !empty($add_ons_notice) ) {
1400 $this->fm_addons_compatibility_notice($add_ons_notice);
1401 }
1402 }
1403
1404 /**
1405 * Incompatibility message.
1406 *
1407 * @param $add_ons_notice
1408 */
1409 function fm_addons_compatibility_notice($add_ons_notice) {
1410 $addon_names = implode($add_ons_notice, ', ');
1411 $count = count($add_ons_notice);
1412 $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);
1413 $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);
1414 echo '<div class="error"><p>' . sprintf( _n($single, $plural, $count, $this->prefix), $addon_names ) .'</p></div>';
1415 }
1416
1417 public function add_query_vars_seo($vars) {
1418 $vars[] = 'form_id';
1419 return $vars;
1420 }
1421
1422 /**
1423 * Prevent adding shortcode conflict with some builders.
1424 */
1425 private function before_shortcode_add_builder_editor() {
1426 if ( defined('ELEMENTOR_VERSION') ) {
1427 add_action('elementor/editor/before_enqueue_scripts', array( $this, 'form_maker_admin_ajax' ));
1428 }
1429 if ( class_exists('FLBuilder') ) {
1430 add_action('wp_enqueue_scripts', array( $this, 'form_maker_admin_ajax' ));
1431 }
1432 }
1433 }
1434
1435 /**
1436 * Main instance of WDFM.
1437 *
1438 * @return WDFM The main instance to prevent the need to use globals.
1439 */
1440 if (!function_exists('WDFMInstance')) {
1441 function WDFMInstance( $version ) {
1442 if ( $version == 2 ) {
1443 return WDCFM::instance();
1444 }
1445 return WDFM::instance();
1446 }
1447 }
1448
1449 WDFMInstance(1);
1450
1451 if (!function_exists('WDW_FM_Library')) {
1452 function WDW_FM_Library( $version = 1 ) {
1453 if ( $version == 2 ) {
1454 return WDW_FMC_Library::instance();
1455 }
1456 return WDW_FM_Library::instance();
1457 }
1458 }
1459
1460 /**
1461 * Form maker output.
1462 *
1463 * @param $id
1464 * @param string $type
1465 */
1466 function wd_form_maker($id, $type = 'embedded') {
1467 require_once (WDFMInstance(1)->plugin_dir . '/frontend/controllers/form_maker.php');
1468 $controller = new FMControllerForm_maker();
1469 $form = $controller->execute($id, $type);
1470 echo $form;
1471 }
1472
1473 function fm_add_plugin_meta_links($meta_fields, $file) {
1474 if ( plugin_basename(__FILE__) == $file ) {
1475 $plugin_url = "https://wordpress.org/support/plugin/form-maker";
1476 $prefix = WDFMInstance(1)->prefix;
1477 $meta_fields[] = "<a href='" . $plugin_url . "' target='_blank'>" . __('Support Forum', $prefix) . "</a>";
1478 $meta_fields[] = "<a href='" . $plugin_url . "/reviews#new-post' target='_blank' title='" . __('Rate', $prefix) . "'>
1479 <i class='wdi-rate-stars'>"
1480 . "<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>"
1481 . "<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>"
1482 . "<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>"
1483 . "<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>"
1484 . "<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>"
1485 . "</i></a>";
1486
1487 $stars_color = "#ffb900";
1488
1489 echo "<style>"
1490 . ".wdi-rate-stars{display:inline-block;color:" . $stars_color . ";position:relative;top:3px;}"
1491 . ".wdi-rate-stars svg{fill:" . $stars_color . ";}"
1492 . ".wdi-rate-stars svg:hover{fill:" . $stars_color . "}"
1493 . ".wdi-rate-stars svg:hover ~ svg{fill:none;}"
1494 . "</style>";
1495 }
1496
1497 return $meta_fields;
1498 }
1499
1500 if ( WDFMInstance(1)->is_free ) {
1501 add_filter("plugin_row_meta", 'fm_add_plugin_meta_links', 10, 2);
1502 }
1503
1504 /**
1505 * Show 10Web manager plugin install or activate banner.
1506 *
1507 * @return string
1508 */
1509 function wdfm_tenweb_install_notice() {
1510 if ( ( !isset($_GET['page']) || strpos(esc_html($_GET['page']), '_fm') === FALSE ) ||
1511 ( isset($_GET['task']) && !strpos(esc_html($_GET['task']), 'edit') === TRUE && !(strpos(esc_html($_GET['task']), 'display') > -1))) {
1512 return '';
1513 }
1514
1515 // Remove old notice.
1516 if ( get_option('tenweb_notice_status') !== FALSE ) {
1517 update_option('tenweb_notice_status', '1', 'no');
1518 }
1519
1520 $meta_value = get_option('tenweb_notice_status');
1521 if ( $meta_value === '' || $meta_value === FALSE ) {
1522 ob_start();
1523 $prefix = WDFMInstance(1)->prefix;
1524 $url = WDFMInstance(1)->plugin_url;
1525 $dismiss_url = add_query_arg(array( 'action' => 'wd_tenweb_dismiss' ), admin_url('admin-ajax.php'));
1526 $verify_url = add_query_arg( array ('action' => 'fm_tenweb_status'), admin_url('admin-ajax.php'));
1527 ?>
1528 <style>
1529 .hide {
1530 display: none !important;
1531 }
1532 #verifyUrl {
1533 display: none
1534 }
1535 #loading {
1536 position: absolute;
1537 right: 20px;
1538 top: 50%;
1539 transform: translateY(-50%);
1540 margin: 0px;
1541 background: url("<?php echo $url . '/images/spinner.gif'; ?>") no-repeat;
1542 background-size: 20px 20px;
1543 filter: alpha(opacity=70);
1544 }
1545 #wd_tenweb_logo_notice {
1546 height: 32px;
1547 float: left;
1548 }
1549 .error_install, .error_activate {
1550 color: red;
1551 font-size: 10px;
1552 }
1553 /* -------------------Version 2 styles------------------ */
1554 #wpbody-content #v2_tenweb_notice_cont {
1555 display: none;
1556 flex-wrap: wrap;
1557 background: #fff;
1558 box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1);
1559 position: relative;
1560 margin-left: 0px;
1561 padding: 5px 0;
1562 overflow: hidden;
1563 border-left: 4px solid #0073AA;
1564 font-family: Open Sans, sans-serif;
1565 height: 40px;
1566 min-height: 40px;
1567 box-sizing: initial;
1568 }
1569 .v2_logo {
1570 display: flex;
1571 flex-direction: column;
1572 justify-content: center;
1573 height: inherit;
1574 }
1575
1576 #v2_tenweb_notice_cont {
1577 height: 50px;
1578 padding: 0px;
1579 }
1580
1581 .v2_content {
1582 flex-grow: 1;
1583 height: inherit;
1584 margin-left: 34px;
1585 }
1586 .v2_content p{
1587 margin: 0px;
1588 padding: 0px;
1589 }
1590 .v2_content p > span{
1591 font-size: 16px;
1592 color: #333B46;
1593 font-weight: 600;
1594 line-height: 40px;
1595 margin: 0;
1596 }
1597 #wd_tenweb_logo_notice {
1598 margin-left: 35px;
1599 height: 30px;
1600 line-height: 100%;
1601 }
1602
1603 .v2_button {
1604 display: flex;
1605 margin-right: 30px;
1606 flex-direction: column;
1607 justify-content: center;
1608 }
1609
1610 .v2_button #install_now, #activate_now {
1611 width: 112px;
1612 height: 32px;
1613 line-height: 30px;
1614 font-size: 14px;
1615 text-align: center;
1616 padding: 0;
1617 }
1618
1619 #v2_tenweb_notice_cont .wd_tenweb_notice_dissmiss.notice-dismiss {
1620 top: 3px;
1621 right: 3px;
1622 padding: 0px;
1623 }
1624
1625 .v2_button .button {
1626 position: relative;
1627 }
1628
1629 .v2_button .button #loading {
1630 position: absolute;
1631 right: 10px;
1632 top: 50%;
1633 transform: translateY(-50%);
1634 margin: 0px;
1635 background-size: 12px 12px;
1636 filter: alpha(opacity=70);
1637 width: 12px;
1638 height: 12px;
1639 }
1640
1641 @media only screen and (max-width: 1200px) and (min-width: 821px) {
1642 #wpbody-content #v2_tenweb_notice_cont {
1643 height: 50px;
1644 min-height: 50px;
1645 }
1646
1647 #v2_tenweb_notice_cont {
1648 height: 60px;
1649 }
1650
1651 .v2_content {
1652 margin-left: 25px;
1653 }
1654 .v2_content p {
1655 font-size: 14px;
1656 color: #333B46;
1657 font-weight: 600;
1658 line-height: 20px;
1659 margin-top: 5px;
1660 }
1661 .v2_content p span {
1662 display: block;
1663 }
1664
1665 #wd_tenweb_logo_notice {
1666 margin-left: 25px;
1667 height: 30px;
1668 line-height: 100%;
1669 }
1670
1671 .v2_button {
1672 display: flex;
1673 margin-right: 30px;
1674 flex-direction: column;
1675 justify-content: center;
1676 }
1677
1678 .v2_button #install_now {
1679 width: 112px;
1680 height: 32px;
1681 line-height: 30px;
1682 font-size: 14px;
1683 text-align: center;
1684 padding: 0;
1685 }
1686
1687 #v2_tenweb_notice_cont .wd_tenweb_notice_dissmiss.notice-dismiss {
1688 top: 3px;
1689 right: 3px;
1690 }
1691 }
1692
1693 @media only screen and (max-width: 820px) and (min-width: 781px) {
1694
1695 #wpbody-content #v2_tenweb_notice_cont {
1696 height: 50px;
1697 min-height: 50px;
1698 }
1699
1700 #v2_tenweb_notice_cont {
1701 height: 60px;
1702 }
1703
1704 .v2_content {
1705 margin-left: 25px;
1706 }
1707
1708 .v2_content p {
1709 font-size: 13px;
1710 color: #333B46;
1711 font-weight: 600;
1712 line-height: 20px;
1713 margin-top: 5px;
1714 }
1715
1716 .v2_content p span {
1717 display: block;
1718 }
1719
1720 }
1721
1722 @media only screen and (max-width: 780px) {
1723
1724 #wpbody-content #v2_tenweb_notice_cont {
1725 height: auto;
1726 min-height: auto;
1727 }
1728
1729 #v2_tenweb_notice_cont {
1730 height: auto;
1731 padding: 5px;
1732 }
1733
1734 .v2_logo {
1735 display: block;
1736 height: auto;
1737 width: 100%;
1738 margin-top: 5px;
1739 }
1740
1741 .v2_content {
1742 display: block;
1743 margin-left: 9px;
1744 margin-top: 10px;
1745 width: calc(100% - 10px);
1746 }
1747
1748 .v2_content p {
1749 line-height: unset;
1750 font-size: 15px;
1751 line-height: 25px;
1752 }
1753 .v2_content p span{
1754 display: block
1755 }
1756 #wd_tenweb_logo_notice {
1757 margin-left: 9px;
1758 }
1759
1760 .v2_button {
1761 margin-left: 9px;
1762 margin-top: 10px;
1763 margin-bottom: 5px;
1764 }
1765 }
1766 </style>
1767 <div id="v2_tenweb_notice_cont" class="notice wd-notice">
1768 <div class="v2_logo">
1769 <img id="wd_tenweb_logo_notice" src="<?php echo $url . '/images/form-maker-logo.png'; ?>" />
1770 </div>
1771 <div class="v2_content">
1772 <p>
1773 <?php echo sprintf(__('%sForm Maker advises:%s %sUse Image Optimizer service to optimize your images quickly and easily.%s', $prefix), '<span>','</span>', '<span>','</span>'); ?>
1774 </p>
1775 </div>
1776 <div class="v2_button">
1777 <?php WDW_FM_Library::twbb_install_button(2); ?>
1778 </div>
1779 <button type="button" class="wd_tenweb_notice_dissmiss notice-dismiss" onclick="jQuery('#v2_tenweb_notice_cont').attr('style', 'display: none !important;'); jQuery.post('<?php echo $dismiss_url; ?>');"><span class="screen-reader-text"></span></button>
1780 <div id="verifyUrl" data-url="<?php echo $verify_url; ?>"></div>
1781 </div>
1782 <?php
1783
1784 echo ob_get_clean();
1785 }
1786 }
1787
1788 if ( !function_exists('is_plugin_active') ) {
1789 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
1790 }
1791
1792 if ( !is_plugin_active( '10web-manager/10web-manager.php' ) && WDFMInstance(1)->is_free ) {
1793 add_action('admin_notices', 'wdfm_tenweb_install_notice');
1794 }
1795
1796 if ( !function_exists('wd_tenwebps_install_notice_status') ) {
1797 // Add usermeta to DB.
1798 function wd_tenwebps_install_notice_status() {
1799 update_option('tenweb_notice_status', '1', 'no');
1800 }
1801 add_action('wp_ajax_wd_tenweb_dismiss', 'wd_tenwebps_install_notice_status');
1802 }
1803 // Check status 10web manager install
1804 function fm_check_tenweb_status() {
1805 $status_install = 0;
1806 $status_active = 0;
1807 if ( WDW_FM_Library::is_plugin_installed('10web-manager') ) {
1808 $status_install = 1;
1809 }
1810 else {
1811 if ( is_plugin_active('10web-manager/10web-manager.php') ) {
1812 $status_active = 1;
1813 }
1814 }
1815 if ( WDW_FM_Library::is_plugin_installed('10web-manager') ) {
1816 $old_opt_array = array();
1817 $new_opt_array = array( 'form-maker' => 95 ); // core_id
1818 $key = 'tenweb_manager_installed';
1819 $option = get_option($key);
1820 if ( !empty($option) ) {
1821 $old_opt_array = (array) json_decode($option);
1822 }
1823 $array_installed = array_merge($new_opt_array, $old_opt_array);
1824 update_option($key, json_encode($array_installed));
1825 }
1826 $jsondata = array( 'status_install' => $status_install, 'status_active' => $status_active );
1827 echo json_encode($jsondata);
1828 exit;
1829 }
1830 add_action('wp_ajax_fm_tenweb_status', 'fm_check_tenweb_status');