PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.15.3
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.15.3
3.3.1 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 All 138 releases
← All changes | includes/Core/Util/Activation.php +22 -60 3.3.12.15.3 View file →
@@ -1,17 +1,11 @@
1 1 <?php
2 2
3 3 namespace BitCode\BitForm\Core\Util;
4 4
5 -if (!defined('ABSPATH')) {
6 - exit;
7 -}
8 -
9 -use BitCode\BitForm\Admin\Form\Helpers;
10 5 use BitCode\BitForm\Core\Database\DB;
11 6 use BitCode\BitForm\Core\Database\FormModel;
12 7 use WP_Error;
13 -use WP_Site;
14 8
15 9 /**
16 10 * Class handling plugin activation.
17 11 *
@@ -28,37 +22,12 @@
28 22
29 23 public function activate()
30 24 {
31 25 add_action('bitforms_activation', [$this, 'install']);
32 - add_action('wp_initialize_site', [$this, 'initializeNewSite'], 120, 1);
33 26 }
34 27
35 - public function install($networkWide)
28 + public function install()
36 29 {
37 - if ($networkWide && \function_exists('is_multisite') && is_multisite()) {
38 - $sites = get_sites(['fields' => 'ids', 'network_id' => get_current_network_id()]);
39 - foreach ($sites as $site) {
40 - switch_to_blog($site);
41 - $this->installOnCurrentBlog();
42 - restore_current_blog();
43 - }
44 - } else {
45 - $this->installOnCurrentBlog();
46 - }
47 - }
48 -
49 - public function initializeNewSite(WP_Site $site)
50 - {
51 - switch_to_blog($site->blog_id);
52 - $plugin = plugin_basename(BITFORMS_PLUGIN_MAIN_FILE);
53 - if (!is_plugin_active_for_network($plugin)) {
54 - do_action('bitforms_activation', false);
55 - }
56 - restore_current_blog();
57 - }
58 -
59 - public function installOnCurrentBlog()
60 - {
61 30 $installed = get_option('bitforms_installed');
62 31
63 32 if (!$installed) {
64 33 DB::migrate();
@@ -72,22 +41,12 @@
72 41 $config = (object) [];
73 42 $config->delete_table = true;
74 43 update_option('bitform_app_config', $config);
75 44 }
76 - $appSettings = get_option('bitform_app_settings');
77 - if (!$appSettings) {
78 - $appSettings = (object) [];
79 - $appSettings->globalMessages = Helpers::getDefaultGlobalMessages();
80 - update_option('bitform_app_settings', $appSettings);
81 - }
82 -
83 45 update_option('bitforms_version', BITFORMS_VERSION);
84 46 $this->layoutUpdate();
85 47 $this->createUploadDir();
86 -
87 - if (!defined('WP_TESTS_DOMAIN')) {
88 - $this->createFrontendPages();
89 - }
48 + $this->createFrontendPages();
90 49 }
91 50
92 51 private function createUploadDir()
93 52 {
@@ -97,8 +56,9 @@
97 56 if (!file_exists(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles')) {
98 57 wp_mkdir_p(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'form-styles');
99 58 }
100 59 if (file_exists(BITFORMS_UPLOAD_DIR) && !file_exists(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . '.htaccess')) {
60 + $htaccessFile = fopen(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . '.htaccess', 'w');
101 61 $rules = '
102 62 <IfDefine php_flag>
103 63 php_flag engine off
104 64 </IfDefine>
@@ -106,15 +66,22 @@
106 66 Order allow,deny
107 67 Deny from all
108 68 Require all denied
109 69 ';
110 - FileHandler::writeFile(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . '.htaccess', $rules);
70 + fwrite($htaccessFile, $rules);
71 + fclose($htaccessFile);
111 72 }
112 73 if (file_exists(BITFORMS_UPLOAD_DIR) && !file_exists(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . 'index.php')) {
113 - FileHandler::writeFile(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . 'index.php', "<?php\n");
74 + $indexFile = fopen(BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . 'index.php', 'w');
75 + $code = "<?php\n";
76 + fwrite($indexFile, $code);
77 + fclose($indexFile);
114 78 }
115 79 if (file_exists(BITFORMS_CONTENT_DIR) && !file_exists(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'index.php')) {
116 - FileHandler::writeFile(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'index.php', "<?php\n");
80 + $indexFile = fopen(BITFORMS_CONTENT_DIR . DIRECTORY_SEPARATOR . 'index.php', 'w');
81 + $code = "<?php\n";
82 + fwrite($indexFile, $code);
83 + fclose($indexFile);
117 84 }
118 85 }
119 86
120 87 private function getForms()
@@ -238,22 +205,17 @@
238 205
239 206 private function createFrontendPages()
240 207 {
241 208 $args = [
242 - 'label' => __('Bitforms Pages', 'bit-form'),
243 - 'public' => false,
244 - 'publicly_queryable' => true,
245 - 'exclude_from_search' => true,
246 - 'show_in_nav_menus' => false,
247 - 'show_ui' => true,
248 - 'show_in_menu' => false,
249 - 'capability_type' => 'page',
250 - 'hierarchical' => false,
251 - 'has_archive' => false,
252 - 'query_var' => false,
253 - 'rewrite' => true,
254 - 'supports' => ['title'],
255 - 'show_in_rest' => false
209 + 'label' => __('Bitforms Pages', 'bit-form'),
210 + 'public' => true,
211 + 'show_ui' => true,
212 + 'show_in_menu' => false,
213 + 'capability_type' => 'page',
214 + 'hierarchical' => false,
215 + 'query_var' => false,
216 + 'supports' => ['title'],
217 + 'show_in_rest' => false
256 218 ];
257 219 register_post_type('bitforms', $args);
258 220 $routes = get_option('bitforms_routes');
259 221 $route_value = [];