wp/wp-includes/customize/class-wp-customize-upload-control.php
changeset 7 cf61fcea0001
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
       
     1 <?php
       
     2 /**
       
     3  * Customize API: WP_Customize_Upload_Control class
       
     4  *
       
     5  * @package WordPress
       
     6  * @subpackage Customize
       
     7  * @since 4.4.0
       
     8  */
       
     9 
       
    10 /**
       
    11  * Customize Upload Control Class.
       
    12  *
       
    13  * @since 3.4.0
       
    14  *
       
    15  * @see WP_Customize_Media_Control
       
    16  */
       
    17 class WP_Customize_Upload_Control extends WP_Customize_Media_Control {
       
    18 	public $type          = 'upload';
       
    19 	public $mime_type     = '';
       
    20 	public $button_labels = array();
       
    21 	public $removed = ''; // unused
       
    22 	public $context; // unused
       
    23 	public $extensions = array(); // unused
       
    24 
       
    25 	/**
       
    26 	 * Refresh the parameters passed to the JavaScript via JSON.
       
    27 	 *
       
    28 	 * @since 3.4.0
       
    29 	 *
       
    30 	 * @uses WP_Customize_Media_Control::to_json()
       
    31 	 */
       
    32 	public function to_json() {
       
    33 		parent::to_json();
       
    34 
       
    35 		$value = $this->value();
       
    36 		if ( $value ) {
       
    37 			// Get the attachment model for the existing file.
       
    38 			$attachment_id = attachment_url_to_postid( $value );
       
    39 			if ( $attachment_id ) {
       
    40 				$this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id );
       
    41 			}
       
    42 		}
       
    43 	}
       
    44 }