elementor / elementor/elementor
`remove_control_from_stack` doesn't work with 'style_controls` from stack (when Optimized Control Loading is enabled)
- Dominant language
- PHP
- Stars
- 7.1k
- Forks
- 1.6k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 193
Description
### Prerequisites
- [X] I have searched for similar issues in open and closed tickets and cannot find a duplicate.
- [X] I have troubleshooted my issue, and it still exists against the latest stable version of Elementor.
### Description
When enabling _Optimized Control Loading_ the new 'style_controls' group from the controls stacks cannot be removed.
Tracking it down to `remove_control_from_stack` I noticed only 'controls' is unset ex:
https://github.com/elementor/elementor/blob/787e74cdc2256fde6c6a36294d9dd4ce59be1c99/includes/managers/controls.php#L907
However there should also be an unset for 'style_controls' ex:
```unset( $this->stacks[ $stack_id ]['style_controls'][ $control_id ] );```
### Steps to reproduce
Use this code:
```
add_action( 'elementor/element/kit/section_settings-layout/before_section_end', function($stack){
$stack->remove_responsive_control( 'container_width' );
});
```
It removes the control from the editor in _Site Settings > Layout > Container Width_, however not the the CSS output which will still be generated.
### Expected behavior
To remove the control's css output.
### Isolating the problem
- [X] This bug happens when only the Elementor (and Elementor Pro) plugins are active.
- [X] This bug happens with the Hello Elementor theme active.
- [X] I can reproduce this bug consistently by following the steps I described above.
### Elementor System Info
```txt
== Server Environment ==
Operating System: Darwin
Software: nginx/1.16.0
MySQL version: MySQL Community Server - GPL v8.0.16
PHP Version: 8.1.23
PHP Memory Limit: 256M
PHP Max Input Vars: 4000
PHP Max Post Size: 1000M
GD Installed: Yes
ZIP Installed: Yes
Write Permissions: All right
Elementor Library: Connected
== WordPress Environment ==
Version: 6.5.4
Site URL: http://hello.local
Home URL: http://hello.local
WP Multisite: No
Max Upload Size: 300 MB
Memory limit: 40M
Max Memory limit: 256M
Permalink Structure: /%postname%/
Language: en_US
Timezone: 0
Admin Email: dev-email@wpengine.local
Debug Mode: Inactive
== Theme ==
Name: Hello Elementor
Version: 3.1.0
Author: Elementor Team
Child Theme: No
== User ==
Role: administrator
WP Profile lang: en-US
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
== Active Plugins ==
Elementor
Version: 3.22.1
Author: Elementor.com
WooCommerce
Version: 9.0.1
Author: Automattic
== Elementor Experiments ==
Improved Asset Loading: Active by default
Improved CSS Loading: Active by default
Inline Font Icons: Inactive by default
Additional Custom Breakpoints: Active by default
Flexbox Container: Active by default
Grid Container: Active by default
Upgrade Swiper Library: Active by default
Nested Elements Performance: Inactive by default
Optimized Control Loading: Inactive by default
Optimized Markup: Inactive by default
Plugin Onboarding: Active by default
Header & Footer: Active by default
Elementor Home Screen: Active by default
Editor Top Bar: Inactive by default
Build with AI: Active by default
Landing Pages: Active by default
Nested Elements: Inactive by default
Lazy Load Background Images: Inactive by default
Element Caching: Inactive by default
Conversion Center: Inactive by default
== Log ==
PHP: showing 1 of 1PHP: 2023-09-17 08:47:57 [notice X 1][/Users/Local Sites/hello/app/public/wp-content/plugins/elementor/core/upgrade/manager.php::63] version_compare(): Passing null to parameter #1 ($version1) of type string is deprecated [array (
'trace' => '
#0: Elementor\Core\Logger\Manager -> shutdown()
',
)]
Log: showing 7 of 72024-06-21 15:48:06 [info] elementor::elementor_updater Started
2024-06-21 15:48:06 [info] Elementor/Upgrades - _on_each_version Start
2024-06-21 15:48:06 [info] Elementor/Upgrades - _on_each_version Finished
2024-06-21 15:48:06 [info] Elementor/Upgrades - _v_3_17_0_site_settings_updates Start
2024-06-21 15:48:06 [info] Elementor/Upgrades - _v_3_17_0_site_settings_updates Finished
2024-06-21 15:48:06 [info] Elementor data updater process has been completed. [array (
'plugin' => 'Elementor',
'from' => '3.16.3',
'to' => '3.22.1',
)]
2024-06-21 15:48:06 [info] Elementor data updater process has been queued. [array (
'plugin' => 'Elementor',
'from' => '3.16.3',
'to' => '3.22.1',
)]
== Elementor - Compatibility Tag ==
```
### Agreement
- [X] I agree that my issue may be closed without action if it doesn't meet all the requirements.
Contributor guide
Assessment
This issue has not been assessed yet.