diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php
index 6fe88ed5..acda401f 100644
--- a/includes/core/class-fields.php
+++ b/includes/core/class-fields.php
@@ -2140,70 +2140,13 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
// Merge data passed with original field data.
$data = array_merge( $origin_data, $data );
}
-
- /**
- * @var string $in_row
- * @var boolean $in_sub_row
- * @var boolean $in_column
- * @var string $type
- * @var string $metakey
- * @var int $position
- * @var string $title
- * @var string $help
- * @var array $options
- * @var string $visibility
- * @var string $label
- * @var string $placeholder
- * @var boolean $public
- * @var boolean $editable
- * @var string $icon
- * @var boolean $in_group
- * @var boolean $required
- * @var string $validate
- * @var string $default
- * @var string $conditional
- * @var string $input
- * @var string $js_format
- * @var string $date_max
- * @var string $date_min
- * @var string $disabled_weekdays
- * @var string $years_x
- * @var string $years
- * @var string $range
- * @var string $intervals
- * @var string $height
- * @var string $spacing
- * @var string $borderwidth
- * @var string $borderstyle
- * @var string $bordercolor
- * @var string $divider_text
- * @var string $crop_class
- * @var string $crop_data
- * @var string $modal_size
- * @var string $ratio
- * @var string $min_width
- * @var string $min_height
- * @var string $button_text
- * @var string $max_size
- * @var string $max_size_error
- * @var string $extension_error
- * @var string $allowed_types
- * @var string $upload_text
- * @var string $max_files_error
- * @var string $upload_help_text
- * @var string $min_size_error
- * @var string $filter
- * @var string $content
- * @var string $max_entries
- */
- extract( $data );
}
if ( ! isset( $data['type'] ) ) {
return '';
}
- if ( isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group' ) {
+ if ( isset( $data['in_group'] ) && '' !== $data['in_group'] && 'group' !== $rule ) {
return '';
}
@@ -2215,7 +2158,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
// required option? 'required_opt' - it's field attribute predefined in the field data in code
if ( isset( $data['required_opt'] ) ) {
$opt = $data['required_opt'];
- if ( UM()->options()->get( $opt[0] ) != $opt[1] ) {
+ if ( UM()->options()->get( $opt[0] ) !== $opt[1] ) {
return '';
}
}
@@ -2229,12 +2172,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
// fields that need to be disabled in edit mode (profile) (email, username, etc.)
$arr_restricted_fields = $this->get_restricted_fields_for_edit( $_um_profile_id );
- if ( in_array( $key, $arr_restricted_fields ) && $this->editing == true && $this->set_mode == 'profile' ) {
+ if ( in_array( $key, $arr_restricted_fields, true ) && true === $this->editing && 'profile' === $this->set_mode ) {
return '';
}
-
- if ( $visibility == 'view' && $this->set_mode != 'register' ) {
+ if ( 'view' === $data['visibility'] && 'register' !== $this->set_mode ) {
return '';
}
@@ -2246,7 +2188,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
// Stop return empty values build field attributes:
- if ( $visibility == 'view' && $this->set_mode == 'register' ) {
+ if ( 'view' === $data['visibility'] && 'register' === $this->set_mode ) {
um_fetch_user( get_current_user_id() );
if ( ! um_user( 'can_edit_everyone' ) ) {
@@ -2254,7 +2196,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
}
um_fetch_user( $_um_profile_id );
- if ( isset( $data['public'] ) && $data['public'] == '-2' && $data['roles'] ) {
+ if ( isset( $data['public'] ) && '-2' === $data['public'] && $data['roles'] ) {
$current_user_roles = um_user( 'roles' );
if ( ! empty( $current_user_roles ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) > 0 ) {
$disabled = '';
@@ -2262,9 +2204,9 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
}
}
- if ( ! empty( $this->editing ) && $this->set_mode == 'profile' ) {
+ if ( ! empty( $this->editing ) && 'profile' === $this->set_mode ) {
if ( ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
- if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
+ if ( isset( $data['editable'] ) && 0 === $data['editable'] ) {
$disabled = ' disabled="disabled" ';
}
}
@@ -2274,41 +2216,47 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
if ( ! isset( $data['autocomplete'] ) ) {
$autocomplete = 'off';
+ } else {
+ $autocomplete = $data['autocomplete'];
}
if ( isset( $data['classes'] ) ) {
- $classes = explode( " ", $data['classes'] );
+ $classes = explode( ' ', $data['classes'] );
+ } else {
+ $classes = '';
}
um_fetch_user( $_um_profile_id );
+ if ( ! isset( $data['type'] ) ) {
+ return '';
+ }
+ $type = $data['type'];
+
/**
- * UM hook
+ * Filters change field type.
*
- * @type filter
- * @title um_hook_for_field_{$type}
- * @description Change field type
- * @input_vars
- * [{"var":"$type","type":"string","desc":"Field Type"}]
- * @change_log
- * ["Since: 2.0"]
- * @usage add_filter( 'um_hook_for_field_{$type}', 'function_name', 10, 1 );
- * @example
- * Change field type.
+ * function my_field_type( $type ) {
* // your code here
* return $type;
* }
- * ?>
+ * add_filter( 'um_hook_for_field_{$type}', 'my_field_type', 10, 1 );
*/
$type = apply_filters( "um_hook_for_field_{$type}", $type );
switch ( $type ) {
case 'textarea':
case 'multiselect':
- $field_id = $field_name = $key;
- $field_value = $this->field_value( $key, $default, $data );
+ $field_id = $field_name = $key;
+ $field_value = $this->field_value( $key, $data['default'], $data );
break;
case 'select':
@@ -2322,30 +2270,26 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
}
/**
- * UM hook
+ * Filters change core id not allowed duplicate.
*
- * @type filter
- * @title um_completeness_field_id
- * @description use for change core id not allowed duplicate
- * @input_vars
- * [{"var":"$field_id","type":"string","desc":"Field id"},
- * {"var":"$data","type":"array","desc":"Field Data"}]
- * {"var":"$args","type":"array","desc":"Optional field arguments"}]
- * @change_log
- * ["Since: 2.0.13"]
- * @usage add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
- * @example
- * Change core id.
* function function_name( $field_id, $data, $args ) {
* // your code here
* return $field_id;
* }
- * ?>
+ * add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
*/
$field_id = apply_filters( 'um_completeness_field_id', $field_id, $data, $args );
-
/* Begin by field type */
switch ( $type ) {
@@ -2354,27 +2298,23 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$mode = ( isset( $this->set_mode ) ) ? $this->set_mode : 'no_mode';
/**
- * UM hook
+ * Filters change field html by $mode and field $type
*
- * @type filter
- * @title um_edit_field_{$mode}_{$type}
- * @description Change field html by $mode and field $type
- * @input_vars
- * [{"var":"$output","type":"string","desc":"Field HTML"},
- * {"var":"$data","type":"array","desc":"Field Data"}]
- * @change_log
- * ["Since: 2.0"]
- * @usage add_filter( 'um_edit_field_{$mode}_{$type}', 'function_name', 10, 2 );
- * @example
- * Change field html by $mode and field $type.
* function my_edit_field_html( $output, $data ) {
* // your code here
* return $output;
* }
- * ?>
+ * add_filter( 'um_edit_field_{$mode}_{$type}', 'my_edit_field_html', 10, 2 );
*/
-
$output .= apply_filters( "um_edit_field_{$mode}_{$type}", $output, $data );
break;
@@ -2384,26 +2324,23 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
case 'vimeo_video':
case 'spotify':
case 'soundcloud_track':
-
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
if ( isset( $data['label'] ) ) {
- $output .= $this->field_label( $label, $key, $data );
+ $output .= $this->field_label( $data['label'], $key, $data );
}
$output .= '
';
- if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
-
- $output .= '
';
-
+ if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons ) {
+ $output .= '
';
}
$field_name = $key . $form_suffix;
- $field_value = $this->field_value( $key, $default, $data );
+ $field_value = $this->field_value( $key, $data['default'], $data );
$field_value = ! is_null( $field_value ) ? htmlspecialchars( $field_value ) : null;
- $output .= '
+ $output .= '
';
@@ -2413,7 +2350,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
if ( $this->is_error( $key ) ) {
$output .= $this->field_error( $this->show_error( $key ) );
- }else if ( $this->is_notice( $key ) ) {
+ } elseif ( $this->is_notice( $key ) ) {
$output .= $this->field_notice( $this->show_notice( $key ) );
}
@@ -2422,26 +2359,25 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
/* Text */
case 'text':
-
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
if ( isset( $data['label'] ) ) {
- $output .= $this->field_label( $label, $key, $data );
+ $output .= $this->field_label( $data['label'], $key, $data );
}
$output .= '
';
- if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
+ if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons ) {
- $output .= '
';
+ $output .= '
';
}
$field_name = $key . $form_suffix;
- $field_value = $this->field_value( $key, $default, $data );
+ $field_value = $this->field_value( $key, $data['default'], $data );
$field_value = ! is_null( $field_value ) ? htmlspecialchars( $field_value ) : null;
- $output .= '
+ $output .= '
';
@@ -2460,26 +2396,25 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
/* Tel */
case 'tel':
-
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
if ( isset( $data['label'] ) ) {
- $output .= $this->field_label( $label, $key, $data );
+ $output .= $this->field_label( $data['label'], $key, $data );
}
$output .= '
';
- if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
+ if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons ) {
- $output .= '
';
+ $output .= '
';
}
$field_name = $key . $form_suffix;
- $field_value = $this->field_value( $key, $default, $data );
+ $field_value = $this->field_value( $key, $data['default'], $data );
$field_value = ! is_null( $field_value ) ? htmlspecialchars( $field_value ) : null;
- $output .= '
+ $output .= '
';
@@ -2489,7 +2424,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
if ( $this->is_error( $key ) ) {
$output .= $this->field_error( $this->show_error( $key ) );
- }else if ( $this->is_notice( $key ) ) {
+ } elseif ( $this->is_notice( $key ) ) {
$output .= $this->field_notice( $this->show_notice( $key ) );
}
@@ -2498,39 +2433,38 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
/* Number */
case 'number':
-
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
if ( isset( $data['label'] ) ) {
- $output .= $this->field_label( $label, $key, $data );
+ $output .= $this->field_label( $data['label'], $key, $data );
}
$output .= '
';
- if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
+ if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons ) {
- $output .= '
';
+ $output .= '
';
}
$number_limit = '';
- if ( isset( $min ) ) {
- $number_limit .= ' min="' . esc_attr( $min ) . '" ';
+ if ( isset( $data['min'] ) ) {
+ $number_limit .= ' min="' . esc_attr( $data['min'] ) . '" ';
}
- if ( isset( $max ) ) {
- $number_limit .= ' max="' . esc_attr( $max ) . '" ';
+ if ( isset( $data['max'] ) ) {
+ $number_limit .= ' max="' . esc_attr( $data['max'] ) . '" ';
}
- $field_value = $this->field_value( $key, $default, $data );
+ $field_value = $this->field_value( $key, $data['default'], $data );
$field_value = ! is_null( $field_value ) ? htmlspecialchars( $field_value ) : null;
- $output .= '
+ $output .= '
';
if ( $this->is_error( $key ) ) {
$output .= $this->field_error( $this->show_error( $key ) );
- }else if ( $this->is_notice( $key ) ) {
+ } elseif ( $this->is_notice( $key ) ) {
$output .= $this->field_notice( $this->show_notice( $key ) );
}
@@ -2539,34 +2473,33 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
/* Password */
case 'password':
-
$original_key = $key;
- if ( $key == 'single_user_password' ) {
+ if ( 'single_user_password' === $key ) {
$key = $original_key;
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
if ( isset( $data['label'] ) ) {
- $output .= $this->field_label( $label, $key, $data );
+ $output .= $this->field_label( $data['label'], $key, $data );
}
$output .= '
';
- if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
+ if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons ) {
- $output .= '
';
+ $output .= '
';
}
- $output .= '
+ $output .= '
';
if ( $this->is_error( $key ) ) {
$output .= $this->field_error( $this->show_error( $key ) );
- }else if ( $this->is_notice( $key ) ) {
+ } elseif ( $this->is_notice( $key ) ) {
$output .= $this->field_notice( $this->show_notice( $key ) );
}
@@ -2574,11 +2507,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
} else {
- if ( UM()->account()->current_password_is_required( 'password' ) &&
- ( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
+ if ( UM()->account()->current_password_is_required( 'password' ) && ( 'account' === $this->set_mode || um_is_core_page( 'account' ) ) ) {
- $key = 'current_' . $original_key;
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
+ $key = 'current_' . $original_key;
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
if ( isset( $data['label'] ) ) {
$output .= $this->field_label( __( 'Current Password', 'ultimate-member' ), $key, $data );
@@ -2586,13 +2518,13 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$output .= '
';
- if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
+ if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons ) {
- $output .= '
';
+ $output .= '
';
}
- $output .= '
+ $output .= '
';
@@ -2608,32 +2540,32 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$key = $original_key;
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
- if ( $this->set_mode == 'account' && um_is_core_page( 'account' ) || $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
+ if ( 'account' === $this->set_mode && um_is_core_page( 'account' ) || 'password' === $this->set_mode && um_is_core_page( 'password-reset' ) ) {
$output .= $this->field_label( __( 'New Password', 'ultimate-member' ), $key, $data );
} elseif ( isset( $data['label'] ) ) {
- $output .= $this->field_label( $label, $key, $data );
+ $output .= $this->field_label( $data['label'], $key, $data );
}
$output .= '
';
- if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
+ if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons ) {
- $output .= '
';
+ $output .= '
';
}
$name = $key . $form_suffix;
- if ( $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
+ if ( 'password' === $this->set_mode && um_is_core_page( 'password-reset' ) ) {
$name = $key;
}
- $output .= '
+ $output .= '
';
@@ -2645,84 +2577,83 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$output .= '
';
- if ( $this->set_mode != 'login' && isset( $data['force_confirm_pass'] ) && $data['force_confirm_pass'] == 1 ) {
+ if ( 'login' !== $this->set_mode && isset( $data['force_confirm_pass'] ) && 1 === $data['force_confirm_pass'] ) {
- $key = 'confirm_' . $original_key;
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
+ $key = 'confirm_' . $original_key;
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
if ( ! empty( $data['label_confirm_pass'] ) ) {
$label_confirm_pass = __( $data['label_confirm_pass'], 'ultimate-member' );
- $output .= $this->field_label( $label_confirm_pass, $key, $data );
+ $output .= $this->field_label( $label_confirm_pass, $key, $data );
} elseif ( isset( $data['label'] ) ) {
$data['label'] = __( $data['label'], 'ultimate-member' );
+ /* translators: 1: label, 2: key, 3: data. */
$output .= $this->field_label( sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] ), $key, $data );
}
$output .= '
';
- if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
+ if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons ) {
- $output .= '
';
+ $output .= '
';
}
$name = $key . $form_suffix;
- if ( $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
+ if ( 'password' === $this->set_mode && um_is_core_page( 'password-reset' ) ) {
$name = $key;
}
if ( ! empty( $label_confirm_pass ) ) {
$placeholder = $label_confirm_pass;
- } elseif( ! empty( $placeholder ) && ! isset( $data['label'] ) ) {
- $placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $placeholder );
- } elseif( isset( $data['label'] ) ) {
+ } elseif ( ! empty( $data['placeholder'] ) && ! isset( $data['label'] ) ) {
+ /* translators: 1: placeholder. */
+ $placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['placeholder'] );
+ } elseif ( isset( $data['label'] ) ) {
+ /* translators: 1: label. */
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] );
}
-
- $output .= '
';
-
+ $output .= '
';
$output .= '
';
if ( $this->is_error( $key ) ) {
$output .= $this->field_error( $this->show_error( $key ) );
- }else if ( $this->is_notice( $key ) ) {
+ } elseif ( $this->is_notice( $key ) ) {
$output .= $this->field_notice( $this->show_notice( $key ) );
}
$output .= '
';
}
-
}
break;
/* URL */
case 'url':
-
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
if ( isset( $data['label'] ) ) {
- $output .= $this->field_label( $label, $key, $data );
+ $output .= $this->field_label( $data['label'], $key, $data );
}
$output .= '
';
- if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
+ if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons ) {
- $output .= '
';
+ $output .= '
';
}
- $output .= '
+ $output .= '
';
if ( $this->is_error( $key ) ) {
$output .= $this->field_error( $this->show_error( $key ) );
- }else if ( $this->is_notice( $key ) ) {
+ } elseif ( $this->is_notice( $key ) ) {
$output .= $this->field_notice( $this->show_notice( $key ) );
}
@@ -2731,23 +2662,22 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
/* Date */
case 'date':
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
-
- if (isset( $data['label'] )) {
- $output .= $this->field_label( $label, $key, $data );
+ if ( isset( $data['label'] ) ) {
+ $output .= $this->field_label( $data['label'], $key, $data );
}
$output .= '
';
- if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
+ if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons ) {
- $output .= '
';
+ $output .= '
';
}
// Normalise date format.
- $value = $this->field_value( $key, $default, $data );
+ $value = $this->field_value( $key, $data['default'], $data );
if ( $value ) {
// numeric (either unix or YYYYMMDD). ACF uses Ymd format of date inside the meta tables.
if ( is_numeric( $value ) && strlen( $value ) !== 8 ) {
@@ -2759,13 +2689,13 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$value = date( 'Y/m/d', $unixtimestamp );
}
- $output .= '
+ $output .= '
';
if ( $this->is_error( $key ) ) {
$output .= $this->field_error( $this->show_error( $key ) );
- }else if ( $this->is_notice( $key ) ) {
+ } elseif ( $this->is_notice( $key ) ) {
$output .= $this->field_notice( $this->show_notice( $key ) );
}
@@ -2774,28 +2704,27 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
/* Time */
case 'time':
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
-
- if (isset( $data['label'] )) {
- $output .= $this->field_label( $label, $key, $data );
+ if ( isset( $data['label'] ) ) {
+ $output .= $this->field_label( $data['label'], $key, $data );
}
$output .= '
';
- if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
+ if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons ) {
- $output .= '
';
+ $output .= '
';
}
- $output .= '
+ $output .= '
';
if ( $this->is_error( $key ) ) {
$output .= $this->field_error( $this->show_error( $key ) );
- }else if ( $this->is_notice( $key ) ) {
+ } elseif ( $this->is_notice( $key ) ) {
$output .= $this->field_notice( $this->show_notice( $key ) );
}
@@ -2809,25 +2738,25 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
/* Textarea */
case 'textarea':
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
if ( isset( $data['label'] ) ) {
- $output .= $this->field_label( $label, $key, $data );
+ $output .= $this->field_label( $data['label'], $key, $data );
}
$output .= '
';
- if ( isset( $data['html'] ) && $data['html'] != 0 && 'description' !== $key ) {
+ if ( isset( $data['html'] ) && 0 !== $data['html'] && 'description' !== $key ) {
$textarea_settings = array(
'media_buttons' => false,
'wpautop' => false,
'editor_class' => $this->get_class( $key, $data ),
- 'editor_height' => $height,
+ 'editor_height' => $data['height'],
'tinymce' => array(
'toolbar1' => 'formatselect,bullist,numlist,bold,italic,underline,forecolor,blockquote,hr,removeformat,link,unlink,undo,redo',
'toolbar2' => '',
- )
+ ),
);
if ( ! empty( $disabled ) ) {
@@ -2835,24 +2764,21 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
}
/**
- * UM hook
+ * Filters change WP Editor options for textarea init.
*
- * @type filter
- * @title um_form_fields_textarea_settings
- * @description Change WP Editor options for textarea init
- * @input_vars
- * [{"var":"$textarea_settings","type":"array","desc":"WP Editor settings"}]
- * @change_log
- * ["Since: 2.0"]
- * @usage add_filter( 'um_form_fields_textarea_settings', 'function_name', 10, 1 );
- * @example
- * Change WP Editor options.
+ * function function_name( $textarea_settings ) {
* // your code here
* return $textarea_settings;
* }
- * ?>
+ * add_filter( 'um_form_fields_textarea_settings', 'function_name', 10, 1 );
*/
$textarea_settings = apply_filters( 'um_form_fields_textarea_settings', $textarea_settings );
@@ -2864,13 +2790,13 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
// add the contents of the buffer to the output variable
$output .= ob_get_clean();
- $output .= '
' . $placeholder . '';
+ $output .= '
' . $data['placeholder'] . '';
} else {
$textarea_field_value = '';
if ( ! empty( $field_value ) ) {
$textarea_field_value = ! empty( $data['html'] ) ? $field_value : wp_strip_all_tags( $field_value );
}
- $output .= '';
+ $output .= '';
}
$output .= '
';
@@ -2881,7 +2807,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
if ( $this->is_error( $key ) ) {
$output .= $this->field_error( $this->show_error( $key ) );
- }else if ( $this->is_notice( $key ) ) {
+ } elseif ( $this->is_notice( $key ) ) {
$output .= $this->field_notice( $this->show_notice( $key ) );
}
@@ -2890,15 +2816,15 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
/* Rating */
case 'rating':
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
if ( isset( $data['label'] ) ) {
- $output .= $this->field_label( $label, $key, $data );
+ $output .= $this->field_label( $data['label'], $key, $data );
}
$output .= '
';
- $output .= '
';
+ $output .= '
';
$output .= '
';
if ( $this->is_error( $key ) ) {
@@ -2913,78 +2839,76 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
/* Gap/Space */
case 'spacing':
- $output .= '
get_atts( $key, $classes, $conditional, $data, array( 'height' => $spacing ) ) . '>
';
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data, array( 'height' => $data['spacing'] ) ) . '>
';
break;
/* A line divider */
case 'divider':
- $output .= '
get_atts( $key, $classes, $conditional, $data, array( 'border-bottom' => $borderwidth . 'px ' . $borderstyle . ' ' . $bordercolor ) ) . '>';
- if ( $divider_text ) {
- $output .= '
' . esc_html( $divider_text ) . '
';
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data, array( 'border-bottom' => $data['borderwidth'] . 'px ' . $data['borderstyle'] . ' ' . $data['bordercolor'] ) ) . '>';
+ if ( $data['divider_text'] ) {
+ $output .= '
' . esc_html( $data['divider_text'] ) . '
';
}
$output .= '
';
break;
/* Single Image Upload */
case 'image':
- $output .= '
get_atts( $key, $classes, $conditional, $data ) . ' data-mode="' . esc_attr( $this->set_mode ) . '" data-upload-label="' . ( ! empty( $data['button_text'] ) ? esc_attr( $data['button_text'] ) : esc_attr__( 'Upload', 'ultimate-member' ) ) . '">';
- if ( in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
+ $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . ' data-mode="' . esc_attr( $this->set_mode ) . '" data-upload-label="' . ( ! empty( $data['button_text'] ) ? esc_attr( $data['button_text'] ) : esc_attr__( 'Upload', 'ultimate-member' ) ) . '">';
+ if ( in_array( $key, array( 'profile_photo', 'cover_photo' ), true ) ) {
$field_value = '';
} else {
- $field_value = $this->field_value( $key, $default, $data );
+ $field_value = $this->field_value( $key, $data['default'], $data );
}
$output .= '
';
if ( isset( $data['label'] ) ) {
- $output .= $this->field_label( $label, $key, $data );
+ $output .= $this->field_label( $data['label'], $key, $data );
}
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload Photo', 'ultimate-member' );
- $output .= '
';
+ $output .= '
';
- if ( ! empty( $field_value ) && $field_value != 'empty_file' ) {
- if ( ! in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
- if ( isset( $this->set_mode ) && 'register' == $this->set_mode ) {
- $image_info = get_transient("um_{$field_value}");
+ if ( ! empty( $field_value ) && 'empty_file' !== $field_value ) {
+ if ( ! in_array( $key, array( 'profile_photo', 'cover_photo' ), true ) ) {
+ if ( isset( $this->set_mode ) && 'register' === $this->set_mode ) {
+ $image_info = get_transient( "um_{$field_value}" );
} else {
- $image_info = um_user( $data['metakey']."_metadata" );
+ $image_info = um_user( $data['metakey'] . '_metadata' );
}
- if ( ( isset( $this->set_mode ) && $this->set_mode == 'register' ) || file_exists( UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $field_value ) ) {
- $imgValue = UM()->uploader()->get_core_temp_url() . "/" . $this->field_value( $key, $default, $data );
+ if ( ( isset( $this->set_mode ) && 'register' === $this->set_mode ) || file_exists( UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $field_value ) ) {
+ $img_value = UM()->uploader()->get_core_temp_url() . '/' . $this->field_value( $key, $data['default'], $data );
} else {
- $imgValue = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
+ $img_value = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
}
- $img = '

';
+ $img = '

';
} else {
$img = '';
}
- $output .= '
';
+ $output .= '
';
if ( empty( $disabled ) ) {
$output .= '
';
}
$output .= $img;
$output .= '
';
if ( empty( $disabled ) ) {
- $output .= '
' . __( 'Change photo', 'ultimate-member' ) . '';
+ $output .= '
' . __( 'Change photo', 'ultimate-member' ) . '';
}
-
-
} else {
- $output .= '
';
/* modal hidden */
if ( empty( $disabled ) ) {
- if ( ! isset( $allowed_types ) ) {
+ if ( ! isset( $data['allowed_types'] ) ) {
$allowed_types = 'gif,jpg,jpeg,png';
- } elseif ( is_array( $allowed_types ) ) {
- $allowed_types = implode( ',', $allowed_types );
+ } elseif ( is_array( $data['allowed_types'] ) ) {
+ $allowed_types = implode( ',', $data['allowed_types'] );
}
$output .= '
';
@@ -2999,8 +2923,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
}
$nonce = wp_create_nonce( 'um_upload_nonce-' . $this->timestamp );
- $output .= '
';
- $output .= '
' . $button_text . '
';
+ $output .= '
';
+ $output .= '
' . $data['button_text'] . '
';
$output .= '