Skip to content

Instantly share code, notes, and snippets.

View saifsultanc's full-sized avatar
🏠
Remote

Saif Sultan saifsultanc

🏠
Remote
View GitHub Profile
<?php
// Original filter to optimize the query using caching
add_filter('gpeb_filters_col_rows_query', 'custom_optimize_gf_entry_meta_query_with_cache', 10, 3);
function custom_optimize_gf_entry_meta_query_with_cache($sql, $col, $table) {
// Check if the current table and column are the ones we want to optimize
if ($table === GFFormsModel::get_entry_meta_table_name() && $col === 'meta_key') {
// Attempt to retrieve cached meta_key results
$cached_meta_keys = get_transient('gf_entry_meta_keys');
@saifsultanc
saifsultanc / gpfup-exact-dimensions-validation.js
Created October 4, 2024 14:27
gpfup-exact-dimensions-validation.js
window.gform.addFilter( 'gpfup_meets_minimum_requirement', function ( meetsMinimum, imageSize, formId, fieldId, GPFUP ) {
if ( imageSize.width == GPFUP.minWidth && imageSize.height == GPFUP.minHeight ) {
return true;
}
return false;
} );
window.gform.addFilter( 'gpfup_strings', function( strings, formId, fieldId ) {
// REPLACE 1 with the field id of your File Upload Pro field
if ( formId != GFFORMID && fieldId == 1 ) {
@saifsultanc
saifsultanc / custom-gpi_inventory_limit_advanced.php
Created October 3, 2024 11:11
custom-gpi_inventory_limit_advanced.php
<?php
/**
* Filter the Graivyt Wiz Inventry limit to set it via custom field value
*/
add_filter( 'gpi_inventory_limit_advanced', 'cf_custom_inventory_limit' );
function cf_custom_inventory_limit( $limit ) {
$queried_object_id = get_queried_object_id();
if ( $queried_object_id == 0 ) {
$queried_object_id = get_transient( 'backup_queried_object_id' );
@saifsultanc
saifsultanc / gpeb-navigation-with-filtered-choices.php
Created October 2, 2024 06:52
gpeb-navigation-with-filtered-choices.php
<?php
// helper method
function get_array_subset( $array, $offset, $limit ) {
if ( $offset > count( $array ) - 1) {
return [];
}
$start = $offset;
$length = min( $limit, count( $array ) - $offset );
return array_slice( $array, $start, $length );
@saifsultanc
saifsultanc / GPNF_Triggered_Population.php
Created September 24, 2024 07:44
GPNF_Triggered_Population.php - Custom Update
<?php
class GPNF_Triggered_Population {
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' => 0,
@saifsultanc
saifsultanc / GPNF_Triggered_Population.php
Created September 23, 2024 12:06
GPNF_Triggered_Population - Custom Snippet
<?php
class GPNF_Triggered_Population {
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' => 0,
@saifsultanc
saifsultanc / gw-custom-none-of-the-above.js
Created September 20, 2024 19:11
Gravity Wiz // Gravity Forms // "None of the Above" Checkbox (With Multiple Checkboxes)
/**
* Gravity Wiz // Gravity Forms // "None of the Above" Checkbox
* https://gravitywiz.com/
*
* Instruction Video: https://www.loom.com/share/0f8de708790b4afd879bf0632efd7eae (Out of date)
*
* Use this snippet to enable a proper "None of the Above" option in your Checkbox fields. If any
* other option is checked, the "None of the Above" option will be disabled. If the "None of the Above"
* option is checked, all other options will be disabled.
*
@saifsultanc
saifsultanc / gw-custom-none-of-the-above.js
Created September 20, 2024 03:03
Gravity Wiz // Gravity Forms // "None of the Above" Checkbox
$( '.gw-none-of-the-above' ).each( function() {
var disable_nota = false;
var $field = $( this );
var $nota = $field.find('input[type="checkbox"]').filter(function() {
return $(this).val().toLowerCase() === 'none of the above';
});
var $others = $field.find( 'input' ).not( $nota );
// If "None of the Above" choice is checked by default.
gform.addFilter( 'gpcc_copied_value', function( value, targetElem, data ) {
$source = jQuery( '#input_' + data.sourceFormId + '_' + data.source );
if( $source.is( '.gfield_radio' ) ) {
value = $source.find( '.gfield-choice-input:checked + label' ).text();
} else {
return value;
}
var label = targetElem.next('label');
// Update field IDs
const startDateField = document.getElementById('input_GFFORMID_1');
const endDateField = document.getElementById('input_GFFORMID_3');
const countField = document.getElementById('input_GFFORMID_6');
function parseDateString(dateString) {
const parts = dateString.split('/');
const day = parseInt(parts[0], 10);
const month = parseInt(parts[1], 10) - 1;
const year = parseInt(parts[2], 10);