- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentyeleven/inc/theme-options.php
r19580 r20936 32 32 * formatted, and safe. 33 33 * 34 * We also use this function to add our theme option if it doesn't already exist.35 *36 34 * @since Twenty Eleven 1.0 37 35 */ 38 36 function twentyeleven_theme_options_init() { 39 40 // If we have no options in the database, let's add them now.41 if ( false === twentyeleven_get_theme_options() )42 add_option( 'twentyeleven_theme_options', twentyeleven_get_default_theme_options() );43 37 44 38 register_setting( … … 315 309 <div class="wrap"> 316 310 <?php screen_icon(); ?> 317 <h2><?php printf( __( '%s Theme Options', 'twentyeleven' ), get_current_theme() ); ?></h2> 311 <?php $theme_name = function_exists( 'wp_get_theme' ) ? wp_get_theme() : get_current_theme(); ?> 312 <h2><?php printf( __( '%s Theme Options', 'twentyeleven' ), $theme_name ); ?></h2> 318 313 <?php settings_errors(); ?> 319 314 … … 448 443 } 449 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' => 'sanitize_hex_color', 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 * Bind JS handlers to make Theme Customizer preview reload changes asynchronously. 524 * Used with blogname and blogdescription. 525 * 526 * @since Twenty Eleven 1.3 527 */ 528 function twentyeleven_customize_preview_js() { 529 wp_enqueue_script( 'twentyeleven-customizer', get_template_directory_uri() . '/inc/theme-customizer.js', array( 'customize-preview' ), '20120523', true ); 530 } 531 add_action( 'customize_preview_init', 'twentyeleven_customize_preview_js' );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)