gps_snaps
Description
Filter the snap positions for the slider. Controls where the slider handle can snap to and which tick marks/labels are displayed. Use showTick to hide tick marks while keeping the snap position. Set label to an empty string to hide the label.
Usage
Filter applied globally to all slider fields.
add_filter( 'gps_snaps', 'my_custom_function' );Filter applied to all slider fields in form FORMID.
add_filter( 'gps_snaps_FORMID', 'my_custom_function' );Filter applied to specific field FIELDID in form FORMID.
add_filter( 'gps_snaps_FORMID_FIELDID', 'my_custom_function' );Parameters
$config
array
The slider configuration array.
mode
string
selectionType
string
min
float|int
max
float|int
step
float|int
prefix
string
suffix
string
decimals
int
rangeSeparator
string
orientation
string
showTooltip
bool
showValue
bool
showTicks
bool
showTickLabels
bool
choices
array
defaultMin
mixed
defaultMax
mixed
$field
GF_Field
The current field object.
Examples
Show only first and last labels (keep all snap positions and tick marks)
add_filter( 'gps_snaps', function( $snaps, $config, $field ) {
$count = count( $snaps );
foreach ( $snaps as $index => &$snap ) {
if ( $index !== 0 && $index !== $count - 1 ) {
$snap['label'] = '';
}
}
return $snaps;
}, 10, 3 );Hide tick marks but keep labels visible
add_filter( 'gps_snaps_1_5', function( $snaps, $config, $field ) {
foreach ( $snaps as &$snap ) {
$snap['showTick'] = false;
}
return $snaps;
}, 10, 3 );Since
1.0Hook added.