* @version 6.0 * @return void */ public static function menu(){ $option = config("theme_config"); if(!isset($option->homelinks)) return null; $menu = []; foreach(explode("\n", $option->homelinks) as $list){ if(empty($list)) continue; [$title, $link] = array_map('trim', explode("|", $list)); $menu[] = ['link' => $link, 'title' => $title]; } return $menu; } /** * Theme Settings * * @author GemPixel * @version 6.0 * @return void */ public static function settings(){ if(!$option = config("theme_config")){ $option = new \stdClass; } if(!isset($option->hero)) $option->hero = ""; if(!isset($option->siteimage)) $option->siteimage = ""; if(!isset($option->homeheader)) $option->homeheader = ""; if(!isset($option->homedescription)) $option->homedescription = ""; if(!isset($option->customfooter)) $option->customfooter = ""; if(!isset($option->homelinks)) $option->homelinks = ""; if(!isset($option->homestyle)) $option->homestyle = "default"; if(!isset($option->pricing)) $option->pricing = "list"; if(!isset($option->blog)) $option->blog = "list"; if(!isset($option->languageselector)) $option->languageselector = "bottom"; if(!isset($option->menutype)) $option->menutype = "hybrid"; if(!isset($option->colors)) { $option->colors = new \stdClass; $option->colors->primary = '#0088ff'; $option->colors->primaryalt = '#0065bd'; $option->colors->secondary = '#22cfff'; $option->colors->primarybg = '#f7f9fc'; $option->colors->darkbg = '#030122'; $option->colors->scrollbar = '#0088ff'; } if(!isset($option->colors->body)) $option->colors->body = '#ffffff'; if(!isset($option->colors->bodycolor)) $option->colors->bodycolor = '#343f52'; if(!isset($option->homepage)) $option->homepage = 'default'; CDN::load('coloris'); View::push("", 'custom')->toFooter(); View::push("", 'custom')->toHeader(); CDN::load('simpleeditor'); \Core\View::push("", "custom")->toFooter(); $content = '
'.e('Pre-defined Colors').'

'.e('You can choose from pre-defined colors to quickly apply to your theme.').'

'.e('Ocean Blue').' '.e('Default').'
'.e('Coral Sunset').' '.e('Warm').'
'.e('Royal Purple').' '.e('Elegant').'
'.e('Forest Green').' '.e('Natural').'
'.e('Midnight Dark').' '.e('Dark').'
'.e('Vibrant Pink').' '.e('Bold').'
'.e('Theme Colors').'

'.e('You can customize colors for front pages (home, pricing, blog etc). Some colors are already preset. You can either use colors from the palette (example #1 with #1 in all options) or mix and match. You can also use your own colors. After saving settings, if you do not see changes, you need to release browser cache. If you are using Cloudflare, you will need to purge cache as well.').'













'.(!empty($option->hero) ? '

':"").'
'.(!empty($option->hero) ? '' : '').'

'.e('This will replace the default hero image that comes shipped with the script. JPG or PNG. 500 kb max. Recommended size: 560x710').'

'.e('This will replace the home main header right before the shortener form. If you leave it empty, the site title will be shown.').'

'.e('This will replace the home main description right before the shortener form. If you leave it empty, the site description will be shown.').'

'.e('Choose which page to display when visitors go to your site root (homepage).').'

'.(!empty($option->siteimage) ? '

'.e('Remove').'

':"").'
'.(!empty($option->siteimage) ? '' : '').'

'.e('This will be used as default OG image unless override by pages.').'

'.e('You can add custom links to the menu using the following format (one per line): TITLE|LINK').'

'.e('You can add custom footer to the page. This will be shown at the bottom of the page.').'

'.csrf().'
Help

HTML Usage

You can use the following HTML elements: '.htmlentities("


").'

Translating Strings

If you add a new title or a new description, you can still translate them to any language by simply adding it via the language manager.

Auto Mode

If you choose the Auto Mode, the color scheme will change based on the user browser or device preference.

Home Header

You can add your custom header and description for the homepage. To use the typing animation use the following format:

<span class="gradient-primary clip-text" data-toggle="typed" data-list="Links,Bio Pages, QR Codes"></span>
Menu Link

You can add custom links to the menu using the following format (one per line): TITLE|LINK

Example

Support|https://support.gempixel.com
Blog|https://gempixel.com/blog

You can add as much as you want however you need to make sure it does not break the template

'; return $content; } /** * Update * * @author GemPixel * @version 6.0 * @return void */ public function update(){ \Gem::addMiddleware('DemoProtect'); $option = config("theme_config"); $request = new \Core\Request; $data = []; $data['hero'] = $option->hero ?? ''; $data['siteimage'] = $option->siteimage ?? ''; $data['homeheader'] = Helper::clean($request->homeheader); $data['homedescription'] = $request->homedescription; $data['customfooter'] = $request->customfooter; $data['homestyle'] = Helper::clean($request->homestyle, 3); $data['homepage'] = Helper::clean($request->homepage, 20); if(!in_array($data['homepage'], ['default', 'bio', 'link', 'qr'])) $data['homepage'] = 'default'; $data['homelinks'] = Helper::clean($request->homelinks, 3); $data['homecolor'] = Helper::clean($request->homecolor, 3); $data['pricing'] = Helper::clean($request->pricing, 3); $data['languageselector'] = Helper::clean($request->languageselector, 3); $data['menutype'] = Helper::clean($request->menutype, 3); $data['blog'] = Helper::clean($request->blog, 3); $data['colors'] = [ 'body' => '#ffffff', 'body-color' => '#343f52', 'primary' => '#0088ff', 'primaryalt' => '#0065bd', 'secondary' => '#22cfff', 'primarybg' => '#f7f9fc', 'darkbg' => '#030122', 'scrollbar' => '#0088ff' ]; $data['cssname'] = strtolower(Helper::rand(12)); foreach($request->colors as $name => $color){ if(strlen(trim($color)) == 7) $data['colors'][$name] = trim(clean($color)); } if($request->remove_logo){ if(isset($option->hero) && !empty($option->hero) && file_exists(appConfig('app.storage')['uploads']['path'].'/'.$option->hero)){ unlink(appConfig('app.storage')['uploads']['path'].'/'.$option->hero); } $data['hero'] = null; } if($image = $request->file('hero')){ if(!$image->mimematch || !in_array($image->ext, ['jpg', 'png'])) return Helper::redirect()->back()->with('danger', e('The custom image is not valid. Only a JPG or PNG are accepted.')); if($image->sizekb > 500) return Helper::redirect()->back()->with('danger', e('Custom image must be either a PNG or a JPEG (Max 500kb).')); $filename = Helper::rand(6)."_hero_".$image->name; if(isset($option->hero) && !empty($option->hero) && file_exists(appConfig('app.storage')['uploads']['path'].'/'.$option->hero)){ unlink(appConfig('app.storage')['uploads']['path'].'/'.$option->hero); } $request->move($image, appConfig('app.storage')['uploads']['path'], $filename); $data['hero'] = $filename; } if($request->remove_siteimage){ if(isset($option->siteimage) && !empty($option->siteimage) && file_exists(appConfig('app.storage')['uploads']['path'].'/'.$option->siteimage)){ unlink(appConfig('app.storage')['uploads']['path'].'/'.$option->siteimage); } $data['siteimage'] = null; } if($image = $request->file('siteimage')){ if(!$image->mimematch || !in_array($image->ext, ['jpg', 'png'])) return Helper::redirect()->back()->with('danger', e('The custom image is not valid. Only a JPG or PNG are accepted.')); if($image->sizekb > 500) return Helper::redirect()->back()->with('danger', e('Custom image must be either a PNG or a JPEG (Max 500kb).')); $filename = Helper::rand(6)."_siteimage_".$image->name; if(isset($option->siteimage) && !empty($option->siteimage) && file_exists(appConfig('app.storage')['uploads']['path'].'/'.$option->siteimage)){ unlink(appConfig('app.storage')['uploads']['path'].'/'.$option->siteimage); } $request->move($image, appConfig('app.storage')['uploads']['path'], $filename); $data['siteimage'] = $filename; } if($request->homestyle == "darkmode"){ $request->cookie('darkmode', 1); } else { $request->cookie('darkmode', 1, -3600); } $setting = DB::settings()->where('config', 'theme_config')->first(); $setting->var = json_encode($data); $setting->save(); self::cssVariables($data['colors'], $data['cssname']); return Helper::redirect()->back()->with('success', e('Settings are successfully saved.')); } /** * Generate CSS variables * * @author GemPixel * @version 7.0 * @param array $variables * @return void */ private static function cssVariables(array $variables, string $cssname){ $variables['primarybgrgb'] = implode(', ', sscanf($variables['primarybg'], "#%02x%02x%02x")); $variables['darkbgrgb'] = implode(', ', sscanf($variables['darkbg'], "#%02x%02x%02x")); $variables['liquidrgb'] = implode(', ', array_merge(sscanf($variables['body'], "#%02x%02x%02x"), [0.8])); $variables['darkbg'] = implode(', ', sscanf($variables['darkbg'], "#%02x%02x%02x")); $data = ":root{--body: {$variables['body']};--body-color: {$variables['body-color']};--hamburger-color: {$variables['body-color']};--bs-primary: {$variables['primary']};--bs-primary-alt: {$variables['primaryalt']};--bs-secondary: {$variables['secondary']};--bg-primary: {$variables['primarybg']};--bg-secondary: {$variables['secondary']};--bs-primary-rgb: {$variables['primarybgrgb']};--scrollbar-color: {$variables['scrollbar']};--bg-header: rgba({$variables['liquidrgb']});--bs-link-color: var(--bs-primary);--bs-link-hover-color: var(--bs-primary-alt);--bs-dark-rgb:{$variables['darkbgrgb']};--bg-liquid: rgba({$variables['liquidrgb']});--bs-dark-rgb: {$variables['darkbg']};}"; $config = config("theme_config"); if(isset($config->cssname) && $config->cssname != $cssname){ if(file_exists(PUB.'/content/'.$config->cssname.'.css')){ unlink(PUB.'/content/'.$config->cssname.'.css'); } } if($css = fopen(PUB.'/content/'.$cssname.'.css', 'w')){ fwrite($css, $data); fclose($css); } } /** * Theme Config * * @author GemPixel * @version 6.3 * @param string $name * @return void */ public static function config(string $name, $is = null, $set = null, $default = null){ $config = config("theme_config"); if($name == 'title'){ return (isset($config->homeheader) && $config->homeheader ? e($config->homeheader) : config('title')); } if($name == 'description'){ return (isset($config->homedescription) && $config->homedescription ? e($config->homedescription) : e(config('description'))); } if($name == 'homecolor'){ if(isset($config->homecolor) && $config->homecolor->type == 'custom' && $config->homestyle != 'darkmode' && !request()->cookie('darkmode')){ return 'style="background: linear-gradient(220.55deg, '.$config->homecolor->c2.' 0%, '.$config->homecolor->c1.' 100%) !important;"'; } return null; } if($name == "homestyle") { if(!isset($config->homestyle)) return $default; if( $config->homestyle == $is && !request()->cookie('darkmode') && $set) return $set; if( $config->homestyle == $is) return true; return $default; } if($name == "pricing") { if(isset($config->pricing)){ if($config->pricing == $is) return $set; return $config->pricing; } return 'list'; } if($is) return isset($config->{$name}) && $config->{$name} == $is; return $config->{$name} ?? null; } /** * Is Dark Mode or Dark Theme * * @author GemPixel * @version 6.6 * @param [type] $return * @return boolean */ public static function isDark($return = null){ $config = config("theme_config"); $isdark = request()->cookie('darkmode') || (isset($config->homestyle) && $config->homestyle == 'darkmode'); return $return && $isdark ? $return : $isdark; } }