I am trying to make a simple widget to show some icons. The widget will only have icons. The problem I am having is that for some reason wordpress widget preview won’t display them. Here is the code.
class Widget_Links extends WP_Widget {
public function __construct() {
parent::__construct('simple-widget', 'Simple Widget', $options);
}
public function widget($args, $instance) {
echo $args['before_widget'];
Plugin::show_links();
echo $args['after_widget'];
}
public function form($instance) {
}
public function update($new_instance, $old_instance) {
}
}
There is obviously some kind of mechanism in wordpress that doesn’t display a preview if there is no content. if I echo some content along with it the icons display fine. So obviously there is no css issues or anything like that.
public function widget($args, $instance) {
echo $args['before_widget'];
echo 'Hello';
Plugin::show_links();
echo $args['after_widget'];
}
I am currently using font awesome for the icons. I am just using css but ive tried adding the svgs directly also but no luck. It works if I add them in an image tag but then I have no control over the fill/color ect. So my next thought would be to just add some content if it’s in a preview window with $this->is_preview()
but for some reason it always returns false. So I’m all out of ideas.
Anyone else experienced this issue? Any help here would be appreciated.