Make WordPress Core

Opened 10 years ago

Closed 7 years ago

Last modified 7 years ago

#32987 closed enhancement (wontfix)

Adding filters to allow alternate sidebar storage for registered sidebars

Reported by: welcher's profile welcher Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3
Component: Widgets Keywords: has-patch dev-feedback bulk-reopened
Focuses: Cc:

Description

Currently sidebars are stored in the sidebars_widgets option in the database which for site with many sidebars can be very inefficient.

I would like to propose a means of being able to change how the information is stored.

I have introduced two filters that allow a user to have access to the information being saved or requested. This is backwards compatible but gives the option of using, for example ,a post type to store the data.

Attachments (6)

32987.diff (2.0 KB) - added by welcher 10 years ago.
32987.2.diff (2.5 KB) - added by welcher 10 years ago.
Updated patch for better hook names, inline doc corrections and a more integrated approach to retrieving the widgets
32987.3.diff (2.6 KB) - added by wonderboymusic 10 years ago.
32987.4.diff (2.6 KB) - added by welcher 10 years ago.
Updated docs and corrected logic for checking for boolean filter results
32987-tests.diff (2.0 KB) - added by welcher 10 years ago.
Adding unit tests
32987-tests.2.diff (2.9 KB) - added by welcher 10 years ago.
Updated unit tests with doc block and better method naming

Download all attachments as: .zip

Change History (17)

@welcher
10 years ago

#2 @welcher
10 years ago

  • Keywords has-patch dev-feedback added

#3 @DrewAPicture
10 years ago

Some notes:

  • These filter names need a little bit of work. They evaluate as booleans but the filter names don't really reflect that
  • If we do end up keeping the boolean returns by default, the check on what is currently the 'sidebars_widgets_custom_storage' hook could just easily be a strict boolean check

On the hook docs:

  • The duplicate hook comment should be one line, e.g. /** This filter is documented in ... */
  • The duplicate hook comment only needs to mention the path to the file
  • Hook doc summaries should end with a period
  • @since versions should be the 3-digit x.x.x style, e.g. 4.4.0
  • Multiple types in phpDoc should use a pipe, e.g. |
Last edited 10 years ago by DrewAPicture (previous) (diff)

#4 follow-up: @westonruter
10 years ago

@welcher As opposed to introducing new filters, why not just utilize pre_option_sidebars_widgets filters?

#5 in reply to: ↑ 4 @welcher
10 years ago

Replying to westonruter:

@welcher As opposed to introducing new filters, why not just utilize pre_option_sidebars_widgets filters?

Currently that would be the best approach, however I like the idea of having a hook before the get_option() call happens so we can decouple the get/set process completely from the calls to the *_option methods. I think this provides more flexibility moving forward.

I also found the storage process with the pre_update_option_sidebars_widgets filter to be a little counter-intuitive as you have to return $old_value to short circuit the update_option call.
.

Last edited 10 years ago by welcher (previous) (diff)

@welcher
10 years ago

Updated patch for better hook names, inline doc corrections and a more integrated approach to retrieving the widgets

This ticket was mentioned in Slack in #core by welcher. View the logs.


10 years ago

@welcher
10 years ago

Updated docs and corrected logic for checking for boolean filter results

@welcher
10 years ago

Adding unit tests

#8 @welcher
10 years ago

I have added some unit tests as per the Slack discussion. Am happy to add more or make any further changes as needed.

This ticket was mentioned in Slack in #core by welcher. View the logs.


10 years ago

@welcher
10 years ago

Updated unit tests with doc block and better method naming

This ticket was mentioned in Slack in #core by welcher. View the logs.


10 years ago

#13 @welcher
7 years ago

  • Keywords bulk-reopened added
  • Resolution set to wontfix
  • Status changed from new to closed

Closing based on where Gutenberg is headed in Phase 2,

Note: See TracTickets for help on using tickets.