Make WordPress Core

Ticket #21483: media-controls-test.php

File media-controls-test.php, 1.2 KB (added by celloexpressions, 9 years ago)

Test plugin with an upload control and an image control, spitting the values out into the preview.

Line 
1<?php
2/*
3 * Plugin Name: Customize Media Controls Test
4 */
5
6function nhcx_test_customize_media_register( $wp_customize ) {
7        $wp_customize->add_section( 'media', array( 'title' => 'Media Controls', 'priority' => 0, ) );
8        $wp_customize->add_setting( 'upload_control', array() );
9        $wp_customize->add_control( new WP_Customize_Upload_Control( $wp_customize, 'upload_control', array(
10                'label' => 'Upload Control',
11                'section' => 'media',
12                'priority' => 1,
13        ) ) );
14        $wp_customize->add_setting( 'image_control', array() );
15        $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'image_control', array(
16                'label' => 'Image Control',
17                'section' => 'media',
18                'priority' => 2,
19        ) ) );
20}
21add_action( 'customize_register', 'nhcx_test_customize_media_register' );
22
23add_action( 'wp_footer', 'nhcx_test_customize_media_output' );
24function nhcx_test_customize_media_output() {
25        if ( is_customize_preview() ) {
26                echo '<img src="' . get_theme_mod( 'upload_control', '' ) . '" style="width: 500px;position: fixed; top: 0; left: 0; z-index: 999;">';
27                echo '<img src="' . get_theme_mod( 'image_control', '' ) . '" style="width: 500px;position: fixed; top: 0; left: 500px; z-index: 999;">';
28        }
29}