Skip to content

Instantly share code, notes, and snippets.

View gfargo's full-sized avatar
🥫
Revolutionizing Food Regulation with Okayd

Griffen Fargo gfargo

🥫
Revolutionizing Food Regulation with Okayd
View GitHub Profile
@gfargo
gfargo / WP Contact Form 7 - MailChimp
Last active August 29, 2015 14:04
MailChimp API Integrations
<?php
/************************************************
Mail Chimp Integration with Wordpress Contact Form 7
************************************************/
function wpcf7_send_to_mailchimp($cfdata) {
@gfargo
gfargo / Basic Form - Name.Business.Email.Number.Message
Last active August 29, 2015 14:05
CF7 - Example Forms [Bootstrap]
<div class="input-group col-sm-6">
[text* cf-name class:form-control placeholder "Name"]
<span class="input-group-addon"><i class="fa fa-user"></i></span>
</div>
<div class="input-group col-sm-6">
[text* cf-business class:form-control placeholder "Business Name"]
<span class="input-group-addon"><i class="fa fa-building"></i></span>
</div>
@gfargo
gfargo / WP - Contextual Help Dropdown.php
Created January 21, 2015 18:05
Easy function to add help tabs to WP Admin Pages
add_filter( 'contextual_help', 'wptuts_contextual_help', 10, 3 );
function wptuts_contextual_help( $contextual_help, $screen_id, $screen ) {
// Only add to certain screen(s). The add_help_tab function for screen was introduced in WordPress 3.3.
if ( $screen_id == 'market-trends' || ! method_exists( $screen, 'add_help_tab' ) )
return $contextual_help;
$screen->add_help_tab( array(
'id' => 'wptuts-overview-tab',
@gfargo
gfargo / array-explode.php
Created March 23, 2015 15:23
Easy Array Explode | Map Maker WP Plugin
<?php
/*
Do Shortcode
http://codex.wordpress.org/Function_Reference/do_shortcode
StackOverflow - Better Way to Explode String
http://stackoverflow.com/questions/7355301/a-better-way-to-explode-twice-in-php
*/
@gfargo
gfargo / client-app.js
Last active August 29, 2015 14:22 — forked from jackiig/client-app.js
Template.CommentAdd.events({
'submit form': function(e, tmpl) {
e.preventDefault();
formEl = tmpl.find('form');
comment = tmpl.find('[name=comment]').value;
if (comment.trim().length == 0) { return false; };
Comments.insert({
login: Meteor.user().profile.login,
timestamp: new Date,
room: Session.get('activeRoom'),
@gfargo
gfargo / CustomMapWidget.php
Last active August 29, 2015 14:26
Extend 2amigos Leaflet Map Class - Allowing for Global access to Map variable
<?php
namespace app\components;
use dosamigos\leaflet\LeafLet;
use dosamigos\leaflet\widgets\Map;
use dosamigos\leaflet\LeafLetAsset;
use yii\base\InvalidConfigException;
use yii\base\Widget;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
@gfargo
gfargo / Gruntfile.js
Last active September 23, 2015 15:42
Easy way to seperate out Grunt stuff to avoid massive gruntfiles
/*****************************************************
Grunt'd
This 'plop-in' plugin was created to expedite the
process of adding the required files for front-end
development.
This includes template scss files and `main.js`
@gfargo
gfargo / Vagrantfile
Created October 16, 2015 20:33
Basic Template for Digital Ocean as Vagrant Provider - Deploy Droplet with Vagrant
####
# Digital Ocean Provider
#
# Update 'provider.token' to API Key given by Digital Ocean
#
####
config.vm.provider :digital_ocean do |provider, override|
# Add path to SSH key for Digital Ocean
override.ssh.private_key_path = 'path/to/ssh/key/id_rsa'
@gfargo
gfargo / is_blog.php
Last active December 19, 2015 12:48 — forked from wesbos/is_blog.php
Returns 'True' when the user is on a Wordpress 'Blog' page.
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
@gfargo
gfargo / Pls: Render $_POST Arrays
Created November 16, 2013 16:29
Returns out Array of Hidden Inputs when received in the $_POST. This function is used in conjunction with the Placester Wordpress Real Estate IDX Plugin. It's purpose is to allow the user to pass an array through the $_POST variable - as opposed to straight AJAX.
function render_post_array ($group = 'location', $key = 'postal') {
if ($_POST['location'] && is_array($_POST['location']['postal'])) {
$output = '';
foreach ($_POST[$group][$key] as $value) {
$output .= '<input type="hidden" name="'.$group.'['.$key.'][]" value="' . $value .'" >';
}
$output .= '<input type="hidden" name="'.$group.'['.$key.'][]" value="in" >';
}
return $output;
}