Changeset 31698
- Timestamp:
- 03/10/2015 06:01:42 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/customize-controls.css
r31661 r31698 583 583 } 584 584 585 /** Header control **/ 586 585 /** Media controls **/ 586 587 .customize-control-media .current, 587 588 .customize-control-upload .current, 588 589 .customize-control-image .current, … … 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, … … 627 631 } 628 632 633 .customize-control-media .current .container, 629 634 .customize-control-upload .current .container, 630 635 .customize-control-image .current .container, … … 638 643 } 639 644 645 .customize-control-media .current .container, 640 646 .customize-control-upload .current .container, 641 647 .customize-control-background .current .container, … … 644 650 } 645 651 652 .customize-control-media .placeholder, 646 653 .customize-control-upload .placeholder, 647 654 .customize-control-image .placeholder, … … 654 661 } 655 662 663 .customize-control-media .inner, 656 664 .customize-control-upload .inner, 657 665 .customize-control-image .inner, … … 667 675 } 668 676 677 .customize-control-media .inner, 669 678 .customize-control-upload .inner, 670 679 .customize-control-background .inner, … … 674 683 } 675 684 685 .customize-control-media .inner, 676 686 .customize-control-upload .inner, 677 687 .customize-control-image .inner, … … 783 793 } 784 794 795 .customize-control-media .actions, 785 796 .customize-control-upload .actions, 786 797 .customize-control-image .actions, … … 800 811 } 801 812 813 .customize-control-media img, 802 814 .customize-control-upload img, 803 815 .customize-control-image img, … … 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, … … 820 834 } 821 835 836 .customize-control-media .upload-button, 822 837 .customize-control-upload .upload-button, 823 838 .customize-control-image .upload-button, -
trunk/src/wp-admin/js/customize-controls.js
r31697 r31698 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 … … 1377 1377 * @augments wp.customize.Class 1378 1378 */ 1379 api. UploadControl = api.Control.extend({1379 api.MediaControl = api.Control.extend({ 1380 1380 1381 1381 /** … … 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 … … 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 … … 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 … … 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 … … 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'); … … 2312 2349 api.controlConstructor = { 2313 2350 color: api.ColorControl, 2351 media: api.MediaControl, 2314 2352 upload: api.UploadControl, 2315 2353 image: api.ImageControl, -
trunk/src/wp-includes/class-wp-customize-control.php
r31661 r31698 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 … … 639 639 640 640 /** 641 * Customize UploadControl class.642 * 643 * @since 3.4.0641 * Customize Media Control class. 642 * 643 * @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 /** … … 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. … … 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() { … … 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 */ … … 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( … … 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 } … … 733 731 * Don't render any content for this control from PHP. 734 732 * 735 * @see WP_Customize_Upload_Control::content_template() 736 * @since 3.4.0 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() { … … 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 * -
trunk/src/wp-includes/class-wp-customize-manager.php
r31697 r31698 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' );
Note: See TracChangeset
for help on using the changeset viewer.