diff --git a/includes/admin/core/class-admin-metabox.php b/includes/admin/core/class-admin-metabox.php index 8773ee3b..e600797b 100644 --- a/includes/admin/core/class-admin-metabox.php +++ b/includes/admin/core/class-admin-metabox.php @@ -40,6 +40,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { function __construct() { $this->in_edit = false; $this->edit_mode_value = null; + $this->edit_array = []; add_action( 'admin_head', array( &$this, 'admin_head' ), 9); add_action( 'admin_footer', array( &$this, 'load_modal_content' ), 9); @@ -1233,7 +1234,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { if ( $this->in_edit == true ) { // we're editing a field $real_attr = substr( $attribute, 1 ); - $this->edit_mode_value = (isset( $this->edit_array[ $real_attr ] ) ) ? $this->edit_array[ $real_attr ] : null; + $this->edit_mode_value = isset( $this->edit_array[ $real_attr ] ) ? $this->edit_array[ $real_attr ] : null; } switch ( $attribute ) { diff --git a/includes/core/class-roles-capabilities.php b/includes/core/class-roles-capabilities.php index 45264c6a..233e7cec 100644 --- a/includes/core/class-roles-capabilities.php +++ b/includes/core/class-roles-capabilities.php @@ -32,7 +32,7 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) { function um_on_roles_update( $option, $old_value, $value ) { global $wp_roles; - if ( isset( $wp_roles->role_key ) && $option == $wp_roles->role_key ) { + if ( is_object( $wp_roles ) && isset( $wp_roles->role_key ) && $option == $wp_roles->role_key ) { foreach ( $value as $role_key => $role_data ) { $role_keys = get_option( 'um_roles', array() ); $role_keys = array_map( function( $item ) { diff --git a/includes/core/um-actions-form.php b/includes/core/um-actions-form.php index 54e9354b..ef85d941 100644 --- a/includes/core/um-actions-form.php +++ b/includes/core/um-actions-form.php @@ -536,13 +536,21 @@ function um_submit_form_errors_hook_( $args ) { if ( isset( $array['min_chars'] ) && $array['min_chars'] > 0 ) { if ( $args[ $key ] && strlen( utf8_decode( $args[ $key ] ) ) < $array['min_chars'] ) { - UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain at least %s characters', 'ultimate-member' ), $array['label'], $array['min_chars'] ) ); + if ( empty( $array['label'] ) ) { + UM()->form()->add_error( $key, sprintf( __( 'This field must contain at least %s characters', 'ultimate-member' ), $array['min_chars'] ) ); + } else { + UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain at least %s characters', 'ultimate-member' ), $array['label'], $array['min_chars'] ) ); + } } } if ( isset( $array['max_chars'] ) && $array['max_chars'] > 0 ) { if ( $args[ $key ] && strlen( utf8_decode( $args[ $key ] ) ) > $array['max_chars'] ) { - UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain less than %s characters', 'ultimate-member' ), $array['label'], $array['max_chars'] ) ); + if ( empty( $array['label'] ) ) { + UM()->form()->add_error( $key, sprintf( __( 'This field must contain less than %s characters', 'ultimate-member' ), $array['max_chars'] ) ); + } else { + UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain less than %s characters', 'ultimate-member' ), $array['label'], $array['max_chars'] ) ); + } } }