Skip to content

Instantly share code, notes, and snippets.

View kjohnson's full-sized avatar

Kyle B. Johnson kjohnson

View GitHub Profile
jQuery('.datepicker').datepicker({
// Show the 'close' and 'today' buttons
showButtonPanel: true,
closeText: objectL10n.closeText,
currentText: objectL10n.currentText,
monthNames: objectL10n.monthNames,
monthNamesShort: objectL10n.monthNamesShort,
dayNames: objectL10n.dayNames,
dayNamesShort: objectL10n.dayNamesShort,
dayNamesMin: objectL10n.dayNamesMin,
@kjohnson
kjohnson / gulpfile.js
Last active August 29, 2015 14:17
Gulp starter for JS
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
gulp.task('js', function () {
return gulp.src('assets/js/**/*.js') //select all javascript files under js/ and any subdirectory
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('assets/js/')); //the destination folder
});
@kjohnson
kjohnson / test.php
Last active August 29, 2015 14:18
Assign and return a property value in a single line
class Test {
public $var;
public function get_var() {
return $this->var = "Hello, world!";
}
}
$test = new Test();
class test {
const HELLO = 'Hello';
}
class test1 extends test {
const HELLO = 'Hello, test1';
}
class test2 extends test {
const HELLO = 'Hello, test2';
}
@kjohnson
kjohnson / rename_csv.php
Created April 20, 2015 20:46
rename a csv email attachment
<?php
add_filter( 'ninja_forms_submission_csv_name', 'my_unique_csv_name', 10, 1 );
function my_unique_csv_name( $csv_name ) {
global $ninja_forms_processing;
return $ninja_forms_processing->get_form_setting( 'sub_id' ). "_" . $csv_name;
}
@kjohnson
kjohnson / my-upgrade.php
Created May 20, 2015 18:47
Ninja Forms Upgrade Handler Registration Hook
add_filter( 'nf_upgrade_handler_register', 'add_nf_my_upgrade', 10, 1 );
function add_nf_my_upgrade( $upgrades ) {
$upgrades[] = new NF_Upgrade_My_UPgrade();
return $upgrades;
}
jQuery(document).ready( function() {
jQuery.datepicker.setDefaults(
{
closeText: 'Close',
prevText: 'Previous',
nextText: 'Next',
currentText: 'Today'
// Add other options as needed
}
);
@kjohnson
kjohnson / debug.js
Last active August 29, 2015 14:21
Ninja Forms Builder Debugger
jQuery(document).ready(function($) {
// Display Field ID next to Field Title
$(".ninja-forms-field-title").each( function() {
var obj_id = this.id;
var temp_array = obj_id.split( '_' );
var id = temp_array[ temp_array.length - 2 ];
var html = $( this ).html();
@kjohnson
kjohnson / CPT_Example.php
Last active August 29, 2015 14:23
An example CPT with the Ninja Forms Append A Form met box.
class CPT_Example {
public function __construct() {
add_action( 'init', array( $this, 'custom_post_type' ), 0 );
add_action('add_meta_boxes', array( $this, 'ninja_forms_add_custom_box' ) );
}
public function custom_post_type() {
//Source: http://generatewp.com/post-type/
$labels = array(
'name' => _x( 'Examples', 'Post Type General Name', 'text_domain' ),
@kjohnson
kjohnson / 0_reuse_code.js
Last active August 29, 2015 14:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console