gform_signature_init_options

gform_signature_init_options

DescriptionUsageParametersExamples1. Fix IE11 issue2. Different size for mobile3. Fix Admin Bar issue4. Enable forceMouseEvent5. Change background colorSincePlacementSource Code

Description

The gform_signature_init_options filter can be used to customize the SuperSignature initialization options.

Usage

The following would apply to all forms.

add_filter( 'gform_signature_init_options', 'your_function_name', 10, 2 );

Parameters

$init_options array
The options to be used when initializing SuperSignature for this field.
$init_options = array(
'Enabled' => true,
'SignObject' => $field_id,
'BackColor' => empty( $this->backgroundColor ) ? '#FFFFFF' : $this->backgroundColor,
'PenSize' => rgblank( $this->penSize ) ? '2' : $this->penSize,
'PenColor' => empty( $this->penColor ) ? '#000000' : $this->penColor,
'SignWidth' => rgblank( $this->boxWidth ) ? '300' : $this->boxWidth,
'SignHeight' => '180',
'BorderStyle' => empty( $this->borderStyle ) ? 'Dashed' : $this->borderStyle,
'BorderWidth' => rgblank( $this->borderWidth ) ? '2px' : $this->borderWidth . 'px',
'BorderColor' => empty( $this->borderColor ) ? '#DDDDDD' : $this->borderColor,
'RequiredPoints' => '15',
'ClearImage' => gf_signature()->get_base_url() . '/includes/super_signature/refresh.png',
'PenCursor' => gf_signature()->get_base_url() . '/includes/super_signature/pen.cur',
'Visible' => true,
'ErrorMessage' => '',
'StartMessage' => '',
'SuccessMessage' => '',
);

$field Field Object
The current field object.

$form Form Object
The current form object.

Examples

1. Fix IE11 issue

This example shows how you can fix an issue with IE11 which prevents the signature being captured.

add_filter( 'gform_signature_init_options', 'disable_iemodalfix' );
function disable_iemodalfix( $init_options ) {
$init_options['IeModalFix'] = false;

return $init_options;
}

2. Different size for mobile

This example shows how you can set a different width for the signature panel for mobile devices.

add_filter( 'gform_signature_init_options', 'mobile_signature_width' );
function mobile_signature_width( $init_options ) {
if ( wp_is_mobile() ) {
$init_options['SignWidth'] = 100;
}

return $init_options;
}

3. Fix Admin Bar issue

This example shows how you can fix an issue with the vertical offset of the signature when the admin bar is present on mobile devices.

add_filter( 'gform_signature_init_options', 'enable_iemodalfix' );
function enable_iemodalfix( $init_options ) {
$init_options['IeModalFix'] = true;

return $init_options;
}

4. Enable forceMouseEvent

This example shows how you can enable the forceMouseEvent setting which resolves an issue with some browsers and devices.

add_filter( 'gform_signature_init_options', 'enable_forceMouseEvent' );
function enable_forceMouseEvent( $init_options ) {
$init_options['forceMouseEvent'] = true;

return $init_options;
}

5. Change background color

This example shows how you can change the background color.

add_filter( 'gform_signature_init_options', 'change_BackColor' );
function change_BackColor( $init_options ) {
$init_options['BackColor'] = '#4091EA';

return $init_options;
}

Since

This filter was added in Gravity Forms Signature Add-On 3.0.2.

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

This filter is located in GF_Field_Signature::get_supersignature_init_options() in class-gf-field-signature.php.

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注