home *** CD-ROM | disk | FTP | other *** search
/ HTML Examples / WP.iso / wordpress / wp-includes / customize / class-wp-customize-upload-control.php < prev    next >
Encoding:
PHP Script  |  2015-10-24  |  977 b   |  45 lines

  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. }
  45.