Home>Support>Page Builder Widgets Override

Page Builder Widgets Override

By gruvii, 10 years ago. Last reply by lenkapage.com, 9 years ago.

I was wondering if you could somehow add the ability to override or extend the page builder widgets. I really wanted to be able to add an additional class and an alt tag to the image widget but I didn’t want to install yet another widget since yours are already great, work well, etc. For now I just edited the basic.php file in the widgets folder which I know is not the proper way to do this and will get removed upon an update. Below is my code if you could add it to yours, worst case scenario.

class SiteOrigin_Panels_Widgets_Image extends WP_Widget {
function __construct() {
parent::__construct(
‘siteorigin-panels-image’,
__( ‘Image (PB)’, ‘so-panels’ ),
array(
‘description’ => __( ‘Displays a simple image.’, ‘so-panels’ ),
)
);
}

/**
* @param array $args
* @param array $instance
*/
function widget( $args, $instance ) {
echo $args[‘before_widget’];
if(!empty($instance[‘href’])) echo ”;
echo ”;
if(!empty($instance[‘href’])) echo ”;
echo $args[‘after_widget’];
}

function update($new, $old){
$new = wp_parse_args($new, array(
‘src’ => ”,
‘href’ => ”,
‘alt’ => ”,
‘class’ => ”,
));
return $new;
}

function form( $instance ) {
$instance = wp_parse_args($instance, array(
‘src’ => ”,
‘href’ => ”,
‘alt’ => ”,
‘class’ => ”,
));

?>

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

  1. 9 years, 11 months ago lenkapage.com

    I’d be very much interested in having the option of adding classes to the image widget as well.

    There is the option to use the classes automatically assigned to each image, but this is not ideal and makes for unclear and repetitive code in the stylesheet.

    Lenka

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