- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyseventeen/inc/customizer.php
r40270 r42343 14 14 */ 15 15 function twentyseventeen_customize_register( $wp_customize ) { 16 $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; 17 $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; 18 $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; 19 20 $wp_customize->selective_refresh->add_partial( 'blogname', array( 21 'selector' => '.site-title a', 22 'render_callback' => 'twentyseventeen_customize_partial_blogname', 23 ) ); 24 $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 25 'selector' => '.site-description', 26 'render_callback' => 'twentyseventeen_customize_partial_blogdescription', 27 ) ); 16 $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; 17 $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; 18 $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; 19 20 $wp_customize->selective_refresh->add_partial( 21 'blogname', array( 22 'selector' => '.site-title a', 23 'render_callback' => 'twentyseventeen_customize_partial_blogname', 24 ) 25 ); 26 $wp_customize->selective_refresh->add_partial( 27 'blogdescription', array( 28 'selector' => '.site-description', 29 'render_callback' => 'twentyseventeen_customize_partial_blogdescription', 30 ) 31 ); 28 32 29 33 /** 30 34 * Custom colors. 31 35 */ 32 $wp_customize->add_setting( 'colorscheme', array( 33 'default' => 'light', 34 'transport' => 'postMessage', 35 'sanitize_callback' => 'twentyseventeen_sanitize_colorscheme', 36 ) ); 37 38 $wp_customize->add_setting( 'colorscheme_hue', array( 39 'default' => 250, 40 'transport' => 'postMessage', 41 'sanitize_callback' => 'absint', // The hue is stored as a positive integer. 42 ) ); 43 44 $wp_customize->add_control( 'colorscheme', array( 45 'type' => 'radio', 46 'label' => __( 'Color Scheme', 'twentyseventeen' ), 47 'choices' => array( 48 'light' => __( 'Light', 'twentyseventeen' ), 49 'dark' => __( 'Dark', 'twentyseventeen' ), 50 'custom' => __( 'Custom', 'twentyseventeen' ), 51 ), 52 'section' => 'colors', 53 'priority' => 5, 54 ) ); 55 56 $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'colorscheme_hue', array( 57 'mode' => 'hue', 58 'section' => 'colors', 59 'priority' => 6, 60 ) ) ); 36 $wp_customize->add_setting( 37 'colorscheme', array( 38 'default' => 'light', 39 'transport' => 'postMessage', 40 'sanitize_callback' => 'twentyseventeen_sanitize_colorscheme', 41 ) 42 ); 43 44 $wp_customize->add_setting( 45 'colorscheme_hue', array( 46 'default' => 250, 47 'transport' => 'postMessage', 48 'sanitize_callback' => 'absint', // The hue is stored as a positive integer. 49 ) 50 ); 51 52 $wp_customize->add_control( 53 'colorscheme', array( 54 'type' => 'radio', 55 'label' => __( 'Color Scheme', 'twentyseventeen' ), 56 'choices' => array( 57 'light' => __( 'Light', 'twentyseventeen' ), 58 'dark' => __( 'Dark', 'twentyseventeen' ), 59 'custom' => __( 'Custom', 'twentyseventeen' ), 60 ), 61 'section' => 'colors', 62 'priority' => 5, 63 ) 64 ); 65 66 $wp_customize->add_control( 67 new WP_Customize_Color_Control( 68 $wp_customize, 'colorscheme_hue', array( 69 'mode' => 'hue', 70 'section' => 'colors', 71 'priority' => 6, 72 ) 73 ) 74 ); 61 75 62 76 /** 63 77 * Theme options. 64 78 */ 65 $wp_customize->add_section( 'theme_options', array( 66 'title' => __( 'Theme Options', 'twentyseventeen' ), 67 'priority' => 130, // Before Additional CSS. 68 ) ); 69 70 $wp_customize->add_setting( 'page_layout', array( 71 'default' => 'two-column', 72 'sanitize_callback' => 'twentyseventeen_sanitize_page_layout', 73 'transport' => 'postMessage', 74 ) ); 75 76 $wp_customize->add_control( 'page_layout', array( 77 'label' => __( 'Page Layout', 'twentyseventeen' ), 78 'section' => 'theme_options', 79 'type' => 'radio', 80 'description' => __( 'When the two-column layout is assigned, the page title is in one column and content is in the other.', 'twentyseventeen' ), 81 'choices' => array( 82 'one-column' => __( 'One Column', 'twentyseventeen' ), 83 'two-column' => __( 'Two Column', 'twentyseventeen' ), 84 ), 85 'active_callback' => 'twentyseventeen_is_view_with_layout_option', 86 ) ); 79 $wp_customize->add_section( 80 'theme_options', array( 81 'title' => __( 'Theme Options', 'twentyseventeen' ), 82 'priority' => 130, // Before Additional CSS. 83 ) 84 ); 85 86 $wp_customize->add_setting( 87 'page_layout', array( 88 'default' => 'two-column', 89 'sanitize_callback' => 'twentyseventeen_sanitize_page_layout', 90 'transport' => 'postMessage', 91 ) 92 ); 93 94 $wp_customize->add_control( 95 'page_layout', array( 96 'label' => __( 'Page Layout', 'twentyseventeen' ), 97 'section' => 'theme_options', 98 'type' => 'radio', 99 'description' => __( 'When the two-column layout is assigned, the page title is in one column and content is in the other.', 'twentyseventeen' ), 100 'choices' => array( 101 'one-column' => __( 'One Column', 'twentyseventeen' ), 102 'two-column' => __( 'Two Column', 'twentyseventeen' ), 103 ), 104 'active_callback' => 'twentyseventeen_is_view_with_layout_option', 105 ) 106 ); 87 107 88 108 /** … … 97 117 // Create a setting and control for each of the sections available in the theme. 98 118 for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) { 99 $wp_customize->add_setting( 'panel_' . $i, array( 100 'default' => false, 101 'sanitize_callback' => 'absint', 102 'transport' => 'postMessage', 103 ) ); 104 105 $wp_customize->add_control( 'panel_' . $i, array( 106 /* translators: %d is the front page section number */ 107 'label' => sprintf( __( 'Front Page Section %d Content', 'twentyseventeen' ), $i ), 108 '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' ) ), 109 'section' => 'theme_options', 110 'type' => 'dropdown-pages', 111 'allow_addition' => true, 112 'active_callback' => 'twentyseventeen_is_static_front_page', 113 ) ); 114 115 $wp_customize->selective_refresh->add_partial( 'panel_' . $i, array( 116 'selector' => '#panel' . $i, 117 'render_callback' => 'twentyseventeen_front_page_section', 118 'container_inclusive' => true, 119 ) ); 119 $wp_customize->add_setting( 120 'panel_' . $i, array( 121 'default' => false, 122 'sanitize_callback' => 'absint', 123 'transport' => 'postMessage', 124 ) 125 ); 126 127 $wp_customize->add_control( 128 'panel_' . $i, array( 129 /* translators: %d is the front page section number */ 130 'label' => sprintf( __( 'Front Page Section %d Content', 'twentyseventeen' ), $i ), 131 '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' ) ), 132 'section' => 'theme_options', 133 'type' => 'dropdown-pages', 134 'allow_addition' => true, 135 'active_callback' => 'twentyseventeen_is_static_front_page', 136 ) 137 ); 138 139 $wp_customize->selective_refresh->add_partial( 140 'panel_' . $i, array( 141 'selector' => '#panel' . $i, 142 'render_callback' => 'twentyseventeen_front_page_section', 143 'container_inclusive' => true, 144 ) 145 ); 120 146 } 121 147 }
Note: See TracChangeset
for help on using the changeset viewer.