Make WordPress Core


Ignore:
Timestamp:
06/22/2021 01:32:42 PM (4 years ago)
Author:
desrosj
Message:

Widgets: Add editor styles to the widgets block editor.

This updates the widgets screen to load the editor styles in the same way as the post editor. This combined with the package updates in [51198] and [51199] ensures that the blocks added to sidebars more accurately reflect what will be displayed on the front end of the site.

Props isabel_brison, noisysocks, andraganescu, audrasjb, jorbin, caseymilne, desrosj.
Fixes #53344. See #53388.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-blocks.php

    r51158 r51200  
    1919 * @global WP_Post      $post             Global post object.
    2020 * @global string       $title
    21  * @global array        $editor_styles
    2221 * @global array        $wp_meta_boxes
    2322 */
    24 global $post_type, $post_type_object, $post, $title, $editor_styles, $wp_meta_boxes;
     23global $post_type, $post_type_object, $post, $title, $wp_meta_boxes;
    2524
    2625$block_editor_context = new WP_Block_Editor_Context( array( 'post' => $post ) );
     
    129128) : $available_templates;
    130129
    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 
    161130// Lock settings.
    162131$user_id = wp_check_post_lock( $post->ID );
     
    213182    'bodyPlaceholder'                      => $body_placeholder,
    214183    'autosaveInterval'                     => AUTOSAVE_INTERVAL,
    215     'styles'                               => $styles,
     184    'styles'                               => get_block_editor_theme_styles(),
    216185    'richEditingEnabled'                   => user_can_richedit(),
    217186    'postLock'                             => $lock_details,
Note: See TracChangeset for help on using the changeset viewer.