twentyeleven_customize_register

Implements Twenty Eleven theme options into Customizer.

Description

twentyeleven_customize_register( (object) $wp_customize ); 

Parameters (1)

0. $wp_customize (object)
Customizer object.

Usage

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

Defined (1)

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

/inc/theme-options.php  
  1. function twentyeleven_customize_register( $wp_customize ) { 
  2. $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; 
  3. $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; 
  4. $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; 
  5.  
  6. if ( isset( $wp_customize->selective_refresh ) ) { 
  7. $wp_customize->selective_refresh->add_partial( 'blogname', array( 
  8. 'selector' => '#site-title a',  
  9. 'container_inclusive' => false,  
  10. 'render_callback' => 'twentyeleven_customize_partial_blogname',  
  11. ) ); 
  12. $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 
  13. 'selector' => '#site-description',  
  14. 'container_inclusive' => false,  
  15. ) ); 
  16.  
  17.  
  18. $wp_customize->add_setting( 'twentyeleven_theme_options[color_scheme]', array( 
  19. 'default' => $defaults['color_scheme'],  
  20. 'type' => 'option',  
  21. 'capability' => 'edit_theme_options',  
  22. ) ); 
  23.  
  24. $choices = array(); 
  25. foreach ( $schemes as $scheme ) { 
  26. $choices[ $scheme['value'] ] = $scheme['label']; 
  27.  
  28. $wp_customize->add_control( 'twentyeleven_color_scheme', array( 
  29. 'label' => __( 'Color Scheme', 'twentyeleven' ),  
  30. 'section' => 'colors',  
  31. 'settings' => 'twentyeleven_theme_options[color_scheme]',  
  32. 'type' => 'radio',  
  33. 'choices' => $choices,  
  34. 'priority' => 5,  
  35. ) ); 
  36.  
  37. // Link Color (added to Color Scheme section in Customizer) 
  38. $wp_customize->add_setting( 'twentyeleven_theme_options[link_color]', array( 
  39. 'default' => twentyeleven_get_default_link_color( $options['color_scheme'] ),  
  40. 'type' => 'option',  
  41. 'sanitize_callback' => 'sanitize_hex_color',  
  42. 'capability' => 'edit_theme_options',  
  43. ) ); 
  44.  
  45. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array( 
  46. 'label' => __( 'Link Color', 'twentyeleven' ),  
  47. 'section' => 'colors',  
  48. 'settings' => 'twentyeleven_theme_options[link_color]',  
  49. ) ) ); 
  50.  
  51. // Default Layout 
  52. $wp_customize->add_section( 'twentyeleven_layout', array( 
  53. 'title' => __( 'Layout', 'twentyeleven' ),  
  54. 'priority' => 50,  
  55. ) ); 
  56.  
  57. $wp_customize->add_setting( 'twentyeleven_theme_options[theme_layout]', array( 
  58. 'type' => 'option',  
  59. 'default' => $defaults['theme_layout'],  
  60. 'sanitize_callback' => 'sanitize_key',  
  61. ) ); 
  62.  
  63. $layouts = twentyeleven_layouts(); 
  64. $choices = array(); 
  65. foreach ( $layouts as $layout ) { 
  66. $choices[ $layout['value'] ] = $layout['label']; 
  67.  
  68. $wp_customize->add_control( 'twentyeleven_theme_options[theme_layout]', array( 
  69. 'section' => 'twentyeleven_layout',  
  70. 'type' => 'radio',  
  71. 'choices' => $choices,  
  72. ) );