Add Customizer to WordPress Theme

You can add the a Customize link to the backend of your WordPress Admin area that lets you add customizations to the theme easily.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// Theme customizer sample
add_action('admin_menu', 'voce_customizer_link_example');
function voce_customizer_link_example() {
	add_theme_page('Customize', 'Customize', 'edit_theme_options', 'customize.php');
}
add_action('customize_register', 'voce_customizer_example');
function voce_customizer_example($wp_customize){
	$wp_customize->add_section('voce_customizer_settings', array(
		'title' => 'Example Settings',
		'priority' => 35,
		)
	);
	$wp_customize->add_setting('background_setting', array(
		'default' => '#ffffff',
		)
	);
	$wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, 'background_setting', array(
		'label' => 'Background Color',
		'section' => 'voce_customizer_settings',
		'settings' => 'background_setting',
		)
		)
	);
	$wp_customize->add_setting('footer_text', array(
		'default' => 'WordPress Demonstration Theme using the Voce CSS Framework',
		)
		);
	$wp_customize->add_control('footer_text', array(
		'label' => 'Footer Text',
		'section' => 'voce_customizer_settings',
		'type' => 'text',
		)
		);
}