-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/** | ||
* Adds the preload paths registered in Core (`edit-form-blocks.php`). | ||
* | ||
* @param array $preload_paths Preload paths to be filtered. | ||
* @param WP_Block_Editor_Context $context The current block editor context. | ||
* @return array | ||
*/ | ||
function gutenberg_preload_navigation_permissions( $preload_paths, $context ) { | ||
|
||
$preload_paths[] = array( rest_get_route_for_post_type_items( 'wp_navigation' ), 'OPTIONS' ); | ||
|
||
$preload_paths[] = rest_get_route_for_post_type_items( 'wp_navigation' ); | ||
// add /wp/v2/navigation?context=edit&per_page=-1&status%5B0%5D=publish&status%5B1%5D=draft to preload paths array | ||
$preload_paths[] = array( | ||
rest_get_route_for_post_type_items( | ||
'wp_navigation', | ||
), | ||
array( | ||
'context' => 'edit', | ||
'per_page' => '-1', | ||
'status' => array( 'publish, draft' ), | ||
), | ||
|
||
); | ||
|
||
// add /wp/v2/navigation?_locale=user&context=edit&per_page=100&status%5B0%5D=publish&status%5B1%5D=draft to preload paths array | ||
$preload_paths[] = array( | ||
rest_get_route_for_post_type_items( | ||
'wp_navigation', | ||
), | ||
array( | ||
'_locale' => 'user', | ||
'context' => 'edit', | ||
'per_page' => '100', | ||
'status' => array( 'publish, draft' ), | ||
), | ||
|
||
); | ||
|
||
echo '<pre>'; | ||
var_dump( $preload_paths ); | ||
echo '</pre>'; | ||
|
||
return $preload_paths; | ||
} | ||
add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_preload_navigation_permissions', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters