Created
September 23, 2016 19:05
-
-
Save bpb54321/6343934d40781ada5a9a20d63be36f73 to your computer and use it in GitHub Desktop.
WordPress Logo Uploader in Theme Customizer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /***************CUSTOMIZE THE THEME CUSTOMIZER************/ | |
| function refinestl_customize_register( $wp_customize ) { | |
| // Do stuff with $wp_customize, the WP_Customize_Manager object. | |
| $wp_customize->add_section( 'logo_section', array( | |
| 'title' => __( 'Logos', 'textdomain' ), | |
| 'priority' => 101, | |
| ) ); | |
| $wp_customize->add_setting( 'site_logo', array( | |
| 'type' => 'theme_mod', | |
| 'default' => '', | |
| 'transport' => 'postMessage', //Shows the new setting in the preview pane instantly (no refresh needed) | |
| 'sanitize_callback' => '', | |
| ) ); | |
| $wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'media_control', array( | |
| 'label' => __( 'Site Logo' ), | |
| 'section' => 'logo_section', | |
| 'settings' => 'site_logo', | |
| ) ) ); | |
| } | |
| add_action( 'customize_register', 'refinestl_customize_register' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $logo_img_id = get_theme_mod('site_logo'); | |
| $img_array = wp_get_attachment_image_src ( $logo_img_id, 'medium', false ); | |
| $img_src = $img_array[0]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment