Skip to content

Instantly share code, notes, and snippets.

@immanuelsun
Created June 15, 2016 00:30
Show Gist options
  • Save immanuelsun/bb52c69cbc6fef4cbe792128e20519dc to your computer and use it in GitHub Desktop.
Save immanuelsun/bb52c69cbc6fef4cbe792128e20519dc to your computer and use it in GitHub Desktop.
WordPress customizer: add image upload (logo)
// 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 -->';
// Email
$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');
load_template( get_template_directory() . '/includes/customizer.php' );
/* 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