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’ => ”,
));
?>
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