Skip to content

Instantly share code, notes, and snippets.

View saifsultanc's full-sized avatar
🏠
Remote

Saif Sultan saifsultanc

🏠
Remote
View GitHub Profile
@saifsultanc
saifsultanc / gpecf-tax-amounts-by-field-value.php
Last active August 6, 2026 10:38
gp-ecommerce-fields/gpecf-tax-amounts-by-field-value.php
<?php
/**
* Gravity Perks // eCommerce Fields // Tax Amount by Field Value
* https://gravitywiz.com/documentation/gravity-forms-ecommerce-fields/
*
* Set the amount of a Tax field based on:
*
* 1. A static mapping tied to another field's value.
* 2. The current value of another field.
*
@saifsultanc
saifsultanc / gpecf-tax-amounts-by-field-value.php
Created July 31, 2026 13:36
gpecf-tax-amounts-by-field-value.php
<?php
class GPECF_Tax_Amounts_By_Field_Value {
private $_args = array();
public function __construct( $args = array() ) {
// set our default arguments, parse against the provided arguments, and store for use throughout the class
$this->_args = wp_parse_args( $args, array(
'form_id' => false,
@saifsultanc
saifsultanc / gpadvs-duplicates.js
Created June 25, 2026 07:50
gpadvs-duplicates.js
/**
* GP Advanced Select allow duplicate-valued choices (STANDALONE, no plugin changes).
*
* Tom Select (which powers Advanced Select) keys its options by value and silently collapses any
* options that share one. So on a single-select Advanced Select dropdown e.g. one populated by
* Populate Anything with "unique results" OFF two choices that share a value but have different
* labels (value `5` shown as both "Math" and "Mathematics") get merged into one option.
*
* This snippet preserves them by giving each colliding choice a unique SYNTHETIC id (so Tom Select
* keeps them all) and mirrors the selected option's REAL value into a companion hidden input that
@saifsultanc
saifsultanc / gcgc-gpb-sync.php
Created May 18, 2026 17:35
gcgc-gpb-sync.php
<?php
// TODO : Update Constants.
define( 'GPB_GCAL_SYNC_ACCOUNT', 'whatever@gmail.com' );
define( 'GPB_GCAL_SYNC_CALENDAR', 'calendar_ID@group.calendar.google.com' );
add_action( 'gpb_availability_block_added', function ( int $block_id, array $block_data, $bookable ) {
// Sync Negative/Unavailability blocks.
if ( empty( $block_data['is_negative'] ) ) {
return;
@saifsultanc
saifsultanc / gw-show-gpasc-draft-data-on-gf-entries.php
Last active May 9, 2026 06:18
gw-show-gpasc-draft-data-on-gf-entries.php
<?php
add_action( 'gform_post_entry_list', function( $form_id ) {
if ( ! is_admin() ) {
return;
}
$user_id = get_current_user_id();
$tokens = gp_advanced_save_and_continue()->get_current_user_resume_tokens( $form_id, '*' ); // '*' for all users if admin
if ( empty( $tokens ) ) {
<?php
define( 'EMAILIT_API_KEY', 'REPLACE_WITH_YOUR_API_KEY' );
add_filter( 'gpev_validation_result', function ( $result, $value, $email ) {
if ( empty( EMAILIT_API_KEY ) ) {
return $result;
}
@saifsultanc
saifsultanc / gpev-emailit-api.php
Created April 3, 2026 15:28
gpev-emailit-api.php
<?php
define( 'EMAILIT_API_KEY', 'REPLACE_WITH_YOUR_API_KEY' );
add_filter( 'gpev_validation_result', function ( $result, $value, $email ) {
if ( empty( EMAILIT_API_KEY ) ) {
return $result;
}
@saifsultanc
saifsultanc / gpev-emailit-validation.php
Created March 26, 2026 05:21
gpev-emailit-validation.php
<?php
define( 'EMAILIT_API_KEY', 'REPLACE_WITH_API_KEY' ); // TODO: Replace with your actual API key
add_filter( 'gpev_validation_result', function ( $result, $value, $email ) {
if ( ! defined( 'EMAILIT_API_KEY' ) || empty( EMAILIT_API_KEY ) ) {
return $result;
}
$response = wp_remote_post(
'https://api.emailit.com/v2/email-verifications',
@saifsultanc
saifsultanc / gw-selectAllMultiSelect.js
Created March 25, 2026 12:04
gw-selectAllMultiSelect.js
let targetFieldId = 4; // TODO: Update field id
let initTimeout;
function selectAllMultiSelect() {
let $target = $('#input_GFFORMID_' + targetFieldId);
// Prevent duplicate init
if (!$target.length || $target.data('select-all-init')) {
return;
}
@saifsultanc
saifsultanc / gw-emailit-validate.php
Last active March 24, 2026 07:47
gw-emailit-validate.php
<?php
// EmailIt Configuration - EDIT THESE VALUES
define( 'EMAILIT_API_KEY', 'REPLACE_API_KEY' ); // Replace with your actual API key
define( 'EMAILIT_ENABLED', true ); // Set to true to enable EmailIt validation
add_filter( 'gpev_validation_result', function ( $result, $value, $email ) {
if ( ! defined( 'EMAILIT_ENABLED' ) || ! EMAILIT_ENABLED ) {
return $result;