forked from wp-media/imagify-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
executable file
·26 lines (19 loc) · 962 Bytes
/
uninstall.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
defined( 'WP_UNINSTALL_PLUGIN' ) || die( 'Cheatin’ uh?' );
global $wpdb;
// Transients.
$transients = $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '%_transient_imgt%' OR option_name LIKE '%_transient_timeout_imgt%'" );
if ( is_multisite() ) {
$transients = $wpdb->query( "DELETE FROM $wpdb->sitemeta WHERE meta_key LIKE '%_transient_imgt%' OR meta_key LIKE '%_transient_timeout_imgt%'" );
}
// Logs.
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s", 'imgt_log' ) );
if ( $post_ids ) {
$post_ids = implode( ',', $post_ids );
// Delete Postmeta.
$sql = sprintf( "DELETE FROM $wpdb->postmeta WHERE post_id IN (%s)", $post_ids );
$wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
// Delete Posts.
$sql = sprintf( "DELETE FROM $wpdb->posts WHERE ID IN (%s)", $post_ids );
$wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}