mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- reviewed #1269;
- unified `UM()->fields()->editing` and `UM()->fields()->viewing` to bool variables use true|false in conditions to make `===` or `!==` comparing;
This commit is contained in:
@@ -625,11 +625,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$output = null;
|
||||
$output .= '<div class="um-field-label">';
|
||||
|
||||
if ( isset( $data['icon'] ) && $data['icon'] != '' && isset( $this->field_icons ) && $this->field_icons != 'off' && ( $this->field_icons == 'label' || $this->viewing == true ) ) {
|
||||
if ( isset( $data['icon'] ) && $data['icon'] != '' && isset( $this->field_icons ) && $this->field_icons != 'off' && ( $this->field_icons == 'label' || true === $this->viewing ) ) {
|
||||
$output .= '<div class="um-field-label-icon"><i class="' . esc_attr( $data['icon'] ) . '" aria-label="' . esc_attr( $label ) . '"></i></div>';
|
||||
}
|
||||
|
||||
if ( $this->viewing == true ) {
|
||||
if ( true === $this->viewing ) {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -705,7 +705,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
$output .= '<label' . $for_attr . '>' . __( $label, 'ultimate-member' ) . '</label>';
|
||||
|
||||
if ( ! empty( $data['help'] ) && $this->viewing == false && ! strstr( $key, 'confirm_user_pass' ) ) {
|
||||
if ( ! empty( $data['help'] ) && false === $this->viewing && ! strstr( $key, 'confirm_user_pass' ) ) {
|
||||
if ( ! UM()->mobile()->isMobile() ) {
|
||||
if ( false === $this->disable_tooltips ) {
|
||||
$output .= '<span class="um-tip um-tip-' . ( is_rtl() ? 'e' : 'w' ) . '" title="' . esc_attr__( $data['help'], 'ultimate-member' ) . '"><i class="um-icon-help-circled"></i></span>';
|
||||
@@ -836,7 +836,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
return stripslashes_deep( UM()->form()->post_form[ $key ] );
|
||||
|
||||
} elseif ( um_user( $key ) && $this->editing == true ) {
|
||||
} elseif ( um_user( $key ) && true === $this->editing ) {
|
||||
|
||||
//show empty value for password fields
|
||||
if ( strstr( $key, 'user_pass' ) || $type == 'password' ) {
|
||||
@@ -889,7 +889,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
*/
|
||||
$value = apply_filters( "um_edit_{$type}_field_value", $value, $key );
|
||||
|
||||
} elseif ( ( um_user( $key ) || isset( $data['show_anyway'] ) ) && $this->viewing == true ) {
|
||||
} elseif ( ( um_user( $key ) || isset( $data['show_anyway'] ) ) && true === $this->viewing ) {
|
||||
|
||||
return um_filtered_value( $key, $data );
|
||||
|
||||
@@ -993,7 +993,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
}
|
||||
|
||||
// Default Value for Registration Form and Profile Form editing
|
||||
if ( ! isset( $value ) && ( $this->set_mode == 'register' || $this->editing == true ) ) {
|
||||
if ( ! isset( $value ) && ( $this->set_mode == 'register' || true === $this->editing ) ) {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
@@ -1173,7 +1173,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
*/
|
||||
$data = apply_filters( 'um_is_selected_filter_data', $data, $key, $field_value );
|
||||
|
||||
if ( ! $this->editing || 'custom' == $this->set_mode ) {
|
||||
if ( false === $this->editing || 'custom' === $this->set_mode ) {
|
||||
// show default on register screen if there is default
|
||||
if ( isset( $data['default'] ) ) {
|
||||
|
||||
@@ -1258,7 +1258,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
}
|
||||
} else {
|
||||
|
||||
if ( $this->editing && 'custom' !== $this->set_mode ) {
|
||||
if ( true === $this->editing && 'custom' !== $this->set_mode ) {
|
||||
if ( um_user( $key ) ) {
|
||||
|
||||
$um_user_value = um_user( $key );
|
||||
@@ -1611,7 +1611,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$array['default'] = null;
|
||||
}
|
||||
|
||||
if ( isset( $array['conditions'] ) && is_array( $array['conditions'] ) && ! $this->viewing ) {
|
||||
if ( isset( $array['conditions'] ) && is_array( $array['conditions'] ) && false === $this->viewing ) {
|
||||
$array['conditional'] = '';
|
||||
|
||||
foreach ( $array['conditions'] as $cond_id => $cond ) {
|
||||
@@ -2178,7 +2178,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $this->editing ) && 'profile' === $this->set_mode ) {
|
||||
if ( true === $this->editing && 'profile' === $this->set_mode ) {
|
||||
if ( ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
||||
if ( empty( $data['editable'] ) ) {
|
||||
$disabled = ' disabled="disabled" ';
|
||||
@@ -2716,10 +2716,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$field_name = $key;
|
||||
$field_value = $this->field_value( $key, $default, $data );
|
||||
|
||||
$bio_key = UM()->profile()->get_show_bio_key( $this->global_args );
|
||||
|
||||
$output .= '<div class="um-field-area">';
|
||||
|
||||
if ( isset( $data['html'] ) && 0 !== $data['html'] && 'description' !== $key ) {
|
||||
|
||||
if ( ! empty( $data['html'] ) && $bio_key !== $key ) {
|
||||
$textarea_settings = array(
|
||||
'media_buttons' => false,
|
||||
'wpautop' => false,
|
||||
@@ -2761,24 +2762,29 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
// echo the editor to the buffer
|
||||
wp_editor( $field_value, $key, $textarea_settings );
|
||||
|
||||
// add the contents of the buffer to the output variable
|
||||
// Add the contents of the buffer to the output variable.
|
||||
$output .= ob_get_clean();
|
||||
$output .= '<br /><span class="description">' . esc_html( $placeholder ) . '</span>';
|
||||
} else {
|
||||
// User 'description' field uses `<textarea>` block everytime.
|
||||
$textarea_field_value = '';
|
||||
if ( ! empty( $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;
|
||||
$bio_html = false;
|
||||
$global_setting = UM()->options()->get( 'profile_show_html_bio' );
|
||||
if ( 'profile' === $this->global_args['mode'] ) {
|
||||
if ( ! empty( $this->global_args['use_custom_settings'] ) ) {
|
||||
if ( ! empty( $this->global_args['show_bio'] ) ) {
|
||||
$bio_html = ! empty( $global_setting );
|
||||
}
|
||||
} else {
|
||||
$bio_html = 0;
|
||||
$global_show_bio = UM()->options()->get( 'profile_show_bio' );
|
||||
if ( ! empty( $global_show_bio ) ) {
|
||||
$bio_html = ! empty( $global_setting );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 1 === (int) $bio_html && array_key_exists( 'html', $data ) && 1 === (int) $data['html'] ) {
|
||||
if ( true === $bio_html && ! empty( $data['html'] ) ) {
|
||||
$textarea_field_value = $field_value;
|
||||
} else {
|
||||
$textarea_field_value = wp_strip_all_tags( $field_value );
|
||||
@@ -4270,8 +4276,25 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
if ( ! empty( $res ) ) {
|
||||
$res = stripslashes( $res );
|
||||
}
|
||||
if ( 'description' === $data['metakey'] ) {
|
||||
if ( UM()->options()->get( 'profile_show_html_bio' ) ) {
|
||||
|
||||
$bio_key = UM()->profile()->get_show_bio_key( $this->global_args );
|
||||
if ( $bio_key === $data['metakey'] ) {
|
||||
$bio_html = false;
|
||||
$global_setting = UM()->options()->get( 'profile_show_html_bio' );
|
||||
if ( 'profile' === $this->global_args['mode'] ) {
|
||||
if ( ! empty( $this->global_args['use_custom_settings'] ) ) {
|
||||
if ( ! empty( $this->global_args['show_bio'] ) ) {
|
||||
$bio_html = ! empty( $global_setting );
|
||||
}
|
||||
} else {
|
||||
$global_show_bio = UM()->options()->get( 'profile_show_bio' );
|
||||
if ( ! empty( $global_show_bio ) ) {
|
||||
$bio_html = ! empty( $global_setting );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( true === $bio_html && ! empty( $data['html'] ) ) {
|
||||
$res = make_clickable( wpautop( wp_kses_post( $res ) ) );
|
||||
} else {
|
||||
$res = esc_html( $res );
|
||||
|
||||
Reference in New Issue
Block a user