acf_field_email

The Advanced Custom Fields acf field email class.

Defined (1)

The class is defined in the following location(s).

/core/fields/email.php  
  1. class acf_field_email extends acf_field 
  2.  
  3. /** 
  4. * __construct 
  5. * Set name / label needed for actions / filters 
  6. * @since 3.6 
  7. * @date 23/01/13 
  8. */ 
  9.  
  10. function __construct() 
  11. // vars 
  12. $this->name = 'email'; 
  13. $this->label = __("Email", 'acf'); 
  14. $this->defaults = array( 
  15. 'default_value' => '',  
  16. 'placeholder' => '',  
  17. 'prepend' => '',  
  18. 'append' => '' 
  19. ); 
  20.  
  21.  
  22. // do not delete! 
  23. parent::__construct(); 
  24.  
  25.  
  26. /** 
  27. * create_field() 
  28. * Create the HTML interface for your field 
  29. * @param $field - an array holding all the field's data 
  30. * @type action 
  31. * @since 3.6 
  32. * @date 23/01/13 
  33. */ 
  34.  
  35. function create_field( $field ) 
  36. // vars 
  37. $o = array( 'id', 'class', 'name', 'value', 'placeholder' ); 
  38. $e = ''; 
  39.  
  40.  
  41. // prepend 
  42. if( $field['prepend'] !== "" ) 
  43. $field['class'] .= ' acf-is-prepended'; 
  44. $e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>'; 
  45.  
  46.  
  47. // append 
  48. if( $field['append'] !== "" ) 
  49. $field['class'] .= ' acf-is-appended'; 
  50. $e .= '<div class="acf-input-append">' . $field['append'] . '</div>'; 
  51.  
  52.  
  53. $e .= '<div class="acf-input-wrap">'; 
  54. $e .= '<input type="email"'; 
  55.  
  56. foreach( $o as $k ) 
  57. $e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';  
  58.  
  59. $e .= ' />'; 
  60. $e .= '</div>'; 
  61.  
  62.  
  63. // return 
  64. echo $e; 
  65.  
  66.  
  67. /** 
  68. * create_options() 
  69. * Create extra options for your field. This is rendered when editing a field. 
  70. * The value of $field['name'] can be used (like bellow) to save extra data to the $field 
  71. * @type action 
  72. * @since 3.6 
  73. * @date 23/01/13 
  74. * @param $field - an array holding all the field's data 
  75. */ 
  76.  
  77. function create_options( $field ) 
  78. // vars 
  79. $key = $field['name']; 
  80.  
  81. ?> 
  82. <tr class="field_option field_option_<?php echo $this->name; ?>"> 
  83. <td class="label"> 
  84. <label><?php _e("Default Value", 'acf'); ?></label> 
  85. <p><?php _e("Appears when creating a new post", 'acf') ?></p> 
  86. </td> 
  87. <td> 
  88. <?php 
  89.  
  90. do_action('acf/create_field', array( 
  91. 'type' => 'text',  
  92. 'name' => 'fields['.$key.'][default_value]',  
  93. 'value' => $field['default_value'],  
  94. )); 
  95.  
  96. ?> 
  97. </td> 
  98. </tr> 
  99. <tr class="field_option field_option_<?php echo $this->name; ?>"> 
  100. <td class="label"> 
  101. <label><?php _e("Placeholder Text", 'acf'); ?></label> 
  102. <p><?php _e("Appears within the input", 'acf') ?></p> 
  103. </td> 
  104. <td> 
  105. <?php  
  106. do_action('acf/create_field', array( 
  107. 'type' => 'text',  
  108. 'name' => 'fields[' .$key.'][placeholder]',  
  109. 'value' => $field['placeholder'],  
  110. )); 
  111. ?> 
  112. </td> 
  113. </tr> 
  114. <tr class="field_option field_option_<?php echo $this->name; ?>"> 
  115. <td class="label"> 
  116. <label><?php _e("Prepend", 'acf'); ?></label> 
  117. <p><?php _e("Appears before the input", 'acf') ?></p> 
  118. </td> 
  119. <td> 
  120. <?php  
  121. do_action('acf/create_field', array( 
  122. 'type' => 'text',  
  123. 'name' => 'fields[' .$key.'][prepend]',  
  124. 'value' => $field['prepend'],  
  125. )); 
  126. ?> 
  127. </td> 
  128. </tr> 
  129. <tr class="field_option field_option_<?php echo $this->name; ?>"> 
  130. <td class="label"> 
  131. <label><?php _e("Append", 'acf'); ?></label> 
  132. <p><?php _e("Appears after the input", 'acf') ?></p> 
  133. </td> 
  134. <td> 
  135. <?php  
  136. do_action('acf/create_field', array( 
  137. 'type' => 'text',  
  138. 'name' => 'fields[' .$key.'][append]',  
  139. 'value' => $field['append'],  
  140. )); 
  141. ?> 
  142. </td> 
  143. </tr> 
  144. <?php 
  145. }  
  146.