Created
June 15, 2016 00:30
-
-
Save immanuelsun/bb52c69cbc6fef4cbe792128e20519dc to your computer and use it in GitHub Desktop.
WordPress customizer: add image upload (logo)
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
// Add theme customizer controls, settings, etc. | |
function kingdom_customize_register($wp_customize) | |
{ | |
/******************************************** | |
! Image Upload | |
*********************************************/ | |
$wp_customize->add_section('kingdom_image_upload', array( | |
'title' => __( 'Images', 'kingdom' ) | |
)); | |
/* Logo */ | |
$wp_customize->add_setting('kingdom_logo_upload'); | |
$wp_customize->add_control( new WP_Customize_Image_Control( | |
$wp_customize, | |
'kingdom_logo_upload', | |
array ( | |
'label' => __( 'Upload your logo', 'kingdom' ), | |
'section' => 'kingdom_image_upload', | |
'setting' => 'kingdom_logo_upload' | |
) | |
)); | |
} | |
/******************************************** | |
! add controls / content to theme | |
*********************************************/ | |
function kingdom_display_contact_details_in_header() | |
{ | |
$html = ''; | |
$html .= '<address>'; | |
// Address | |
$html .= '<p class="address">'; | |
$html .= get_theme_mod( 'kingdom_address_setting', 'Your Address' ); | |
$html .= '</p><!-- /.address -->'; | |
// Phone | |
$html .= '<p class="phone">'; | |
$html .= get_theme_mod( 'kingdom_phone_setting', 'Your phone number' ); | |
$html .= '</p><!-- /.phone -->'; | |
$html .= '<p class="email">'; | |
$email = get_theme_mod( 'kingdom_email_setting', 'Your email address' ); | |
$html .= '<a href="' . $email . ' ">'; | |
$html .= $email; | |
$html .= '</a>'; | |
$html .= '</p><!-- /.email -->'; | |
$html .= '</address>'; | |
echo $html; | |
} | |
add_action('kingdom_in_header', 'kingdom_display_contact_details_in_header'); |
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
load_template( get_template_directory() . '/includes/customizer.php' ); |
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
/* action hook for any content placed inside the right hand header, including the widget area. */ | |
do_action ( 'kingdom_in_header' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment