2016-10-20 11:27:32 +02:00
< ? php
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
/**
* Twenty Seventeen : Theme Customizer
*
* @ package WordPress
* @ subpackage Twenty_Seventeen
* @ since 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 ) {
2016-10-21 07:28:31 +02:00
$wp_customize -> get_setting ( 'blogname' ) -> transport = 'postMessage' ;
$wp_customize -> get_setting ( 'blogdescription' ) -> transport = 'postMessage' ;
$wp_customize -> get_setting ( 'header_textcolor' ) -> transport = 'postMessage' ;
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
/**
* 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 ,
) );
2016-10-26 00:33:30 +02:00
$wp_customize -> add_control ( new WP_Customize_Color_Control ( $wp_customize , 'colorscheme_hue' , array (
'mode' => 'hue' ,
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
'section' => 'colors' ,
'priority' => 6 ,
2016-10-26 00:33:30 +02:00
) ) );
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
/**
* Add the Theme Options section .
*/
$wp_customize -> add_panel ( 'options_panel' , array (
'title' => __ ( 'Theme Options' , 'twentyseventeen' ),
'description' => __ ( 'Configure your theme settings' , 'twentyseventeen' ),
) );
// Page Options.
$wp_customize -> add_section ( 'page_options' , array (
'title' => __ ( 'Single Page Layout' , 'twentyseventeen' ),
'active_callback' => 'twentyseventeen_is_page' ,
'panel' => 'options_panel' ,
) );
$wp_customize -> add_setting ( 'page_options' , array (
'default' => 'two-column' ,
'sanitize_callback' => 'twentyseventeen_sanitize_layout' ,
'transport' => 'postMessage' ,
) );
$wp_customize -> add_control ( 'page_options' , array (
'label' => __ ( 'Page Layout' , 'twentyseventeen' ),
'section' => 'page_options' ,
'type' => 'radio' ,
'description' => __ ( 'When no sidebar widgets are assigned, you can opt to display all pages with a one column or two column layout. 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' ),
),
) );
// Panel 1.
$wp_customize -> add_section ( 'panel_1' , array (
'title' => __ ( 'Panel 1' , 'twentyseventeen' ),
'active_callback' => 'is_front_page' ,
'panel' => 'options_panel' ,
'description' => __ ( 'Add an image to your panel by setting a featured image in the page editor. If you don’t select a page, this panel will not be displayed.' , 'twentyseventeen' ),
) );
$wp_customize -> add_setting ( 'panel_1' , array (
'default' => false ,
'sanitize_callback' => 'absint' ,
) );
$wp_customize -> add_control ( 'panel_1' , array (
'label' => __ ( 'Panel Content' , 'twentyseventeen' ),
'section' => 'panel_1' ,
'type' => 'dropdown-pages' ,
) );
// Panel 2.
$wp_customize -> add_section ( 'panel_2' , array (
'title' => __ ( 'Panel 2' , 'twentyseventeen' ),
'active_callback' => 'is_front_page' ,
'panel' => 'options_panel' ,
'description' => __ ( 'Add an image to your panel by setting a featured image in the page editor. If you don’t select a page, this panel will not be displayed.' , 'twentyseventeen' ),
) );
$wp_customize -> add_setting ( 'panel_2' , array (
'default' => false ,
'sanitize_callback' => 'absint' ,
) );
$wp_customize -> add_control ( 'panel_2' , array (
'label' => __ ( 'Panel Content' , 'twentyseventeen' ),
'section' => 'panel_2' ,
'type' => 'dropdown-pages' ,
) );
// Panel 3.
$wp_customize -> add_section ( 'panel_3' , array (
'title' => __ ( 'Panel 3' , 'twentyseventeen' ),
'active_callback' => 'is_front_page' ,
'panel' => 'options_panel' ,
'description' => __ ( 'Add an image to your panel by setting a featured image in the page editor. If you don’t select a page, this panel will not be displayed.' , 'twentyseventeen' ),
) );
$wp_customize -> add_setting ( 'panel_3' , array (
'default' => false ,
'sanitize_callback' => 'absint' ,
) );
$wp_customize -> add_control ( 'panel_3' , array (
'label' => __ ( 'Panel Content' , 'twentyseventeen' ),
'section' => 'panel_3' ,
'type' => 'dropdown-pages' ,
) );
// Panel 4.
$wp_customize -> add_section ( 'panel_4' , array (
'title' => __ ( 'Panel 4' , 'twentyseventeen' ),
'active_callback' => 'is_front_page' ,
'panel' => 'options_panel' ,
'description' => __ ( 'Add an image to your panel by setting a featured image in the page editor. If you don’t select a page, this panel will not be displayed.' , 'twentyseventeen' ),
) );
$wp_customize -> add_setting ( 'panel_4' , array (
'default' => false ,
'sanitize_callback' => 'absint' ,
) );
$wp_customize -> add_control ( 'panel_4' , array (
'label' => __ ( 'Panel Content' , 'twentyseventeen' ),
'section' => 'panel_4' ,
'type' => 'dropdown-pages' ,
) );
}
add_action ( 'customize_register' , 'twentyseventeen_customize_register' );
/**
* Sanitize a radio button .
*/
function twentyseventeen_sanitize_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 .
*/
function twentyseventeen_sanitize_colorscheme ( $input ) {
$valid = array ( 'light' , 'dark' , 'custom' );
if ( in_array ( $input , $valid ) ) {
return $input ;
}
return 'light' ;
}
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously .
*/
function twentyseventeen_customize_preview_js () {
wp_enqueue_script ( 'twentyseventeen-customizer' , get_theme_file_uri ( '/assets/js/customizer.js' ), array ( 'customize-preview' ), '1.0' , true );
}
add_action ( 'customize_preview_init' , 'twentyseventeen_customize_preview_js' );
/**
* Some extra JavaScript to improve the user experience in the Customizer for this theme .
*/
function twentyseventeen_panels_js () {
wp_enqueue_script ( 'twentyseventeen-panel-customizer' , get_theme_file_uri ( '/assets/js/panel-customizer.js' ), array (), '1.0' , true );
}
add_action ( 'customize_controls_enqueue_scripts' , 'twentyseventeen_panels_js' );