One of the only important functions on the SiteOrigin_Widget that does not have a filter to override it’s value is the “get_less_variables()” function. Normally this wouldn’t be such a big deal, but it’s very important that we be able to override this with a filter because it’s used by the “get_style_hash()” function which uniquely identifies the instance. This means that with the way it currently works, it’s impossible to add new editor fields to a widget via the “siteorigin_widgets_form_options” filter and have it work properly, because the new field values will not be properly factored into the widget’s style hash and it will be grouped with other widgets that have different values of the new field. I could add this new field by subclassing the widget class and overriding the “get_less_variables()” function that way, but this is a rather heavyweight solution for what I want to do, which is just add one simple editor field that adds a particular CSS style to the widget in order to customize it for my theme.
My suggested fix is to add a filter to the following two places like so:
//so-widgets-bundle/base/siteorigin-widget.class.php:788 $vars = apply_filters( 'siteorigin_widgets_less_variables_' . $this->id_base, $this->get_less_variables( $instance ), $instance, $this);
//so-widgets-bundle/base/siteorigin-widget.class.php:1035 $less_variables = apply_filters( 'siteorigin_widgets_less_variables_' . $this->id_base, $this->get_less_variables( $instance ), $instance, $this); $vars = method_exists($this, 'get_style_hash_variables') ? $this->get_style_hash_variables( $instance ) : $less_variables;
Hi Tim,
I can definitely see the value in this change. Would it be possible for you to submit a pull request to the SiteOrigin Widgets Bundle repo with this change? If you would rather not, I can submit one for you.
Excellent, I didn’t realize that this plugin had a public GitHub repository. I’ve submitted a pull request there.
Thanks for your feedback, Alex.
Hi Tim,
Thank you for your contribution! :)