Skip to content

Instantly share code, notes, and snippets.

View dabernathy89's full-sized avatar

Daniel Abernathy dabernathy89

View GitHub Profile
@dabernathy89
dabernathy89 / gravity-forms-field-groups.php
Created March 13, 2013 19:55
Insert this script into functions.php in your WordPress theme (be cognizant of the opening and closing php tags) to allow field groups in Gravity Forms. The script will create two new field types - Open Group and Close Group. Add classes to your Open Group fields to style your groups. Note that there is a stray (but empty) <li> element created. …
<?php
/*
Insert this script into functions.php in your WordPress theme (be cognizant of the opening and closing php tags) to allow field groups in Gravity Forms. The script will create two new field types - Open Group and Close Group. Add classes to your Open Group fields to style your groups.
Note that there is a stray (but empty) <li> element created. It is given the class "fieldgroup_extra_li" so that you can hide it in your CSS if needed.
*/
add_filter("gform_add_field_buttons", "add_fieldgroup_fields");
function add_fieldgroup_fields($field_groups){
foreach($field_groups as &$group){
@dabernathy89
dabernathy89 / gf_button_addclass.php
Last active December 23, 2015 07:19
Add class(es) to Gravity Forms buttons
add_filter("gform_submit_button", "alter_form_submit_button", 10, 2);
function alter_form_submit_button($button, $form){
if ($form["button"]["type"] == "text") {
// (class=) followed by (single or double quote) followed by (anything that is not a single or double quote)
$pattern = '/(class=)(\'|")([^\'"]+)/';
$replacement = '${1}${2}${3} btn';
$newbutton = preg_replace($pattern, $replacement, $button);
if ( !is_null($newbutton) ) {
return $newbutton;
}
<?php
/*
Plugin Name: Gravity Forms Queue Listener
*/
class GravityFormsQueueListener {
function __construct() {
add_action('wp_loaded', array($this,'process_push_queue_msg'), 10 );
add_action('gform_after_submission', array( $this, 'send_to_ironio'), 10, 2);
{"scrollwheel":false,"styles":[{"featureType":"landscape","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","stylers":[{"saturation":-100},{"lightness":51},{"visibility":"simplified"}]},{"featureType":"road.highway","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"road.arterial","stylers":[{"saturation":-100},{"lightness":30},{"visibility":"on"}]},{"featureType":"road.local","stylers":[{"saturation":-100},{"lightness":40},{"visibility":"on"}]},{"featureType":"transit","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"administrative.province","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":-25},{"saturation":-100}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]}]}
@dabernathy89
dabernathy89 / wp_custom_posts_navigation
Created March 17, 2015 16:39
WordPress custom posts navigation function
<?php
// Adapted from Underscores' posts navigation function
// Uses Bootstrap classes
// In a default query:
// custom_posts_navigation();
// In a custom query:
// custom_posts_navigation($my_custom_query);
class SimpleEndpoint {
public function hooks() {
add_action( 'init', array( $this, 'add_endpoint' ) );
add_action( 'template_redirect', array( $this, 'handle_request' ) );
}
public function add_endpoint() {
add_rewrite_tag( '%foobar%', '([^&]+)' );
add_rewrite_rule( '^(foobar)/?$', 'index.php?$matches[1]=1', 'top' );
}
@dabernathy89
dabernathy89 / vue-router-stringify-query-nested-parameters.js
Last active May 29, 2020 09:32
An implementation of the Vue Router `stringifyQuery` method which handles nested query parameters. It uses square brackets (`[]`) for query parameter arrays (regular and nested).
/*
Ex:
stringifyQuery({foo: "bar", baz: ['a','b'], fizz: {foo: [1,2,3], bar: {bees: "knees"}}});
-> ?foo=bar&baz[]=a&baz[]=b&fizz[foo][]=1&fizz[foo][]=2&fizz[foo][]=3&fizz[bar][bees]=knees
Square brackets will be URL encoded; I didn't do so in this example for readability.
*/
function stringifyQuery (obj, parentName) {
const res = obj ? Object.keys(obj).map(key => {

Keybase proof

I hereby claim:

  • I am dabernathy89 on github.
  • I am dabernathy89 (https://keybase.io/dabernathy89) on keybase.
  • I have a public key ASBoFatFFwKWw1_xz99UcyHPVG_3rJSp-yyWJdlvab_kjQo

To claim this, I am signing this object:

@dabernathy89
dabernathy89 / conference-slack-reasons.md
Created January 30, 2018 20:19
Why would a conference Slack be useful?

In addition to normal conference discussion that happens on Twitter, I think that having a dedicated place for conference discussion (Slack, Discord, or something else) would be useful.

There are a few limitations with Twitter:

  • conversations are not centralized around topics
  • not everyone wants to use their Twitter to discuss conference stuff (some people are more selective about how they tweet)
  • 280 character limit, no formatting
  • hashtag gets flooded with well-meaning but possibly over-eager live-tweeters

Here are the benefits of using a messaging app in addition to Twitter:

@dabernathy89
dabernathy89 / component.vue
Last active June 21, 2018 14:57
How to wrap a component that uses slots?
<v-server-table
:columns="columns"
:options="mergedOptions"
:name="tableName"
:ref="tableName">
<template slot="beforeFilter">
<slot name="beforeFilter"></slot>
</template>
<template slot="afterFilter">