Ticket #21303: diff3.patch
File diff3.patch, 19.5 KB (added by , 12 years ago) |
---|
-
wp-includes/class-wp-customize-section.php
1 1 <?php 2 2 /** 3 * Customize Section Class 3 * Customize Section Class. 4 4 * 5 5 * @package WordPress 6 6 * @subpackage Customize 7 7 * @since 3.4.0 8 8 */ 9 10 9 class WP_Customize_Section { 11 10 public $manager; 12 11 public $id; … … 22 21 * 23 22 * @since 3.4.0 24 23 * 24 * @param WP_Customize_Manager $manager 25 25 * @param string $id An specific ID of the section. 26 26 * @param array $args Section arguments. 27 27 */ … … 72 72 $this->render(); 73 73 } 74 74 75 76 75 /** 77 76 * Render the section. 78 77 * -
wp-includes/class-wp-customize-manager.php
1 1 <?php 2 2 /** 3 * Customize 3 * Customize Manager. 4 4 * 5 5 * @package WordPress 6 6 * @subpackage Customize 7 7 * @since 3.4.0 8 8 */ 9 10 9 final class WP_Customize_Manager { 11 10 protected $theme; 12 11 protected $original_stylesheet; … … 56 55 add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ) ); 57 56 } 58 57 59 58 /** 60 59 * Return true if it's an AJAX request. 61 60 * 62 61 * @since 3.4.0 62 * 63 * @return bool 63 64 */ 64 65 public function doing_ajax() { 65 66 return isset( $_POST['customized'] ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ); … … 69 70 * Custom wp_die wrapper. Returns either the standard message for UI 70 71 * or the AJAX message. 71 72 * 72 * @param mixed $ajax_message AJAX return 73 * @param mixed $message UI message 73 * @since 3.4.0 74 74 * 75 * @since 3.4.0 75 * @param mixed $ajax_message AJAX return 76 * @param mixed $message UI message 76 77 */ 77 78 protected function wp_die( $ajax_message, $message = null ) { 78 79 if ( $this->doing_ajax() ) … … 88 89 * Return the AJAX wp_die() handler if it's a customized request. 89 90 * 90 91 * @since 3.4.0 92 * 93 * @return string 91 94 */ 92 95 public function wp_die_handler() { 93 96 if ( $this->doing_ajax() ) … … 95 98 96 99 return '_default_wp_die_handler'; 97 100 } 101 98 102 /** 99 * Start preview and customize theme. 100 * 101 * Check if customize query variable exist. Init filters to filter the current theme. 103 * Start preview and customize theme. 102 104 * 105 * Check if customize query variable exist. Init filters to filter the current theme. 106 * 103 107 * @since 3.4.0 104 108 */ 105 109 public function setup_theme() { … … 136 140 137 141 $this->start_previewing_theme(); 138 142 } 139 143 144 /** 145 * Callback to validate a theme once it is loaded 146 * 147 * @since 3.4.0 148 */ 140 149 function after_setup_theme() { 141 150 if ( ! $this->doing_ajax() && ! validate_current_theme() ) { 142 151 wp_redirect( 'themes.php?broken=true' ); … … 279 288 * Instead, the JS will sniff out the location header. 280 289 * 281 290 * @since 3.4.0 291 * 292 * @param $status 293 * @return int 282 294 */ 283 295 public function wp_redirect_status( $status ) { 284 296 if ( $this->is_preview() && ! is_admin() ) … … 291 303 * Decode the $_POST attribute used to override the WP_Customize_Setting values. 292 304 * 293 305 * @since 3.4.0 306 * 307 * @param mixed $setting A WP_Customize_Setting derived object 308 * @return string Sanitized attribute 294 309 */ 295 310 public function post_value( $setting ) { 296 311 if ( ! isset( $this->_post_values ) ) { … … 367 382 ); 368 383 369 384 if ( 2 == $this->nonce_tick ) { 370 371 372 373 374 385 $settings['nonce'] = array( 386 'save' => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ), 387 'preview' => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() ) 388 ); 389 } 375 390 376 391 foreach ( $this->settings as $id => $setting ) { 377 392 $settings['values'][ $id ] = $setting->js_value(); … … 464 479 * 465 480 * @since 3.4.0 466 481 * 482 * @param $current_theme {@internal Parameter is not used} 467 483 * @return string Theme name. 468 484 */ 469 485 public function current_theme( $current_theme ) { … … 630 646 * 631 647 * @param object $a Object A. 632 648 * @param object $b Object B. 649 * @return int 633 650 */ 634 651 protected final function _cmp_priority( $a, $b ) { 635 652 $ap = $a->priority; … … 960 977 * Accepts 'blank', and otherwise uses sanitize_hex_color_no_hash(). 961 978 * 962 979 * @since 3.4.0 980 * 981 * @param string $color 982 * @return string 963 983 */ 964 984 public function _sanitize_header_textcolor( $color ) { 965 985 return ( 'blank' === $color ) ? 'blank' : sanitize_hex_color_no_hash( $color ); … … 973 993 * For validating values without a #, see sanitize_hex_color_no_hash(). 974 994 * 975 995 * @since 3.4.0 996 * 997 * @param string $color 998 * @return string|null 976 999 */ 977 1000 function sanitize_hex_color( $color ) { 978 1001 if ( '' === $color ) … … 995 1018 * Returns either '', a 3 or 6 digit hex color (without a #), or null. 996 1019 * 997 1020 * @since 3.4.0 1021 * @uses sanitize_hex_color() 1022 * 1023 * @param string $color 1024 * @return string|null 998 1025 */ 999 1026 function sanitize_hex_color_no_hash( $color ) { 1000 1027 $color = ltrim( $color, '#' ); … … 1012 1039 * This method should only be necessary if using sanitize_hex_color_no_hash(). 1013 1040 * 1014 1041 * @since 3.4.0 1042 * 1043 * @param string $color 1044 * @return string 1015 1045 */ 1016 1046 function maybe_hash_hex_color( $color ) { 1017 1047 if ( $unhashed = sanitize_hex_color_no_hash( $color ) ) -
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(); -
wp-includes/class-wp-customize-setting.php
1 1 <?php 2 2 /** 3 * Customize Setting Class 3 * Customize Setting Class. 4 4 * 5 5 * @package WordPress 6 6 * @subpackage Customize 7 7 * @since 3.4.0 8 8 */ 9 10 9 class WP_Customize_Setting { 11 10 public $manager; 12 11 public $id; … … 28 27 * 29 28 * @since 3.4.0 30 29 * 30 * @param WP_Customize_Manager $manager 31 31 * @param string $id An specific ID of the setting. Can be a 32 32 * theme mod or option name. 33 33 * @param array $args Setting arguments. 34 * @return WP_Customize_Setting 34 35 */ 35 36 function __construct( $manager, $id, $args = array() ) { 36 37 $keys = array_keys( get_class_vars( __CLASS__ ) ); … … 87 88 * Callback function to filter the theme mods and options. 88 89 * 89 90 * @since 3.4.0 91 * @uses WP_Customize_Setting::multidimensional_replace() 90 92 * 91 * @param mixed Old value.93 * @param mixed $original Old value. 92 94 * @return mixed New or old value. 93 95 */ 94 96 public function _preview_filter( $original ) { … … 118 120 * 119 121 * @since 3.4.0 120 122 * 121 * @param $default mixedA default value which is used as a fallback. Default is null.122 * @return mixed Either the default value on failure orsanitized value.123 * @param mixed $default A default value which is used as a fallback. Default is null. 124 * @return mixed The default value on failure, otherwise the sanitized value. 123 125 */ 124 126 public final function post_value( $default = null ) { 125 127 if ( isset( $this->_post_value ) ) … … 138 140 * 139 141 * @since 3.4.0 140 142 * 141 * @param $value mixedThe value to sanitize.143 * @param mixed $value The value to sanitize. 142 144 * @return mixed Null if an input isn't valid, otherwise the sanitized value. 143 145 */ 144 146 public function sanitize( $value ) { … … 151 153 * 152 154 * @since 3.4.0 153 155 * 154 * @param $value mixedThe value to update.156 * @param mixed $value The value to update. 155 157 * @return mixed The result of saving the value. 156 158 */ 157 159 protected function update( $value ) { … … 172 174 * 173 175 * @since 3.4.0 174 176 * 175 * @param $value mixedThe value to update.177 * @param mixed $value The value to update. 176 178 * @return mixed The result of saving the value. 177 179 */ 178 180 protected function _update_theme_mod( $value ) { … … 192 194 * 193 195 * @since 3.4.0 194 196 * 195 * @param $value mixedThe value to update.197 * @param mixed $value The value to update. 196 198 * @return mixed The result of saving the value. 197 199 */ 198 200 protected function _update_option( $value ) { … … 276 278 * @param $root 277 279 * @param $keys 278 280 * @param bool $create Default is false. 279 * @return null|array 281 * @return null|array Keys are 'root', 'node', and 'key'. 280 282 */ 281 283 final protected function multidimensional( &$root, $keys, $create = false ) { 282 284 if ( $create && empty( $root ) ) … … 372 374 * A setting that is used to filter a value, but will not save the results. 373 375 * 374 376 * Results should be properly handled using another setting or callback. 377 * 378 * @package WordPress 379 * @subpackage Customize 380 * @since 3.4.0 375 381 */ 376 382 class WP_Customize_Filter_Setting extends WP_Customize_Setting { 383 384 /** 385 * @since 3.4.0 386 */ 377 387 public function update() {} 378 388 } 379 389 … … 381 391 * A setting that is used to filter a value, but will not save the results. 382 392 * 383 393 * Results should be properly handled using another setting or callback. 394 * 395 * @package WordPress 396 * @subpackage Customize 397 * @since 3.4.0 384 398 */ 385 399 final class WP_Customize_Header_Image_Setting extends WP_Customize_Setting { 386 400 public $id = 'header_image_data'; 387 401 402 /** 403 * @since 3.4.0 404 * 405 * @param $value 406 */ 388 407 public function update( $value ) { 389 408 global $custom_image_header; 390 409 … … 400 419 } 401 420 } 402 421 422 /** 423 * @package WordPress 424 * @subpackage Customize 425 * @since 3.4.0 426 */ 403 427 final class WP_Customize_Background_Image_Setting extends WP_Customize_Setting { 404 428 public $id = 'background_image_thumb'; 405 429 430 /** 431 * @since 3.4.0 432 * @uses remove_theme_mod() 433 * 434 * @param $value 435 */ 406 436 public function update( $value ) { 407 437 remove_theme_mod( 'background_image_thumb' ); 408 438 }