This repository was archived by the owner on Apr 29, 2018. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathfunctions.php
More file actions
243 lines (208 loc) · 5.42 KB
/
Copy pathfunctions.php
File metadata and controls
243 lines (208 loc) · 5.42 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?php
/**
* Registers options with the Theme Customizer
*
* @param object $wp_customize The WordPress Theme Customizer
* @package tcx
* @since 0.2.0
* @version 1.0.0
*/
function tcx_register_theme_customizer( $wp_customize ) {
$wp_customize->add_setting(
'tcx_link_color',
array(
'default' => '#000000',
'sanitize_callback' => 'tcx_sanitize_input',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'link_color',
array(
'label' => 'Link Color',
'section' => 'colors',
'settings' => 'tcx_link_color'
)
)
);
/*-----------------------------------------------------------*
* Defining our own 'Display Options' section
*-----------------------------------------------------------*/
$wp_customize->add_section(
'tcx_display_options',
array(
'title' => 'Display Options',
'priority' => 200
)
);
/* Display Header */
$wp_customize->add_setting(
'tcx_display_header',
array(
'default' => 'true',
'sanitize_callback' => 'tcx_sanitize_input',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'tcx_display_header',
array(
'section' => 'tcx_display_options',
'label' => 'Display Header?',
'type' => 'checkbox'
)
);
/* Change Color Scheme */
$wp_customize->add_setting(
'tcx_color_scheme',
array(
'default' => 'normal',
'sanitize_callback' => 'tcx_sanitize_input',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'tcx_color_scheme',
array(
'section' => 'tcx_display_options',
'label' => 'Color Scheme',
'type' => 'radio',
'choices' => array(
'normal' => 'Normal',
'inverse' => 'Inverse'
)
)
);
/* Change Font */
$wp_customize->add_setting(
'tcx_font',
array(
'default' => 'times',
'sanitize_callback' => 'tcx_sanitize_input',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'tcx_font',
array(
'section' => 'tcx_display_options',
'label' => 'Theme Font',
'type' => 'select',
'choices' => array(
'times' => 'Times New Roman',
'arial' => 'Arial',
'courier' => 'Courier New'
)
)
);
/* Display Copyright */
$wp_customize->add_setting(
'tcx_footer_copyright_text',
array(
'default' => 'All Rights Reserved',
'sanitize_callback' => 'tcx_sanitize_input',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'tcx_footer_copyright_text',
array(
'section' => 'tcx_display_options',
'label' => 'Copyright Message',
'type' => 'text'
)
);
/*-----------------------------------------------------------*
* Defining our own 'Advanced Options' section
*-----------------------------------------------------------*/
$wp_customize->add_section(
'tcx_advanced_options',
array(
'title' => 'Advanced Options',
'priority' => 201
)
);
/* Background Image */
$wp_customize->add_setting(
'tcx_background_image',
array(
'default' => '',
'sanitize_callback' => 'tcx_sanitize_input',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'tcx_background_image',
array(
'label' => 'Background Image',
'settings' => 'tcx_background_image',
'section' => 'tcx_advanced_options'
)
)
);
} // end tcx_register_theme_customizer
add_action( 'customize_register', 'tcx_register_theme_customizer' );
/**
* Sanitizes the incoming input and returns it prior to serialization.
*
* @param string $input The string to sanitize
* @return string The sanitized string
* @package tcx
* @since 0.5.0
* @version 1.0.2
*/
function tcx_sanitize_input( $input ) {
return strip_tags( stripslashes( $input ) );
} // end tcx_sanitize_input
/**
* Writes styles out the `<head>` element of the page based on the configuration options
* saved in the Theme Customizer.
*
* @since 0.2.0
* @version 1.0.1
*/
function tcx_customizer_css() {
?>
<style type="text/css">
body {
font-family: <?php echo get_theme_mod( 'tcx_font' ); ?>;
<?php if ( 'normal' === get_theme_mod( 'tcx_color_scheme' ) || '' === get_theme_mod( 'tcx_color_scheme' ) ) { ?>
background: #fff;
color: #000;
<?php } else { ?>
background: #000;
color: #fff;
<?php } // end if/else ?>
<?php if ( 0 < count( strlen( ( $background_image_url = get_theme_mod( 'tcx_background_image' ) ) ) ) ) { ?>
background-image: url( <?php echo $background_image_url; ?> );
<?php } // end if ?>
}
a { color: <?php echo get_theme_mod( 'tcx_link_color' ); ?>; }
<?php if( false === get_theme_mod( 'tcx_display_header' ) ) { ?>
#header { display: none; }
<?php } // end if ?>
</style>
<?php
} // end tcx_customizer_css
add_action( 'wp_head', 'tcx_customizer_css' );
/**
* Registers the Theme Customizer Preview with WordPress.
*
* @package tcx
* @since 0.3.0
* @version 1.0.0
*/
function tcx_customizer_live_preview() {
wp_enqueue_script(
'tcx-theme-customizer',
get_template_directory_uri() . '/js/theme-customizer.js',
array( 'customize-preview' ),
'1.0.0',
true
);
} // end tcx_customizer_live_preview
add_action( 'customize_preview_init', 'tcx_customizer_live_preview' );