forked from microweber-templates/shopmag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
61 lines (38 loc) · 1.2 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
<?php
autoload_add_namespace(__DIR__ . '/src/', 'MicroweberPackages\\Template\\Shopmag\\');
api_expose('theme_colors_palette_css');
function theme_colors_palette_css($params = false)
{
return include __DIR__ . DS . 'styles.php';
}
api_expose_admin('theme_css_styles_save');
function theme_css_styles_save($params = false)
{
$option = array();
$option['option_value'] = json_encode($params);
$option['option_key'] = 'new-world_theme_less_vars';
$option['option_group'] = 'template';
save_option($option);
}
api_expose('theme_css_styles_get_url');
function theme_css_styles_get_url($params = false)
{
return template_url() . 'assets/css/main.css';
}
function theme_css_styles_get_less_vars()
{
$less_file = template_dir() . 'assets/css/less/vars.less';
$css_file = template_dir() . 'assets/css/main.css';
$url_root = template_url();
try {
$parser = new Less_Parser();
$parser->parseFile($less_file, $url_root);
$css = $parser->getCss();
$variables = $parser->getVariables();
return $variables;
} catch (Exception $e) {
$error_message = $e->getMessage();
print $error_message;
return;
}
}