diff --git a/plugin.php b/plugin.php index 821d9ef..9ca2586 100644 --- a/plugin.php +++ b/plugin.php @@ -4,7 +4,7 @@ * Plugin Name: Advanced Custom Fields: Phone Number * Plugin URI: https://github.com/log1x/acf-phone-number * Description: A real ACF phone number field. - * Version: 1.0.1 + * Version: 1.0.2 * Author: Brandon Nifong * Author URI: https://github.com/log1x */ diff --git a/src/PhoneNumber.php b/src/PhoneNumber.php index bfff00a..e7d66e4 100644 --- a/src/PhoneNumber.php +++ b/src/PhoneNumber.php @@ -71,6 +71,13 @@ public function __construct($settings) */ public function render_field($field) { + if (is_string($value = $field['value']) && ! empty(trim($value))) { + $field['value'] = [ + 'number' => $value, + 'country' => '', + ]; + } + echo sprintf( '', $field['name'], @@ -153,49 +160,4 @@ public function validate_value($valid, $value, $field, $input) return $this->phone->isValidNumber($phone) ? $valid : 'The phone number entered is not valid.'; } - - /** - * This action is fired after a value has been deleted from the database. - * - * @param mixed $post_id - * @param string $key - * @return void - */ - // public function delete_value($post_id, $key) - // { - // - // } - - /** - * This filter is applied to the $field after it is loaded from the database. - * - * @param array $field - * @return array - */ - // public function load_field($field) - // { - // return $field; - // } - - /** - * This filter is applied to the $field before it is saved to the database. - * - * @param array $field - * @return array - */ - // public function update_field($field) - // { - // return $field; - // } - - /** - * This action is fired after a field is deleted from the database. - * - * @param array $field - * @return void - */ - // public function delete_field($field) - // { - // return $field; - // } }