Skip to content

Instantly share code, notes, and snippets.

View kenmasters's full-sized avatar

Ken John Siosan kenmasters

View GitHub Profile
@kenmasters
kenmasters / parallax.js
Created February 25, 2016 03:33 — forked from srikat/parallax.js
Applying Parallax effect from Parallax Pro in any Genesis theme. http://sridharkatakam.com/apply-parallax-effect-parallax-pro-genesis-theme/
//* Register widget areas
genesis_register_sidebar( array(
'id' => 'parallax-section-below-header',
'name' => __( 'Parallax Section Below Header', 'your-theme-slug' ),
'description' => __( 'This is the parallax section below header.', 'your-theme-slug' ),
) );
genesis_register_sidebar( array(
'id' => 'parallax-section-above-footer',
'name' => __( 'Parallax Section Above Footer', 'your-theme-slug' ),
@kenmasters
kenmasters / Create an `ORDER ID` for gravityform.
Last active August 30, 2017 13:00
Creating unique order id.
Here are the detailed steps on how to add/create a unique order id for specific form.
An order id can be of any format, for demonstration purposes our format would be,
XXX-AAAYYMMDDHHMMSS - change XXX and AAA to your own preferences.
Step 1: Create new form.
Step 2: Add single field
Label: ORDER ID
Goto Advance Tab -> Visibility -> Administrative
@kenmasters
kenmasters / Custom Math captcha shortcode
Last active September 9, 2017 17:29
Creating a custom math captcha in gravityform in a form of a shortcode
// Paste code from `gform-math-captcha.txt` in your current themes functions.php
// Then add an HTML field in gravityform where you want to have a math captcha
// Then add the shortcode: [math-captcha form=yourformID]
-How it works?
// Submit button will be disabled by default, and will be enabled when entering the correct answer to a math equation.
add_shortcode('math-captcha', 'math_captcha');
@kenmasters
kenmasters / GFORM remove `MapIt` link
Last active September 9, 2017 17:31
Remove `Map It` link in gravityform address field
<div class="panel panel-primary">
<div class="panel-heading"></div>
<div class="panel-body">
<h2>Thank You.</h2>
<p>Your order was successful with an order id of <strong>{ORDER ID:294}</strong>.</p>
<p>
<a class="btn btn-default btn-md" role="button" href="/">Order Again</a>
<a class="btn btn-primary btn-md" role="button" href="http://pay.orderpayroll.com/order/{ORDER ID:294}">Pay Now</a>
</p>
</div>
@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' );
@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 );
// 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"