Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add separate widgets endpoint #25958

Merged
merged 26 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e508e63
Initial move to widgets endpoint
TimothyBJacobs Oct 8, 2020
1384ddf
Separate sidebar and widgets tests. Add more widgets tests.
TimothyBJacobs Oct 8, 2020
7f29083
Fix linting
TimothyBJacobs Oct 8, 2020
79ad6e2
Actually register the widgets controller. Register the context param.
TimothyBJacobs Oct 8, 2020
d46528e
Fix most test failures
TimothyBJacobs Oct 8, 2020
5434a8f
Fix creating a new widget being given the wrong id.
TimothyBJacobs Oct 8, 2020
e4434b2
Fix linting
TimothyBJacobs Oct 8, 2020
417da96
Use widget controller test
spacedmonkey Oct 8, 2020
3d3fa3c
Add links for widget.
spacedmonkey Oct 8, 2020
1e980f8
Add extra fields.
spacedmonkey Oct 8, 2020
45426f6
Add links to sidebar.
spacedmonkey Oct 8, 2020
25b81d2
Add extra fields to sidebar.
spacedmonkey Oct 8, 2020
32736d0
Use use
spacedmonkey Oct 8, 2020
8b59350
Fix tests
spacedmonkey Oct 9, 2020
33fe1d3
Add helper method to remove links.
spacedmonkey Oct 10, 2020
09733d3
Add a "deprecated" mode that uses inner requests to the widgets endpo…
TimothyBJacobs Oct 13, 2020
cb17ecf
Don't try and render widgets in the inactive sidebar.
TimothyBJacobs Oct 13, 2020
0956065
Pass "deprecated" parameter to the sidebars endpoint.
TimothyBJacobs Oct 13, 2020
5572c1b
Fix linting
TimothyBJacobs Oct 13, 2020
2d7d7ae
Move the new endpoints to wp/v2. Make the __experimental sidebars end…
TimothyBJacobs Oct 14, 2020
be016cd
The deleted widget cannot be rendered
TimothyBJacobs Oct 13, 2020
97d5df3
CS
TimothyBJacobs Oct 14, 2020
c970cc3
Don't load non existent sidebars.
TimothyBJacobs Oct 14, 2020
6257bf1
Fix adding new reference widgets to a sidebar.
TimothyBJacobs Oct 14, 2020
4a32333
Merge branch 'add/widgets-endpoint' of github.com:TimothyBJacobs/gute…
TimothyBJacobs Oct 14, 2020
e380dc8
Make sure widgets are always an array.
TimothyBJacobs Oct 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
633 changes: 277 additions & 356 deletions lib/class-wp-rest-sidebars-controller.php

Large diffs are not rendered by default.

771 changes: 771 additions & 0 deletions lib/class-wp-rest-widgets-controller.php

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ function gutenberg_is_experiment_enabled( $name ) {
if ( ! class_exists( 'WP_REST_Sidebars_Controller' ) ) {
require_once dirname( __FILE__ ) . '/class-wp-rest-sidebars-controller.php';
}
if ( ! class_exists( 'WP_REST_Widgets_Controller' ) ) {
require_once dirname( __FILE__ ) . '/class-wp-rest-widgets-controller.php';
}
if ( ! class_exists( 'WP_REST_Block_Directory_Controller' ) ) {
require dirname( __FILE__ ) . '/class-wp-rest-block-directory-controller.php';
}
Expand Down
9 changes: 6 additions & 3 deletions lib/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,16 @@ function gutenberg_register_plugins_endpoint() {
add_action( 'rest_api_init', 'gutenberg_register_plugins_endpoint' );

/**
* Registers the Sidebars REST API routes.
* Registers the Sidebars & Widgets REST API routes.
*/
function gutenberg_register_sidebars_endpoint() {
function gutenberg_register_sidebars_and_widgets_endpoint() {
$sidebars = new WP_REST_Sidebars_Controller();
$sidebars->register_routes();

$widgets = new WP_REST_Widgets_Controller();
$widgets->register_routes();
}
add_action( 'rest_api_init', 'gutenberg_register_sidebars_endpoint' );
add_action( 'rest_api_init', 'gutenberg_register_sidebars_and_widgets_endpoint' );

/**
* Registers the Batch REST API routes.
Expand Down
4 changes: 3 additions & 1 deletion packages/edit-widgets/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export function* saveWidgetAreas( widgetAreas ) {
KIND,
WIDGET_AREA_ENTITY_TYPE,
widgetArea.id,
{ widgets: newWidgets }
{
widgets: newWidgets,
}
);

yield* trySaveWidgetArea( widgetArea.id );
Expand Down
4 changes: 3 additions & 1 deletion packages/edit-widgets/src/store/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export const buildWidgetAreasPostId = () => `widget-areas`;
* @return {Object} Query.
*/
export function buildWidgetAreasQuery() {
return { per_page: -1 };
return {
per_page: -1,
};
}

/**
Expand Down
Loading