wppaste
WordPress

WP_Customize_Media_Control

Since
4.2.0
Source
wp-includes/customize/class-wp-customize-media-control.php:17
Customize Media Control class.

Compatibility

WordPress
since 4.2.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 3

$typestringpublic
Control type.
$mime_typestringpublic
Media control mime type.
$button_labelsarraypublic
Button labels.

Methods · 6

Source code

class WP_Customize_Media_Control extends WP_Customize_Control {	/**	 * Control type.	 *	 * @since 4.2.0	 * @var string	 */	public $type = 'media'; 	/**	 * Media control mime type.	 *	 * @since 4.2.0	 * @var string	 */	public $mime_type = ''; 	/**	 * Button labels.	 *	 * @since 4.2.0	 * @var array	 */	public $button_labels = array(); 	/**	 * Constructor.	 *	 * @since 4.1.0	 * @since 4.2.0 Moved from WP_Customize_Upload_Control.	 *	 * @see WP_Customize_Control::__construct()	 *	 * @param WP_Customize_Manager $manager Customizer bootstrap instance.	 * @param string               $id      Control ID.	 * @param array                $args    Optional. Arguments to override class property defaults.	 *                                      See WP_Customize_Control::__construct() for information	 *                                      on accepted arguments. Default empty array.	 */	public function __construct( $manager, $id, $args = array() ) {		parent::__construct( $manager, $id, $args ); 		$this->button_labels = wp_parse_args( $this->button_labels, $this->get_default_button_labels() );	} 	/**	 * Enqueue control related scripts/styles.	 *	 * @since 3.4.0	 * @since 4.2.0 Moved from WP_Customize_Upload_Control.	 */	public function enqueue() {		wp_enqueue_media();	} 	/**	 * Refresh the parameters passed to the JavaScript via JSON.	 *	 * @since 3.4.0	 * @since 4.2.0 Moved from WP_Customize_Upload_Control.	 *	 * @see WP_Customize_Control::to_json()	 */	public function to_json() {		parent::to_json();		$this->json['label']         = html_entity_decode( $this->label, ENT_QUOTES, get_bloginfo( 'charset' ) );		$this->json['mime_type']     = $this->mime_type;		$this->json['button_labels'] = $this->button_labels;		$this->json['canUpload']     = current_user_can( 'upload_files' ); 		$value = $this->value(); 		if ( is_object( $this->setting ) ) {			if ( $this->setting->default ) {				/*				 * Fake an attachment model - needs all fields used by template.				 * Note that the default value must be a URL, NOT an attachment ID.				 */				$ext       = wp_check_filetype( $this->setting->default )['ext'];				$ext_types = wp_get_ext_types();

Changelog

Introduced in 4.2.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/customize/class-wp-customize-media-control.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.