A talk about building a WordPress plugin that controls sidebar and widget visibility depending on the section/page/post being viewed.
Take Control ofYour WidgetsKaspars Dambiskonstruktors.com@konstruktorsWordCamp Norway 2013
View Slide
Who is this guy?
Latvian Champion in Autocross, 2007
World's first electric race carto finish Dakar rally in 2012
In ❤ since 2007
Custom Function Widgets
Widget ContextVersion 0.1
A Sidebar?
Sidebar "Minima" for Blogger
Sidebar "Cubric" in WordPress 1.5 (2005)
Sidebar "Twenty Twelve" in WordPress (2012)
Sidebars arefor related content
Widgets in Core Widgets were firstprovided by a plugin.Available in core sinceWP 2.2 (May 16, 2007).
Widgets in Core Available in core sinceWP 2.2 (May 16, 2007).
Problems1. Widgets are not attached to the content2. Widgets can't be edited in contextBUTWidgets provide flexibility
But Context Matters
Solutions1. Use multiple widget areas (sidebars) andtemplates to control their appearance2. Use a plugin
Need to know Template Tags(can't give to clients)Uses evil() eval();Widget Logic
WooSidebarsSidebars as a custom post type.Sidebars in context.
Creates a lot of widgetareas with customvisibility rules which aredefined in anothersection of the WordPressdashboard.WooSidebars
Display WidgetsAdds context UI to widget settings.
Individual posts andpages can be targetedonly by URL patterns,which are hard tounderstand.Widget ContextAdds context UI to widget settings.
Problems1. Widgets can't be edited on per-page basis.2. Widgets can't be re-orderedon per-page basis
Widget ContextExperiments
Concept ABring Widget UI into Page Edit Screen
Features:Per-page settings;Re-order widgets.Problems:Adding and hidingnew widgets requiresediting all pagesConcept A
Concept A Demo
Simple Show/Hideoption with a list ofavailable rules.Concept B
Concept B Demo
Concept C
Concept C Demo
Conclusions1. Current setup (Sidebar UI) doesn't allowgranular widget control.2. Granular setup (Post Edit UI) is hard tomanage on large scale sites.
konstruktors.com@konstruktorsgithub.com/kasparsd