mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
@@ -2767,7 +2767,22 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
} else {
|
||||
$textarea_field_value = '';
|
||||
if ( ! empty( $field_value ) ) {
|
||||
$textarea_field_value = ! empty( $data['html'] ) ? $field_value : wp_strip_all_tags( $field_value );
|
||||
$profile_custom_settings = get_post_meta( $this->global_args['form_id'], '_um_profile_use_custom_settings', true );
|
||||
if ( 1 === $profile_custom_settings ) {
|
||||
$bio_html = get_post_meta( $this->global_args['form_id'], '_um_profile_show_bio', true );
|
||||
} else {
|
||||
if ( UM()->options()->get( 'profile_show_html_bio' ) ) {
|
||||
$bio_html = 1;
|
||||
} else {
|
||||
$bio_html = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( 1 === (int) $bio_html && array_key_exists( 'html', $data ) && 1 === (int) $data['html'] ) {
|
||||
$textarea_field_value = $field_value;
|
||||
} else {
|
||||
$textarea_field_value = wp_strip_all_tags( $field_value );
|
||||
}
|
||||
}
|
||||
$output .= '<textarea ' . $disabled . ' style="height: ' . esc_attr( $data['height'] ) . ';" class="' . esc_attr( $this->get_class( $key, $data ) ) . '" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" placeholder="' . esc_attr( $placeholder ) . '">' . esc_textarea( $textarea_field_value ) . '</textarea>';
|
||||
}
|
||||
|
||||
@@ -573,9 +573,14 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
|
||||
}
|
||||
|
||||
if ( isset( $array['max_words'] ) && $array['max_words'] > 0 ) {
|
||||
// count words without html tags
|
||||
$without_tags = wp_strip_all_tags( $submitted_data[ $key ] );
|
||||
if ( str_word_count( $without_tags, 0, 'éèàôù' ) > $array['max_words'] ) {
|
||||
if ( array_key_exists( 'html', $array ) && 1 === (int) $array['html'] ) {
|
||||
$text_value = wp_strip_all_tags( $submitted_data[ $key ] );
|
||||
} else {
|
||||
// count words without html tags
|
||||
$text_value = $submitted_data[ $key ];
|
||||
}
|
||||
|
||||
if ( str_word_count( $text_value, 0, '0123456789éèàôù' ) > $array['max_words'] ) {
|
||||
// translators: %s: max words.
|
||||
UM()->form()->add_error( $key, sprintf( __( 'You are only allowed to enter a maximum of %s words', 'ultimate-member' ), $array['max_words'] ) );
|
||||
}
|
||||
@@ -668,6 +673,40 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
|
||||
}
|
||||
}
|
||||
|
||||
$description_key = UM()->profile()->get_show_bio_key( $array );
|
||||
if ( isset( $submitted_data['description'] ) && $description_key === $array['metakey'] ) {
|
||||
$max_chars = UM()->options()->get( 'profile_bio_maxchars' );
|
||||
$profile_show_bio = UM()->options()->get( 'profile_show_bio' );
|
||||
$description_key = UM()->profile()->get_show_bio_key( $array );
|
||||
|
||||
if ( array_key_exists( $description_key, $submitted_data['submitted'] ) ) {
|
||||
|
||||
if ( array_key_exists( 'max_chars', $array ) && ! empty( $array['max_chars'] ) ) {
|
||||
$max_chars = $array['max_chars'];
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'html', $array ) && 1 === (int) $array['html'] && 1 === (int) UM()->options()->get( 'profile_show_html_bio' ) ) {
|
||||
$description_value = wp_strip_all_tags( $submitted_data[ $description_key ] );
|
||||
} else {
|
||||
$description_value = $submitted_data[ $description_key ];
|
||||
}
|
||||
} else {
|
||||
if ( ! UM()->options()->get( 'profile_show_html_bio' ) ) {
|
||||
$description_value = $submitted_data['description'];
|
||||
} else {
|
||||
$description_value = wp_strip_all_tags( $submitted_data['description'] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $profile_show_bio ) {
|
||||
|
||||
if ( mb_strlen( str_replace( array( "\r\n", "\n", "\r\t", "\t" ), ' ', $description_value ) ) > $max_chars && $max_chars ) {
|
||||
// translators: %s: max chars.
|
||||
UM()->form()->add_error( 'description', sprintf( __( 'Your user description must contain less than %s characters', 'ultimate-member' ), $max_chars ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( empty( $array['validate'] ) ) {
|
||||
continue;
|
||||
}
|
||||
@@ -932,18 +971,6 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if ( isset( $submitted_data['description'] ) ) {
|
||||
$max_chars = UM()->options()->get( 'profile_bio_maxchars' );
|
||||
$profile_show_bio = UM()->options()->get( 'profile_show_bio' );
|
||||
|
||||
if ( $profile_show_bio ) {
|
||||
if ( mb_strlen( str_replace( array( "\r\n", "\n", "\r\t", "\t" ), ' ', $submitted_data['description'] ) ) > $max_chars && $max_chars ) {
|
||||
// translators: %s: max chars.
|
||||
UM()->form()->add_error( 'description', sprintf( __( 'Your user description must contain less than %s characters', 'ultimate-member' ), $max_chars ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end if ( isset in args array )
|
||||
}
|
||||
add_action( 'um_submit_form_errors_hook_', 'um_submit_form_errors_hook_', 10, 2 );
|
||||
|
||||
@@ -1237,15 +1237,36 @@ function um_profile_header( $args ) {
|
||||
} ?>
|
||||
</div>
|
||||
|
||||
<?php } elseif ( UM()->fields()->editing == true && $args['show_bio'] ) { ?>
|
||||
<?php } elseif ( UM()->fields()->editing == true && $args['show_bio'] ) {
|
||||
if ( ! empty( $args['custom_fields']['description'] ) ) {
|
||||
if ( array_key_exists( 'html', $args['custom_fields']['description'] ) && 1 === (int) $args['custom_fields']['description']['html'] && 1 === (int) UM()->options()->get( 'profile_show_html_bio' ) ) {
|
||||
$description_value = UM()->fields()->field_value( $description_key );
|
||||
} else {
|
||||
$description_value = wp_strip_all_tags( UM()->fields()->field_value( $description_key ) );
|
||||
}
|
||||
} else {
|
||||
if ( 1 === (int) UM()->options()->get( 'profile_show_html_bio' ) ) {
|
||||
$description_value = UM()->fields()->field_value( $description_key );
|
||||
} else {
|
||||
$description_value = wp_strip_all_tags( UM()->fields()->field_value( $description_key ) );
|
||||
}
|
||||
}
|
||||
if ( array_key_exists( 'max_chars', $args['custom_fields']['description'] ) ) {
|
||||
$limit = $args['custom_fields']['description']['max_chars'];
|
||||
} else {
|
||||
$limit = UM()->options()->get( 'profile_bio_maxchars' );
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="um-meta-text">
|
||||
<textarea id="um-meta-bio"
|
||||
data-character-limit="<?php echo esc_attr( UM()->options()->get( 'profile_bio_maxchars' ) ); ?>"
|
||||
data-html="<?php echo esc_attr( UM()->options()->get( 'profile_show_html_bio' ) ); ?>"
|
||||
data-character-limit="<?php echo esc_attr( $limit ); ?>"
|
||||
placeholder="<?php esc_attr_e( 'Tell us a bit about yourself...', 'ultimate-member' ); ?>"
|
||||
name="<?php echo esc_attr( $description_key ); ?>"><?php echo UM()->fields()->field_value( $description_key ) ?></textarea>
|
||||
<span class="um-meta-bio-character um-right"><span
|
||||
class="um-bio-limit"><?php echo UM()->options()->get( 'profile_bio_maxchars' ); ?></span></span>
|
||||
name="<?php echo esc_attr( $description_key ); ?>"><?php echo $description_value; ?></textarea>
|
||||
<span class="um-meta-bio-character um-right">
|
||||
<span class="um-bio-limit"><?php echo esc_html( $limit ); ?></span>
|
||||
</span>
|
||||
|
||||
<?php if ( UM()->fields()->is_error( $description_key ) ) {
|
||||
echo UM()->fields()->field_error( UM()->fields()->show_error( $description_key ), true );
|
||||
|
||||
Reference in New Issue
Block a user