Skip to content

Instantly share code, notes, and snippets.

@starckio
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starckio/235defc20492bb8d1713 to your computer and use it in GitHub Desktop.
Save starckio/235defc20492bb8d1713 to your computer and use it in GitHub Desktop.
Reducing codes css in php for Kirby CMS.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title><?php echo $site->title()->html() ?> | <?php echo $page->title()->html() ?></title>
<meta name="description" content="<?php echo $site->description()->html() ?>">
<meta name="keywords" content="<?php echo $site->keywords()->html() ?>">
<?php include_once('minify.php') ?>
</head>
<body>
<header class="header cf" role="banner">
<a class="logo" href="<?php echo $site->language()->url() ?>">
<img src="<?php echo url('assets/images/logo.svg') ?>" alt="<?php echo $site->title()->html() ?>" />
</a>
<?php snippet('menu') ?>
</header>
<main class="main" role="main">
<div class="text">
<h1><?php echo $page->title()->html() ?></h1>
<?php echo $page->text()->kirbytext() ?>
</div>
</main>
<footer class="footer cf" role="contentinfo">
<p><?php echo l::get('made-with') ?></p>
</footer>
<?php echo js('assets/js/jquery-latest.min.js') ?>
<?php echo js('assets/js/scripts.js') ?>
</body>
</html>
<style media="all" rel="stylesheet" type="text/css">
<?php ob_start("minify");
function minify($buffer) {
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
$buffer = str_replace(array(' } ',' }','} ',';}'), '}', $buffer);
$buffer = str_replace(array(' { ',' {','{ '), '{', $buffer);
$buffer = str_replace(array(' : ',' :',': '), ':', $buffer);
return $buffer; }
include('assets/css/fonts.css');
include('assets/css/styles.css');
ob_end_flush(); ?>
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment