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 REST API endpoints #1293

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions src/wp-includes/class-wp-widget-factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,22 @@ public function _register_widgets() {
$this->widgets[ $key ]->_register();
}
}

/**
* Returns the registered WP_Widget object for the given widget type.
*
* @since 5.8.0
*
* @param string $id_base Widget type ID.
* @return WP_Widget|null
*/
public function get_widget_object( $id_base ) {
foreach ( $this->widgets as $widget_object ) {
if ( $widget_object->id_base === $id_base ) {
return $widget_object;
}
}

return null;
}
}
3 changes: 3 additions & 0 deletions src/wp-includes/default-widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@

/** WP_Widget_Custom_HTML class */
require_once ABSPATH . WPINC . '/widgets/class-wp-widget-custom-html.php';

/** WP_Widget_Block class */
require_once ABSPATH . WPINC . '/widgets/class-wp-widget-block.php';
12 changes: 12 additions & 0 deletions src/wp-includes/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,18 @@ function create_initial_rest_routes() {
$controller = new WP_REST_Plugins_Controller();
$controller->register_routes();

// Sidebars.
$controller = new WP_REST_Sidebars_Controller();
$controller->register_routes();

// Widget Types.
$controller = new WP_REST_Widget_Types_Controller();
$controller->register_routes();

// Widgets.
$controller = new WP_REST_Widgets_Controller();
$controller->register_routes();

// Block Directory.
$controller = new WP_REST_Block_Directory_Controller();
$controller->register_routes();
Expand Down
Loading