<?php

class Wiaas_Admin_Profile {

    public static function init() {
        add_filter( 'user_contactmethods', array(__CLASS__, 'modify_user_contact_methods') );

        add_action( 'user_profile_update_errors', array(__CLASS__, 'crf_user_profile_update_errors'), 10, 3 );

    }

    public static function crf_user_profile_update_errors( $errors, $update, $user ) {

        $phone = $_POST['phone'];

        if (!Wiaas_Validation::is_phone($phone)){
            $errors->add('phone_error', __( '<strong>ERROR</strong>: Enter valid phone number.', 'crf' ));
        };

    }

    public static function modify_user_contact_methods($user_contact){
        $user_contact['phone'] = __( 'Phone number' );

        return $user_contact;
    }


}

Wiaas_Admin_Profile::init();