ID : null, $blog instanceof \WP_Site ? array( $blog->blog_id, $blog->site_id, $blog->deleted, $blog->archived, $blog->spam ) : null, is_object( $network ) ? ( $network->id ?? null ) : null ); foreach ( array( $wpdb, $db ) as $connection ) { $map = array(); foreach ( array( 'prefix', 'base_prefix', 'blogid', 'siteid', 'posts', 'comments', 'links', 'options', 'postmeta', 'terms', 'term_taxonomy', 'term_relationships', 'termmeta', 'commentmeta', 'users', 'usermeta', 'blogs', 'blogmeta', 'signups', 'site', 'sitemeta', 'registration_log' ) as $field ) { $map[ $field ] = $connection->$field ?? null; } $context[] = $map; } return $context; } /** * Drop the fixed optional import cursor table under current explicit uninstall consent. * * Fixed optional cursor ownership remains available when the add-on is inactive. * * @return true|\WP_Error True after verified absence, or a consent, authority or storage error. */ public static function uninstall(): bool|\WP_Error { global $wpdb; /** * Current WordPress database adapter used by this operation. * * @var \wpdb $wpdb */ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) || ! class_exists( Derived::class ) ) { return self::error( 'cleanup' ); } $db = $wpdb; $origin = self::origin( $db ); $allowed = static function () use ( $db, $origin ): bool { if ( self::origin( $db ) !== $origin ) { return false; } $held = $db->get_var( $db->prepare( 'SELECT IS_USED_LOCK(%s)=CONNECTION_ID()', Derived::lock_name() ) ); if ( '' !== $db->last_error || '1' !== (string) $held ) { return false; } $choice = $db->get_var( is_multisite() ? $db->prepare( "SELECT meta_value FROM %i WHERE site_id=%d AND meta_key='logged_ai_delete_all_on_uninstall' LIMIT 1", $db->sitemeta, get_main_network_id() ) : "SELECT option_value FROM $db->options WHERE option_name='logged_ai_delete_all_on_uninstall' LIMIT 1" ); return '' === $db->last_error && in_array( $choice, array( '1', 'b:1;' ), true ) && self::origin( $db ) === $origin; }; $table = $db->base_prefix . 'logged_ai_pro_import_sources'; if ( ! preg_match( '/\A[a-zA-Z0-9_]{1,64}\z/D', $table ) || ! $allowed() || false === $db->query( $db->prepare( "DROP TABLE IF EXISTS %i", $table ) ) ) { return self::error( 'cleanup' ); } $found = $db->get_var( $db->prepare( 'SHOW TABLES LIKE %s', $db->esc_like( $table ) ) ); return '' === $db->last_error && null === $found && $allowed() ? true : self::error( 'cleanup' ); } }