';
- if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons ) {
+ $has_icon = ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons;
+
+ $output .= '
';
+ if ( $has_icon ) {
$output .= '
';
}
@@ -3060,21 +3078,19 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
}
if ( ! empty( $data['parent_dropdown_relationship'] ) && ! UM()->user()->preview ) {
-
- $disabled_by_parent_option = 'disabled = disabled';
-
- $has_parent_option = true;
+ $has_parent_option = true;
+ $disabled_by_parent_option = ' disabled="disabled" ';
/**
- * Filters change parent dropdown relationship by $form_key.
+ * Filters parent dropdown relationship by $form_key.
*
- * @since 2.0
+ * @since 1.3.x
* @hook um_custom_dropdown_options_parent__{$form_key}
*
* @param {string} $parent Parent dropdown relationship.
* @param {array} $data Field Data.
*
- * @return {array} $parent Parent dropdown relationship.
+ * @return {string} Parent dropdown relationship.
*
* @example
Change parent dropdown relationship.
* function function_name( $parent, $data ) {
@@ -3084,16 +3100,16 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* add_filter( 'um_custom_dropdown_options_parent__{$form_key}', 'function_name', 10, 2 );
*/
$parent_dropdown_relationship = apply_filters( "um_custom_dropdown_options_parent__{$form_key}", $data['parent_dropdown_relationship'], $data );
- $atts_ajax .= " data-um-parent='{$parent_dropdown_relationship}' ";
+ $atts_ajax .= ' data-um-parent="' . esc_attr( $parent_dropdown_relationship ) . '" ';
- if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option && function_exists( $data['custom_dropdown_options_source'] ) && um_user( $data['parent_dropdown_relationship'] ) ) {
+ if ( ! empty( $data['custom_dropdown_options_source'] ) && function_exists( $data['custom_dropdown_options_source'] ) && um_user( $data['parent_dropdown_relationship'] ) ) {
if ( ! $this->is_source_blacklisted( $data['custom_dropdown_options_source'] ) ) {
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
}
$disabled_by_parent_option = '';
if ( um_user( $form_key ) ) {
- $select_original_option_value = " data-um-original-value='" . um_user( $form_key ) . "' ";
+ $select_original_option_value = ' data-um-original-value="' . esc_attr( um_user( $form_key ) ) . '" ';
}
}
}
@@ -3105,7 +3121,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
// Child dropdown
if ( $has_parent_option ) {
- if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option && function_exists( $data['custom_dropdown_options_source'] ) && isset( UM()->form()->post_form[ $form_key ] ) ) {
+ if ( ! empty( $data['custom_dropdown_options_source'] ) && function_exists( $data['custom_dropdown_options_source'] ) && isset( UM()->form()->post_form[ $form_key ] ) ) {
if ( ! $this->is_source_blacklisted( $data['custom_dropdown_options_source'] ) ) {
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
}
@@ -3113,19 +3129,18 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
}
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
-
/**
- * Filters change custom dropdown options source by $form_key.
+ * Filters a custom dropdown options source by $form_key.
*
- * @since 2.0
+ * @since 1.3.x
* @hook um_custom_dropdown_options_source__{$form_key}
*
- * @param {string} $source Dropdown options source.
- * @param {array} $data Field Data.
+ * @param {string} $source Dropdown options source.
+ * @param {array} $data Field Data.
*
- * @return {array} $source Parent dropdown relationship.
+ * @return {string} Dropdown options source.
*
- * @example
Change custom dropdown options.
+ * @example
Change custom dropdown options source.
* function function_name( $source, $data ) {
* // your code here
* return $source;
@@ -3134,50 +3149,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
*/
$ajax_source = apply_filters( "um_custom_dropdown_options_source__{$form_key}", $data['custom_dropdown_options_source'], $data );
$atts_ajax .= ' data-um-ajax-source="' . esc_attr( $ajax_source ) . '" ';
-
- /**
- * Filters change custom dropdown options source by $form_key.
- *
- * @since 2.0
- * @hook um_custom_dropdown_options_source_url__{$form_key}
- *
- * @param {string} $url Dropdown options source URL.
- * @param {array} $data Field Data.
- *
- * @return {array} $url Parent dropdown relationship.
- *
- * @example
Change custom dropdown options.
- * function my_custom_dropdown_options_source_url( $url, $data ) {
- * // your code here
- * return $url;
- * }
- * add_filter( 'um_custom_dropdown_options_source_url__{$form_key}', 'my_custom_dropdown_options_source_url', 10, 2 );
- */
- // todo maybe deprecate
-// $ajax_source_url = apply_filters( "um_custom_dropdown_options_source_url__{$form_key}", admin_url( 'admin-ajax.php' ), $data );
-// $atts_ajax .= ' data-um-ajax-url="' . esc_url( $ajax_source_url ) . '" ';
-
}
- /**
- * Filters enable options pairs by field $key.
- *
- * @since 2.0
- * @hook um_fields_options_enable_pairs__{$key}
- *
- * @param {string} $options_pairs Enable pairs.
- *
- * @return {string} $options_pairs Enable pairs.
- *
- * @example
Enable options pairs.
- * function my_fields_options_enable_pairs( $options_pairs ) {
- * // your code here
- * return $options_pairs;
- * }
- * add_filter( 'um_fields_options_enable_pairs__{$key}', 'my_fields_options_enable_pairs', 10, 1 );
- */
- $enable_options_pair = apply_filters( "um_fields_options_enable_pairs__{$key}", false );
-
if ( ! $has_parent_option ) {
if ( isset( $options ) && 'builtin' === $options ) {
$options = UM()->builtin()->get( $data['filter'] );
@@ -3190,19 +3163,36 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$options = $data['options'];
}
+ /**
+ * Filters dropdown options.
+ *
+ * @since 2.0
+ * @hook um_selectbox_options
+ *
+ * @param {array} $options Field options.
+ * @param {string} $key Field metakey.
+ *
+ * @return {array} Field options.
+ *
+ * @example
Extend dropdown options.
+ * function my_um_selectbox_options( $options, $key ) {
+ * // your code here
+ * return $options;
+ * }
+ * add_filter( 'um_selectbox_options', 'my_um_selectbox_options', 10, 2 );
+ */
$options = apply_filters( 'um_selectbox_options', $options, $key );
-
if ( isset( $options ) ) {
/**
- * Filters extend dropdown dynamic options.
+ * Filters dropdown dynamic options.
*
- * @since 2.0
+ * @since 1.3.x
* @hook um_select_dropdown_dynamic_options
*
- * @param {array} $options Dynamic options.
- * @param {array} $data Field Data.
+ * @param {array} $options Dynamic options.
+ * @param {array} $data Field Data.
*
- * @return {array} $options Dynamic options.
+ * @return {array} Dynamic options.
*
* @example
Extend dropdown dynamic options.
* function my_select_dropdown_dynamic_options( $options, $data ) {
@@ -3212,16 +3202,15 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* add_filter( 'um_select_dropdown_dynamic_options', 'my_select_dropdown_dynamic_options', 10, 2 );
*/
$options = apply_filters( 'um_select_dropdown_dynamic_options', $options, $data );
-
/**
- * Filters extend dropdown dynamic options by field $key.
+ * Filters dropdown dynamic options by field $key.
*
- * @since 2.0
+ * @since 1.3.x
* @hook um_select_dropdown_dynamic_options_{$key}
*
- * @param {array} $options Dynamic options.
+ * @param {array} $options Dynamic options.
*
- * @return {array} $options Dynamic options.
+ * @return {array} Dynamic options.
*
* @example
Extend dropdown dynamic options by field $key.
* function my_select_dropdown_dynamic_options( $options ) {
@@ -3244,10 +3233,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* @since 2.0
* @hook um_select_options_pair
*
- * @param {string} $options_pair Enable pairs.
- * @param {array} $data Field Data.
+ * @param {bool|null} $options_pair Enable pairs.
+ * @param {array} $data Field Data.
*
- * @return {array} $options_pair Enable pairs.
+ * @return {bool} Enable pairs.
*
* @example
Enable options pair.
* function my_um_select_options_pair( $options_pair, $data ) {
@@ -3258,21 +3247,14 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
*/
$options_pair = apply_filters( 'um_select_options_pair', null, $data );
- // switch options pair for custom options from a callback function
+ // Switch options pair for custom options from a callback function.
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
$options_pair = true;
}
$field_value = '';
- if ( ! empty( $data['placeholder'] ) && is_string( $data['placeholder'] ) ) {
- $placeholder = strip_tags( $data['placeholder'] );
- } else {
- $placeholder = '';
- }
-
- $output .= '
';
break;
-
/* Multi-Select dropdown */
case 'multiselect':
- $max_selections = ( isset( $data['max_selections'] ) ) ? absint( $data['max_selections'] ) : 0;
+ $options = array();
+ if ( isset( $data['options'] ) && is_array( $data['options'] ) ) {
+ $options = $data['options'];
+ }
+ $max_selections = isset( $data['max_selections'] ) ? absint( $data['max_selections'] ) : 0;
- $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
+ $field_id = $key;
+ $field_name = $key;
+ $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
+
+ $class = 'um-s1';
if ( isset( $data['allowclear'] ) && 0 === $data['allowclear'] ) {
$class = 'um-s2';
- } else {
- $class = 'um-s1';
}
if ( isset( $data['label'] ) ) {
$output .= $this->field_label( $data['label'], $key, $data );
}
- $field_icon = false;
- $field_icon_output = '';
-
/**
- * Filters change multiselect keyword data.
+ * Filters multiselect keyword data.
*
- * @since 2.0
+ * @since 1.3.x
* @hook um_multiselect_option_value
*
- * @param {int} $keyword Option Value.
- * @param {string} $type Field Type.
+ * @param {int} $keyword If 1 - keyword is enabled. It's 0 by default.
+ * @param {string} $type Field Type.
*
- * @return {int} $keyword Option Value.
+ * @return {int} Enabled keyword.
*
- * @example
Change multiselect keyword data.
+ * @example
Change multiselect keyword data. Enable it.
* function my_multiselect_option_value( $keyword, $type ) {
* // your code here
+ * $keyword = 1;
* return $keyword;
* }
* add_filter( 'um_multiselect_option_value', 'my_multiselect_option_value', 10, 2 );
*/
- $use_keyword = apply_filters( 'um_multiselect_option_value', 0, $data['type'] );
+ $use_keyword = apply_filters( 'um_multiselect_option_value', 0, $type );
- $output .= '
';
- if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons ) {
+ $has_icon = ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'field' === $this->field_icons;
+
+ $output .= '
';
+ if ( $has_icon ) {
$output .= '
';
}
- $output .= '
';
+ $output .= '';
if ( isset( $options ) && 'builtin' === $options ) {
$options = UM()->builtin()->get( $data['filter'] );
@@ -3383,15 +3368,15 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
if ( isset( $options ) ) {
/**
- * Filters extend multiselect options.
+ * Filters multiselect options.
*
- * @since 2.0
+ * @since 1.3.x
* @hook um_multiselect_options
*
- * @param {array} $options Multiselect Options.
- * @param {array} $data Field Data.
+ * @param {array} $options Multiselect Options.
+ * @param {array} $data Field Data.
*
- * @return {array} $options Multiselect Options.
+ * @return {array} Multiselect Options.
*
* @example Extend multiselect options.
* function my_multiselect_options( $options, $data ) {
@@ -3401,11 +3386,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* add_filter( 'um_multiselect_options', 'my_multiselect_options', 10, 2 );
*/
$options = apply_filters( 'um_multiselect_options', $options, $data );
-
/**
- * Filters extend multiselect options by field $key.
+ * Filters multiselect options by field $key.
*
- * @since 2.0
+ * @since 1.3.x
* @hook um_multiselect_options_{$key}
*
* @param {array} $options Multiselect Options.
@@ -3420,17 +3404,16 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* add_filter( 'um_multiselect_options_{$key}', 'my_multiselect_options', 10, 2 );
*/
$options = apply_filters( "um_multiselect_options_{$key}", $options );
-
/**
- * Filters extend multiselect options by field $type.
+ * Filters multiselect options by field $type.
*
- * @since 2.0
+ * @since 1.3.x
* @hook um_multiselect_options_{$type}
*
- * @param {array} $options Multiselect Options.
- * @param {array} $data Field Data.
+ * @param {array} $options Multiselect Options.
+ * @param {array} $data Field Data.
*
- * @return {array} $options Multiselect Options.
+ * @return {array} Multiselect Options.
*
* @example Extend multiselect options.
* function my_multiselect_options( $options, $data ) {
@@ -3442,32 +3425,15 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$options = apply_filters( "um_multiselect_options_{$type}", $options, $data );
}
- /**
- * Filters enable options pair by field $data.
- *
- * @since 2.0
- * @hook um_multiselect_options_{$type}
- *
- * @param {null} $options_pair Enable pairs.
- * @param {array} $data Field Data.
- *
- * @return {array} $options_pair Enable pairs.
- *
- * @example Enable options pair.
- * function my_um_select_options_pair( $options_pair, $data ) {
- * // your code here
- * return $options_pair;
- * }
- * add_filter( 'um_select_options_pair', 'my_um_select_options_pair', 10, 2 );
- */
+ /** This filter is documented in includes/core/class-fields.php */
$use_keyword = apply_filters( 'um_select_options_pair', null, $data );
- // switch options pair for custom options from a callback function
+ // Switch options pair for custom options from a callback function.
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
$use_keyword = true;
}
- // add an empty option!
+ // Add an empty option!
$output .= '';
$arr_selected = array();
@@ -3481,20 +3447,19 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$opt_value = $v;
if ( $use_keyword ) {
- $um_field_checkbox_item_title = $v;
- $opt_value = $k;
+ $opt_value = $k;
}
$opt_value = $this->filter_field_non_utf8_value( $opt_value );
- $output .= '';
+ $output .= '>' . esc_html__( $um_field_checkbox_item_title, 'ultimate-member' ) . '';
}
}
@@ -3517,24 +3482,25 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$output .= '';
break;
-
/* Radio */
case 'radio':
+ $form_key = str_replace( array( 'role_select', 'role_radio' ), 'role', $key );
+
$options = array();
if ( isset( $data['options'] ) && is_array( $data['options'] ) ) {
$options = $data['options'];
}
/**
- * Filters extend radio field options.
+ * Filters radio field options.
*
- * @since 2.0
+ * @since 1.3.x
* @hook um_radio_field_options
*
- * @param {array} $options Radio Field Options.
- * @param {array} $data Field Data.
+ * @param {array} $options Radio Field Options.
+ * @param {array} $data Field Data.
*
- * @return {array} $options Radio Field Options.
+ * @return {array} Radio Field Options.
*
* @example
Extend radio field options.
* function my_radio_field_options( $options, $data ) {
@@ -3544,16 +3510,15 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* add_filter( 'um_radio_field_options', 'my_radio_field_options', 10, 2 );
*/
$options = apply_filters( 'um_radio_field_options', $options, $data );
-
/**
- * Filters extend radio field options by field $key.
+ * Filters radio field options by field $key.
*
- * @since 2.0
+ * @since 1.3.x
* @hook um_radio_field_options_{$key}
*
- * @param {array} $options Radio Field Options.
+ * @param {array} $options Radio Field Options.
*
- * @return {array} $options Radio Field Options.
+ * @return {array} Radio Field Options.
*
* @example
Extend radio field options.
* function my_radio_field_options( $options ) {
@@ -3563,8 +3528,9 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* add_filter( 'um_radio_field_options_{$key}', 'my_radio_field_options', 10, 1 );
*/
$options = apply_filters( "um_radio_field_options_{$key}", $options );
+ $options = $this->get_available_roles( $form_key, $options );
- $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
+ $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
if ( isset( $data['label'] ) ) {
$output .= $this->field_label( $data['label'], $key, $data );
@@ -3572,9 +3538,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$output .= '
';
- $options = $this->get_available_roles( $form_key, $options );
-
- // add options
+ // Add options.
$i = 0;
$field_value = array();
@@ -3584,10 +3548,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* @since 2.0
* @hook um_radio_options_pair__{$key}
*
- * @param {null} $options_pair Enable pairs.
- * @param {array} $data Field Data.
+ * @param {bool} $options_pair Enable pairs.
+ * @param {array} $data Field Data.
*
- * @return {array} $options_pair Enable pairs.
+ * @return {bool} Enable pairs.
*
* @example
Enable options pair.
* function my_radio_field_options( $options ) {
@@ -3606,14 +3570,12 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$um_field_checkbox_item_title = $v;
$option_value = $v;
- if ( ! is_numeric( $k ) && in_array( $form_key, array( 'role' ), true ) || ( 'account' === $this->set_mode || um_is_core_page( 'account' ) ) ) {
- $um_field_checkbox_item_title = $v;
- $option_value = $k;
+ if ( ( ! is_numeric( $k ) && 'role' === $form_key ) || ( 'account' === $this->set_mode || um_is_core_page( 'account' ) ) ) {
+ $option_value = $k;
}
if ( $options_pair ) {
- $um_field_checkbox_item_title = $v;
- $option_value = $k;
+ $option_value = $k;
}
$i++;
@@ -3639,7 +3601,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$option_value = $this->filter_field_non_utf8_value( $option_value );
- $output .= 'is_radio_checked( $key, $option_value, $data ) ) {
$output .= 'checked';
@@ -3676,7 +3638,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$output .= '';
break;
-
/* Checkbox */
case 'checkbox':
$options = array();
@@ -3685,15 +3646,15 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
}
/**
- * Filters extend checkbox options.
+ * Filters checkbox options.
*
- * @since 2.0
+ * @since 1.3.x
* @hook um_checkbox_field_options
*
- * @param {array} $options Checkbox Options.
- * @param {array} $data Field Data.
+ * @param {array} $options Checkbox Options.
+ * @param {array} $data Field Data.
*
- * @return {array} $options Checkbox Options.
+ * @return {array} Checkbox Options.
*
* @example
Extend checkbox options.
* function um_checkbox_field_options( $options, $data ) {
@@ -3703,16 +3664,15 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* add_filter( 'um_checkbox_field_options', 'um_checkbox_field_options', 10, 2 );
*/
$options = apply_filters( 'um_checkbox_field_options', $options, $data );
-
/**
- * Filters extend checkbox options by field $key.
+ * Filters checkbox options by field $key.
*
- * @since 2.0
+ * @since 1.3.x
* @hook um_checkbox_field_options_{$key}
*
- * @param {array} $options Checkbox Options.
+ * @param {array} $options Checkbox Options.
*
- * @return {array} $options Checkbox Options.
+ * @return {array} Checkbox Options.
*
* @example
Extend checkbox options.
* function my_checkbox_options( $options ) {
@@ -3723,7 +3683,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
*/
$options = apply_filters( "um_checkbox_field_options_{$key}", $options );
- $output .= '
get_atts( $key, $classes, $data['conditional'], $data ) . '>';
+ $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
if ( isset( $data['label'] ) ) {
$output .= $this->field_label( $data['label'], $key, $data );
@@ -3731,9 +3691,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$output .= '
';
- // add options
+ // Add options.
$i = 0;
-
foreach ( $options as $k => $v ) {
$v = rtrim( $v );
@@ -3781,15 +3740,15 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
/**
* Filters change Checkbox item title.
*
- * @since 2.0
+ * @since 1.3.x
* @hook um_field_checkbox_item_title
*
- * @param {array} $um_field_checkbox_item_title Item Title.
- * @param {string} $key Field Key.
- * @param {string} $v Field Value.
- * @param {array} $data Field Data.
+ * @param {string} $um_field_checkbox_item_title Item Title.
+ * @param {string} $key Field Key.
+ * @param {string} $v Field Value.
+ * @param {array} $data Field Data.
*
- * @return {array} $um_field_checkbox_item_title Item Title.
+ * @return {string} Item Title.
*
* @example
Change Checkbox item title.
* function um_checkbox_field_options( $um_field_checkbox_item_title, $key, $v, $data ) {
@@ -3800,7 +3759,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
*/
$um_field_checkbox_item_title = apply_filters( 'um_field_checkbox_item_title', $um_field_checkbox_item_title, $key, $v, $data );
- $output .= '' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '';
+ $output .= '' . esc_html__( $um_field_checkbox_item_title, 'ultimate-member' ) . '';
$output .= '';
if ( 0 === $i % 2 ) {
@@ -3819,10 +3778,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$output .= '';
break;
-
/* HTML */
case 'block':
$content = array_key_exists( 'content', $data ) ? $data['content'] : '';
+ // @todo WP_KSES for $content
$output .= '
get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '
';
break;
/* Shortcode */
@@ -3830,7 +3789,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$content = array_key_exists( 'content', $data ) ? $data['content'] : '';
$content = str_replace( '{profile_id}', um_profile_id(), $content );
$content = apply_shortcodes( $content );
-
+ // @todo WP_KSES for $content
$output .= '
get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '
';
break;
/* Unlimited Group */
@@ -3838,7 +3797,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$fields = $this->get_fields_in_group( $key );
if ( ! empty( $fields ) ) {
- $output .= '
+ $output .= '
' . esc_html__( $data['label'], 'ultimate-member' ) . '
';
$output .= '
';
@@ -3879,7 +3838,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
return $output;
}
-
/**
* Filter for user roles
*
@@ -4278,7 +4236,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$_field_value = $this->field_value( $key, $default, $data );
if ( ( isset( $_field_value ) && '' !== $_field_value ) || in_array( $type, $fields_without_metakey, true ) ) {
- $output .= '
get_atts( $key, $classes, $conditional, $data ) ) . '>';
+ $output .= '
get_atts( $key, $classes, $conditional, $data ) . '>';
if ( isset( $data['label'] ) || ! empty( $data['icon'] ) ) {
diff --git a/includes/core/class-shortcodes.php b/includes/core/class-shortcodes.php
index 3b15dbeb..f1b6bb78 100644
--- a/includes/core/class-shortcodes.php
+++ b/includes/core/class-shortcodes.php
@@ -297,16 +297,23 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
if ( isset( $this->set_args ) && is_array( $this->set_args ) ) {
$args = $this->set_args;
- unset( $args['file'] );
- unset( $args['theme_file'] );
- unset( $args['tpl'] );
+ unset( $args['file'], $args['theme_file'], $args['tpl'] );
$args = apply_filters( 'um_template_load_args', $args, $tpl );
- extract( $args );
+ /*
+ * This use of extract() cannot be removed. There are many possible ways that
+ * templates could depend on variables that it creates existing, and no way to
+ * detect and deprecate it.
+ *
+ * Passing the EXTR_SKIP flag is the safest option, ensuring globals and
+ * function variables cannot be overwritten.
+ */
+ // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
+ extract( $args, EXTR_SKIP );
}
- $file = um_path . "templates/{$tpl}.php";
+ $file = UM_PATH . "templates/{$tpl}.php";
$theme_file = get_stylesheet_directory() . "/ultimate-member/templates/{$tpl}.php";
if ( file_exists( $theme_file ) ) {
$file = $theme_file;
diff --git a/includes/core/um-actions-form.php b/includes/core/um-actions-form.php
index 3c4eae9f..e8eea188 100644
--- a/includes/core/um-actions-form.php
+++ b/includes/core/um-actions-form.php
@@ -416,8 +416,8 @@ function um_check_conditions_on_submit( $condition, $fields, $args, $reset = fal
*/
function um_submit_form_errors_hook_( $args ) {
$form_id = $args['form_id'];
- $mode = $args['mode'];
- $fields = unserialize( $args['custom_fields'] );
+ $mode = $args['mode'];
+ $fields = unserialize( $args['custom_fields'] );
$um_profile_photo = um_profile('profile_photo');
if ( get_post_meta( $form_id, '_um_profile_photo_required', true ) && ( empty( $args['profile_photo'] ) && empty( $um_profile_photo ) ) ) {
@@ -425,12 +425,12 @@ function um_submit_form_errors_hook_( $args ) {
}
if ( ! empty( $fields ) ) {
-
- $can_edit = false;
- $current_user_roles = [];
+ $can_edit = false;
+ $current_user_roles = array();
if ( is_user_logged_in() ) {
-
- $can_edit = UM()->roles()->um_current_user_can( 'edit', $args['user_id'] );
+ if ( array_key_exists( 'user_id', $args ) ) {
+ $can_edit = UM()->roles()->um_current_user_can( 'edit', $args['user_id'] );
+ }
um_fetch_user( get_current_user_id() );
$current_user_roles = um_user( 'roles' );
@@ -439,7 +439,7 @@ function um_submit_form_errors_hook_( $args ) {
foreach ( $fields as $key => $array ) {
- if ( $mode == 'profile' ) {
+ if ( 'profile' === $mode ) {
$restricted_fields = UM()->fields()->get_restricted_fields_for_edit();
if ( is_array( $restricted_fields ) && in_array( $key, $restricted_fields ) ) {
continue;
@@ -447,7 +447,7 @@ function um_submit_form_errors_hook_( $args ) {
}
$can_view = true;
- if ( isset( $array['public'] ) && $mode != 'register' ) {
+ if ( isset( $array['public'] ) && 'register' !== $mode ) {
switch ( $array['public'] ) {
case '1': // Everyone
@@ -491,7 +491,6 @@ function um_submit_form_errors_hook_( $args ) {
continue;
}
-
/**
* UM hook
*