function hocwp_plugin_load_custom_css() { $option = get_option('hocwp_plugin_custom_css'); $css = hocwp_get_value_by_key($option, 'code'); if (!empty($css)) { $css = hocwp_minify_css($css); $style = new HOCWP_HTML('style'); $style->set_attribute('type', 'text/css'); $style->set_text($css); $style->output(); } }
function hocwp_shortcode_before($class = '', $attributes) { $title = hocwp_get_value_by_key($attributes, 'title'); hocwp_add_string_with_space_before($class, 'hocwp-shortcode'); $class = hocwp_add_more_class($class, 'module'); $class = hocwp_add_more_class($class, 'clearfix'); $style = hocwp_get_value_by_key($attributes, 'style'); if (!empty($style)) { $style = hocwp_minify_css($style); $style = rtrim($style, ';'); } $max_width = hocwp_get_value_by_key($attributes, 'max_width'); if (!empty($max_width)) { $style .= ';max-width: ' . $max_width; } $column = hocwp_get_value_by_key($attributes, 'column'); if (!empty($column)) { hocwp_add_string_with_space_before($class, 'column-' . $column); } $html = '<div class="' . $class . '" style="' . $style . '">'; if (!empty($title)) { $style = ''; $border_color = hocwp_get_value_by_key($attributes, 'border_color'); if (hocwp_is_color($border_color)) { $color_name = hocwp_is_color_name($border_color); if (is_array($color_name)) { $color_name = 'rgb(' . implode(',', $color_name) . ')'; if (hocwp_is_rgb_color($color_name)) { $border_color = $color_name; } } $style .= 'border-color: ' . $border_color; } $html .= '<div class="module-header clearfix">'; $html .= '<h4 class="module-name"><span style="' . $style . '">' . $title . '</span></h4>'; $html .= '</div>'; } $html .= '<div class="module-body clearfix">'; return $html; }
function hocwp_setup_theme_custom_head() { $options = get_option('hocwp_theme_custom'); $background_image = hocwp_get_value_by_key($options, 'background_image'); $background_image = hocwp_get_media_option_url($background_image); if (hocwp_url_valid($background_image)) { $style = new HOCWP_HTML('style'); $style->set_attribute('type', 'text/css'); $elements = array('body.hocwp'); $properties = array('background-image' => 'url("' . $background_image . '")', 'background-repeat' => 'no-repeat', 'background-color' => 'rgba(0,0,0,0)'); $lazyload = hocwp_get_value_by_key($options, 'background_lazyload'); if ((bool) $lazyload) { unset($properties['background-image']); } $background_repeat = hocwp_get_value_by_key($options, 'background_repeat'); if ((bool) $background_repeat) { $properties['background-repeat'] = 'repeat'; } $background_color = hocwp_get_value_by_key($options, 'background_color'); if (hocwp_color_valid($background_color)) { $properties['background-color'] = $background_color; } $background_size = hocwp_get_value_by_key($options, 'background_size'); if (!empty($background_size)) { $properties['background-size'] = $background_size; } $background_position = hocwp_get_value_by_key($options, 'background_position'); if (!empty($background_position)) { $properties['background-position'] = $background_position; } $background_attachment = hocwp_get_value_by_key($options, 'background_attachment'); if (!empty($background_attachment)) { $properties['background-attachment'] = $background_attachment; } $css = hocwp_build_css_rule($elements, $properties); $css = hocwp_minify_css($css); $style->set_text($css); if (!empty($css)) { $style->output(); } } }
function hocwp_theme_copy_style_to_min_file() { if (!defined('HOCWP_THEME_PATH')) { return; } $hocwp_css_path = HOCWP_THEME_PATH . '/css'; $min_file = $hocwp_css_path . '/hocwp-custom-front-end.min.css'; if (!file_exists($min_file)) { hocwp_create_file($min_file); } $old_content = @file_get_contents($min_file); $old_content = trim($old_content); if (empty($old_content)) { $tmp_file = $hocwp_css_path . '/hocwp-custom-front-end.css'; if (file_exists($tmp_file)) { $old_content = @file_get_contents($tmp_file); $old_content = hocwp_minify_css($old_content); $old_content = trim($old_content); } } if (!empty($old_content)) { $temp_file = HOCWP_PATH . '/css/hocwp-front-end.min.css'; if (file_exists($temp_file)) { $temp_content = @file_get_contents($temp_file); $temp_content = trim($temp_content); $old_content = $temp_content . $old_content; } $temp_file = HOCWP_PATH . '/css/hocwp.min.css'; if (file_exists($temp_file)) { $temp_content = @file_get_contents($temp_file); $temp_content = trim($temp_content); $old_content = $temp_content . $old_content; } $temp_file = HOCWP_THEME_PATH . '/css/hocwp-custom-font.min.css'; if (file_exists($temp_file)) { $temp_content = @file_get_contents($temp_file); $temp_content = trim($temp_content); $old_content = $temp_content . $old_content; } $old_content = trim($old_content); } @file_put_contents($min_file, $old_content); }