Bxcft_Field_Type_Email

The BuddyPress Xprofile Custom Fields Type Bxcft Field Type Email class.

Defined (1)

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

/classes/Bxcft_Field_Type_Email.php  
  1. class Bxcft_Field_Type_Email extends BP_XProfile_Field_Type 
  2. public function __construct() { 
  3. parent::__construct(); 
  4.  
  5. $this->name = _x( 'Email (HTML5 field)', 'xprofile field type', 'bxcft' ); 
  6.  
  7. $this->set_format( '/^[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\.[a-zA-Z]{2, 4}$/', 'replace' ); // "something@something.some" 
  8. do_action( 'bp_xprofile_field_type_email', $this ); 
  9.  
  10. public function admin_field_html (array $raw_properties = array ()) 
  11. $html = $this->get_edit_field_html_elements( array_merge( 
  12. array( 'type' => 'email' ),  
  13. $raw_properties 
  14. ) ); 
  15. ?> 
  16. <input <?php echo $html; ?> /> 
  17. <?php 
  18.  
  19. public function edit_field_html (array $raw_properties = array ()) 
  20. if ( isset( $raw_properties['user_id'] ) ) { 
  21. unset( $raw_properties['user_id'] ); 
  22.  
  23. // HTML5 required attribute. 
  24. if ( bp_get_the_profile_field_is_required() ) { 
  25. $raw_properties['required'] = 'required'; 
  26.  
  27. $html = $this->get_edit_field_html_elements( array_merge( 
  28. array( 
  29. 'type' => 'email',  
  30. 'value' => bp_get_the_profile_field_edit_value(),  
  31. ),  
  32. $raw_properties 
  33. ) ); 
  34.  
  35. $label = sprintf( 
  36. '<label for="%s">%s%s</label>',  
  37. bp_get_the_profile_field_input_name(),  
  38. bp_get_the_profile_field_name(),  
  39. (bp_get_the_profile_field_is_required()) ? 
  40. ' ' . esc_html__( '(required)', 'buddypress' ) : '' 
  41. ); 
  42. // Label. 
  43. echo apply_filters('bxcft_field_label', $label, bp_get_the_profile_field_id(), bp_get_the_profile_field_type(), bp_get_the_profile_field_input_name(), bp_get_the_profile_field_name(), bp_get_the_profile_field_is_required()); 
  44. // Errors. 
  45. do_action( bp_get_the_profile_field_errors_action() ); 
  46. // Input. 
  47. ?> 
  48. <input <?php echo $html; ?> /> 
  49. <?php 
  50.  
  51. public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {} 
  52.  
  53. /** 
  54. * Modify the appearance of value. Apply autolink if enabled. 
  55. * @param string $value Original value of field 
  56. * @param int $field_id Id of field 
  57. * @return string Value formatted 
  58. */ 
  59. public static function display_filter($field_value, $field_id = '') { 
  60.  
  61. $new_field_value = $field_value; 
  62.  
  63. if (!empty($field_value)) { 
  64. $new_field_value = sprintf('<a href="mailto:%1$s" rel="nofollow">%1$s</a>',  
  65. $field_value); 
  66.  
  67. if (!empty($field_id)) { 
  68. $field = BP_XProfile_Field::get_instance($field_id); 
  69. if ($field) { 
  70. $do_autolink = apply_filters('bxcft_do_autolink',  
  71. $field->get_do_autolink()); 
  72. if ($do_autolink) { 
  73. $query_arg = bp_core_get_component_search_query_arg( 'members' ); 
  74. $search_url = add_query_arg( array( 
  75. $query_arg => urlencode( $field_value ) 
  76. ), bp_get_members_directory_permalink() ); 
  77. $new_field_value = '<a href="' . esc_url( $search_url ) . 
  78. '" rel="nofollow">' . $field_value . '</a>'; 
  79.  
  80. /** 
  81. * bxcft_email_display_filter 
  82. * Use this filter to modify the appearance of Email 
  83. * field value. 
  84. * @param $new_field_value Value of field 
  85. * @param $field_id Id of field. 
  86. * @return Filtered value of field. 
  87. */ 
  88. return apply_filters('bxcft_email_display_filter',  
  89. $new_field_value, $field_id);