twentyfifteen_customize_register

Add postMessage support for site title and description for the Customizer.

Description

twentyfifteen_customize_register( (WP_Customize_Manager) $wp_customize ); 

Parameters (1)

0. $wp_customize (WP_Customize_Manager)
Customizer object.

Usage

  1. if ( !function_exists( 'twentyfifteen_customize_register' ) ) { 
  2. require_once '/inc/customizer.php'; 
  3.  
  4. // Customizer object. 
  5. $wp_customize = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = twentyfifteen_customize_register($wp_customize); 
  9.  

Defined (1)

The function is defined in the following location(s).

/inc/customizer.php  
  1. function twentyfifteen_customize_register( $wp_customize ) { 
  2. $color_scheme = twentyfifteen_get_color_scheme(); 
  3.  
  4. $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; 
  5. $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; 
  6.  
  7. if ( isset( $wp_customize->selective_refresh ) ) { 
  8. $wp_customize->selective_refresh->add_partial( 'blogname', array( 
  9. 'selector' => '.site-title a',  
  10. 'container_inclusive' => false,  
  11. 'render_callback' => 'twentyfifteen_customize_partial_blogname',  
  12. ) ); 
  13. $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 
  14. 'selector' => '.site-description',  
  15. 'container_inclusive' => false,  
  16. ) ); 
  17.  
  18. // Add color scheme setting and control. 
  19. $wp_customize->add_setting( 'color_scheme', array( 
  20. 'default' => 'default',  
  21. 'sanitize_callback' => 'twentyfifteen_sanitize_color_scheme',  
  22. 'transport' => 'postMessage',  
  23. ) ); 
  24.  
  25. $wp_customize->add_control( 'color_scheme', array( 
  26. 'label' => __( 'Base Color Scheme', 'twentyfifteen' ),  
  27. 'section' => 'colors',  
  28. 'type' => 'select',  
  29. 'priority' => 1,  
  30. ) ); 
  31.  
  32. // Add custom header and sidebar text color setting and control. 
  33. $wp_customize->add_setting( 'sidebar_textcolor', array( 
  34. 'default' => $color_scheme[4],  
  35. 'sanitize_callback' => 'sanitize_hex_color',  
  36. 'transport' => 'postMessage',  
  37. ) ); 
  38.  
  39. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'sidebar_textcolor', array( 
  40. 'label' => __( 'Header and Sidebar Text Color', 'twentyfifteen' ),  
  41. 'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ),  
  42. 'section' => 'colors',  
  43. ) ) ); 
  44.  
  45. // Remove the core header textcolor control, as it shares the sidebar text color. 
  46. $wp_customize->remove_control( 'header_textcolor' ); 
  47.  
  48. // Add custom header and sidebar background color setting and control. 
  49. $wp_customize->add_setting( 'header_background_color', array( 
  50. 'default' => $color_scheme[1],  
  51. 'sanitize_callback' => 'sanitize_hex_color',  
  52. 'transport' => 'postMessage',  
  53. ) ); 
  54.  
  55. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_background_color', array( 
  56. 'label' => __( 'Header and Sidebar Background Color', 'twentyfifteen' ),  
  57. 'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ),  
  58. 'section' => 'colors',  
  59. ) ) ); 
  60.  
  61. // Add an additional description to the header image section. 
  62. $wp_customize->get_section( 'header_image' )->description = __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' );