Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions uninstall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Our uninstall call.
*
* @package FAIR
*/

// Only run this on the actual WP uninstall function.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
die;
}

// Include the avatar namespace so we can use the constant.
require_once __DIR__ . '/inc/avatars/namespace.php';

// Delete any single or multisite keys.
delete_option( 'fair_indexnow_key' );
delete_site_option( \FAIR\Avatars\AVATAR_SRC_SETTING_KEY );

// Delete any transients we may have created or modified.
delete_site_transient( 'update_plugins' );
delete_site_transient( 'update_themes' );

global $wpdb;

// Prepare our delete query.
$query_args = $wpdb->prepare("
DELETE FROM $wpdb->usermeta
WHERE meta_key IN (
%s,
%s
)
", 'fair_avatar_site_id', 'fair_avatar_id' );

// And actually run it.
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- we did use the prepare function above
$wpdb->query( $query_args );