Make WordPress Core

Opened 9 years ago

Last modified 6 years ago

#33915 new enhancement

Add a filter in dynamic_sidebar() function to modify sidebar index

Reported by: fahidjavid's profile fahidjavid Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3
Component: Widgets Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description

Changing sidebars depending on the page/post/etc loaded through a plugin. Nothing too complex, just no way to do it. There is a filter dynamic_sidebar_params but that isn't called until later on in the function after the widgets have been collected for that sidebar.

Attachments (3)

widgets.php (53.9 KB) - added by fahidjavid 9 years ago.
Added dynamic_sidebar_index filter in this sidebar
dynamic_sidebar_index.diff (53.9 KB) - added by fahidjavid 9 years ago.
33915.diff (1.1 KB) - added by ShinichiN 9 years ago.
brought from #34942

Download all attachments as: .zip

Change History (14)

@fahidjavid
9 years ago

Added dynamic_sidebar_index filter in this sidebar

#1 @fahidjavid
9 years ago

  • Keywords has-patch added

#2 @swissspidy
9 years ago

  • Keywords needs-patch added; has-patch removed

Thanks for your report.

Would you mind updating your patch according to this guide? You shouldn't upload the whole changed file, but only a diff of what's changed.

Besides that, dynamic_sidebar() already has lots of hooks. Is there no way to use those for what you wanna accomplish? Perhaps a proof-of-concept example might help.

Changing sidebars depending on the page/post/etc loaded through a plugin. Nothing too complex, just no way to do it.

Plugins like WooSidebars have been doing this successfully for years. How are they accomplishing this?

#3 @afercia
9 years ago

  • Focuses accessibility removed

#4 @SergeyBiryukov
9 years ago

#34942 was marked as a duplicate.

#5 @SergeyBiryukov
9 years ago

#20127 was marked as a duplicate.

@ShinichiN
9 years ago

brought from #34942

#6 @ShinichiN
9 years ago

  • Keywords has-patch added; needs-patch removed

#7 @swissspidy
9 years ago

  • Milestone changed from Awaiting Review to 4.5

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


9 years ago

#9 @swissspidy
9 years ago

  • Keywords needs-unit-tests added
  • Milestone changed from 4.5 to Future Release

Even though this is a fairly minor change, there hasn't been any feedback on why it is necessary and how usage would look like. Some unit tests and perhaps even a sample proof-of-concept plugin would be neat.

See also #34942.

#10 @ShinichiN
9 years ago

@swissspidy thank you for watching the ticket.

By a sample proof-of-concept plugin, do you mean a plugin which uses the suggested filter?

I'll try my first unit test patch later.

#11 @swissspidy
9 years ago

@ShinichiN Correct, a plugin using the suggested filter to see how feasible and reasonable it is.

Note: See TracTickets for help on using tickets.