Tools > "Delete all data on uninstall" sets frontglut_delete_on_uninstall). */ defined( 'WP_UNINSTALL_PLUGIN' ) || exit; // phpcs:disable PluginCheck.Security.DirectDB.UnescapedDBParameter,WordPress.DB.DirectDatabaseQuery -- queries target the plugin's own prefixed tables (names are constants, values are prepared). /** Runs inside a function so nothing leaks into the global scope. */ function frontglut_uninstall() { global $wpdb; if ( ! get_option( 'frontglut_delete_on_uninstall' ) ) { return; } foreach ( array( 'forms', 'audit', 'notifications', 'messages', 'tickets', 'ticket_replies', 'commissions', 'withdrawals', 'follows' ) as $table ) { $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}frontglut_{$table}" ); // phpcs:ignore WordPress.DB.PreparedSQL } foreach ( array( 'frontglut_settings', 'frontglut_modules', 'frontglut_db_version', 'frontglut_default_forms', 'frontglut_kb_form', 'frontglut_post_types', 'frontglut_taxonomies', 'frontglut_custom_roles', 'frontglut_reports_ver', 'frontglut_roles_reviewed', 'frontglut_flush_rewrite', 'frontglut_delete_on_uninstall' ) as $option ) { delete_option( $option ); } wp_clear_scheduled_hook( 'frontglut_daily' ); // The plugin is not loaded during uninstall, so the capability list is spelled out here (keep in sync with Caps::all()). $caps = array( 'frontglut_access_dashboard', 'frontglut_manage_posts', 'frontglut_publish_posts', 'frontglut_moderate', 'frontglut_upload_files', 'frontglut_manage_files', 'frontglut_manage_products', 'frontglut_manage_orders', 'frontglut_manage_coupons', 'frontglut_view_reports', 'frontglut_manage_customers', 'frontglut_manage_reviews', 'frontglut_manage_vendors', 'frontglut_is_vendor', 'frontglut_send_notices', 'frontglut_manage_tickets', 'frontglut_manage_settings' ); foreach ( wp_roles()->role_objects as $role ) { foreach ( $caps as $cap ) { $role->remove_cap( $cap ); } } remove_role( 'frontglut_vendor' ); $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\\_transient\\_frontglut\\_%' OR option_name LIKE '\\_transient\\_timeout\\_frontglut\\_%'" ); // phpcs:ignore WordPress.DB.PreparedSQL } frontglut_uninstall();