PluginProbe
Image Source Control Lite – Show Image Credits and Captions / 3.11.0
Image Source Control Lite – Show Image Credits and Captions v3.11.0
3.12.0 3.11.0 trunk 1.1 1.1.1 1.1.2 1.1.2.1 1.1.3 1.10 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.2 1.2.0.1 1.2.0.2 1.2.0.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.4.1 1.3.5 All 110 releases
image-source-control-isc / uninstall.php

uninstall.php in Image Source Control Lite – Show Image Credits and Captions 3.11.0, at uninstall.php

49 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
3 exit();
4 }
5
6 // check if the option to remove data on uninstall is enabled
7 $options = get_option( 'isc_options' );
8 if ( ! empty( $options['remove_on_uninstall'] ) ) {
9 global $wpdb;
10
11 // delete post meta fields
12 delete_post_meta_by_key( 'isc_post_images' );
13 delete_post_meta_by_key( 'isc_image_posts' );
14 delete_post_meta_by_key( 'isc_image_source' );
15 delete_post_meta_by_key( 'isc_image_source_own' );
16 delete_post_meta_by_key( 'isc_image_source_url' );
17 delete_post_meta_by_key( 'isc_possible_usages' );
18 delete_post_meta_by_key( 'isc_possible_usages_last_check' );
19 delete_post_meta_by_key( 'isc_post_images_before_update' );
20 delete_post_meta_by_key( 'isc_last_index' );
21 delete_post_meta_by_key( 'isc_ignored_unused_image' );
22
23 // delete main plugin options
24 delete_option( 'isc_options' );
25 // delete storage
26 delete_option( 'isc_storage' );
27 // delete the total number of unused images (Pro). Option no longer set since version 3.9
28 delete_option( 'isc_unused_images_total_items' );
29 // delete the last log created by the Scanner
30 delete_option( 'isc_scanner_log' );
31
32 // delete user meta
33 delete_metadata( 'user', null, 'isc_newsletter_subscribed', '', true );
34
35 // drop the index table
36 $table_name = $wpdb->prefix . 'isc_index';
37 // phpcs:ignore
38 $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
39
40 // delete the log file if it exists
41 $upload_dir = wp_upload_dir();
42 // Hash the AUTH_KEY to create the same filename that was used
43 $log_file_name = 'image-source-control_' . hash( 'crc32', AUTH_KEY ) . '.log';
44 $log_file_path = $upload_dir['basedir'] . '/' . $log_file_name;
45 if ( file_exists( $log_file_path ) ) {
46 wp_delete_file( $log_file_path );
47 }
48 }
49