| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * Plugin Name: Customize Media Controls Test |
|---|
| 4 | */ |
|---|
| 5 | |
|---|
| 6 | function 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 | } |
|---|
| 21 | add_action( 'customize_register', 'nhcx_test_customize_media_register' ); |
|---|
| 22 | |
|---|
| 23 | add_action( 'wp_footer', 'nhcx_test_customize_media_output' ); |
|---|
| 24 | function 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 | } |
|---|