Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( ! class_exists( 'GFForms' ) ) {
- die();
- }
- class Optin_Field extends GF_Field_Checkbox {
- /**
- * @var string $type The field type.
- */
- public $type = 'optin';
- public $inputType = 'checkbox';
- /**
- * Return the field title, for use in the form editor.
- *
- * @return string
- */
- public function get_form_editor_field_title() {
- return esc_attr__( 'Email Opt-In', 'socialactionsaddon' );
- }
- /**
- * The scripts to be included in the form editor.
- *
- * @return string
- */
- public function get_form_editor_inline_script_on_page_render() {
- $script = sprintf( "function SetDefaultValues_%s(field) {
- field.label = 'Subscribe';
- field.choices = [new Choice('Subscribe to our Newsletter')];
- field.labelPlacement = 'hidden_label';
- }", $this->type ) . PHP_EOL;
- return $script;
- }
- }
- GF_Fields::register( new Optin_Field() );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement