Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2.  
  3. if ( ! class_exists( 'GFForms' ) ) {
  4.     die();
  5. }
  6.  
  7. class Optin_Field extends GF_Field_Checkbox {
  8.  
  9.     /**
  10.      * @var string $type The field type.
  11.      */
  12.     public $type = 'optin';
  13.     public $inputType = 'checkbox';
  14.  
  15.     /**
  16.      * Return the field title, for use in the form editor.
  17.      *
  18.      * @return string
  19.      */
  20.     public function get_form_editor_field_title() {
  21.         return esc_attr__( 'Email Opt-In', 'socialactionsaddon' );
  22.     }
  23.  
  24.     /**
  25.      * The scripts to be included in the form editor.
  26.      *
  27.      * @return string
  28.      */
  29.     public function get_form_editor_inline_script_on_page_render() {
  30.  
  31.         $script = sprintf( "function SetDefaultValues_%s(field) {
  32.             field.label = 'Subscribe';
  33.             field.choices = [new Choice('Subscribe to our Newsletter')];
  34.             field.labelPlacement = 'hidden_label';
  35.             }", $this->type ) . PHP_EOL;
  36.  
  37.         return $script;
  38.     }
  39. }
  40.  
  41. GF_Fields::register( new Optin_Field() );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement