Skip to content

Instantly share code, notes, and snippets.

@samikeijonen samikeijonen/sanse-100.php
Last active May 24, 2017

Embed
What would you like to do?
You want Sanse theme to get 100/100 in Google Page Speed? No problem. With this plugin theme styles are placed inline in the header, and we're done.
<?php
/**
* Plugin Name: Sanse 100
* Plugin URI: https://foxland.fi/
* Description: Load Sanse theme styles inline in the header.
* Version: 1.2.1
* Author: Sami Keijonen
* Author URI: http://foxnet.fi/
* Text Domain: sanse-100
* Domain Path: /languages
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License version 2, as published by the Free Software Foundation. You may NOT assume
* that you can use any other version of the GPL.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @package Sanse100
* @author Sami Keijonen <sami.keijonen@foxnet.fi>
* @copyright Copyright (c) 2016, Sami Keijonen
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Dequeue Sanse theme styles.
*/
function sanse_100_scripts() {
// Dequeue theme styles.
wp_dequeue_style( 'sanse-style' );
}
add_action( 'wp_enqueue_scripts', 'sanse_100_scripts', 11 );
/**
* Add styles inline in the header.
*/
function sanse_100_add_inline_styles() {
$style = '';
$style .= '
html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:0}hr{box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}body,button,input,select,textarea{color:#404040;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:1em;line-height:1.5;word-wrap:break-word}.site-title,h1,h2,h3,h4,h5,h6{clear:both;color:#000;font-weight:700;line-height:1.2;letter-spacing:.05em;margin:0 0 .62429507697em}.entry-title,.site-title{text-transform:uppercase}.site-title{margin-bottom:.30794614765em}.site-title a{text-decoration:none}.entry-content h2,.entry-content h3,.entry-content h4,.entry-content h5,.entry-content h6{margin-top:1.424em}.site-description{font-size:.875em;font-style:italic;line-height:1;margin-bottom:0}.site-title,h1{font-size:1.602em}h2{font-size:1.5em}.comment-reply-title,.comments-title,.widget-title,.widgettitle,h3{font-size:1.424em}.entry-inner .entry-title,.front-page-content .entry-content,h4{font-size:1.265625em}.footer-widgets-wrapper .widget-title,.front-page-blog .entry-inner .entry-title,h5{font-size:1.125em}h6{font-size:1em}@media screen and (min-width:58.875em){body,button,input,select,textarea{font-size:1.125em}h1{font-size:1.802em}h2{font-size:1.602em}.comment-reply-title .widget-title,.comments-title,.widgettitle,h3{font-size:1.5em}.entry-inner .entry-title,h4{font-size:1.424em}.footer-widgets-wrapper .widget-title,.front-page-blog .entry-inner .entry-title,h5{font-size:1.265625em}h6{font-size:1.125em}}.mejs-container,p{margin:0 0 1.5em}cite,dfn,em,i{font-style:italic}blockquote{margin:0 1.5em}address{margin:0 0 1.5em}pre{background:#f0f0f0;font-family:Courier\ 10 Pitch,Courier,monospace;font-size:.9375em;line-height:1.6;margin-bottom:1.6em;max-width:100%;overflow:auto;padding:1.6em;word-wrap:normal}code,kbd,tt,var{font-family:Monaco,Consolas,Andale Mono,DejaVu Sans Mono,monospace;font-size:.9375em}abbr,acronym{border-bottom:1px dotted #666;cursor:help}ins,mark{background:#fff9c0;text-decoration:none}big{font-size:125%}html{box-sizing:border-box}*,:after,:before{box-sizing:inherit}body{background:#f0f0f0}blockquote:after,blockquote:before,q:after,q:before{content:""}blockquote,q{quotes:"" ""}blockquote{border-left:4px solid #000;font-size:1.125em;font-style:italic;padding-left:1.125em;margin:0 0 1.333333333em}blockquote p:last-child,q p:last-child{margin-bottom:0}hr{background-color:#ccc;border:0;height:2px;margin-bottom:1.5em}ol,ul{padding:0;margin:0 0 1.5em 1.5em}ul{list-style:disc}ol{list-style:decimal}li>ol,li>ul{padding-left:1em;margin-bottom:0;margin-left:1em}dt{font-weight:700}dd{margin:0 1.5em 1.5em}img{height:auto;max-width:100%}table,td,th{border:1px solid #ccc}table{border-collapse:separate;border-spacing:0;border-width:1px 0 0 1px;margin:0 0 1.5em;table-layout:fixed;width:100%}caption,td,th{font-weight:400;text-align:left}th{font-weight:700}td,th{border-width:0 1px 1px 0}td,th{padding:.44444444em}a.button,button,input[type=button],input[type=reset],input[type=submit]{background-color:#ffcd00;border:0;color:#000;font-size:.88888888888em;line-height:1;padding:1em 1.424em;text-transform:uppercase;transition:all .2s ease-in-out}a.button,button,input[type=button],input[type=reset],input[type=submit],label{font-weight:700;letter-spacing:1px}.comment-form input[type=submit]{margin-bottom:1.802em}a.button:active,a.button:focus,a.button:hover,button:active,button:focus,button:hover,input[type=button]:active,input[type=button]:focus,input[type=button]:hover,input[type=reset]:active,input[type=reset]:focus,input[type=reset]:hover,input[type=submit]:active,input[type=submit]:focus,input[type=submit]:hover{background-color:#000;color:#ffcd00}a.button:focus,button:focus,input[type=button]:focus,input[type=reset]:focus,input[type=submit]:focus{outline:1px dotted;outline-offset:-2px}a.button{display:block}.menu-toggle{border:2px solid #000;margin:1em auto 0}.no-header-text .menu-toggle{margin-top:0}input[type=color],input[type=date],input[type=datetime-local],input[type=datetime],input[type=email],input[type=month],input[type=number],input[type=password],input[type=range],input[type=search],input[type=tel],input[type=text],input[type=time],input[type=url],input[type=week],select,textarea{border:1px solid #ccc;padding:.44444444444em;transition:all .25s ease-in-out;width:100%}.search-field,input[name=post_password]{margin-bottom:.62429507697em}.error404 .search-form{margin-bottom:1.5em}input[type=color]:focus,input[type=date]:focus,input[type=datetime-local]:focus,input[type=datetime]:focus,input[type=email]:focus,input[type=month]:focus,input[type=number]:focus,input[type=password]:focus,input[type=range]:focus,input[type=search]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=time]:focus,input[type=url]:focus,input[type=week]:focus,select:focus,textarea:focus{border-color:#000;outline:0}a,a:visited{color:#000;transition:all .25s ease-in-out;text-decoration:none}.footer-widgets-wrapper a,.site-info a{color:#ccc}.site-info a{font-style:italic}.entry-content a,.entry-meta a,.entry-summary a,.site-info a,.taxonomy-description a,.widget a{border-bottom:2px solid #ffcd00}.entry-meta a{border-bottom-color:#f0f0f0}.entry-content .gallery-icon a,.entry-content .mejs-horizontal-volume-slider,.footer-widgets-wrapper a,a.button{border-bottom:none}a:active,a:focus,a:hover{color:#404040}.footer-widgets-wrapper a:active,.footer-widgets-wrapper a:focus,.footer-widgets-wrapper a:hover,.site-info a:active,.site-info a:focus,.site-info a:hover{color:#fff}a:focus{outline:thin dotted}a:active,a:hover{outline:0}.entry-title a{text-decoration:none}.main-navigation{position:relative;text-transform:uppercase}.main-navigation ul{list-style:none;margin:0;padding-left:0;display:none}.no-js .main-navigation ul{display:block}.main-navigation.toggled{margin-left:-1em;margin-right:-1em}.main-navigation.toggled .primary-menu-wrapper{position:absolute;background-color:#ffcd00;width:100%;z-index:1000}.main-navigation li{border-bottom:1px solid #000;display:block;padding-left:5%;padding-right:5%;position:relative}.main-navigation .sub-menu li{border-bottom:none}.main-navigation a{display:block;font-size:.88888888em;font-weight:700;line-height:1.3125;outline-offset:-1px;padding:.84375em 0;text-decoration:none}.main-navigation .sub-menu a{padding:.25em 0;text-transform:none}.main-navigation .current-menu-ancestor>a,.main-navigation .current-menu-item>a,.main-navigation a:active,.main-navigation a:focus,.main-navigation a:hover{color:#404040}.main-navigation ul ul{display:none;margin-bottom:.875em}.main-navigation.toggled ul,.main-navigation ul .toggled-on,.menu-toggle,.no-js .main-navigation ul ul{display:block}@media screen and (min-width:62.875em){.menu-toggle{display:none}.main-navigation ul{display:block}.main-navigation{padding-left:5%;padding-right:5%;padding-top:.88888888888em;margin:0;text-align:center}.no-header-text .main-navigation{padding-top:0}.main-navigation li{padding-left:0;padding-right:0}.main-navigation .primary-menu,.main-navigation .primary-menu>li{border:0}.main-navigation .primary-menu>li,.main-navigation a{display:inline-block}.main-navigation .sub-menu a,.main-navigation a{padding:.65625em}.main-navigation .sub-menu a{padding:.70233196159em}.main-navigation ul ul{background-color:#ffcd00;border:1px solid #000;border-bottom:none;display:block;left:-999em;margin:0;opacity:0;position:absolute;transition-property:opacity;transition-duration:.25s;transition-delay:.25s;transition:opacity .3s ease-in-out;z-index:99999}.main-navigation ul ul ul{top:0}.main-navigation ul ul ul:after,.main-navigation ul ul ul:before{border:0}.main-navigation .sub-menu li,.main-navigation ul ul li{border-bottom:1px solid #484653}.main-navigation ul ul a{width:13.6875em}.main-navigation li.focus>ul,.main-navigation li:hover>ul{right:auto;left:0;opacity:1}.main-navigation ul ul li.focus>ul,.main-navigation ul ul li:hover>ul{right:auto;left:100%}.main-navigation .menu-item-has-children>a{margin:0}.main-navigation ul ul .menu-item-has-children>a{padding-right:2.0625em}}.menu-social{padding-bottom:1.5em}.menu-social ul{list-style:none;padding:0;margin:0 0 -.49327018427em}.menu-social li{display:inline-block;padding-left:.49327018427em;margin-bottom:.62429507697em}.menu-social li:first-child{padding-left:0}.menu-social a{background-color:#ffcd00;border-bottom:none;border-radius:4px;color:#000;display:block;width:3em;height:3em}.menu-social a:active,.menu-social a:focus,.menu-social a:hover{background-color:#fff;color:#000}.menu-social a:focus{outline-offset:-4px}.menu-social .icon{width:2em;height:2em;top:.5em}.page-header,.pagination,.post-navigation{text-align:center}.footer-widgets-wrapper:after,.page-header:after,.pagination:before,.post-navigation .nav-previous~.nav-next:before,.post-navigation:before,.single .entry-header:after,body.page .entry-header:after{border-bottom:2px solid #ffcd00;content:"";display:block;margin:0 auto 1.5em;width:60px}.front-page-blog .page-header:after,.post-navigation .nav-previous~.nav-next:before{border-bottom-color:#ccc;margin-top:1.5em}.single .entry-header:after,body.page .entry-header:after{margin-top:1.5em;margin-bottom:1.802em}.footer-widgets-wrapper:after{margin-top:1.5em;margin-bottom:3em}body.page .front-page-blog .entry-header:after{display:none}.pagination .page-numbers{padding:.30794614765em}.pagination .page-numbers.dots{padding:0}.post-navigation .meta-nav{display:block;font-size:.8888888888em;font-weight:700;letter-spacing:1px;text-transform:uppercase}.post-navigation .post-title{font-style:italic}.post-navigation .nav-previous .icon{margin-right:.30794614765em}.post-navigation .nav-next .icon{margin-left:.30794614765em}.site-main .comment-navigation,.site-main .post-navigation{overflow:hidden}@media screen and (min-width:62.875em){.post-navigation{text-align:left}.comment-navigation .nav-previous,.post-navigation .nav-previous{float:left;width:50%}.comment-navigation .nav-next,.post-navigation .nav-next{float:right;text-align:right;width:50%}.post-navigation .nav-previous~.nav-next:before{display:none}}.screen-reader-text{clip:rect(1px,1px,1px,1px);position:absolute!important;height:1px;width:1px;overflow:hidden}.screen-reader-text:focus{background-color:#000;clip:auto!important;color:#ffcd00;display:block;font-size:.8888888888em;font-weight:700;height:auto;left:5px;line-height:normal;padding:15px 23px 14px;text-decoration:none;top:5px;width:auto;z-index:100000}#main[tabindex="-1"]:focus{outline:0}.alignleft{float:left;margin-right:1.5em}.alignleft,.alignright{display:inline;margin-bottom:1em}.alignright{float:right;margin-left:1.5em}.aligncenter{clear:both;display:block;margin-left:auto;margin-right:auto}.clear:after,.clear:before,.comment-content:after,.comment-content:before,.entry-content:after,.entry-content:before,.site-content:after,.site-content:before,.site-footer:after,.site-footer:before,.site-header:after,.site-header:before{content:"";display:table;table-layout:fixed}.clear:after,.comment-content:after,.entry-content:after,.site-content:after,.site-footer:after,.site-header:after{clear:both}.widget{margin:0 0 1.5em}.footer-widgets-wrapper ol,.footer-widgets-wrapper ul,.front-page-widgets-wrapper ol,.front-page-widgets-wrapper ul{list-style-type:none;margin-left:0}.footer-widgets-wrapper li,.front-page-widgets-wrapper li{padding-bottom:.19224926395em}.footer-widgets-wrapper .widget-title{color:#ffcd00}.front-page-widgets-wrapper{padding-bottom:1.5em}.front-page-widget-area>.widget:first-of-type{background-color:#f0f0f0;padding:1.5em;margin-bottom:3em;text-align:center}.widget select{max-width:100%}.comment-respond,.comments-area,.content-area,.entry-content,.entry-footer,.entry-header,.entry-meta,.entry-summary,.site-info,.site-main,.widget-inner-wrapper,.wrapper{margin-left:auto;margin-right:auto;max-width:1220px}.site-main{padding-bottom:1.5em;margin-bottom:3em;max-width:820px}.entry-header{text-align:center}.entry-inner .entry-header{text-align:left}.comment-respond,.comments-area,.entry-content,.entry-footer,.entry-inner .entry-header,.entry-inner .entry-meta,.entry-summary,.footer-widgets-1 .footer-widgets-wrapper .wrapper,.widget-inner-wrapper{max-width:620px}.content-area{background-color:#fff;border-top:.38974434312em solid #000;padding:7.5% 1em 0;margin-top:-350px}.hero{background-color:#ffcd00;min-height:350px}@media screen and (min-width:1260px){.custom-header-image .hero{background-position:50%;background-repeat:no-repeat;background-size:cover;min-height:400px}}.site-header{background-color:#ffcd00;padding:1em;text-align:center}.site-footer{background-color:#000;color:#fff;padding:3em 1.5em}.site-info{text-align:center}.grid-wrapper,.grid-wrapper>.hentry,.grid-wrapper>.hentry>.entry-inner{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.grid-wrapper>.hentry>.entry-inner{-ms-flex-direction:column;flex-direction:column}.grid-wrapper>*,.grid-wrapper>.hentry>*,.grid-wrapper>.hentry>.entry-inner>*{width:100%}.entry-inner>.entry-meta{margin-top:auto}.grid-wrapper>.hentry{padding-bottom:1.5em}@media screen and (min-width:56em){.grid-wrapper{margin-left:-1.5em}.grid-wrapper>.hentry{padding-left:1.5em;width:50%}.footer-widgets-wrapper .widget-area{padding-left:1.5em}.footer-widgets-2 .footer-widgets-wrapper .widget-area{width:50%}.footer-widgets-3 .footer-widgets-wrapper .widget-area{width:33.3333333333%}}.sticky{display:block}.hentry{margin:0 0 1.5em}.byline,.updated:not(.published){display:none}.group-blog .byline,.single .byline{display:inline}.byline,.posted-on{font-size:.88888888em;font-style:italic;letter-spacing:1px}.byline .url,.entry-date{font-style:normal;text-transform:uppercase}.entry-content,.entry-summary,.page-content{margin-bottom:1.5em}.entry-inner .entry-summary{margin-bottom:0}.entry-footer{padding-bottom:1.5em}.entry-terms-wrapper{font-size:.888888888em;font-weight:600}.entry-tags-wrapper{clear:both}.entry-terms>a{background-color:#f0f0f0;border-radius:2px;color:#404040;display:block;float:left;line-height:1.75em;height:1.75em;padding:0 .38974434312em;margin-right:.38974434312em;margin-bottom:.38974434312em;text-transform:capitalize;transition:all .25s ease-in-out}.entry-terms>a:active,.entry-terms>a:focus,.entry-terms>a:hover{background-color:#000;color:#fff}.entry-terms>a:focus{outline-offset:-2px}.page-links{clear:both;margin:0 0 1.5em}.taxonomy-description{font-style:italic}.comments-area{padding-top:3em;padding-bottom:1.5em}.comment-list+.comment-respond,.comment-navigation+.comment-respond{padding-top:1.5em}.comment-reply-title,.comments-title{font-weight:400;letter-spacing:2px;line-height:1.25;margin-bottom:0;text-align:center;text-transform:uppercase}.comments-title{margin-bottom:1.266em}.comment-list{list-style:none;margin:0}.comment-list .pingback,.comment-list .trackback,.comment-list article{padding:1.802em 0}.comment-list .children{list-style:none;margin:0}.comment-author{margin-bottom:.25em}.comment-author .avatar{border-radius:4px;float:left;height:60px;margin-top:-.151900653em;margin-right:1em;position:relative;width:60px}.comment-author .says{display:none}.comment-metadata,.pingback .edit-link{font-size:.88888888em}.comment-metadata{margin-bottom:1.602em}.comment-metadata .edit-link,.pingback .edit-link{display:inline-block;margin-top:0}.comment-metadata .edit-link:before,.pingback .edit-link:before{content:"\002f";display:inline-block;opacity:.7;padding:0 .538461538em}ol.comment-list ol.children{padding-left:3%}.comment-reply-link{display:inline-block;font-size:.888888888888em;font-weight:700;letter-spacing:1px;text-transform:uppercase}.comment-reply-link .icon{margin-left:.24331547469em}.comment-form{padding-top:1.75em}.comment-form label{display:block;font-size:14px;font-size:.875rem;letter-spacing:.076923077em;text-transform:uppercase}.comment-list .comment-form{padding-bottom:1.75em}.comment-awaiting-moderation,.comment-notes,.form-allowed-tags,.logged-in-as,.no-comments{font-style:italic;margin-bottom:1.75em;text-align:center}.comment-navigation+.no-comments{border-top:0;padding-top:0}.comment-content .wp-smiley,.entry-content .wp-smiley,.page-content .wp-smiley{border:none;margin-bottom:0;margin-top:0;padding:0}embed,iframe,object{max-width:100%}.custom-logo{margin-bottom:.38974434312em}.icon{display:inline-block;fill:currentColor;height:1em;width:1em;vertical-align:middle;position:relative;top:-.0625em}.icon-wrapper{background-color:#f0f0f0;border-radius:2px;display:block;float:left;margin-right:.38974434312em;width:1.75em;height:1.75em}.icon-wrapper>.icon{left:.5em;top:.5em;width:.75em;height:.75em;vertical-align:top}.wp-caption{margin-bottom:1em;max-width:100%}.wp-caption img[class*=wp-image-]{display:block;margin-left:auto;margin-right:auto}.wp-caption .wp-caption-text{margin:.8888888em 0}.wp-caption-text{font-style:italic;text-align:center}.gallery{margin-bottom:1.5em}.gallery-item{display:inline-block;text-align:center;vertical-align:top;width:100%}.gallery-columns-2 .gallery-item{max-width:50%}.gallery-columns-3 .gallery-item{max-width:33.33%}.gallery-columns-4 .gallery-item{max-width:25%}.gallery-columns-5 .gallery-item{max-width:20%}.gallery-columns-6 .gallery-item{max-width:16.66%}.gallery-columns-7 .gallery-item{max-width:14.28%}.gallery-columns-8 .gallery-item{max-width:12.5%}.gallery-columns-9 .gallery-item{max-width:11.11%}.gallery-caption{display:block}
';
echo "\n" . '<style type="text/css" id="sanse-100-css">' . trim( str_replace( array( "\r", "\n", "\t", " " ), '', $style ) ) . '</style>' . "\n";
}
add_action( 'wp_head', 'sanse_100_add_inline_styles' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.