Changeset 31698 for trunk/src/wp-includes/class-wp-customize-control.php
- Timestamp:
- 03/10/2015 06:01:42 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 *
Note: See TracChangeset
for help on using the changeset viewer.