Skip to content

Instantly share code, notes, and snippets.

View LucaRosaldi's full-sized avatar

Luca Rosaldi LucaRosaldi

View GitHub Profile
@LucaRosaldi
LucaRosaldi / distance-sample.php
Last active February 12, 2024 09:05
PHP: Get Distance Between two Geolocated Points (lat/lon)
<?php
/* These are two points in New York City */
$point1 = array('lat' => 40.770623, 'long' => -73.964367);
$point2 = array('lat' => 40.758224, 'long' => -73.917404);
$distance = getDistanceBetweenPoints($point1['lat'], $point1['long'], $point2['lat'], $point2['long']);
foreach ($distance as $unit => $value) {
echo $unit.': '.number_format($value,4).'<br />';
}
@LucaRosaldi
LucaRosaldi / Elenco Province Italiane
Last active November 27, 2023 14:52
Elenco Province Italiane in vari formati: HTML, PHP, JSON, TXT, Pipe notation (es. Elementor).
# Fonte: Wikipedia
# URL: https://it.wikipedia.org/wiki/Province_d%27Italia
# Aggiornato al: 2022
Agrigento
Alessandria
Ancona
Aosta
Arezzo
Ascoli Piceno
@LucaRosaldi
LucaRosaldi / reset.css
Last active December 17, 2022 07:05
CSS: Modern Reset
/* -------------------------------------------*/
/* RESET
/* -------------------------------------------*/
*, *::before, *::after {
box-sizing: border-box;
}
* {
margin: 0;
}
@LucaRosaldi
LucaRosaldi / wp-config.php
Last active July 26, 2022 10:05
WP: wp-config.php additional settings
<?php
/**
* Raise PHP memory limit.
*/
define( 'WP_MEMORY_LIMIT', '256M' );
/**
* Disable revisions, we don’t need them.
*/
define( 'WP_POST_REVISIONS', false );
@LucaRosaldi
LucaRosaldi / iubenda_gtm.js
Created July 14, 2022 09:41
JS: Iubenda GTM integration callback
/* Copy this code in "Advanced Options" > "Callbacks > "onPreferenceExpressedOrNotNeeded" textarea */
/* See full explanation on: https://www.iubenda.com/en/help/1235-google-tag-manager-blocking-cookies */
function(preference){dataLayer.push({iubenda_ccpa_opted_out:_iub.cs.api.isCcpaOptedOut()});if(!preference){dataLayer.push({event:"iubenda_preference_not_needed"})}else{if(preference.consent===true){dataLayer.push({event:"iubenda_consent_given"})}else if(preference.consent===false){dataLayer.push({event:"iubenda_consent_rejected"})}else if(preference.purposes){for(var purposeId in preference.purposes){if(preference.purposes[purposeId]){dataLayer.push({event:"iubenda_consent_given_purpose_"+purposeId})}}}}}
@LucaRosaldi
LucaRosaldi / system-fonts.css
Last active June 21, 2022 15:50
CSS: System fonts
/* Sans Serif */
html, body {
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif;
}
/* Serif */
html, body {
font-family: Iowan Old Style, Apple Garamond, Baskerville, Times New Roman, Droid Serif, Times, Source Serif Pro, serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
}
@LucaRosaldi
LucaRosaldi / wp_extend_search_results_including_tags.php
Last active April 28, 2022 10:12
WP: extend search results including tags
<?php
/**
* Extend search results query including tags.
*
* @hook posts_where, posts_join, posts_groupby
*
* @param string
* @return string
*/
function my_theme_search_where_clause_include_tags( string $where ) : string
@LucaRosaldi
LucaRosaldi / wp_add_custom_image_sizes.php
Created April 6, 2022 08:00
WP: add custom image sizes
<?php
/**
* Add custom image sizes.
*
* @hook after_setup_theme
*
* @return void
*/
function my_theme_add_custom_image_sizes() : void
@LucaRosaldi
LucaRosaldi / get_data_uri.php
Last active February 24, 2022 10:30
PHP: Get data URI string from an image file.
<?php
/**
* Get data URI string from an image file.
*
* @param string $path_to_file
* @return string
*/
function get_data_uri( string $path_to_file ) : string
{
@LucaRosaldi
LucaRosaldi / login-styles.php
Last active February 24, 2022 10:26
WP: Customize Login Page
<?php
function my_login_enqueue_scripts() {
wp_enqueue_style( 'my-login', get_stylesheet_directory_uri() . '/assets/css/style-login.css' );
}
add_action( 'login_enqueue_scripts', 'my_login_enqueue_scripts', 10 );