示例#1
0
function generate_css_from_less_hook($smof_data)
{
    $less_variables = array();
    if (isset($smof_data['less_editor']) && $smof_data['less_editor'] != '') {
        $lines = explode("\n", $smof_data['less_editor']);
        foreach ($lines as $current) {
            $line = trim($current . '');
            if (substr($line, 0, 2) != "//" && strlen($line) > 3 && substr($line, 0, 1) == "@") {
                $splits = explode(':', $line);
                $variable = trim(str_replace('@', '', $splits[0]));
                $value = trim($splits[1]);
                if (strpos($value, '//') !== false) {
                    $pos = explode('//', $value);
                    $value = trim($pos[0]);
                }
                $value = str_replace(';', '', $value);
                if ($variable != '') {
                    $less_variables = array_merge($less_variables, array($variable => $value));
                }
            }
        }
    }
    // Save LESS Variables
    $encoded_str = base64_encode(serialize($less_variables));
    set_theme_mod("less_theme_variables", $encoded_str);
    build_main_less_to_css($less_variables);
}
示例#2
0
function themeton_customize_save_after()
{
    ThemetonTheme_Customize::init_data();
    global $color_options;
    global $smof_data;
    $less_vals = array();
    foreach ($color_options as $color_option) {
        $items = $color_option['items'];
        foreach ($items as $item) {
            $less_vals = array_merge($less_vals, array($item['id'] => get_theme_mod($item['id'])));
        }
    }
    $theme_less_vars = get_theme_options_less_vars();
    foreach ($less_vals as $key => $value) {
        if (isset($theme_less_vars[$key]) && $value != '') {
            $theme_less_vars[$key] = $value;
        }
    }
    // Save LESS Variables
    $encoded_str = base64_encode(serialize($theme_less_vars));
    set_theme_mod("less_theme_variables", $encoded_str);
    /* Build CSS */
    build_main_less_to_css($theme_less_vars);
}