Make WordPress Core


Ignore:
Timestamp:
10/30/2018 02:13:07 AM (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.

File:
1 edited

Legend:

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

    r43808 r43842  
    55 * @package WordPress
    66 * @subpackage Twenty_Nineteen
     7 * @since 1.0.0
    78 */
    89
     
    3334        );
    3435    }
     36
     37    /**
     38     * Custom colors.
     39     */
     40    $wp_customize->add_setting(
     41        'colorscheme',
     42        array(
     43            'default'           => 'default',
     44            'transport'         => 'postMessage',
     45            'sanitize_callback' => 'twentynineteen_sanitize_color_option',
     46        )
     47    );
     48
     49    $wp_customize->add_control(
     50        'colorscheme',
     51        array(
     52            'type'    => 'radio',
     53            'label'    => __( 'Color Scheme', 'twentynineteen' ),
     54            'choices'  => array(
     55                'default'  => __( 'Default', 'twentynineteen' ),
     56                'custom' => __( 'Custom', 'twentynineteen' ),
     57            ),
     58            'section'  => 'colors',
     59            'priority' => 5,
     60        )
     61    );
     62
     63    // Add primary color setting and control.
     64    $wp_customize->add_setting(
     65        'colorscheme_hue',
     66        array(
     67            'default'           => 199,
     68            'transport'         => 'postMessage',
     69            'sanitize_callback' => 'absint',
     70        )
     71    );
     72
     73    $wp_customize->add_control(
     74        new WP_Customize_Color_Control(
     75            $wp_customize,
     76            'colorscheme_hue',
     77            array(
     78                'label'       => __( 'Primary Color' ),
     79                'description' => __( 'Changes the Color of the Featured Image overlay, Buttons, Links etc.' ),
     80                'section'     => 'colors',
     81                'mode'        => 'hue',
     82            )
     83        )
     84    );
     85
     86    $wp_customize->add_setting(
     87        'image_filter',
     88        array(
     89            'default'           => 'active',
     90            'sanitize_callback' => 'twentynineteen_sanitize_image_filter',
     91            'transport'         => 'postMessage',
     92        )
     93    );
     94
     95    $wp_customize->add_control(
     96        'image_filter',
     97        array(
     98            'label'       => __( 'Featured Image Color Filter', 'twentynineteen' ),
     99            'section'     => 'colors',
     100            'type'        => 'radio',
     101            'description' => __( "Twenty Nineteen adds a color filter to featured images using your site's primary color. If you disable this effect, the theme will use a black filter in individual posts to keep text readable when it appears on top of the featured image.", 'twentynineteen' ) . '<br/><span style="font-style: normal; display: block; margin-top: 16px;">' . __( 'On Featured Images, apply', 'twentynineteen' ) . '</span>',
     102            'choices'     => array(
     103                'active'   => __( 'A color filter', 'twentynineteen' ),
     104                'inactive' => __( 'A black filter', 'twentynineteen' ),
     105            ),
     106        )
     107    );
    35108}
    36109add_action( 'customize_register', 'twentynineteen_customize_register' );
     
    55128
    56129/**
    57  * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
     130 * Bind JS handlers to instantly live-preview changes.
    58131 */
    59132function twentynineteen_customize_preview_js() {
    60     wp_enqueue_script( 'twentynineteen-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true );
     133    wp_enqueue_script( 'twentynineteen-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20151215', true );
    61134}
    62135add_action( 'customize_preview_init', 'twentynineteen_customize_preview_js' );
     136
     137/**
     138 * Load dynamic logic for the customizer controls area.
     139 */
     140function twentynineteen_panels_js() {
     141    wp_enqueue_script( 'twentynineteen-customize-controls', get_theme_file_uri( '/js/customize-controls.js' ), array(), '1.0', true );
     142}
     143add_action( 'customize_controls_enqueue_scripts', 'twentynineteen_panels_js' );
     144
     145/**
     146 * Sanitize image filter choice.
     147 *
     148 * @param string $choice Whether image filter is active.
     149 *
     150 * @return string
     151 */
     152function twentynineteen_sanitize_color_option( $choice ) {
     153    $valid = array(
     154        'default',
     155        'custom',
     156    );
     157
     158    if ( in_array( $choice, $valid, true ) ) {
     159        return $choice;
     160    }
     161
     162    return 'default';
     163}
     164/**
     165 * Sanitize image filter choice.
     166 *
     167 * @param string $choice Whether image filter is active.
     168 *
     169 * @return string
     170 */
     171function twentynineteen_sanitize_image_filter( $choice ) {
     172    $valid = array(
     173        'active',
     174        'inactive',
     175    );
     176
     177    if ( in_array( $choice, $valid, true ) ) {
     178        return $choice;
     179    }
     180
     181    return 'active';
     182}
Note: See TracChangeset for help on using the changeset viewer.