Changeset 20248 for trunk/wp-includes/class-wp-customize.php
- Timestamp:
- 03/21/2012 10:55:43 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/class-wp-customize.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-customize.php
r20212 r20248 30 30 add_action( 'admin_footer', array( $this, 'admin_footer' ) ); 31 31 32 add_action( 'customize_previewing', array( $this, 'customize_previewing' ) ); 33 add_action( 'customize_register', array( $this, 'register_controls' ) ); 34 add_action( 'customize_controls_init', array( $this, 'prepare_controls' ) ); 32 add_action( 'customize_previewing', array( $this, 'customize_previewing' ) ); 33 add_action( 'customize_register', array( $this, 'register_controls' ) ); 34 add_action( 'customize_controls_init', array( $this, 'prepare_controls' ) ); 35 add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ) ); 35 36 } 36 37 … … 103 104 do_action( 'customize_register' ); 104 105 105 if ( ! $this->is_preview() ) 106 return; 106 if ( $this->is_preview() ) 107 add_action( 'template_redirect', array( $this, 'customize_preview_init' ) ); 108 } 109 110 /** 111 * Print javascript settings. 112 * 113 * @since 3.4.0 114 */ 115 public function customize_preview_init() { 116 $this->prepare_controls(); 107 117 108 118 wp_enqueue_script( 'customize-preview' ); … … 112 122 $setting->preview(); 113 123 } 114 } 124 125 do_action( 'customize_preview_init' ); 126 } 127 115 128 116 129 /** … … 350 363 */ 351 364 public function add_setting( $id, $args = array() ) { 352 $setting = new WP_Customize_Setting( $ id, $args );365 $setting = new WP_Customize_Setting( $this, $id, $args ); 353 366 354 367 $this->settings[ $setting->id ] = $setting; … … 388 401 */ 389 402 public function add_section( $id, $args = array() ) { 390 $section = new WP_Customize_Section( $ id, $args );403 $section = new WP_Customize_Section( $this, $id, $args ); 391 404 392 405 $this->sections[ $section->id ] = $section; … … 425 438 * @param object $b Object B. 426 439 */ 427 protected f unction _cmp_priority( $a, $b ) {440 protected final function _cmp_priority( $a, $b ) { 428 441 $ap = $a->priority; 429 442 $bp = $b->priority; … … 435 448 436 449 /** 437 * Prepare settings and sections. Also enqueue needed scripts/styles.450 * Prepare settings and sections. 438 451 * 439 452 * @since 3.4.0 440 453 */ 441 454 public function prepare_controls() { 455 // Prepare settings 442 456 // Reversing makes uasort sort by time added when conflicts occur. 443 457 458 $this->settings = array_reverse( $this->settings ); 459 $settings = array(); 460 461 foreach ( $this->settings as $id => $setting ) { 462 if ( ! isset( $this->sections[ $setting->section ] ) || ! $setting->check_capabilities() ) 463 continue; 464 465 $this->sections[ $setting->section ]->settings[] = $setting; 466 $settings[ $id ] = $setting; 467 } 468 $this->settings = $settings; 469 470 // Prepare sections 444 471 $this->sections = array_reverse( $this->sections ); 445 472 uasort( $this->sections, array( $this, '_cmp_priority' ) ); 446 447 $this->settings = array_reverse( $this->settings ); 473 $sections = array(); 474 475 foreach ( $this->sections as $section ) { 476 if ( ! $section->check_capabilities() ) 477 continue; 478 479 usort( $section->settings, array( $this, '_cmp_priority' ) ); 480 $sections[] = $section; 481 } 482 $this->sections = $sections; 483 } 484 485 /** 486 * Enqueue scripts for customize controls. 487 * 488 * @since 3.4.0 489 */ 490 public function enqueue_control_scripts() { 448 491 foreach ( $this->settings as $setting ) { 449 if ( ! isset( $this->sections[ $setting->section ] ) ) 450 continue; 451 452 $this->sections[ $setting->section ]->settings[] = $setting; 453 454 if ( $setting->check_capabilities() ) 455 $setting->enqueue(); 456 } 457 458 foreach ( $this->sections as $section ) { 459 usort( $section->settings, array( $this, '_cmp_priority' ) ); 492 $setting->enqueue(); 460 493 } 461 494 } … … 480 513 'sanitize_callback' => 'sanitize_hexcolor', 481 514 'control' => 'color', 515 'theme_supports' => array( 'custom-header', 'header-text' ), 482 516 'default' => get_theme_support( 'custom-header', 'default-text-color' ), 483 517 ) );
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)