Skip to content

Instantly share code, notes, and snippets.

Nico Martin nico-martin

Block or report user

Report or block nico-martin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View loadfonts.js
function loadFont(t, e, n) {
return new Promise(resolve => {
const a = navigator.userAgent;
if (window.addEventListener && (!a.match(/(Android (2|3|4.0|4.1|4.2|4.3))|(Opera (Mini|Mobi))/) || a.match(/Chrome/))) {
let o = {};
try {
o = localStorage || {}
} catch (t) {}
const r = t, i = r + "url", s = r + "css", d = o[i], c = o[s], l = document.createElement("style");
if (l.rel = "stylesheet", document.head.appendChild(l), !c || d !== e && d !== n) {
nico-martin / .htaccess
Last active Jun 13, 2019
Cache-Control headers
View .htaccess
<ifModule mod_headers.c>
# One year for image and video files
<filesMatch ".(flv|gif|ico|jpg|jpeg|mp4|mpeg|png|svg|swf|webp)$">
Header set Cache-Control "max-age=31536000, public"
# One month for JavaScript and PDF files
<filesMatch ".(js|pdf)$">
Header set Cache-Control "max-age=2592000, public"
nico-martin / ServerSideRender.jsx
Last active Jun 26, 2019
ServerSideRender block
View ServerSideRender.jsx
const {ServerSideRender} = wp.components;
wp.blocks.registerBlockType('test/ssr', {
title: 'Post Archiv',
icon: 'grid-view',
category: 'my-category',
edit(props) {
return <ServerSideRender block="test/ssr"/>
save() {
nico-martin / block-ssr.js
Last active Jun 26, 2019
This is an example of a server side rendered block without any build step. It's all plain JS/PHP and it uses the helpers and components WordPress already offers in the block admin interface.
View block-ssr.js
(function (blocks, components, element) {
blocks.registerBlockType('test/ssr', {
title: 'Server Side Rendered Block',
icon: 'admin-site-alt3',
category: 'test',
edit: function (props) {
return element.createElement(components.ServerSideRender, {block: 'test/ssr'});
save: function () {
return null;
nico-martin / InnerBlock-renderAppender-block.jsx
Last active Jul 9, 2019
Gutenberg InnerBlock with renderAppender
View InnerBlock-renderAppender-block.jsx
const {TextControl, IconButton} = wp.components;
const {InnerBlocks} = wp.editor;
const {__} = wp.i18n;
const {dispatch} =;
const {createBlock, registerBlockType} = wp.blocks;
registerBlockType('prefix/container', {
title: 'Container',
icon: 'category',
category: 'category',
You can’t perform that action at this time.