function __construct()
{
// Upload size limit is 1GB
add_filter('upload_size_limit', function () {
return 1073741824;
// pow( 2, 30 )
});
// Hooks for the mu-plugin WordPress Importer
add_filter('load-importer-wordpress', array(&$this, 'check_to_download_file'), 10);
add_filter('wp_insert_attachment_data', array(&$this, 'check_to_upload_file'), 10, 2);
// WP 4.5 introduced a new filter, which simplifies how we generate unique filenames
// We retain test sites on the version that precedes the current stable release, making this necessary
global $wp_version;
if (version_compare($wp_version, '4.5', '>=')) {
add_filter('wp_unique_filename', array($this, 'filter_unique_filename'), 10, 4);
add_filter('wp_check_filetype_and_ext', array($this, 'filter_filetype_check'), 10, 4);
} else {
add_filter('wp_handle_upload_prefilter', array(&$this, 'get_unique_filename'), 10, 1);
add_filter('wp_handle_sideload_prefilter', array(&$this, 'get_unique_filename'), 10, 1);
}
add_filter('upload_dir', array(&$this, 'get_upload_dir'), 10, 1);
add_filter('wp_handle_upload', array(&$this, 'upload_file'), 10, 2);
add_filter('wp_delete_file', array(&$this, 'delete_file'), 20, 1);
add_filter('wp_save_image_file', array(&$this, 'save_image_file'), 10, 5);
add_filter('wp_save_image_editor_file', array(&$this, 'save_image_file'), 10, 5);
add_filter('image_downsize', array(&$this, 'image_resize'), 5, 3);
// Ensure this runs before Jetpack, when Photon is active
// Automatic creation of intermediate image sizes is disabled via `wpcom_intermediate_sizes()`
// ensure we always upload with year month folder layouts
add_filter('pre_option_uploads_use_yearmonth_folders', function ($arg) {
return '1';
});
// ensure the correct upload URL is used even after switch_to_blog is called
add_filter('option_upload_url_path', array($this, 'upload_url_path'), 10, 2);
}