bricks_delete_component
Overview
Deletes a Bricks Component from the site. By default, the tool checks whether the component is currently used on any pages and returns a warning with usage details if instances are found. Use force=true to bypass this safety check and delete the component regardless of usage.
Deleting a component that is in use will cause existing instances on pages to break or render empty. Always check usage first with bricks_get_component_usage before deleting.
Key Features
When to Use
When cleaning up test or draft components during development
When replacing a component with a better version (delete old after migrating instances)
Recommended: Run bricks_get_component_usage to verify no active instances exist
If instances exist, update them to use a different component or inline the elements first
When NOT to Use
When you want to update a component — use bricks_update_component instead
When unsure if the component is in use — run bricks_get_component_usage first
Parameters
Warning: Undefined array key "param_enum_values" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 28
component_idstringREQUIREDWarning: Undefined array key "param_enum_values" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 28
forcebooleanoptionalfalseCode Examples
Safe delete with usage check
Attempts to delete a component. If it is in use, returns a warning instead of deleting.
bricks_delete_component({
component_id: "abc123",
force: false
})// If unused:
{ "success": true, "message": "Component deleted successfully" }
// If in use:
{ "success": false, "message": "Component is in use on 3 pages. Use force=true to delete anyway.", "usage": { "pages": [33, 45, 67], "instance_count": 8 } }Common Mistakes
bricks_delete_component({ component_id: "abc123", force: true })// Step 1: Check usage
bricks_get_component_usage({ component_id: "abc123" })
// Step 2: Migrate instances if needed
// Step 3: Then delete safely
bricks_delete_component({ component_id: "abc123" })Tips & Warnings
Destructive operation: Deleting a component that is in use will cause existing instances to render empty or break. Always check usage first.
No undo: Component deletion cannot be undone. If you need a backup, use bricks_get_components({ include_elements: true }) to export the component definition before deleting.