PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.2.4
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.2.4
1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 1.3.51 1.3.50 1.3.49 1.3.48 1.3.47 1.3.46 1.3.45 1.3.44 All 176 releases
disco / uninstall.php

uninstall.php in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO 1.2.4, at uninstall.php

105 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Disco
5 *
6 * Fired when the plugin is uninstalled.
7 *
8 * When populating this file, consider the following flow
9 * of control:
10 *
11 * - This method should be static
12 * - Check if the $_REQUEST content actually is the plugin name
13 * - Run an admin referrer check to make sure it goes through authentication
14 * - Verify the output of $_GET makes sense
15 * - Repeat with other user roles. Best directly by using the links/query string parameters.
16 * - Repeat things for multisite. Once for a single site in the network, once sitewide.
17 *
18 * @package Disco
19 * @author Ohidul Islam <wahid0003@gmail.com>
20 * @copyright 2022 WebAppick
21 * @license GPL 2.0+
22 * @link http://domain.tld
23 */
24
25 // If uninstall not called from WordPress, then exit.
26 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
27 exit;
28 }
29
30 /**
31 * Loop for uninstall
32 *
33 * @return void
34 */
35 function disco_uninstall_multisite() {
36 if ( is_multisite() ) {
37 /** @var array<\WP_Site> $blogs */
38 $blogs = get_sites();
39
40 if ( ! empty( $blogs ) ) {
41 foreach ( $blogs as $blog ) {
42 switch_to_blog( (int) $blog->blog_id );
43 disco_uninstall();
44 restore_current_blog();
45 }
46
47 return;
48 }
49 }
50
51 disco_uninstall();
52 }
53
54 /**
55 * What happens on uninstalling?
56 *
57 * @return void
58 * @global WP_Roles $wp_roles
59 */
60 function disco_uninstall() { // phpcs:ignore
61 global $wp_roles;
62
63 // Ensure $wp_roles is properly initialized
64 if ( ! isset( $wp_roles ) ) {
65 if ( ! class_exists( 'WP_Roles' ) ) {
66 return; // Exit if WP_Roles class does not exist
67 }
68
69 $wp_roles = new WP_Roles(); // phpcs:ignore
70 }
71
72 $caps = array(
73 'create_plugins',
74 'read_demo',
75 'read_private_demoes',
76 'edit_demo',
77 'edit_demoes',
78 'edit_private_demoes',
79 'edit_published_demoes',
80 'edit_others_demoes',
81 'publish_demoes',
82 'delete_demo',
83 'delete_demoes',
84 'delete_private_demoes',
85 'delete_published_demoes',
86 'delete_others_demoes',
87 'manage_demoes',
88 );
89
90 foreach ( $wp_roles->roles as $role_key => $role_name ) { // phpcs:ignore
91 $role_cap = get_role( $role_key );
92
93 if ( ! $role_cap ) {
94 continue; // Skip if a role does not exist
95 }
96
97 foreach ( $caps as $cap ) {
98 $role_cap->remove_cap( $cap );
99 }
100 }
101 }
102
103
104 disco_uninstall_multisite();
105