Hi SiteOrigin Team!
I have created a simple widgets plugin to extend the site origin widgets bundle.
I’ve followed the hello widget tutorial and have managed to display a simple text widget and offered 3 different colours. It basically uses the same code as the button widget, but instead of ‘atom , flat and wire’ i have used ‘red, blue and green’.
I’ve included three less stylesheets, one for each colour. Everything works as expected.
The only problem i am facing is with the W3 total cache plugin, when i try to minify all the CSS into a single stylesheet, the hello widget styles are separated into different CSS styles including the base CSS file for the text widget. I’ve noticed all the site origin widget styles do get minified into a single file with the style.css file.
Are you guys aware how i can ensure all the CSS for the custom widgets gets minified along with the rest of the CSS into a single CSS file.
I’m guessing the code in question could be this:
function initialize() { $this->register_frontend_styles( array( array( 'hello-widget-base', '/wp-content/plugins/ss-widgets-bundle/ss-widgets/ss-hello-widget/css/style.css', array(), SOW_BUNDLE_VERSION ), ) ); } function get_template_name($instance) { return 'base'; } function get_style_name($instance) { if(empty($instance['design']['theme'])) return 'red'; return $instance['design']['theme']; }
Cheers,
Paul
Hi Paul
This is actually a good idea for something to add to the Widgets Bundle Base. I’ll look at some of the more popular caching plugins (like W3TC) and see if their APIs give us a way to add code to the minified files.
I’d have assumed they’d just work with all the Widgets Bundle styles because it uses a fairly standard method (wp_enqueue_style) to add stylesheets. I’ll look into why it’s not.
Hey Greg, thanks for replying!
I’m a total Newbie with building WordPress widgets and am just starting out with Site Origin Page Builder.
I wanted to add a bunch of my coded HTML/CSS/JS elements as widgets to the widgets bundle. So i’ve started at the very beginning and have to say it’s not the most daunting task (once you get your widgets to actually show up :)
But this problem i run into while testing the hello widget is a major problem, if i have say 15 widgets, thats a lot of stylesheets being added and would damage load times.
I’ve not got into adding JS to a widget yet, but i assume the same problem will be there even with W3TC minifying stuff.
I look forward to seeing what you can cook up with this and thank you for providing such an outstanding page builder!
Cheers,
Paul
Yeah, this is a very important thing that we’d need to sort out. Loading all those separate files is a lot of overhead.
Hopefully we can come up with a solution that just-works. So you wont need to change anything in your widgets, they’ll just automagically integrating with the popular caching plugins.
Are you planning on releasing this plugin to the general public or is this something for an internal project? Just interested :)
Hey Greg,
Excellent news, the support from you guys for this FREE page builder is outstanding. Really fills me with confidence to be spending time working with it.
As for releasing the plugin to the public, if i get it to a level where i feel i won’t be laughed out of the web development world then i will definitely release it.
Thanks again :)
And it’s awesome having developers like yourself working with Page Builder and Widgets Bundle. It’s our goal to make it easy for people to create beautiful content, but we’ll only be able to achieve this with the help the broader development community.
So thanks for spending time working in our platform – it really means a lot :)