Skip to content

Instantly share code, notes, and snippets.

View evemilano's full-sized avatar

Giovanni Sacheli evemilano

View GitHub Profile
@evemilano
evemilano / Redirezioni di massa verso un altro dominio
Created December 17, 2014 22:37
Redirezioni di massa verso un altro dominio
RewriteEngine on
# Redirect to another domain: www.sitodidestinazione.it.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^(www\.)?sitodidestinazione\.it$ [NC]
RewriteRule .* http://www.sitodidestinazione.it%{REQUEST_URI} [R=301,L]
# Same for HTTPS:
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^(www\.)?sitodidestinazione\.it$ [NC]
RewriteRule .* https://www.sitodidestinazione.it%{REQUEST_URI} [R=301,L]
@evemilano
evemilano / external-link-blank
Last active April 24, 2019 10:11
WordPress plugin to open all external file in _blank page
@evemilano
evemilano / Da usare nel file functions.php
Last active December 17, 2018 19:16
Come disabilitare le Rest API di WordPress
/* 410 STATUS CODE */
add_filter( 'rest_authentication_errors', function( $result ) {
if ( ! empty( $result ) ) {
return $result;
}
if ( ! is_user_logged_in() ) {
return new WP_Error( 'rest_not_logged_in', 'You are not currently logged in.', array( 'status' => 401 ) );
}
return $result;
});
@evemilano
evemilano / Installazione Official GoAccess Ubuntu Repository
Last active December 6, 2018 14:14
Installazione Official GoAccess Ubuntu Repository
#Official GoAccess' Debian/Ubuntu Repository
echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list
wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install goaccess
# UBUNTU EASY INSTALL
apt-get install goaccess
@evemilano
evemilano / WordPress: HTML default editor
Last active October 24, 2018 13:53
WordPress: HTML default editor
# Questa regola imposta come default l'editor HTML
add_filter( 'wp_default_editor', create_function('', 'return "html";') );
# Questa regola imposta come default l'editor visuale
add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );
@evemilano
evemilano / JSON-LD
Created October 11, 2018 20:39
Breadcrumb Schema.org Markup JSON-LD
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"name": "Books",
"item": "https://example.com/books"
},{
@evemilano
evemilano / Microdata
Created October 11, 2018 19:39
Breadcrumb Schema.org Markup Microdata
<ol vocab="http://schema.org/" typeof="BreadcrumbList">
<li property="itemListElement" typeof="ListItem">
<a property="item" typeof="WebPage"
href="https://example.com/books">
<span property="name">Books</span></a>
<meta property="position" content="1">
</li>
<li property="itemListElement" typeof="ListItem">
<a property="item" typeof="WebPage"
@evemilano
evemilano / RDFA
Last active October 11, 2018 20:01
Breadcrumb Schema.org Markup RDFA
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemtype="http://schema.org/Thing"
itemprop="item" href="https://example.com/books">
<span itemprop="name">Books</span></a>
<meta itemprop="position" content="1" />
</li>
<li itemprop="itemListElement" itemscope
@evemilano
evemilano / Add this to the functions.php
Last active August 9, 2018 14:05
Add Defer & Async Attributes to many WordPress Script
function add_defer_attribute($tag, $handle) {
// add script handles to the array below
$scripts_to_defer = array('jquery-migrate', 'hoverIntent', 'superfish', 'superfish-args', 'skip-links', 'wp-embed');
foreach($scripts_to_defer as $defer_script) {
if ($defer_script === $handle) {
return str_replace(' src', ' defer="defer" src', $tag);
}
}
return $tag;
@evemilano
evemilano / eve_meta.php
Last active July 19, 2018 08:12
WordPress Plugin - Dynamic Open Graph markup injector
<?php
/*
Plugin Name: EVE OG Injector
Plugin URI: https://www.evemilano.com/
Version: 3.6 - 20171128
Description: Inject dynamic Open Graph into HTML head
Author: Giovanni Sacheli
Author URI: https://www.evemilano.com/
*/