Closed inspiredearth closed 1 year ago
Hi @inspiredearth
I see you've also added this here now haha.
Alright, first things first, I consider this advanced usage and will only implement this in code, not through the UI.
I think this is best done through filters and I can think if a two:
ocs_enable_frontend
> Same as the setting, enabled by default. Renders frontend HTML.ocs_enable_assets
> Load CSS/JS (also inline)What do you think?
Hi @JoryHogeveen. Thanks for giving this consideration. I also (just now) read your responses on WP forums.
Yes, I think having a couple of filters as you've suggested would be handy for this purpose.
I totally understand that this is likely something most users won't bother with (although they likely should ... because, for optimisation purposes, I think it's important to be able to cut back how much extraneous code is loading site-wide for features that might only be used on a single page or two ... I come across so many plugins and page builders etc., that load a heap of code and CSS files which are unnecessary much of the time... but that's another story for another day!).
So yes, only being able to do this via code is totally fine with me, and would be great.
@inspiredearth
I can understand what you mean regarding optimizing asset loading. Most users use this plugin for an off-canvas menu I suppose but yes, having a bit more control of what is happening is always nice.
I've added the suggested filters for v0.5.8.
Could you test the dev
branch and let me know if this works for you?
All changes: https://github.com/JoryHogeveen/off-canvas-sidebars/pull/111
Let me know! Cheers, Jory
Hi @inspiredearth
I didn't hear from you anymore, can you please let me know if the update works for you?
Branch: https://github.com/JoryHogeveen/off-canvas-sidebars/tree/dev PR: https://github.com/JoryHogeveen/off-canvas-sidebars/pull/111
Let me know! Cheers, Jory
Closing topic as fixed in 0.5.8
Description
Describe the solution you'd like Currently sidebars are either enabled site-wide or disabled site-wide.
I can think of plenty of situations where it's not necessary to have a sidebar enabled site-wide. For example, I have a sidebar set up for the Woocommerce search results and shop pages. I don't need the sidebar code loaded on any other pages, including homepage, checkout pages, single product pages, etc. So it is unnecessarily adding additional weight to those pages.
Is your feature request related to a problem? Please describe. The problem is simply that it's inefficient to be loading all the sidebar data/code on pages where the sidebar isn't needed.
Other notes
Describe alternatives you've considered I can set up some PHP to conditionally control when OCS can and can't load, as mentioned here.
Which is fine when only using one sidebar used on one set of pages on the site. But that would be come unwieldy to do when handling multiple sidebars, intended to display on different sets of pages.
Also, I see that wordpress.org user "dvieira" reports that the JS and CSS still loads, even when the sidebar is programatically disabled.