WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/27/2016 10:08:33 PM (5 years ago)
Author:
davidakennedy
Message:

Twenty Seventeen: Improve user and developer experience with the customizer integration

  • Rename customizer JS files to customize-preview.js and customize-controls.js to align with the core file naming and make it clearer where each file runs.
  • Only show the colorscheme_hue control when there's a custom color scheme.
  • Update preview JS handling for revised front page section handling, see below.
  • Remove all references to "Theme Customizer" in code comments. It hasn't been called that since before 4.0.
  • Clarify the purpose of the JS files by updated the code comments in the file headers.
  • Improve code readability.
  • Make the arbitrary number of front page sections filterable, for UI registration and output.
  • Rename twentyseventeen_sanitize_layout to twentyseventeen_sanitize_page_layout to be clearer about what it sanitizes in case child themes or plugins consider reusing it.
  • Rename page_options setting/control to page_layout as that's more reflective of what that option does; and again, helps for potential extensions.
  • Make the page layout option contextual to pages and the sidebar being inactive, as the option only applies when there is no sidebar (per its description).
  • Condense options into a single section.
  • Add selective refresh for front page sections.
  • Locate active_callback functions within customizer.php so that they're easier to find when editing customizer registrations, similarly to sanitize callbacks.
  • Adjust the styling for placeholders for panels that aren't active.
  • Ensure that the new visible edit shortcuts don't have any issues.

Props celloexpressions.

Fixes #38426.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyseventeen/inc/template-functions.php

    r38985 r38986  
    4747    // Add class for one or two column page layouts.
    4848    if ( is_page() ) {
    49         if ( 'one-column' === get_theme_mod( 'page_options' ) ) {
     49        if ( 'one-column' === get_theme_mod( 'page_layout' ) ) {
    5050            $classes[] = 'page-one-column';
    5151        } else {
     
    7373 */
    7474function twentyseventeen_panel_count() {
    75     $panels = array( '1', '2', '3', '4' );
     75
    7676    $panel_count = 0;
    7777
    78     foreach ( $panels as $panel ) {
    79         if ( get_theme_mod( 'panel_' . $panel ) ) {
     78    /**
     79     * Filter number of front page sections in Twenty Seventeen.
     80     *
     81     * @since Twenty Seventeen 1.0
     82     *
     83     * @param $num_sections integer
     84     */
     85    $num_sections = apply_filters( 'twentyseventeen_front_page_sections', 4 );
     86
     87    // Create a setting and control for each of the sections available in the theme.
     88    for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) {
     89        if ( get_theme_mod( 'panel_' . $i ) ) {
    8090            $panel_count++;
    8191        }
     
    91101    return ( is_front_page() && ! is_home() );
    92102}
    93 
    94 /**
    95  * Custom Active Callback to check for page.
    96  */
    97 function twentyseventeen_is_page() {
    98     return ( is_page() );
    99 }
Note: See TracChangeset for help on using the changeset viewer.