bricks_fix_audit_issues

Phase 5IntermediateComplexity: 5/10
Auto-fix audit findings (missing alt text, placeholder text)

Overview

Automatically fixes issues identified by bricks_analyze_page. Supports 8 fix types: add alt text, fix heading order, extract inline styles to classes, add responsive breakpoints, fix color contrast, remove empty elements, optimize nesting, and add ARIA attributes.

Each fix returns before/after state so you can verify the changes. This is the action companion to the diagnostic bricks_analyze_page tool.

Use this as the final step in the Phase 5 polish workflow to automatically remediate common quality issues without manual element-by-element editing.

Key Features

8 Fix Types
Supports: add_alt_text (generates descriptive alt), fix_heading_order (corrects hierarchy), extract_class (moves inline styles to global class), add_responsive (adds breakpoint overrides), fix_contrast (adjusts colors), remove_empty (deletes empty elements), optimize_nesting (flattens unnecessary wrappers), add_aria (adds accessibility attributes).
Before/After State
Each applied fix returns the element state before and after the change, allowing verification and rollback if needed.
Parameterized Fixes
Each fix accepts optional params for fine-tuning: element_id to target specific elements, class_name for extract_class, color values for fix_contrast, etc.
Batch Application
Apply multiple fixes in a single call. Fixes are applied sequentially, so heading order fixes run before responsive fixes, ensuring consistent results.

When to Use

You have run bricks_analyze_page and want to auto-fix the reported issues
You need to quickly add alt text to images that are missing it
You want to fix heading hierarchy gaps (e.g., h1 followed by h3 without h2)
You want to extract repeated inline styles into a global class
You need to add responsive breakpoints to elements that lack them
Prerequisites
Run bricks_analyze_page first to identify issues
The target page must exist and contain Bricks elements
Bricks Builder version 1.9 or higher

When NOT to Use

You have not run bricks_analyze_page first — always diagnose before fixing
You want site-wide fixes — this tool works on one page at a time
You need manual control over the fix — use bricks_update_element instead

Parameters

2 Total Parameters2 Required

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
page_idnumberREQUIRED
The WordPress page (post) ID to apply fixes to.

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
fixesarray of objectsREQUIRED
Array of fix objects. Each has: type (enum: add_alt_text, fix_heading_order, extract_class, add_responsive, fix_contrast, remove_empty, optimize_nesting, add_aria) and optional params (object with fix-specific parameters like element_id, class_name, color value).

Code Examples


Warning: Undefined array key "example_output" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 12

Fix heading order and add alt text

Applies two common fixes: corrects heading hierarchy and adds alt text to images.

JSON
bricks_fix_audit_issues({
  page_id: 33,
  fixes: [
    { type: "fix_heading_order" },
    { type: "add_alt_text" }
  ]
})
// Returns:
// {
//   applied: [
//     { type: "fix_heading_order", element_id: "abc123",
//       before: { tag: "h3" }, after: { tag: "h2" }, success: true },
//     { type: "add_alt_text", element_id: "def456",
//       before: { alt: "" }, after: { alt: "Team meeting photo" }, success: true }
//   ],
//   summary: { attempted: 2, successful: 2, failed: 0 }
// }

Warning: Undefined array key "example_output" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 12

Extract inline styles to a global class

Extracts repeated inline typography styles into a new global class.

JSON
bricks_fix_audit_issues({
  page_id: 33,
  fixes: [
    {
      type: "extract_class",
      params: {
        element_id: "abc123",
        class_name: "heading-feature"
      }
    }
  ]
})

Common Mistakes


Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 1935

Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48

Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Always run bricks_analyze_page before bricks_fix_audit_issues. The analysis identifies which fixes are needed and provides the element IDs. Blindly applying fixes may produce unexpected results.

Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 1935

Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48

Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Some fixes like fix_contrast may change colors that were intentionally chosen. Always review the before/after state in the response to ensure the fix is desirable.

Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 1935

Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48

Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Before extracting inline styles into a new class, check bricks_get_global_classes to see if a suitable class already exists. Creating duplicate classes defeats the purpose.

Tips & Warnings

Tips & Warnings

Tip: The recommended workflow is: (1) bricks_analyze_page to find issues, (2) review findings, (3) bricks_fix_audit_issues for auto-fixable items, (4) bricks_update_element for manual fixes, (5) re-run analysis to verify.

Tip: The add_alt_text fix generates descriptive alt text based on the image context (surrounding headings, nearby text). Review generated alt text for accuracy.

Warning: The remove_empty fix permanently deletes elements with no content or children. This cannot be undone unless you restore from page history.

Warning: The optimize_nesting fix removes unnecessary wrapper divs. If those wrappers have CSS classes or custom styles applied, the styling may be lost.

Return Values

FieldTypeDescription
appliedarrayArray of applied fix results, each with: type, element_id, before (previous state), after (new state), success (boolean).
summaryobjectSummary with total fixes attempted, successful, and failed counts.

Related Tools

Technical Details

Tool ID
bricks_fix_audit_issues
API Endpoint
/analysis/fix
HTTP Method
POST
Namespace
analysis
Source File
analysis/page-audit.ts
Version
1.0
Min Bricks Version
1.9
Requires Auth
Yes

Changelog

v1.0
Initial release with 8 auto-fix types: alt text, heading order, class extraction, responsive, contrast, empty removal, nesting optimization, ARIA attributes.
20250101