WP_Customize_Upload_Control::to_json() WordPress Method

The WP_Customize_Upload_Control::to_json() method is used to retrieve the JSON representation of a Customizer upload control. This is used to populate the control with data for use in the Customizer preview.

WP_Customize_Upload_Control::to_json() #

Refresh the parameters passed to the JavaScript via JSON.


Source

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

	public function to_json() {
		parent::to_json();

		$value = $this->value();
		if ( $value ) {
			// Get the attachment model for the existing file.
			$attachment_id = attachment_url_to_postid( $value );
			if ( $attachment_id ) {
				$this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id );
			}
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
3.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.