Forum Replies Created

Viewing 1 replies (of 1 total)
  • This is a bit late, but this is exactly the same thing that I needed to do. I tried for a while to push the class into the widget options in different ways but failed with everything so I just went with a preg_replace on $before_widget.

    This is how it looked for me:

    function widget($args, $instance) {
    	extract($args);
    
    	$color = $instance['color'];
    	$before_widget = preg_replace('/class="(.*?)"/i', 'class="$1 '.$color.'"', $before_widget);
    
    	echo $before_widget;
    		echo '<h3>'.$instance['title'].'</h3>';
    		echo '<div class="text">'.$instance['text'].'</div>';
    	echo $after_widget;
    }
Viewing 1 replies (of 1 total)