PluginProbe ʕ •ᴥ•ʔ
Alt Magic: AI Image Alt Text Generator for WP & Image Rename / 1.7.8
Alt Magic: AI Image Alt Text Generator for WP & Image Rename v1.7.8
1.7.8 1.7.7 1.7.6 1.7.5 1.7.4 trunk 0.2.9 0.3.1 0.3.2 0.4.0 0.4.1 0.4.2 0.4.3 0.4.4 0.4.5 0.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.6.1 1.6.2 1.6.3 1.7.1 1.7.2 1.7.3
alt-magic-ai-powered-alt-texts / uninstall.php
alt-magic-ai-powered-alt-texts Last commit date
admin-functions 2 days ago admin-settings-pages 2 days ago assets 2 days ago common-functions 2 days ago css 2 days ago integrations-functions 2 days ago media-library-page-functions 2 days ago scripts 2 days ago altm-main-file.php 2 days ago index.php 2 days ago readme.txt 2 days ago uninstall.php 2 days ago
uninstall.php
106 lines
1 <?php
2
3 // Ensure this file is not accessed directly
4 if (!defined('WP_UNINSTALL_PLUGIN')) {
5 exit;
6 }
7
8 // Include the main plugin file to get constants
9 require_once dirname(__FILE__) . '/altm-main-file.php';
10
11 // Define the server endpoint for plugin events
12 define('ALT_MAGIC_PLUGIN_EVENTS_ENDPOINT', '/wp-plugin-events');
13
14 /**
15 * Send plugin deletion event ping to server
16 * This function is called when the plugin is deleted (uninstalled)
17 */
18 function altm_send_plugin_deletion_ping() {
19 // Get site information
20 $site_url = get_site_url();
21
22 // Get user_id if available
23 $user_id = get_option('alt_magic_user_id');
24
25 // Prepare the request data (trimmed to essential fields only)
26 $request_data = array(
27 'event_type' => 'deleted',
28 'plugin_version' => ALT_MAGIC_PLUGIN_VERSION,
29 'site_url' => $site_url
30 );
31
32 // Add user_id if available
33 if (!empty($user_id)) {
34 $request_data['user_id'] = $user_id;
35 }
36
37 // Get the base URL for the ping
38 $base_url = ALT_MAGIC_API_BASE_URL;
39 $ping_url = $base_url . ALT_MAGIC_PLUGIN_EVENTS_ENDPOINT;
40
41 // Prepare the request arguments
42 $args = array(
43 'method' => 'POST',
44 'headers' => array(
45 'Content-Type' => 'application/json',
46 'User-Agent' => 'Alt-Magic-WordPress-Plugin/' . ALT_MAGIC_PLUGIN_VERSION
47 ),
48 'body' => wp_json_encode($request_data),
49 'timeout' => 30,
50 'blocking' => false, // Non-blocking request to avoid slowing down uninstall
51 'httpversion' => '1.1',
52 'sslverify' => true
53 );
54
55 // Send the ping
56 $response = wp_remote_post($ping_url, $args);
57
58 if (is_wp_error($response)) {
59 // Log error if possible (though logging might not be available during uninstall)
60 altm_log('Alt Magic: Failed to send plugin deletion ping: ' . $response->get_error_message());
61 } else {
62 $response_code = wp_remote_retrieve_response_code($response);
63 if ($response_code >= 200 && $response_code < 300) {
64 altm_log('Alt Magic: Successfully sent plugin deletion ping');
65 } else {
66 altm_log('Alt Magic: Plugin deletion ping returned status code: ' . $response_code);
67 }
68 }
69 }
70
71 // Send the deletion ping
72 altm_send_plugin_deletion_ping();
73
74 // Clean up plugin options (optional - uncomment if you want to remove all plugin data)
75 /*
76 $options_to_remove = [
77 'alt_magic_account_active',
78 'alt_magic_api_key',
79 'alt_magic_user_id',
80 'alt_magic_plan_type',
81 'alt_magic_language',
82 'alt_magic_use_for_title',
83 'alt_magic_use_for_caption',
84 'alt_magic_use_for_description',
85 'alt_magic_prepend_string',
86 'alt_magic_append_string',
87 'alt_magic_auto_generate',
88 'alt_magic_auto_rename_on_upload',
89 'alt_magic_use_seo_keywords',
90 'alt_magic_use_post_title',
91 'alt_magic_refresh_alt_text',
92 'alt_magic_private_site',
93 'alt_magic_woocommerce_use_product_name',
94 'alt_magic_rename_use_seo_keywords',
95 'alt_magic_rename_use_post_title',
96 'alt_magic_rename_use_woocommerce_product_name',
97 'alt_magic_max_concurrency'
98 ];
99
100 foreach ($options_to_remove as $option) {
101 delete_option($option);
102 }
103 */
104
105 ?>
106