PluginProbe
CBX Map for Google Map & OpenStreetMap / 2.0.3
CBX Map for Google Map & OpenStreetMap v2.0.3
trunk 1.1.10 1.1.11 1.1.12 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5
cbxgooglemap / includes / CBXGoogleMapUninstall.php

CBXGoogleMapUninstall.php in CBX Map for Google Map & OpenStreetMap 2.0.3, at includes/CBXGoogleMapUninstall.php

87 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // If uninstall not called from WordPress, then exit.
3 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
4 exit;
5 }
6
7 use Cbx\Googlemap\CBXGooglemapSettings;
8 use Cbx\Googlemap\Helpers\CBXGooglemapHelper;
9
10 /**
11 * Fired during plugin uninstall/delete.
12 *
13 * This class defines all code necessary to run during the plugin's uninstallation.
14 *
15 * @since 1.0.0
16 * @package cbxgooglemap
17 * @subpackage cbxgooglemap/includes
18 * @author CBX Team <info@codeboxr.com>
19 */
20 class CBXGoogleMapUninstall {
21 /**
22 * Uninstall plugin functionality
23 *
24 *
25 * @since 1.1.3
26 */
27 public static function uninstall() {
28 // For the regular site.
29 if ( ! is_multisite() ) {
30 self::uninstall_tasks();
31 } else {
32 //for multi site
33 global $wpdb;
34
35 $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM %s", $wpdb->blogs ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery
36 $original_blog_id = get_current_blog_id();
37
38 foreach ( $blog_ids as $blog_id ) {
39 switch_to_blog( $blog_id );
40
41 self::uninstall_tasks();
42 }
43
44 switch_to_blog( $original_blog_id );
45 }
46 }//end method uninstall
47
48 /**
49 * Do the necessary uninstall tasks
50 *
51 * @return void
52 */
53 public static function uninstall_tasks() {
54 if ( ! current_user_can( 'activate_plugins' ) ) {
55 return;
56 }
57
58 $settings = new CBXGooglemapSettings();
59 $delete_global_config = $settings->get_field( 'delete_global_config', 'cbxgooglemap_tools', 'no' );
60
61 if ( $delete_global_config == 'yes' ) {
62 //before hook
63 do_action( 'cbxgooglemap_plugin_uninstall_before' );
64
65 //delete options
66 $option_values = CBXGooglemapHelper::getAllOptionNames();
67
68 do_action( 'cbxgooglemap_plugin_options_deleted_before' );
69
70 foreach ( $option_values as $key => $option_value ) {
71 $option = $option_value['option_name'];
72
73 do_action( 'cbxgooglemap_plugin_option_delete_before', $option );
74 delete_option( $option );
75 do_action( 'cbxgooglemap_plugin_option_delete_after', $option );
76 }
77
78 do_action( 'cbxgooglemap_plugin_options_deleted_after' );
79 do_action( 'cbxgooglemap_plugin_options_deleted' );
80 //end delete options
81
82 //after hook
83 do_action( 'cbxgooglemap_plugin_uninstall_after' );
84 }
85 }//end method uninstall
86 }//end class Uninstall
87