Changeset 53559 for trunk/src/wp-admin/includes/post.php
- Timestamp:
- 06/23/2022 06:46:18 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/post.php
r53455 r53559 2149 2149 2150 2150 /** 2151 * Returns whether the post can be edited in the block editor.2152 *2153 * @since 5.0.02154 *2155 * @param int|WP_Post $post Post ID or WP_Post object.2156 * @return bool Whether the post can be edited in the block editor.2157 */2158 function use_block_editor_for_post( $post ) {2159 $post = get_post( $post );2160 2161 if ( ! $post ) {2162 return false;2163 }2164 2165 // We're in the meta box loader, so don't use the block editor.2166 if ( isset( $_GET['meta-box-loader'] ) ) {2167 check_admin_referer( 'meta-box-loader', 'meta-box-loader-nonce' );2168 return false;2169 }2170 2171 $use_block_editor = use_block_editor_for_post_type( $post->post_type );2172 2173 /**2174 * Filters whether a post is able to be edited in the block editor.2175 *2176 * @since 5.0.02177 *2178 * @param bool $use_block_editor Whether the post can be edited or not.2179 * @param WP_Post $post The post being checked.2180 */2181 return apply_filters( 'use_block_editor_for_post', $use_block_editor, $post );2182 }2183 2184 /**2185 * Returns whether a post type is compatible with the block editor.2186 *2187 * The block editor depends on the REST API, and if the post type is not shown in the2188 * REST API, then it won't work with the block editor.2189 *2190 * @since 5.0.02191 *2192 * @param string $post_type The post type.2193 * @return bool Whether the post type can be edited with the block editor.2194 */2195 function use_block_editor_for_post_type( $post_type ) {2196 if ( ! post_type_exists( $post_type ) ) {2197 return false;2198 }2199 2200 if ( ! post_type_supports( $post_type, 'editor' ) ) {2201 return false;2202 }2203 2204 $post_type_object = get_post_type_object( $post_type );2205 if ( $post_type_object && ! $post_type_object->show_in_rest ) {2206 return false;2207 }2208 2209 /**2210 * Filters whether a post is able to be edited in the block editor.2211 *2212 * @since 5.0.02213 *2214 * @param bool $use_block_editor Whether the post type can be edited or not. Default true.2215 * @param string $post_type The post type being checked.2216 */2217 return apply_filters( 'use_block_editor_for_post_type', true, $post_type );2218 }2219 2220 /**2221 2151 * Prepares server-registered blocks for the block editor. 2222 2152 *
Note: See TracChangeset
for help on using the changeset viewer.