Ticket #5589: ticket-5589.01.patch
File ticket-5589.01.patch, 3.4 KB (added by , 11 years ago) |
---|
-
bp-xprofile/bp-xprofile-classes.php
diff --git a/bp-xprofile/bp-xprofile-classes.php b/bp-xprofile/bp-xprofile-classes.php index 852214c..56ee31c 100644
a b class BP_XProfile_Field_Type_Number extends BP_XProfile_Field_Type { 2497 2497 } 2498 2498 2499 2499 /** 2500 * A placeholder xprofile field type. Doesn't do anything. 2501 * 2502 * Used if an existing field has an unknown type (e.g. one provided by a missing third-party plugin). 2503 * 2504 * @since BuddyPress (2.0.1) 2505 */ 2506 class BP_XProfile_Field_Type_Placeholder extends BP_XProfile_Field_Type { 2507 2508 /** 2509 * Constructor for the placeholder field type. 2510 * 2511 * @since BuddyPress (2.0.1) 2512 */ 2513 public function __construct() { 2514 } 2515 2516 /** 2517 * Prevent any HTML being ouptut for this field type. 2518 * 2519 * @param array $raw_properties Optional key/value array of {@link http://dev.w3.org/html5/markup/input.text.html permitted attributes} that you want to add. 2520 * @since BuddyPress (2.0.1) 2521 */ 2522 public function edit_field_html( array $raw_properties = array() ) { 2523 } 2524 2525 /** 2526 * Prevent any HTML being ouptut for this field type. 2527 * 2528 * @param array $raw_properties Optional key/value array of permitted attributes that you want to add. 2529 * @since BuddyPress (2.0.1) 2530 */ 2531 public function admin_field_html( array $raw_properties = array() ) { 2532 } 2533 2534 /** 2535 * Prevent any HTML being ouptut for this field type. 2536 * 2537 * @param BP_XProfile_Field $current_field The current profile field on the add/edit screen. 2538 * @param string $control_type Optional. HTML input type used to render the current field's child options. 2539 * @since BuddyPress (2.0.1) 2540 */ 2541 public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {} 2542 } 2543 2544 /** 2500 2545 * Represents a type of XProfile field and holds meta information about the type of value that it accepts. 2501 2546 * 2502 2547 * @since BuddyPress (2.0.0) -
bp-xprofile/bp-xprofile-functions.php
diff --git a/bp-xprofile/bp-xprofile-functions.php b/bp-xprofile/bp-xprofile-functions.php index 31f890a..a165405 100644
a b function bp_xprofile_create_field_type( $type ) { 95 95 $class = isset( $field[$type] ) ? $field[$type] : ''; 96 96 97 97 /** 98 * For backpat and to handle (missing) field types introduced by other plugins, fallback to 99 * textbox if a type is unknown. Textbox validation and display is intentionally low key. 98 * To handle (missing) field types, fallback to a placeholder field object if a type is unknown. 100 99 */ 101 100 if ( $class && class_exists( $class ) ) { 102 101 return new $class; 103 102 } else { 104 return new BP_XProfile_Field_Type_ Textbox;103 return new BP_XProfile_Field_Type_Placeholder; 105 104 } 106 105 } 107 106 -
tests/testcases/xprofile/class-bp-xprofile-field-type.php
diff --git a/tests/testcases/xprofile/class-bp-xprofile-field-type.php b/tests/testcases/xprofile/class-bp-xprofile-field-type.php index 72d5d6b..04ace3c 100644
a b class BP_Tests_XProfile_Field_Type extends BP_UnitTestCase { 14 14 15 15 public function test_unregistered_field_type_returns_textbox() { 16 16 $field = bp_xprofile_create_field_type( 'fakeyfield' ); 17 $this->assertEquals( get_class( $field ), 'BP_XProfile_Field_Type_ Textbox' );17 $this->assertEquals( get_class( $field ), 'BP_XProfile_Field_Type_Placeholder' ); 18 18 } 19 19 20 20 public function test_textbox_validate_empty_string() {