PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.16.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.16.2
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
← All changes | includes/Plugin.php +45 -29 2.02.16.2 View file →
@@ -7,17 +7,20 @@
7 7 *
8 8 * @since 1.0.0-alpha
9 9 */
10 10
11 +use BitCode\BitForm\BitApps\WPTelemetry\Telemetry\Telemetry;
12 +use BitCode\BitForm\BitApps\WPTelemetry\Telemetry\TelemetryConfig;
11 13 use BitCode\BitForm\Core\Database\DB;
12 14 use BitCode\BitForm\Core\Database\FormModel;
15 +use BitCode\BitForm\Core\Fallback\FormFallback;
13 16 use BitCode\BitForm\Core\Hooks\Hooks;
14 17 use BitCode\BitForm\Core\Util\Activation;
15 18 use BitCode\BitForm\Core\Util\Deactivation;
16 -use BitCode\BitForm\Core\Util\FrontendHelpers;
17 19 use BitCode\BitForm\Core\Util\Uninstallation;
18 20
19 -final class Plugin {
21 +final class Plugin
22 +{
20 23 /**
21 24 * Main instance of the plugin.
22 25 *
23 26 * @since 1.0.0-alpha
@@ -29,34 +32,20 @@
29 32 * Registers the plugin with WordPress.
30 33 *
31 34 * @since 1.0.0-alpha
32 35 */
33 - public function register() {
36 + public function register()
37 + {
34 38 add_action('plugins_loaded', [$this, 'init_plugin']);
35 - add_action('init', [$this, 'checkIfFirstHttpRequest']);
36 39 (new Activation())->activate();
37 40 (new Deactivation())->register();
38 41 (new Uninstallation())->register();
39 - }
40 42
41 - public function checkIfFirstHttpRequest() {
42 - $referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
43 - $referrerQueryParams = FrontendHelpers::parseQueryParams($referrer);
44 - $pageBuilderQueryParams = FrontendHelpers::$pageBuilderList;
45 - $referrerMatchesWithPageBuilder = array_intersect_assoc($referrerQueryParams, $pageBuilderQueryParams);
46 - if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($referrer) && 0 === count($referrerMatchesWithPageBuilder)) {
47 - delete_transient('is_page_builder');
48 - delete_transient('bf_frontend_form_ids');
49 - $currentUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
50 - $currentUrlQueryParams = FrontendHelpers::parseQueryParams($currentUrl);
51 - $currentUrlMatchesWithPageBuilder = array_intersect_assoc($currentUrlQueryParams, $pageBuilderQueryParams);
52 - if (0 !== count($currentUrlMatchesWithPageBuilder)) {
53 - set_transient('is_page_builder', true);
54 - }
55 - }
43 + $this->initWpTelemetry();
56 44 }
57 45
58 - private function commaReplace($options, $lbl, $val) {
46 + private function commaReplace($options, $lbl, $val)
47 + {
59 48 foreach ($options as $key => $option) {
60 49 if (!empty($option[$lbl]) && !empty($option[$val])) {
61 50 $options[$key][$val] = str_replace(',', '_', $option[$val]);
62 51 }
@@ -66,9 +55,10 @@
66 55 }
67 56 return $options;
68 57 }
69 58
70 - private function replaceOptionSeparator($formContent) {
59 + private function replaceOptionSeparator($formContent)
60 + {
71 61 $updated = false;
72 62 foreach ($formContent['fields'] as $key => $field) {
73 63 if ('check' === $field['typ']) {
74 64 $formContent['fields'][$key]['opt'] = $this->commaReplace($field['opt'], 'lbl', 'val');
@@ -81,9 +71,10 @@
81 71 }
82 72 return [$formContent, $updated];
83 73 }
84 74
85 - public function optionFallBack() {
75 + public function optionFallBack()
76 + {
86 77 $formModel = new FormModel();
87 78 $forms = $formModel->get(
88 79 ['id', 'form_content']
89 80 );
@@ -108,9 +99,10 @@
108 99 * Updates bit form content tables on wp db
109 100 *
110 101 * @return void
111 102 */
112 - public function update_tables() {
103 + public function update_tables()
104 + {
113 105 if (!current_user_can('manage_options')) {
114 106 return;
115 107 }
116 108
@@ -127,9 +119,15 @@
127 119 * @param array $links
128 120 *
129 121 * @return array
130 122 */
131 - public function init_plugin() {
123 + public function init_plugin()
124 + {
125 + $currentBitFormVersion = BITFORMS_VERSION;
126 + $installedBitFormVersion = get_option('bitforms_version');
127 + if ($currentBitFormVersion !== $installedBitFormVersion) {
128 + (new FormFallback())->resetJsGeneratedPageIds();
129 + }
132 130 Hooks::init_hooks();
133 131 $this->update_tables();
134 132 do_action('bitform_loaded');
135 133 }
@@ -140,14 +138,16 @@
140 138 * @since 1.0.0-alpha
141 139 *
142 140 * @return BITFORM Plugin main instance.
143 141 */
144 - public static function instance() {
142 + public static function instance()
143 + {
145 144 return static::$instance;
146 145 }
147 146
148 - public function plugin_action_links($links) {
149 - $links[] = '<a href="https://docs.form.bitapps.pro" target="_blank">' . __('Docs') . '</a>';
147 + public function plugin_action_links($links)
148 + {
149 + $links[] = '<a href="https://bitapps.pro/docs/bit-form/" target="_blank">' . __('Docs') . '</a>';
150 150
151 151 return $links;
152 152 }
153 153
@@ -157,9 +157,10 @@
157 157 * @param string $main_file Absolute path to the plugin main file.
158 158 *
159 159 * @return bool True if the plugin main instance could be loaded, false otherwise.
160 160 */
161 - public static function load($main_file) {
161 + public static function load($main_file)
162 + {
162 163 if (null !== static::$instance) {
163 164 return false;
164 165 }
165 166
@@ -165,6 +166,21 @@
165 166
166 167 static::$instance = new static($main_file);
167 168 static::$instance->register();
168 169 return true;
170 + }
171 +
172 + private function initWpTelemetry()
173 + {
174 + TelemetryConfig::setSlug(Config::SLUG);
175 + TelemetryConfig::setTitle(Config::TITLE);
176 + TelemetryConfig::setVersion(Config::VERSION);
177 + TelemetryConfig::setPrefix(Config::VAR_PREFIX);
178 +
179 + TelemetryConfig::setServerBaseUrl('https://wp-api.bitapps.pro/public/');
180 + TelemetryConfig::setTermsUrl('https://bitapps.pro/terms-of-service/');
181 + TelemetryConfig::setPolicyUrl('https://bitapps.pro/privacy-policy/');
182 +
183 + Telemetry::report()->addPluginData()->init();
184 + Telemetry::feedback()->init();
169 185 }
170 186 }