| @@ -10,8 +10,17 @@ | ||
| 10 | 10 | die( 'Silence is golden.' ); |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | + * Registers the customizer nonces REST API routes. | |
| 15 | + */ | |
| 16 | +function gutenberg_register_rest_customizer_nonces() { | |
| 17 | + $customizer_nonces = new WP_Rest_Customizer_Nonces(); | |
| 18 | + $customizer_nonces->register_routes(); | |
| 19 | +} | |
| 20 | +add_action( 'rest_api_init', 'gutenberg_register_rest_customizer_nonces' ); | |
| 21 | + | |
| 22 | +/** | |
| 14 | 23 | * Registers the Block editor settings REST API routes. |
| 15 | 24 | */ |
| 16 | 25 | function gutenberg_register_block_editor_settings() { |
| 17 | 26 | $editor_settings = new WP_REST_Block_Editor_Settings_Controller(); |
| @@ -28,9 +37,9 @@ | ||
| 28 | 37 | * is actually publish in order to return the future permalink format. |
| 29 | 38 | * |
| 30 | 39 | * This is a temporary fix until we can patch get_sample_permalink() |
| 31 | 40 | * |
| 32 | - * @link https://core.trac.wordpress.org/ticket/46266 | |
| 41 | + * @see https://core.trac.wordpress.org/ticket/46266 | |
| 33 | 42 | * |
| 34 | 43 | * @param array $permalink Array containing the sample permalink with placeholder for the post name, and the post name. |
| 35 | 44 | * @param int $id ID of the post. |
| 36 | 45 | * @param string $title Title of the post. |
| @@ -91,4 +100,25 @@ | ||
| 91 | 100 | |
| 92 | 101 | return $permalink; |
| 93 | 102 | } |
| 94 | 103 | add_filter( 'get_sample_permalink', 'gutenberg_auto_draft_get_sample_permalink', 10, 5 ); |
| 104 | + | |
| 105 | +/** | |
| 106 | + * Hook in to the template and template part post types and decorate | |
| 107 | + * the rest endpoint with the revision count. | |
| 108 | + * | |
| 109 | + * When merging to core, this can be removed once Gutenberg_REST_Template_Revision_Count is | |
| 110 | + * merged with WP_REST_Template_Controller. | |
| 111 | + * | |
| 112 | + * @param array $args Current registered post type args. | |
| 113 | + * @param string $post_type Name of post type. | |
| 114 | + * | |
| 115 | + * @return array | |
| 116 | + */ | |
| 117 | +function wp_api_template_revision_args( $args, $post_type ) { | |
| 118 | + if ( 'wp_template' === $post_type || 'wp_template_part' === $post_type ) { | |
| 119 | + $args['rest_controller_class'] = 'Gutenberg_REST_Template_Revision_Count'; | |
| 120 | + } | |
| 121 | + | |
| 122 | + return $args; | |
| 123 | +} | |
| 124 | +add_filter( 'register_post_type_args', 'wp_api_template_revision_args', 10, 2 ); | |