Skip to content

Commit 379ef7c

Browse files
committed
Initial commit. Add meta field to post types.
1 parent f50e045 commit 379ef7c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/compat/wordpress-6.7/rest-api.php

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* PHP and WordPress configuration compatibility functions for the Gutenberg
4+
* editor plugin changes related to REST API.
5+
*
6+
* @package gutenberg
7+
*/
8+
9+
if ( ! defined( 'ABSPATH' ) ) {
10+
die( 'Silence is golden.' );
11+
}
12+
13+
if ( ! function_exists( 'gutenberg_register_wp_rest_post_types_meta_fields' ) ) {
14+
/**
15+
* Adds `template` and `template_lock` fields to WP_REST_Post_Types_Controller class.
16+
*/
17+
function gutenberg_register_wp_rest_post_types_meta_fields() {
18+
register_rest_field(
19+
'type',
20+
'meta',
21+
array(
22+
'get_callback' => function ( $item ) {
23+
return get_registered_meta_keys( $item['slug'] );
24+
},
25+
'schema' => array(
26+
'type' => 'array',
27+
'description' => __( 'Meta Keys', 'gutenberg' ),
28+
'readonly' => true,
29+
'context' => array( 'view', 'edit', 'embed' ),
30+
),
31+
)
32+
);
33+
}
34+
}
35+
add_action( 'rest_api_init', 'gutenberg_register_wp_rest_post_types_meta_fields' );

lib/load.php

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ function gutenberg_is_experiment_enabled( $name ) {
5151
require __DIR__ . '/compat/wordpress-6.6/class-gutenberg-rest-templates-controller-6-6.php';
5252
require __DIR__ . '/compat/wordpress-6.6/rest-api.php';
5353

54+
// WordPress 6.7 compat.
55+
require __DIR__ . '/compat/wordpress-6.7/rest-api.php';
56+
5457
// Plugin specific code.
5558
require_once __DIR__ . '/class-wp-rest-global-styles-controller-gutenberg.php';
5659
require_once __DIR__ . '/class-wp-rest-edit-site-export-controller-gutenberg.php';

0 commit comments

Comments
 (0)