Make WordPress Core

Changeset 44148 for trunk


Ignore:
Timestamp:
12/14/2018 02:21:38 AM (6 years ago)
Author:
desrosj
Message:

Twenty Seventeen: Add styles and support for the new block-based editor.

This update adds styles and theme support related to the new block-based editor to enhance the experience of using it with Twenty Seventeen.

These are the specific changes made to this theme:

  • Add blocks.css, to style blocks on the front end, to make sure they match the theme’s existing HTML element styles.
  • Add editor-blocks.css to style blocks in the editor, to make sure they match the theme’s existing HTML element styles.
  • Add theme support for editor-styles, to pull the existing editor stylesheet into the new editor.
  • Add theme support for wp-block-styles, to load the default block styles on the front end.

Props laurelfulford, ianbelanger, crunnells, davidkennedy.

Merges [43800] to trunk.

Fixes #45045.

Location:
trunk
Files:
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-content/themes/twentyseventeen/functions.php

    r43659 r44148  
    118118    add_editor_style( array( 'assets/css/editor-style.css', twentyseventeen_fonts_url() ) );
    119119
     120    // Load regular editor styles into the new block-based editor.
     121    add_theme_support( 'editor-styles' );
     122
     123    // Load default block styles.
     124    add_theme_support( 'wp-block-styles' );
     125
    120126    // Define and register starter content to showcase the theme on new sites.
    121127    $starter_content = array(
     
    440446    wp_enqueue_style( 'twentyseventeen-style', get_stylesheet_uri() );
    441447
     448    // Theme block stylesheet.
     449    wp_enqueue_style( 'twentyseventeen-block-style', get_theme_file_uri( '/assets/css/blocks.css' ), array( 'twentyseventeen-style' ), '1.0' );
     450
    442451    // Load the dark colorscheme.
    443452    if ( 'dark' === get_theme_mod( 'colorscheme', 'light' ) || is_customize_preview() ) {
     
    490499
    491500/**
     501 * Enqueue editor styles for Gutenberg
     502 *
     503 * @since Twenty Seventeen 1.8
     504 */
     505function twentyseventeen_block_editor_styles() {
     506    // Block styles.
     507    wp_enqueue_style( 'twentyseventeen-block-editor-style', get_theme_file_uri( '/assets/css/editor-blocks.css' ) );
     508    // Add custom fonts.
     509    wp_enqueue_style( 'twentyseventeen-fonts', twentyseventeen_fonts_url(), array(), null );
     510}
     511add_action( 'enqueue_block_editor_assets', 'twentyseventeen_block_editor_styles' );
     512
     513/**
    492514 * Add custom image sizes attribute to enhance responsive image functionality
    493515 * for content images.
Note: See TracChangeset for help on using the changeset viewer.