Changeset 51200
- Timestamp:
- 06/22/2021 01:32:42 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/edit-form-blocks.php
r51158 r51200 19 19 * @global WP_Post $post Global post object. 20 20 * @global string $title 21 * @global array $editor_styles22 21 * @global array $wp_meta_boxes 23 22 */ 24 global $post_type, $post_type_object, $post, $title, $ editor_styles, $wp_meta_boxes;23 global $post_type, $post_type_object, $post, $title, $wp_meta_boxes; 25 24 26 25 $block_editor_context = new WP_Block_Editor_Context( array( 'post' => $post ) ); … … 129 128 ) : $available_templates; 130 129 131 // Editor Styles.132 $styles = array(133 array(134 'css' => 'body { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif }',135 '__unstableType' => 'core',136 ),137 );138 if ( $editor_styles && current_theme_supports( 'editor-styles' ) ) {139 foreach ( $editor_styles as $style ) {140 if ( preg_match( '~^(https?:)?//~', $style ) ) {141 $response = wp_remote_get( $style );142 if ( ! is_wp_error( $response ) ) {143 $styles[] = array(144 'css' => wp_remote_retrieve_body( $response ),145 '__unstableType' => 'theme',146 );147 }148 } else {149 $file = get_theme_file_path( $style );150 if ( is_file( $file ) ) {151 $styles[] = array(152 'css' => file_get_contents( $file ),153 'baseURL' => get_theme_file_uri( $style ),154 '__unstableType' => 'theme',155 );156 }157 }158 }159 }160 161 130 // Lock settings. 162 131 $user_id = wp_check_post_lock( $post->ID ); … … 213 182 'bodyPlaceholder' => $body_placeholder, 214 183 'autosaveInterval' => AUTOSAVE_INTERVAL, 215 'styles' => $styles,184 'styles' => get_block_editor_theme_styles(), 216 185 'richEditingEnabled' => user_can_richedit(), 217 186 'postLock' => $lock_details, -
trunk/src/wp-admin/widgets-form-blocks.php
r51149 r51200 26 26 27 27 $editor_settings = get_block_editor_settings( 28 get_legacy_widget_block_editor_settings(),28 array_merge( get_legacy_widget_block_editor_settings(), array( 'styles' => get_block_editor_theme_styles() ) ), 29 29 $block_editor_context 30 30 ); -
trunk/src/wp-includes/block-editor.php
r51149 r51200 465 465 ); 466 466 } 467 468 /** 469 * Creates an array of theme styles to load into the block editor. 470 * 471 * @since 5.8.0 472 * 473 * @global array $editor_styles 474 * 475 * @return array An array of theme styles for the block editor. Includes default font family 476 * style and theme stylesheets. 477 */ 478 function get_block_editor_theme_styles() { 479 global $editor_styles; 480 481 $styles = array( 482 array( 483 'css' => 'body { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif }', 484 '__unstableType' => 'core', 485 ), 486 ); 487 if ( $editor_styles && current_theme_supports( 'editor-styles' ) ) { 488 foreach ( $editor_styles as $style ) { 489 if ( preg_match( '~^(https?:)?//~', $style ) ) { 490 $response = wp_remote_get( $style ); 491 if ( ! is_wp_error( $response ) ) { 492 $styles[] = array( 493 'css' => wp_remote_retrieve_body( $response ), 494 '__unstableType' => 'theme', 495 ); 496 } 497 } else { 498 $file = get_theme_file_path( $style ); 499 if ( is_file( $file ) ) { 500 $styles[] = array( 501 'css' => file_get_contents( $file ), 502 'baseURL' => get_theme_file_uri( $style ), 503 '__unstableType' => 'theme', 504 ); 505 } 506 } 507 } 508 } 509 510 return $styles; 511 } -
trunk/tests/phpunit/tests/blocks/block-editor.php
r51149 r51200 430 430 $this->assertContains( '"\/wp\/v2\/types"', $after ); 431 431 } 432 433 /** 434 * @ticket 53344 435 */ 436 function test_get_block_editor_theme_styles() { 437 $theme_styles = get_block_editor_theme_styles(); 438 $this->assertCount( 1, $theme_styles ); 439 $this->assertSameSets( 440 array( 441 'css' => 'body { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif }', 442 '__unstableType' => 'core', 443 ), 444 $theme_styles[0] 445 ); 446 } 432 447 }
Note: See TracChangeset
for help on using the changeset viewer.