forked from Automattic/_s
-
Notifications
You must be signed in to change notification settings - Fork 1
/
customizer.php
154 lines (137 loc) · 4.71 KB
/
customizer.php
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
/**
* Shoestrap Theme Customizer.
*
* @package Shoestrap
*/
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function shoestrap_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
}
add_action( 'customize_register', 'shoestrap_customize_register' );
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function shoestrap_customize_preview_js() {
wp_enqueue_script( 'shoestrap_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'shoestrap_customize_preview_js' );
if ( class_exists( 'Kirki' ) ) {
Kirki::add_config( 'shoestrap', array(
'option_type' => 'theme_mod',
'capability' => 'edit_theme_options',
) );
Kirki::add_panel( 'shoestrap_header', array(
'title' => esc_attr__( 'Header', 'shoestrap' ),
) );
Kirki::add_section( 'shoestrap_navigation', array(
'title' => esc_attr__( 'Navigation', 'shoestrap' ),
'panel' => 'shoestrap_header',
'type' => 'expanded',
) );
Kirki::add_panel( 'shoestrap_typography', array(
'title' => esc_attr__( 'Typography', 'shoestrap' ),
) );
Kirki::add_section( 'shoestrap_typography_body', array(
'title' => esc_attr__( 'Body Typography', 'shoestrap' ),
'panel' => 'shoestrap_typography',
'type' => 'expanded',
) );
Kirki::add_panel( 'shoestrap_layout', array(
'title' => esc_attr__( 'Layout', 'shoestrap' ),
) );
Kirki::add_section( 'shoestrap_layout_navbar', array(
'title' => esc_attr__( 'NavBar', 'shoestrap' ),
'panel' => 'shoestrap_layout',
'type' => 'expanded',
) );
Kirki::add_section( 'shoestrap_layout_content', array(
'title' => esc_attr__( 'Content', 'shoestrap' ),
'panel' => 'shoestrap_layout',
'type' => 'expanded',
) );
Kirki::add_field( 'shoestrap', array(
'type' => 'color-alpha',
'settings' => 'navbar_bg_color',
'label' => esc_attr__( 'Navbar Background Color', 'shoestrap' ),
'section' => 'shoestrap_navigation',
'default' => '#333333',
'priority' => 10,
'output' => array(
array(
'element' => '#site-navigation',
'property' => 'background-color',
),
array(
'element' => '#site-navigation a',
'property' => 'color',
'sanitize_callback' => 'shoestrap_get_readable_color',
),
array(
'element' => '#site-navigation .active',
'property' => 'background-color',
'sanitize_callback' => 'shoestrap_darken_5',
),
),
) );
Kirki::add_field( 'shoestrap', array(
'type' => 'typography',
'settings' => 'body_typography',
'label' => esc_attr__( 'Typography', 'shoestrap' ),
'description' => esc_attr__( 'Controls the main typography of your site. Please note that this control affects all typography elemenents on your site.', 'shoestrap' ),
'section' => 'shoestrap_typography_body',
'default' => array(
'font-family' => 'Roboto',
'font-size' => '1em',
'variant' => '300',
'line-height' => '1.5',
'letter-spacing' => '0',
'color' => '#333333',
),
'priority' => 10,
'choices' => array(
'font-family' => true,
'font-size' => true,
'font-weight' => true,
'line-height' => true,
'color' => false,
),
'output' => array(
array(
'element' => 'body',
),
),
) );
Kirki::add_field( 'shoestrap', array(
'type' => 'radio-buttonset',
'settings' => 'navbar_container',
'label' => esc_attr__( 'Navbar Mode', 'shoestrap' ),
'description' => esc_attr__( 'Select if the navbar should be boxed or fluid.', 'shoestrap' ),
'section' => 'shoestrap_layout_navbar',
'default' => 'container-fluid',
'priority' => 10,
'choices' => array(
'container' => esc_attr__( 'Boxed', 'shoestrap' ),
'container-fluid' => esc_attr__( 'Fluid', 'shoestrap' ),
),
) );
Kirki::add_field( 'shoestrap', array(
'type' => 'radio-buttonset',
'settings' => 'content_container',
'label' => esc_attr__( 'Content Mode', 'shoestrap' ),
'description' => esc_attr__( 'Select if the content should be boxed or fluid.', 'shoestrap' ),
'section' => 'shoestrap_layout_content',
'default' => 'container',
'priority' => 10,
'choices' => array(
'container' => esc_attr__( 'Boxed', 'shoestrap' ),
'container-fluid' => esc_attr__( 'Fluid', 'shoestrap' ),
),
) );
}