Make WordPress Core


Ignore:
Timestamp:
12/14/2018 02:32:33 AM (6 years ago)
Author:
pento
Message:

Default Themes: Import Twenty Nineteen from the 5.0 branch.

Merges [43808,43821,43842,43860,43892,43904,43909,43926-43929,43956,43961-43963] from the 5.0 branch to trunk.

Props allancole, karmatosed, kjellr, yingling017, mrasharirfan, milana_cap, fabiankaegy, westonruter, jorbin, netweb, b-07, khleomix, audrasjb, nielslange, mmaumio, richsalvucci, littlebigthing, dimadin, joyously, anevins, peterwilsoncc, dannycooper, iCaleb, siriokun, technosiren, travel_girl, azchughtai, ianbelanger, nadim1992, ismailelkorchi, nativeinside, chetan200891, grapplerulrich, ocean90, joshfeck, frankew, AbdulWahab610, mendezcode, eliorivero, melchoyce, joen, laurelfulford, mdawaffe, kraftbj, dsmart, nao, mayukojpn, enodekciw, ketuchetan, atanasangelovdev, poena, sharaz, artisticasad, mukesh27, burhandodhy, crunnells, aprakasa, themeroots, imonly_ik, tlxo, youthkee, brentswisher, smyoon315, mrahmadawais, desideveloper, Kau-Boy, mor10, mikeyarce, dingo_bastard, xkon, twoabove.

Fixes #45424.

Location:
trunk
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-content/themes/twentynineteen/inc/customizer.php

    r43808 r44149  
    11<?php
    22/**
    3  * Twenty Nineteen Theme Customizer
     3 * Twenty Nineteen: Customizer
    44 *
    55 * @package WordPress
    66 * @subpackage Twenty_Nineteen
     7 * @since 1.0.0
    78 */
    89
     
    3334        );
    3435    }
     36
     37    /**
     38     * Primary color.
     39     */
     40    $wp_customize->add_setting(
     41        'primary_color',
     42        array(
     43            'default'           => 'default',
     44            'transport'         => 'postMessage',
     45            'sanitize_callback' => 'twentynineteen_sanitize_color_option',
     46        )
     47    );
     48
     49    $wp_customize->add_control(
     50        'primary_color',
     51        array(
     52            'type'     => 'radio',
     53            'label'    => __( 'Primary Color', 'twentynineteen' ),
     54            'choices'  => array(
     55                'default'  => _x( 'Default', 'primary color', 'twentynineteen' ),
     56                'custom' => _x( 'Custom', 'primary color', 'twentynineteen' ),
     57            ),
     58            'section'  => 'colors',
     59            'priority' => 5,
     60        )
     61    );
     62
     63    // Add primary color hue setting and control.
     64    $wp_customize->add_setting(
     65        'primary_color_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            'primary_color_hue',
     77            array(
     78                'description' => __( 'Apply a custom color for buttons, links, featured images, etc.', 'twentynineteen' ),
     79                'section'     => 'colors',
     80                'mode'        => 'hue',
     81            )
     82        )
     83    );
     84
     85    // Add image filter setting and control.
     86    $wp_customize->add_setting(
     87        'image_filter',
     88        array(
     89            'default'           => 1,
     90            'sanitize_callback' => 'absint',
     91            'transport'         => 'postMessage',
     92        )
     93    );
     94
     95    $wp_customize->add_control(
     96        'image_filter',
     97        array(
     98            'label'   => __( 'Apply a filter to featured images using the primary color', 'twentynineteen' ),
     99            'section' => 'colors',
     100            'type'    => 'checkbox',
     101        )
     102    );
    35103}
    36104add_action( 'customize_register', 'twentynineteen_customize_register' );
     
    55123
    56124/**
    57  * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
     125 * Bind JS handlers to instantly live-preview changes.
    58126 */
    59127function twentynineteen_customize_preview_js() {
    60     wp_enqueue_script( 'twentynineteen-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true );
     128    wp_enqueue_script( 'twentynineteen-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20151215', true );
    61129}
    62130add_action( 'customize_preview_init', 'twentynineteen_customize_preview_js' );
     131
     132/**
     133 * Load dynamic logic for the customizer controls area.
     134 */
     135function twentynineteen_panels_js() {
     136    wp_enqueue_script( 'twentynineteen-customize-controls', get_theme_file_uri( '/js/customize-controls.js' ), array(), '1.0', true );
     137}
     138add_action( 'customize_controls_enqueue_scripts', 'twentynineteen_panels_js' );
     139
     140/**
     141 * Sanitize custom color choice.
     142 *
     143 * @param string $choice Whether image filter is active.
     144 *
     145 * @return string
     146 */
     147function twentynineteen_sanitize_color_option( $choice ) {
     148    $valid = array(
     149        'default',
     150        'custom',
     151    );
     152
     153    if ( in_array( $choice, $valid, true ) ) {
     154        return $choice;
     155    }
     156
     157    return 'default';
     158}
Note: See TracChangeset for help on using the changeset viewer.