Filtering input data
I suggest you should use a configuration array like this:

 $config = [
      ip =&gt; FILTER_VALIDATE_IP,
      email=&gt; FILTER_VALIDATE_EMAIL
 ]


and simplify the code like this:

if(in_array($config, $data_type)) {
     if($filter_VAR($data, $config[$data_type]) {
          $output = $data;
     }
}



In your code, length is checked only if both min and max are set. Is it the expected behavior? In some cases, only min or max checks are required.
Generally, you should avoid repeating code, in favor of calling functions. This makes it more readable. Plus, you can create test cases for small functions with predictable results, rather that a big complicated thing.
With security I have no idea what this function is designed to protect against.