Skip to content

Instantly share code, notes, and snippets.

View imelgrat's full-sized avatar

Iván Melgrati imelgrat

View GitHub Profile
@imelgrat
imelgrat / cube-carousel.css
Created February 15, 2019 12:15
Create a 3D "cube carousel" using CSS3 transforms
@imelgrat
imelgrat / .htaccess
Created February 15, 2019 12:07
Protect your WordPress website using a few cut-and-paste .htaccess hacks
#Taken from https://imelgrat.me/security/wordpress-htaccess-file-protect/
# Prevent access to .htaccess and .htpasswd files
<files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</files>
# Deny access to wp-config.php file
@imelgrat
imelgrat / rotate-on-hover.css
Last active February 15, 2019 11:58
“Rotate-on-Hover” 3D Gallery using CSS3 transforms - Create a 3-D picture gallery using only CSS.
@charset "utf-8";
/* Delete all margins and paddings from Gallery items */
/* Check the article at: https://imelgrat.me/css/3d-gallery-css3-transforms/ */
.gallery-container * {
margin: 0;
padding: 0;
}
.gallery-container {
@imelgrat
imelgrat / add-wordcount-column.php
Created February 15, 2019 11:13
Reorder WordPress post-list columns, adding a word-count column after the title column.
<?php
/**
* Reorder post-list columns, adding a word-count column after the title column.
*
* This code assumes a new column named "wordcount" was already.
* Check the link for the whole process.
*
* @link https://imelgrat.me/wordpress/customize-wordpress-post-management-page/
*
* @param array $defaults List of default post-list columns
@imelgrat
imelgrat / wordpress-wordcount-column.php
Created February 15, 2019 11:01
Add a word-count column to WordPress Posts List (Dashboard view).
<?php
/**
* Add a word-count column to WordPress Posts List (Dashboard view).
*
* Custom code for adding a new column to the posts list.
* The new column will contain the number of words in the post
*
* @link https://imelgrat.me/wordpress/customize-wordpress-post-management-page/
*/
@imelgrat
imelgrat / count-post-words.php
Created February 15, 2019 10:56
Custom function that takes a WordPress post ID and returns the number of words in the post.
<?php
/**
* Count Post Words.
*
* Custom function that takes a WordPress post ID and returns the number of words in the post.
* You should paste it on your theme's functions.php file.
*
* @link https://imelgrat.me/wordpress/customize-wordpress-post-management-page/
*
* @param int $post_id The Post ID
@imelgrat
imelgrat / json-ld-job-posting.js
Created February 15, 2019 01:33
Structured DataExample: Helping Google find a Job offer
<script type="application/ld+json">
{
"@context":"http://schema.org",
"@type":"JobPosting",
"baseSalary":
{
"@type":"MonetaryAmount",
"currency":"USD",
"value":
{
@imelgrat
imelgrat / structured-data-json-ld.js
Created February 15, 2019 01:21
Simple example showing how to tag a blog post using JSON-LD (JSON for Linked Data), the newest structured format and the one Google recommends for its search engine.
<script type="application/ld+json">{
"@context": "http://schema.org",
"@type": "Article",
"author": {
"@type": "Person",
"name": "Ivan Melgrati"
},
"datePublished": "2018-02-01",
"description": "This article is about structured data"
}</script>
<?php
/**
* Simple example showing how to tag a blog post using RDFa (Resource Description Framework)
*
* @link https://imelgrat.me/json-xml/structured-data-google-recipes-jobs/
*/
?>
<div vocab="http://schema.org/" typeof="Article">
<div> <span property="name">Structured Data: Helping Google find recipes and jobs</span> by <span property="author">Ivan Melgrati</span></div>
<div property="datePublished" content="2018-02-01">Published on Feb 1, 2018</div>
@imelgrat
imelgrat / structured-microdata.php
Last active February 15, 2019 02:33
Simple example showing how to tag a blog post using Microdata following some of Schema.org’s properties used to define an “Article”.
<?php
/**
* Simple example showing how to tag a blog post using Microdata
* following some of Schema.org’s properties used to define an “Article”.
*
* @link https://imelgrat.me/json-xml/structured-data-google-recipes-jobs/
*/
?>
<div itemscope itemtype="http://schema.org/Article">
<div>