Skip to content

Instantly share code, notes, and snippets.

View gsarig's full-sized avatar

Giorgos Sarigiannidis gsarig

View GitHub Profile
@gsarig
gsarig / get_instagram_media.php
Last active May 21, 2022 10:12
Get Instagram media on WordPress using the current Instagram (Facebook) API (details: https://www.gsarigiannidis.gr/instagram-feed-api-after-june-2020/)
<?php
/**
* Get Instagram media on WordPress using the current Instagram (Facebook) API
*
* @param $token // Info on how to retrieve the token: https://www.gsarigiannidis.gr/instagram-feed-api-after-june-2020/
* @param $user // User ID can be found using the Facebook debug tool: https://developers.facebook.com/tools/debug/accesstoken/
* @param int $limit // Add a limit to prevent excessive calls.
* @param string $fields // More options here: https://developers.facebook.com/docs/instagram-basic-display-api/reference/media
* @param array $restrict // Available options: IMAGE, VIDEO, CAROUSEL_ALBUM
*
<?php
$form_id = 3;
add_filter( 'gform_form_post_get_meta_' . $form_id, 'add_repeater_field' );
function add_repeater_field( $form ) {
$field_id = 1000;
$fields = [
GF_Fields::create(
[
'type' => 'text',
@gsarig
gsarig / wp-cli_batch_db_backup.sh
Last active January 28, 2021 15:07
Batch backup a server's WordPress databases with WP-CLI (read more at: https://www.gsarigiannidis.gr/wp-cli-batch-backup-wordpress-databases/)
#!/bin/bash
# A bash script to batch backup a server's WordPress databases with WP-CLI. It requires WP-CLI, obviously (https://wp-cli.org/).
# The script will search for all WordPress installations under a given directory and will backup their databases. You can declare more than one such directories.
# You don't have to modify the script every time you add a new site. As long as the new site is under a declared parent directory, its database will be backed up.
# After creating the file, don't forget to make it executable by doing:
# chmod +x wp-cli_batch_db_backup.sh
# Also, you might want to add this in a cron job for scheduled backups.
# Set PATH environment variable
@paceaux
paceaux / tinyRules.css.md
Last active April 3, 2024 01:19
Tiny rules for how to name things in CSS and JS

Tiny rules for how to name stuff

CSS

How to name CSS classes

Stateful Class names

Is it a state that is only one of two conditions? (i.e. a boolean)

@rileypaulsen
rileypaulsen / functions.php
Created August 19, 2014 16:08
Add Advanced Custom Fields Fields to the WP REST API
function wp_api_encode_acf($data,$post,$context){
$data['meta'] = array_merge($data['meta'],get_fields($post['ID']));
return $data;
}
if( function_exists('get_fields') ){
add_filter('json_prepare_post', 'wp_api_encode_acf', 10, 3);
}
@arunk-s
arunk-s / backup.sh
Created April 13, 2014 06:36
Shell Script for taking Incremental Backup and store it at a remote place
# backup.sh
# The contents of this file are released under the GNU General Public License. Feel free to reuse the contents of this work, as long as the resultant works give proper attribution and are made publicly available under the GNU General Public License.
# By Arun Sori <arunsori94@gmail.com>
#For taking backup of the desired directory and store it at a remote place
#timestamp
time_stamp=`date`
#backup file name
@mourner
mourner / TileLayer.Common.js
Created February 11, 2012 23:11
Leaflet shortcuts for common tile providers
// Lefalet shortcuts for common tile providers - is it worth adding such 1.5kb to Leaflet core?
L.TileLayer.Common = L.TileLayer.extend({
initialize: function (options) {
L.TileLayer.prototype.initialize.call(this, this.url, options);
}
});
(function () {