Bxcft_Field_Type_Web

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

Defined (1)

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

/classes/Bxcft_Field_Type_Web.php  
  1. class Bxcft_Field_Type_Web extends BP_XProfile_Field_Type 
  2. public function __construct() { 
  3. parent::__construct(); 
  4.  
  5. $this->name = _x( 'Website (HTML5 field)', 'xprofile field type', 'bxcft' ); 
  6.  
  7. $this->set_format( '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1, 3}) {3})(?!127(?:\.\d{1, 3}) {3})(?!169\.254(?:\.\d{1, 3}) {2})(?!192\.168(?:\.\d{1, 3}) {2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1, 3}) {2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1, 2}|2[0-4]\d|25[0-5])) {2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2, })))(?::\d{2, 5})?(?:/[^\s]*)?$_iuS', 'replace' ); 
  8. do_action( 'bp_xprofile_field_type_web', $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' => 'url' ),  
  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' => 'url',  
  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. No autolink feature for Web type. 
  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="%1$s">%1$s</a>',  
  65. $field_value); 
  66.  
  67. /** 
  68. * bxcft_web_display_filter 
  69. * Use this filter to modify the appearance of Web 
  70. * field value. 
  71. * @param $new_field_value Value of field 
  72. * @param $field_id Id of field. 
  73. * @return Filtered value of field. 
  74. */ 
  75. return apply_filters('bxcft_web_display_filter',  
  76. $new_field_value, $field_id);