Skip to content

Instantly share code, notes, and snippets.

View evemilano's full-sized avatar

Giovanni Sacheli evemilano

View GitHub Profile
@evemilano
evemilano / external-link-blank
Last active April 24, 2019 10:11
WordPress plugin to open all external file in _blank page
@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 / redirect HTTP to HTTPS
Created July 17, 2018 22:47
Nginx HTTP to HTTPS 301 redirect
#blocco di redirect HTTP
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name www.evemilano.com evemilano.com;
return 301 https://www.evemilano.com$request_uri;
}
#blocco di redirect IP
server {
@evemilano
evemilano / HTTPS Virtual Host NGINX sites-available
Created July 17, 2018 22:44
Configurazione Virtual Host Nginx evemilano.com
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m use_temp_path=off;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
# 201803 aggiunto
add_header X-Cache $upstream_cache_status;
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
@evemilano
evemilano / server
Last active July 18, 2018 21:12
Nginx basic server block with HTTPS and Cache
fastcgi_cache_path /etc/nginx/cache/1 levels=1:2 keys_zone=CACHESITO:10m max_size=50m inactive=1440m use_temp_path=off;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
add_header X-Cache $upstream_cache_status;
server {
listen 80;
listen [::]:80;
#redirect to HTTPS
@evemilano
evemilano / redirect not www to www
Last active July 17, 2018 22:42
Nginx www and not www 301 redirect
#blocco di redirect
server {
listen 80;
listen [::]:80;
server_name evemilano.com;
rewrite ^(.*) http://www.evemilano.com$1 permanent;
}
#blocco default
server {
@evemilano
evemilano / Google jQuery CDN
Created June 25, 2018 19:21
WordPress with jQuery Google CDN
//Making jQuery Google API
function replace_jquery() {
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', false, '1.11.3');
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'replace_jquery');
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;
});