PluginProbe
Gutenberg / 23.6.0
Gutenberg v23.6.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / experimental / knowledge / index.php

index.php in Gutenberg 23.6.0, at lib/experimental/knowledge/index.php

56 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Knowledge experimental feature.
4 *
5 * @package gutenberg
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 require_once __DIR__ . '/knowledge.php';
13 require_once __DIR__ . '/class-gutenberg-knowledge-post-type.php';
14 require_once __DIR__ . '/class-gutenberg-knowledge-rest-controller.php';
15 require_once __DIR__ . '/class-gutenberg-guideline-scopes-rest-controller.php';
16
17 /*
18 * Register the knowledge post type.
19 * The standard /wp/v2/knowledge collection is served by the custom
20 * Gutenberg_Knowledge_REST_Controller (set via the post type's
21 * `rest_controller_class`).
22 */
23 add_action( 'init', array( 'Gutenberg_Knowledge_Post_Type', 'register' ) );
24
25 /*
26 * Ensure the post type is registered before any other `rest_api_init` callback
27 * runs. `init` normally fires before `rest_api_init`, but anything that calls
28 * `rest_get_server()` early (e.g. from `plugins_loaded`) fires `rest_api_init`
29 * before `init` priority 10. The callback below dereferences the post type
30 * object and would fatal (or trip `_doing_it_wrong`) without this guard.
31 */
32 add_action(
33 'rest_api_init',
34 static function () {
35 if ( ! post_type_exists( Gutenberg_Knowledge_Post_Type::POST_TYPE ) ) {
36 Gutenberg_Knowledge_Post_Type::register();
37 }
38 },
39 1
40 );
41
42 /*
43 * Register the read-only guideline scopes registry route beside the standard
44 * CPT routes. Guideline data itself is read and written through the standard
45 * /wp/v2/knowledge collection; scope rows are identified by the `guideline-`
46 * slug prefix and the `guideline` knowledge type (see the reservation guard in
47 * knowledge.php).
48 */
49 add_action(
50 'rest_api_init',
51 static function () {
52 $scopes_controller = new Gutenberg_Guideline_Scopes_REST_Controller();
53 $scopes_controller->register_routes();
54 }
55 );
56