/core/fields/email.php

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