-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Site Editor: Fix Template Parts post type preload path (#64401)
* Site Editor: Fix Template Parts post type preload path * Add backport changelog file Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
- Loading branch information
1 parent
92ea19f
commit 21cfde3
Showing
3 changed files
with
37 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,3 @@ | ||
https://github.com/WordPress/wordpress-develop/pull/7179 | ||
|
||
* https://github.com/WordPress/gutenberg/pull/64401 |
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,31 @@ | ||
<?php | ||
/** | ||
* PHP and WordPress configuration compatibility functions for the Gutenberg | ||
* editor plugin changes related to REST API. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
die( 'Silence is golden.' ); | ||
} | ||
|
||
/** | ||
* Update the preload paths registered in Core (`site-editor.php` or `edit-form-blocks.php`). | ||
* | ||
* @param array $paths REST API paths to preload. | ||
* @param WP_Block_Editor_Context $context Current block editor context. | ||
* @return array Filtered preload paths. | ||
*/ | ||
function gutenberg_block_editor_preload_paths_6_7( $paths, $context ) { | ||
if ( 'core/edit-site' === $context->name ) { | ||
// Fixes post type name. It should be `type/wp_template_part`. | ||
$parts_key = array_search( '/wp/v2/types/wp_template-part?context=edit', $paths, true ); | ||
if ( false !== $parts_key ) { | ||
$paths[ $parts_key ] = '/wp/v2/types/wp_template_part?context=edit'; | ||
} | ||
} | ||
|
||
return $paths; | ||
} | ||
add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_block_editor_preload_paths_6_7', 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