-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
205 lines (149 loc) · 4.71 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
197
198
199
200
201
202
203
204
205
<?php
function eastwood_resources() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action('wp_enqueue_scripts', 'eastwood_resources');
// Get top ancestor
function get_top_ancestor_id() {
global $post;
if ($post->post_parent) {
$ancestors = array_reverse(get_post_ancestors($post->ID));
return $ancestors[0];
}
return $post->ID;
}
// Does page have children?
function has_children() {
global $post;
$pages = get_pages('child_of=' . $post->ID);
return count($pages);
}
// Customize excerpt word count length
function custom_excerpt_length() {
return 22;
}
add_filter('excerpt_length', 'custom_excerpt_length');
// Theme setup
function eastwoood_setup() {
// Navigation Menus
register_nav_menus(array(
'primary' => __( 'Primary Menu'),
'footer' => __( 'Footer Menu'),
));
// Add featured image support
add_theme_support('post-thumbnails');
add_image_size('small-thumbnail', 180, 120, true);
add_image_size('square-thumbnail', 80, 80, true);
add_image_size('banner-image', 920, 210, array('left', 'top'));
// Add post type support
add_theme_support('post-formats', array('aside', 'gallery', 'link'));
}
add_action('after_setup_theme', 'eastwoood_setup');
// Add Widget Areas
function ourWidgetsInit() {
register_sidebar( array(
'name' => 'Sidebar',
'id' => 'sidebar1',
'before_widget' => '<div class="widget-item">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
));
register_sidebar( array(
'name' => 'Footer Area 1',
'id' => 'footer1',
'before_widget' => '<div class="widget-item">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
));
register_sidebar( array(
'name' => 'Footer Area 2',
'id' => 'footer2',
'before_widget' => '<div class="widget-item">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
));
register_sidebar( array(
'name' => 'Footer Area 3',
'id' => 'footer3',
'before_widget' => '<div class="widget-item">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
));
register_sidebar( array(
'name' => 'Footer Area 4',
'id' => 'footer4',
'before_widget' => '<div class="widget-item">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
));
}
add_action('widgets_init', 'ourWidgetsInit');
// Customize Appearance Options
function eastwoood_customize_register( $wp_customize ) {
$wp_customize->add_setting('lwp_link_color', array(
'default' => '#006ec3',
'transport' => 'refresh',
));
$wp_customize->add_setting('lwp_btn_color', array(
'default' => '#006ec3',
'transport' => 'refresh',
));
$wp_customize->add_setting('lwp_btn_hover_color', array(
'default' => '#004C87',
'transport' => 'refresh',
));
$wp_customize->add_section('lwp_standard_colors', array(
'title' => __('Standard Colors', 'eastwoood'),
'priority' => 30,
));
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'lwp_link_color_control', array(
'label' => __('Link Color', 'eastwoood'),
'section' => 'lwp_standard_colors',
'settings' => 'lwp_link_color',
) ) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'lwp_btn_color_control', array(
'label' => __('Button Color', 'eastwoood'),
'section' => 'lwp_standard_colors',
'settings' => 'lwp_btn_color',
) ) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'lwp_btn_hover_color_control', array(
'label' => __('Button Hover Color', 'eastwoood'),
'section' => 'lwp_standard_colors',
'settings' => 'lwp_btn_hover_color',
) ) );
}
add_action('customize_register', 'eastwoood_customize_register');
// Output Customize CSS
function eastwoood_customize_css() { ?>
<style type="text/css">
a:link,
a:visited {
color: <?php echo get_theme_mod('lwp_link_color'); ?>;
}
.site-header nav ul li.current-menu-item a:link,
.site-header nav ul li.current-menu-item a:visited,
.site-header nav ul li.current-page-ancestor a:link,
.site-header nav ul li.current-page-ancestor a:visited {
background-color: <?php echo get_theme_mod('lwp_link_color'); ?>;
}
.btn-a,
.btn-a:link,
.btn-a:visited,
div.hd-search #searchsubmit {
background-color: <?php echo get_theme_mod('lwp_btn_color'); ?>;
}
.btn-a:hover,
div.hd-search #searchsubmit:hover {
background-color: <?php echo get_theme_mod('lwp_btn_hover_color'); ?>;
}
</style>
<?php }
add_action('wp_head', 'eastwoood_customize_css');