#41683 closed feature request (fixed)
Add Widget REST API endpoint
Reported by: | spacedmonkey | Owned by: | noisysocks |
---|---|---|---|
Milestone: | 5.8 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | REST API | Keywords: | has-patch has-unit-tests needs-dev-note |
Focuses: | rest-api | Cc: |
Description
There needs to be a REST endpoint to interacts with widgets. Current users can use the options api to interact with the data, but this is extremely limited. I would recommend that we look to WP CLI for pointer on how the api is laid out. Docs can be found here - https://developer.wordpress.org/cli/commands/widget/ .
One of the likely issues with if the is a view, how the html for a widget is rendered.
Change History (35)
#2
@
7 years ago
getting a widget by itself may be useful for admin screens, but to build a front end, you actually need access to Sidebars. See something I am using here: https://highforthis.com/wp-json/graphql/v1/sidebars
Without the sidebar context and a representation of the widget HTML, how useful is the data?
#3
@
7 years ago
We have the repo https://github.com/WP-API/wp-api-menus-widgets-endpoints for adding this as a feature plugin, so I don't think we need to manage and do this in trac.
This ticket was mentioned in Slack in #core-restapi by timothybjacobs. View the logs.
5 years ago
#6
@
5 years ago
This looks to be something that the Gutenberg team is actively working on: https://github.com/WordPress/gutenberg/issues/13204
Work should probably be happening there for now.
This ticket was mentioned in Slack in #core-restapi by spacedmonkey. View the logs.
4 years ago
This ticket was mentioned in PR #1293 on WordPress/wordpress-develop by TimothyBJacobs.
3 years ago
#10
- Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed
Trac ticket: https://core.trac.wordpress.org/ticket/41683
noisysocks commented on PR #1293:
3 years ago
#12
Code LGTM. If tests pass I'm happy 👍
#13
@
3 years ago
Committing this will break Gutenberg CI because the plugin will re-declare classes that already exist, so let's just hold off on committing this until I have a Gutenberg PR ready to go that fixes that.
#14
@
3 years ago
- Owner set to noisysocks
- Resolution set to fixed
- Status changed from new to closed
In 50993:
#15
@
3 years ago
Committing this will break Gutenberg CI because the plugin will re-declare classes that already exist, so let's just hold off on committing this until I have a Gutenberg PR ready to go that fixes that.
Why doesn't Gutenberg have class_exists
guards for that or use different class name prefix?
Also, I feel like all the contributors to the original class in Gutenberg should have received props.
#16
@
3 years ago
There are a few class_exists
guards but some of it isn't working properly. https://github.com/WordPress/wordpress-develop/pull/1284 will address those.
Folks who contributed in Gutenberg should get props when we generate props from the Gutenberg git commits, no? Nonetheless I definitely forgot to props @spacedmonkey and will work on editing the commit message to include that.
#19
@
3 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Per the WordPress Documentation Standards:
@author Tag
It is WordPress’ policy not to use the
@author
tag, except in the case of maintaining it in external libraries. We do not want to imply any sort of “ownership” over code that might discourage contribution.
@copyright and @license Tags
The
@copyright
and@license
tags are used in external libraries and scripts, and should not be used in WordPress core files.
@copyright
is used to specify external script copyrights.
@license
is used to specify external script licenses.
Based on the above, would rest-api/endpoints/class-wp-rest-sidebars-controller.php
still be maintained as an external library or a core file from now on? If the latter, then I guess this whole fragment should be removed from WP_REST_Sidebars_Controller
for consistency with other REST API classes:
* Copyright (C) 2015 Martin Pettersson * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @author Martin Pettersson <martin_pettersson@outlook.com> * @copyright 2015 Martin Pettersson * @license GPLv2 * @link https://github.com/martin-pettersson/wp-rest-api-sidebars
To keep the original author's credit, it could be replaced with a comment like the one we have in the wpdb
class:
Original code from {@link http://php.justinvincent.com Justin Vincent (justin@visunet.ie)}
#20
@
3 years ago
@SergeyBiryukov As far as I know, that copyright information is wrong and should be removed.
#21
@
3 years ago
That copyright info is from the original plugin that was used as a basis for the endpoints. During the 5.6 cycle I asked @pento whether we should remove or modify the copyright information given that it had been modified extensively. I was advised that we should leave the original copyright in place, like we do for kses.php
. Since 5.6, the code has been modified even more substantially.
I don't have any real opinions on what the right way to handle it is.
This ticket was mentioned in Slack in #core by desrosj. View the logs.
3 years ago
This ticket was mentioned in PR #1304 on WordPress/wordpress-develop by peterwilsoncc.
3 years ago
#25
Trac ticket:
This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.
3 years ago
#27
@
3 years ago
peterwilsoncc commented on PR #1304:
3 years ago
#29
#33
@
3 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening to address comment:19.
After checking with @desrosj, @chanthaboune, and Automattic's legal team, this was the answer, as shared by @cbringmann:
Our legal team confirmed that the copyright modification is acceptable:
Original code from {@link https://github.com/martin-pettersson/wp-rest-api-sidebars Martin Pettersson (martin_pettersson@outlook.com)}We are integrating his code with modifications and the carry forward of his copyright in his original code is implied. The primary goal is to avoid the impression that the entirety is the original work of the new contributor.
Related: #33507, #35574, #35669, https://github.com/WP-API/wp-api-menus-widgets-endpoints