Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Take Control of Your Widgets

661eb21385c25c01ad64ab9e13b37331?s=47 Kaspars
January 26, 2013

Take Control of Your Widgets

A talk about building a WordPress plugin that controls sidebar and widget visibility depending on the section/page/post being viewed.

661eb21385c25c01ad64ab9e13b37331?s=128

Kaspars

January 26, 2013
Tweet

Transcript

  1. Take Control of Your Widgets Kaspars Dambis konstruktors.com @konstruktors WordCamp

    Norway 2013
  2. Who is this guy?

  3. Latvian Champion in Autocross, 2007

  4. World's first electric race car to finish Dakar rally in

    2012
  5. None
  6. None
  7. In ❤ since 2007

  8. None
  9. Custom Function Widgets

  10. Custom Function Widgets

  11. Widget Context Version 0.1

  12. A Sidebar?

  13. Sidebar "Minima" for Blogger

  14. Sidebar "Cubric" in WordPress 1.5 (2005)

  15. Sidebar "Twenty Twelve" in WordPress (2012)

  16. Sidebars are for related content

  17. Widgets in Core Widgets were first provided by a plugin.

    Available in core since WP 2.2 (May 16, 2007).
  18. Widgets in Core Available in core since WP 2.2 (May

    16, 2007).
  19. Problems 1. Widgets are not attached to the content 2.

    Widgets can't be edited in context BUT Widgets provide flexibility
  20. But Context Matters

  21. Solutions 1. Use multiple widget areas (sidebars) and templates to

    control their appearance 2. Use a plugin
  22. Solutions 1. Use multiple widget areas (sidebars) and templates to

    control their appearance 2. Use a plugin
  23. Need to know Template Tags (can't give to clients) Uses

    evil() eval(); Widget Logic
  24. WooSidebars Sidebars as a custom post type. Sidebars in context.

  25. Creates a lot of widget areas with custom visibility rules

    which are defined in another section of the WordPress dashboard. WooSidebars
  26. Display Widgets Adds context UI to widget settings.

  27. Individual posts and pages can be targeted only by URL

    patterns, which are hard to understand. Widget Context Adds context UI to widget settings.
  28. Problems 1. Widgets can't be edited on per-page basis. 2.

    Widgets can't be re-ordered on per-page basis
  29. Widget Context Experiments

  30. Concept A Bring Widget UI into Page Edit Screen

  31. Features: Per-page settings; Re-order widgets. Problems: Adding and hiding new

    widgets requires editing all pages Concept A
  32. Concept A Demo

  33. Simple Show/Hide option with a list of available rules. Concept

    B
  34. Concept B Demo

  35. Concept C

  36. Concept C Demo

  37. Conclusions 1. Current setup (Sidebar UI) doesn't allow granular widget

    control. 2. Granular setup (Post Edit UI) is hard to manage on large scale sites.
  38. konstruktors.com @konstruktors github.com/kasparsd