[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: class-css-generator.php
<?php if ( ! class_exists( 'ReduxFrameworkInstances' ) ) { return; } if(!function_exists('alico_hex_to_rgba')){ function alico_hex_to_rgba($hex,$opacity = 1) { $hex = str_replace("#",null, $hex); $color = array(); if(strlen($hex) == 3) { $color['r'] = hexdec(substr($hex,0,1).substr($hex,0,1)); $color['g'] = hexdec(substr($hex,1,1).substr($hex,1,1)); $color['b'] = hexdec(substr($hex,2,1).substr($hex,2,1)); $color['a'] = $opacity; } else if(strlen($hex) == 6) { $color['r'] = hexdec(substr($hex, 0, 2)); $color['g'] = hexdec(substr($hex, 2, 2)); $color['b'] = hexdec(substr($hex, 4, 2)); $color['a'] = $opacity; } $color = "rgba(".implode(', ', $color).")"; return $color; } } class CSS_Generator { /** * scssc class instance * * @access protected * @var scssc */ protected $scssc = null; /** * ReduxFramework class instance * * @access protected * @var ReduxFramework */ protected $redux = null; /** * Debug mode is turn on or not * * @access protected * @var boolean */ protected $dev_mode = true; /** * opt_name of ReduxFramework * * @access protected * @var string */ protected $opt_name = ''; /** * Constructor */ function __construct() { $this->opt_name = alico_get_opt_name(); if ( empty( $this->opt_name ) ) { return; } $this->dev_mode = alico_get_opt( 'dev_mode', '0' ) === '1' ? true : false; add_filter( 'ct_scssc_on', '__return_true' ); add_action( 'init', array( $this, 'init' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 20 ); } /** * init hook - 10 */ function init() { if ( ! class_exists( 'scssc' ) ) { return; } $this->redux = ReduxFrameworkInstances::get_instance( $this->opt_name ); if ( empty( $this->redux ) || ! $this->redux instanceof ReduxFramework ) { return; } add_action( 'wp', array( $this, 'generate_with_dev_mode' ) ); add_action( "redux/options/{$this->opt_name}/saved", function () { $this->generate_file_options(); } ); } function generate_with_dev_mode() { if ( $this->dev_mode === true ) { $this->generate_file_options(); $this->generate_file(); } } function generate_file_options() { $scss_dir = get_template_directory() . '/assets/scss/'; $this->scssc = new scssc(); $this->scssc->setImportPaths( $scss_dir ); $_options = $scss_dir . 'variables.scss'; $this->scssc->setFormatter( 'scss_formatter' ); $this->redux->filesystem->execute( 'put_contents', $_options, array( 'content' => preg_replace( "/(?<=[^\r]|^)\n/", "\r\n", $this->options_output() ) ) ); } /** * Generate options and css files */ function generate_file() { $scss_dir = get_template_directory() . '/assets/scss/'; $css_dir = get_template_directory() . '/assets/css/'; $this->scssc = new scssc(); $this->scssc->setImportPaths( $scss_dir ); $css_file = $css_dir . 'theme.css'; $this->scssc->setFormatter( 'scss_formatter' ); $this->redux->filesystem->execute( 'put_contents', $css_file, array( 'content' => preg_replace( "/(?<=[^\r]|^)\n/", "\r\n", $this->scssc->compile( '@import "theme.scss"' ) ) ) ); } protected function print_scss_opt_colors($variable,$param){ if(is_array($variable)){ $k = []; $v = []; foreach ($variable as $key => $value) { $k[] = str_replace('-', '_', $key); $v[] = 'var(--'.str_replace(['#',' '], [''],$key).'-color)'; } if($param === 'key'){ return implode(',', $k); }else{ return implode(',', $v); } } else { return $variable; } } /** * Output options to _variables.scss * * @access protected * @return string */ protected function options_output() { $theme_colors = alico_configs('theme_colors'); $links = alico_configs('link'); $gradients = alico_configs('gradient'); $gradients2 = alico_configs('gradient2'); $gradients3 = alico_configs('gradient3'); $gradients4 = alico_configs('gradient4'); ob_start(); printf('$alico_theme_colors_key:(%s);',$this->print_scss_opt_colors($theme_colors,'key')); printf('$alico_theme_colors_val:(%s);',$this->print_scss_opt_colors($theme_colors,'val')); // color rgb only foreach ($theme_colors as $key => $value) { printf('$%1$s_color_hex: %2$s;', str_replace('-', '_', $key), $value['value']); } // color foreach ($theme_colors as $key => $value) { printf('$%1$s_color: %2$s;', str_replace('-', '_', $key), 'var(--'.str_replace(['#',' '], [''],$key).'-color)' ); } // color rgb only foreach ($theme_colors as $key => $value) { printf('$%1$s_color_hex: %2$s;', str_replace('-', '_', $key), $value['value']); } // color foreach ($theme_colors as $key => $value) { printf('$%1$s_color: %2$s;', str_replace('-', '_', $key), 'var(--'.str_replace(['#',' '], [''],$key).'-color)' ); } // link color foreach ($links as $key => $value) { printf('$link_%1$s: %2$s;', str_replace('-', '_', $key), 'var(--link-'.$key.')'); } // Gradient Color 1 foreach ($gradients as $key => $value) { printf('$gradient_%1$s: %2$s;', str_replace('-', '_', $key), 'var(--gradient-'.$key.')'); } $gradient_color_hex = alico_get_opt( 'gradient_color' ); if ( !empty($gradient_color_hex['from']) && isset($gradient_color_hex['from']) ) { printf( '$gradient_from_hex: %s;', esc_attr( $gradient_color_hex['from'] ) ); } else { echo '$gradient_from_hex: #0c3ef8;'; } if ( !empty($gradient_color_hex['to']) && isset($gradient_color_hex['to']) ) { printf( '$gradient_to_hex: %s;', esc_attr( $gradient_color_hex['to'] ) ); } else { echo '$gradient_to_hex: #6a84ff;'; } // Gradient Color 2 foreach ($gradients2 as $key => $value) { printf('$gradient_%1$s: %2$s;', str_replace('-', '_', $key), 'var(--gradient-'.$key.')'); } $gradient_color_hex2 = alico_get_opt( 'gradient_color2' ); if ( !empty($gradient_color_hex2['from']) && isset($gradient_color_hex2['from']) ) { printf( '$gradient_from_hex2: %s;', esc_attr( $gradient_color_hex2['from'] ) ); } else { echo '$gradient_from_hex2: #9fd712;'; } if ( !empty($gradient_color_hex2['to']) && isset($gradient_color_hex2['to']) ) { printf( '$gradient_to_hex2: %s;', esc_attr( $gradient_color_hex2['to'] ) ); } else { echo '$gradient_to_hex2: #cbf855;'; } // Gradient Color 3 foreach ($gradients3 as $key => $value) { printf('$gradient_%1$s: %2$s;', str_replace('-', '_', $key), 'var(--gradient-'.$key.')'); } $gradient_color_hex3 = alico_get_opt( 'gradient_color3' ); if ( !empty($gradient_color_hex3['from']) && isset($gradient_color_hex3['from']) ) { printf( '$gradient_from_hex3: %s;', esc_attr( $gradient_color_hex3['from'] ) ); } else { echo '$gradient_from_hex3: #1c7cff;'; } if ( !empty($gradient_color_hex3['to']) && isset($gradient_color_hex3['to']) ) { printf( '$gradient_to_hex3: %s;', esc_attr( $gradient_color_hex3['to'] ) ); } else { echo '$gradient_to_hex3: #a3ff12;'; } // Gradient Color 4 foreach ($gradients4 as $key => $value) { printf('$gradient_%1$s: %2$s;', str_replace('-', '_', $key), 'var(--gradient-'.$key.')'); } $gradient_color_hex4 = alico_get_opt( 'gradient_color4' ); if ( !empty($gradient_color_hex4['from']) && isset($gradient_color_hex4['from']) ) { printf( '$gradient_from_hex4: %s;', esc_attr( $gradient_color_hex4['from'] ) ); } else { echo '$gradient_from_hex4: #006acc;'; } if ( !empty($gradient_color_hex4['to']) && isset($gradient_color_hex4['to']) ) { printf( '$gradient_to_hex4: %s;', esc_attr( $gradient_color_hex4['to'] ) ); } else { echo '$gradient_to_hex4: #01d5ff;'; } /* Font */ $body_default_font = alico_get_opt( 'body_default_font', 'Roboto' ); if ( isset( $body_default_font ) ) { echo ' $body_default_font: ' . esc_attr( $body_default_font ) . '; '; } $heading_default_font = alico_get_opt( 'heading_default_font', 'Poppins' ); if ( isset( $heading_default_font ) ) { echo ' $heading_default_font: ' . esc_attr( $heading_default_font ) . '; '; } return ob_get_clean(); } /** * Hooked wp_enqueue_scripts - 20 * Make sure that the handle is enqueued from earlier wp_enqueue_scripts hook. */ function enqueue() { $css = $this->inline_css(); if ( ! empty( $css ) ) { wp_add_inline_style( 'alico-theme', $this->dev_mode ? $css : alico_css_minifier( $css ) ); } } /** * Generate inline css based on theme options */ protected function inline_css() { ob_start(); /* Logo */ $logo_maxh = alico_get_opt( 'logo_maxh' ); if ( ! empty( $logo_maxh['height'] ) && $logo_maxh['height'] != 'px' ) { printf( '#ct-header-wrap .ct-header-branding a img { max-height: %s !important; }', esc_attr( $logo_maxh['height'] ) ); } ?> @media screen and (max-width: 1199px) { <?php $logo_maxh_sm = alico_get_opt( 'logo_maxh_sm' ); if ( ! empty( $logo_maxh_sm['height'] ) && $logo_maxh_sm['height'] != 'px' ) { printf( '#ct-header-wrap .ct-header-branding a img, .ct-header-mobile .ct-header-branding img { max-height: %s !important; }', esc_attr( $logo_maxh_sm['height'] ) ); } ?> } <?php /* End Logo */ /* Menu */ ?> @media screen and (min-width: 1200px) { <?php $main_menu_color = alico_get_opt( 'main_menu_color' ); if ( ! empty( $main_menu_color['regular'] ) ) { printf( '.ct-main-menu > li > a { color: %s !important; }', esc_attr( $main_menu_color['regular'] ) ); } if ( ! empty( $main_menu_color['hover'] ) ) { printf( '.ct-main-menu > li > a:hover { color: %s !important; }', esc_attr( $main_menu_color['hover'] ) ); } if ( ! empty( $main_menu_color['active'] ) ) { printf( '.ct-main-menu > li.current_page_item > a, .ct-main-menu > li.current-menu-item > a, .ct-main-menu > li.current_page_ancestor > a, .ct-main-menu > li.current-menu-ancestor > a { color: %s !important; }', esc_attr( $main_menu_color['active'] ) ); } $sticky_menu_color = alico_get_opt( 'sticky_menu_color' ); if ( ! empty( $sticky_menu_color['regular'] ) ) { printf( '#ct-header.h-fixed .ct-main-menu > li > a { color: %s !important; }', esc_attr( $sticky_menu_color['regular'] ) ); } if ( ! empty( $sticky_menu_color['hover'] ) ) { printf( '#ct-header.h-fixed .ct-main-menu > li > a:hover { color: %s !important; }', esc_attr( $sticky_menu_color['hover'] ) ); } if ( ! empty( $sticky_menu_color['active'] ) ) { printf( '#ct-header.h-fixed .ct-main-menu > li.current_page_item > a, #ct-header.h-fixed .ct-main-menu > li.current-menu-item > a, #ct-header.h-fixed .ct-main-menu > li.current_page_ancestor > a, #ct-header.h-fixed .ct-main-menu > li.current-menu-ancestor > a { color: %s !important; }', esc_attr( $sticky_menu_color['active'] ) ); } $sub_menu_color = alico_get_opt( 'sub_menu_color' ); if ( ! empty( $sub_menu_color['regular'] ) ) { printf( '#ct-header .ct-main-menu .sub-menu > li > a { color: %s !important; }', esc_attr( $sub_menu_color['regular'] ) ); } if ( ! empty( $sub_menu_color['hover'] ) ) { printf( '#ct-header .ct-main-menu .sub-menu > li > a:hover { color: %s !important; }', esc_attr( $sub_menu_color['hover'] ) ); printf( '#ct-header .ct-main-menu .sub-menu > li > a:before { background-color: %s !important; }', esc_attr( $sub_menu_color['hover'] ) ); } if ( ! empty( $sub_menu_color['active'] ) ) { printf( '#ct-header .ct-main-menu .sub-menu > li.current_page_item > a, #ct-header .ct-main-menu .sub-menu > li.current-menu-item > a, #ct-header .ct-main-menu .sub-menu > li.current_page_ancestor > a, #ct-header .ct-main-menu .sub-menu > li.current-menu-ancestor > a { color: %s !important; }', esc_attr( $sub_menu_color['active'] ) ); printf( '#ct-header .ct-main-menu .sub-menu > li.current_page_item > a:before, #ct-header .ct-main-menu .sub-menu > li.current-menu-item > a:before, #ct-header .ct-main-menu .sub-menu > li.current_page_ancestor > a:before, #ct-header .ct-main-menu .sub-menu > li.current-menu-ancestor > a:before { background-color: %s !important; }', esc_attr( $sub_menu_color['active'] ) ); } $menu_icon_color = alico_get_opt( 'menu_icon_color' ); if ( ! empty( $menu_icon_color ) ) { printf( '.ct-main-menu .link-icon { color: %s !important; }', esc_attr( $menu_icon_color ) ); } ?> } <?php /* End Menu */ /* Page Title */ $ptitle_bg = alico_get_page_opt( 'ptitle_bg' ); $custom_pagetitle = alico_get_page_opt( 'custom_pagetitle', 'themeoption' ); if ( $custom_pagetitle == 'show' && ! empty( $ptitle_bg['background-image'] ) ) { echo 'body .site #pagetitle.page-title { background-image: url(' . esc_attr( $ptitle_bg['background-image'] ) . '); }'; } if ( $custom_pagetitle == 'show' && ! empty( $ptitle_bg['background-color'] ) ) { echo 'body .site #pagetitle.page-title { background-color: '. esc_attr( $ptitle_bg['background-color'] ) .'; }'; } /* Custom Css */ $custom_css = alico_get_opt( 'site_css' ); if ( ! empty( $custom_css ) ) { echo esc_attr( $custom_css ); } return ob_get_clean(); } } new CSS_Generator();
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.81 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002