Changeset 7523 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/gutenberg/functions.php
- Timestamp:
- 07/30/2018 05:17:43 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/gutenberg/functions.php
r7522 r7523 17 17 return; 18 18 } 19 20 function frontenberg_edit_pages( $allcaps ) {21 $allcaps['edit_pages'] = true;22 $allcaps['edit_others_pages'] = true;23 $allcaps['edit_published_pages'] = true;24 25 return $allcaps;26 }27 add_filter( 'user_has_cap', 'frontenberg_edit_pages' );28 19 29 20 show_admin_bar( true ); … … 61 52 add_action( 'wp_enqueue_scripts', 'gutenberg_editor_scripts_and_styles' ); 62 53 63 if ( ! is_user_logged_in() ) {64 add_filter( 'wp_insert_post_empty_content', '__return_true', PHP_INT_MAX -1, 2 );65 add_filter( 'pre_insert_term', function( $t ) {return ''; });66 }67 68 54 // Disable use XML-RPC 69 55 add_filter( 'xmlrpc_enabled', '__return_false' ); … … 136 122 } 137 123 add_action( 'wp_ajax_nopriv_query-attachments', 'frontenberg_wp_ajax_nopriv_query_attachments' ); 124 125 // Override the WP API to give Gutenberg the REST API responses it wants. 126 function frontenberg_override_rest_api( $null, $wp_rest_server, $request ) { 127 if ( is_admin() || preg_match( '!/wp-json/!', $_SERVER['REQUEST_URI'] ) ) { 128 return $null; // Don't modify an actual API responses.. 129 } 130 131 if ( '/wp/v2/types' == $request->get_route() ) { 132 // Minimal data required by Gutenberg for pages. 133 return new WP_REST_Response( array( 134 'page' => array( 135 'rest_base' => 'pages', 136 ) 137 ), 200 ); 138 } 139 140 if ( preg_match( '!^/wp/v2/pages/(\d+)$!', $request->get_route(), $m ) ) { 141 $content = include __DIR__ . '/gutenfront-content.php'; 142 143 return new WP_REST_Response( array( 144 'id' => $m[1], 145 'date' => gmdate( 'c' ), 'date_gmt' => gmdate( 'c' ), 146 'modified' => gmdate( 'c' ), 'modified_gmt' => gmdate( 'c' ), 147 'link' => 'https://wordpress.org/gutenberg/', 'guid' => array(), 148 'parent' => 0, 'menu_order' => 0, 'author' => 0, 'featured_media' => 0, 149 'comment_status' => 'closed', 'ping_status' => 'closed', 'template' => '', 'meta' => [], '_links' => [], 150 'type' => 'page', 'slug' => '', 'status' => 'draft', 151 'excerpt' => array( 'raw' => '' ), 152 'title' => array( 153 'raw' => $content['title'], 154 ), 155 'content' => array( 156 'raw' => $content['content'], 157 ), 158 ), 200 ); 159 } 160 161 return $null; 162 } 163 add_filter( 'rest_pre_dispatch', 'frontenberg_override_rest_api', 10, 3 ); 164 138 165 139 166 if ( ! function_exists( 'gutenbergtheme_setup' ) ) :
Note: See TracChangeset
for help on using the changeset viewer.