WordPress/wp-content/themes/twentyseventeen/inc/customizer.php

252 lines
6.7 KiB
PHP
Raw Normal View History

<?php
/**
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
* Twenty Seventeen: Customizer
*
* @package WordPress
* @subpackage Twenty_Seventeen
* @since Twenty Seventeen 1.0
*/
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function twentyseventeen_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
$wp_customize->selective_refresh->add_partial(
'blogname',
array(
'selector' => '.site-title a',
'render_callback' => 'twentyseventeen_customize_partial_blogname',
)
);
$wp_customize->selective_refresh->add_partial(
'blogdescription',
array(
'selector' => '.site-description',
'render_callback' => 'twentyseventeen_customize_partial_blogdescription',
)
);
/**
* Custom colors.
*/
$wp_customize->add_setting(
'colorscheme',
array(
'default' => 'light',
'transport' => 'postMessage',
'sanitize_callback' => 'twentyseventeen_sanitize_colorscheme',
)
);
$wp_customize->add_setting(
'colorscheme_hue',
array(
'default' => 250,
'transport' => 'postMessage',
'sanitize_callback' => 'absint', // The hue is stored as a positive integer.
)
);
$wp_customize->add_control(
'colorscheme',
array(
'type' => 'radio',
'label' => __( 'Color Scheme', 'twentyseventeen' ),
'choices' => array(
'light' => __( 'Light', 'twentyseventeen' ),
'dark' => __( 'Dark', 'twentyseventeen' ),
'custom' => __( 'Custom', 'twentyseventeen' ),
),
'section' => 'colors',
'priority' => 5,
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'colorscheme_hue',
array(
'mode' => 'hue',
'section' => 'colors',
'priority' => 6,
)
)
);
/**
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
* Theme options.
*/
$wp_customize->add_section(
'theme_options',
array(
'title' => __( 'Theme Options', 'twentyseventeen' ),
'priority' => 130, // Before Additional CSS.
)
);
$wp_customize->add_setting(
'page_layout',
array(
'default' => 'two-column',
'sanitize_callback' => 'twentyseventeen_sanitize_page_layout',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
'page_layout',
array(
'label' => __( 'Page Layout', 'twentyseventeen' ),
'section' => 'theme_options',
'type' => 'radio',
'description' => __( 'When the two-column layout is assigned, the page title is in one column and content is in the other.', 'twentyseventeen' ),
'choices' => array(
'one-column' => __( 'One Column', 'twentyseventeen' ),
'two-column' => __( 'Two Column', 'twentyseventeen' ),
),
'active_callback' => 'twentyseventeen_is_view_with_layout_option',
)
);
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
/**
* Filters the number of front page sections in Twenty Seventeen.
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
*
* @since Twenty Seventeen 1.0
*
* @param int $num_sections Number of front page sections.
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
*/
$num_sections = apply_filters( 'twentyseventeen_front_page_sections', 4 );
// Create a setting and control for each of the sections available in the theme.
for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) {
$wp_customize->add_setting(
'panel_' . $i,
array(
'default' => false,
'sanitize_callback' => 'absint',
'transport' => 'postMessage',
)
);
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
$wp_customize->add_control(
'panel_' . $i,
array(
/* translators: %d: The front page section number. */
'label' => sprintf( __( 'Front Page Section %d Content', 'twentyseventeen' ), $i ),
'description' => ( 1 !== $i ? '' : __( 'Select pages to feature in each area from the dropdowns. Add an image to a section by setting a featured image in the page editor. Empty sections will not be displayed.', 'twentyseventeen' ) ),
'section' => 'theme_options',
'type' => 'dropdown-pages',
'allow_addition' => true,
'active_callback' => 'twentyseventeen_is_static_front_page',
)
);
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
$wp_customize->selective_refresh->add_partial(
'panel_' . $i,
array(
'selector' => '#panel' . $i,
'render_callback' => 'twentyseventeen_front_page_section',
'container_inclusive' => true,
)
);
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
}
}
add_action( 'customize_register', 'twentyseventeen_customize_register' );
/**
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
* Sanitize the page layout options.
*
* @param string $input Page layout.
*/
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
function twentyseventeen_sanitize_page_layout( $input ) {
$valid = array(
'one-column' => __( 'One Column', 'twentyseventeen' ),
'two-column' => __( 'Two Column', 'twentyseventeen' ),
);
if ( array_key_exists( $input, $valid ) ) {
return $input;
}
return '';
}
/**
* Sanitize the colorscheme.
*
* @param string $input Color scheme.
*/
function twentyseventeen_sanitize_colorscheme( $input ) {
$valid = array( 'light', 'dark', 'custom' );
if ( in_array( $input, $valid, true ) ) {
return $input;
}
return 'light';
}
/**
* Render the site title for the selective refresh partial.
*
* @since Twenty Seventeen 1.0
*
* @see twentyseventeen_customize_register()
*
* @return void
*/
function twentyseventeen_customize_partial_blogname() {
bloginfo( 'name' );
}
/**
* Render the site tagline for the selective refresh partial.
*
* @since Twenty Seventeen 1.0
*
* @see twentyseventeen_customize_register()
*
* @return void
*/
function twentyseventeen_customize_partial_blogdescription() {
bloginfo( 'description' );
}
/**
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
* Return whether we're previewing the front page and it's a static page.
*/
function twentyseventeen_is_static_front_page() {
return ( is_front_page() && ! is_home() );
}
/**
* Return whether we're on a view that supports a one or two column layout.
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
*/
function twentyseventeen_is_view_with_layout_option() {
// This option is available on all pages. It's also available on archives when there isn't a sidebar.
return ( is_page() || ( is_archive() && ! is_active_sidebar( 'sidebar-1' ) ) );
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
}
/**
* Bind JS handlers to instantly live-preview changes.
*/
function twentyseventeen_customize_preview_js() {
wp_enqueue_script( 'twentyseventeen-customize-preview', get_theme_file_uri( '/assets/js/customize-preview.js' ), array( 'customize-preview' ), '20161002', true );
}
add_action( 'customize_preview_init', 'twentyseventeen_customize_preview_js' );
/**
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. Built from https://develop.svn.wordpress.org/trunk@38986 git-svn-id: http://core.svn.wordpress.org/trunk@38929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-28 00:09:40 +02:00
* Load dynamic logic for the customizer controls area.
*/
function twentyseventeen_panels_js() {
wp_enqueue_script( 'twentyseventeen-customize-controls', get_theme_file_uri( '/assets/js/customize-controls.js' ), array(), '20161020', true );
}
add_action( 'customize_controls_enqueue_scripts', 'twentyseventeen_panels_js' );