class-wp-customize-upload-control.php 977 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. * Customize Upload Control Class.
  11. *
  12. * @since 3.4.0
  13. *
  14. * @see WP_Customize_Media_Control
  15. */
  16. class WP_Customize_Upload_Control extends WP_Customize_Media_Control {
  17. public $type = 'upload';
  18. public $mime_type = '';
  19. public $button_labels = array();
  20. public $removed = ''; // unused
  21. public $context; // unused
  22. public $extensions = array(); // unused
  23. /**
  24. * Refresh the parameters passed to the JavaScript via JSON.
  25. *
  26. * @since 3.4.0
  27. *
  28. * @uses WP_Customize_Media_Control::to_json()
  29. */
  30. public function to_json() {
  31. parent::to_json();
  32. $value = $this->value();
  33. if ( $value ) {
  34. // Get the attachment model for the existing file.
  35. $attachment_id = attachment_url_to_postid( $value );
  36. if ( $attachment_id ) {
  37. $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id );
  38. }
  39. }
  40. }
  41. }