function themify_get_css() { $data = themify_get_data(); $output = ''; /** * Stores CSS rules * @var string */ $module_styling = ''; if ($data['skin'] != "") { $output .= '<link href="' . themify_https_esc($data['skin']) . '" rel="stylesheet" type="text/css" />' . "\n"; } if (is_file(THEME_DIR . "/custom_style.css")) { $output .= '<link href="' . get_template_directory_uri() . '/custom_style.css" rel="stylesheet" type="text/css" />' . "\n"; } if (is_array($data)) { foreach ($data as $name => $value) { $array = explode('-', $name); $path = ""; foreach ($array as $part) { $path .= "['{$part}']"; } eval("\$config" . $path . " = \$value;"); } if (is_array($config['styling'])) { foreach ($config['styling'] as $nav => $value) { foreach ($value as $element => $val) { $temp = ""; foreach ($val as $attribute => $v) { $attribute = str_replace("_", "-", $attribute); if ($v['value'] != '' && isset($v['value'])) { switch ($attribute) { case "border": foreach ($v['value'] as $key => $val) { if ($val == '') { if (strpos($key, "style") === false) { if (strpos($key, "color") === false) { $v['value'][$key] = 0; } else { $v['value'][$key] = '000000'; } } else { $v['value'][$key] = 'solid'; } } } if ($v['value']['checkbox']) { $temp .= "border: " . $v['value']['same'] . "px " . $v['value']['same_style'] . " #" . $v['value']['same_color'] . ";\n"; } else { if ($v['value']['top'] != '' && $v['value']['top_style'] != '' && $v['value']['top_color'] != '') { $temp .= "border-top: " . $v['value']['top'] . "px " . $v['value']['top_style'] . " #" . $v['value']['top_color'] . ";\n"; } if ($v['value']['right'] != '' && $v['value']['right_style'] != '' && $v['value']['right_color'] != '') { $temp .= "border-right: " . $v['value']['right'] . "px " . $v['value']['right_style'] . " #" . $v['value']['right_color'] . ";\n"; } if ($v['value']['bottom'] != '' && $v['value']['bottom_style'] != '' && $v['value']['bottom_color'] != '') { $temp .= "border-bottom: " . $v['value']['bottom'] . "px " . $v['value']['bottom_style'] . " #" . $v['value']['bottom_color'] . ";\n"; } if ($v['value']['left'] != '' && $v['value']['left_style'] != '' && $v['value']['left_color'] != '') { $temp .= "border-left: " . $v['value']['left'] . "px " . $v['value']['left_style'] . " #" . $v['value']['left_color'] . ";\n"; } } break; case "background-position": if ($v['value']['x'] != '' && $v['value']['y']) { foreach ($v['value'] as $key => $val) { if ($val == '') { $v['value'][$key] = 0; } } $temp .= $attribute . ": "; $temp .= $v['value']['x'] . " " . $v['value']['y'] . ";\n"; } break; case "padding": if ($v['value']['checkbox']) { $temp .= $attribute . ": "; $temp .= $v['value']['same'] . "px" . ";\n"; } else { if ($v['value']['top'] != '' || $v['value']['right'] != '' || $v['value']['bottom'] != '' || $v['value']['left'] != '') { if ($v['value']['top'] != '') { $temp .= "padding-top: " . $v['value']['top'] . "px;\n"; } if ($v['value']['right'] != '') { $temp .= "padding-right: " . $v['value']['right'] . "px;\n"; } if ($v['value']['bottom'] != '') { $temp .= "padding-bottom: " . $v['value']['bottom'] . "px;\n"; } if ($v['value']['left'] != '') { $temp .= "padding-left: " . $v['value']['left'] . "px;\n"; } } } break; case "margin": if ($v['value']['checkbox']) { $temp .= $attribute . ": "; $temp .= $v['value']['same'] . "px" . ";\n"; } else { if ($v['value']['top'] != '' || $v['value']['right'] != '' || $v['value']['bottom'] != '' || $v['value']['left'] != '') { if ($v['value']['top'] != '') { $temp .= "margin-top: " . $v['value']['top'] . "px;\n"; } if ($v['value']['right'] != '') { $temp .= "margin-right: " . $v['value']['right'] . "px;\n"; } if ($v['value']['bottom'] != '') { $temp .= "margin-bottom: " . $v['value']['bottom'] . "px;\n"; } if ($v['value']['left'] != '') { $temp .= "margin-left: " . $v['value']['left'] . "px;\n"; } } } break; case "color": if ($v['value']['value'] != '' && $v['value']['value'] != ' ') { $temp .= $attribute . ": "; $temp .= "#" . $v['value']['value'] . ";\n"; } break; case "background-color": if ($v['value']['transparent']) { $temp .= $attribute . ": transparent;\n"; } else { if ($v['value']['value'] != '' && $v['value']['value'] != ' ') { $temp .= $attribute . ": "; $temp .= "#" . $v['value']['value'] . ";\n"; } } break; case "background-image": if ($v['value']['value'] != '' && $v['value']['value'] != ' ') { $temp .= $attribute . ": "; $temp .= "url(" . $v['value']['value'] . ")" . ";\n"; } else { if ($v['value']['none'] == "on") { $temp .= $attribute . ": "; $temp .= "none;\n"; } } break; case "background-repeat": if ($v['value']['value'] != '' && $v['value']['value'] != ' ') { $temp .= $attribute . ": "; $temp .= $v['value']['value'] . ";\n"; } break; case "font-family": if ($v['value']['value'] != '' && $v['value']['value'] != ' ') { $temp .= $attribute . ": "; $temp .= $v['value']['value'] . ";\n"; } break; case "line-height": if ($v['value']['value'] != '' && $v['value']['value'] != ' ') { $temp .= $attribute . ": "; $temp .= $v['value']['value'] . $v['value']['unit'] . ";\n"; } break; case "position": if ($v['value']['value'] != '' && $v['value']['value'] != ' ') { $temp .= $attribute . ": "; $temp .= $v['value']['value'] . ";\n"; if ($v['value']['value'] == 'absolute' || $v['value']['value'] == 'fixed') { if ($v['value']['x_value'] != '' && $v['value']['x_value'] != ' ') { $temp .= $v['value']['x'] . ": " . $v['value']['x_value'] . "px;\n"; } if ($v['value']['y_value'] != '' && $v['value']['y_value'] != ' ') { $temp .= $v['value']['y'] . ": " . $v['value']['y_value'] . "px;\n"; } } } break; default: if ($v['value']['value'] != '' && $v['value']['value'] != ' ') { $temp .= $attribute . ": "; $temp .= $v['value']['value']; if (isset($v['value']['unit'])) { $temp .= $v['value']['unit']; } $temp .= ";\n"; } break; } } } if ($temp != '' && $temp != ' ') { $module_styling .= urldecode(themify_scrub_decode($element)) . " {\n"; $module_styling .= $temp; $module_styling .= "}\n\n"; } } } } } else { $output = '<style type="text/css">/* ' . __('No Values in the Database', 'themify') . ' */</style>'; } $module_styling_before = "<!-- modules styling -->\n<style type='text/css'>\n"; $module_styling_after = "</style>"; if ('' != $module_styling) { $output .= $module_styling_before . $module_styling . $module_styling_after; } echo "\n\n" . $output; }
/** * Convert old data to new data * @param type $old_data * @return array */ function convert_data($old_data) { $new_data = array(); // convert old data if (is_array($old_data) && count($old_data) >= 1) { foreach ($old_data as $name => $value) { $array = explode('-', $name); $path = ""; foreach ($array as $part) { $path .= "['{$part}']"; } eval("\$config" . $path . " = \$value;"); } if (is_array($config['styling'])) { foreach ($config['styling'] as $nav => $value) { // get parent array $parent_arr = themify_get_theme_arr($nav, 'styling'); foreach ($value as $element => $val) { $selector = urldecode(themify_scrub_decode($element)); $title = str_replace('_', ' ', $nav); // return id of element by selector $id_style = themify_search_arr($parent_arr, 'selector', $selector, true); if (isset($id_style[0]['id'])) { $style_key = $id_style[0]['id']; $config['styling'][$nav][$style_key] = $val; } } } } // convert into new array $new_data = $this->dfs($config); } return $new_data; }