reset-plugin-data
File: bin/reset-plugin-data.php
Wipes every database entry and generated file created by the plugin. Use this to get back to a clean slate between blueprint tests, demo installs, or development iterations.
Usage
Run from the WordPress root directory:
wp eval-file wp-content/plugins/sanil-website-builder/bin/reset-plugin-data.php
No arguments. The script always wipes everything.
What It Deletes
1. Custom Templates Table
Target: {prefix}sanilwb_templates
All template rows are removed via TRUNCATE. This resets the auto-increment counter as well, so the next inserted template will start from ID 1 again.
2. Plugin Options
Target: wp_options where option_name LIKE 'sanilwb_%'
Every option the plugin writes uses the sanilwb_ prefix, so a single DELETE ... LIKE query catches all of them. This includes:
| Option | Written by |
|---|---|
sanilwb_theme_options |
Theme Options — colors, typography, logo, social |
sanilwb_active_fonts |
Font Sync — list of fonts in use |
sanilwb_fonts_css_version |
Font Downloader — hash of the last-downloaded font CSS |
sanilwb_fallback_font_url |
Font Downloader — Google Fonts URL used as fallback |
sanilwb_blueprint_snapshot |
Blueprints — snapshot taken before last install |
sanilwb_blueprint_ref_map |
Blueprints — post ID mapping during install |
sanilwb_blueprint_install_status |
Blueprints — in_progress or completed |
sanilwb_blueprint_last_name |
Blueprints — name of the last applied blueprint |
sanilwb_blueprint_last_applied |
Blueprints — slug of the last applied blueprint |
Legacy/orphaned keys still swept up by the same LIKE query, if present: sanilwb_header_preset, sanilwb_header_preset_settings, sanilwb_footer_preset, sanilwb_footer_preset_settings, sanilwb_template_assignment_{type}. Nothing writes these anymore — the old header/footer folder-preset system and the legacy template-assignment path have both been removed — but the script's DELETE ... LIKE 'sanilwb_%' query is generic and doesn't distinguish current keys from stale ones, so any of these left over from before the migration are still cleared.
3. Page Builder Post Meta
Target: wp_postmeta where meta_key = 'sanilwb_data'
Removes the page builder layout JSON from every post and page that had the builder applied. The posts themselves are not deleted — only the sanilwb_data meta key is removed.
4. Cached CSS Files
Target: wp-content/uploads/sanilwb/
The entire directory is deleted recursively. This directory is created by SANILWB_CSS_Cache and contains:
page-css/{id}.css— cached CSS for a page's own directly-authored contenttemplate-css/{id}.css— cached CSS for a Templatesite-layout-css/{id}.css— cached CSS for a Site Layout row
5. Downloaded Font Files
Target: wp-content/uploads/sanilwb-fonts/
The entire directory is deleted recursively. This directory is created by the Font Downloader when Google Fonts are self-hosted. It contains the font CSS file and all downloaded font face files (.woff2, .woff, etc.).
What It Does NOT Delete
| Item | Reason |
|---|---|
| Posts and pages created by Blueprints | No persistent post marker is stored after the install finishes |
Site Layout rows ({prefix}sanilwb_site_layouts table) |
This script does not currently truncate this table — Site Layout entries and their schema_json/condition_json survive a reset |
| WordPress core options modified by Blueprints | show_on_front, page_on_front, sidebars_widgets, widget_block, widget_text — these belong to WP core and could affect other functionality |
The wp_sanilwb_templates table structure |
Only rows are removed; the table schema is preserved |
If you need to also reset the WordPress reading settings and widget areas, do that manually via the WordPress admin or with additional wp option update calls.
Example Output
Truncated table: wp_sanilwb_templates
Deleted options: 14 rows (option_name LIKE 'sanilwb_%')
Deleted post meta: 3 rows (meta_key = 'sanilwb_data')
Deleted directory: /var/www/html/wp-content/uploads/sanilwb
Deleted directory: /var/www/html/wp-content/uploads/sanilwb-fonts
Done. All plugin data has been wiped.
Implementation Notes
- Uses
TRUNCATE(notDELETE) on the templates table — faster and resets auto-increment. - Uses a
LIKE 'sanilwb_%'query onwp_options— catches all current and future plugin options without needing to list them individually. - Directory deletion uses PHP's
RecursiveDirectoryIteratorinCHILD_FIRSTorder, which ensures files are deleted before their parent directories. - The script is safe to run even when directories don't exist — it checks with
is_dir()before attempting deletion and prints a "skipped" message instead of erroring.