- fixed PHP errors when some custom registered fields are displayed without registration;

This commit is contained in:
Mykyta Synelnikov
2024-05-20 14:23:45 +03:00
parent 7d8ef01091
commit 8208d01bf8
2 changed files with 12 additions and 14 deletions
+11 -13
View File
@@ -1513,24 +1513,24 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
return '';
}
/**
* Get field label
*
* @param string $key
* @param string $key Field meta key
*
* @return string
*/
function get_label( $key ) {
$label = '';
public function get_label( $key ) {
$label = '';
$fields = UM()->builtin()->all_user_fields;
$field_data = array_key_exists( $key, $fields ) ? $fields[ $key ] : array();
$fields = UM()->builtin()->all_user_fields;
if ( isset( $fields[ $key ]['label'] ) ) {
$label = stripslashes( $fields[ $key ]['label'] );
if ( array_key_exists( 'label', $field_data ) ) {
$label = stripslashes( $field_data['label'] );
}
if ( empty( $label ) && isset( $fields[ $key ]['title'] ) ) {
$label = stripslashes( $fields[ $key ]['title'] );
if ( empty( $label ) && array_key_exists( 'title', $field_data ) ) {
$label = stripslashes( $field_data['title'] );
}
/**
@@ -1556,13 +1556,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* }
* add_filter( 'um_change_field_label', 'my_change_field_label', 10, 3 );
*/
$label = apply_filters( 'um_change_field_label', $label, $key, $fields[ $key ] );
$label = apply_filters( 'um_change_field_label', $label, $key, $field_data );
$label = sprintf( __( '%s', 'ultimate-member' ), $label );
return $label;
return sprintf( __( '%s', 'ultimate-member' ), $label );
}
/**
* Get field title
*
+1 -1
View File
@@ -456,7 +456,7 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
$value = '<a href="' . esc_url( $value, $protocols ) . '" title="' . esc_attr( $alt ) . '" target="' . esc_attr( $data['url_target'] ) . '" ' . $url_rel . '>' . esc_html( $alt ) . '</a>';
} else {
// check $value is oEmbed
if ( 'oembed' === $data['type'] ) {
if ( array_key_exists( 'type', $data ) && 'oembed' === $data['type'] ) {
return $value;
}