query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $wpdb->prefix . $table ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery } foreach ( array( 'qrsvp_settings', 'qrsvp_db_version', 'qrsvp_kit_snapshot', 'qrsvp_legal_pages', 'qrsvp_retention_last_run', 'qrsvp_home_before', 'qrsvp_self_erased', 'qrsvp_rewrite_version', 'qrsvp_legal_layout' ) as $option ) { delete_option( $option ); } $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\\_transient\\_qrsvp\\_%' OR option_name LIKE '\\_transient\\_timeout\\_qrsvp\\_%'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery // Cached QR images. $uploads = wp_upload_dir( null, false ); $dir = trailingslashit( $uploads['basedir'] ) . 'qrsvp'; if ( is_dir( $dir . '/qr' ) ) { foreach ( (array) glob( $dir . '/qr/*' ) as $file ) { wp_delete_file( $file ); } foreach ( array( '/qr/index.php', '/index.php', '/.htaccess' ) as $file ) { wp_delete_file( $dir . $file ); } // The folders through WordPress's filesystem, as QRSVP_Files writes // them (this file stands alone). Not recursive: anything someone // else put there stays, and so does its folder. require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php'; $fs = new WP_Filesystem_Direct( null ); $fs->rmdir( $dir . '/qr' ); $fs->rmdir( $dir ); } remove_role( 'qrsvp_door_staff' ); remove_role( 'qrsvp_event_manager' ); // Which events each person could work on (QRSVP → Team). delete_metadata( 'user', 0, 'qrsvp_event_access', '', true ); foreach ( wp_roles()->role_objects as $role ) { foreach ( array( 'qrsvp_manage_events', 'qrsvp_check_in', 'qrsvp_view_reports' ) as $cap ) { $role->remove_cap( $cap ); } } // Pages the plugin generated (event, door, ticket, confirmation, legal // drafts) are the owner's content now and are left alone. } if ( is_multisite() ) { foreach ( get_sites( array( 'fields' => 'ids', 'number' => 0 ) ) as $qrsvp_site ) { switch_to_blog( (int) $qrsvp_site ); qrsvp_uninstall_site(); restore_current_blog(); } } else { qrsvp_uninstall_site(); }