diff --git src/bp-xprofile/bp-xprofile-classes.php src/bp-xprofile/bp-xprofile-classes.php
index 69a5144..bb0c049 100644
|
|
class BP_XProfile_Field_Type_Datebox extends BP_XProfile_Field_Type { |
1693 | 1693 | * @since BuddyPress (2.0.0) |
1694 | 1694 | */ |
1695 | 1695 | public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {} |
| 1696 | |
| 1697 | /** |
| 1698 | * Apply formatting specific to a Date field. |
| 1699 | * |
| 1700 | * @param string $field_value The date value, as saved in the database. |
| 1701 | * Typically, this is a MySQL-formatted date string (Y-m-d H:i:s). |
| 1702 | * @return string |
| 1703 | */ |
| 1704 | public static function display_filter( $field_value ) { |
| 1705 | // If Unix timestamp |
| 1706 | if ( is_numeric( $field_value ) ) { |
| 1707 | $field_value = bp_format_time( $field_value, true, false ); |
| 1708 | |
| 1709 | // If MySQL timestamp |
| 1710 | } else { |
| 1711 | $field_value = bp_format_time( strtotime( $field_value ), true, false ); |
| 1712 | } |
| 1713 | |
| 1714 | return $field_value; |
| 1715 | } |
1696 | 1716 | } |
1697 | 1717 | |
1698 | 1718 | /** |
… |
… |
abstract class BP_XProfile_Field_Type { |
2849 | 2869 | <?php |
2850 | 2870 | } |
2851 | 2871 | |
| 2872 | /** |
| 2873 | * Allow field types to modify the appearance of their values. |
| 2874 | * |
| 2875 | * By default, this is a pass-through method that does nothing. Only |
| 2876 | * override in your own field type if you need to provide custom |
| 2877 | * filtering for output values. |
| 2878 | * |
| 2879 | * @since BuddyPress (2.1.0) |
| 2880 | * |
| 2881 | * @param mixed $field_value Field value. |
| 2882 | * @return mixed |
| 2883 | */ |
| 2884 | public static function display_filter( $field_value ) { |
| 2885 | return $field_value; |
| 2886 | } |
2852 | 2887 | |
2853 | 2888 | /** |
2854 | 2889 | * 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..d230332 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( 'xprofile_get_field_data', 'xprofile_filter_format_field_value_by_field_id', 5, 2 ); |
| 53 | add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_format_field_value_by_type', 5, 2 ); |
52 | 54 | add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 ); |
53 | 55 | |
54 | 56 | 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 | 136 | if ( !isset( $field_value ) || empty( $field_value ) ) |
135 | 137 | return false; |
136 | 138 | |
137 | | if ( 'datebox' == $field_type ) { |
| 139 | if ( 'datebox' != $field_type ) { |
| 140 | $field_value = str_replace(']]>', ']]>', $field_value ); |
| 141 | } |
138 | 142 | |
139 | | // If Unix timestamp |
140 | | if ( is_numeric( $field_value ) ) { |
141 | | $field_value = bp_format_time( $field_value, true, false ); |
| 143 | return stripslashes( $field_value ); |
| 144 | } |
142 | 145 | |
143 | | // If MySQL timestamp |
144 | | } else { |
145 | | $field_value = bp_format_time( strtotime( $field_value ), true, false ); |
| 146 | /** |
| 147 | * Apply display_filter() filters as defined by the BP_XProfile_Field_Type classes, when fetched inside a bp_has_profile() loop. |
| 148 | * |
| 149 | * @since BuddyPress (2.1.0) |
| 150 | * |
| 151 | * @param mixed $field_value Field value. |
| 152 | * @param string $field_type Field type. |
| 153 | * @return mixed |
| 154 | */ |
| 155 | function xprofile_filter_format_field_value_by_type( $field_value, $field_type = '' ) { |
| 156 | foreach ( bp_xprofile_get_field_types() as $type => $class ) { |
| 157 | if ( $type !== $field_type ) { |
| 158 | continue; |
146 | 159 | } |
147 | 160 | |
148 | | } else { |
149 | | $field_value = str_replace(']]>', ']]>', $field_value ); |
| 161 | if ( method_exists( array( $class, 'display_filter' ) ) ) { |
| 162 | $field_value = call_user_func( array( $class, 'display_filter' ), $field_value ); |
| 163 | } |
150 | 164 | } |
151 | 165 | |
152 | | return stripslashes( $field_value ); |
| 166 | return $field_value; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Apply display_filter() filters as defined by the BP_XProfile_Field_Type classes, when fetched by xprofile_get_field_data(). |
| 171 | * |
| 172 | * @since BuddyPress (2.1.0) |
| 173 | * |
| 174 | * @param mixed $field_value |
| 175 | * @param int $field_id |
| 176 | */ |
| 177 | function xprofile_filter_format_field_value_by_field_id( $field_value, $field_id ) { |
| 178 | $field = new BP_XProfile_Field( $field_id ); |
| 179 | return xprofile_filter_format_field_value_by_type( $field_value, $field->type ); |
153 | 180 | } |
154 | 181 | |
155 | 182 | function xprofile_filter_link_profile_data( $field_value, $field_type = 'textbox' ) { |