REST API: In WP_REST_Block_Directory_Controller::get_items()
, make sure the blocks data for a plugin is not empty before proceeding.
This avoids a PHP notice if the API returns a plugin with empty data for `blocks` key. Props khag7, TwentyZeroTwo, justinahinon, TimothyBlynJacobs, dd32, SergeyBiryukov. Merges [48842] to the 5.5 branch. Fixes #51018. git-svn-id: https://develop.svn.wordpress.org/branches/5.5@48849 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4e7ac9bb9f
commit
4ad67eb3c2
@ -95,6 +95,11 @@ class WP_REST_Block_Directory_Controller extends WP_REST_Controller {
|
||||
$result = array();
|
||||
|
||||
foreach ( $response->plugins as $plugin ) {
|
||||
// If the API returned a plugin with empty data for 'blocks', skip it.
|
||||
if ( empty( $plugin['blocks'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = $this->prepare_item_for_response( $plugin, $request );
|
||||
$result[] = $this->prepare_response_for_collection( $data );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user