Skip to content

Instantly share code, notes, and snippets.

View teolaz's full-sized avatar

Matteo teolaz

View GitHub Profile
@teolaz
teolaz / rsync-remote-with-percentage.sh
Created December 12, 2018 11:00
Rsync to a remote server seeing percentage
#!/bin/sh
echo "rsync starting..."
SOURCE_DIR="/source/dir/with/final/backslash/"
TARGET_ADDRESS="127.0.0.1"
TARGET_DIR="/dir/with/final/backslash/"
TARGET_USER="remote-ssh-user"
RSYNC_ARGS='-vrltD --delete --stats --human-readable'
TODO=$(find ${SOURCE_DIR} | wc -l)
echo "found ${TODO} files, syncing..."
@teolaz
teolaz / ACFToArray.php
Last active June 12, 2023 08:33
This class is an helpful method to add a caching layer to Advanced Custom Fields. This works adding a new row on database with the entire ACF data serialized for that saved post or option page, and then WITH A SINGLE QUERY done you can have all data back and ready to use.
<?php
/**
* Created by PhpStorm.
* User: Matteo
* Date: 04/07/2018
* Time: 12:52
*/
/**
* Class ACFToArray
@teolaz
teolaz / ACFToArray.php
Created July 3, 2018 15:49
This class is an helpful method to add a caching layer to Advanced Custom Fields. This works adding a new row on database with
<?php
/**
* Class ACFToArray
* Used to offer a better performance experience on frontend, while maintaining the same old ACF structure
*/
class ACFToArray {
const DB_FIELD_PREFIX = 'acf_array_';
@teolaz
teolaz / ACFToArray.php
Created July 3, 2018 15:49
This class is an helpful method to add a caching layer to Advanced Custom Fields. This works adding a new row on database with
/**
* Class ACFToArray
* Used to offer a better performance experience on frontend, while maintaining the same old ACF structure
*/
class ACFToArray {
const DB_FIELD_PREFIX = 'acf_array_';
protected function __construct() {
add_action( 'acf/save_post', array( $this, 'saveTotalArray' ), 20 );