johannesress
2/8/2014 - 7:42 AM

Adds a theme customizer page to the backend with custom boxes and controls

Adds a theme customizer page to the backend with custom boxes and controls

<?php
/***********************************************************************************************/
/* Add a menu option to link to the customizer */
/***********************************************************************************************/
add_action('admin_menu', 'display_custom_options_link');

function display_custom_options_link() {
	add_theme_page('Theme Optionen', 'Theme Optionen', 'edit_theme_options', 'customize.php');
}

/***********************************************************************************************/
/* Add options in the theme customizer page */
/***********************************************************************************************/
add_action('customize_register', 'sti_customize_register');

function sti_customize_register($wp_customize) {
	
	// Custom Image Uploader 
  $wp_customize->add_section('sti_image_section', array(
		'title' => __('Image', 'adaptive-framework'),
		'description' => __('Ein eigenes Bild z.B. für Teaser oder Logo hochladen.', 'adaptive-framework'),
		'priority' => 35
	));
	
	$wp_customize->add_setting('sti_custom_settings[image]', array(
		'default' => IMAGES . '/logo.png',
		'type' => 'option'
	));
	
	$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'image', array(
		'label' => __('Lade dein Bild hoch', 'adaptive-framework'),
		'section' => 'sti_image',
		'settings' => 'sti_custom_settings[image]'
	)));

	// Custom Color Choose 
  $wp_customize->add_section('sti_color_section', array(
		'title' => 'Farbwahl',
		'description' => 'Besonderes Auswahlfeld für Farben hinzufügen',
		'priority' => 35
	));
	
  $wp_customize->add_setting(
    'sti_custom_settings[color]', array(
      'default' => '#27ae60'
    )
  );
  
  $wp_customize->add_control(
    new WP_Customize_Color_Control(
      $wp_customize, 'design_color', array(
        'label' => 'Farbe des Design',
        'section' => 'colors',
        'settings' => 'design_color'
      )
    )
  );
  
	// 
	// Contact Daten
	//
	$wp_customize->add_section('sti_contact_data', array(
		'title' => __('Kontaktdaten', 'adaptive-framework'),
		'description' => 'Kontaktdaten eintragen.',
		'priority' => 37
	));
	
	// E-Mail
	$wp_customize->add_setting('sti_custom_settings[contact_email]', array(
		'default' => '',
		'type' => 'option'
	));
	
	$wp_customize->add_control('sti_custom_settings[contact_email]', array(
		'label' => 'E-Mail Adresse',
		'section' => 'sti_contact_data',
		'settings' => 'sti_custom_settings[contact_email]',
		'type' => 'text'
	));

	// Telefon
	$wp_customize->add_setting('sti_custom_settings[contact_telefon]', array(
		'default' => '',
		'type' => 'option'
	));
	
	$wp_customize->add_control('sti_custom_settings[contact_telefon]', array(
		'label' => 'Telefonummer',
		'section' => 'sti_contact_data',
		'settings' => 'sti_custom_settings[contact_telefon]',
		'type' => 'text'
	));

	// Mobil
	$wp_customize->add_setting('sti_custom_settings[contact_fax]', array(
		'default' => '',
		'type' => 'option'
	));
	
	$wp_customize->add_control('sti_custom_settings[contact_fax]', array(
		'label' => 'Faxnummer',
		'section' => 'sti_contact_data',
		'settings' => 'sti_custom_settings[contact_fax]',
		'type' => 'text'
	));



	// Name
	$wp_customize->add_setting('sti_custom_settings[contact_name]', array(
		'default' => '',
		'type' => 'option'
	));
	
	$wp_customize->add_control('sti_custom_settings[contact_name]', array(
		'label' => 'Name',
		'section' => 'sti_contact_data',
		'settings' => 'sti_custom_settings[contact_name]',
		'type' => 'text'
	));

	// Straße
	$wp_customize->add_setting('sti_custom_settings[contact_strasse]', array(
		'default' => '',
		'type' => 'option'
	));
	
	$wp_customize->add_control('sti_custom_settings[contact_strasse]', array(
		'label' => 'Straße und Hausnummer',
		'section' => 'sti_contact_data',
		'settings' => 'sti_custom_settings[contact_strasse]',
		'type' => 'text'
	));

	// PLZ
	$wp_customize->add_setting('sti_custom_settings[contact_plz]', array(
		'default' => '',
		'type' => 'option'
	));
	
	$wp_customize->add_control('sti_custom_settings[contact_plz]', array(
		'label' => 'Postleitzahl',
		'section' => 'sti_contact_data',
		'settings' => 'sti_custom_settings[contact_plz]',
		'type' => 'text'
	));

	// Ort
	$wp_customize->add_setting('sti_custom_settings[contact_ort]', array(
		'default' => '',
		'type' => 'option'
	));
	
	$wp_customize->add_control('sti_custom_settings[contact_ort]', array(
		'label' => 'Ort',
		'section' => 'sti_contact_data',
		'settings' => 'sti_custom_settings[contact_ort]',
		'type' => 'text'
	));


	// 
	// SocialData
	//
	$wp_customize->add_section('sti_social_data', array(
		'title' => __('Social', 'adaptive-framework'),
		'description' => 'Social Media Accounts eintragen.',
		'priority' => 37
	));
	
	// E-Mail
	$wp_customize->add_setting('sti_custom_settings[facebook]', array(
		'default' => '',
		'type' => 'option'
	));
	
	$wp_customize->add_control('sti_custom_settings[facebook]', array(
		'label' => 'Facebook',
		'section' => 'sti_social_data',
		'settings' => 'sti_custom_settings[facebook]',
		'type' => 'text'
	));

	// Telefon
	$wp_customize->add_setting('sti_custom_settings[twitter]', array(
		'default' => '',
		'type' => 'option'
	));
	
	$wp_customize->add_control('sti_custom_settings[twitter]', array(
		'label' => 'Twitter',
		'section' => 'sti_social_data',
		'settings' => 'sti_custom_settings[twitter]',
		'type' => 'text'
	));

	// Mobil
	$wp_customize->add_setting('sti_custom_settings[google]', array(
		'default' => '',
		'type' => 'option'
	));
	
	$wp_customize->add_control('sti_custom_settings[google]', array(
		'label' => 'Google+',
		'section' => 'sti_social_data',
		'settings' => 'sti_custom_settings[google]',
		'type' => 'text'
	));
}	
?>