[ Index ]

MailPress 7.1

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/options/form/field_types/email/ -> email.php (source)

   1  <?php
   2  class MP_Form_field_type_email extends MP_form_field_type_
   3  {
   4      var $file        = __FILE__;
   5  
   6      var $id        = 'email';
   7  
   8      var $category     = 'html';
   9  
  10      var $order        = 80;
  11  
  12  	function submitted( $field )
  13      {
  14          $this->field = $field;
  15  
  16          $value    = $this->get_value();
  17          $value    = trim( $value );
  18  
  19          $required     = ( isset( $this->field->settings['controls']['required'] ) && $this->field->settings['controls']['required'] );
  20          $empty     = empty( $value );
  21          $is_email     = ( MailPress::is_email( $value ) );
  22          if ( $required )
  23          {
  24              if ( $empty )
  25              {
  26                  $this->field->submitted['on_error'] = 1;
  27                  return $this->field;
  28              }
  29              if ( !$is_email )
  30              {
  31                  $this->field->submitted['on_error'] = 2;
  32                  return $this->field;
  33              }
  34          }
  35          if ( !$empty && !$is_email )
  36          {
  37              $this->field->submitted['on_error'] = 3;
  38              return $this->field;
  39          }
  40          return parent::submitted( $this->field );
  41      }
  42  
  43  	function attributes_filter( $no_reset )
  44      {
  45          $visitor_email = ( isset( $this->field->settings['options']['visitor_email'] ) && $this->field->settings['options']['visitor_email'] );
  46          if ( $visitor_email )
  47          {
  48              global $user_ID; switch ( true ) { case ( $user_ID != 0 && is_numeric( $user_ID ) ) : $user  = get_userdata( $user_ID ); $email = $user->user_email; break; default : $email = ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) ? $_COOKIE['comment_author_email_' . COOKIEHASH] : ''; break; }
  49              if ( !empty( $email ) ) $this->field->settings['attributes']['value'] = $email;
  50          }
  51  
  52          if ( !$no_reset ) return;
  53  
  54          parent::attributes_filter( $no_reset );
  55          $this->attributes_filter_css();
  56      }
  57  }
  58  new MP_Form_field_type_email( __( 'Email', 'MailPress' ) );


Generated: Mon Mar 11 18:33:33 2019 Cross-referenced by PHPXref 0.7.1