Last active
December 9, 2016 04:48
-
-
Save sbruner/d5d52d9a2fc1ae26968ea40231fb3228 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Create a validation rule called "my_file_exists" | |
add_filter('piklist_validation_rules', 'check_file_exists', 11); | |
function check_file_exists($validation_rules) | |
{ | |
$validation_rules['my_file_exists'] = array( | |
'callback' => 'my_validate_file_exists' | |
); | |
return $validation_rules; | |
} | |
/** | |
* @param int $index The field index being checked. | |
* @param mixed $value The value of the field. | |
* @param array $options The options. | |
* @param array $field The field object. | |
* @param array $fields Collection of fields. | |
*/ | |
function my_validate_file_exists($index, $value, $options, $field, $fields) | |
{ | |
return @file_get_contents($value) ? true : 'contains a file that does not exist.'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment