elementor / elementor/elementor
Global Settings hook not saving additional settings to database
- Dominant language
- PHP
- Stars
- 7.1k
- Forks
- 1.6k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 193
Description
- [x] I have searched for similar features requests in both open and closed tickets and cannot find a duplicate.
- [x] The feature is still missing in the latest stable version of Elementor ( Elementor Pro. )
### What problem is your feature request going to solve? Please describe.
I'm trying to add additional settings to the "Global Settings" panel by using the `elementor/element/global-settings/style/after_section_end` hook.
It is adding the controls there fine, and also triggers AJAX `save` request on changing any of these new control's values, but these values are not actually being saved.
That is because the `save_settings_to_db()` located in `Elementor\Core\Settings\General\Manager` class (which triggers the database saving) picks up the controls manually defined in the `Elementor\Core\Settings\General\Model::get_controls_list()`
### Describe the solution you'd like
There are 2 potential solutions:
1. **Easy:** A filter that applies `array_merge` to add external controls to the `Elementor\Core\Settings\General\Model::get_controls_list()`
2. **More work:** Fetching controls from the stack instead of hardcoded function, so that covers the other controls added using a hook like `elementor/element/global-settings/{$section_id}/after_section_end`
### Describe alternatives you've considered
Overwriting the `get_controls_list()` function from `\Elementor\Core\Settings\General\Model` but that is not working because the `Settings\General\Manager` directly accesses `Model::get_controls_list()` so there's no scope of overwriting AFAIK.
**If there's any way to overwrite the `\Elementor\Core\Settings\General\Model::get_controls_list()` to add more controls to the array, it would be much appreciated if you can let me know about it.**
Contributor guide
Assessment
This issue has not been assessed yet.