Changeset 20916
- Timestamp:
- 05/25/2012 09:50:01 PM (12 years ago)
- Location:
- trunk/wp-content/themes/twentyeleven/inc
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentyeleven/inc/theme-options.php
r20875 r20916 443 443 } 444 444 add_filter( 'body_class', 'twentyeleven_layout_classes' ); 445 446 /** 447 * Implements Twenty Eleven theme options into Theme Customizer 448 * 449 * @param $wp_customize Theme Customizer object 450 * @return void 451 * 452 * @since Twenty Eleven 1.3 453 */ 454 function twentyeleven_customize_register( $wp_customize ) { 455 $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; 456 $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; 457 458 $options = twentyeleven_get_theme_options(); 459 $defaults = twentyeleven_get_default_theme_options(); 460 461 $wp_customize->add_setting( 'twentyeleven_theme_options[color_scheme]', array( 462 'default' => $defaults['color_scheme'], 463 'type' => 'option', 464 'capability' => 'edit_theme_options', 465 ) ); 466 467 $schemes = twentyeleven_color_schemes(); 468 $choices = array(); 469 foreach ( $schemes as $scheme ) { 470 $choices[ $scheme['value'] ] = $scheme['label']; 471 } 472 473 $wp_customize->add_control( 'twentyeleven_color_scheme', array( 474 'label' => __( 'Color Scheme', 'twentyeleven' ), 475 'section' => 'colors', 476 'settings' => 'twentyeleven_theme_options[color_scheme]', 477 'type' => 'radio', 478 'choices' => $choices, 479 'priority' => 5, 480 ) ); 481 482 // Link Color (added to Color Scheme section in Theme Customizer) 483 $wp_customize->add_setting( 'twentyeleven_theme_options[link_color]', array( 484 'default' => twentyeleven_get_default_link_color( $options['color_scheme'] ), 485 'type' => 'option', 486 'sanitize_callback' => 'twentyeleven_sanitize_hexcolor', 487 'capability' => 'edit_theme_options', 488 ) ); 489 490 $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array( 491 'label' => __( 'Link Color', 'twentyeleven' ), 492 'section' => 'colors', 493 'settings' => 'twentyeleven_theme_options[link_color]', 494 ) ) ); 495 496 // Default Layout 497 $wp_customize->add_section( 'twentyeleven_layout', array( 498 'title' => __( 'Layout', 'twentyeleven' ), 499 'priority' => 50, 500 ) ); 501 502 $wp_customize->add_setting( 'twentyeleven_theme_options[theme_layout]', array( 503 'type' => 'option', 504 'default' => $defaults['theme_layout'], 505 'sanitize_callback' => 'sanitize_key', 506 ) ); 507 508 $layouts = twentyeleven_layouts(); 509 $choices = array(); 510 foreach ( $layouts as $layout ) { 511 $choices[$layout['value']] = $layout['label']; 512 } 513 514 $wp_customize->add_control( 'twentyeleven_theme_options[theme_layout]', array( 515 'section' => 'twentyeleven_layout', 516 'type' => 'radio', 517 'choices' => $choices, 518 ) ); 519 } 520 add_action( 'customize_register', 'twentyeleven_customize_register' ); 521 522 /** 523 * Sanitize user input hex color value 524 * 525 * @uses sanitize_hexcolor() 526 * @param $color string 527 * @return string sanitized with prefixed # character 528 */ 529 function twentyeleven_sanitize_hexcolor( $color ) { 530 return '#' . sanitize_hexcolor( $color ); 531 } 532 533 /** 534 * Bind JS handlers to make Theme Customizer preview reload changes asynchronously. 535 * Used with blogname and blogdescription. 536 * 537 * @since Twenty Eleven 1.3 538 */ 539 function twentyeleven_customize_preview_js() { 540 wp_enqueue_script( 'twentyeleven-customizer', get_template_directory_uri() . '/inc/theme-customizer.js', array( 'customize-preview' ), '20120523', true ); 541 } 542 add_action( 'customize_preview_init', 'twentyeleven_customize_preview_js' );
Note: See TracChangeset
for help on using the changeset viewer.