Skip to content

Keep widget classes on non-TG widgets rendered in Elementor - #93

Open
deepench wants to merge 1 commit into
developfrom
fix/elementor-widget-wrapper-classes
Open

deepench wants to merge 1 commit into
developfrom
fix/elementor-widget-wrapper-classes

Conversation

@deepench

@deepench deepench commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Free-theme counterpart of themegrill/accelerate-pro#63 (the same filter and helper are in the free theme).

Changes proposed in this Pull Request:

Core and WooCommerce widgets added through Elementor's WordPress widgets rendered unstyled. The theme's elementor/widgets/wordpress/widget_args filter builds the wrapper as <aside class="widget {classes}">, but accelerate_widget_class_names() only knows the theme's own widgets and returned an empty string for everything else, so the wrapper was <aside class="widget "> and selectors such as widget_shopping_cart never matched. For widgets outside the theme's list the class is now read from the registered widget's own classname option, and the value is escaped; the theme's own widgets still use the existing map and are unchanged.

The issue suggests preserving the incoming before_widget, but Elementor passes an empty before_widget to this filter (its own wrapper is separate), so there is nothing to preserve. The id is also left out on purpose: Elementor's widget id is the widget type, so it would repeat if the same widget is used twice on a page.

Verified live on an Elementor page containing the Cart, Search and TG: Call To Action widgets (Elementor enabled for the test requests only, test page deleted afterwards):

Before After
Cart wrapper widget widget woocommerce widget_shopping_cart
Search wrapper widget widget widget_search
TG: Call To Action wrapper widget widget_call_to_action unchanged
Mini-cart item padding-left 0 32px
Mini-cart remove link position static absolute
Mini-cart thumbnail width 300px 32px

Demo: before and after

Before After
Before After

(screenshots and gif are in a secret gist, fine to delete once reviewed)

How to test the changes in this Pull Request:

  1. Activate Elementor and WooCommerce and put an item in the cart.
  2. Edit a page with Elementor, add the WordPress > Cart (mini-cart) widget and the Search widget, and publish.
  3. View the page and inspect the wrappers: they should be widget woocommerce widget_shopping_cart and widget widget_search.
  4. Confirm the mini-cart shows the item padded, with the remove link at the side and a small thumbnail.
  5. Add a TG widget (e.g. Call To Action) and confirm its wrapper is still widget widget_call_to_action.

Types of changes:

  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (modification of the currently available functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Other information:

  • Have you added an explanation of what your changes do and why you would like us to include them?
  • Have you successfully ran tests with your changes locally?
  • Have you updated the documentation accordingly?

Changelog entry

Fix - Core and WooCommerce widgets added through Elementor now keep their widget classes and styling.

The Elementor widget-args filter builds the wrapper as
<aside class="widget {classes}">, but the class lookup only knows the
theme's own widgets and returned an empty string for everything else. Core
and WooCommerce widgets therefore rendered as <aside class="widget "> and
lost selectors like widget_shopping_cart that their CSS depends on. For
widgets outside the theme's list the class is now read from the registered
widget (its classname option), and the value is escaped. The theme's own
widgets are unchanged.

Verified live on an Elementor page: the Cart widget wrapper went from
"widget " to "widget woocommerce widget_shopping_cart", and the mini-cart
item padding, remove-link position and thumbnail width went from 0 / static
/ 300px to 32px / absolute / 32px.
@deepench deepench added the bug label Oct 1, 2026
@tg-autopilot
tg-autopilot requested a lite review from Copilot October 1, 2026 06:34
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

QA suite — refused, no regression spec

This PR changes product source but adds no spec, so the suite was
refused before booting WordPress — running it just to report the same
thing at the end costs runner minutes for nothing. Run
/claudegrill:verify-fix locally and let write-spec add the guard
to this branch, then push again.

Source files changed with no matching spec
inc/elementor/elementor.php

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved review comments; the focused fix preserves existing behavior while restoring widget styling.

Review effort: Lite
Findings: None

What changed in this PR

Fixes missing CSS classes on core and WooCommerce widgets rendered through Elementor.

Changes:

  • Falls back to registered widget classname values.
  • Escapes resolved widget classes.
  • Preserves existing theme widget mappings.
File Summary
inc/​elementor/​elementor.php Adds fallback class resolution and output escaping.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@deepench
deepench requested a review from subin-shk October 1, 2026 06:38
@deepench deepench self-assigned this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants