-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a38c4f9
commit 74d934b
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* PHP and WordPress configuration compatibility functions for the Gutenberg | ||
* editor plugin changes related to REST API. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
die( 'Silence is golden.' ); | ||
} | ||
|
||
if ( ! function_exists( 'wp_api_template_access_controller' ) ) { | ||
/** | ||
* Hook in to the template and template part post types and modify the | ||
* access control for the rest endpoint to allow lower user roles to access | ||
* the templates and template parts. | ||
* | ||
* @param array $args Current registered post type args. | ||
* @param string $post_type Name of post type. | ||
* | ||
* @return array | ||
*/ | ||
function wp_api_template_access_controller( $args, $post_type ) { | ||
if ( 'wp_template' === $post_type || 'wp_template_part' === $post_type ) { | ||
$args['rest_controller_class'] = 'Gutenberg_REST_Templates_Controller_6_6'; | ||
} | ||
return $args; | ||
} | ||
} | ||
add_filter( 'register_post_type_args', 'wp_api_template_access_controller', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters