Make WordPress Core

Opened 13 years ago

Last modified 5 years ago

#16613 new enhancement

Extend Widget API to allow sidebar/widget manipulation

Reported by: viper007bond's profile Viper007Bond Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Widgets Keywords: needs-patch
Focuses: Cc:

Description

There is currently no easy way to add a widget to a sidebar using code. We should add methods of doing this.

A good example usage of such an API could be when a new theme is activated, it could add it's custom widgets to it's sidebar.

API should provide support for adding widget X to sidebar Y (or even just the first sidebar) along with setting some options for the widget and where in the sidebar to add it (top vs. bottom).

Change History (12)

#1 @scribu
13 years ago

  • Cc scribu added

#2 follow-up: @ryan
13 years ago

Trying to decide if I would deactivate on the spot any theme that did this. ;-)

#3 in reply to: ↑ 2 @Viper007Bond
13 years ago

Replying to ryan:

Trying to decide if I would deactivate on the spot any theme that did this. ;-)

Ha, okay, maybe not the greatest example, but I have legitimate usage for this API. :P

#4 @sirzooro
13 years ago

  • Cc sirzooro added
  • Keywords dev-feedback 2nd-opinion needs-codex added

+1 for this.

I am going to create custom wizard-like plugin, which will allow to quickly configure new site. It will perform following tasks:

  • gather few configuration details from user;
  • activate plugins and configure them;
  • set theme;
  • add widgets and configure them.

So far it looks that last step will be the most difficult, because Widgets Management API is mostly undocumented, and some operations are even available via admin-ajax.php only.

If is is possible, please document at least some operations on Codex now. For code changes it is probably too late to include them in 3.3, so please target them for 3.4. It will be good to change this ticket to Blessed Task for 3.4.

#5 @dcowgill
11 years ago

  • Cc dcowgill@… added

#6 @chacha102
11 years ago

  • Cc chacha102 added

#7 @ocean90
10 years ago

#18671 was marked as a duplicate.

#8 @ocean90
10 years ago

  • Keywords dev-feedback 2nd-opinion needs-codex removed

#9 @westonruter
10 years ago

For an example API (at least for the kinds of operations that can be performed), see what was recently added to WP-CLI for widget management: https://github.com/wp-cli/wp-cli/blob/master/php/commands/widget.php

#10 @danielbachhuber
10 years ago

We could test drive a class or two in WP-CLI and/or WP-API.

This ticket was mentioned in IRC in #wordpress-dev by danielbachhuber. View the logs.


10 years ago

#12 @chriscct7
8 years ago

  • Priority changed from low to normal
Note: See TracTickets for help on using tickets.