Skip to content

Extension to the Customize Posts and Shortcake plugins to add post/page-specific widget areas in content (an implementation of content blocks).

Notifications You must be signed in to change notification settings

xwp/wp-customize-content-widgets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 

Repository files navigation

Customize Content Widgets

Extension to the Customize Posts and Shortcake plugins to add post/page-specific widget areas in content (an implementation of content blocks). Also facilitate for dynamic page/post specific widget areas.

Ideas for how to implement content blocks as widgets in the Customizer inside the post content, powered by Customize Posts, Shortcake, and (ideally) JS Widgets:

  1. Register a new shortcode for widget_area which takes a single argument to indicate the widget area to embed (sidebar ID). (Additional shortcake attributes arguments could also be supplied according to the normal sidebar args passed into register_sidebar()).
  2. Create a new content_widget_area post type to store the widget configurations for the widget areas (sidebars) registered for a given post/page.
  3. In the Shortcode UI, provide a dropdown of all the existing registered sidebars with an option to create a new dynamic one.
  4. Add a new “Add Widget Area” media button as a shortcut for opening the media modal and selecting the widget area to embed.
  5. Implement the Shortcode UI (Shortcake) preview extensions to allow the widget_area to be presented in the visual editor as a list of widgets, similar to how they appear in a collapsed state on the admin page or Customizer pane
  6. The TinyMCE view on the widget area preview should have an Edit link to change which widget area is displayed, and Edit button to open the sidebar Customizer section, and add an edit button with each widget listed in the TinyMCE view which provides a deep link to the widget control in the Customizer sidebar section. Note than when the sidebar/widget is focused in the Customizer, the back button should be overridden to return the user back to the post being edited, instead of the list of sidebars. See #32683.
  7. Implement lazy-loading of widget settings and sidebars so widgets and sidebars needn't all be exported up-front when the Customizer first loads (see #28580). See also Optimized Widget Registration, which is needed to prevent widgets from being registered unnecessarily.
  8. Make sure the Shortcode TinyMCE view in the post is synced when the corresponding sidebar and widgets are updated.

For background, see:

Page-Specific Sidebars Outside Content Area

For page-specific dynamically-generated sidebars (not statically declared via register_sidebar() in the theme's functions.php) that appear outside of the post content, this could also be implemented as part of this plugin. There could be page-specific overrides for a theme's widget areas. Or rather, to have page-specific sidebars registered for various widgetized templates. So in the Customizer you'd need to be able to dynamically create new widget areas. There could be a postmeta attached to a given post/page which has a list of the widget IDs contained in the widget area. Then when that post/page is loaded into the Customizer, there could be a check to see if this postmeta is populated (there could be acheckbox control for manipulating this postmeta via the Customize Posts plugin). If so, then the register_sidebar() call could be done and inside of the template there could be a dynamic_sidebar() call referencing the unique post/page-specific sidebar ID. These page-specific sidebars could then be shown in the Customizer by sending a message from the Customizer preview to the to the Customizer pane to get it to dynamically create the new Customizer section for that widget area along with the controls for that widget area. That would require some custom JS, naturally. This would be needed because the register_sidebar() calls for that page when the Customizer initially loads (or when any other page on the frontend loads).

About

Extension to the Customize Posts and Shortcake plugins to add post/page-specific widget areas in content (an implementation of content blocks).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published