Ticket #29215: 29215.2.patch
File 29215.2.patch, 10.9 KB (added by , 10 years ago) |
---|
-
src/wp-admin/css/customize-controls.css
582 582 -webkit-overflow-scrolling: touch; 583 583 } 584 584 585 /** Header control**/585 /** Media controls **/ 586 586 587 .customize-control-media .current, 587 588 .customize-control-upload .current, 588 589 .customize-control-image .current, 589 590 .customize-control-background .current, … … 610 611 display: block; 611 612 } 612 613 614 .customize-control-media .remove-button, 615 .customize-control-media .default-button, 616 .customize-control-media .upload-button, 613 617 .customize-control-upload .remove-button, 614 618 .customize-control-upload .default-button, 615 619 .customize-control-upload .upload-button, … … 626 630 height: auto; 627 631 } 628 632 633 .customize-control-media .current .container, 629 634 .customize-control-upload .current .container, 630 635 .customize-control-image .current .container, 631 636 .customize-control-background .current .container, … … 637 642 border-radius: 2px; 638 643 } 639 644 645 .customize-control-media .current .container, 640 646 .customize-control-upload .current .container, 641 647 .customize-control-background .current .container, 642 648 .customize-control-image .current .container { 643 649 min-height: 40px; 644 650 } 645 651 652 .customize-control-media .placeholder, 646 653 .customize-control-upload .placeholder, 647 654 .customize-control-image .placeholder, 648 655 .customize-control-background .placeholder, … … 653 660 cursor: default; 654 661 } 655 662 663 .customize-control-media .inner, 656 664 .customize-control-upload .inner, 657 665 .customize-control-image .inner, 658 666 .customize-control-background .inner, … … 666 674 overflow: hidden; 667 675 } 668 676 677 .customize-control-media .inner, 669 678 .customize-control-upload .inner, 670 679 .customize-control-background .inner, 671 680 .customize-control-image .inner { … … 673 682 min-height: 40px; 674 683 } 675 684 685 .customize-control-media .inner, 676 686 .customize-control-upload .inner, 677 687 .customize-control-image .inner, 678 688 .customize-control-background .inner, … … 782 792 100% { color: #d4b146; } 783 793 } 784 794 795 .customize-control-media .actions, 785 796 .customize-control-upload .actions, 786 797 .customize-control-image .actions, 787 798 .customize-control-background .actions, … … 799 810 margin-bottom: 0; 800 811 } 801 812 813 .customize-control-media img, 802 814 .customize-control-upload img, 803 815 .customize-control-image img, 804 816 .customize-control-background img, … … 808 820 border-radius: 2px; 809 821 } 810 822 823 .customize-control-media .remove-button, 824 .customize-control-media .default-button, 811 825 .customize-control-upload .remove-button, 812 826 .customize-control-upload .default-button, 813 827 .customize-control-image .remove-button, … … 819 833 margin-right: 3px; 820 834 } 821 835 836 .customize-control-media .upload-button, 822 837 .customize-control-upload .upload-button, 823 838 .customize-control-image .upload-button, 824 839 .customize-control-background .upload-button, -
src/wp-admin/js/customize-controls.js
1370 1370 }); 1371 1371 1372 1372 /** 1373 * A n upload control, which utilizes the media modal.1373 * A control that implements the media modal. 1374 1374 * 1375 1375 * @class 1376 1376 * @augments wp.customize.Control 1377 1377 * @augments wp.customize.Class 1378 1378 */ 1379 api. UploadControl = api.Control.extend({1379 api.MediaControl = api.Control.extend({ 1380 1380 1381 1381 /** 1382 1382 * When the control's DOM structure is ready, … … 1471 1471 this.params.attachment = attachment; 1472 1472 1473 1473 // Set the Customizer setting; the callback takes care of rendering. 1474 this.setting( attachment. url);1474 this.setting( attachment.id ); 1475 1475 node = this.container.find( 'audio, video' ).get(0); 1476 1476 1477 1477 // Initialize audio/video previews. … … 1509 1509 this.params.attachment = {}; 1510 1510 this.setting( '' ); 1511 1511 this.renderContent(); // Not bound to setting change when emptying. 1512 } 1513 }); 1514 1515 /** 1516 * An upload control, which utilizes the media modal. 1517 * 1518 * @class 1519 * @augments wp.customize.MediaControl 1520 * @augments wp.customize.Control 1521 * @augments wp.customize.Class 1522 */ 1523 api.UploadControl = api.MediaControl.extend({ 1524 1525 /** 1526 * Callback handler for when an attachment is selected in the media modal. 1527 * Gets the selected image information, and sets it within the control. 1528 */ 1529 select: function() { 1530 // Get the attachment from the modal frame. 1531 var node, 1532 attachment = this.frame.state().get( 'selection' ).first().toJSON(), 1533 mejsSettings = window._wpmejsSettings || {}; 1534 1535 this.params.attachment = attachment; 1536 1537 // Set the Customizer setting; the callback takes care of rendering. 1538 this.setting( attachment.url ); 1539 node = this.container.find( 'audio, video' ).get(0); 1540 1541 // Initialize audio/video previews. 1542 if ( node ) { 1543 this.player = new MediaElementPlayer( node, mejsSettings ); 1544 } else { 1545 this.cleanupPlayer(); 1546 } 1512 1547 }, 1513 1548 1514 1549 // @deprecated … … 1526 1561 * 1527 1562 * @class 1528 1563 * @augments wp.customize.UploadControl 1564 * @augments wp.customize.MediaControl 1529 1565 * @augments wp.customize.Control 1530 1566 * @augments wp.customize.Class 1531 1567 */ … … 1539 1575 * 1540 1576 * @class 1541 1577 * @augments wp.customize.UploadControl 1578 * @augments wp.customize.MediaControl 1542 1579 * @augments wp.customize.Control 1543 1580 * @augments wp.customize.Class 1544 1581 */ … … 1575 1612 */ 1576 1613 api.HeaderControl = api.Control.extend({ 1577 1614 ready: function() { 1578 this.btnRemove 1579 this.btnNew 1615 this.btnRemove = $('#customize-control-header_image .actions .remove'); 1616 this.btnNew = $('#customize-control-header_image .actions .new'); 1580 1617 1581 1618 _.bindAll(this, 'openMedia', 'removeImage'); 1582 1619 … … 2311 2348 2312 2349 api.controlConstructor = { 2313 2350 color: api.ColorControl, 2351 media: api.MediaControl, 2314 2352 upload: api.UploadControl, 2315 2353 image: api.ImageControl, 2316 2354 header: api.HeaderControl, -
src/wp-includes/class-wp-customize-control.php
521 521 * @since 4.1.0 522 522 */ 523 523 final public function print_template() { 524 525 526 527 528 524 ?> 525 <script type="text/html" id="tmpl-customize-control-<?php echo $this->type; ?>-content"> 526 <?php $this->content_template(); ?> 527 </script> 528 <?php 529 529 } 530 530 531 531 /** … … 638 638 } 639 639 640 640 /** 641 * Customize UploadControl class.641 * Customize Media Control class. 642 642 * 643 * @since 3.4.0643 * @since 4.2.0 644 644 * 645 645 * @see WP_Customize_Control 646 646 */ 647 class WP_Customize_ Upload_Control extends WP_Customize_Control {648 public $type = ' upload';647 class WP_Customize_Media_Control extends WP_Customize_Control { 648 public $type = 'media'; 649 649 public $mime_type = ''; 650 650 public $button_labels = array(); 651 public $removed = ''; // unused652 public $context; // unused653 public $extensions = array(); // unused654 651 655 652 /** 656 653 * Constructor. 657 654 * 658 655 * @since 4.1.0 656 * @since 4.2.0 Moved from WP_Customize_Upload_Control. 659 657 * 660 658 * @param WP_Customize_Manager $manager {@see WP_Customize_Manager} instance. 661 659 */ … … 677 675 * Enqueue control related scripts/styles. 678 676 * 679 677 * @since 3.4.0 678 * @since 4.2.0 Moved from WP_Customize_Upload_Control. 680 679 */ 681 680 public function enqueue() { 682 681 wp_enqueue_media(); … … 686 685 * Refresh the parameters passed to the JavaScript via JSON. 687 686 * 688 687 * @since 3.4.0 688 * @since 4.2.0 Moved from WP_Customize_Upload_Control. 689 * 689 690 * @uses WP_Customize_Control::to_json() 690 691 */ 691 692 public function to_json() { … … 698 699 if ( is_object( $this->setting ) ) { 699 700 if ( $this->setting->default ) { 700 701 // Fake an attachment model - needs all fields used by template. 702 // Note that the default value must be a URL, NOT an attachment ID. 701 703 $type = in_array( substr( $this->setting->default, -3 ), array( 'jpg', 'png', 'gif', 'bmp' ) ) ? 'image' : 'document'; 702 704 $default_attachment = array( 703 705 'id' => 1, … … 720 722 // Set the default as the attachment. 721 723 $this->json['attachment'] = $this->json['defaultAttachment']; 722 724 } elseif ( $value ) { 723 // Get the attachment model for the existing file. 724 $attachment_id = attachment_url_to_postid( $value ); 725 if ( $attachment_id ) { 726 $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id ); 727 } 725 $this->json['attachment'] = wp_prepare_attachment_for_js( $value ); 728 726 } 729 727 } 730 728 } … … 732 730 /** 733 731 * Don't render any content for this control from PHP. 734 732 * 735 * @see WP_Customize_Upload_Control::content_template()736 733 * @since 3.4.0 734 * @since 4.2.0 Moved from WP_Customize_Upload_Control. 735 * 736 * @see WP_Customize_Media_Control::content_template() 737 737 */ 738 738 public function render_content() {} 739 739 740 740 /** 741 * Render a JS template for the content of the uploadcontrol.741 * Render a JS template for the content of the media control. 742 742 * 743 743 * @since 4.1.0 744 * @since 4.2.0 Moved from WP_Customize_Upload_Control. 744 745 */ 745 746 public function content_template() { 746 747 ?> … … 823 824 } 824 825 825 826 /** 827 * Customize Upload Control Class. 828 * 829 * @since 3.4.0 830 * 831 * @see WP_Customize_Media_Control 832 */ 833 class WP_Customize_Upload_Control extends WP_Customize_Media_Control { 834 public $type = 'upload'; 835 public $mime_type = ''; 836 public $button_labels = array(); 837 public $removed = ''; // unused 838 public $context; // unused 839 public $extensions = array(); // unused 840 841 /** 842 * Refresh the parameters passed to the JavaScript via JSON. 843 * 844 * @since 3.4.0 845 * 846 * @uses WP_Customize_Media_Control::to_json() 847 */ 848 public function to_json() { 849 parent::to_json(); 850 851 $value = $this->value(); 852 if ( $value ) { 853 // Get the attachment model for the existing file. 854 $attachment_id = attachment_url_to_postid( $value ); 855 if ( $attachment_id ) { 856 $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id ); 857 } 858 } 859 } 860 } 861 862 /** 826 863 * Customize Image Control class. 827 864 * 828 865 * @since 3.4.0 -
src/wp-includes/class-wp-customize-manager.php
1139 1139 1140 1140 /* Control Types (custom control classes) */ 1141 1141 $this->register_control_type( 'WP_Customize_Color_Control' ); 1142 $this->register_control_type( 'WP_Customize_Media_Control' ); 1142 1143 $this->register_control_type( 'WP_Customize_Upload_Control' ); 1143 1144 $this->register_control_type( 'WP_Customize_Image_Control' ); 1144 1145 $this->register_control_type( 'WP_Customize_Background_Image_Control' );