Skip to content

Instantly share code, notes, and snippets.

View adamplabarge's full-sized avatar

Adam LaBarge adamplabarge

View GitHub Profile
@adamplabarge
adamplabarge / gf-acf-image-attachment-maker.php
Last active October 27, 2016 20:41
GF-ACF image attachment maker
<?php
//* the the default upload path to work in normal WP structure
add_filter("gform_upload_path", "change_upload_path", 20, 2);
function change_upload_path($path_info, $form_id){
$wp_upload_path = wp_upload_dir();
$path_info["path"] = $wp_upload_path['path'] . '/';
$path_info["url"] = $wp_upload_path['url'] . '/';
return $path_info;
@adamplabarge
adamplabarge / Ajax_Controller.php
Last active August 29, 2015 14:24
Ajax API for WP - setup for PSR4 autoload
<?php
namespace Classes;
/*//////////////////////////////////////////////////////////////////////////////
================================================================================
Ajax_Controller
- registers, enqueues, localizes ajax js file
- passes method and params to Ajax_Function_Suite();
- returns $ajax_function_suite->respond() as JSON
- don't forget nonce
@adamplabarge
adamplabarge / unique_multi_arrays.php
Last active August 29, 2015 14:24
unique multi dimensionnel arrays
<?php
/**
* @param = multi-dimensionnal array with dups
* @return = unique multi-dimensional array
*/
function make_arrays_unique( $array )
{
array_map("unserialize", array_unique(array_map("serialize", $arras)));
}
function htmlEncode(str) {
return str.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
}
<?php
$highlights = new WP_Query($args);
$sort = function(&$posts) {
$props = array('year', 'authors');
usort($posts, function($a, $b) use ($props) {
if ($a->$props[0] == $b->$props[0])
<?php
add_action('genesis_before', function() {
global $wpdb;
$post_type = 'product';
$query = "
SELECT DISTINCT($wpdb->postmeta.meta_key)
FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta
@adamplabarge
adamplabarge / .babelrc
Last active February 5, 2017 17:28
Babelify Browserify and SASS Gulp
{
"presets": ["es2015"]
}
@adamplabarge
adamplabarge / rockPaperScissors.py
Created November 29, 2017 17:42
Python Class - Rock Paper Scissors
"""
Some python from a free python class offered by The Tech Academy Portland
https://www.meetup.com/techacademy/
"""
import math
from random import randint
randMin = 0
randMax = 2
@adamplabarge
adamplabarge / plugin.php
Last active January 8, 2018 21:24
Portland WP Meetup - Hooks and Filters - Jan 08 2018 - Sample Hooks Plugin Code
<?php
/*
Plugin Name: Sample Plugin
Plugin URI:
Description: Sample code for the Portland WordPress MeetUp Hooks and Filters Talk
Version: 1.0.0
Author: adamplabarge
Author URI: https://github.com/adamplabarge
Text Domain: sample-plugin
License: GPLv2
@adamplabarge
adamplabarge / plugin.php
Created January 8, 2018 05:44
Portland WP Meetup - Hooks and Filters - Jan 08 2018 - Hooks and Filters in a plugins and Class
<?php
/**
* Plugin Name: TheAudioBeatnik Category Slideshow
* Description: A category page slideshow using Slick.js and WP Plugin Advanced Custom Fields
* Author: Adam LaBarge
* Version: 1.0
* Author URI: https://www.linkedin.com/in/adamlabarge
*/
class tab_CategorySlideShow {