Make WordPress Core


Ignore:
Timestamp:
11/02/2018 11:52:16 PM (6 years ago)
Author:
allancole
Message:

Importing Twenty Nineteen, our new default theme for 2019, set for 5.0.

Let Gutenberg shine with this simple, fast, and powerful theme. Initial development occurred on GitHub. See: https://github.com/WordPress/twentynineteen

Props allancole, karmatosed, kjellr, yingling017, mrasharirfan, milana_cap, fabiankaegy, westonruter, aaronjorbin, netweb, b-07, khleomix, blowery, dereksmart, jasmussen, audrasjb, nielslange, mmaumio, dimadin, joyously, anevins12, peterwilsoncc, dannycooper, icaleb, siriokun, technosiren, travel_girl, azchughtai, ianbelanger, nadim1992, ismailelkorchi, nativeinside, chetan200891, icaleb, grapplerulrich, ocean90, joshfeck, frankew, abdulwahab610, mendezcode, eliorivero, melchoyce, joen, laurelfulford, mdawaffe, kraftbj, dsmart, mukeshpanchal27, burhandodhy, crunnells, Ismail-elkorchi, aryaprakasa.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-content/themes/twentynineteen/functions.php

    r43842 r43860  
    8484        );
    8585
     86        // Add theme support for selective refresh for widgets.
     87        add_theme_support( 'customize-selective-refresh-widgets' );
     88
    8689        // Add support for Block Styles
    8790        add_theme_support( 'wp-block-styles' );
     
    9699        add_editor_style( 'style-editor.css' );
    97100
    98         // Add custom color to the editor color palette
     101        // Editor color palette
    99102        add_theme_support(
    100         'editor-color-palette',
     103            'editor-color-palette',
    101104            array(
    102105                array(
    103106                    'name'  => esc_html__( 'Primary Color', 'twentynineteen' ),
    104107                    'slug'  => 'primary',
    105                     'color' => twentynineteen_hsl_hex( absint( get_theme_mod( 'colorscheme_hue', 199 ) ), 100, 33 ),
     108                    'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'colorscheme' ) ? 199 : get_theme_mod( 'colorscheme_primary_hue', 199 ), 100, 33 ),
    106109                ),
    107110            )
    108111        );
     112
     113        // Add support for responsive embedded content
     114        add_theme_support( 'responsive-embeds' );
    109115
    110116    }
     
    121127    register_sidebar(
    122128        array(
    123             'name'          => __( 'Footer 1', 'twentynineteen' ),
     129            'name'          => __( 'Footer', 'twentynineteen' ),
    124130            'id'            => 'sidebar-1',
    125131            'description'   => __( 'Add widgets here to appear in your footer.', 'twentynineteen' ),
     
    161167    if ( has_nav_menu( 'menu-1' ) ) {
    162168        wp_enqueue_script( 'twentynineteen-touch-navigation', get_theme_file_uri( '/js/touch-navigation.js' ), array(), '1.0', true );
    163         $twentynineteen_l10n['expand']   = __( 'Expand child menu', 'twentynineteen' );
    164         $twentynineteen_l10n['collapse'] = __( 'Collapse child menu', 'twentynineteen' );
    165     }
    166 
    167     wp_localize_script( 'twentynineteen-skip-link-focus-fix', 'twentynineteenScreenReaderText', $twentynineteen_l10n );
     169        $l10n_skip_link_focus_fix['expand']   = __( 'Expand child menu', 'twentynineteen' );
     170        $l10n_skip_link_focus_fix['collapse'] = __( 'Collapse child menu', 'twentynineteen' );
     171        wp_localize_script( 'twentynineteen-skip-link-focus-fix', 'twentynineteenScreenReaderText', $l10n_skip_link_focus_fix );
     172    }
    168173
    169174    wp_enqueue_style( 'twentynineteen-print-style', get_template_directory_uri() . '/print.css', array(), wp_get_theme()->get( 'Version' ), 'print' );
     
    182187 * Enqueue supplemental block editor styles
    183188 */
    184 function twentynineteen_editor_frame_styles() {
    185 
    186     // Include color patterns
     189function twentynineteen_editor_customizer_styles() {
     190
     191    wp_enqueue_style( 'twentynineteen-editor-customizer-styles', get_theme_file_uri( '/style-editor-customizer.css' ), false, '1.0', 'all' );
     192
     193    if ( 'custom' === get_theme_mod( 'colorscheme' ) ) {
     194        // Include color patterns
     195        require_once( get_parent_theme_file_path( '/inc/color-patterns.php' ) );
     196        wp_add_inline_style( 'twentynineteen-editor-customizer-styles', twentynineteen_custom_colors_css() );
     197    }
     198}
     199add_action( 'enqueue_block_editor_assets', 'twentynineteen_editor_customizer_styles' );
     200
     201/**
     202 * Display custom color CSS in customizer and on frontend.
     203 */
     204function twentynineteen_colors_css_wrap() {
     205
     206    // Only include custom colors in customizer or frontend
     207    if ( ( ! is_customize_preview() && is_admin() ) || is_admin() ) {
     208        return;
     209    }
     210
    187211    require_once( get_parent_theme_file_path( '/inc/color-patterns.php' ) );
    188212
    189     wp_enqueue_style( 'twentynineteen-editor-frame-styles', get_theme_file_uri( '/style-editor-frame.css' ), false, '1.0', 'all' );
    190     wp_add_inline_style( 'twentynineteen-editor-frame-styles', twentynineteen_custom_colors_css() );
    191 }
    192 add_action( 'enqueue_block_editor_assets', 'twentynineteen_editor_frame_styles' );
    193 
    194 /**
    195  * Display custom color CSS in customizer and on frontend.
    196  */
    197 function twentynineteen_colors_css_wrap() {
    198     if ( 'custom' !== get_theme_mod( 'colorscheme' ) && ! is_customize_preview() ) {
    199         return;
    200     }
    201 
    202     require_once( get_parent_theme_file_path( '/inc/color-patterns.php' ) );
    203     $hue = absint( get_theme_mod( 'colorscheme_hue', 250 ) );
     213    if ( 'default' === get_theme_mod( 'colorscheme', 'default' ) ) {
     214        $primary_color = 199;
     215    } else {
     216        $primary_color = absint( get_theme_mod( 'colorscheme_primary_hue', 199 ) );
     217    }
    204218    ?>
    205219
    206     <style type="text/css" id="custom-theme-colors" <?php echo is_customize_preview() ? 'data-hue="' . $hue . '"' : ''; ?>>
     220    <style type="text/css" id="custom-theme-colors" <?php echo is_customize_preview() ? 'data-hue="' . $primary_color . '"' : ''; ?>>
    207221        <?php echo twentynineteen_custom_colors_css(); ?>
    208222    </style>
Note: See TracChangeset for help on using the changeset viewer.