[ Index ]

MailPress 7.1

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

title

Body

[close]

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

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


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