/deprecated/includes/fields/password.php

  1. <?php if ( ! defined( 'ABSPATH' ) ) exit; 
  2. function ninja_forms_register_field_profile_pass() { 
  3. $args = array( 
  4. 'name' => __( 'Password', 'ninja-forms' ),  
  5. 'display_function' => 'ninja_forms_field_profile_pass_display',  
  6. 'group' => 'standard_fields',  
  7. 'edit_label' => true,  
  8. 'edit_label_pos' => false,  
  9. 'default_label_pos' => 'left',  
  10. 'edit_req' => true,  
  11. 'edit_custom_class' => true,  
  12. 'edit_help' => true,  
  13. 'edit_meta' => false,  
  14. 'sidebar' => 'template_fields',  
  15. 'edit_conditional' => true,  
  16. 'conditional' => array( 
  17. 'value' => array( 
  18. 'type' => 'text',  
  19. ),  
  20. ),  
  21. //'limit' => 1,  
  22. 'save_sub' => false,  
  23. 'pre_process' => 'ninja_forms_field_profile_pass_pre_process',  
  24. 'edit_options' => array( 
  25. array( 
  26. 'name' => 'reg_password',  
  27. 'type' => 'checkbox',  
  28. 'label' => __( 'Use this as a registration password field', 'ninja-forms' ),  
  29. 'default' => 1,  
  30. 'desc' => '<br>'.__( 'If this box is checked, both password and re-password textboxes will be output.', 'ninja-forms' ),  
  31. 'width' => 'wide',  
  32. ),  
  33. array( 
  34. 'name' => 're_pass',  
  35. 'type' => 'text',  
  36. 'label' => __( 'Re-enter Password Label', 'ninja-forms' ),  
  37. 'class' => 'widefat reg-password',  
  38. 'default' => __( 'Re-enter Password', 'ninja-forms' ),  
  39. 'width' => 'wide',  
  40. ),  
  41. array( 
  42. 'name' => 'adv_pass',  
  43. 'type' => 'checkbox',  
  44. 'label' => __( 'Show Password Strength Indicator', 'ninja-forms' ),  
  45. 'default' => 1,  
  46. 'class' => 'reg-password',  
  47. ),  
  48. ),  
  49. ); 
  50.  
  51. if( function_exists( 'ninja_forms_register_field' ) ) { 
  52. ninja_forms_register_field('_profile_pass', $args); 
  53.  
  54. add_action( 'init', 'ninja_forms_register_field_profile_pass' ); 
  55.  
  56. function ninja_forms_field_profile_pass_display( $field_id, $data, $form_id = '' ) { 
  57. global $current_user; 
  58. $field_class = ninja_forms_get_field_class( $field_id, $form_id ); 
  59.  
  60. if( isset( $data['default_value'] ) ) { 
  61. $default_value = $data['default_value']; 
  62. }else{ 
  63. $default_value = ''; 
  64.  
  65. if( isset( $data['adv_pass'] ) ) { 
  66. $adv_pass = $data['adv_pass']; 
  67. }else{ 
  68. $adv_pass = 0; 
  69.  
  70. $default_value_re = ''; 
  71.  
  72. if( isset( $data['label_pos'] ) ) { 
  73. $label_pos = $data['label_pos']; 
  74. }else{ 
  75. $label_pos = "left"; 
  76.  
  77. if( isset( $data['label'] ) ) { 
  78. $label = $data['label']; 
  79. }else{ 
  80. $label = ''; 
  81.  
  82. if( isset( $data['re_pass'] ) ) { 
  83. $re_pass = $data['re_pass']; 
  84. }else{ 
  85. $re_pass = ''; 
  86.  
  87. if( $label_pos == 'inside' ) { 
  88. $default_value = $label; 
  89. $default_value_re = $re_pass; 
  90.  
  91. if( isset( $data['reg_password'] ) ) { 
  92. $reg_password = $data['reg_password']; 
  93. }else{ 
  94. $reg_password = 1; 
  95.  
  96. if( $reg_password == 1 ) { 
  97. ?> 
  98. <input id="pass1_<?php echo $field_id;?>" title="" name="ninja_forms_field_<?php echo $field_id;?>" type="password" class="<?php echo $field_class;?> pass1" value="<?php echo $default_value;?>" rel="<?php echo $field_id;?>" /> 
  99. </div> 
  100. <div class="ninja-forms-pass2"> 
  101. <?php 
  102. if( $label_pos == 'left' OR $label_pos == 'above' ) { 
  103. ?> 
  104. <label><?php echo $re_pass;?></label> 
  105. <?php 
  106. ?> 
  107. <input id="pass2_<?php echo $field_id;?>" title="" name="_pass_<?php echo $field_id;?>" type="password" class="<?php echo $field_class;?> pass2" value="<?php echo $default_value_re;?>" /> 
  108. <?php 
  109. if( $label_pos == 'right' OR $label_pos == 'below' ) { 
  110. ?> 
  111. <label><?php echo $re_pass;?></label> 
  112. <?php 
  113. echo '</div>'; 
  114. if( $adv_pass == 1 ) { 
  115. $class = apply_filters( 'ninja_forms_display_field_desc_class', 'description indicator-hint', $field_id ); 
  116. ?> 
  117. <div id="pass-strength-result"><?php _e( 'Strength indicator', 'ninja-forms' ); ?></div> 
  118. <p class="<?php echo $class; ?>"><?php _e( 'Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).', 'ninja-forms' ); ?></p> 
  119. <?php 
  120.  
  121. }else{ 
  122. ?> 
  123. <input id="ninja_forms_field_<?php echo $field_id;?>" title="" name="ninja_forms_field_<?php echo $field_id;?>" type="password" class="<?php echo $field_class;?>" value="<?php echo $default_value;?>" rel="<?php echo $field_id;?>" /></div> 
  124. <?php 
  125.  
  126. function ninja_forms_field_profile_pass_pre_process( $field_id, $user_value ) { 
  127. global $ninja_forms_processing; 
  128.  
  129. $field_row = $ninja_forms_processing->get_field_settings( $field_id ); 
  130. $field_data = $field_row['data']; 
  131. if( isset( $field_data['reg_password'] ) AND $field_data['reg_password'] == 1 ) { 
  132. if( $user_value != $ninja_forms_processing->get_extra_value( '_pass_'.$field_id ) ) { 
  133. $ninja_forms_processing->add_error( 'mismatch-'.$field_id, __( 'Passwords do not match', 'ninja-forms' ), $field_id ); 
  134. }else{ 
  135. $ninja_forms_processing->update_extra_value( '_password', $user_value ); 
  136.  
  137. function ninja_forms_field_profile_add_open_wrapper( $field_id, $data ) { 
  138. $field_row = ninja_forms_get_field_by_id( $field_id ); 
  139. if ( '_profile_pass' == $field_row['type'] ) { 
  140. echo '<div class="ninja-forms-pass1">'; 
  141. add_action( 'ninja_forms_display_after_opening_field_wrap', 'ninja_forms_field_profile_add_open_wrapper', 10, 2 ); 
  142.  
  143. function ninja_forms_field_profile_add_close_wrapper( $field_id, $data ) { 
  144. $field_row = ninja_forms_get_field_by_id( $field_id ); 
  145. if ( '_profile_pass' == $field_row['type'] ) { 
  146. //echo '</div>'; 
  147. add_action( 'ninja_forms_display_before_closing_field_wrap', 'ninja_forms_field_profile_add_close_wrapper', 10, 2 ); 
.