Skip to content

Commit

Permalink
v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x committed Aug 12, 2020
1 parent ab99a77 commit 7fc7538
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.4
* Version: 1.0.5
* Author: Brandon Nifong
* Author URI: https://github.com/log1x
*/
Expand Down
19 changes: 18 additions & 1 deletion src/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@ public function format_value($value, $post_id, $field)
]);
}

/**
* This filter is applied to the $value before it is saved in the database.
*
* @param mixed $value
* @param mixed $post_id
* @param array $field
* @return mixed
*/
public function update_value($value, $post_id, $field)
{
if (! is_array($value) || empty($value['number'])) {
return;
}

return $value;
}

/**
* This filter is used to perform validation on the value prior to saving.
*
Expand All @@ -144,7 +161,7 @@ public function format_value($value, $post_id, $field)
public function validate_value($valid, $value, $field, $input)
{
if (! is_array($value) || empty($value['number'])) {
return 'The phone number entered is not valid.';
return $valid;
}

if (empty($value['country'])) {
Expand Down

0 comments on commit 7fc7538

Please sign in to comment.