Skip to content

Instantly share code, notes, and snippets.

View kenmasters's full-sized avatar

Ken John Siosan kenmasters

View GitHub Profile
@kenmasters
kenmasters / GFORM: Product Order Summary
Last active December 7, 2017 02:03
Option to remove or show product order summary when using {all_fields} merge tag
# Docs: https://docs.gravityforms.com/gform_display_product_summary/
# Disable for all forms
add_filter( 'gform_display_product_summary', '__return_false' );
# Disable for a specific form
add_filter( 'gform_display_product_summary', function( $display_product_summary, $field, $form, $entry ) {
return $form['id'] == 10 ? false : $display_product_summary;
}, 10, 4 );
@kenmasters
kenmasters / GFORM: Change Currency
Last active June 30, 2019 21:03
Gravity Forms PayPal Standard Add-On
/**
* Change payment currency base from another field, when specific form is submitted.
*/
add_action( 'gform_pre_submission_2', 'change_currency_' );
function change_currency_( $form ) {
add_filter( 'gform_currency', function() { return rgpost('input_4'); } );
}
@kenmasters
kenmasters / Genesis - Footer Widgets
Last active December 19, 2017 06:01
Moving Footer widgets + Header and Footer outside Site Container in Executive Pro (Genesis)
function clean($string) {
$string = str_replace(' ', '_', $string); // Replaces all spaces with hyphens.
$string = preg_replace('/[^A-Za-z0-9_]/', '', $string); // Removes special chars.
return preg_replace('/_+/', '_', $string); // Replaces multiple hyphens with single one.
}
echo clean("HAnn-a Jane##ll f. e"); // HAnna_Janell_f_e
// Limit maximum year to current year
add_filter( 'gform_date_max_year', 'set_max_year' );
function set_max_year( $max_year ) {
return date('Y', current_time('timestamp'));
}
// Reference: https://www.gravityhelp.com/documentation/article/gform_date_max_year/
@kenmasters
kenmasters / GFORM merge tag change date
Last active December 7, 2017 02:04
GFORM merge tag change date display format wen using {all_fields}.
// Code placement: current theme functions.php
// Change date displayed format.
// Example adding a date field in a dropdown/datefield format is dd-mm-yy and value `09-09-2017`,
// By adding this filter it will display as `09-September-2017`.
// Take note that in gforms docs: https://www.gravityhelp.com/documentation/article/gform_merge_tag_filter/#5-date-field
// priority is `10` and is working only for datepicker but not for dropdown and datefield,
// here is changed to `15` to ensure filter would not be overriden.
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
Reference: https://davidwalsh.name/query-string-javascript
How to use ?
// Assuming "?post=1234&action=edit"
@kenmasters
kenmasters / Using TWBS to WP
Last active December 7, 2017 02:04 — forked from mrbobbybryant/gist:83c4a076da6dd67de3da
Properly enqueue Bootstrap(CSS/JS) into WordPress CMS
<?php
/**
* Enqueue scripts and styles
*/
add_action( 'wp_enqueue_scripts', 'your_theme_enqueue_scripts' );
function your_theme_enqueue_scripts() {
// all styles
wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/css/bootstrap.css', array(), 20141119 );
@kenmasters
kenmasters / GFORM SIN
Created August 30, 2017 13:02
Creating a custom gravityform field (Canada SIN [Standard Insurance Number])
/*******/
class GF_Field_SIN extends GF_Field {
public $type = 'sin';
public function get_form_editor_field_title() {
return esc_attr__( 'SIN', 'gravityforms' );
@ethanstenis
ethanstenis / Postman POST PUT Requests.txt
Last active March 27, 2025 02:10
How to make Postman work with POST/PUT requests in Laravel...
To make Postman work with POST/PUT requests...
https://laravel.com/docs/5.2/routing#csrf-x-csrf-token
In addition to checking for the CSRF token as a POST parameter, the Laravel VerifyCsrfToken middleware will also check for the X-CSRF-TOKEN request header.
1. Store the token in a "meta" tag at the top of your root view file (layouts/app.blade.php)...
<meta name="csrf-token" content="{{ csrf_token() }}">
** If using jQuery, you can now instruct it to include the token in all request headers.
$.ajaxSetup({