PluginProbe
Gutenberg / 23.1.1
Gutenberg v23.1.1
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 / guidelines / index.php

index.php in Gutenberg 23.1.1, at lib/experimental/guidelines/index.php

72 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Guidelines experimental feature.
4 *
5 * @package gutenberg
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 require_once __DIR__ . '/guidelines.php';
13 require_once __DIR__ . '/class-gutenberg-guidelines-post-type.php';
14 require_once __DIR__ . '/class-gutenberg-content-guidelines-revisions-controller.php';
15 require_once __DIR__ . '/class-gutenberg-content-guidelines-rest-controller.php';
16
17 /*
18 * Register the guideline post type.
19 * The standard /wp/v2/guidelines collection uses the default posts controller.
20 */
21 add_action( 'init', array( 'Gutenberg_Guidelines_Post_Type', 'register' ) );
22
23 // Register post meta once the REST API loads and the block registry is available.
24 add_action( 'rest_api_init', array( 'Gutenberg_Guidelines_Post_Type', 'register_post_meta' ) );
25
26 /*
27 * Register content singleton routes beside the standard CPT routes.
28 * The singleton rule is scoped to /wp/v2/content-guidelines for UI handling.
29 * The standard /wp/v2/guidelines route keeps default post handling for every
30 * `wp_guideline` post. If `content` becomes a data level singleton, add
31 * enforcement to the default CPT route too.
32 */
33 add_action(
34 'rest_api_init',
35 static function () {
36 $content_controller = new Gutenberg_Content_Guidelines_REST_Controller();
37 $content_controller->register_routes();
38
39 $content_revisions_controller = new Gutenberg_Content_Guidelines_Revisions_Controller();
40 $content_revisions_controller->register_routes();
41 }
42 );
43
44 add_action(
45 'current_screen',
46 function ( $screen ) {
47 if ( Gutenberg_Guidelines_Post_Type::POST_TYPE !== $screen->post_type ) {
48 return;
49 }
50
51 // Disable the block editor for this post type.
52 add_filter( 'use_block_editor_for_post_type', '__return_false' );
53
54 // Remove the media button.
55 remove_action( 'media_buttons', 'media_buttons' );
56
57 // Use a plain textarea by disabling TinyMCE and Quicktags.
58 add_filter(
59 'wp_editor_settings',
60 static function ( $settings, $editor_id ) {
61 if ( 'content' === $editor_id ) {
62 $settings['tinymce'] = false;
63 $settings['quicktags'] = false;
64 }
65 return $settings;
66 },
67 10,
68 2
69 );
70 }
71 );
72