lib/experimental/guidelines
class-gutenberg-content-guidelines-rest-controller.php
24.3 KB
4 months ago
class-gutenberg-content-guidelines-revisions-controller.php
10.3 KB
4 months ago
class-gutenberg-guidelines-post-type.php
12.1 KB
3 months ago
class-gutenberg-guidelines-rest-controller.php
1.4 KB
3 months ago
guidelines.php
3.6 KB
4 months ago
index.php
2.1 KB
3 months ago
load.php
1.2 KB
4 months ago
index.php in Gutenberg 23.2.0, at lib/experimental/guidelines/index.php
| 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-guidelines-rest-controller.php'; |
| 15 | require_once __DIR__ . '/class-gutenberg-content-guidelines-revisions-controller.php'; |
| 16 | require_once __DIR__ . '/class-gutenberg-content-guidelines-rest-controller.php'; |
| 17 | |
| 18 | /* |
| 19 | * Register the guideline post type. |
| 20 | * The standard /wp/v2/guidelines collection uses the default posts controller. |
| 21 | */ |
| 22 | add_action( 'init', array( 'Gutenberg_Guidelines_Post_Type', 'register' ) ); |
| 23 | |
| 24 | // Register post meta once the REST API loads and the block registry is available. |
| 25 | add_action( 'rest_api_init', array( 'Gutenberg_Guidelines_Post_Type', 'register_post_meta' ) ); |
| 26 | |
| 27 | /* |
| 28 | * Register content singleton routes beside the standard CPT routes. |
| 29 | * The singleton rule is scoped to /wp/v2/content-guidelines for UI handling. |
| 30 | * The standard /wp/v2/guidelines route keeps default post handling for every |
| 31 | * `wp_guideline` post. If `content` becomes a data level singleton, add |
| 32 | * enforcement to the default CPT route too. |
| 33 | */ |
| 34 | add_action( |
| 35 | 'rest_api_init', |
| 36 | static function () { |
| 37 | $content_controller = new Gutenberg_Content_Guidelines_REST_Controller(); |
| 38 | $content_controller->register_routes(); |
| 39 | |
| 40 | $content_revisions_controller = new Gutenberg_Content_Guidelines_Revisions_Controller(); |
| 41 | $content_revisions_controller->register_routes(); |
| 42 | } |
| 43 | ); |
| 44 | |
| 45 | add_action( |
| 46 | 'current_screen', |
| 47 | function ( $screen ) { |
| 48 | if ( Gutenberg_Guidelines_Post_Type::POST_TYPE !== $screen->post_type ) { |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | // Disable the block editor for this post type. |
| 53 | add_filter( 'use_block_editor_for_post_type', '__return_false' ); |
| 54 | |
| 55 | // Remove the media button. |
| 56 | remove_action( 'media_buttons', 'media_buttons' ); |
| 57 | |
| 58 | // Use a plain textarea by disabling TinyMCE and Quicktags. |
| 59 | add_filter( |
| 60 | 'wp_editor_settings', |
| 61 | static function ( $settings, $editor_id ) { |
| 62 | if ( 'content' === $editor_id ) { |
| 63 | $settings['tinymce'] = false; |
| 64 | $settings['quicktags'] = false; |
| 65 | } |
| 66 | return $settings; |
| 67 | }, |
| 68 | 10, |
| 69 | 2 |
| 70 | ); |
| 71 | } |
| 72 | ); |
| 73 |