-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds support for the Legal Signature (both text and image-based signatures) and Legal Consent fields in Gravity PDF.
- Loading branch information
1 parent
cde4341
commit 15e9c9b
Showing
6 changed files
with
327 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace GFPDF\Helper\Fields; | ||
|
||
use Exception; | ||
use GF_Field_Consent; | ||
use GFPDF\Helper\Helper_Abstract_Fields; | ||
use GFPDF\Helper\Helper_Abstract_Form; | ||
use GFPDF\Helper\Helper_Misc; | ||
use GFPDF\Statics\Kses; | ||
|
||
/** | ||
* @package Gravity PDF | ||
* @copyright Copyright (c) 2024, Blue Liquid Designs | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | ||
*/ | ||
|
||
/* Exit if accessed directly */ | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
/** | ||
* Controls the display and output of a Gravity Form field | ||
* | ||
* @since 6.10 | ||
*/ | ||
class Field_Fg_Ls_Consent extends Field_Consent { | ||
public function form_data() { | ||
$label = $this->get_label(); | ||
$field_id = (int) $this->field->id; | ||
|
||
$data = []; | ||
|
||
/* Maintain backwards compatibility */ | ||
$value = $this->get_value(); | ||
$data[ $field_id . '.' . $label ] = $value; | ||
$data[ $field_id ] = $value; | ||
$data[ $label ] = $value; | ||
|
||
$value = $this->value(); | ||
$data[ $field_id . '.' . $label . '.2' ] = $value; | ||
$data[ $field_id . '.2' ] = $value; | ||
$data[ $label . '.2' ] = $value; | ||
|
||
return [ 'field' => $data ]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<?php | ||
|
||
namespace GFPDF\Helper\Fields; | ||
|
||
use GFCommon; | ||
use GFPDF\Helper\Helper_Abstract_Fields; | ||
|
||
/** | ||
* @package Gravity PDF | ||
* @copyright Copyright (c) 2024, Blue Liquid Designs | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | ||
*/ | ||
|
||
/* Exit if accessed directly */ | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
/** | ||
* Controls the display and output of Cosmic Giant's Legal Signing Signature field | ||
* | ||
* @since 6.10 | ||
*/ | ||
class Field_Fg_Ls_Signature extends Helper_Abstract_Fields { | ||
|
||
/** | ||
* Display the HTML version of this field | ||
* | ||
* @param string $value | ||
* @param bool $label | ||
* | ||
* @return string | ||
* | ||
* @since 6.10 | ||
*/ | ||
public function html( $value = '', $label = true ) { | ||
|
||
$data = $this->value(); | ||
|
||
if ( isset( $data['image'] ) ) { | ||
$html = sprintf( | ||
'<div class="legalsigning-field-signature__signed-signature"><img src="%1$s" /></div>', | ||
esc_attr( rgar( $data, 'image' ) ) | ||
); | ||
} else { | ||
$height = $this->field['canvasHeight'] ?? '150'; | ||
|
||
$styles = [ | ||
'background-color' => $this->field['backgroundColor'] ?? '#FFF', | ||
'color' => $this->field['penColor'] ?? '#000', | ||
'font-family' => ( $data['font'] ?? 'caveat' ) . ', cursive', | ||
'height' => (int) $height, | ||
]; | ||
|
||
$css = ''; | ||
foreach ( $styles as $property => $val ) { | ||
$css .= "$property: $val;"; | ||
} | ||
|
||
$html = sprintf( | ||
'<table> | ||
<tr> | ||
<td class="legalsigning-field-signature__signed-signature" style="%2$s">%1$s</td> | ||
</tr> | ||
</table>', | ||
esc_html( rgar( $data, 'name' ) ), | ||
esc_attr( $css ) | ||
); | ||
} | ||
|
||
$html = sprintf( | ||
'<div class="legalsigning-field-signature__signed"> | ||
<div class="legalsigning-field-signature__signed-by"> | ||
<span class="legalsigning-field-signature__signed-by--inner">%2$s</span> | ||
</div> | ||
<div class="legalsigning-field-signature__signed-wrapper">%1$s</div> | ||
<div class="legalsigning-field-signature__signed-verification"> | ||
<span class="legalsigning-field-signature__signed-verification--inner">%3$s</span> | ||
</div> | ||
</div>', | ||
$html, | ||
( $this->field['nameType'] ?? '' ) === 'initials' ? esc_html__( 'Initialed By', 'forgravity_legalsigning' ) : esc_html__( 'Signed By', 'forgravity_legalsigning' ), | ||
Check failure on line 84 in src/Helper/Fields/Field_Fg_Ls_Signature.php
|
||
esc_html__( 'Signed using Legal Signing', 'forgravity_legalsigning' ) | ||
Check failure on line 85 in src/Helper/Fields/Field_Fg_Ls_Signature.php
|
||
); | ||
|
||
return parent::html( $html ); | ||
} | ||
|
||
/** | ||
* Get form data array for current field | ||
* | ||
* @return array | ||
* | ||
* @since 6.10 | ||
*/ | ||
public function form_data() { | ||
$label = $this->get_label(); | ||
$field_id = (int) $this->field->id; | ||
|
||
$data = []; | ||
|
||
/* Maintain backwards compatibility */ | ||
$value = $this->get_value(); | ||
$data[ $field_id . '.' . $label ] = $value; | ||
$data[ $field_id ] = $value; | ||
$data[ $label ] = $value; | ||
|
||
$value = $this->value(); | ||
$data[ $field_id . '.' . $label . '.2' ] = $value; | ||
$data[ $field_id . '.2' ] = $value; | ||
$data[ $label . '.2' ] = $value; | ||
|
||
return [ 'field' => $data ]; | ||
} | ||
|
||
/** | ||
* Get the standard GF value of this field | ||
* | ||
* @return string|array | ||
* | ||
* @since 6.10 | ||
*/ | ||
public function value() { | ||
if ( $this->has_cache() ) { | ||
return $this->cache(); | ||
} | ||
|
||
$value = $this->get_value(); | ||
$value = \GFCommon::is_json( $value ) ? json_decode( $value, true ) : [ 'image' => $value ]; | ||
$this->cache( $value ); | ||
|
||
return $this->cache(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
/** | ||
* The styles needed to display the Legal Signing for Gravity Forms plugin fields | ||
* | ||
* @package Gravity PDF | ||
* @copyright Copyright (c) 2024, Blue Liquid Designs | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | ||
* @since 6.10 | ||
*/ | ||
|
||
/* Exit if accessed directly */ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
?> | ||
|
||
<style> | ||
.legalsigning-field-signature__signed { | ||
background: #FFF; | ||
padding: 10px; | ||
width: 400px; | ||
border-radius: 3px; | ||
} | ||
|
||
.legalsigning-field-signature__signed-wrapper { | ||
border: 1px solid rgba(11, 16, 51, 0.1); | ||
border-radius: 10px; | ||
padding: 6px 18px; | ||
} | ||
|
||
.legalsigning-field-signature__signed-signature { | ||
font-size: 38px; | ||
line-height: 55px; | ||
text-align: center; | ||
} | ||
|
||
.legalsigning-field-signature__signed-by, | ||
.legalsigning-field-signature__signed-verification { | ||
text-align: center; | ||
} | ||
|
||
.legalsigning-field-signature__signed-by { | ||
font-size: 7pt; | ||
text-transform: uppercase; | ||
letter-spacing: 0.92px; | ||
margin-bottom: -7px; | ||
z-index: 1; | ||
} | ||
|
||
.legalsigning-field-signature__signed-verification { | ||
font-size: 8pt; | ||
margin-top: -8px; | ||
} | ||
|
||
.legalsigning-field-signature__signed-by--inner, | ||
.legalsigning-field-signature__signed-verification--inner { | ||
border: 5px solid #FFF; | ||
border-top: 0; | ||
border-bottom: 0; | ||
background: #FFF; | ||
} | ||
|
||
/* Text Signatures */ | ||
.legalsigning-field-signature__signed-signature--caveat { | ||
font-family: "Caveat", caveat, cursive; | ||
} | ||
|
||
.legalsigning-field-signature__signed-signature--dancing-script { | ||
font-family: "Dancing Script", dancing-script, cursive; | ||
} | ||
|
||
.legalsigning-field-signature__signed-signature--homemade-apple { | ||
font-family: "Homemade Apple", homemade-apple, cursive; | ||
} | ||
|
||
.legalsigning-field-signature__signed-signature--permanent-marker { | ||
font-family: "Permanent Marker", permanent-marker, cursive; | ||
} | ||
|
||
.legalsigning-field-signature__signed-signature--rock-salt { | ||
font-family: "Rock Salt", rock-salt, cursive; | ||
} | ||
</style> |