Skip to content

Instantly share code, notes, and snippets.

View kjohnson's full-sized avatar

Kyle B. Johnson kjohnson

View GitHub Profile
@kjohnson
kjohnson / Event Tracking
Last active February 13, 2017 19:06 — forked from Quay3/Event Tracking
<script>
jQuery( document ).ready( function() {
/* Form ID #5 */
var formID = 5;
var category = 'Email List';
var action = 'Subscribed';
var label = 'New Subscriber';
jQuery( document ).on('click', '.nf-form-' + formID + '-cont input[type=button]', function() {
ga('send', 'event', category, action, label );
@kjohnson
kjohnson / nf-recaptcha-response.js
Last active February 8, 2017 15:46
Ninja Forms - reCaptcha Response Submission Data
var myCustomFieldController = Marionette.Object.extend({
fieldType: 'recaptcha',
initialize: function() {
// See: http://developer.ninjaforms.com/codex/field-submission-data/
Backbone.Radio.channel( this.fieldType ).reply( ‘get:submitData’, this.getSubmitData );
},
getSubmitData: function( fieldData ) {
@kjohnson
kjohnson / class-plugin-theme-review-request.php
Created February 2, 2017 15:54 — forked from danieliser/class-plugin-theme-review-request.php
Class to handle dashboard review requests. Read comments for full feature & usage. For the Remote Tracking Server see https://gist.github.com/danieliser/0d997532e023c46d38e1bdfd50f38801
<?php
/**
* This class can be customized to quickly add a review request system.
*
* It includes:
* - Multiple trigger groups which can be ordered by priority.
* - Multiple triggers per group.
* - Customizable messaging per trigger.
* - Link to review page.
* - Request reviews on a per user basis rather than per site.
@kjohnson
kjohnson / nf-create-post-wp-types-date.php
Created January 20, 2017 17:26
Converts a formatted Ninja Forms date to a timestamp for compatibility with Custom Fields (Date Type)
<?php
// Requires PHP v5.3 or higher.
add_filter( 'ninja_forms_create_post_meta_value', function( $meta_value, $post_type, $meta_key ){
// TODO: Update $post_type check.
// TODO: Update $meta_key check.
if( 'test' == $post_type && 'wpcf-test-date' == $meta_key ){
// Convert formatted date to timestamp for WP-Types compatibility.
jQuery( document ).ready( function(){
var myListController = Marionette.Object.extend({
initialize: function() {
// Listen to the value change for Checkbox List fields.
this.listenTo( Backbone.Radio.channel( 'listcheckbox' ), 'change:modelValue', this.onChangeModelValue );
},
onChangeModelValue: function( fieldModel ) {
<?php
/*
* Plugin Name: Ninja Forms - Datepicker Customizations
*/
add_filter( 'ninja_forms_enqueue_scripts', 'nf_datepicker_options' );
function nf_datepicker_options() {
wp_enqueue_script( 'nf_datepicker_options', plugin_dir_url( __FILE__ ) . 'script.js', array( 'jquery' ), false, true );
}
@kjohnson
kjohnson / css-classes.txt
Last active November 20, 2016 14:27
Submit button template for Blade. Install at: {theme}/ninja-forms/templates/fields-submit.html
grve-btn-small grve-square grve-bg-primary-2 grve-bg-hover-primary-2 grve-btn-line
@kjohnson
kjohnson / functions.php
Created November 17, 2016 15:01
Max File Size filter for All-in-One WP Migration
<?php
add_filter( 'ai1wm_max_file_size', 'my_ai1wm_max_file_size', 10, 1 );
function my_ai1wm_max_file_size( $max_file_size ){
$new_max_file_size = 1073741824;
return $new_max_file_size;
}
// apply_filters( ‘ai1wm_max_file_size’, AI1WM_MAX_FILE_SIZE ) );
@kjohnson
kjohnson / fields-submit.html
Last active November 20, 2016 14:23
{theme}/ninja-forms/templates/fields-submit.html
<script id="tmpl-nf-field-submit" type="text/template">
<a id="nf-field-{{{ data.id }}}" class="btn {{{ data.renderClasses() }}} nf-element " target="_self" href="#">
<span class="btn-content">{{{ data.label }}}</span>
<div class="icon">
<div class="icon-arrow-right"></div>
</div>
</a>
</script>
<?php
if( version_compare( get_option( 'ninja_forms_version', '0.0.0' ), '3', '<' ) || get_option( 'ninja_forms_load_deprecated', FALSE ) ) {
// Deprecated Codebase (v2.9.x)
} else {
// THREE Codebase (v3)
}