/** * Check that value has a valid file extension. * * @param mixed $check Value to check * @param array $extensions file extenstions to allow * @return boolean Success * @access public */ function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) { //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188215131/comments if (!isset($check) || empty($check)) { return false; } //########################################################################################## if (is_array($check)) { return WPToolset_Cake_Validation::extension(array_shift($check), $extensions); } if (!is_array($extensions)) { $extensions = explode('|', $extensions); } $check = strtolower($check); $extension = pathinfo($check, PATHINFO_EXTENSION); foreach ($extensions as $value) { if ($extension == strtolower($value)) { return true; } } return false; }
/** * Check that value has a valid file extension. * * @param mixed $check Value to check * @param array $extensions file extenstions to allow * @return boolean Success * @access public */ function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) { if (is_array($check)) { return WPToolset_Cake_Validation::extension(array_shift($check), $extensions); } $extension = strtolower(array_pop(explode('.', $check))); foreach ($extensions as $value) { if ($extension == strtolower($value)) { return true; } } return false; }