PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.3.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.3.1
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/Deactivation.php +43 -20 1.23.3.1 View file →
@@ -1,7 +1,12 @@
1 1 <?php
2 +
2 3 namespace BitCode\BitForm\Core\Util;
3 4
5 +if (!defined('ABSPATH')) {
6 + exit;
7 +}
8 +
4 9 /**
5 10 * Class handling plugin deactivation.
6 11 *
7 12 * @since 1.0.0
@@ -9,29 +14,47 @@
9 14 * @ignore
10 15 */
11 16 final class Deactivation
12 17 {
18 + /**
19 + * Registers functionality through WordPress hooks.
20 + *
21 + * @since 1.0.0
22 + */
23 + public function register()
24 + {
25 + add_action('bitforms_deactivation', [$this, 'deactive']);
26 + }
13 27
14 - /**
15 - * Registers functionality through WordPress hooks.
16 - *
17 - * @since 1.0.0
18 - */
19 - public function register()
20 - {
21 - add_action('bitforms_deactivation', array($this, 'deactive'));
28 + // handle deactivation tasks with multisite support
29 + public function deactive($network_wide)
30 + {
31 + if ($network_wide && \function_exists('is_multisite') && is_multisite()) {
32 + global $wpdb;
33 + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
34 + foreach ($blog_ids as $blog_id) {
35 + switch_to_blog($blog_id);
36 + $this->deactivateOnCurrentBlog();
37 + restore_current_blog();
38 + }
39 + } else {
40 + $this->deactivateOnCurrentBlog();
22 41 }
42 + }
23 43
24 - public function deactive()
25 - {
26 - $routes = get_option('bitforms_routes');
27 - if ($routes && isset($routes['root'])) {
28 - $root_page = array( 'ID' => $routes['root'], 'post_status' => 'draft' );
29 - wp_update_post($root_page);
30 - }
31 - if ($routes && isset($routes['file'])) {
32 - $file_page = array( 'ID' => $routes['file'], 'post_status' => 'draft' );
33 - wp_update_post($file_page);
34 - }
35 - flush_rewrite_rules();
44 + /**
45 + * Deactivates plugin for a single site
46 + */
47 + public function deactivateOnCurrentBlog()
48 + {
49 + $routes = get_option('bitforms_routes');
50 + if ($routes && isset($routes['root'])) {
51 + $root_page = ['ID' => $routes['root'], 'post_status' => 'draft'];
52 + wp_update_post($root_page);
36 53 }
54 + if ($routes && isset($routes['file'])) {
55 + $file_page = ['ID' => $routes['file'], 'post_status' => 'draft'];
56 + wp_update_post($file_page);
57 + }
58 + flush_rewrite_rules();
59 + }
37 60 }