diff --git src/bp-xprofile/bp-xprofile-classes.php src/bp-xprofile/bp-xprofile-classes.php
index 522bb45..df705c5 100644
|
|
class BP_XProfile_Field_Type_Datebox extends BP_XProfile_Field_Type { |
1691 | 1691 | * @since BuddyPress (2.0.0) |
1692 | 1692 | */ |
1693 | 1693 | public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {} |
| 1694 | |
| 1695 | /** |
| 1696 | * Apply formatting specific to a Date field. |
| 1697 | */ |
| 1698 | public function display_filter( $field_value ) { |
| 1699 | // If Unix timestamp |
| 1700 | if ( is_numeric( $field_value ) ) { |
| 1701 | $field_value = bp_format_time( $field_value, true, false ); |
| 1702 | |
| 1703 | // If MySQL timestamp |
| 1704 | } else { |
| 1705 | $field_value = bp_format_time( strtotime( $field_value ), true, false ); |
| 1706 | } |
| 1707 | |
| 1708 | return $field_value; |
| 1709 | } |
1694 | 1710 | } |
1695 | 1711 | |
1696 | 1712 | /** |
… |
… |
abstract class BP_XProfile_Field_Type { |
2847 | 2863 | <?php |
2848 | 2864 | } |
2849 | 2865 | |
| 2866 | /** |
| 2867 | * Allow field types to modify the appearance of their values. |
| 2868 | * |
| 2869 | * By default, this is a pass-through method that does nothing. Only |
| 2870 | * override in your own field type if you need to provide custom |
| 2871 | * filtering for output values. |
| 2872 | * |
| 2873 | * @since BuddyPress (2.1.0) |
| 2874 | * |
| 2875 | * @param mixed $field_value Field value. |
| 2876 | * @return mixed |
| 2877 | */ |
| 2878 | public function display_filter( $field_value ) { |
| 2879 | return $field_value; |
| 2880 | } |
2850 | 2881 | |
2851 | 2882 | /** |
2852 | 2883 | * Internal protected/private helper methods past this point. |
diff --git src/bp-xprofile/bp-xprofile-filters.php src/bp-xprofile/bp-xprofile-filters.php
index c049194..e648b66 100644
|
|
add_filter( 'xprofile_get_field_data', 'stripslashes' ); |
49 | 49 | |
50 | 50 | add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_format_field_value', 1, 2 ); |
51 | 51 | add_filter( 'bp_get_the_site_member_profile_data', 'xprofile_filter_format_field_value', 1, 2 ); |
| 52 | add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_format_field_value_by_type', 5, 2 ); |
52 | 53 | add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 ); |
53 | 54 | |
54 | 55 | add_filter( 'xprofile_data_value_before_save', 'xprofile_sanitize_data_value_before_save', 1, 2 ); |
… |
… |
function xprofile_filter_format_field_value( $field_value, $field_type = '' ) { |
134 | 135 | if ( !isset( $field_value ) || empty( $field_value ) ) |
135 | 136 | return false; |
136 | 137 | |
137 | | if ( 'datebox' == $field_type ) { |
| 138 | if ( 'datebox' != $field_type ) { |
| 139 | $field_value = str_replace(']]>', ']]>', $field_value ); |
| 140 | } |
138 | 141 | |
139 | | // If Unix timestamp |
140 | | if ( is_numeric( $field_value ) ) { |
141 | | $field_value = bp_format_time( $field_value, true, false ); |
| 142 | return stripslashes( $field_value ); |
| 143 | } |
142 | 144 | |
143 | | // If MySQL timestamp |
144 | | } else { |
145 | | $field_value = bp_format_time( strtotime( $field_value ), true, false ); |
| 145 | /** |
| 146 | * Apply display_filter() filters as defined by the BP_XProfile_Field_Type classes. |
| 147 | * |
| 148 | * @since BuddyPress (2.1.0) |
| 149 | * |
| 150 | * @param mixed $field_value Field value. |
| 151 | * @param string $field_type Field type. |
| 152 | * @return mixed |
| 153 | */ |
| 154 | function xprofile_filter_format_field_value_by_type( $field_value, $field_type = '' ) { |
| 155 | foreach ( bp_xprofile_get_field_types() as $type => $class ) { |
| 156 | if ( $type !== $field_type ) { |
| 157 | continue; |
146 | 158 | } |
147 | 159 | |
148 | | } else { |
149 | | $field_value = str_replace(']]>', ']]>', $field_value ); |
| 160 | if ( method_exists( array( $class, 'display_filter' ) ) ) { |
| 161 | $field_value = call_user_func( array( $class, 'display_filter' ), $field_value ); |
| 162 | } |
150 | 163 | } |
151 | 164 | |
152 | | return stripslashes( $field_value ); |
| 165 | return $field_value; |
153 | 166 | } |
154 | 167 | |
155 | 168 | function xprofile_filter_link_profile_data( $field_value, $field_type = 'textbox' ) { |