Changeset 8672 for trunk/src/bp-xprofile/bp-xprofile-classes.php
- Timestamp:
- 07/23/2014 01:42:48 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-classes.php
r8671 r8672 2646 2646 2647 2647 $r = bp_parse_args( $raw_properties, array( 2648 'type' => 'url', 2649 'value' => esc_url( bp_get_the_profile_field_edit_value() ), 2648 'type' => 'text', 2649 'inputmode' => 'url', 2650 'value' => esc_url( bp_get_the_profile_field_edit_value() ), 2650 2651 ) ); ?> 2651 2652 … … 2692 2693 */ 2693 2694 public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {} 2695 2696 /** 2697 * Modify submitted URL values before validation. 2698 * 2699 * The URL validation regex requires a http(s) protocol, so that all 2700 * values saved in the database are fully-formed URLs. However, we 2701 * still want to allow users to enter URLs without a protocol, for a 2702 * better user experience. So we catch submitted URL values, and if 2703 * the protocol is missing, we prepend 'http://' before passing to 2704 * is_valid(). 2705 * 2706 * @since BuddyPress (2.1.0) 2707 * 2708 * @param string $submitted_value Raw value submitted by the user. 2709 * @return string 2710 */ 2711 public static function pre_validate_filter( $submitted_value ) { 2712 if ( false === strpos( $submitted_value, ':' ) 2713 && substr( $submitted_value, 0, 1 ) !== '/' 2714 && substr( $submitted_value, 0, 1 ) !== '#' 2715 && ! preg_match( '/^[a-z0-9-]+?\.php/i', $submitted_value ) 2716 ) { 2717 $submitted_value = 'http://' . $submitted_value; 2718 } 2719 2720 return $submitted_value; 2721 } 2694 2722 2695 2723 /** … … 3065 3093 3066 3094 /** 3095 * Allow field types to modify submitted values before they are validated. 3096 * 3097 * In some cases, it may be appropriate for a field type to catch 3098 * submitted values and modify them before they are passed to the 3099 * is_valid() method. For example, URL validation requires the 3100 * 'http://' scheme (so that the value saved in the database is always 3101 * a fully-formed URL), but in order to allow users to enter a URL 3102 * without this scheme, BP_XProfile_Field_Type_URL prepends 'http://' 3103 * when it's not present. 3104 * 3105 * By default, this is a pass-through method that does nothing. Only 3106 * override in your own field type if you need this kind of pre- 3107 * validation filtering. 3108 * 3109 * @since BuddyPress (2.1.0) 3110 * 3111 * @param mixed $submitted_value Submitted value. 3112 * @return mixed 3113 */ 3114 public static function pre_validate_filter( $field_value ) { 3115 return $field_value; 3116 } 3117 3118 /** 3067 3119 * Allow field types to modify the appearance of their values. 3068 3120 *
Note: See TracChangeset
for help on using the changeset viewer.