Changeset 50776
- Timestamp:
- 04/21/2021 05:10:56 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/edit-form-blocks.php
r50761 r50776 23 23 */ 24 24 global $post_type, $post_type_object, $post, $title, $editor_styles, $wp_meta_boxes; 25 26 $editor_name = 'post-editor'; 25 27 26 28 // Flag that we're loading the block editor. … … 57 59 ); 58 60 61 59 62 /** 60 63 * Preload common data by specifying an array of REST API paths that will be preloaded. … … 136 139 ); 137 140 138 139 /*140 * Initialize the editor.141 */142 143 $align_wide = get_theme_support( 'align-wide' );144 $color_palette = current( (array) get_theme_support( 'editor-color-palette' ) );145 $font_sizes = current( (array) get_theme_support( 'editor-font-sizes' ) );146 $gradient_presets = current( (array) get_theme_support( 'editor-gradient-presets' ) );147 $custom_line_height = get_theme_support( 'custom-line-height' );148 $custom_units = get_theme_support( 'custom-units' );149 $custom_spacing = get_theme_support( 'custom-spacing' );150 151 /**152 * Filters the allowed block types for the editor, defaulting to true (all153 * block types supported).154 *155 * @since 5.0.0156 *157 * @param bool|array $allowed_block_types Array of block type slugs, or158 * boolean to enable/disable all.159 * @param WP_Post $post The post resource data.160 */161 $allowed_block_types = apply_filters( 'allowed_block_types', true, $post );162 163 141 /* 164 142 * Get all available templates for the post/page attributes meta-box. … … 175 153 $available_templates 176 154 ) : $available_templates; 177 178 // Media settings.179 $max_upload_size = wp_max_upload_size();180 if ( ! $max_upload_size ) {181 $max_upload_size = 0;182 }183 155 184 156 // Editor Styles. … … 209 181 } 210 182 211 // Image sizes.212 213 /** This filter is documented in wp-admin/includes/media.php */214 $image_size_names = apply_filters(215 'image_size_names_choose',216 array(217 'thumbnail' => __( 'Thumbnail' ),218 'medium' => __( 'Medium' ),219 'large' => __( 'Large' ),220 'full' => __( 'Full Size' ),221 )222 );223 224 $available_image_sizes = array();225 foreach ( $image_size_names as $image_size_slug => $image_size_name ) {226 $available_image_sizes[] = array(227 'slug' => $image_size_slug,228 'name' => $image_size_name,229 );230 }231 232 $default_size = get_option( 'image_default_size', 'large' );233 $image_default_size = in_array( $default_size, array_keys( $image_size_names ), true ) ? $image_default_size : 'large';234 235 $image_dimensions = array();236 $all_sizes = wp_get_registered_image_subsizes();237 foreach ( $available_image_sizes as $size ) {238 $key = $size['slug'];239 if ( isset( $all_sizes[ $key ] ) ) {240 $image_dimensions[ $key ] = $all_sizes[ $key ];241 }242 }243 244 183 // Lock settings. 245 184 $user_id = wp_check_post_lock( $post->ID ); … … 290 229 291 230 $editor_settings = array( 292 'alignWide' => $align_wide,293 231 'availableTemplates' => $available_templates, 294 'allowedBlockTypes' => $allowed_block_types,295 'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),296 'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),297 'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ),298 232 'disablePostFormats' => ! current_theme_supports( 'post-formats' ), 299 233 /** This filter is documented in wp-admin/edit-form-advanced.php */ 300 234 'titlePlaceholder' => apply_filters( 'enter_title_here', __( 'Add title' ), $post ), 301 235 'bodyPlaceholder' => $body_placeholder, 302 'isRTL' => is_rtl(),303 236 'autosaveInterval' => AUTOSAVE_INTERVAL, 304 'maxUploadFileSize' => $max_upload_size,305 'allowedMimeTypes' => get_allowed_mime_types(),306 237 'styles' => $styles, 307 'imageSizes' => $available_image_sizes,308 'imageDefaultSize' => $image_default_size,309 'imageDimensions' => $image_dimensions,310 238 'richEditingEnabled' => user_can_richedit(), 311 239 'postLock' => $lock_details, … … 321 249 // field so that we're not always loading its assets. 322 250 'enableCustomFields' => (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ), 323 'enableCustomLineHeight' => $custom_line_height,324 'enableCustomUnits' => $custom_units,325 'enableCustomSpacing' => $custom_spacing,326 251 ); 327 252 … … 337 262 } 338 263 339 if ( false !== $color_palette ) {340 $editor_settings['colors'] = $color_palette;341 }342 343 if ( false !== $font_sizes ) {344 $editor_settings['fontSizes'] = $font_sizes;345 }346 347 if ( false !== $gradient_presets ) {348 $editor_settings['gradients'] = $gradient_presets;349 }350 351 264 if ( ! empty( $post_type_object->template ) ) { 352 265 $editor_settings['template'] = $post_type_object->template; … … 373 286 wp_enqueue_editor(); 374 287 375 376 288 /** 377 289 * Styles … … 401 313 } 402 314 403 /** 404 * Filters the settings to pass to the block editor. 405 * 406 * @since 5.0.0 407 * 408 * @param array $editor_settings Default editor settings. 409 * @param WP_Post $post Post being edited. 410 */ 411 $editor_settings = apply_filters( 'block_editor_settings', $editor_settings, $post ); 315 $editor_settings = get_block_editor_settings( $editor_name, $editor_settings ); 412 316 413 317 $init_script = <<<JS -
trunk/src/wp-admin/includes/post.php
r50618 r50776 2182 2182 2183 2183 /** 2184 * Returns all the block categories that will be shown in the block editor.2185 *2186 * @since 5.0.02187 *2188 * @param WP_Post $post Post object.2189 * @return array[] Array of block categories.2190 */2191 function get_block_categories( $post ) {2192 $default_categories = array(2193 array(2194 'slug' => 'text',2195 'title' => _x( 'Text', 'block category' ),2196 'icon' => null,2197 ),2198 array(2199 'slug' => 'media',2200 'title' => _x( 'Media', 'block category' ),2201 'icon' => null,2202 ),2203 array(2204 'slug' => 'design',2205 'title' => _x( 'Design', 'block category' ),2206 'icon' => null,2207 ),2208 array(2209 'slug' => 'widgets',2210 'title' => _x( 'Widgets', 'block category' ),2211 'icon' => null,2212 ),2213 array(2214 'slug' => 'theme',2215 'title' => _x( 'Theme', 'block category' ),2216 'icon' => null,2217 ),2218 array(2219 'slug' => 'embed',2220 'title' => _x( 'Embeds', 'block category' ),2221 'icon' => null,2222 ),2223 array(2224 'slug' => 'reusable',2225 'title' => _x( 'Reusable Blocks', 'block category' ),2226 'icon' => null,2227 ),2228 );2229 2230 /**2231 * Filters the default array of block categories.2232 *2233 * @since 5.0.02234 *2235 * @param array[] $default_categories Array of block categories.2236 * @param WP_Post $post Post being loaded.2237 */2238 return apply_filters( 'block_categories', $default_categories, $post );2239 }2240 2241 /**2242 2184 * Prepares server-registered blocks for the block editor. 2243 2185 * -
trunk/src/wp-settings.php
r50761 r50776 295 295 require ABSPATH . WPINC . '/blocks.php'; 296 296 require ABSPATH . WPINC . '/blocks/index.php'; 297 require ABSPATH . WPINC . '/block-editor.php'; 297 298 require ABSPATH . WPINC . '/block-patterns.php'; 298 299 require ABSPATH . WPINC . '/class-wp-block-supports.php';
Note: See TracChangeset
for help on using the changeset viewer.