← All changes
|
front-end/default-fields/description/description.php
+24
-4
3.9.9
→
4.0.3
View file →
| @@ -1,7 +1,27 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 | 3 | |
| 4 | +/** | |
| 5 | + * Sanitize Default Biographical Info (stored as the WordPress user description). | |
| 6 | + * | |
| 7 | + * @param array $request Request data (e.g. $_POST) that may contain a `description` key. | |
| 8 | + * @return string | |
| 9 | + */ | |
| 10 | +function wppb_sanitize_default_biographical_info_from_request( $request ) { | |
| 11 | + if ( ! is_array( $request ) || ! array_key_exists( 'description', $request ) ) { | |
| 12 | + return ''; | |
| 13 | + } | |
| 14 | + | |
| 15 | + $meta_value = sanitize_textarea_field( wp_unslash( $request['description'] ) ); | |
| 16 | + | |
| 17 | + if ( apply_filters( 'wppb_form_field_textarea_escape_on_save', false ) ) { | |
| 18 | + $meta_value = esc_textarea( $meta_value ); | |
| 19 | + } | |
| 20 | + | |
| 21 | + return apply_filters( 'pre_user_description', $meta_value ); | |
| 22 | +} | |
| 23 | + | |
| 4 | 24 | /* handle field output */ |
| 5 | 25 | function wppb_description_handler( $output, $form_location, $field, $user_id, $field_check_errors, $request_data ){ |
| 6 | 26 | $item_title = apply_filters( 'wppb_'.$form_location.'_description_item_title', wppb_icl_t( 'plugin profile-builder-pro', 'default_field_'.$field['id'].'_title_translation', $field['field-title'], true ) ); |
| 7 | 27 | $item_description = wppb_icl_t( 'plugin profile-builder-pro', 'default_field_'.$field['id'].'_description_translation', $field['description'], true ); |
| @@ -14,8 +34,9 @@ | ||
| 14 | 34 | if ( trim( $input_value ) == '' && !empty( $field['default-content'] ) ) |
| 15 | 35 | $input_value = $field['default-content']; |
| 16 | 36 | |
| 17 | 37 | $input_value = ( isset( $request_data['description'] ) ? trim( $request_data['description'] ) : $input_value ); |
| 38 | + $input_value = apply_filters( 'wppb_form_description_field_value', $input_value, $field, $form_location ); | |
| 18 | 39 | |
| 19 | 40 | $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); |
| 20 | 41 | |
| 21 | 42 | if ( $form_location != 'back_end' ){ |
| @@ -51,12 +72,11 @@ | ||
| 51 | 72 | |
| 52 | 73 | /* handle field save */ |
| 53 | 74 | function wppb_userdata_add_description( $userdata, $global_request, $form_args ){ |
| 54 | 75 | if( wppb_field_exists_in_form( 'Default - Biographical Info', $form_args ) ) { |
| 55 | - if (isset($global_request['description'])) { | |
| 56 | - $description = apply_filters('pre_user_description', trim($global_request['description'])); | |
| 57 | - $userdata['description'] = $description; | |
| 58 | - } | |
| 76 | + if ( array_key_exists( 'description', $global_request ) ){ | |
| 77 | + $userdata['description'] = wppb_sanitize_default_biographical_info_from_request( $global_request ); | |
| 78 | + } | |
| 59 | 79 | } |
| 60 | 80 | return $userdata; |
| 61 | 81 | } |
| 62 | 82 | add_filter( 'wppb_build_userdata', 'wppb_userdata_add_description', 10, 3 ); |