Connectors), shared with any other // plugin that uses them: they stay global $wpdb; // Settings and transients (also the API keys that versions before 1.0 kept in their own settings, if still there) $options = $wpdb->get_col( $wpdb->prepare( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- on uninstall, to find every setting of the plugin: no API lists options by prefix "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s", $wpdb->esc_like( 'velischat_' ) . '%', $wpdb->esc_like( '_transient_velischat_' ) . '%', $wpdb->esc_like( '_transient_timeout_velischat_' ) . '%' ) ); foreach( $options as $option ){ delete_option( $option ); } // The users' choice to hide the upgrade banner (update_user_option(): per site) delete_metadata( 'user', 0, $wpdb->get_blog_prefix() . 'velischat_upgrade_hidden', '', true ); // The folder of the context PDF of the versions up to 0.9.9, if still there (velis-chatbot up to 0.8.1) $upload_dir = wp_upload_dir( null, false ); foreach( array( 'velischat', 'velis-chatbot' ) as $name ){ $dir = trailingslashit( $upload_dir[ 'basedir' ] ) . $name; if( ! is_dir( $dir ) ){ continue; } foreach( array_merge( (array) glob( $dir . '/context-*.pdf' ), array( $dir . '/.htaccess', $dir . '/web.config', $dir . '/index.php' ) ) as $file ){ wp_delete_file( $file ); } // Only if nothing else was put in it if( ! class_exists( 'WP_Filesystem_Direct' ) ){ require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php'; } ( new WP_Filesystem_Direct( null ) )->rmdir( $dir ); } } if( is_multisite() ){ foreach( get_sites( array( 'fields' => 'ids', 'number' => 0 ) ) as $velischat_site_id ){ switch_to_blog( $velischat_site_id ); velischat_uninstall_site(); restore_current_blog(); } } else { velischat_uninstall_site(); }