Ticket #29215: 29215.diff
File 29215.diff, 9.1 KB (added by , 10 years ago) |
---|
-
src/wp-admin/css/customize-controls.css
577 577 -webkit-overflow-scrolling: touch; 578 578 } 579 579 580 /** Header control**/580 /** Media controls **/ 581 581 582 .customize-control-media .current, 582 583 .customize-control-upload .current, 583 584 .customize-control-image .current, 584 585 .customize-control-background .current, … … 605 606 display: block; 606 607 } 607 608 609 .customize-control-media .remove-button, 610 .customize-control-media .default-button, 611 .customize-control-media .upload-button, 608 612 .customize-control-upload .remove-button, 609 613 .customize-control-upload .default-button, 610 614 .customize-control-upload .upload-button, … … 621 625 height: auto; 622 626 } 623 627 628 .customize-control-media .current .container, 624 629 .customize-control-upload .current .container, 625 630 .customize-control-image .current .container, 626 631 .customize-control-background .current .container, … … 632 637 border-radius: 2px; 633 638 } 634 639 640 .customize-control-media .current .container, 635 641 .customize-control-upload .current .container, 636 642 .customize-control-background .current .container, 637 643 .customize-control-image .current .container { … … 638 644 min-height: 40px; 639 645 } 640 646 647 .customize-control-media .placeholder, 641 648 .customize-control-upload .placeholder, 642 649 .customize-control-image .placeholder, 643 650 .customize-control-background .placeholder, … … 648 655 cursor: default; 649 656 } 650 657 658 .customize-control-media .inner, 651 659 .customize-control-upload .inner, 652 660 .customize-control-image .inner, 653 661 .customize-control-background .inner, … … 661 669 overflow: hidden; 662 670 } 663 671 672 .customize-control-media .inner, 664 673 .customize-control-upload .inner, 665 674 .customize-control-background .inner, 666 675 .customize-control-image .inner { … … 668 677 min-height: 40px; 669 678 } 670 679 680 .customize-control-media .inner, 671 681 .customize-control-upload .inner, 672 682 .customize-control-image .inner, 673 683 .customize-control-background .inner, … … 785 795 100% { color: #d4b146; } 786 796 } 787 797 798 .customize-control-medua .actions, 788 799 .customize-control-upload .actions, 789 800 .customize-control-image .actions, 790 801 .customize-control-background .actions, … … 802 813 margin-bottom: 0; 803 814 } 804 815 816 .customize-control-media img, 805 817 .customize-control-upload img, 806 818 .customize-control-image img, 807 819 .customize-control-background img, … … 811 823 border-radius: 2px; 812 824 } 813 825 826 .customize-control-media .remove-button, 827 .customize-control-media .default-button, 814 828 .customize-control-upload .remove-button, 815 829 .customize-control-upload .default-button, 816 830 .customize-control-image .remove-button, … … 822 836 margin-right: 3px; 823 837 } 824 838 839 .customize-control-media .upload-button, 825 840 .customize-control-upload .upload-button, 826 841 .customize-control-image .upload-button, 827 842 .customize-control-background .upload-button, -
src/wp-admin/js/customize-controls.js
1011 1011 }); 1012 1012 1013 1013 /** 1014 * A n upload control, which utilizes the media modal.1014 * A control that implements the media modal. 1015 1015 * 1016 1016 * @class 1017 1017 * @augments wp.customize.Control 1018 1018 * @augments wp.customize.Class 1019 1019 */ 1020 api. UploadControl = api.Control.extend({1020 api.MediaControl = api.Control.extend({ 1021 1021 1022 1022 /** 1023 1023 * When the control's DOM structure is ready, … … 1088 1088 this.params.attachment = attachment; 1089 1089 1090 1090 // Set the Customizer setting; the callback takes care of rendering. 1091 this.setting( attachment. url);1091 this.setting( attachment.id ); 1092 1092 }, 1093 1093 1094 1094 /** … … 1118 1118 this.params.attachment = {}; 1119 1119 this.setting( '' ); 1120 1120 this.renderContent(); // Not bound to setting change when emptying. 1121 } 1122 }); 1123 1124 /** 1125 * An upload control, which utilizes the media modal. 1126 * 1127 * @class 1128 * @augments wp.customize.MediaControl 1129 * @augments wp.customize.Control 1130 * @augments wp.customize.Class 1131 */ 1132 api.UploadControl = api.MediaControl.extend({ 1133 1134 /** 1135 * Callback handler for when an attachment is selected in the media modal. 1136 * Gets the selected image information, and sets it within the control. 1137 */ 1138 select: function() { 1139 // Get the attachment from the modal frame. 1140 var attachment = this.frame.state().get( 'selection' ).first().toJSON(); 1141 1142 this.params.attachment = attachment; 1143 1144 // Set the Customizer setting; the callback takes care of rendering. 1145 this.setting( attachment.url ); 1121 1146 }, 1122 1147 1123 1148 // @deprecated … … 1124 1149 success: function() {}, 1125 1150 1126 1151 // @deprecated 1127 removerVisibility: function() {} 1152 removerVisibility: function() {} 1128 1153 }); 1129 1154 1155 1130 1156 /** 1131 1157 * A control for uploading images. 1132 1158 * … … 1135 1161 * 1136 1162 * @class 1137 1163 * @augments wp.customize.UploadControl 1164 * @augments wp.customize.MediaControl 1138 1165 * @augments wp.customize.Control 1139 1166 * @augments wp.customize.Class 1140 1167 */ … … 1148 1175 * 1149 1176 * @class 1150 1177 * @augments wp.customize.UploadControl 1178 * @augments wp.customize.MediaControl 1151 1179 * @augments wp.customize.Control 1152 1180 * @augments wp.customize.Class 1153 1181 */ … … 1854 1882 1855 1883 api.controlConstructor = { 1856 1884 color: api.ColorControl, 1885 media: api.MediaControl, 1857 1886 upload: api.UploadControl, 1858 1887 image: api.ImageControl, 1859 1888 header: api.HeaderControl, -
src/wp-includes/class-wp-customize-control.php
632 632 } 633 633 634 634 /** 635 * Customize UploadControl Class635 * Customize Media Control Class 636 636 * 637 637 * @package WordPress 638 638 * @subpackage Customize 639 * @since 3.4.0639 * @since 4.2.0 640 640 */ 641 class WP_Customize_ Upload_Control extends WP_Customize_Control {642 public $type = ' upload';641 class WP_Customize_Media_Control extends WP_Customize_Control { 642 public $type = 'media'; 643 643 public $mime_type = ''; 644 644 public $button_labels = array(); 645 public $removed = ''; // unused646 public $context; // unused647 public $extensions = array(); // unused648 645 649 646 /** 650 647 * Constructor. … … 692 689 if ( is_object( $this->setting ) ) { 693 690 if ( $this->setting->default ) { 694 691 // Fake an attachment model - needs all fields used by template. 692 // Note that the default value must be a URL, NOT an attachment ID. 695 693 $type = in_array( substr( $this->setting->default, -3 ), array( 'jpg', 'png', 'gif', 'bmp' ) ) ? 'image' : 'document'; 696 694 $default_attachment = array( 697 695 'id' => 1, … … 714 712 // Set the default as the attachment. 715 713 $this->json['attachment'] = $this->json['defaultAttachment']; 716 714 } elseif ( $value ) { 717 // Get the attachment model for the existing file. 718 $attachment_id = attachment_url_to_postid( $value ); 719 if ( $attachment_id ) { 720 $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id ); 721 } 715 $this->json['attachment'] = wp_prepare_attachment_for_js( $value ); 722 716 } 723 717 } 724 718 } … … 726 720 /** 727 721 * Don't render any content for this control from PHP. 728 722 * 729 * @see WP_Customize_ Upload_Control::content_template()723 * @see WP_Customize_Media_Control::content_template() 730 724 * @since 3.4.0 731 725 */ 732 726 public function render_content() {} 733 727 734 728 /** 735 * Render a JS template for the content of the uploadcontrol.729 * Render a JS template for the content of the media control. 736 730 * 737 731 * @since 4.1.0 738 732 */ … … 803 797 } 804 798 805 799 /** 800 * Customize Upload Control Class 801 * 802 * @package WordPress 803 * @subpackage Customize 804 * @since 3.4.0 805 */ 806 class WP_Customize_Upload_Control extends WP_Customize_Media_Control { 807 public $type = 'upload'; 808 public $mime_type = ''; 809 public $button_labels = array(); 810 public $removed = ''; // unused 811 public $context; // unused 812 public $extensions = array(); // unused 813 814 /** 815 * Refresh the parameters passed to the JavaScript via JSON. 816 * 817 * @since 3.4.0 818 * @uses WP_Customize_Control::to_json() 819 */ 820 public function to_json() { 821 parent::to_json(); 822 823 $value = $this->value(); 824 if ( $value ) { 825 // Get the attachment model for the existing file. 826 $attachment_id = attachment_url_to_postid( $value ); 827 if ( $attachment_id ) { 828 $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id ); 829 } 830 } 831 } 832 } 833 834 /** 806 835 * Customize Image Control Class 807 836 * 808 837 * @package WordPress -
src/wp-includes/class-wp-customize-manager.php
988 988 989 989 /* Control Types (custom control classes) */ 990 990 $this->register_control_type( 'WP_Customize_Color_Control' ); 991 $this->register_control_type( 'WP_Customize_Media_Control' ); 991 992 $this->register_control_type( 'WP_Customize_Upload_Control' ); 992 993 $this->register_control_type( 'WP_Customize_Image_Control' ); 993 994 $this->register_control_type( 'WP_Customize_Background_Image_Control' );