-
Notifications
You must be signed in to change notification settings - Fork 5
/
functions.php
196 lines (183 loc) · 5.47 KB
/
functions.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
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
<?php
/**
* Child theme function
*
* @package yt1300
* @since 0.1
* @author Josh Pollock http://JoshPress.net
* @license GPLv2+
*/
/**
* Add controls/ settings for background colors ans social links
*
* @package yt1300
* @since 0.1
* @author Josh Pollock
*/
function yt1300_customizer() {
global $wp_customize;
//add sections
$wp_customize->add_section( 'yt1300_social', array(
'title' => __('Social Links For Header', 'yt1300'),
'priority' => 45,
) );
//color settings
//gradient start color
$wp_customize->add_setting( 'gradient_start', array(
'default' => '#000',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'gradient_start', array(
'label' => __('Gradient Start Color', 'yt1300'),
'section' => 'colors',
'settings'=> 'gradient_start',
) ) );
//gradient end color
$wp_customize->add_setting( 'gradient_end', array(
'default' => '#F5F5F5',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'gradient_end', array(
'label' => __('Gradient End Color', 'yt1300'),
'section' => 'colors',
'settings'=> 'gradient_end',
) ) );
//sidr theme
$wp_customize->add_setting( 'sidr_theme', array(
'default' => 'dark',
) );
$wp_customize->add_control( 'sidr_theme', array(
'label' => __('Mobile Slide Out Sidebar Theme', 'yt1300'),
'section' => 'colors',
'type' => 'select',
'choices' => array(
'dark' => 'Dark',
'light'=> 'Light',
),
) );
//Create Text fields for social with a loop
$socials = array(
array(
'label' => 'Facebook Profile or Page',
'name' => 'facebook',
),
array(
'label' => 'Twitter Profile',
'name' => 'twitter',
),
array(
'label' => 'Google Plus Profile',
'name' => 'googleplus',
),
array(
'label' => 'LinkedIn Profile',
'name' => 'linkedin',
),
);
foreach ( $socials as $social ) {
$wp_customize->add_setting( $social['name'], array(
) );
$wp_customize->add_control( $social['name'], array(
'label' => __($social['label'], 'yt1300'),
'section' => 'yt1300_social',
'settings' => $social['name'],
) );
}
}
add_action( 'customize_register', 'yt1300_customizer' );
/**
* Add gradient background with colors set in bg_colors() as inline style in heades
*
* @package yt1300
* @since 0.1
* @author Josh Pollock
*/
function yt1300_falcon_style() {
//get colors
$start = get_theme_mod( 'gradient_start', '#000' );
$end = get_theme_mod( 'gradient_end', '#F5F5F5');
//set up custom style
$custom_css = "
.site:before, body{
background-image: -webkit-gradient(linear,left bottom,right bottom,color-stop(0,{$start}),color-stop(1,{$end}));
background-image: -o-linear-gradient(right,{$start} 0%,{$end} 100%);
background-image: -moz-linear-gradient(right,{$start} 0%,{$end} 100%);
background-image: -webkit-linear-gradient(right,{$start} 0%,{$end} 100%);
background-image: -ms-linear-gradient(right,{$start} 0%,{$end} 100%);
background-image: linear-gradient(to right,{$start} 0%,{$end} 100%);
}";
//print for header
echo '<style>'.$custom_css.'</style>';
}
add_action( 'wp_head', 'yt1300_falcon_style' );
/**
* Include functions for fancier topbar
*
* @package yt1300
* @since 0.1
* @author Josh Pollock
*/
include( 'inc/topbar.php' );
/**
* Add Slidein sidebar functionality
*
* @package yt1300
* @since 0.2
* @author Josh Pollock
*/
include_once('inc/mobile_sidebar.php');
/**
* Output correct header area (#masthead) based on device detection
*
* @uses topbar::header()
* @uses mobile_sidebar::header()
*
* @package yt1300
* @since 0.2
* @author Josh Pollock
*/
function yt1300_header() {
if ( !wp_is_mobile() ) {
yt1300_topbar::header();
//return \yt1300\topbar::header();
}
else {
return yt1300_mobile_sidebar::header();
//return \yt1300\mobile_sidebar::header();
}
}
/**
* Sets the theme mods to either a default value or previously set value on theme activation
*
* @package yt1300
* @since 0.6
* @author Josh Pollock
*/
function yt1300_set_defaults() {
//Array of defaults
$defaults = array(
'twitter' => '',
'googleplus' => '',
'facebook' => '',
'linkedin' => '',
'gradient_start' => '#000',
'gradient_end' => '#F5F5F5',
);
//parse array using set values if they exists, if not, use $defaults
$yt1300_defaults = wp_parse_args( get_theme_mods( 'yt1300', array() ), $defaults );
//set theme mods with parsed array
foreach ( $yt1300_defaults as $key=>$data) {
$name = $key;
$value = $data;
set_theme_mod( $name, $value );
}
}
add_action('after_switch_theme', 'yt1300_set_defaults');
/**
* Override the plugable functions in twentyfourteen/inc/custom-header.php with nothing
*
* @package yt1300
* @since 1.0.1
* @author Josh Pollock
*/
function twentyfourteen_admin_header_image() {}
function twentyfourteen_header_style() {}
?>