-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
(WIP) Add a new endpoint that exposes block editor settings through the REST API #25226
Changes from 1 commit
484e3ee
9737fbc
0b90f30
ba80bcc
d1cc0f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,22 +31,18 @@ public function register_routes() { | |
array( | ||
'methods' => WP_REST_Server::READABLE, | ||
'callback' => array( $this, 'get_items' ), | ||
'permission_callback' => array( $this, 'get_items_permissions_check' ) | ||
) | ||
'permission_callback' => array( $this, 'get_items_permissions_check' ), | ||
), | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Checks whether a given request has permission to read block editor settings | ||
* | ||
* @since 5.5.0 | ||
* | ||
* @param WP_REST_Request $request Full details about the request. | ||
* | ||
* @return WP_Error|bool True if the request has permission, WP_Error object otherwise. | ||
*/ | ||
public function get_items_permissions_check( $request ) { | ||
public function get_items_permissions_check() { | ||
if ( ! current_user_can( 'edit_posts' ) ) { | ||
$error = __( 'Sorry, you are not allowed to read the block editor settings.', 'gutenberg' ); | ||
return new WP_Error( 'rest_cannot_read_settings', $error, array( 'status' => rest_authorization_required_code() ) ); | ||
|
@@ -58,13 +54,9 @@ public function get_items_permissions_check( $request ) { | |
/** | ||
* Return all block editor settings | ||
* | ||
* @since 5.5.0 | ||
* | ||
* @param WP_REST_Request $request Full details about the request. | ||
* | ||
* @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure. | ||
*/ | ||
public function get_items( $request ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @geriux I think You might still need this when I pull in this commit I get:
|
||
public function get_items() { | ||
$settings = apply_filters( 'block_editor_settings', array() ); | ||
|
||
return rest_ensure_response( $settings ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geriux I think You might still need this when I pull in this commit I get: