Advertisement
Guest User

3.4 Theme Customizer

a guest
Jun 8th, 2012
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. <?php
  2. function twentyeleven_customizer_options($wp_customize) {
  3.  
  4. $wp_customize->add_section( 'twentyeleven_color_scheme', array(
  5.     'title'          => __( 'Colors', 'twentyeleven' ),
  6.     'priority'       => 35,
  7. ));
  8.  
  9. $wp_customize->add_setting( 'twentyeleven_theme_options[text_color]', array(
  10.     'default'   => '#000000',
  11.     'type'      => 'option',
  12.     'transport' => 'postMessage',
  13. ));
  14.  
  15. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'text_color', array(
  16.     'label'   => __( 'Text Color', 'twentyeleven' ),
  17.     'section' => 'twentyeleven_color_scheme',
  18.     'settings'   => 'twentyeleven_theme_options[text_color]',
  19. ) ) );
  20.  
  21.  
  22. $wp_customize->get_setting('twentyeleven_theme_options[text_color]')->transport='postMessage';
  23.  
  24. if ( $wp_customize->is_preview() && ! is_admin() )
  25.     add_action( 'wp_footer', 'twentyeleven_customize_preview', 21);
  26. }
  27. add_action( 'customize_register', 'twentyeleven_customizer_options' );
  28.  
  29. function twentyeleven_customize_preview() {
  30.     ?>
  31.     <script type="text/javascript">
  32.     wp.customize( 'twentyeleven_theme_options[text_color]', function( value ) {
  33.         value.bind(function(to) {
  34.             jQuery('body').css('color', to );
  35.         });
  36.     });
  37.     </script>
  38.     <?php
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement