| 1 |
<?php |
| 2 |
/** |
| 3 |
* Shims the /wp/v2/widget-types/<id>/render endpoint in WP versions where it's missing |
| 4 |
* |
| 5 |
* @package gutenberg |
| 6 |
*/ |
| 7 |
|
| 8 |
// Load the polyfill class. |
| 9 |
require_once __DIR__ . '/class-gb-rest-widget-render-endpoint-polyfill.php'; |
| 10 |
|
| 11 |
/** |
| 12 |
* Registers routes from the GB_REST_Widget_Render_Endpoint_Polyfill class. |
| 13 |
*/ |
| 14 |
function setup_widget_render_api_endpoint_polyfill() { |
| 15 |
$polyfill = new GB_REST_Widget_Render_Endpoint_Polyfill(); |
| 16 |
$polyfill->register_routes(); |
| 17 |
} |
| 18 |
|
| 19 |
// Priority should be larger than 99 which is the one used for registering the core routes. |
| 20 |
add_action( 'rest_api_init', 'setup_widget_render_api_endpoint_polyfill', 100 ); |
| 21 |
|
| 22 |
|
| 23 |
|