Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have modified a customized version of the Upload File control so that I could upload mp4 videos and use the media library. The control seems to be saving the videos as 'Array'. After uploading a video and saving them, I try to get the theme mod assigned to the control, and I just get the string 'Array' back and not the videos URL.

Can anyone see what is going on here?

function wp_customize_video_upload_control($wp_customize) {
     * Video Upload Control
 class Wp_Customize_Video_Upload_Control extends WP_Customize_Control {

    public function __construct( $wp_customize, $control_id, $args = array() ) {

        // declare these first so they can be overridden
        $this->l10n = array(
            'remove' => __( 'Remove Video', 'mwau' ),
            'choose' => __( 'Choose a Video', 'mwau' ),
            'set' =>    __( 'Set as Hero Video', 'mwau' ),
            'upload' => __( 'Pick or Upload Video', 'mwau' )

        parent::__construct( $wp_customize, $control_id, $args );

    // this will be critical for your JS constructor
    public $type = 'advancedUpload';

    // this allows overriding of global labels by a specific control
    public $l10n = array();

    // the type of files that should be allowed by the media modal
    public $mime_type = 'video/mp4';

    public function enqueue() {
        //Register our scripts
        wp_register_style( 'advanced-upload-control', get_stylesheet_directory_uri() . '/css/advanced-upload-control.css' );
        wp_register_script( 'advanced-upload-control', get_stylesheet_directory_uri() . '/js/advanced-upload-control.js', array( 'media-views', 'customize-controls', 'underscore' ), '', true );
        // enqueues all needed media resources
        // Except for its templates - those are attached to hooks that don't exist
        // in the Customizer. Just add once
        if ( ! has_action( 'customize_controls_print_footer_scripts', 'wp_print_media_templates' ) )
            add_action( 'customize_controls_print_footer_scripts', 'wp_print_media_templates' );

        // Finally, ensure our control script and style are enqueued
        wp_enqueue_script( 'advanced-upload-control' );
        wp_enqueue_style( 'advanced-upload-control' );

    public function render_content() {
        // We do this to allow the upload control to specify certain labels
        $l10n = json_encode( $this->l10n );

            '<span class="customize-control-title" data-l10n="%s" data-mime="%s">%s</span>',
            esc_attr( $l10n ),
            esc_attr( $this->mime_type ),
            esc_html( $this->label )
 add_action( 'customize_register', 'wp_customize_video_upload_control', 1, 1 );
share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.