PluginProbe
CBX Map for Google Map & OpenStreetMap / trunk
CBX Map for Google Map & OpenStreetMap vtrunk
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 trunk, at includes/CBXGoogleMapUninstall.php

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