PluginProbe
WP-Memory-Usage / 2.0.0
WP-Memory-Usage v2.0.0
2.3.1 trunk 1.2.10 1.2.11 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.2.0 2.2.1 2.3.0
wp-memory-usage / uninstall.php

uninstall.php in WP-Memory-Usage 2.0.0, at uninstall.php

70 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WP-Memory-Usage - Uninstall Script
4 *
5 * Runs when the plugin is deleted via the WordPress admin.
6 * Removes all plugin options, scheduled events, and log files.
7 */
8
9 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
10 exit;
11 }
12
13 // -- 1. WordPress Options ------------------------------------------------------
14 $wp_memory_usage_options_to_delete = array(
15 'wpmu_threshold_alerts',
16 );
17
18 foreach ( $wp_memory_usage_options_to_delete as $wp_memory_usage_option ) {
19 delete_option( $wp_memory_usage_option );
20 }
21
22 // Multisite: remove site-level options if applicable
23 if ( is_multisite() ) {
24 foreach ( $wp_memory_usage_options_to_delete as $wp_memory_usage_option ) {
25 delete_site_option( $wp_memory_usage_option );
26 }
27 }
28
29 // -- 2. Scheduled Cron Events --------------------------------------------------
30 $wp_memory_usage_cron_hooks = array(
31 'wpmu_daily_digest', // DIGEST_HOOK
32 'wpmu_cleanup_hook', // log-rotation cron
33 );
34
35 foreach ( $wp_memory_usage_cron_hooks as $wp_memory_usage_hook ) {
36 $wp_memory_usage_timestamp = wp_next_scheduled( $wp_memory_usage_hook );
37 while ( $wp_memory_usage_timestamp ) {
38 wp_unschedule_event( $wp_memory_usage_timestamp, $wp_memory_usage_hook );
39 $wp_memory_usage_timestamp = wp_next_scheduled( $wp_memory_usage_hook );
40 }
41 wp_clear_scheduled_hook( $wp_memory_usage_hook ); // safety net
42 }
43
44 // Remove any dynamically named interval hooks (wpmu_every_XX_min)
45 $wp_memory_usage_crons = _get_cron_array();
46 if ( is_array( $wp_memory_usage_crons ) ) {
47 foreach ( $wp_memory_usage_crons as $wp_memory_usage_timestamp => $wp_memory_usage_cron_jobs ) {
48 foreach ( $wp_memory_usage_cron_jobs as $wp_memory_usage_hook_name => $wp_memory_usage_events ) {
49 if ( strpos( $wp_memory_usage_hook_name, 'wpmu_' ) === 0 ) {
50 foreach ( $wp_memory_usage_events as $wp_memory_usage_key => $wp_memory_usage_event ) {
51 wp_unschedule_event( $wp_memory_usage_timestamp, $wp_memory_usage_hook_name, $wp_memory_usage_event['args'] );
52 }
53 }
54 }
55 }
56 }
57
58 // -- 3. Log Files --------------------------------------------------------------
59 // Note: settings (settings.cgi) and all log files are stored in the
60 // log directory below and are removed together with it.$wp_memory_usage_log_dir = ABSPATH. '../logs/wpmu/';
61 if ( $wp_memory_usage_log_dir && is_dir( $wp_memory_usage_log_dir ) ) {
62 // Remove directory
63 global $wp_filesystem;
64 if ( ! function_exists( 'WP_Filesystem' ) ) {
65 require_once ABSPATH . 'wp-admin/includes/file.php';
66 }
67 WP_Filesystem();
68 $wp_filesystem->rmdir( $wp_memory_usage_log_dir, true );
69 }
70