File Type Is Not Permitted – Cronjob

Defining ALLOW_UNFILTERED_UPLOADS isn’t enough anymore: it doesn’t grant the capability, it just permits non-admin users who have the unfiltered_uploads capability to upload any file (except on a multisite). You also need to grant yourself the capability, e.g. from Sebastian’s answer here

#
# For this, see: wp-includes/capabilities.php > map_meta_cap()
#
function wpse_6533_map_unrestricted_upload_filter($caps, $cap) {
  if ($cap == 'unfiltered_upload') {
    $caps = array();
    $caps[] = $cap;
  }

  return $caps;
}

add_filter('map_meta_cap', 'wpse_6533_map_unrestricted_upload_filter', 0, 2);

However it’s probably simpler to just enable the XML filetype for your cron job, e.g.

function mime_types_add_xml( $mime_types ) {
    // PHP's fileinfo returns text/xml not application/xml
    $mime_types[ 'xml' ] = 'text/xml';
    return $mime_types;
}
if ( defined( 'DOING_CRON' ) {
    add_filter( 'mime_types', 'mime_types_add_xml' );
}

This however will only work if your XML files have document declarations e.g.

<?xml version="1.0" encoding="utf-8"?>

WordPress uses PHP fileinfo to detect whether the file matches the extension you gave it, and that only generates text/xml for me with the declaration. (Else it’ll return text/plain, then reject the file since that doesn’t match the expected text/xml for the .xml extension.) This check can be fixed with a wp_check_filetype_and_ext filter if necessary.