Skip to content

Instantly share code, notes, and snippets.

View wgroenewold's full-sized avatar

Wouter Groenewold wgroenewold

  • GH+O Communicatie
View GitHub Profile
@wgroenewold
wgroenewold / ACFGallery-parser
Created January 21, 2014 08:18
Gist to decode the Wordpress attachment ID's from a ACF Gallery custom field
var gallerycf = json.post.custom_fields.gallerij[0];
gallerycf = gallerycf.split('{');
gallerycf = gallerycf[1].split(';');
var items = [];
for(i=0; i<gallerycf.length; i++){
if(i % 2 !== 0){
items.push(gallerycf[i]);
}
}
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}
@wgroenewold
wgroenewold / yammer.php
Created July 3, 2015 06:44
ohmy-auth Yammer
<?php
require_once __DIR__ . '/vendor/autoload.php';
use ohmy\Auth2;
# do 3-legged oauth
$yammer = Auth2::legs(3)
# configuration
->set(array(
Link real bank accounts to RevBank accounts
Read mutations
Substract "lidmaatschap" (note: administrate this somewhere as well? No consumption if no lidmaatschap paid for 2 months?)
Put leftover amount in RevSpace bank
@wgroenewold
wgroenewold / maakplekDeurbel.php
Last active September 29, 2015 22:23
Maakplek Deurbel
<?php
/*
* Initial doorbell.
*
* @todo: Twitter connection
* @todo: Storage with timestamp to generate heatmaps
* @todo: Spaceapi.net eraan knopen.
*/
function updateIndexNumbers($postid) {
$post = get_post($postid);
if ($post->post_type == 'project') {
$args = array(
'post_type' => 'project',
'posts_per_page' => -1,
'post_status' => 'publish',
'order' => 'ASC',
'orderby' => 'date'
<?php
///*
//Plugin Name: MODX importer
//Plugin URI: http://gho.nl/
//Description: Import newsitems from MODX.
//Version: 1.0
//Author: Wouter Groenewold
//License: GPL
//Copyright: GH+O Communicatie
//*/
@wgroenewold
wgroenewold / ig_scraper.php
Created July 5, 2016 08:55
Fuck you Instagram
<?php
$tag = 'horse';
$scrape = scrape_ig_tag($tag);
function scrape_ig_tag($tag) {
$ig_url = file_get_contents('https://www.instagram.com/explore/tags/'.$tag.'/'); // instagrame tag url
$shards = explode('window._sharedData = ', $ig_url);
$ig_json = explode(';</script>', $shards[1]);
$ig_data = json_decode($ig_json[0], TRUE);
return $ig_data; // the whole shebang
@wgroenewold
wgroenewold / update_srv
Last active November 24, 2016 07:08
Update your DirectAdmin NGINX mainline server the easy way
#!/bin/env bash
function read_yes_no()
{
if [ "$1" = "-y" -o "$1" = "y" ]; then
{
yesno="y";
echo "y";
echo "Skipping...as -y was given";
}
@wgroenewold
wgroenewold / Force all traffic for Wordpress over SSL
Last active February 8, 2024 10:51
Force all traffic for Wordpress over SSL
define('FORCE_SSL_ADMIN', true);
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){
$_SERVER['HTTPS']='on';
}