This repository was archived by the owner on Feb 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeme-settings.php
More file actions
72 lines (63 loc) · 2.38 KB
/
theme-settings.php
File metadata and controls
72 lines (63 loc) · 2.38 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
<?php
function theme_ymeu_form_system_theme_settings_alter(&$form, $form_state, $form_id = NULL) {
$form['youmove'] = array(
'#type' => 'fieldset',
'#title' => t('Campaign'),
);
$form['youmove']['campaign_webform_id'] = array(
'#type' => 'textfield',
'#title' => t('Campaign page ID'),
'#default_value' => theme_get_setting('campaign_webform_id'),
);
// Set custom validate function
// - based on system_theme_settings_validate()
// - with 1 exception: svg logo is excepted
$form['#validate'] = array();
$form['#validate'][] = 'theme_ymeu_system_theme_settings_validate';
}
function theme_ymeu_system_theme_settings_validate($form, &$form_state) {
// Handle file uploads.
$validators = array('file_validate_extensions' => array('ico png gif jpg jpeg apng svg'));
//$validators = array('file_validate_is_image' => array());
// Check for a new uploaded logo.
$file = file_save_upload('logo_upload', $validators);
if (isset($file)) {
// File upload was attempted.
if ($file) {
// Put the temporary file in form_values so we can save it on submit.
$form_state['values']['logo_upload'] = $file;
}
else {
// File upload failed.
form_set_error('logo_upload', t('The logo could not be uploaded.'));
}
}
$validators = array('file_validate_extensions' => array('ico png gif jpg jpeg apng svg'));
// Check for a new uploaded favicon.
$file = file_save_upload('favicon_upload', $validators);
if (isset($file)) {
// File upload was attempted.
if ($file) {
// Put the temporary file in form_values so we can save it on submit.
$form_state['values']['favicon_upload'] = $file;
}
else {
// File upload failed.
form_set_error('favicon_upload', t('The favicon could not be uploaded.'));
}
}
// If the user provided a path for a logo or favicon file, make sure a file
// exists at that path.
if (!empty($form_state['values']['logo_path'])) {
$path = _system_theme_settings_validate_path($form_state['values']['logo_path']);
if (!$path) {
form_set_error('logo_path', t('The custom logo path is invalid.'));
}
}
if (!empty($form_state['values']['favicon_path'])) {
$path = _system_theme_settings_validate_path($form_state['values']['favicon_path']);
if (!$path) {
form_set_error('favicon_path', t('The custom favicon path is invalid.'));
}
}
}