Ticket #21303: diff2.patch
File diff2.patch, 9.9 KB (added by , 12 years ago) |
---|
-
wp-includes/class-wp-customize-control.php
6 6 * @subpackage Customize 7 7 * @since 3.4.0 8 8 */ 9 10 9 class WP_Customize_Control { 10 /** 11 * @access public 12 * @var WP_Customize_Manager 13 */ 11 14 public $manager; 15 16 /** 17 * @access public 18 * @var string 19 */ 12 20 public $id; 13 21 14 // All settings tied to the control. 22 /** 23 * All settings tied to the control. 24 * 25 * @access public 26 * @var array 27 */ 15 28 public $settings; 16 29 17 // The primary setting for the control (if there is one). 30 /** 31 * The primary setting for the control (if there is one). 32 * 33 * @access public 34 * @var string 35 */ 18 36 public $setting = 'default'; 19 37 38 /** 39 * @access public 40 * @var int 41 */ 20 42 public $priority = 10; 43 44 /** 45 * @access public 46 * @var string 47 */ 21 48 public $section = ''; 49 50 /** 51 * @access public 52 * @var string 53 */ 22 54 public $label = ''; 23 // @todo: remove choices 55 56 /** 57 * @todo: Remove choices 58 * 59 * @access public 60 * @var array 61 */ 24 62 public $choices = array(); 25 63 64 /** 65 * @access public 66 * @var array 67 */ 26 68 public $json = array(); 27 69 70 /** 71 * @access public 72 * @var string 73 */ 28 74 public $type = 'text'; 29 75 30 76 … … 34 80 * If $args['settings'] is not defined, use the $id as the setting ID. 35 81 * 36 82 * @since 3.4.0 83 * 84 * @param WP_Customize_Manager $manager 85 * @param string $id 86 * @param array $args 37 87 */ 38 88 function __construct( $manager, $id, $args = array() ) { 39 89 $keys = array_keys( get_object_vars( $this ) ); … … 75 125 * Grabs the main setting by default. 76 126 * 77 127 * @since 3.4.0 128 * 129 * @param string $setting_key 130 * @return mixed The requested setting's value, if the setting exists. 78 131 */ 79 132 public final function value( $setting_key = 'default' ) { 80 133 if ( isset( $this->settings[ $setting_key ] ) ) … … 119 172 * Check capabilities and render the control. 120 173 * 121 174 * @since 3.4.0 175 * @uses WP_Customize_Control::render() 122 176 */ 123 177 public final function maybe_render() { 124 178 if ( ! $this->check_capabilities() ) … … 143 197 <?php $this->render_content(); ?> 144 198 </li><?php 145 199 } 146 200 201 /** 202 * Get the data link parameter for a setting. 203 * 204 * @since 3.4.0 205 * 206 * @param string $setting_key 207 * @return string Data link parameter, if $setting_key is a valid setting, empty string otherwise. 208 */ 147 209 public function get_link( $setting_key = 'default' ) { 148 210 if ( ! isset( $this->settings[ $setting_key ] ) ) 149 211 return ''; 150 212 151 213 return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"'; 152 214 } 153 215 216 /** 217 * Render the data link parameter for a setting 218 * 219 * @since 3.4.0 220 * @uses WP_Customize_Control::get_link() 221 * 222 * @param string $setting_key 223 */ 154 224 public function link( $setting_key = 'default' ) { 155 225 echo $this->get_link( $setting_key ); 156 226 } … … 238 308 } 239 309 } 240 310 311 /** 312 * Customize Color Control Class 313 * 314 * @package WordPress 315 * @subpackage Customize 316 * @since 3.4.0 317 */ 241 318 class WP_Customize_Color_Control extends WP_Customize_Control { 319 /** 320 * @access public 321 * @var string 322 */ 242 323 public $type = 'color'; 324 325 /** 326 * @access public 327 * @var array 328 */ 243 329 public $statuses; 244 330 331 /** 332 * Constructor. 333 * 334 * If $args['settings'] is not defined, use the $id as the setting ID. 335 * 336 * @since 3.4.0 337 * @uses WP_Customize_Control::__construct() 338 * 339 * @param WP_Customize_Manager $manager 340 * @param string $id 341 * @param array $args 342 */ 245 343 public function __construct( $manager, $id, $args = array() ) { 246 344 $this->statuses = array( '' => __('Default') ); 247 345 parent::__construct( $manager, $id, $args ); 248 346 } 249 347 348 /** 349 * Enqueue control related scripts/styles. 350 * 351 * @since 3.4.0 352 */ 250 353 public function enqueue() { 251 354 wp_enqueue_script( 'farbtastic' ); 252 355 wp_enqueue_style( 'farbtastic' ); 253 356 } 254 357 358 /** 359 * Refresh the parameters passed to the JavaScript via JSON. 360 * 361 * @since 3.4.0 362 * @uses WP_Customize_Control::to_json() 363 */ 255 364 public function to_json() { 256 365 parent::to_json(); 257 366 $this->json['statuses'] = $this->statuses; 258 367 } 259 368 369 /** 370 * Render the control's content. 371 * 372 * @since 3.4.0 373 */ 260 374 public function render_content() { 261 375 ?> 262 376 <label> … … 276 390 } 277 391 } 278 392 393 /** 394 * Customize Upload Control Class 395 * 396 * @package WordPress 397 * @subpackage Customize 398 * @since 3.4.0 399 */ 279 400 class WP_Customize_Upload_Control extends WP_Customize_Control { 280 401 public $type = 'upload'; 281 402 public $removed = ''; 282 403 public $context; 283 404 405 /** 406 * Enqueue control related scripts/styles. 407 * 408 * @since 3.4.0 409 */ 284 410 public function enqueue() { 285 411 wp_enqueue_script( 'wp-plupload' ); 286 412 } 287 413 414 /** 415 * Refresh the parameters passed to the JavaScript via JSON. 416 * 417 * @since 3.4.0 418 * @uses WP_Customize_Control::to_json() 419 */ 288 420 public function to_json() { 289 421 parent::to_json(); 290 422 … … 294 426 $this->json['context'] = $this->context; 295 427 } 296 428 429 /** 430 * Render the control's content. 431 * 432 * @since 3.4.0 433 */ 297 434 public function render_content() { 298 435 ?> 299 436 <label> … … 307 444 } 308 445 } 309 446 447 /** 448 * Customize Image Control Class 449 * 450 * @package WordPress 451 * @subpackage Customize 452 * @since 3.4.0 453 */ 310 454 class WP_Customize_Image_Control extends WP_Customize_Upload_Control { 311 455 public $type = 'image'; 312 456 public $get_url; … … 314 458 315 459 protected $tabs = array(); 316 460 461 /** 462 * Constructor. 463 * 464 * If $args['settings'] is not defined, use the $id as the setting ID. 465 * 466 * @since 3.4.0 467 * @uses WP_Customize_Upload_Control::__construct() 468 * 469 * @param WP_Customize_Manager $manager 470 * @param string $id 471 * @param array $args 472 */ 317 473 public function __construct( $manager, $id, $args ) { 318 474 $this->statuses = array( '' => __('No Image') ); 319 475 … … 323 479 $this->add_tab( 'uploaded', __('Uploaded'), array( $this, 'tab_uploaded' ) ); 324 480 } 325 481 482 /** 483 * Refresh the parameters passed to the JavaScript via JSON. 484 * 485 * @since 3.4.0 486 * @uses WP_Customize_Upload_Control::to_json() 487 */ 326 488 public function to_json() { 327 489 parent::to_json(); 328 490 $this->json['statuses'] = $this->statuses; 329 491 } 330 492 493 /** 494 * Render the control's content. 495 * 496 * @since 3.4.0 497 */ 331 498 public function render_content() { 332 499 $src = $this->value(); 333 500 if ( isset( $this->get_url ) ) … … 372 539 </div> 373 540 <?php 374 541 } 375 542 543 /** 544 * Add a tab to the control. 545 * 546 * @since 3.4.0 547 * 548 * @param string $id 549 * @param string $label 550 * @param mixed $callback 551 */ 376 552 public function add_tab( $id, $label, $callback ) { 377 553 $this->tabs[ $id ] = array( 378 554 'label' => $label, … … 380 556 ); 381 557 } 382 558 559 /** 560 * Remove a tab from the control. 561 * 562 * @since 3.4.0 563 * 564 * @param string $id 565 */ 383 566 public function remove_tab( $id ) { 384 567 unset( $this->tabs[ $id ] ); 385 568 } 386 569 570 /** 571 * @since 3.4.0 572 */ 387 573 public function tab_upload_new() { 388 574 if ( ! _device_can_upload() ) { 389 575 ?> … … 400 586 <?php 401 587 } 402 588 } 403 589 590 /** 591 * @since 3.4.0 592 */ 404 593 public function tab_uploaded() { 405 594 ?> 406 595 <div class="uploaded-target"></div> 407 596 <?php 408 597 } 409 598 599 /** 600 * @since 3.4.0 601 * 602 * @param string $url 603 * @param string $thumbnail_url 604 */ 410 605 public function print_tab_image( $url, $thumbnail_url = null ) { 411 606 $url = set_url_scheme( $url ); 412 607 $thumbnail_url = ( $thumbnail_url ) ? set_url_scheme( $thumbnail_url ) : $url; … … 418 613 } 419 614 } 420 615 616 /** 617 * Customize Background Image Control Class 618 * 619 * @package WordPress 620 * @subpackage Customize 621 * @since 3.4.0 622 */ 421 623 class WP_Customize_Background_Image_Control extends WP_Customize_Image_Control { 624 625 /** 626 * Constructor. 627 * 628 * @since 3.4.0 629 * @uses WP_Customize_Image_Control::__construct() 630 * 631 * @param WP_Customize_Manager $manager 632 */ 422 633 public function __construct( $manager ) { 423 634 parent::__construct( $manager, 'background_image', array( 424 635 'label' => __( 'Background Image' ), … … 431 642 $this->add_tab( 'default', __('Default'), array( $this, 'tab_default_background' ) ); 432 643 } 433 644 645 /** 646 * @since 3.4.0 647 */ 434 648 public function tab_uploaded() { 435 649 $backgrounds = get_posts( array( 436 650 'post_type' => 'attachment', … … 448 662 foreach ( (array) $backgrounds as $background ) 449 663 $this->print_tab_image( esc_url_raw( $background->guid ) ); 450 664 } 451 665 666 /** 667 * @since 3.4.0 668 * @uses WP_Customize_Image_Control::print_tab_image() 669 */ 452 670 public function tab_default_background() { 453 671 $this->print_tab_image( $this->setting->default ); 454 672 } 455 673 } 456 674 675 /** 676 * Customize Header Image Control Class 677 * 678 * @package WordPress 679 * @subpackage Customize 680 * @since 3.4.0 681 */ 457 682 class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control { 683 684 /** 685 * Constructor. 686 * 687 * @since 3.4.0 688 * @uses WP_Customize_Image_Control::__construct() 689 * @uses WP_Customize_Image_Control::add_tab() 690 * 691 * @param WP_Customize_Manager $manager 692 */ 458 693 public function __construct( $manager ) { 459 694 parent::__construct( $manager, 'header_image', array( 460 695 'label' => __( 'Header Image' ), … … 477 712 $this->add_tab( 'default', __('Default'), array( $this, 'tab_default_headers' ) ); 478 713 } 479 714 715 /** 716 * @since 3.4.0 717 * 718 * @param mixed $choice Which header image to select. (@see Custom_Image_Header::get_header_image() ) 719 * @param array $header 720 */ 480 721 public function print_header_image( $choice, $header ) { 481 722 $header['url'] = set_url_scheme( $header['url'] ); 482 723 $header['thumbnail_url'] = set_url_scheme( $header['thumbnail_url'] ); … … 496 737 </a> 497 738 <?php 498 739 } 499 740 741 /** 742 * @since 3.4.0 743 */ 500 744 public function tab_uploaded() { 501 745 $headers = get_uploaded_header_images(); 502 746 … … 506 750 $this->print_header_image( $choice, $header ); 507 751 } 508 752 753 /** 754 * @since 3.4.0 755 */ 509 756 public function tab_default_headers() { 510 757 global $custom_image_header; 511 758 $custom_image_header->process_default_headers();