BP_XProfile_Field_Type_Number

Number xprofile field type.

Defined (1)

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

/bp-xprofile/classes/class-bp-xprofile-field-type-number.php  
  1. class BP_XProfile_Field_Type_Number extends BP_XProfile_Field_Type { 
  2.  
  3. /** 
  4. * Constructor for the number field type. 
  5. * @since 2.0.0 
  6. */ 
  7. public function __construct() { 
  8. parent::__construct(); 
  9.  
  10. $this->category = _x( 'Single Fields', 'xprofile field type category', 'buddypress' ); 
  11. $this->name = _x( 'Number', 'xprofile field type', 'buddypress' ); 
  12.  
  13. $this->set_format( '/^\d+|-\d+$/', 'replace' ); 
  14.  
  15. /** 
  16. * Fires inside __construct() method for BP_XProfile_Field_Type_Number class. 
  17. * @since 2.0.0 
  18. * @param BP_XProfile_Field_Type_Number $this Current instance of 
  19. * the field type number. 
  20. */ 
  21. do_action( 'bp_xprofile_field_type_number', $this ); 
  22.  
  23. /** 
  24. * Output the edit field HTML for this field type. 
  25. * Must be used inside the {@link bp_profile_fields()} template loop. 
  26. * @since 2.0.0 
  27. * @param array $raw_properties Optional key/value array of 
  28. * {@link http://dev.w3.org/html5/markup/input.number.html permitted attributes} 
  29. * that you want to add. 
  30. */ 
  31. public function edit_field_html( array $raw_properties = array() ) { 
  32.  
  33. // User_id is a special optional parameter that certain other fields 
  34. // types pass to {@link bp_the_profile_field_options()}. 
  35. if ( isset( $raw_properties['user_id'] ) ) { 
  36. unset( $raw_properties['user_id'] ); 
  37.  
  38. $r = bp_parse_args( $raw_properties, array( 
  39. 'type' => 'number',  
  40. 'value' => bp_get_the_profile_field_edit_value() 
  41. ) ); ?> 
  42.  
  43. <label for="<?php bp_the_profile_field_input_name(); ?>"> 
  44. <?php bp_the_profile_field_name(); ?> 
  45. <?php bp_the_profile_field_required_label(); ?> 
  46. </label> 
  47.  
  48. <?php 
  49.  
  50. /** This action is documented in bp-xprofile/bp-xprofile-classes */ 
  51. do_action( bp_get_the_profile_field_errors_action() ); ?> 
  52.  
  53. <input <?php echo $this->get_edit_field_html_elements( $r ); ?>> 
  54.  
  55. <?php 
  56.  
  57. /** 
  58. * Output HTML for this field type on the wp-admin Profile Fields screen. 
  59. * Must be used inside the {@link bp_profile_fields()} template loop. 
  60. * @since 2.0.0 
  61. * @param array $raw_properties Optional key/value array of permitted attributes that you want to add. 
  62. */ 
  63. public function admin_field_html( array $raw_properties = array() ) { 
  64. $r = bp_parse_args( $raw_properties, array( 
  65. 'type' => 'number' 
  66. ) ); ?> 
  67.  
  68. <label for="<?php bp_the_profile_field_input_name(); ?>" class="screen-reader-text"><?php 
  69. /** translators: accessibility text */ 
  70. esc_html_e( 'Number field', 'buddypress' ); 
  71. ?></label> 
  72. <input <?php echo $this->get_edit_field_html_elements( $r ); ?>> 
  73. <?php 
  74.  
  75. /** 
  76. * This method usually outputs HTML for this field type's children options on the wp-admin Profile Fields 
  77. * "Add Field" and "Edit Field" screens, but for this field type, we don't want it, so it's stubbed out. 
  78. * @since 2.0.0 
  79. * @param BP_XProfile_Field $current_field The current profile field on the add/edit screen. 
  80. * @param string $control_type Optional. HTML input type used to render the current 
  81. * field's child options. 
  82. */ 
  83. public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {}