Home>Support>SiteOrigin Widgets Class needs filter over get_less_variables()

SiteOrigin Widgets Class needs filter over get_less_variables()

Notice: This thread is over two years old; the information may be outdated. Please consider creating a new thread if you require free support. If you have an active SiteOrigin Premium license, you can email our premium support desk at [email protected].

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;

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 8 years, 6 months ago Alex S
    Hi, I Work Here

    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.

  2. 8 years, 6 months ago Tim Zook

    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.

  3. 8 years, 6 months ago Alex S
    Hi, I Work Here

    Hi Tim,

    Thank you for your contribution! :)

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More