PageRenderTime 26ms CodeModel.GetById 17ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-includes/customize/class-wp-customize-upload-control.php

https://bitbucket.org/skyarch-iijima/wordpress
PHP | 44 lines | 19 code | 3 blank | 22 comment | 2 complexity | 4aeba7d8c346f71e79c5bea97240937b MD5 | raw file
 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 */
17class 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}