Skip to content
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

Site Editor: Fix Template Parts post type preload path #64401

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backport-changelog/6.7/7179.md
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
31 changes: 31 additions & 0 deletions lib/compat/wordpress-6.7/rest-api.php
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 );
3 changes: 3 additions & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/compat/wordpress-6.6/class-gutenberg-rest-templates-controller-6-6.php';
require __DIR__ . '/compat/wordpress-6.6/rest-api.php';

// WordPress 6.7 compat.
require __DIR__ . '/compat/wordpress-6.7/rest-api.php';

// Plugin specific code.
require_once __DIR__ . '/class-wp-rest-global-styles-controller-gutenberg.php';
require_once __DIR__ . '/class-wp-rest-edit-site-export-controller-gutenberg.php';
Expand Down
Loading