Skip to content

Instantly share code, notes, and snippets.

@starckio

starckio/header.php

Created May 4, 2017
Embed
What would you like to do?
Minimisation des fichiers CSS et affichage direct dans la balise <style></style>.
<!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() ?>">
<style>
<?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/main.css');
if($page->template() != 'default'){
include('assets/css/templates/' . $page->template() . '.css');
}
ob_end_flush(); ?>
</style>
</head>
<body>
<header class="header cf" role="banner">
<a class="logo" href="<?php echo url() ?>">
<img src="<?php echo url('assets/images/logo.svg') ?>" alt="<?php echo $site->title()->html() ?>" />
</a>
<?php snippet('menu') ?>
</header>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment