/core/fields/password.php

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