-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
304 lines (285 loc) · 9.17 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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<?php
add_theme_support( 'custom-logo', array(
'height' => 76,
'width' => 100,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
) );
add_theme_support( 'post-formats', array( 'aside', 'quote' ) );
add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );
add_theme_support( 'title-tag' );
function register_my_menus() {
register_nav_menus(
array(
'header-menu' => __( 'Header Menu' ),
'footer-menu' => esc_html__( 'Footer Links', 'theme-textdomain' ),
)
);
}
add_action( 'init', 'register_my_menus' );
function custom_selective_refresh( $wp_customize ) {
$wp_customize->selective_refresh->add_partial( 'blogname', array(
'selector' => '.welcome-section h1 .scouts-teal',
'render_callback' => 'site-title',
) );
$wp_customize->selective_refresh->add_partial( 'custom_logo', array(
'selector' => '.navbar-brand',
'render_callback' => 'site-title',
) );
$wp_customize->selective_refresh->add_partial( 'main_menu', array(
'selector' => '#main-menu-menu',
'render_callback' => 'header-menu',
) );
}
add_action( 'customize_register', 'custom_selective_refresh' );
function add_charity_number_to_customizer( $wp_customize ) {
$wp_customize->add_setting(
'charity_number',
array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options'
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'charity_number',
array(
'label' => __( 'Charity Number', 'textdomain' ),
'description' => __( 'Your charity number', 'textdomain' ),
'settings' => 'charity_number',
'priority' => 10,
'section' => 'title_tagline',
'type' => 'text',
)
) );
$wp_customize->selective_refresh->add_partial( 'charity_number', array(
'selector' => '#charity_number',
'render_callback' => 'charity_number',
) );
}
add_action( 'customize_register', 'add_charity_number_to_customizer' );
function add_front_page_message_to_customizer( $wp_customize ) {
$wp_customize->add_setting(
'front_page_message',
array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options'
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'front_page_message',
array(
'label' => __( 'Front Page Message', 'textdomain' ),
'description' => __( 'Message to appear on the front page', 'textdomain' ),
'settings' => 'front_page_message',
'priority' => 10,
'section' => 'title_tagline',
'type' => 'text',
)
) );
$wp_customize->selective_refresh->add_partial( 'front_page_message', array(
'selector' => '#front_page_message',
'render_callback' => 'front_page_message',
) );
}
add_action( 'customize_register', 'add_front_page_message_to_customizer' );
function add_front_page_announcement_to_customizer( $wp_customize ) {
$wp_customize->add_setting(
'front_page_announcement',
array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options'
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'front_page_announcement',
array(
'label' => __( 'Front Page Announcement', 'textdomain' ),
'description' => __( 'Announcement to appear as a banner at the top of the homepage', 'textdomain' ),
'settings' => 'front_page_announcement',
'priority' => 10,
'section' => 'title_tagline',
'type' => 'text',
)
) );
$wp_customize->selective_refresh->add_partial( 'front_page_announcement', array(
'selector' => '#front_page_announcement',
'render_callback' => 'front_page_announcement',
) );
}
add_action( 'customize_register', 'add_front_page_announcement_to_customizer' );
function add_social_media_to_customizer( $wp_customize ) {
$wp_customize->add_section( 'social_media', array(
'title' => __( 'Social Media Info', 'scoutstheme' ),
'priority' => 30,
) );
$wp_customize->add_setting(
'twitter_handle',
array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options'
)
);
$wp_customize->add_setting(
'facebook_handle',
array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options'
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'twitter_handle',
array(
'label' => __( 'Twitter name', 'textdomain' ),
'description' => __( 'Your Twitter name. eg. @WestSussexScout', 'textdomain' ),
'settings' => 'twitter_handle',
'priority' => 10,
'section' => 'social_media',
'type' => 'text',
)
) );
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'facebook_handle',
array(
'label' => __( 'Facebook URL', 'textdomain' ),
'description' => __( 'Your Facebook URL. eg. https://en-gb.facebook.com/WSScouts/', 'textdomain' ),
'settings' => 'facebook_handle',
'priority' => 10,
'section' => 'social_media',
'type' => 'text',
)
) );
}
add_action( 'customize_register', 'add_social_media_to_customizer' );
function add_homepage_settings_to_customizer( $wp_customize ) {
$wp_customize->add_section( 'homepage_links', array(
'title' => __( 'Homepage Links', 'scoutstheme' ),
'priority' => 30,
) );
$setting_defaults = array(
'setting_name' => '',
'label' => '',
'description' => '',
'type' => 'dropdown-pages',
'capability' => 'edit_theme_options',
'selector' => '',
'section' => 'homepage_links'
);
$front_page_settings = [
array(
'setting_name' => 'sfl_fom_target',
'label' => 'Skills For Life > Find Out More',
'description' => 'Page that "Find Out More" link in "Skills For Life" points to',
'selector' => '#sfl_fom'
),
array(
'setting_name' => 'sfl_jt_target',
'label' => 'Skills For Life > Join Today',
'description' => 'Page that "Join Today" link in "Skills For Life',
'selector' => '#sfl_jt'
),
array(
'setting_name' => 'welcome_fom_target',
'label' => 'Welcome > Find Out More',
'description' => 'Page that "Find Out More" link in "Welcome" points to',
'selector' => '#welcome_fom'
),
array(
'setting_name' => 'section_beavers_target',
'label' => 'Sections > Beavers',
'description' => 'Page that "Beavers" button in Sections list points to',
'selector' => '#section_btn_beavers'
),
array(
'setting_name' => 'section_cubs_target',
'label' => 'Sections > Cubs',
'description' => 'Page that "Cubs" button in Sections list points to',
'selector' => '#section_btn_cubs'
),
array(
'setting_name' => 'section_scouts_target',
'label' => 'Sections > Scouts',
'description' => 'Page that "Scouts" button in Sections list points to',
'selector' => '#section_btn_scouts'
),
array(
'setting_name' => 'section_explorers_target',
'label' => 'Sections > Explorers',
'description' => 'Page that "Explorers" button in Sections list points to',
'selector' => '#section_btn_explorers'
),
array(
'setting_name' => 'section_network_target',
'label' => 'Sections > Network',
'description' => 'Page that "Network" button in Sections list points to',
'selector' => '#section_btn_Network'
),
array(
'setting_name' => 'av_fom_target',
'label' => 'Adult Volunteers > Find Out More',
'description' => 'Page that "Find Out More" link in "Adult Volunteers" points to',
'selector' => '#av_fom'
),
array(
'setting_name' => 'safeguarding_from_target',
'label' => 'Safe Guarding > Find Out More',
'description' => 'Page that "Find out more " link in "Safe Guarding" points to',
'selector' => '#safeguarding_from'
),
];
$index = 1;
foreach ( $front_page_settings as $setting ) {
foreach ( $setting_defaults as $key => $value ) {
if ( ! array_key_exists( $key, $setting ) ) {
$setting[ $key ] = $value;
};
};
$wp_customize->add_setting(
$setting['setting_name'],
array(
'default' => '',
'type' => 'option',
'capability' => $setting['capability']
)
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
$setting['setting_name'],
array(
'label' => __( $setting['label'], 'textdomain' ),
'description' => __( $setting['description'], 'textdomain' ),
'settings' => $setting['setting_name'],
'priority' => $index,
'section' => $setting['section'],
'type' => $setting['type'],
)
) );
$wp_customize->selective_refresh->add_partial( $setting['label'],
array(
'selector' => $setting['selector'],
'render_callback' => $setting['setting_name'],
)
);
$index ++;
}
}
add_action( 'customize_register', 'add_homepage_settings_to_customizer' );
#Auto Update Functionality
require 'vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php';
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'https://github.com/west-sussex-scouts/county-wordpress-theme',
__FILE__,
'county-wordpress-theme'
);
$myUpdateChecker->getVcsApi()->enableReleaseAssets('/.*\.zip/');
require 'vendor/wp-bootstrap/wp-bootstrap-navwalker/class-wp-bootstrap-navwalker.php';